liminix

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 9e199c695724a88fafe57135a64df3f36b5466b6
parent c8e3d84bf429569941d602e553373b37c6e0563b
Author: Daniel Barlow <dan@telent.net>
Date:   Fri, 26 Jan 2024 22:51:58 +0000

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

Diffstat:
Mmodules/outputs/tftpboot.nix | 5+++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git 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"