commit 9c894bdabfc039174ea55546e6d65fb8174b2ce7
parent a962f183696cf56c9fc98180a50605b788a8ecb7
Author: Daniel Barlow <dan@telent.net>
Date: Thu, 21 Dec 2023 19:17:14 +0000
add tftpboot test for mips
Diffstat:
8 files changed, 95 insertions(+), 5 deletions(-)
diff --git a/devices/families/qemu.nix b/devices/families/qemu.nix
@@ -33,7 +33,7 @@
in {
defaultOutput = "vmroot";
rootDevice = "/dev/mtdblock0";
- dts.src = null;
+ dts.src = pkgs.lib.mkDefault null;
flash.eraseBlockSize = 65536;
networkInterfaces =
let inherit (config.system.service.network) link;
diff --git a/devices/qemu/default.nix b/devices/qemu/default.nix
@@ -36,7 +36,7 @@
in the Development manual.
'';
- module = {pkgs, config, lim, ... }: {
+ module = {pkgs, config, lib, lim, ... }: {
imports = [
../../modules/arch/mipseb.nix
../families/qemu.nix
@@ -50,5 +50,24 @@
SERIAL_8250_CONSOLE= "y";
};
};
+ hardware =
+ # from arch/mips/mti-malta/Platform:load-$(CONFIG_MIPS_MALTA) += 0xffffffff80100000
+ let addr = lim.parseInt "0x80100000";
+ in {
+ loadAddress = addr;
+ entryPoint = addr;
+
+ # Unlike the arm qemu targets, we need a static dts when
+ # running u-boot-using tests, qemu dumpdtb command doesn't
+ # work for this board. I am not at all sure this dts is
+ # *correct* but it does at least boot
+ dts = lib.mkForce {
+ src = "${config.system.outputs.kernel.modulesupport}/arch/mips/boot/dts/mti/malta.dts";
+ includes = [
+ "${config.system.outputs.kernel.modulesupport}/arch/mips/boot/dts/"
+ ];
+ };
+
+ };
};
}
diff --git a/overlay.nix b/overlay.nix
@@ -224,6 +224,34 @@ extraPkgs // {
'';
};
+ ubootQemuMips = final.buildUBoot {
+ defconfig = "malta_defconfig";
+ extraMeta.platforms = ["mips-linux"];
+ filesToInstall = ["u-boot.bin"];
+ # define the prompt to be the same as arm{32,64} so
+ # we can use the same expect script for both
+ extraPatches = [ ./pkgs/u-boot/0002-virtio-init-for-malta.patch ];
+ extraConfig = ''
+ CONFIG_SYS_PROMPT="=> "
+ CONFIG_VIRTIO=y
+ CONFIG_AUTOBOOT=y
+ CONFIG_DM_PCI=y
+ CONFIG_VIRTIO_PCI=y
+ CONFIG_VIRTIO_NET=y
+ CONFIG_VIRTIO_BLK=y
+ CONFIG_VIRTIO_MMIO=y
+ CONFIG_QFW_MMIO=y
+ CONFIG_FIT=y
+ CONFIG_LZMA=y
+ CONFIG_CMD_LZMADEC=y
+ CONFIG_SYS_BOOTM_LEN=0x1000000
+ CONFIG_SYS_MALLOC_LEN=0x400000
+ CONFIG_MIPS_BOOT_FDT=y
+ CONFIG_OF_LIBFDT=y
+ CONFIG_OF_STDOUT_VIA_ALIAS=y
+ '';
+ };
+
# gnufdisk = prev.gnufdisk.override {
# guile = null;
# };
diff --git a/pkgs/kernel/default.nix b/pkgs/kernel/default.nix
@@ -51,6 +51,7 @@ stdenv.mkDerivation rec {
patches = [
./cmdline-cookie.patch
./phram-allow-cached-mappings.patch
+ ./mips-malta-fdt-from-bootloader.patch
];
# this is here to work around what I think is a bug in nixpkgs
diff --git a/pkgs/kernel/mips-malta-fdt-from-bootloader.patch b/pkgs/kernel/mips-malta-fdt-from-bootloader.patch
@@ -0,0 +1,18 @@
+diff --git a/arch/mips/mti-malta/malta-setup.c b/arch/mips/mti-malta/malta-setup.c
+index 21cb3ac1237b..f11409ae9583 100644
+--- a/arch/mips/mti-malta/malta-setup.c
++++ b/arch/mips/mti-malta/malta-setup.c
+@@ -192,7 +192,12 @@ static void __init bonito_quirks_setup(void)
+
+ void __init *plat_get_fdt(void)
+ {
+- return (void *)__dtb_start;
++ void *r=0;
++ if(fw_arg0 == -2)
++ r = (void *) KSEG1ADDR(fw_arg1);
++ else
++ r = (void *) __dtb_start;
++ return r;
+ }
+
+ void __init plat_mem_setup(void)
diff --git a/pkgs/u-boot/0002-virtio-init-for-malta.patch b/pkgs/u-boot/0002-virtio-init-for-malta.patch
@@ -0,0 +1,15 @@
+diff --git a/board/imgtec/malta/malta.c b/board/imgtec/malta/malta.c
+index 9853a0ba82..d95e332d6d 100644
+--- a/board/imgtec/malta/malta.c
++++ b/board/imgtec/malta/malta.c
+@@ -169,7 +169,9 @@ int board_early_init_f(void)
+ int misc_init_r(void)
+ {
+ rtc_reset();
+-
++#if IS_ENABLED(CONFIG_VIRTIO)
++ virtio_init();
++#endif
+ return 0;
+ }
+
diff --git a/tests/tftpboot/configuration.nix b/tests/tftpboot/configuration.nix
@@ -18,9 +18,17 @@ in {
../../modules/outputs/tftpboot.nix
];
config = {
- hardware.dts.src = lib.mkForce dts;
+ # use extracted dts if it was null in the device
+ # definition, use actual dts if provided
+ hardware.dts.src = lib.mkOverride 500 dts;
boot.tftp = {
- loadAddress = lim.parseInt "0x44000000";
+ loadAddress =
+ let offsets = {
+ mips = "0x88000000";
+ arm = "0x44000000";
+ aarch64 = "0x44000000";
+ };
+ in lim.parseInt offsets.${pkgs.stdenv.hostPlatform.qemuArch} ;
serverip = "10.0.2.2";
ipaddr = "10.0.2.15";
};
diff --git a/tests/tftpboot/test.nix b/tests/tftpboot/test.nix
@@ -30,6 +30,7 @@ run-liminix-vm \
expect ${./script.expect} 2>&1 |tee $out
'';
in {
- arm = check "qemu-armv7l" "ubootQemuArm";
aarch64 = check "qemu-aarch64" "ubootQemuAarch64";
+ arm = check "qemu-armv7l" "ubootQemuArm";
+ mips = check "qemu" "ubootQemuMips";
}