Skip to contentSkip to conversation

Makefile: Ensure initrd parameters in /chosen are up-to-date

PATCH Applied Dave Martin 2 participants 3 messages May 12, 2025 – May 13, 2025 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Makefile: Ensure initrd parameters in /chosen are up-to-date

The initrd parameters in the FDT /chosen node are fixed when the device tree blob is generated, so it is important to regenerate the device tree if the initrd image has been updated.

Currently this does not happen, so the parameters can be stale. In particular, if the initrd image is bigger than it was when the device tree was first generated then the value of the linux,initrd-end parameter is too small, leading to truncation of the initrd image on boot even though the whole image is present in linux-system.axf.

Make $(FILESYSTEM) a dependency of fdt.dtb so that the parameters are refreshed properly based on the current initrd image (if any).

Without --with-initrd, FILESYSTEM is the empty string and the dependency evaporates, which is just fine.

---
 Makefile.am | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile.am +1 -1
index a8d5c1b..0178e5d 100644
@@ -185,7 +185,7 @@ model.lds: $(LD_SCRIPT) Makefile
 DTC_NOWARN  = $(call test-dtc-option,-Wno-clocks_property)
 DTC_NOWARN += $(call test-dtc-option,-Wno-gpios_property)
 
-fdt.dtb: $(KERNEL_DTB) Makefile
+fdt.dtb: $(KERNEL_DTB) Makefile $(FILESYSTEM)
 	( $(DTC) -O dts -I dtb $(KERNEL_DTB) ; echo "/ { $(CHOSEN_NODE) $(PSCI_NODE) }; $(CPU_NODES)" ) | $(DTC) -O dtb -o $@ $(DTC_NOWARN) -
 
 # The filesystem archive might not exist if INITRD is not being used
Signature · 1 line
2.34.1
Applied
#1 lore raw
Quoted 10 lines · Dave Martin

The initrd parameters in the FDT /chosen node are fixed when the device tree blob is generated, so it is important to regenerate the device tree if the initrd image has been updated.

Currently this does not happen, so the parameters can be stale. In particular, if the initrd image is bigger than it was when the device tree was first generated then the value of the linux,initrd-end parameter is too small, leading to truncation of the initrd image on boot even though the whole image is present in linux-system.axf.

Quoted 7 lines

Make $(FILESYSTEM) a dependency of fdt.dtb so that the parameters are refreshed properly based on the current initrd image (if any).

Without --with-initrd, FILESYSTEM is the empty string and the dependency evaporates, which is just fine.

Applied.

Mark.

Quoted 20 lines
---
 Makefile.am | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile.am +1 -1
index a8d5c1b..0178e5d 100644
@@ -185,7 +185,7 @@ model.lds: $(LD_SCRIPT) Makefile
 DTC_NOWARN  = $(call test-dtc-option,-Wno-clocks_property)
 DTC_NOWARN += $(call test-dtc-option,-Wno-gpios_property)
 
-fdt.dtb: $(KERNEL_DTB) Makefile
+fdt.dtb: $(KERNEL_DTB) Makefile $(FILESYSTEM)
 	( $(DTC) -O dts -I dtb $(KERNEL_DTB) ; echo "/ { $(CHOSEN_NODE) $(PSCI_NODE) }; $(CPU_NODES)" ) | $(DTC) -O dtb -o $@ $(DTC_NOWARN) -
 
 # The filesystem archive might not exist if INITRD is not being used
Signature · 1 line
2.34.1
#2 lore raw

Hi,

Quoted 14 lines · Mark Rutland
Quoted 13 lines · Dave Martin

The initrd parameters in the FDT /chosen node are fixed when the device tree blob is generated, so it is important to regenerate the device tree if the initrd image has been updated.

Currently this does not happen, so the parameters can be stale. In particular, if the initrd image is bigger than it was when the device tree was first generated then the value of the linux,initrd-end parameter is too small, leading to truncation of the initrd image on boot even though the whole image is present in linux-system.axf.

Make $(FILESYSTEM) a dependency of fdt.dtb so that the parameters are refreshed properly based on the current initrd image (if any).

Quoted 8 lines
Quoted 4 lines

Without --with-initrd, FILESYSTEM is the empty string and the dependency evaporates, which is just fine.

Applied.

Mark.

Thanks!

---Dave