Skip to contentSkip to conversation

Unexpected RPi5 Behavior with Saved U-Boot Environment

DISCUSSION Richard Weinberger 4 participants 7 messages Mar 27, 2025 – Apr 23, 2025

lore
Share & tools
lore
#0 lore raw

Hi!

We recently started using U-Boot on various Raspberry Pi 5 boards with different hardware configurations.

While testing, Simon noticed unusual boot failures, such as the kernel failing to boot with no output or U-Boot reporting:
"ERROR: Did not find a cmdline Flattened Device Tree."

Today, I spent time investigating these issues. It appears that U-Boot retrieves several variables from the Raspberry Pi firmware, with fdt_addr being particularly important.
If the environment is saved, fdt_addr gets stored and takes precedence over what the firmware provides to U-Boot.

Interestingly, the RPi firmware seems to modify fdt_addr based on connected hardware. Our experiments showed that even attaching an RPi camera module changes the computed fdt_addr and U-Boot reads from the wrong memory location.

As a result, saving the environment, whether via the saveenv command in U-Boot or fw_setenv in Linux, can lead to boot failures if the hardware configuration changes.

Do you have any suggestions for mitigating this issue? In my opinion, U-Boot should not override such critical variables.

Thanks,
//richard

Signature · 2 lines
​​​​​sigma star gmbh | Eduard-Bodem-Gasse 6, 6020 Innsbruck, AUT UID/VAT Nr:
ATU 66964118 | FN: 374287y
#1 lore raw
Quoted 19 lines · Richard Weinberger

Hi!

We recently started using U-Boot on various Raspberry Pi 5 boards with different hardware configurations.

While testing, Simon noticed unusual boot failures, such as the kernel failing to boot with no output or U-Boot reporting:
"ERROR: Did not find a cmdline Flattened Device Tree."

Today, I spent time investigating these issues. It appears that U-Boot retrieves several variables from the Raspberry Pi firmware, with fdt_addr being particularly important.
If the environment is saved, fdt_addr gets stored and takes precedence over what the firmware provides to U-Boot.

Interestingly, the RPi firmware seems to modify fdt_addr based on connected hardware. Our experiments showed that even attaching an RPi camera module changes the computed fdt_addr and U-Boot reads from the wrong memory location.

Quoted 9 lines

As a result, saving the environment, whether via the saveenv command in U-Boot or fw_setenv in Linux, can lead to boot failures if the hardware configuration changes.

Do you have any suggestions for mitigating this issue? In my opinion, U-Boot should not override such critical variables.

Thanks,
//richard

Hi Richard,

could be related tho this [1]?

I sent this patch some years ago but was never accepted in u-boot tree. But meta-rpi uses it in u-boot recipe [2].

Regards

[1] https://lists.denx.de/pipermail/u-boot/2021-May/449609.html
[2] https://github.com/agherzan/meta-raspberrypi/blob/master/recipes-bsp/u-boot/files/0001-rpi-always-set-fdt_addr-with-firmware-provided-FDT-address.patch

Signature · 1 line
Mauro
#2 lore raw
Quoted 4 lines · On Donnerstag, 27. März 2025 17:24 Mauro Salvini wrote:

could be related tho this [1]?

I sent this patch some years ago but was never accepted in u-boot tree. But meta-rpi uses it in u-boot recipe [2].

Uh, good point!
In our initial experiments we have used meta-raspberrypi but now we don't. This would explain it.

IMHO this patch needs to be reconsidered.

Thanks,
//richard

Signature · 2 lines
​​​​​sigma star gmbh | Eduard-Bodem-Gasse 6, 6020 Innsbruck, AUT UID/VAT Nr:
ATU 66964118 | FN: 374287y
#3 lore raw
Quoted 12 lines · Richard Weinberger
Quoted 4 lines · On Donnerstag, 27. März 2025 17:24 Mauro Salvini wrote:

could be related tho this [1]?

I sent this patch some years ago but was never accepted in u-boot tree. But meta-rpi uses it in u-boot recipe [2].

Uh, good point!
In our initial experiments we have used meta-raspberrypi but now we don't. This would explain it.

IMHO this patch needs to be reconsidered.

Hi Richard,

glad that the patch was helpful.

Here [1] the original discussion about the patch.

[1] https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/

Signature · 1 line
Mauro
#4 lore raw
In reply to Richard Weinberger

Hi,

Quoted 4 lines · Richard Weinberger
Quoted 2 lines · On Donnerstag, 27. März 2025 17:24 Mauro Salvini wrote:

could be related tho this [1]?

Quoted 8 lines
Quoted 2 lines

I sent this patch some years ago but was never accepted in u-boot tree. But meta-rpi uses it in u-boot recipe [2].

Uh, good point!
In our initial experiments we have used meta-raspberrypi but now we don't. This would explain it.

IMHO this patch needs to be reconsidered.

It seems i hit the same problem when I sent this series:

https://lore.kernel.org/u-boot/[email protected]/

Quoted 9 lines

Thanks,
//richard

--
sigma star gmbh | Eduard-Bodem-Gasse 6, 6020 Innsbruck, AUT UID/VAT Nr:
ATU 66964118 | FN: 374287y

Regards,
Simon

#5 lore raw
In reply to Mauro Salvini

Hi Mauro,

Quoted 27 lines
Quoted 17 lines

We recently started using U-Boot on various Raspberry Pi 5 boards with different hardware configurations.

While testing, Simon noticed unusual boot failures, such as the kernel failing to boot with no output or U-Boot reporting:
"ERROR: Did not find a cmdline Flattened Device Tree."

Today, I spent time investigating these issues. It appears that U-Boot retrieves several variables from the Raspberry Pi firmware, with fdt_addr being particularly important.
If the environment is saved, fdt_addr gets stored and takes precedence over what the firmware provides to U-Boot.

Interestingly, the RPi firmware seems to modify fdt_addr based on connected hardware. Our experiments showed that even attaching an RPi camera module changes the computed fdt_addr and U-Boot reads from the wrong memory location.

Quoted 9 lines

As a result, saving the environment, whether via the saveenv command in U-Boot or fw_setenv in Linux, can lead to boot failures if the hardware configuration changes.

Do you have any suggestions for mitigating this issue? In my opinion, U-Boot should not override such critical variables.

Thanks,
//richard

Quoted 6 lines

Hi Richard,

could be related tho this [1]?

I sent this patch some years ago but was never accepted in u-boot tree. But meta-rpi uses it in u-boot recipe [2].

After digging into this and a discussion with Tom we decided this is the correct fix so I've pulled that patch in for 2025.07.

Thanks,
Peter

Quoted 8 lines

Regards

[1] https://lists.denx.de/pipermail/u-boot/2021-May/449609.html
[2]
https://github.com/agherzan/meta-raspberrypi/blob/master/recipes-bsp/u-boot/files/0001-rpi-always-set-fdt_addr-with-firmware-provided-FDT-address.patch

--
Mauro

#6 lore raw
Quoted 33 lines · Peter Robinson

Hi Mauro,

Quoted 31 lines
Quoted 17 lines

We recently started using U-Boot on various Raspberry Pi 5 boards with different hardware configurations.

While testing, Simon noticed unusual boot failures, such as the kernel failing to boot with no output or U-Boot reporting:
"ERROR: Did not find a cmdline Flattened Device Tree."

Today, I spent time investigating these issues. It appears that U-Boot retrieves several variables from the Raspberry Pi firmware, with fdt_addr being particularly important.
If the environment is saved, fdt_addr gets stored and takes precedence over what the firmware provides to U-Boot.

Interestingly, the RPi firmware seems to modify fdt_addr based on connected hardware. Our experiments showed that even attaching an RPi camera module changes the computed fdt_addr and U-Boot reads from the wrong memory location.

Quoted 9 lines

As a result, saving the environment, whether via the saveenv command in U-Boot or fw_setenv in Linux, can lead to boot failures if the hardware configuration changes.

Do you have any suggestions for mitigating this issue? In my opinion, U-Boot should not override such critical variables.

Thanks,
//richard

Hi Richard,

could be related tho this [1]?

Quoted 9 lines
Quoted 2 lines

I sent this patch some years ago but was never accepted in u-boot tree. But meta-rpi uses it in u-boot recipe [2].

After digging into this and a discussion with Tom we decided this is the correct fix so I've pulled that patch in for 2025.07.

Thanks,
Peter

Hi Peter,

thank you.

Regards

Mauro

Quoted 9 lines
Quoted 8 lines

Regards

[1] https://lists.denx.de/pipermail/u-boot/2021-May/449609.html
[2]
https://github.com/agherzan/meta-raspberrypi/blob/master/recipes-bsp/u-boot/files/0001-rpi-always-set-fdt_addr-with-firmware-provided-FDT-address.patch

--
Mauro