Boot does not work when changing default dts

Hi,
I also wrote on RPI forums [1] to discuss about this problem.
I'm using a CM4 module on CMIO board, with an image built by Yocto (dunfell version) and containing u-boot version 2020.01.
When I add some overlays via config.txt file, or I change the original Linux dts and rebuild its dtb, often occours that the boot stops with this error message:
libfdt fdt_check_header(): FDT_ERR_BADMAGIC
generated by the "fdt addr" command in boot.scr script, executed by u-boot.
If I delete the env file (that boot.scr saves in FAT partition), boot restarts to work without errors. If I modify another time the devicetree (for example undoing the last modification), error happens again. Then, the problem is not related to dts errors.
This behavior seems to occour when a overlay (or a dts modification) adds or removes some pieces of dts: if overlay/modification overwrites existing properties values, error does not happen.
In fact, it seems that u-boot always uses fdt_addr saved in environment (when an env is saved), instead of the value passed by the RPI firmware, that changes if a modification (via dts rebuild or via overlay addition/remove) happens since the last loaded devicetree.
Is this the expected behavior (delete .env when there is a devicetree mdoification) or could be a bug?
Thanks in advance, regards
[1] https://www.raspberrypi.org/forums/viewtopic.php?f=107&t=307300
participants (1)
-
Mauro Salvini