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)
module-based-network
Daniel Barlow 2023-04-10 18:09:37 +01:00
parent 2e15acd61c
commit 0687ae7f5c
11 changed files with 27 additions and 27 deletions

View File

@ -13,12 +13,12 @@ and the services that you want to run on it. Start by copying
directory for some pre-written configurations. directory for some pre-written configurations.
If you want to create a configuration that can be installed on 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 .. code-block: nix
imports = [ imports = [
./modules/flashable.nix ./modules/flashimage.nix
] ]

View File

@ -33,7 +33,7 @@ in rec {
imports = [ imports = [
../modules/tftpboot.nix ../modules/tftpboot.nix
../modules/wlan.nix ../modules/wlan.nix
../modules/flashable.nix ../modules/flashimage.nix
../modules/kexecboot.nix ../modules/kexecboot.nix
]; ];

View File

@ -35,7 +35,7 @@ in rec {
imports = [ imports = [
../modules/wlan.nix ../modules/wlan.nix
../modules/tftpboot.nix ../modules/tftpboot.nix
../modules/flashable.nix ../modules/flashimage.nix
]; ];
hostname = "extneder"; hostname = "extneder";

View File

@ -33,7 +33,7 @@ in rec {
imports = [ imports = [
./modules/wlan.nix ./modules/wlan.nix
./modules/tftpboot.nix ./modules/tftpboot.nix
# ./modules/flashable.nix # ./modules/flashimage.nix
]; ];
kernel = { kernel = {

View File

@ -25,15 +25,15 @@ in {
let o = config.outputs; in let o = config.outputs; in
pkgs.runCommand "firmware" {} '' pkgs.runCommand "firmware" {} ''
dd if=${o.uimage} of=$out bs=128k conv=sync 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 let o = config.outputs; in
pkgs.runCommand "flashable" {} '' pkgs.runCommand "flashimage" {} ''
mkdir $out mkdir $out
cd $out cd $out
ln -s ${o.firmware} firmware.bin ln -s ${o.firmware} firmware.bin
ln -s ${o.squashfs} squashfs ln -s ${o.rootfs} rootfs
ln -s ${o.kernel} vmlinux ln -s ${o.kernel} vmlinux
ln -s ${o.manifest} manifest ln -s ${o.manifest} manifest
ln -s ${o.kernel.headers} build ln -s ${o.kernel.headers} build

View File

@ -16,7 +16,7 @@ in {
pkgs.runCommand "kexecboot" {} '' pkgs.runCommand "kexecboot" {} ''
mkdir $out mkdir $out
cd $out cd $out
ln -s ${o.squashfs} squashfs ln -s ${o.rootfs} rootfs
ln -s ${o.kernel} kernel ln -s ${o.kernel} kernel
ln -s ${o.manifest} manifest ln -s ${o.manifest} manifest
ln -s ${o.boot-sh} boot.sh ln -s ${o.boot-sh} boot.sh
@ -27,19 +27,19 @@ in {
outputs.boot-sh = outputs.boot-sh =
let let
inherit (pkgs.lib.trivial) toHexString; inherit (pkgs.lib.trivial) toHexString;
inherit (config.outputs) squashfs kernel; inherit (config.outputs) rootfs kernel;
cmdline = concatStringsSep " " config.boot.commandLine; cmdline = concatStringsSep " " config.boot.commandLine;
in in
pkgs.buildPackages.runCommand "boot.sh.sh" { pkgs.buildPackages.runCommand "boot.sh.sh" {
} '' } ''
squashfsStart=${toString (100 * 1024 * 1024)} rootfsStart=${toString (100 * 1024 * 1024)}
squashfsBytes=$(stat -L -c %s ${squashfs}) rootfsBytes=$(stat -L -c %s ${rootfs})
append_cmd="mtdparts=phram0:''${squashfsBytes}(rootfs) phram.phram=phram0,''${squashfsStart},''${squashfsBytes} memmap=''${squashfsBytes}\$''${squashfsStart}"; append_cmd="mtdparts=phram0:''${rootfsBytes}(rootfs) phram.phram=phram0,''${rootfsStart},''${rootfsBytes} memmap=''${rootfsBytes}\$''${rootfsStart}";
cat > $out <<EOF cat > $out <<EOF
#!/bin/sh #!/bin/sh
test -d \$1 test -d \$1
cd \$1 cd \$1
./kexec -f -d --map-file squashfs@$squashfsStart --dtb dtb --command-line '${cmdline} $append_cmd' kernel ./kexec -f -d --map-file rootfs@$rootfsStart --dtb dtb --command-line '${cmdline} $append_cmd' kernel
EOF EOF
''; '';
}; };

View File

@ -17,7 +17,7 @@ in
}; };
config = { config = {
outputs = rec { outputs = rec {
squashfs = liminix.builders.squashfs config.filesystem.contents; rootfs = liminix.builders.squashfs config.filesystem.contents;
tftpd = pkgs.buildPackages.tufted; tftpd = pkgs.buildPackages.tufted;
kernel = liminix.builders.kernel.override { kernel = liminix.builders.kernel.override {
inherit (config.kernel) config src extraPatchPhase; inherit (config.kernel) config src extraPatchPhase;
@ -40,13 +40,13 @@ in
} '' } ''
mkdir $out mkdir $out
dd if=${uimage} of=$out/firmware.bin bs=128k conv=sync dd if=${uimage} of=$out/firmware.bin bs=128k conv=sync
dd if=${squashfs} of=$out/firmware.bin bs=128k conv=sync,nocreat,notrunc oflag=append dd if=${rootfs} of=$out/firmware.bin bs=128k conv=sync,nocreat,notrunc oflag=append
''; '';
vmroot = pkgs.runCommand "qemu" {} '' vmroot = pkgs.runCommand "qemu" {} ''
mkdir $out mkdir $out
cd $out cd $out
ln -s ${squashfs} squashfs ln -s ${rootfs} rootfs
ln -s ${kernel} vmlinux ln -s ${kernel} vmlinux
ln -s ${manifest} manifest ln -s ${manifest} manifest
ln -s ${kernel.headers} build ln -s ${kernel.headers} build

View File

@ -17,7 +17,7 @@ in {
pkgs.runCommand "tftpboot" {} '' pkgs.runCommand "tftpboot" {} ''
mkdir $out mkdir $out
cd $out cd $out
ln -s ${o.squashfs} squashfs ln -s ${o.rootfs} rootfs
ln -s ${o.kernel} vmlinux ln -s ${o.kernel} vmlinux
ln -s ${o.manifest} manifest ln -s ${o.manifest} manifest
ln -s ${o.kernel.headers} build ln -s ${o.kernel.headers} build
@ -31,16 +31,16 @@ in {
in in
pkgs.buildPackages.runCommand "boot-scr" {} '' pkgs.buildPackages.runCommand "boot-scr" {} ''
uimageSize=$(($(stat -L -c %s ${config.outputs.uimage}) + 0x1000 &(~0xfff))) uimageSize=$(($(stat -L -c %s ${config.outputs.uimage}) + 0x1000 &(~0xfff)))
squashfsStart=0x$(printf %x $((${cfg.loadAddress} + 0x100000 + $uimageSize))) rootfsStart=0x$(printf %x $((${cfg.loadAddress} + 0x100000 + $uimageSize)))
squashfsBytes=$(($(stat -L -c %s ${config.outputs.squashfs}) + 0x100000 &(~0xfffff))) rootfsBytes=$(($(stat -L -c %s ${config.outputs.rootfs}) + 0x100000 &(~0xfffff)))
squashfsMb=$(($squashfsBytes >> 20)) rootfsMb=$(($rootfsBytes >> 20))
cmd="mtdparts=phram0:''${squashfsMb}M(rootfs) phram.phram=phram0,''${squashfsStart},''${squashfsMb}Mi memmap=''${squashfsMb}M\$''${squashfsStart} root=1f00"; cmd="mtdparts=phram0:''${rootfsMb}M(rootfs) phram.phram=phram0,''${rootfsStart},''${rootfsMb}Mi memmap=''${rootfsMb}M\$''${rootfsStart} root=1f00";
cat > $out << EOF cat > $out << EOF
setenv serverip ${cfg.serverip} setenv serverip ${cfg.serverip}
setenv ipaddr ${cfg.ipaddr} setenv ipaddr ${cfg.ipaddr}
setenv bootargs 'liminix $cmd' 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}) bootm 0x$(printf %x ${cfg.loadAddress})
EOF EOF
''; '';

View File

@ -46,7 +46,7 @@ trap fatal ERR
routeros $serverstatedir routeros $serverstatedir
mkdir vm mkdir vm
mips-vm --background ./vm ${img}/vmlinux ${img}/squashfs mips-vm --background ./vm ${img}/vmlinux ${img}/rootfs
expect ${./getaddress.expect} expect ${./getaddress.expect}
set -o pipefail set -o pipefail

View File

@ -5,7 +5,7 @@
let img = (import liminix { let img = (import liminix {
device = import "${liminix}/devices/qemu/"; device = import "${liminix}/devices/qemu/";
liminix-config = "${liminix}/vanilla-configuration.nix"; liminix-config = "${liminix}/vanilla-configuration.nix";
}).outputs.squashfs; }).outputs.rootfs;
pkgs = import <nixpkgs> {}; pkgs = import <nixpkgs> {};
in pkgs.runCommand "check" { in pkgs.runCommand "check" {
nativeBuildInputs = with pkgs; [ squashfsTools s6-rc ] ; nativeBuildInputs = with pkgs; [ squashfsTools s6-rc ] ;

View File

@ -34,6 +34,6 @@ fatal(){
trap fatal ERR trap fatal ERR
mkdir vm 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 expect ${./wait-for-wlan.expect} |tee output && mv output $out
'' ''