From 315907de98a23ee9a78ea31efb6625c3c62e64c8 Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Sun, 12 Nov 2023 18:47:31 +0000 Subject: [PATCH] convert hardware loadAddress to int --- devices/belkin-rt3200/default.nix | 2 +- devices/gl-ar750/default.nix | 2 +- devices/gl-mt300a/default.nix | 2 +- devices/gl-mt300n-v2/default.nix | 2 +- devices/qemu-aarch64/default.nix | 2 +- devices/qemu-armv7l/default.nix | 2 +- modules/hardware.nix | 2 +- modules/outputs/ubimage.nix | 2 +- modules/tftpboot.nix | 8 ++++---- pkgs/kernel/uimage.nix | 4 ++-- 10 files changed, 14 insertions(+), 14 deletions(-) diff --git a/devices/belkin-rt3200/default.nix b/devices/belkin-rt3200/default.nix index c226e8a8..46ee22ab 100644 --- a/devices/belkin-rt3200/default.nix +++ b/devices/belkin-rt3200/default.nix @@ -180,7 +180,7 @@ # We put it at the 32MB mark so that tftpboot can put its rootfs # image and DTB underneath, but maybe this is a terrible waste of # RAM unless the kernel is able to reuse it later. Oh well - loadAddress = "0x42000000"; + loadAddress = lim.parseInt "0x42000000"; entryPoint = "0x42000000"; rootDevice = "ubi0:liminix"; dts = { diff --git a/devices/gl-ar750/default.nix b/devices/gl-ar750/default.nix index aba60307..d8f9157d 100644 --- a/devices/gl-ar750/default.nix +++ b/devices/gl-ar750/default.nix @@ -103,7 +103,7 @@ }; hardware = { defaultOutput = "flashimage"; - loadAddress = "0x80060000"; + loadAddress = lim.parseInt "0x80060000"; entryPoint = "0x80060000"; flash = { address = "0x9F060000"; diff --git a/devices/gl-mt300a/default.nix b/devices/gl-mt300a/default.nix index 55ae68c7..684b15a8 100644 --- a/devices/gl-mt300a/default.nix +++ b/devices/gl-mt300a/default.nix @@ -55,7 +55,7 @@ imports = [ ../../modules/arch/mipsel.nix ]; hardware = { defaultOutput = "flashimage"; - loadAddress = "0x80000000"; + loadAddress = lim.parseInt "0x80000000"; entryPoint = "0x80000000"; # Creating 5 MTD partitions on "spi0.0": diff --git a/devices/gl-mt300n-v2/default.nix b/devices/gl-mt300n-v2/default.nix index be3c4a6e..45f6c589 100644 --- a/devices/gl-mt300n-v2/default.nix +++ b/devices/gl-mt300n-v2/default.nix @@ -62,7 +62,7 @@ }; hardware = { defaultOutput = "flashimage"; - loadAddress = "0x80000000"; + loadAddress = lim.parseInt "0x80000000"; entryPoint = "0x80000000"; flash = { diff --git a/devices/qemu-aarch64/default.nix b/devices/qemu-aarch64/default.nix index f04f274e..e8271735 100644 --- a/devices/qemu-aarch64/default.nix +++ b/devices/qemu-aarch64/default.nix @@ -65,7 +65,7 @@ }; in { defaultOutput = "vmroot"; - loadAddress = "0x0"; + loadAddress = lim.parseInt "0x0"; entryPoint = "0x0"; rootDevice = "/dev/mtdblock0"; diff --git a/devices/qemu-armv7l/default.nix b/devices/qemu-armv7l/default.nix index 97747c9f..f603eb8d 100644 --- a/devices/qemu-armv7l/default.nix +++ b/devices/qemu-armv7l/default.nix @@ -67,7 +67,7 @@ }; in { defaultOutput = "vmroot"; - loadAddress = "0x00010000"; + loadAddress = lim.parseInt "0x00010000"; entryPoint = "0x00010000"; rootDevice = "/dev/mtdblock0"; diff --git a/modules/hardware.nix b/modules/hardware.nix index aa20d65b..7c9dcd8d 100644 --- a/modules/hardware.nix +++ b/modules/hardware.nix @@ -59,7 +59,7 @@ in { type = types.str; }; }; - loadAddress = mkOption { default = null; }; + loadAddress = mkOption { type = types.ints.unsigned; default = null; }; entryPoint = mkOption { }; radios = mkOption { description = '' diff --git a/modules/outputs/ubimage.nix b/modules/outputs/ubimage.nix index 3d553e24..795eb797 100644 --- a/modules/outputs/ubimage.nix +++ b/modules/outputs/ubimage.nix @@ -10,7 +10,7 @@ let instructions = pkgs.writeText "env.scr" '' setenv serverip ${cfg.serverip} setenv ipaddr ${cfg.ipaddr} - setenv loadaddr ${cfg.loadAddress} + setenv loadaddr ${lib.toHexString cfg.loadAddress} ''; in { options.system.outputs = { diff --git a/modules/tftpboot.nix b/modules/tftpboot.nix index 85e70993..2c3c8792 100644 --- a/modules/tftpboot.nix +++ b/modules/tftpboot.nix @@ -70,13 +70,13 @@ in { in pkgs.buildPackages.runCommand "boot-scr" { nativeBuildInputs = [ pkgs.pkgsBuildBuild.dtc ]; } '' uimageSize=$(($(stat -L -c %s ${o.uimage}) + 0x1000 &(~0xfff))) - rootfsStart=0x$(printf %x $((${cfg.loadAddress} + 0x100000 + $uimageSize &(~0xfffff) ))) + rootfsStart=0x$(printf %x $((${toString cfg.loadAddress} + 0x100000 + $uimageSize &(~0xfffff) ))) 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"; - dtbStart=$(printf %x $((${cfg.loadAddress} + $rootfsBytes + 0x100000 + $uimageSize ))) + dtbStart=$(printf %x $((${toString cfg.loadAddress} + $rootfsBytes + 0x100000 + $uimageSize ))) mkdir $out cat ${o.dtb} > $out/dtb @@ -89,8 +89,8 @@ in { setenv serverip ${cfg.serverip} setenv ipaddr ${cfg.ipaddr} setenv bootargs 'liminix ${cmdline} $cmd' - tftpboot 0x$(printf %x ${cfg.loadAddress}) result/uimage ; tftpboot 0x$(printf %x $rootfsStart) result/rootfs ; tftpboot 0x$dtbStart result/dtb - bootm 0x$(printf %x ${cfg.loadAddress}) - 0x$dtbStart + tftpboot 0x${lib.toHexString cfg.loadAddress} result/uimage ; tftpboot 0x$(printf %x $rootfsStart) result/rootfs ; tftpboot 0x$dtbStart result/dtb + bootm 0x$${lib.toHexString cfg.loadAddress} - 0x$dtbStart EOF ''; }; diff --git a/pkgs/kernel/uimage.nix b/pkgs/kernel/uimage.nix index ceebe9a7..f2caeea2 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 ${loadAddress} -e ${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 ${entryPoint} -n '${lib.toUpper arch} Liminix Linux ${extraName}' -d vmlinux.bin.lzma kernel.uimage ''; buildPhaseFIT = '' @@ -57,7 +57,7 @@ in { images { kernel { data = /incbin/("./vmlinux.bin.lzma"); - load = <${loadAddress}>; + load = <0x${lib.toHexString loadAddress}>; entry = <${entryPoint}>; arch = "${arch}"; compression = "lzma";