From 231c2cef0323d23ea61b9780442b19ba140a985a Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Thu, 21 Dec 2023 22:21:20 +0000 Subject: [PATCH] make reserved-memory work on mips, and improve test --- modules/outputs/tftpboot.nix | 12 ++++++++---- tests/tftpboot/script.expect | 10 +++++++++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/modules/outputs/tftpboot.nix b/modules/outputs/tftpboot.nix index 8ce3468..0261696 100644 --- 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 index 31c2fcf..a622e15 100644 --- 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