Compare commits
2 Commits
71a1ef286e
...
e8e0de0284
Author | SHA1 | Date | |
---|---|---|---|
e8e0de0284 | |||
6920ee765d |
36
THOUGHTS.txt
36
THOUGHTS.txt
@ -4044,8 +4044,36 @@ will depend on whether there's a writable fs or not, which is unexpected)
|
|||||||
|
|
||||||
Tue Feb 13 22:31:03 GMT 2024
|
Tue Feb 13 22:31:03 GMT 2024
|
||||||
|
|
||||||
the reason we can't reboot is that there is a service to add each lan
|
* the reason we can't reboot is that there is a service to add each
|
||||||
device to the bridge which does ifwait $dev running, which doesn't
|
lan device to the bridge which does ifwait $dev running, which doesn't
|
||||||
return until there's something plugged in. So s6-rc hangs indefinitely
|
return until there's something plugged in. So s6-rc hangs indefinitely
|
||||||
until the lan switch is fully populated. This is definitely a
|
until the lan switch is fully populated. This is definitely a "next
|
||||||
"next milestone" thing
|
milestone" thing.
|
||||||
|
|
||||||
|
* another example of "thing that depends on other thing but which it
|
||||||
|
is actually OK if neither of them happen" might be "mount a
|
||||||
|
filesystem if there is a usb mass storage device attached"
|
||||||
|
|
||||||
|
* I don't know if failover also fits into the model we don't quite
|
||||||
|
have. LTE route depends on pppoe not being healthy
|
||||||
|
|
||||||
|
we can have services (or bundles) that aren't part of the default target,
|
||||||
|
and plumb them into events of some kind (netlink?) to bring them up/down?
|
||||||
|
|
||||||
|
we can use s6-rc instanced services:
|
||||||
|
https://skarnet.org/software/s6/instances.html
|
||||||
|
|
||||||
|
"s6-instance-create and s6-instance-delete are relatively expensive operations, because they have to recursively copy or delete directories and use the synchronization mechanism with the instance supervisor, compared to s6-instance-control which only has to send commands to already existing supervisors. If you are going to turn instances on and off on a regular basis, it is more efficient to keep the instance existing and control it with s6-instance-control than it is to repeatedly create and delete it. "
|
||||||
|
|
||||||
|
Probably we need something that reads netlink messages and converts
|
||||||
|
them to a format that we can use to control services. Is there a
|
||||||
|
benefit to using services here and not just running commands? it means
|
||||||
|
the system state change we desire will stay changed.
|
||||||
|
|
||||||
|
TODO items not to lose track of
|
||||||
|
|
||||||
|
- speed testing (iperf)
|
||||||
|
- make gl-ar750 tftpboot build again
|
||||||
|
- finish belkin
|
||||||
|
- install sniproxy
|
||||||
|
- is there something simple we can do to make it reboot again?
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
let
|
let
|
||||||
inherit (lib) mkOption types concatStringsSep;
|
inherit (lib) mkOption types concatStringsSep;
|
||||||
cfg = config.boot.tftp;
|
cfg = config.boot.tftp;
|
||||||
|
hw = config.hardware;
|
||||||
in {
|
in {
|
||||||
imports = [ ../ramdisk.nix ];
|
imports = [ ../ramdisk.nix ];
|
||||||
options.boot.tftp = {
|
options.boot.tftp = {
|
||||||
@ -22,6 +23,10 @@ in {
|
|||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
};
|
};
|
||||||
|
appendDTB = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
options.system.outputs = {
|
options.system.outputs = {
|
||||||
tftpboot = mkOption {
|
tftpboot = mkOption {
|
||||||
@ -62,24 +67,46 @@ in {
|
|||||||
uimage = "bootm";
|
uimage = "bootm";
|
||||||
zimage = "bootz";
|
zimage = "bootz";
|
||||||
}; in choices.${cfg.kernelFormat};
|
}; in choices.${cfg.kernelFormat};
|
||||||
|
|
||||||
cmdline = concatStringsSep " " config.boot.commandLine;
|
cmdline = concatStringsSep " " config.boot.commandLine;
|
||||||
|
objcopy = "${pkgs.stdenv.cc.bintools.targetPrefix}objcopy";
|
||||||
|
stripAndZip = ''
|
||||||
|
${objcopy} -O binary -R .reginfo -R .notes -R .note -R .comment -R .mdebug -R .note.gnu.build-id -S vmlinux.elf vmlinux.bin
|
||||||
|
rm -f vmlinux.bin.lzma ; lzma -k -z vmlinux.bin
|
||||||
|
'';
|
||||||
in
|
in
|
||||||
pkgs.runCommand "tftpboot" { nativeBuildInputs = with pkgs.pkgsBuildBuild; [ lzma dtc ]; } ''
|
pkgs.runCommand "tftpboot" { nativeBuildInputs = with pkgs.pkgsBuildBuild; [ lzma dtc pkgs.stdenv.cc ubootTools ]; } ''
|
||||||
mkdir $out
|
mkdir $out
|
||||||
cd $out
|
cd $out
|
||||||
binsize() { local s=$(stat -L -c %s $1); echo $(($s + 0x1000 &(~0xfff))); }
|
binsize() { local s=$(stat -L -c %s $1); echo $(($s + 0x1000 &(~0xfff))); }
|
||||||
binsize64k() { local s=$(stat -L -c %s $1); echo $(($s + 0x10000 &(~0xffff))); }
|
binsize64k() { local s=$(stat -L -c %s $1); echo $(($s + 0x10000 &(~0xffff))); }
|
||||||
hex() { printf "0x%x" $1; }
|
hex() { printf "0x%x" $1; }
|
||||||
|
|
||||||
rootfsStart=${toString cfg.loadAddress}
|
rootfsStart=${toString cfg.loadAddress}
|
||||||
rootfsSize=$(binsize64k ${o.rootfs} )
|
rootfsSize=$(binsize64k ${o.rootfs} )
|
||||||
rootfsSize=$(($rootfsSize + ${toString cfg.freeSpaceBytes} ))
|
rootfsSize=$(($rootfsSize + ${toString cfg.freeSpaceBytes} ))
|
||||||
dtbStart=$(($rootfsStart + $rootfsSize))
|
|
||||||
imageSize=$(binsize ${image})
|
|
||||||
|
|
||||||
ln -s ${o.manifest} manifest
|
ln -s ${o.manifest} manifest
|
||||||
ln -s ${image} image
|
|
||||||
ln -s ${o.kernel} vmlinux # handy for gdb
|
ln -s ${o.kernel} vmlinux # handy for gdb
|
||||||
|
|
||||||
|
# if we are transferring kernel and dtb separately, the
|
||||||
|
# dtb has to precede the kernel in ram, because zimage
|
||||||
|
# decompression code will assume that any memory after the
|
||||||
|
# end of the kernel is free
|
||||||
|
|
||||||
|
dtbStart=$(($rootfsStart + $rootfsSize))
|
||||||
|
${if cfg.compressRoot
|
||||||
|
then ''
|
||||||
|
lzma -z9cv ${o.rootfs} > rootfs.lz
|
||||||
|
rootfsLzStart=$dtbStart
|
||||||
|
rootfsLzSize=$(binsize rootfs.lz)
|
||||||
|
dtbStart=$(($dtbStart + $rootfsLzSize))
|
||||||
|
''
|
||||||
|
else ''
|
||||||
|
ln -s ${o.rootfs} rootfs
|
||||||
|
''
|
||||||
|
}
|
||||||
|
|
||||||
cat ${o.dtb} > dtb
|
cat ${o.dtb} > dtb
|
||||||
address_cells=$(fdtget dtb / '#address-cells')
|
address_cells=$(fdtget dtb / '#address-cells')
|
||||||
size_cells=$(fdtget dtb / '#size-cells')
|
size_cells=$(fdtget dtb / '#size-cells')
|
||||||
@ -93,34 +120,41 @@ in {
|
|||||||
fdtput -p -t s dtb /reserved-memory/$node compatible phram
|
fdtput -p -t s dtb /reserved-memory/$node compatible phram
|
||||||
fdtput -p -t lx dtb /reserved-memory/$node reg $ac_prefix $(hex $rootfsStart) $sz_prefix $(hex $rootfsSize)
|
fdtput -p -t lx dtb /reserved-memory/$node reg $ac_prefix $(hex $rootfsStart) $sz_prefix $(hex $rootfsSize)
|
||||||
|
|
||||||
dtbSize=$(binsize ./dtb )
|
|
||||||
imageStart=$(($dtbStart + $dtbSize))
|
|
||||||
${if cfg.compressRoot
|
|
||||||
then ''
|
|
||||||
lzma -z9cv ${o.rootfs} > rootfs.lz
|
|
||||||
rootfsLzStart=$(($imageStart + $imageSize))
|
|
||||||
rootfsLzSize=$(binsize rootfs.lz)
|
|
||||||
''
|
|
||||||
else "ln -s ${o.rootfs} rootfs"
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd="liminix ${cmdline} mtdparts=phram0:''${rootfsSize}(rootfs) phram.phram=phram0,''${rootfsStart},''${rootfsSize},${toString config.hardware.flash.eraseBlockSize} root=/dev/mtdblock0";
|
cmd="liminix ${cmdline} mtdparts=phram0:''${rootfsSize}(rootfs) phram.phram=phram0,''${rootfsStart},''${rootfsSize},${toString config.hardware.flash.eraseBlockSize} root=/dev/mtdblock0";
|
||||||
fdtput -t s dtb /chosen bootargs "$cmd"
|
fdtput -t s dtb /chosen bootargs "$cmd"
|
||||||
|
|
||||||
# dtc -I dtb -O dts -o /dev/stdout dtb | grep -A10 chosen ; exit 1
|
dtbSize=$(binsize ./dtb )
|
||||||
|
|
||||||
|
${if cfg.appendDTB then ''
|
||||||
|
imageStart=$dtbStart
|
||||||
|
# re-package image with updated dtb
|
||||||
|
cat ${o.kernel} > vmlinux.elf
|
||||||
|
${objcopy} --update-section .appended_dtb=dtb vmlinux.elf
|
||||||
|
${stripAndZip}
|
||||||
|
# TODO don't hardcode mips, entryPoint, loadAddress, name
|
||||||
|
mkimage -A mips -O linux -T kernel -C lzma -a $(hex ${toString hw.loadAddress}) -e $(hex ${toString hw.entryPoint}) -n 'MIPS Liminix Linux' -d vmlinux.bin.lzma image
|
||||||
|
# dtc -I dtb -O dts -o /dev/stdout dtb | grep -A10 chosen ; exit 1
|
||||||
|
tftpcmd="tftpboot $(hex $imageStart) result/image "
|
||||||
|
bootcmd="bootm $(hex $imageStart)"
|
||||||
|
'' else ''
|
||||||
|
imageStart=$(($dtbStart + $dtbSize))
|
||||||
|
tftpcmd="tftpboot $(hex $imageStart) result/image; tftpboot $(hex $dtbStart) result/dtb "
|
||||||
|
ln -s ${image} image
|
||||||
|
bootcmd="${bootCommand} $(hex $imageStart) - $(hex $dtbStart)"
|
||||||
|
''}
|
||||||
|
|
||||||
cat > boot.scr << EOF
|
cat > boot.scr << EOF
|
||||||
setenv serverip ${cfg.serverip}
|
setenv serverip ${cfg.serverip}
|
||||||
setenv ipaddr ${cfg.ipaddr}
|
setenv ipaddr ${cfg.ipaddr}
|
||||||
tftpboot $(hex $imageStart) result/image ; ${
|
${
|
||||||
if cfg.compressRoot
|
if cfg.compressRoot
|
||||||
then "tftpboot $(hex $rootfsLzStart) result/rootfs.lz"
|
then "tftpboot $(hex $rootfsLzStart) result/rootfs.lz"
|
||||||
else "tftpboot $(hex $rootfsStart) result/rootfs"
|
else "tftpboot $(hex $rootfsStart) result/rootfs"
|
||||||
}; tftpboot $(hex $dtbStart) result/dtb
|
}; $tftpcmd
|
||||||
${if cfg.compressRoot
|
${if cfg.compressRoot
|
||||||
then "lzmadec $(hex $rootfsLzStart) $(hex $rootfsStart); "
|
then "lzmadec $(hex $rootfsLzStart) $(hex $rootfsStart); "
|
||||||
else ""
|
else ""
|
||||||
} ${bootCommand} $(hex $imageStart) - $(hex $dtbStart)
|
} $bootcmd
|
||||||
EOF
|
EOF
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ let derivation = (import liminix {
|
|||||||
img = derivation.outputs.tftpboot;
|
img = derivation.outputs.tftpboot;
|
||||||
uboot = derivation.outputs.u-boot;
|
uboot = derivation.outputs.u-boot;
|
||||||
pkgsBuild = derivation.pkgs.pkgsBuildBuild;
|
pkgsBuild = derivation.pkgs.pkgsBuildBuild;
|
||||||
in pkgsBuild.runCommand "check" {
|
in pkgsBuild.runCommand "check-${deviceName}" {
|
||||||
nativeBuildInputs = with pkgsBuild; [
|
nativeBuildInputs = with pkgsBuild; [
|
||||||
expect
|
expect
|
||||||
socat
|
socat
|
||||||
@ -44,4 +44,7 @@ in {
|
|||||||
mipsLz = check "qemu" {
|
mipsLz = check "qemu" {
|
||||||
boot.tftp.compressRoot = true;
|
boot.tftp.compressRoot = true;
|
||||||
};
|
};
|
||||||
|
mipsOldUboot = check "qemu" {
|
||||||
|
boot.tftp.appendDTB = true;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user