From 0687ae7f5c9b27ce164dd5153f94df57788ca1c8 Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Mon, 10 Apr 2023 18:09:37 +0100 Subject: [PATCH] rename flashable->flashimage, o.squashfs to rootfs "rootfs" describes what it is for, "squashfs" merely says how it's implemented (also, rootfs-as-jffs2 will soon be added) --- doc/user.rst | 4 ++-- examples/arhcive.nix | 2 +- examples/extneder.nix | 2 +- examples/rotuer.nix | 2 +- modules/{flashable.nix => flashimage.nix} | 8 ++++---- modules/kexecboot.nix | 12 ++++++------ modules/outputs.nix | 6 +++--- modules/tftpboot.nix | 12 ++++++------ tests/pppoe/test.nix | 2 +- tests/smoke/test.nix | 2 +- tests/wlan/test.nix | 2 +- 11 files changed, 27 insertions(+), 27 deletions(-) rename modules/{flashable.nix => flashimage.nix} (89%) diff --git a/doc/user.rst b/doc/user.rst index 3f1f1f9..bd6241d 100644 --- a/doc/user.rst +++ b/doc/user.rst @@ -13,12 +13,12 @@ and the services that you want to run on it. Start by copying directory for some pre-written configurations. If you want to create a configuration that can be installed on -a hardware device, be sure to include the "flashable" module. +a hardware device, be sure to include the "flashimage" module. .. code-block: nix imports = [ - ./modules/flashable.nix + ./modules/flashimage.nix ] diff --git a/examples/arhcive.nix b/examples/arhcive.nix index 6cfca8c..3b08fae 100644 --- a/examples/arhcive.nix +++ b/examples/arhcive.nix @@ -33,7 +33,7 @@ in rec { imports = [ ../modules/tftpboot.nix ../modules/wlan.nix - ../modules/flashable.nix + ../modules/flashimage.nix ../modules/kexecboot.nix ]; diff --git a/examples/extneder.nix b/examples/extneder.nix index ced3849..e2187f8 100644 --- a/examples/extneder.nix +++ b/examples/extneder.nix @@ -35,7 +35,7 @@ in rec { imports = [ ../modules/wlan.nix ../modules/tftpboot.nix - ../modules/flashable.nix + ../modules/flashimage.nix ]; hostname = "extneder"; diff --git a/examples/rotuer.nix b/examples/rotuer.nix index e777a64..da38617 100644 --- a/examples/rotuer.nix +++ b/examples/rotuer.nix @@ -33,7 +33,7 @@ in rec { imports = [ ./modules/wlan.nix ./modules/tftpboot.nix -# ./modules/flashable.nix +# ./modules/flashimage.nix ]; kernel = { diff --git a/modules/flashable.nix b/modules/flashimage.nix similarity index 89% rename from modules/flashable.nix rename to modules/flashimage.nix index 38e038c..b5f0fe1 100644 --- a/modules/flashable.nix +++ b/modules/flashimage.nix @@ -25,15 +25,15 @@ in { let o = config.outputs; in pkgs.runCommand "firmware" {} '' dd if=${o.uimage} of=$out bs=128k conv=sync - dd if=${o.squashfs} of=$out bs=128k conv=sync,nocreat,notrunc oflag=append + dd if=${o.rootfs} of=$out bs=128k conv=sync,nocreat,notrunc oflag=append ''; - outputs.flashable = + outputs.flashimage = let o = config.outputs; in - pkgs.runCommand "flashable" {} '' + pkgs.runCommand "flashimage" {} '' mkdir $out cd $out ln -s ${o.firmware} firmware.bin - ln -s ${o.squashfs} squashfs + ln -s ${o.rootfs} rootfs ln -s ${o.kernel} vmlinux ln -s ${o.manifest} manifest ln -s ${o.kernel.headers} build diff --git a/modules/kexecboot.nix b/modules/kexecboot.nix index 408c005..c34c1d5 100644 --- a/modules/kexecboot.nix +++ b/modules/kexecboot.nix @@ -16,7 +16,7 @@ in { pkgs.runCommand "kexecboot" {} '' mkdir $out cd $out - ln -s ${o.squashfs} squashfs + ln -s ${o.rootfs} rootfs ln -s ${o.kernel} kernel ln -s ${o.manifest} manifest ln -s ${o.boot-sh} boot.sh @@ -27,19 +27,19 @@ in { outputs.boot-sh = let inherit (pkgs.lib.trivial) toHexString; - inherit (config.outputs) squashfs kernel; + inherit (config.outputs) rootfs kernel; cmdline = concatStringsSep " " config.boot.commandLine; in pkgs.buildPackages.runCommand "boot.sh.sh" { } '' - squashfsStart=${toString (100 * 1024 * 1024)} - squashfsBytes=$(stat -L -c %s ${squashfs}) - append_cmd="mtdparts=phram0:''${squashfsBytes}(rootfs) phram.phram=phram0,''${squashfsStart},''${squashfsBytes} memmap=''${squashfsBytes}\$''${squashfsStart}"; + rootfsStart=${toString (100 * 1024 * 1024)} + rootfsBytes=$(stat -L -c %s ${rootfs}) + append_cmd="mtdparts=phram0:''${rootfsBytes}(rootfs) phram.phram=phram0,''${rootfsStart},''${rootfsBytes} memmap=''${rootfsBytes}\$''${rootfsStart}"; cat > $out <> 20)) - cmd="mtdparts=phram0:''${squashfsMb}M(rootfs) phram.phram=phram0,''${squashfsStart},''${squashfsMb}Mi memmap=''${squashfsMb}M\$''${squashfsStart} root=1f00"; + rootfsStart=0x$(printf %x $((${cfg.loadAddress} + 0x100000 + $uimageSize))) + rootfsBytes=$(($(stat -L -c %s ${config.outputs.rootfs}) + 0x100000 &(~0xfffff))) + rootfsMb=$(($rootfsBytes >> 20)) + cmd="mtdparts=phram0:''${rootfsMb}M(rootfs) phram.phram=phram0,''${rootfsStart},''${rootfsMb}Mi memmap=''${rootfsMb}M\$''${rootfsStart} root=1f00"; cat > $out << EOF setenv serverip ${cfg.serverip} setenv ipaddr ${cfg.ipaddr} setenv bootargs 'liminix $cmd' - tftp 0x$(printf %x ${cfg.loadAddress}) result/uimage ; tftp 0x$(printf %x $squashfsStart) result/squashfs + tftp 0x$(printf %x ${cfg.loadAddress}) result/uimage ; tftp 0x$(printf %x $rootfsStart) result/rootfs bootm 0x$(printf %x ${cfg.loadAddress}) EOF ''; diff --git a/tests/pppoe/test.nix b/tests/pppoe/test.nix index f5ef219..ef51013 100644 --- a/tests/pppoe/test.nix +++ b/tests/pppoe/test.nix @@ -46,7 +46,7 @@ trap fatal ERR routeros $serverstatedir mkdir vm -mips-vm --background ./vm ${img}/vmlinux ${img}/squashfs +mips-vm --background ./vm ${img}/vmlinux ${img}/rootfs expect ${./getaddress.expect} set -o pipefail diff --git a/tests/smoke/test.nix b/tests/smoke/test.nix index 907174a..25a81c7 100644 --- a/tests/smoke/test.nix +++ b/tests/smoke/test.nix @@ -5,7 +5,7 @@ let img = (import liminix { device = import "${liminix}/devices/qemu/"; liminix-config = "${liminix}/vanilla-configuration.nix"; - }).outputs.squashfs; + }).outputs.rootfs; pkgs = import {}; in pkgs.runCommand "check" { nativeBuildInputs = with pkgs; [ squashfsTools s6-rc ] ; diff --git a/tests/wlan/test.nix b/tests/wlan/test.nix index ebe6470..24e2a3f 100644 --- a/tests/wlan/test.nix +++ b/tests/wlan/test.nix @@ -34,6 +34,6 @@ fatal(){ trap fatal ERR mkdir vm -mips-vm --background ./vm ${img}/vmlinux ${img}/squashfs +mips-vm --background ./vm ${img}/vmlinux ${img}/rootfs expect ${./wait-for-wlan.expect} |tee output && mv output $out ''