commit 6d6dbe1cbbf1c339035fa57e56a5374a58dfb0c9
parent 151dc88c285b30819a87676d63ff0a4f3a961d15
Author: Daniel Barlow <dan@telent.net>
Date: Sun, 23 Apr 2023 23:29:53 +0100
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
Diffstat:
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/examples/rotuer.nix b/examples/rotuer.nix
@@ -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";
};
diff --git a/modules/tftpboot.nix b/modules/tftpboot.nix
@@ -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}