Uploaded February 2025 | Updated September 2026, 2 weeks ago
In the previous episode on the Yocto Project and OpenEmbedded for Raspberry Pi 5, we switched to the open-source U-Boot bootloader. In this follow-up, episode 5, I will demonstrate how to view and modify U-Boot environment variables from Linux user space using the fw_printenv and fw_setenv tools from libubootenv. U-Boot (Das U-Boot) is a widely used open-source bootloader for embedded systems, initializing hardware and loading the OS kernel. Supporting multiple architectures like ARM, x86, and RISC-V, it offers networking, storage access, and scripting capabilities for system configuration. Its flexibility and extensive hardware support make it a key component in Linux-based embedded devices. The demonstrations in this video are made possible by the community-driven Yocto/OpenEmbedded BSP layer meta-raspberrypi. My build setup is based on the Yocto LTS release Scarthgap, which defaults to U-Boot v2024.01. However, Raspberry Pi 5 support was only introduced in U-Boot v2024.04. To address this in the previous video, we used the scarthgap/u-boot branch of the Yocto/OE layer meta-lts-mixins. Follow the steps below to add a single line to your existing local.conf and modify U-Boot variables on Raspberry Pi 5:
* Initialize the build environment:
source oe-init-build-env
* Add the following line to conf/local.conf:
IMAGE_INSTALL:append = " u-boot-fw-utils u-boot-env"
* Build the image:
bitbake core-image-base
* Flash core-image-base on a microSD card and boot the Raspberry Pi 5 with it
* Quickly press any key to interrupt U-Boot when prompted and in the U-Boot shell enter the following command to list available variables:
printenv
* Create a new U-Boot environment variable:
set env hello world
* Carry on and boot the Linux distribution by executing (optionally you can execute saveenv although it is not needed for the particular demo as explained in the video):
boot
* Login as root and execute the following command to list all U-Boot environment variables from Linux user space:
fw_printenv hello
* From Linux user space change the value of U-Boot env variable hello to world2:
fw_setenv hello world2
* From Linux user space create a new U-Boot env variable foo:
fw_setenv foo bar
* Reboot the Raspberry Pi 5, again interrupt U-Boot and check the value of U-Boot env variables hello and foo using fw_printenv.
🔗 Related Videos
===
Episode 1: The Yocto Project on Raspberry Pi 5: Building an Embedded GNU Linux Distribution
youtu.be/fY7u6PiV8qA?si=-DgvkJ_yTsiX05vx
Episode 2: SSH for Remote Network Access
youtu.be/ltckiBV9FXg?si=DJwsKLDhHkDIqCIn
Episode 3: The Yocto Project on Raspberry Pi 5 Episode 3: Running Docker Containers
youtu.be/kQnOidK_U3M?si=5KiS1FK87OwfdQ0m
Episode 4: The Yocto Project on Raspberry Pi 5 Episode 4: U-Boot Bootloader
youtu.be/9tohomiv1Ug?si=QydN1yPRJzY6zEfz
Episode 6: Runtime Package Management with apt and deb Packages
youtu.be/6i5UtF7fiaA?si=8DuUHUxywVEEtdyN
Episode 7: Create a New Layer, a New Recipe (.bb) and .bbappend
youtu.be/W5J1W_Cy14Y?si=ftu5WpeGqel8BZhf
📚 Useful Links
===
yoctoproject.org
docs.yoctoproject.org
openembedded.org/wiki/Main_Page
meta-raspberrypi.readthedocs.io/en/latest/extra-build-config.html#boot-to-u-boot
docs.u-boot.org
github.com/sbabic/libubootenv
anavi.org/article/303
In the previous episode on the Yocto Project and OpenEmbedded for Raspberry Pi 5, we switched to the open-source U-Boot bootloader. In this follow-up, episode 5, I will demonstrate how to view and modify U-Boot environment variables from Linux user space using the fw_printenv and fw_setenv tools from libubootenv. U-Boot (Das U-Boot) is a widely used open-source bootloader for embedded systems, initializing hardware and loading the OS kernel. Supporting multiple architectures like ARM, x86, and RISC-V, it offers networking, storage access, and scripting capabilities for system configuration. Its flexibility and extensive hardware support make it a key component in Linux-based embedded devices. The demonstrations in this video are made possible by the community-driven Yocto/OpenEmbedded BSP layer meta-raspberrypi. My build setup is based on the Yocto LTS release Scarthgap, which defaults to U-Boot v2024.01. However, Raspberry Pi 5 support was only introduced in U-Boot v2024.04. To address this in the previous video, we used the scarthgap/u-boot branch of the Yocto/OE layer meta-lts-mixins. Follow the steps below to add a single line to your existing local.conf and modify U-Boot variables on Raspberry Pi 5:
* Initialize the build environment:
source oe-init-build-env
* Add the following line to conf/local.conf:
IMAGE_INSTALL:append = " u-boot-fw-utils u-boot-env"
* Build the image:
bitbake core-image-base
* Flash core-image-base on a microSD card and boot the Raspberry Pi 5 with it
* Quickly press any key to interrupt U-Boot when prompted and in the U-Boot shell enter the following command to list available variables:
printenv
* Create a new U-Boot environment variable:
set env hello world
* Carry on and boot the Linux distribution by executing (optionally you can execute saveenv although it is not needed for the particular demo as explained in the video):
boot
* Login as root and execute the following command to list all U-Boot environment variables from Linux user space:
fw_printenv hello
* From Linux user space change the value of U-Boot env variable hello to world2:
fw_setenv hello world2
* From Linux user space create a new U-Boot env variable foo:
fw_setenv foo bar
* Reboot the Raspberry Pi 5, again interrupt U-Boot and check the value of U-Boot env variables hello and foo using fw_printenv.
🔗 Related Videos
===
Episode 1: The Yocto Project on Raspberry Pi 5: Building an Embedded GNU Linux Distribution
youtu.be/fY7u6PiV8qA?si=-DgvkJ_yTsiX05vx
Episode 2: SSH for Remote Network Access
youtu.be/ltckiBV9FXg?si=DJwsKLDhHkDIqCIn
Episode 3: The Yocto Project on Raspberry Pi 5 Episode 3: Running Docker Containers
youtu.be/kQnOidK_U3M?si=5KiS1FK87OwfdQ0m
Episode 4: The Yocto Project on Raspberry Pi 5 Episode 4: U-Boot Bootloader
youtu.be/9tohomiv1Ug?si=QydN1yPRJzY6zEfz
Episode 6: Runtime Package Management with apt and deb Packages
youtu.be/6i5UtF7fiaA?si=8DuUHUxywVEEtdyN
Episode 7: Create a New Layer, a New Recipe (.bb) and .bbappend
youtu.be/W5J1W_Cy14Y?si=ftu5WpeGqel8BZhf
📚 Useful Links
===
yoctoproject.org
docs.yoctoproject.org
openembedded.org/wiki/Main_Page
meta-raspberrypi.readthedocs.io/en/latest/extra-build-config.html#boot-to-u-boot
docs.u-boot.org
github.com/sbabic/libubootenv
anavi.org/article/303










