diff --git a/devices/gl-ar750/default.nix b/devices/gl-ar750/default.nix index 9418241..2d1ab23 100644 --- a/devices/gl-ar750/default.nix +++ b/devices/gl-ar750/default.nix @@ -106,9 +106,9 @@ loadAddress = lim.parseInt "0x80060000"; entryPoint = lim.parseInt "0x80060000"; flash = { - address = "0x9F060000"; - size ="0xfa0000"; - eraseBlockSize = "65536"; + address = lim.parseInt "0x9F060000"; + size = lim.parseInt "0xfa0000"; + eraseBlockSize = 65536; }; rootDevice = "/dev/mtdblock5"; dts = { diff --git a/devices/gl-mt300a/default.nix b/devices/gl-mt300a/default.nix index 28ca20e..3fa9c38 100644 --- a/devices/gl-mt300a/default.nix +++ b/devices/gl-mt300a/default.nix @@ -69,9 +69,9 @@ # 0x000000260000-0x000000f80000 : "rootfs" flash = { - address = "0xbc050000"; - size ="0xf80000"; - eraseBlockSize = "65536"; + address = lim.parseInt "0xbc050000"; + size = lim.parseInt "0xf80000"; + eraseBlockSize = 65536; }; rootDevice = "/dev/mtdblock5"; diff --git a/devices/gl-mt300n-v2/default.nix b/devices/gl-mt300n-v2/default.nix index e3d1774..c1dea49 100644 --- a/devices/gl-mt300n-v2/default.nix +++ b/devices/gl-mt300n-v2/default.nix @@ -66,9 +66,9 @@ entryPoint = lim.parseInt "0x80000000"; flash = { - address = "0xbc050000"; - size = "0xfb0000"; - eraseBlockSize = "65536"; + address = lim.parseInt "0xbc050000"; + size = lim.parseInt "0xfb0000"; + eraseBlockSize = 65536; }; rootDevice = "/dev/mtdblock5"; diff --git a/devices/qemu-aarch64/default.nix b/devices/qemu-aarch64/default.nix index cc7b07e..cd246b9 100644 --- a/devices/qemu-aarch64/default.nix +++ b/devices/qemu-aarch64/default.nix @@ -69,7 +69,7 @@ entryPoint = lim.parseInt "0x0"; rootDevice = "/dev/mtdblock0"; - flash.eraseBlockSize = "65536"; # c.f. pkgs/mips-vm/mips-vm.sh + flash.eraseBlockSize = 65536; # c.f. pkgs/mips-vm/mips-vm.sh networkInterfaces = let inherit (config.system.service.network) link; in { diff --git a/devices/qemu-armv7l/default.nix b/devices/qemu-armv7l/default.nix index 201d39e..6e60849 100644 --- a/devices/qemu-armv7l/default.nix +++ b/devices/qemu-armv7l/default.nix @@ -71,7 +71,7 @@ entryPoint = lim.parseInt "0x00010000"; rootDevice = "/dev/mtdblock0"; - flash.eraseBlockSize = "65536"; # c.f. pkgs/mips-vm/mips-vm.sh + flash.eraseBlockSize = 65536; # c.f. pkgs/mips-vm/mips-vm.sh networkInterfaces = let inherit (config.system.service.network) link; in { diff --git a/devices/qemu/default.nix b/devices/qemu/default.nix index b5a2755..87d7b47 100644 --- a/devices/qemu/default.nix +++ b/devices/qemu/default.nix @@ -73,7 +73,7 @@ in { defaultOutput = "vmroot"; rootDevice = "/dev/mtdblock0"; - flash.eraseBlockSize = "65536"; # c.f. pkgs/run-liminix-vm/run-liminix-vm.sh + flash.eraseBlockSize = 65536; networkInterfaces = let inherit (config.system.service.network) link; in { diff --git a/modules/hardware.nix b/modules/hardware.nix index 938df1a..81ab050 100644 --- a/modules/hardware.nix +++ b/modules/hardware.nix @@ -48,15 +48,15 @@ in { kernel uimage and root fs. Usually not the entire flash, as we don't want to clobber the bootloader, calibration data etc ''; - type = types.str; + type = types.ints.unsigned; }; size = mkOption { - type = types.str; + type = types.ints.unsigned; description = "Size in bytes of the firmware partition"; }; eraseBlockSize = mkOption { description = "Flash erase block size in bytes"; - type = types.str; + type = types.ints.unsigned; }; }; loadAddress = mkOption { type = types.ints.unsigned; default = null; }; diff --git a/modules/jffs2.nix b/modules/jffs2.nix index cb822e6..d85ba26 100644 --- a/modules/jffs2.nix +++ b/modules/jffs2.nix @@ -37,7 +37,7 @@ in cp ${systemConfiguration}/bin/activate $TMPDIR/empty/activate ln -s ${pkgs.s6-init-bin}/bin/init $TMPDIR/empty/init grafts=$(sed < ${systemConfiguration}/etc/nix-store-paths 's/^\(.*\)$/--graft \1:\1/g') - mkfs.jffs2 --compression-mode=size ${endian} -e ${config.hardware.flash.eraseBlockSize} --enable-compressor=lzo --pad --root $TMPDIR/empty --output $out $grafts --squash --faketime + mkfs.jffs2 --compression-mode=size ${endian} -e ${toString config.hardware.flash.eraseBlockSize} --enable-compressor=lzo --pad --root $TMPDIR/empty --output $out $grafts --squash --faketime ''; }; }; diff --git a/modules/outputs/flashimage.nix b/modules/outputs/flashimage.nix index 42d0bce..41d6a75 100644 --- a/modules/outputs/flashimage.nix +++ b/modules/outputs/flashimage.nix @@ -75,7 +75,7 @@ in { firmware = let o = config.system.outputs; - bs = config.hardware.flash.eraseBlockSize; + bs = toString config.hardware.flash.eraseBlockSize; in pkgs.runCommand "firmware" {} '' dd if=${o.uimage} of=$out bs=${bs} conv=sync dd if=${o.rootfs} of=$out bs=${bs} conv=sync,nocreat,notrunc oflag=append @@ -107,8 +107,8 @@ in { setenv serverip ${tftp.serverip} setenv ipaddr ${tftp.ipaddr} tftp 0x${toHexString tftp.loadAddress} result/firmware.bin - erase 0x$(printf %x ${flash.address}) +${flash.size} - cp.b 0x${toHexString tftp.loadAddress} 0x$(printf %x ${flash.address}) \''${filesize} + erase 0x${toHexString flash.address} +0x${toHexString flash.size} + cp.b 0x${toHexString tftp.loadAddress} 0x${toHexString flash.address} \''${filesize} echo command line was ${builtins.toJSON (concatStringsSep " " config.boot.commandLine)} EOF ''; diff --git a/modules/tftpboot.nix b/modules/tftpboot.nix index 2c3c879..70bcae0 100644 --- a/modules/tftpboot.nix +++ b/modules/tftpboot.nix @@ -74,7 +74,7 @@ in { rootfsBytes=$(($(stat -L -c %s ${o.rootfs}) + 0x100000 &(~0xfffff))) rootfsBytes=$(($rootfsBytes + ${toString cfg.freeSpaceBytes} )) rootfsMb=$(($rootfsBytes >> 20)) - cmd="mtdparts=phram0:''${rootfsMb}M(rootfs) phram.phram=phram0,''${rootfsStart},''${rootfsBytes},${config.hardware.flash.eraseBlockSize} root=/dev/mtdblock0"; + cmd="mtdparts=phram0:''${rootfsMb}M(rootfs) phram.phram=phram0,''${rootfsStart},''${rootfsBytes},${toString config.hardware.flash.eraseBlockSize} root=/dev/mtdblock0"; dtbStart=$(printf %x $((${toString cfg.loadAddress} + $rootfsBytes + 0x100000 + $uimageSize ))) diff --git a/pkgs/kernel/uimage.nix b/pkgs/kernel/uimage.nix index e096a91..eca50d5 100644 --- a/pkgs/kernel/uimage.nix +++ b/pkgs/kernel/uimage.nix @@ -46,7 +46,7 @@ in { buildPhaseUImage = '' test -f tmp.dtb && ${objcopy} --update-section .appended_dtb=tmp.dtb vmlinux.elf || ${objcopy} --add-section .appended_dtb=tmp.dtb vmlinux.elf ${stripAndZip} - mkimage -A ${arch} -O linux -T kernel -C lzma -a 0x${lib.toHexString loadAddress} -e 0x${lib.tohexString entryPoint} -n '${lib.toUpper arch} Liminix Linux ${extraName}' -d vmlinux.bin.lzma kernel.uimage + mkimage -A ${arch} -O linux -T kernel -C lzma -a 0x${lib.toHexString loadAddress} -e 0x${lib.toHexString entryPoint} -n '${lib.toUpper arch} Liminix Linux ${extraName}' -d vmlinux.bin.lzma kernel.uimage ''; buildPhaseFIT = ''