commit 231c2cef0323d23ea61b9780442b19ba140a985a parent dbb82339bdd3352cd44383a393cf45fa32ec5aa6 Author: Daniel Barlow <dan@telent.net> Date: Thu, 21 Dec 2023 22:21:20 +0000 make reserved-memory work on mips, and improve test Diffstat:
| M | modules/outputs/tftpboot.nix | | | 12 | ++++++++---- |
| M | tests/tftpboot/script.expect | | | 11 | ++++++++++- |
2 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/modules/outputs/tftpboot.nix b/modules/outputs/tftpboot.nix @@ -80,11 +80,15 @@ in { mkdir $out cat ${o.dtb} > $out/dtb - fdtput -p $out/dtb /reserved-memory '#address-cells' 2 - fdtput -p $out/dtb /reserved-memory '#size-cells' 2 + address_cells=$(fdtget $out/dtb / '#address-cells') + size_cells=$(fdtget $out/dtb / '#size-cells') + if [ address_cells -gt 1 ]; then ac_prefix=0; fi + if [ size_cells -gt 1 ]; then sz_prefix=0; fi + fdtput -p $out/dtb /reserved-memory '#address-cells' $address_cells + fdtput -p $out/dtb /reserved-memory '#size-cells' $size_cells fdtput -p $out/dtb /reserved-memory ranges - fdtput -p -t s $out/dtb /reserved-memory/phram-rootfs@$rootfsStart compatible phram - fdtput -p -t lx $out/dtb /reserved-memory/phram-rootfs@$rootfsStart reg 0 0x$rootfsStart 0 $(printf %x $rootfsBytes) + fdtput -p -t s $out/dtb /reserved-memory/phram-rootfs@$rootfsStart compatible phram + fdtput -p -t lx $out/dtb /reserved-memory/phram-rootfs@$rootfsStart reg $ac_prefix 0x$rootfsStart $sz_prefix $(printf %x $rootfsBytes) # dtc -I dtb -O dts -o /dev/stdout $out/dtb; exit 1 dtbBytes=$(($(stat -L -c %s $out/dtb) + 0x1000 &(~0xfff))) diff --git a/tests/tftpboot/script.expect b/tests/tftpboot/script.expect @@ -14,9 +14,17 @@ while {[gets $fh line] >= 0} { close $fh expect { - "s6-linux-init" { exit 0 } + "s6-linux-init" { } "Reserved memory: unsupported node format, ignoring" { exit 1 } timeout { exit 1 } } +expect { + "#" { send "test -f /proc/device-tree/reserved-memory/phram-rootfs*/name && tty \r" } + timeout { exit 1 } +} +expect { + "/dev/ttyS0" { exit 0 } + timeout { exit 1 } +} +\ No newline at end of file