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,15 +86,24 @@
Name: liminix Name: liminix
Character device major/minor: 250:8 Character device major/minor: 250:8
root@OpenWrt:~# ubiupdatevol /dev/ubi0_7 /tmp/rootfs 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 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, just run the
For subsequent Liminix reinstalls, you don't need to repeat the :command:`ubiupdatevol` command again. You don't need to repeat
"Preparation" step and in fact should seek to avoid it if the "Preparation" step and in fact should seek to avoid it if
possible. Updating volumes with :command:`ubiupdatevol` will possible, as it will reset the erase counters used for write
preserve the erase counters used for write levelling, so is levelling. Using UBI-aware tools is therefore preferred over any
preferred over any kind of "factory" wipe which will reset them. kind of "factory" wipe which will reset them.
''; '';
system = { system = {
@ -104,7 +113,8 @@
}; };
module = {pkgs, config, lib, lim, ... }: module = {pkgs, config, lib, lim, ... }:
let firmware = pkgs.stdenv.mkDerivation { let inherit (lib) mkIf;
firmware = pkgs.stdenv.mkDerivation {
name = "wlan-firmware"; name = "wlan-firmware";
phases = ["installPhase"]; phases = ["installPhase"];
installPhase = '' installPhase = ''
@ -259,6 +269,9 @@
"${openwrt.src}/target/linux/mediatek/dts" "${openwrt.src}/target/linux/mediatek/dts"
"${config.system.outputs.kernel.modulesupport}/arch/arm64/boot/dts/mediatek/" "${config.system.outputs.kernel.modulesupport}/arch/arm64/boot/dts/mediatek/"
]; ];
includes = mkIf config.logging.persistent.enable [
./pstore-pmsg.dtsi
];
}; };
# - 0x000000000000-0x000008000000 : "spi-nand0" # - 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 let
inherit (lib) mkIf mkOption types; inherit (lib) mkIf mkOption types;
cfg = config.boot.tftp; cfg = config.boot.tftp;
instructions = pkgs.writeText "env.scr" '' instructions = pkgs.writeText "flash.scr" ''
setenv serverip ${cfg.serverip} setenv serverip ${cfg.serverip}
setenv ipaddr ${cfg.ipaddr} setenv ipaddr ${cfg.ipaddr}
setenv loadaddr ${lib.toHexString cfg.loadAddress} setenv loadaddr ${lib.toHexString cfg.loadAddress}
tftpboot $loadaddr result/rootfs
ubi write $loadaddr liminix $filesize
''; '';
in { in {
options.system.outputs = { options.system.outputs = {
@ -63,18 +65,20 @@ Now we can make our new root volume
uboot> ubi create liminix - uboot> ubi create liminix -
3) transfer the root filesystem from the build system and write it 3) transfer the root filesystem from the build system and write it to
to the new volume. Paste the environment variable settings from the new volume. Paste the contents of :file:`result/flash.scr` one line at a time
:file:`result/env.scr` into U-Boot, then run into U-Boot:
.. code-block:: console .. code-block:: console
uboot> tftpboot ''${loadaddr} result/rootfs uboot> setenv serverip 10.0.0.1
uboot> ubi write ''${loadaddr} liminix $filesize 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 Now we have the root filesystem installed on the device. You
can even mount it and poke around using ``ubifsmount ubi0:liminix; can even mount it and poke around using :command:`ubifsmount ubi0:liminix; ubifsls /`
ubifsls /``
4) optional: before you configure the device to boot into Liminix 4) optional: before you configure the device to boot into Liminix
automatically, you can try booting it by hand to see if it works: 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. return to U-Boot.
5) Instructions for configuring autoboot are likely to be very 5) Instructions for configuring autoboot are likely to be very
device-dependent. On the Linksys E8450/Belkin RT3200, the environment device-dependent and you should consult the Liminix documentation for
variable `boot_production` governs what happens on a normal boot, so your device. (If you're bringing up a new device, some detective work
you could do may be needed. Try running `printenv` and trace through the flow of
execution from (probably) :command:`$bootcmd` and look for a suitable
.. code-block:: console variable to change)
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.
6) Now you can reboot the device into Liminix 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 mkdir $out
cd $out cd $out
ln -s ${o.rootfs} rootfs 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 = config.system.outputs.updater =
runCommand "buildUpdater" { } '' 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 \ substitute ${./update.sh} $out/bin/update.sh \
--subst-var-by toplevel ${o.systemConfiguration} \ --subst-var-by toplevel ${o.systemConfiguration} \
--subst-var-by min_copy_closure ${min-copy-closure} --subst-var-by min_copy_closure ${min-copy-closure}

View File

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

View File

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