forked from DGNum/liminix
extract phram.mtd ramdisk support from tftpboot module
also rename tftproot output to tftpboot for consistency
This commit is contained in:
parent
6e95932e0e
commit
ce05f4e44c
6 changed files with 45 additions and 29 deletions
|
@ -87,7 +87,7 @@
|
|||
inherit (pkgs.liminix.networking) interface;
|
||||
in {
|
||||
hardware = {
|
||||
defaultOutput = "tftproot";
|
||||
defaultOutput = "tftpboot";
|
||||
loadAddress = "0x80060000";
|
||||
entryPoint = "0x80060000";
|
||||
flash = {
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
};
|
||||
in {
|
||||
hardware = {
|
||||
defaultOutput = "tftproot";
|
||||
defaultOutput = "tftpboot";
|
||||
loadAddress = "0x80000000";
|
||||
entryPoint = "0x80000000";
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
};
|
||||
};
|
||||
hardware = {
|
||||
defaultOutput = "tftproot";
|
||||
defaultOutput = "tftpboot";
|
||||
loadAddress = "0x80000000";
|
||||
entryPoint = "0x80000000";
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ image instead of flashing. In your device configuration add
|
|||
ipaddr = "192.168.200.251";
|
||||
};
|
||||
|
||||
and then build ``outputs.tftproot``. This creates a file in
|
||||
and then build ``outputs.tftpboot``. This creates a file in
|
||||
``result/`` called ``boot.scr``, which you can copy and paste into
|
||||
U-Boot to transfer the kernel and filesystem over TFTP and boot the
|
||||
kernel from RAM.
|
||||
|
|
34
modules/ramdisk.nix
Normal file
34
modules/ramdisk.nix
Normal file
|
@ -0,0 +1,34 @@
|
|||
{
|
||||
config
|
||||
, pkgs
|
||||
, lib
|
||||
, ...
|
||||
}:
|
||||
let
|
||||
inherit (lib) mkIf mkEnableOption mkOption; # types concatStringsSep;
|
||||
in {
|
||||
options = {
|
||||
boot = {
|
||||
ramdisk = {
|
||||
enable = mkEnableOption (lib.mdDoc ''
|
||||
Configure kernel to enable reserving part of memory as
|
||||
an MTD-based RAM disk. Needed for TFTP booting or for
|
||||
kexec-based revertable upgrade
|
||||
'');
|
||||
};
|
||||
};
|
||||
};
|
||||
config = mkIf config.boot.ramdisk.enable {
|
||||
kernel = {
|
||||
config = {
|
||||
MTD = "y";
|
||||
MTD_PHRAM = "y";
|
||||
MTD_CMDLINE_PARTS = "y";
|
||||
MTD_OF_PARTS = "y";
|
||||
PARTITION_ADVANCED = "y";
|
||||
MTD_BLKDEVS = "y";
|
||||
MTD_BLOCK = "y";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -20,32 +20,14 @@ in {
|
|||
};
|
||||
};
|
||||
};
|
||||
imports = [ ./ramdisk.nix ];
|
||||
config = {
|
||||
kernel = {
|
||||
config = {
|
||||
MTD = "y";
|
||||
MTD_PHRAM = "y";
|
||||
MTD_CMDLINE_PARTS = "y";
|
||||
MIPS_CMDLINE_FROM_BOOTLOADER = "y";
|
||||
boot.ramdisk.enable = true;
|
||||
kernel.config.MIPS_CMDLINE_FROM_BOOTLOADER = "y";
|
||||
|
||||
# one or more of the following is required to get from
|
||||
# VFS: Cannot open root device "1f00" or unknown-block(31,0): error -6
|
||||
# to
|
||||
# VFS: Mounted root (squashfs filesystem) readonly on device 31:0.
|
||||
MTD_OF_PARTS = "y";
|
||||
PARTITION_ADVANCED = "y";
|
||||
MSDOS_PARTITION = "y";
|
||||
EFI_PARTITION = "y";
|
||||
MTD_BLKDEVS = "y";
|
||||
MTD_BLOCK = "y";
|
||||
|
||||
# CONFIG_MTD_MTDRAM=m c'est quoi?
|
||||
};
|
||||
|
||||
};
|
||||
outputs.tftproot =
|
||||
outputs.tftpboot =
|
||||
let o = config.outputs; in
|
||||
pkgs.runCommand "tftproot" {} ''
|
||||
pkgs.runCommand "tftpboot" {} ''
|
||||
mkdir $out
|
||||
cd $out
|
||||
ln -s ${o.squashfs} squashfs
|
||||
|
@ -60,12 +42,13 @@ in {
|
|||
let
|
||||
inherit (pkgs.lib.trivial) toHexString;
|
||||
in
|
||||
pkgs.buildPackages.runCommand "" {} ''
|
||||
pkgs.buildPackages.runCommand "boot-scr" {} ''
|
||||
uimageSize=$(($(stat -L -c %s ${config.outputs.uimage}) + 0x1000 &(~0xfff)))
|
||||
squashfsStart=0x$(printf %x $((${cfg.loadAddress} + 0x100000 + $uimageSize)))
|
||||
squashfsBytes=$(($(stat -L -c %s ${config.outputs.squashfs}) + 0x100000 &(~0xfffff)))
|
||||
squashfsMb=$(($squashfsBytes >> 20))
|
||||
cmd="mtdparts=phram0:''${squashfsMb}M(nix) phram.phram=phram0,''${squashfsStart},''${squashfsMb}Mi memmap=''${squashfsMb}M\$''${squashfsStart} root=1f00";
|
||||
|
||||
cat > $out << EOF
|
||||
setenv serverip ${cfg.serverip}
|
||||
setenv ipaddr ${cfg.ipaddr}
|
||||
|
@ -74,6 +57,5 @@ in {
|
|||
bootm 0x$(printf %x ${cfg.loadAddress})
|
||||
EOF
|
||||
'';
|
||||
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue