commit 3e19f1b9279ef0b1ed43fec6a239c13112856031
parent 452aaa2f60e30de34002db73d2800e093514f10c
Author: Daniel Barlow <dan@telent.net>
Date: Tue, 24 Dec 2024 13:47:27 +0000
Merge branch 'runciter'
Diffstat:
7 files changed, 82 insertions(+), 42 deletions(-)
diff --git a/devices/belkin-rt3200/default.nix b/devices/belkin-rt3200/default.nix
@@ -4,7 +4,8 @@
******************************
This device is based on a 64 bit Mediatek MT7622 ARM platform,
- and is "work in progress" in Liminix.
+ and is mostly feature-complete in Liminix but as of Dec 2024
+ has seen very little actual use.
.. note:: The factory flash image contains ECC errors that make it
incompatible with Liminix: use the `OpenWrt
@@ -25,7 +26,11 @@
Installation
============
- Installation is currently a manual process.
+ Liminix on this device uses the UBI volume management system to
+ perform wear leveling on the flash. This is not set up from the
+ factory, so a one-time step is needed to prepare it before Liminix
+ can be installed.
+
Preparation
-----------
@@ -33,7 +38,7 @@
To prepare the device for Liminix you first need to use the
`OpenWrt UBI Installer
<https://github.com/dangowrt/owrt-ubi-installer>`_ image to
- rewrite the flash layout. You can do this in onw of two ways:
+ rewrite the flash layout. You can do this in one of two ways:
either follow the instructions to do it through the vendor web
interface, or you can drop to U-boot and use TFTP
@@ -44,14 +49,50 @@
MT7622> tftpboot 0x42000000 openwrt-mediatek-mt7622-linksys_e8450-ubi-initramfs-recovery-installer.itb
MT7622> bootm 0x42000000
- Once it's finished booted into Linux you can safely reboot
+ This will write the new flash layout and then boot into a
+ "recovery" OpenWrt installation.
+
+ Building/installing Liminix
+ ----------------
- Installing Liminix
- ------------------
+ The default target for this device is ``outputs.ubimage`` which
+ makes a ubifs image suitable for use with :command:`ubiupdatevol`.
+ For a first-time installation the simplest way to achieve this is
+ using the OpenWrt recovery system that you installed in the
+ previous step. In this configuration the device assigns itself the
+ IP address 192.168.1.1/24 on its LAN ports and expects the
+ connected computer to have 192.168.1.254
- This is a manual process: you need a :ref:`serial <serial>` conection and TFTP : follow the instructions at :ref:`system-outputs-ubimage`
+ The `ubi0_7` device in these instructions is correct as of Dec
+ 2024 (dangowrt/owrt-ubi-installer commit d79e7928). If you are
+ installing some time later, it is important to check the output
+ from :command:`ubinfo -a` and make sure you are updating the
+ "liminix" volume and not some other one which had been introduced
+ since I wrote this.
+
+ .. code-block:: console
-'';
+ $ nix-build -I liminix-config=./my-configuration.nix --arg device "import ./devices/belkin-rt3200" -A outputs.default
+ $ cat result/rootfs | ssh root@192.168.1.1 "cat > /tmp/rootfs"
+ $ ssh root@192.168.1.1
+ root@OpenWrt:~# ubimkvol /dev/ubi0 --name=liminix --maxavsize
+ root@OpenWrt:~# ubinfo -a
+ [...]
+ Volume ID: 7 (on ubi0)
+ Type: dynamic
+ Alignment: 1
+ Size: 851 LEBs (108056576 bytes, 103.0 MiB)
+ State: OK
+ Name: liminix
+ Character device major/minor: 250:8
+ root@OpenWrt:~# ubiupdatevol /dev/ubi0_7 /tmp/rootfs
+
+ 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.
+ '';
system = {
crossSystem = {
@@ -177,6 +218,7 @@
tftp.loadAddress = lim.parseInt "0x4007ff28";
imageFormat = "fit";
};
+ rootfsType = lib.mkDefault "ubifs";
filesystem =
let inherit (pkgs.pseudofile) dir symlink;
in
@@ -198,7 +240,8 @@
in {
ubi = {
minIOSize = "2048";
- eraseBlockSize = "126976";
+ logicalEraseBlockSize = "126976";
+ physicalEraseBlockSize = "131072";
maxLEBcount = "1024"; # guessing
};
diff --git a/modules/hardware.nix b/modules/hardware.nix
@@ -13,6 +13,12 @@ in
options = {
boot = { };
hardware = {
+ ubi = {
+ minIOSize = mkOption { type = types.str; };
+ logicalEraseBlockSize = mkOption { type = types.str; }; # LEB
+ physicalEraseBlockSize = mkOption { type = types.str; }; # PEB
+ maxLEBcount = mkOption { type = types.str; }; # LEB
+ };
dts = {
src = mkOption {
type = types.nullOr types.path;
diff --git a/modules/outputs.nix b/modules/outputs.nix
@@ -17,6 +17,7 @@ in
./outputs/boot-fit.nix
./outputs/uimage.nix
./outputs/updater
+ ./outputs/ubimage.nix
];
options = {
system.outputs = {
diff --git a/modules/outputs/ubifs.nix b/modules/outputs/ubifs.nix
@@ -13,18 +13,6 @@ in
./initramfs.nix
];
- options.system.outputs.rootubifs = mkOption {
- type = types.package;
- internal = true;
- };
-
- options.hardware.ubi = {
- minIOSize = mkOption { type = types.str; };
- logicalEraseBlockSize = mkOption { type = types.str; }; # LEB
- physicalEraseBlockSize = mkOption { type = types.str; }; # PEB
- maxLEBcount = mkOption { type = types.str; }; # LEB
- };
-
config = mkIf (config.rootfsType == "ubifs") {
kernel.config = {
MTD_UBI="y";
@@ -33,7 +21,7 @@ in
};
boot.initramfs.enable = true;
system.outputs = {
- rootubifs =
+ rootfs =
let
inherit (pkgs.pkgsBuildBuild) runCommand mtdutils;
cfg = config.hardware.ubi;
diff --git a/modules/outputs/ubimage.nix b/modules/outputs/ubimage.nix
@@ -82,12 +82,11 @@ automatically, you can try booting it by hand to see if it works:
.. code-block:: console
uboot> ubifsmount ubi0:liminix
- uboot> ubifsload ''${loadaddr} boot/uimage
+ uboot> ubifsload ''${loadaddr} boot/fit
uboot> bootm ''${loadaddr}
Once you've done this and you're happy with it, reset the device to
-U-Boot. You don't need to recreate the volume but you do need to
-repeat step 3.
+return to U-Boot.
5) Instructions for configuring autoboot are likely to be very
device-dependent. On the Linksys E8450/Belkin RT3200, the environment
@@ -96,7 +95,10 @@ you could do
.. code-block:: console
- uboot> setenv boot_production 'led $bootled_pwr on ; ubifsmount ubi0:liminix; ubifsload ''${loadaddr} boot/uimage; bootm ''${loadaddr}'
+ 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
@@ -111,16 +113,13 @@ boot process, maybe even try looking for documentation for that device.
};
};
- config = mkIf (config.rootfsType == "ubifs") {
- system.outputs = {
- ubimage =
- let o = config.system.outputs; in
- pkgs.runCommand "ubimage" {} ''
- mkdir $out
- cd $out
- ln -s ${o.rootfs} rootfs
- ln -s ${instructions} env.scr
- '';
- };
- };
+ config.system.outputs.ubimage =
+ assert config.rootfsType == "ubifs";
+ let o = config.system.outputs; in
+ pkgs.runCommand "ubimage" {} ''
+ mkdir $out
+ cd $out
+ ln -s ${o.rootfs} rootfs
+ ln -s ${instructions} env.scr
+ '';
}
diff --git a/modules/outputs/ubivolume.nix b/modules/outputs/ubivolume.nix
@@ -18,6 +18,9 @@ in
eraseBlockSize = mkOption { type = types.str; }; # LEB
maxLEBcount = mkOption { type = types.str; }; # LEB
};
+ options.system.outputs.ubivolume = mkOption {
+ type = types.package;
+ };
config = mkIf (config.rootfsType == "ubifs") {
kernel.config = {
@@ -28,7 +31,7 @@ in
};
boot.initramfs.enable = true;
- system.outputs.rootfs =
+ system.outputs.ubivolume =
let
inherit (pkgs.pkgsBuildBuild) runCommand;
ubiVolume = ({ name, volumeId, image, flags ? [] }:
@@ -81,7 +84,7 @@ in
]);
disk = ubiDisk {
- initramfs = config.system.outputs.rootubifs; # liminix.builders.squashfs config.filesystem.contents; # # assert this is a proper FIT.
+ initramfs = config.system.outputs.rootfs; # ???
};
in
diff --git a/modules/outputs/zyxel-nwa-fit.nix b/modules/outputs/zyxel-nwa-fit.nix
@@ -31,7 +31,7 @@ on a system with pre-existing firmware and OS.
config = mkIf (config.rootfsType == "ubifs") {
system.outputs.zyxel-nwa-fit =
- let
+ let
o = config.system.outputs;
# 8129kb padding.
paddedKernel = pkgs.runCommand "padded-kernel" {} ''
@@ -39,7 +39,7 @@ on a system with pre-existing firmware and OS.
dd if=/dev/zero of=$out bs=1 count=1 seek=8388607
'';
firmwareImage = pkgs.runCommand "firmware-image" {} ''
- cat ${paddedKernel} ${o.rootfs} > $out
+ cat ${paddedKernel} ${o.ubivolume} > $out
'';
dts = pkgs.writeText "image.its" ''
/dts-v1/;