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
module-based-network
Daniel Barlow 2023-04-23 23:29:53 +01:00
parent 151dc88c28
commit 6d6dbe1cbb
2 changed files with 7 additions and 3 deletions

View File

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

View File

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