1
0

Compare commits

...

6 Commits

Author SHA1 Message Date
fd28f0ce04 rt3200 needs pmsg-size set in its dts for persistent logging 2025-01-01 14:11:22 +00:00
497307588f automate ubimage instructions a little 2025-01-01 12:38:08 +00:00
788169586f /boot is a directory, copy files instead of replacing it with symlink
for the record, u-boot doesn't like having /boot/fit -> ../nix/store/..../fit
symlinks so we don't use symlinks inside /boot either
2025-01-01 12:29:25 +00:00
3af9e86624 rt3200: replace bootcmd variable
the default is to boot to recovery if there's anything in pstore, but
this doesn't interact well with persstent logging
2025-01-01 11:56:54 +00:00
28d39cd66d provide etc/kconfig in updater output
this is for debugging/documentation purposes and isn't copied to the
device
2025-01-01 11:55:33 +00:00
9dd169d500 add "config" output to kernel derivation 2025-01-01 11:54:46 +00:00
6 changed files with 56 additions and 36 deletions

View File

@ -86,16 +86,25 @@
Name: liminix
Character device major/minor: 250:8
root@OpenWrt:~# ubiupdatevol /dev/ubi0_7 /tmp/rootfs
root@OpenWrt:~# fw_setenv orig_boot_production $(fw_printenv boot_production | sed -E 's/.+?=//')
To make the new system bootable we also need to change some U-Boot variables.
``boot_production`` needs to mount the filesystem and boot the FIT image
found there, and :code:`bootcmd` needs to be told _not_ to boot the rescue
image if there are records in pstore, because that interferes with
``config.log.persistent``
root@OpenWrt:~# fw_setenv orig_boot_production $(fw_printenv -n boot_production)
root@OpenWrt:~# fw_setenv orig_bootcmd $(fw_printenv -n bootcmd)
root@OpenWrt:~# fw_setenv boot_production 'led $bootled_pwr on ; ubifsmount ubi0:liminix && ubifsload ''${loadaddr} boot/fit && bootm ''${loadaddr}'
root@OpenWrt:~# fw_setenv bootcmd 'run boot_ubi'
For subsequent Liminix reinstalls, you don't need to repeat the
"Preparation" step and in fact should seek to avoid it if
possible. Updating volumes with :command:`ubiupdatevol` will
preserve the erase counters used for write levelling, so is
preferred over any kind of "factory" wipe which will reset them.
'';
For subsequent Liminix reinstalls, just run the
:command:`ubiupdatevol` command again. You don't need to repeat
the "Preparation" step and in fact should seek to avoid it if
possible, as it will reset the erase counters used for write
levelling. Using UBI-aware tools is therefore preferred over any
kind of "factory" wipe which will reset them.
'';
system = {
crossSystem = {
@ -104,7 +113,8 @@
};
module = {pkgs, config, lib, lim, ... }:
let firmware = pkgs.stdenv.mkDerivation {
let inherit (lib) mkIf;
firmware = pkgs.stdenv.mkDerivation {
name = "wlan-firmware";
phases = ["installPhase"];
installPhase = ''
@ -259,6 +269,9 @@
"${openwrt.src}/target/linux/mediatek/dts"
"${config.system.outputs.kernel.modulesupport}/arch/arm64/boot/dts/mediatek/"
];
includes = mkIf config.logging.persistent.enable [
./pstore-pmsg.dtsi
];
};
# - 0x000000000000-0x000008000000 : "spi-nand0"

View File

@ -0,0 +1,8 @@
/ {
reserved-memory {
/* make sure address matches upstream */
ramoops@42ff0000 {
pmsg-size = <0x10000>;
};
};
};

View File

@ -7,10 +7,12 @@
let
inherit (lib) mkIf mkOption types;
cfg = config.boot.tftp;
instructions = pkgs.writeText "env.scr" ''
instructions = pkgs.writeText "flash.scr" ''
setenv serverip ${cfg.serverip}
setenv ipaddr ${cfg.ipaddr}
setenv loadaddr ${lib.toHexString cfg.loadAddress}
tftpboot $loadaddr result/rootfs
ubi write $loadaddr liminix $filesize
'';
in {
options.system.outputs = {
@ -63,18 +65,20 @@ Now we can make our new root volume
uboot> ubi create liminix -
3) transfer the root filesystem from the build system and write it
to the new volume. Paste the environment variable settings from
:file:`result/env.scr` into U-Boot, then run
3) transfer the root filesystem from the build system and write it to
the new volume. Paste the contents of :file:`result/flash.scr` one line at a time
into U-Boot:
.. code-block:: console
uboot> tftpboot ''${loadaddr} result/rootfs
uboot> ubi write ''${loadaddr} liminix $filesize
uboot> setenv serverip 10.0.0.1
uboot> setenv ipaddr 10.0.0.8
uboot> setenv loadaddr 4007FF28
uboot> tftpboot $loadaddr result/rootfs
uboot> ubi write $loadaddr liminix $filesize
Now we have the root filesystem installed on the device. You
can even mount it and poke around using ``ubifsmount ubi0:liminix;
ubifsls /``
can even mount it and poke around using :command:`ubifsmount ubi0:liminix; ubifsls /`
4) optional: before you configure the device to boot into Liminix
automatically, you can try booting it by hand to see if it works:
@ -89,20 +93,11 @@ Once you've done this and you're happy with it, reset the device to
return to U-Boot.
5) Instructions for configuring autoboot are likely to be very
device-dependent. On the Linksys E8450/Belkin RT3200, the environment
variable `boot_production` governs what happens on a normal boot, so
you could do
.. code-block:: console
uboot> setenv orig_boot_production $boot_production
uboot> setenv boot_production 'led $bootled_pwr on ; ubifsmount ubi0:liminix && ubifsload ''${loadaddr} boot/fit && bootm ''${loadaddr}'
uboot> saveenv
uboot> reset
On other devices, some detective work may be needed. Try running
`printenv` and look for likely commands, try looking at the existing
boot process, maybe even try looking for documentation for that device.
device-dependent and you should consult the Liminix documentation for
your device. (If you're bringing up a new device, some detective work
may be needed. Try running `printenv` and trace through the flow of
execution from (probably) :command:`$bootcmd` and look for a suitable
variable to change)
6) Now you can reboot the device into Liminix
@ -120,6 +115,6 @@ boot process, maybe even try looking for documentation for that device.
mkdir $out
cd $out
ln -s ${o.rootfs} rootfs
ln -s ${instructions} env.scr
ln -s ${instructions} flash.scr
'';
}

View File

@ -27,7 +27,8 @@ in
config.system.outputs.updater =
runCommand "buildUpdater" { } ''
mkdir -p $out/bin
mkdir -p $out/bin $out/etc
cp ${o.kernel.config} $out/etc/kconfig
substitute ${./update.sh} $out/bin/update.sh \
--subst-var-by toplevel ${o.systemConfiguration} \
--subst-var-by min_copy_closure ${min-copy-closure}

View File

@ -45,7 +45,7 @@ stdenv.mkDerivation rec {
dontStrip = true;
dontPatchELF = true;
outputs = ["out" "headers" "modulesupport"] ++ targetNames;
outputs = ["out" "headers" "modulesupport" "config"] ++ targetNames;
phases = [
"unpackPhase"
"butcherPkgconfig"
@ -114,5 +114,6 @@ stdenv.mkDerivation rec {
mkdir -p $modulesupport
make modules
cp -a . $modulesupport
cp .config $config
'';
}

View File

@ -99,8 +99,10 @@ in attrset:
cp -v -fP \$src/bin/* \$src/etc/* \$dest
${if attrset ? boot then ''
(cd \$dest
if test -e boot ; then rm boot ; fi
ln -sf ${lib.strings.removePrefix "/" attrset.boot.target} ./boot
test -d boot || mkdir boot
cd boot
cp ../${lib.strings.removePrefix "/" attrset.boot.target}/* .
sync; sync
)
'' else ""}
EOF