Compare commits

...

7 Commits

Author SHA1 Message Date
Daniel Barlow ec1ff283da vmdisk output: allow extra params to run.sh 2023-12-29 18:12:57 +00:00
Daniel Barlow 0bf98c5243 add output for u-boot 2023-12-29 17:07:47 +00:00
Daniel Barlow dc42969ef6 dribble 2023-12-29 16:54:35 +00:00
Daniel Barlow 1a041392aa liminix-rebuild: add --no-reboot param 2023-12-27 17:47:42 +00:00
Daniel Barlow 6469408d5f run-liminix-vm: don't reverse order of --flags params 2023-12-26 21:59:00 +00:00
Daniel Barlow f020d5b25d qemu mips: enable rebooting 2023-12-26 21:58:18 +00:00
Daniel Barlow e5cbc2b86b WIP add systemConfiguration "install" command
which copies the init stuff (whatever it is) from store to /persist
instead of making liminix-rebuild have to know what the files are.

This is principally to ease making a system configuration in /mnt or
similar when operating in a rescue/recovery scenario, and we
don't want to liminix-rebuild because it will reboot
2023-12-23 23:53:47 +00:00
11 changed files with 154 additions and 21 deletions

View File

@ -3176,9 +3176,6 @@ Turris TODO
- perhaps we need different boot "recipes" - e.g. some device
might want boot.scr and another something different
- create installable tarball and test
- gpio thingy for SFP switching
- iperf
@ -3630,14 +3627,129 @@ back into it
- build a stripped-down installer image which can be put on a
usb stick
- from openwrt on the device, use fw_setenv to set boot order
- boot into the installer image
- reformat the emmc as per requirements
- ???
- boot into the installer image-
reformat the emmc as per requirements
- PREFIX=/mnt liminix-rebuild
- profit
the missing step might be to do a cpio from installer onto
the emmc
Could we liminix-rebuild into /some/prefix/nix/store this would
actually be useful both for this boot-from-usb scenario and for
levitate. Looks like min-copy-closure doesn't need anything much on
the destination system except a working sshd and maybe an empty
/nix/store and /persist. Potentially we could even do it without
chroot (which would save running a second sshd), just add a prefix on
the paths
or something with chroot
what's the fallback? we're not touching the turris rescue
system (which is in nor flash) so we can expect all the
knightrider modes to continue to workto be able to
boot back into that and restore the vendor os? I think so
is levitate useful here?
Fri Dec 22 16:56:40 GMT 2023
If we're going to use fw_setenv to change boot order,
we could equally well boot from tftp and not need the
usb stick
fw_setenv boot_targets "tftp mmc0 nvme0 scsi0 usb0 pxe dhcp"
setenv bootcmd_tftp "echo TFTP BOOT"
how can we get a tftp boot into few enough characters to reasonably
put it in an environment variable?
- use dhcp?
- embed bootargs into the fdt
Fri Dec 22 21:10:53 GMT 2023
* dtb needs size and offset of uncompressed root filesystem to add
reserved-memory and cmdline params
* setting these in the dtb will change the size of the dtb
* am assuming that we don't want the kernel to relocate into
ram that clashes with the root fs
* should we care about phys mem fragmentation?
conclusion:
hardware.loadAddress
<uncompressed/relocated kernel>
tftp.loadAddress
<space for uncompressed root>
uimage or zimage
dtb
compressed root
[ should we rename hardware.loadAddress to something that expresses
more clearly it's the _kernel_ load address? ]
[ another thing we need to do is stop building two kernels
because the uimage and zimage derivations are different ]
Sat Dec 23 18:07:43 GMT 2023
Addendum: for a zimage we need the compressed kernel to be at the
highest address, otherwise it prints "Starting" and then hangs
indefinitely.
I believe this to be because the kernel decompressor sets up a stack
directly after the compressed payload, so will trash the fdt if it was
also there. The bug didn't exhibit on Turris Omnia with the same
layout, but maybe that was just luck.
Sat Dec 23 18:11:04 GMT 2023
Here is scope of work for Turris:
(I) we need to build a suitable tftpboot image for
recovery/install.
- disk partitioning tools and mkfs stuff
- dhcp client for connecting to wired network
(II) we need insttuctions for building the real system
and using min-copy-closure to copy and install the system
configuration of the real one into /mnt
(III) probably try the same recovery image as a USB stick
(IV) I've lost track of what we're doing with /boot, does that work?
(V) gpio thingy for SFP switching
(VI) iperf, performance testing
(VII) put device name and usefulness tiers ("stable", "experimental", "wip") in the docs
(VIII) params for ubi(fs) are a mess
(IX) wlan country code
Tue Dec 26 16:23:37 GMT 2023
I seem to have lost a chunk of notes here. Have added
systemConfiguration/bin/install which does the stuff to copy the right
files into /bin and wherever. There is currently no test for it though
We could further simplify liminix-rebuild by adding --reboot as a flag
to install
Tue Dec 26 21:38:43 GMT 2023
To be any use, the test needs to be end-to-end - as in, rather than
just checking some files are copied, test that the machine rebooted
successfully
COPYING /nix/store/dlz86nip271ybaz0cip7bgkbzijk0cr7-make-stuff-mips-unknown-linux-musl TO //persist
/nix/store/gr255qjxijksf9361glsj5lz0cklassx-profile
md5sum /persist/activate
8eb0760c39cdee0b141b15bbafbc94a0 /persist/activate BAD
6c27b75cbe9f2ce87c1fd1425362108f /persist/activate GOOD
8eb0760c39cdee0b141b15bbafbc94a0 /persist/activate

View File

@ -46,6 +46,9 @@
MIPS_MALTA= "y";
CPU_MIPS32_R2= "y";
POWER_RESET = "y";
POWER_RESET_SYSCON = "y";
SERIAL_8250= "y";
SERIAL_8250_CONSOLE= "y";
};

View File

@ -13,5 +13,6 @@
# USE_OF = "y";
};
hardware.ram.startAddress = lim.parseInt "0x40000000";
system.outputs.u-boot = pkgs.ubootQemuAarch64;
};
}

View File

@ -5,5 +5,6 @@
OF = "y";
};
hardware.ram.startAddress = lim.parseInt "0x40000000";
system.outputs.u-boot = pkgs.ubootQemuArm;
};
}

View File

@ -5,5 +5,6 @@
kernel.config = {
CPU_BIG_ENDIAN = "y";
};
system.outputs.u-boot = pkgs.ubootQemuMips;
};
}

View File

@ -60,6 +60,9 @@ in
Combined kernel and FDT in uImage (U-Boot compatible) format
'';
};
u-boot = mkOption {
type = types.package;
};
manifest = mkOption {
type = types.package;
internal = true;

View File

@ -42,7 +42,7 @@ in {
ln -s ${o.mbrimage} ./mbrimage
cat > run.sh <<EOF
#!${pkgs.runtimeShell}
${pkgs.pkgsBuildBuild.run-liminix-vm}/bin/run-liminix-vm --arch ${pkgs.stdenv.hostPlatform.qemuArch} --u-boot ${pkgs.ubootQemuArm}/u-boot.bin --phram-address 0x${phram_address} --disk-image ${o.mbrimage} /dev/null /dev/null
${pkgs.pkgsBuildBuild.run-liminix-vm}/bin/run-liminix-vm --arch ${pkgs.stdenv.hostPlatform.qemuArch} --u-boot ${o.u-boot}/u-boot.bin --phram-address 0x${phram_address} --disk-image ${o.mbrimage} \$* /dev/null /dev/null
EOF
chmod +x run.sh
'';

View File

@ -1,18 +1,25 @@
#!/usr/bin/env bash
ssh_command=${SSH_COMMAND-ssh}
if [ "$1" = "--no-reboot" ] ; then
reboot="true"
shift
else
reboot="reboot"
fi
target_host=$1
shift
if [ -z "$target_host" ] ; then
echo Usage: liminix-rebuild target-host params
echo Usage: liminix-rebuild [--no-reboot] target-host params
exit 1
fi
if toplevel=$(nix-build "$@" -A outputs.systemConfiguration --no-out-link); then
echo systemConfiguration $toplevel
min-copy-closure $target_host $toplevel
$ssh_command $target_host cp -v -fP $toplevel/bin/* $toplevel/etc/* /persist
$ssh_command $target_host $toplevel/bin/install
$ssh_command $target_host "sync; source /etc/profile; reboot"
else
echo Rebuild failed

View File

@ -45,7 +45,7 @@
["--wan" spec & rest] (assoc (parse-args rest) :wan spec)
["--command-line" cmd & rest] (assoc (parse-args rest) :command-line cmd)
["--flag" flag & rest] (let [o (parse-args rest)]
(assoc o :flags (doto o.flags (table.insert flag))))
(assoc o :flags (doto o.flags (table.insert 1 flag))))
[kernel rootfsimg]
{ :flags [] :kernel kernel :rootfs (pad-file rootfsimg (* 16 1024)) }
))

View File

@ -80,5 +80,10 @@ in attrset:
cp $closure/store-paths $out/etc/nix-store-paths
$STRIP --remove-section=.note --remove-section=.comment --strip-all makedevs -o $out/bin/activate
ln -s ${s6-init-bin}/bin/init $out/bin/init
cat > $out/bin/install <<EOF
#!/bin/sh
cp -v -fP $out/bin/* $out/etc/* \''${1-/}/persist
EOF
chmod +x $out/bin/install
'';
}

View File

@ -1,7 +1,7 @@
{
liminix
}:
let check = deviceName : ubootName : config :
let check = deviceName : config :
let derivation = (import liminix {
device = import "${liminix}/devices/${deviceName}/";
liminix-config = { pkgs, ... } : {
@ -10,7 +10,7 @@ let derivation = (import liminix {
};
});
img = derivation.outputs.tftpboot;
uboot = derivation.pkgs.${ubootName};
uboot = derivation.outputs.u-boot;
pkgsBuild = derivation.pkgs.pkgsBuildBuild;
in pkgsBuild.runCommand "check" {
nativeBuildInputs = with pkgsBuild; [
@ -35,13 +35,13 @@ run-liminix-vm \
expect ${./script.expect} 2>&1 |tee $out
'';
in {
aarch64 = check "qemu-aarch64" "ubootQemuAarch64" {};
arm = check "qemu-armv7l" "ubootQemuArm" {};
armZimage = check "qemu-armv7l" "ubootQemuArm" {
aarch64 = check "qemu-aarch64" {};
arm = check "qemu-armv7l" {};
armZimage = check "qemu-armv7l" {
boot.tftp.kernelFormat = "zimage";
};
mips = check "qemu" "ubootQemuMips" {};
mipsLz = check "qemu" "ubootQemuMips" {
mips = check "qemu" {};
mipsLz = check "qemu" {
boot.tftp.compressRoot = true;
};
}