diff --git a/examples/rotuer.nix b/examples/rotuer.nix index 749232c..42140f5 100644 --- 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 index 6eb2e79..6be5fdd 100644 --- 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}