This commit is contained in:
Daniel Barlow
2023-11-10 21:17:20 +00:00
parent 22882dabee
commit 7cfb92e3ce
14 changed files with 102 additions and 58 deletions

View File

@@ -11,7 +11,6 @@
./dnsmasq
./ext4fs.nix
./firewall
./flashimage.nix
./hardware.nix
./hostapd
./hostname.nix
@@ -24,6 +23,8 @@
./ntp
./outputs.nix
./outputs/vmroot.nix
./outputs/ubimage.nix
./outputs/flashimage.nix
./ppp
./ramdisk.nix
./squashfs.nix
@@ -31,7 +32,6 @@
./standard.nix
./tftpboot.nix
./ubifs.nix
./ubimage.nix
./users.nix
./vlan
./watchdog

View File

@@ -12,6 +12,8 @@ in
imports = [
./squashfs.nix
./outputs/vmroot.nix
./outputs/flashimage.nix
./outputs/ubimage.nix
];
options = {
system.outputs = {

View File

@@ -6,11 +6,19 @@
}:
let
inherit (lib) mkIf mkEnableOption mkOption types concatStringsSep;
loadaddr = config.boot.tftp.loadAddress;
cfg = config.boot.tftp;
instructions = pkgs.writeText "INSTALL.md" ''
# First-time installation
instructions = pkgs.writeText "env.scr" ''
setenv serverip ${cfg.serverip}
setenv ipaddr ${cfg.ipaddr}
setenv loadaddr ${cfg.loadAddress}
'';
in {
options.system.outputs = {
ubimage = mkOption {
type = types.package;
description = ''
ubimage
*******
First-time installation of a UBIFS Liminix system presently can only
be done from the U-Boot command line (or from a ramdisk-based recovery
@@ -25,13 +33,17 @@ U-Boot
1) determine which MTD device is being used for UBI and the partition name:
.. code-block:: console
uboot> ubi part
Device 0: ubi0, MTD partition ubi
In this case the important value is `ubi0`
In this case the important value is ``ubi0``
2) list the available volumes and create a new one on which to install Liminix
.. code-block:: console
uboot> ubi info l
[ copious output scrolls past ]
@@ -40,32 +52,39 @@ important. Unless you know what you're doing, don't remove anything
whose name suggests it's related to uboot, or any kind of backup or
recovery partition. To see how much space is free:
.. code-block:: console
uboot> ubi info
[ ... ]
UBI: available PEBs: 823
Now we can make our new root volume
.. code-block:: console
uboot> ubi create liminix -
3) transfer the root filesystem from the build system and write it
to the new volume
to the new volume. Paste the environment variable settings from
:file:`result/env.scr` into U-Boot, then run
uboot> setenv serverip ${cfg.serverip}
uboot> setenv ipaddr ${cfg.ipaddr}
uboot> tftpboot ${loadaddr} result/rootfs
uboot> ubi write ${loadaddr} liminix $filesize
.. code-block:: console
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 ``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:
.. code-block:: console
uboot> ubifsmount ubi0:liminix
uboot> ubifsload ${loadaddr} boot/uimage
uboot> bootm ${loadaddr}
uboot> ubifsload ''${loadaddr} boot/uimage
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
@@ -76,7 +95,9 @@ device-dependent. On the Linksys E8450/Belkin RT3200, the environment
variable `boot_production` governs what happens on a normal boot, so
you could do
uboot> setenv boot_production 'led $bootled_pwr on ; ubifsmount ubi0:liminix; ubifsload ${loadaddr} boot/uimage; bootm ${loadaddr}'
.. code-block:: console
uboot> setenv boot_production 'led $bootled_pwr on ; ubifsmount ubi0:liminix; ubifsload ''${loadaddr} boot/uimage; bootm ''${loadaddr}'
On other devices, some detective work may be needed. Try running
`printenv` and look for likely commands, try looking at the existing
@@ -84,15 +105,9 @@ boot process, maybe even try looking for documentation for that device.
6) Now you can reboot the device into Liminix
uboot> reset
.. code-block:: console
'';
in {
options.system.outputs = {
ubimage = mkOption {
type = types.package;
description = ''
UBIFS image and instructions to install it
uboot> reset
'';
};
};
@@ -105,7 +120,7 @@ in {
mkdir $out
cd $out
ln -s ${o.rootfs} rootfs
ln -s ${instructions} INSTALL
ln -s ${instructions} env.scr
'';
};
};

View File

@@ -5,7 +5,7 @@
imports = [
./tftpboot.nix
./kexecboot.nix
./flashimage.nix
./outputs/flashimage.nix
./jffs2.nix
./ubifs.nix
];