diff --git a/devices/qemu-armv7l/default.nix b/devices/qemu-armv7l/default.nix index 03fddb9..d0e0ee1 100644 --- a/devices/qemu-armv7l/default.nix +++ b/devices/qemu-armv7l/default.nix @@ -45,9 +45,9 @@ boot.commandLine = [ "console=ttyAMA0" ]; - hardware = { - loadAddress = lim.parseInt "0x00010000"; - entryPoint = lim.parseInt "0x00010000"; + hardware = let addr = lim.parseInt "0x40008000"; in { + loadAddress = addr; + entryPoint = addr; }; }; } diff --git a/overlay.nix b/overlay.nix index 3a29d63..5ce37a1 100644 --- a/overlay.nix +++ b/overlay.nix @@ -212,6 +212,9 @@ extraPkgs // { CONFIG_CMD_UBIFS=y CONFIG_BOOTSTD=y CONFIG_BOOTMETH_DISTRO=y + CONFIG_LZMA=y + CONFIG_CMD_LZMADEC=y + CONFIG_SYS_BOOTM_LEN=0x1000000 ''; }; diff --git a/tests/ci.nix b/tests/ci.nix index c84ae07..f923e85 100644 --- a/tests/ci.nix +++ b/tests/ci.nix @@ -7,4 +7,5 @@ ext4 = import ./ext4/test.nix; min-copy-closure = import ./min-copy-closure/test.nix; fennel = import ./fennel/test.nix; + tftpboot = import ./tftpboot/test.nix; } diff --git a/tests/tftpboot/a.sh b/tests/tftpboot/a.sh new file mode 100644 index 0000000..b8fc6d6 --- /dev/null +++ b/tests/tftpboot/a.sh @@ -0,0 +1,31 @@ +"qemu-system-arm" \ + "-M" \ + "virt,highmem=off" \ + "-cpu" \ + "cortex-a15" \ + "-m" \ + "272" \ + "-echr" \ + "16" \ + "-device" \ + "loader,file=run-vm-FwJ0aL,addr=0x3c00000" \ + "-serial" \ + "mon:stdio" \ + "-drive" \ + "if=pflash,format=raw,file=run-vm-duvYIP" \ + "-drive" \ + "if=none,format=raw,id=hd0,file=run-vm-FwJ0aL" \ + "-device" \ + "virtio-blk-pci,drive=hd0" \ + "-netdev" \ + "socket,id=access,mcast=230.0.0.1:1234,localaddr=127.0.0.1" \ + "-device" \ + "virtio-net,disable-legacy=on,disable-modern=off,netdev=access,mac=ba:ad:1d: \ +ea:21:02" \ + "-netdev" \ + "user,tftp=/build,id=lan" \ + "-device" \ + "virtio-net,disable-legacy=on,disable-modern=off,netdev=lan,mac=ba:ad:1d:ea: \ +21:01" \ + "-display" \ + "none" diff --git a/tests/tftpboot/configuration.nix b/tests/tftpboot/configuration.nix new file mode 100644 index 0000000..1601428 --- /dev/null +++ b/tests/tftpboot/configuration.nix @@ -0,0 +1,33 @@ +{ config, pkgs, lib, lim, ... } : +let + inherit (pkgs.pseudofile) dir symlink; + dts = pkgs.runCommand "qemu.dts" { + nativeBuildInputs = with pkgs.pkgsBuildBuild; [ dtc qemu ]; + } '' + qemu-system-arm -machine virt -machine dumpdtb=tmp.dtb + dtc -I dtb -O dts -o $out tmp.dtb + ''; +in { + imports = [ + ../../modules/outputs/ext4fs.nix + ../../modules/outputs/tftpboot.nix + ]; + config = { + hardware.dts.src = lib.mkForce dts; + boot.tftp = { + loadAddress = lim.parseInt "0x42000000"; + serverip = "10.0.2.2"; + ipaddr = "10.0.2.15"; + }; + boot.imageFormat = "fit"; + rootfsType = "ext4"; + filesystem = dir { + hello = { + type = "f"; + uid = 7; + gid = 24; + file = "hello world"; + }; + }; + }; +} diff --git a/tests/tftpboot/script.expect b/tests/tftpboot/script.expect new file mode 100644 index 0000000..7cc1712 --- /dev/null +++ b/tests/tftpboot/script.expect @@ -0,0 +1,21 @@ +set timeout 10 + +spawn socat unix-connect:vm/console - +expect "stop autoboot" +send "\r" +expect "=>" +send "setenv ethact eth1\r" +set fh [open "result/boot.scr"] +while {[gets $fh line] >= 0} { + expect "=>" + send "$line\r" +} + +close $fh + +expect { + "s6-linux-init" { exit 0 } + timeout { exit 1 } +} + + diff --git a/tests/tftpboot/test.nix b/tests/tftpboot/test.nix new file mode 100644 index 0000000..468c476 --- /dev/null +++ b/tests/tftpboot/test.nix @@ -0,0 +1,31 @@ +{ + liminix +}: +let derivation = (import liminix { + device = import "${liminix}/devices/qemu-armv7l/"; + liminix-config = ./configuration.nix; + }); + img = derivation.outputs.tftpboot; + pkgs = derivation.pkgs; + pkgsBuild = pkgs.pkgsBuildBuild; +in pkgsBuild.runCommand "check" { + nativeBuildInputs = with pkgsBuild; [ + expect + socat + run-liminix-vm + ] ; +} '' +mkdir vm +ln -s ${img} result +run-liminix-vm \ + --background ./vm \ + --u-boot ${pkgs.ubootQemuArm}/u-boot.bin \ + --arch arm \ + --flag -S \ + --phram-address 0x40200000 \ + --lan "user,tftp=`pwd`" \ + --disk-image result/rootfs \ + result/uimage result/rootfs + +expect ${./script.expect} 2>&1 |tee $out +''