1
0

Compare commits

...

4 Commits

Author SHA1 Message Date
67768004ee erase full flash, it seems to help with jffs2 2023-04-26 22:19:01 +01:00
26c6eac937 delete config boot.tftp.enable as it doesn't enable anything 2023-04-26 22:18:23 +01:00
4cfaed7303 specify root device as /dev/mtdblockn
the (openwrt?) magic that autodetects it based on mtd labels
won't work with a two-stage boot
2023-04-26 22:16:15 +01:00
6d6dbe1cbb tftpboot: allow padding image with freeSpaceBytes
this is useful for writable filesystems so that there's more than
an erase block of space to write into
2023-04-26 22:15:19 +01:00
8 changed files with 17 additions and 9 deletions

View File

@ -89,7 +89,7 @@
size ="0xfa0000";
eraseBlockSize = "65536";
};
rootDevice = "1f05";
rootDevice = "/dev/mtdblock5";
dts = {
src = "${openwrt.src}/target/linux/ath79/dts/qca9531_glinet_gl-ar750.dts";
includes = [

View File

@ -47,7 +47,7 @@
size ="0xf80000";
eraseBlockSize = "65536";
};
rootDevice = "1f05";
rootDevice = "/dev/mtdblock5";
dts = {
src = "${openwrt.src}/target/linux/ramips/dts/mt7620a_glinet_gl-mt300a.dts";

View File

@ -44,7 +44,7 @@
size = "0xfb0000";
eraseBlockSize = "65536";
};
rootDevice = "1f05";
rootDevice = "/dev/mtdblock5";
dts = {
src = "${openwrt.src}/target/linux/ramips/dts/mt7628an_glinet_gl-mt300n-v2.dts";

View File

@ -25,7 +25,7 @@ let
in rec {
boot = {
tftp = {
enable = true;
freeSpaceBytes = 3 * 1024 * 1024;
serverip = "10.0.0.1";
ipaddr = "10.0.0.8";
};

View File

@ -2,7 +2,6 @@
let
inherit (lib) mkEnableOption mkOption types isDerivation hasAttr ;
inherit (pkgs.pseudofile) dir symlink;
# inherit (pkgs) busybox;
inherit (pkgs.liminix.networking) address interface;
inherit (pkgs.liminix.services) bundle;
@ -52,7 +51,6 @@ in {
# the right to change them if I think of better ones.
ipaddr = mkOption { type = types.str; };
serverip = mkOption { type = types.str; };
enable = mkOption { type = types.boolean; };
};
};
};
@ -119,6 +117,7 @@ in {
};
boot.commandLine = [
"console=ttyS0,115200 panic=10 oops=panic init=/bin/init loglevel=8"
"root=${config.hardware.rootDevice}"
"rootfstype=${config.rootfsType}"
"fw_devlink=off"
];

View File

@ -53,7 +53,7 @@ in {
setenv serverip ${tftp.serverip}
setenv ipaddr ${tftp.ipaddr}
tftp 0x$(printf %x ${tftp.loadAddress}) result/firmware.bin
erase 0x$(printf %x ${flash.address}) +\''${filesize})
erase 0x$(printf %x ${flash.address}) +${flash.size}
cp.b 0x$(printf %x ${tftp.loadAddress}) 0x$(printf %x ${flash.address}) \''${filesize}
echo command line was ${builtins.toJSON (concatStringsSep " " config.boot.commandLine)}
EOF

View File

@ -31,6 +31,11 @@ in
dir /dev 0755 0 0
nod /dev/console 0600 0 0 c 5 1
nod /dev/mtdblock0 0600 0 0 b 31 0
nod /dev/mtdblock1 0600 0 0 b 31 1
nod /dev/mtdblock2 0600 0 0 b 31 2
nod /dev/mtdblock3 0600 0 0 b 31 3
nod /dev/mtdblock4 0600 0 0 b 31 4
nod /dev/mtdblock5 0600 0 0 b 31 5
dir /target 0755 0 0
dir /target/persist 0755 0 0
dir /target/nix 0755 0 0

View File

@ -9,6 +9,10 @@ let
cfg = config.boot.tftp;
in {
imports = [ ./ramdisk.nix ];
options.boot.tftp.freeSpaceBytes = mkOption {
type = types.int;
default = 0;
};
config = {
boot.ramdisk.enable = true;
@ -33,8 +37,8 @@ in {
uimageSize=$(($(stat -L -c %s ${config.outputs.uimage}) + 0x1000 &(~0xfff)))
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,${config.hardware.flash.eraseBlockSize} memmap=''${rootfsMb}M\$''${rootfsStart} root=/dev/mtdblock0";
rootfsBytes=$(($rootfsBytes + ${toString cfg.freeSpaceBytes} ))
cmd="mtdparts=phram0:''${rootfsMb}M(rootfs) phram.phram=phram0,''${rootfsStart},''${rootfsBytes},${config.hardware.flash.eraseBlockSize} memmap=''${rootfsBytes}\$''${rootfsStart} root=/dev/mtdblock0";
cat > $out << EOF
setenv serverip ${cfg.serverip}