Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set an environmental variable on my target board using a yocto recipe?

I would like to create an environmental variable called BOARD that is set to the physical board type from a Yocto recipe. This variable will not be used during the actual installation of recipes. I would also like to modify the HOME variable. These variables need to be accessible on the board after it is booted. What is the best of doing so?

I have tried using export but realized that this command doesn't affect the parent shell. I have read about modifying the dot.profile file, but I don't want to hard code a variable. I would like it to dynamically alter the variable depending on what MACHINE variable was used to run bitbake.

For example in the dot.profile file:

export BOARD = "${MACHINE}"

However, MACHINE doesn't seem to be accessible.

like image 435
vinayksk Avatar asked Sep 05 '25 16:09

vinayksk


1 Answers

You can add something like this in image recipe or local.conf:

set_board_env(){
    mkdir -p ${IMAGE_ROOTFS}/etc/profile.d 
    echo "export BOARD=${MACHINE}" > ${IMAGE_ROOTFS}/etc/profile.d/set_board_env.sh
}

ROOTFS_POSTPROCESS_COMMAND += "set_board_env;"
like image 178
Nayfe Avatar answered Sep 09 '25 17:09

Nayfe