From 9e199c695724a88fafe57135a64df3f36b5466b6 Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Fri, 26 Jan 2024 22:51:58 +0000 Subject: [PATCH] tftpboot: compute dtbSize *after* changing dtb Adding the reserved-memory node to the dtb can cause it to grow by enough that it needs an extra page - this will overlap the start of the kernel image if we calculate offsets based on the original size Reported-by: sinavir Authored-by: sinavir --- modules/outputs/tftpboot.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/outputs/tftpboot.nix b/modules/outputs/tftpboot.nix index 274ebad..36d96ff 100644 --- a/modules/outputs/tftpboot.nix +++ b/modules/outputs/tftpboot.nix @@ -74,8 +74,6 @@ in { rootfsSize=$(binsize64k ${o.rootfs} ) rootfsSize=$(($rootfsSize + ${toString cfg.freeSpaceBytes} )) dtbStart=$(($rootfsStart + $rootfsSize)) - dtbSize=$(binsize ${o.dtb} ) - imageStart=$(($dtbStart + $dtbSize)) imageSize=$(binsize ${image}) ln -s ${o.manifest} manifest @@ -103,6 +101,9 @@ in { fdtput -p -t s dtb /reserved-memory/$node compatible phram fdtput -p -t lx dtb /reserved-memory/$node reg $ac_prefix $(hex $rootfsStart) $sz_prefix $(hex $rootfsSize) + dtbSize=$(binsize ./dtb ) + imageStart=$(($dtbStart + $dtbSize)) + cmd="liminix ${cmdline} mtdparts=phram0:''${rootfsSize}(rootfs) phram.phram=phram0,''${rootfsStart},''${rootfsSize},${toString config.hardware.flash.eraseBlockSize} root=/dev/mtdblock0"; fdtput -t s dtb /chosen bootargs "$cmd"