fix(zyxel/nwa50ax): ubi cannot run on phram
Discovered the hard way. Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
This commit is contained in:
parent
85bfe94429
commit
c1e61d6af5
5 changed files with 42 additions and 24 deletions
|
@ -5,7 +5,8 @@
|
|||
, ...
|
||||
}:
|
||||
let
|
||||
inherit (lib) mkIf mkOption types;
|
||||
inherit (pkgs) liminix;
|
||||
inherit (lib) mkIf;
|
||||
o = config.system.outputs;
|
||||
in
|
||||
{
|
||||
|
@ -24,17 +25,10 @@ in
|
|||
};
|
||||
boot.initramfs.enable = true;
|
||||
system.outputs = {
|
||||
rootfs =
|
||||
let
|
||||
inherit (pkgs.pkgsBuildBuild) runCommand mtdutils;
|
||||
endian = if pkgs.stdenv.isBigEndian
|
||||
then "--big-endian" else "--little-endian";
|
||||
in runCommand "make-jffs2" {
|
||||
depsBuildBuild = [ mtdutils ];
|
||||
} ''
|
||||
tree=${o.bootablerootdir}
|
||||
(cd $tree && mkfs.jffs2 --compression-mode=size ${endian} -e ${toString config.hardware.flash.eraseBlockSize} --enable-compressor=lzo --pad --root . --output $out --squash --faketime )
|
||||
'';
|
||||
rootfs = liminix.builders.jffs2 {
|
||||
bootableRootDirectory = o.bootablerootdir;
|
||||
inherit (config.hardware.flash) eraseBlockSize;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -5,10 +5,18 @@
|
|||
, ...
|
||||
}:
|
||||
let
|
||||
inherit (lib) mkOption types concatStringsSep;
|
||||
inherit (lib) mkOption mkIf types concatStringsSep;
|
||||
inherit (pkgs) liminix;
|
||||
cfg = config.boot.tftp;
|
||||
hw = config.hardware;
|
||||
arch = pkgs.stdenv.hostPlatform.linuxArch;
|
||||
|
||||
# UBI cannot run on the top of phram.
|
||||
needsSquashfs = config.rootfsType == "ubifs";
|
||||
rootfstype = if needsSquashfs then "squashfs" else config.rootfsType;
|
||||
rootfs = if needsSquashfs then
|
||||
liminix.builders.squashfs config.filesystem.contents
|
||||
else config.system.outputs.rootfs;
|
||||
in {
|
||||
imports = [ ../ramdisk.nix ];
|
||||
options.boot.tftp = {
|
||||
|
@ -74,6 +82,11 @@ in {
|
|||
config = {
|
||||
boot.ramdisk.enable = true;
|
||||
|
||||
kernel.config = mkIf needsSquashfs {
|
||||
SQUASHFS = "y";
|
||||
SQUASHFS_XZ = "y";
|
||||
};
|
||||
|
||||
system.outputs = rec {
|
||||
tftpboot-fit =
|
||||
let
|
||||
|
@ -128,7 +141,7 @@ in {
|
|||
hex() { printf "0x%x" $1; }
|
||||
|
||||
rootfsStart=${toString cfg.loadAddress}
|
||||
rootfsSize=$(binsize64k ${o.rootfs} )
|
||||
rootfsSize=$(binsize64k ${rootfs} )
|
||||
rootfsSize=$(($rootfsSize + ${toString cfg.freeSpaceBytes} ))
|
||||
|
||||
ln -s ${o.manifest} manifest
|
||||
|
@ -142,13 +155,13 @@ in {
|
|||
dtbStart=$(($rootfsStart + $rootfsSize))
|
||||
${if cfg.compressRoot
|
||||
then ''
|
||||
lzma -z9cv ${o.rootfs} > rootfs.lz
|
||||
lzma -z9cv ${rootfs} > rootfs.lz
|
||||
rootfsLzStart=$dtbStart
|
||||
rootfsLzSize=$(binsize rootfs.lz)
|
||||
dtbStart=$(($dtbStart + $rootfsLzSize))
|
||||
''
|
||||
else ''
|
||||
ln -s ${o.rootfs} rootfs
|
||||
ln -s ${rootfs} rootfs
|
||||
''
|
||||
}
|
||||
|
||||
|
@ -165,7 +178,7 @@ in {
|
|||
fdtput -p -t s dtb /reserved-memory/$node compatible phram
|
||||
fdtput -p -t lx dtb /reserved-memory/$node reg $ac_prefix $(hex $rootfsStart) $sz_prefix $(hex $rootfsSize)
|
||||
|
||||
cmd="liminix ${cmdline} mtdparts=phram0:''${rootfsSize}(rootfs) phram.phram=phram0,''${rootfsStart},''${rootfsSize},${toString config.hardware.flash.eraseBlockSize} root=/dev/mtdblock0";
|
||||
cmd="liminix ${cmdline} mtdparts=phram0:''${rootfsSize}(rootfs) phram.phram=phram0,''${rootfsStart},''${rootfsSize},${toString config.hardware.flash.eraseBlockSize} rootfstype=${rootfstype} root=/dev/mtdblock0";
|
||||
fdtput -t s dtb /chosen ${config.boot.commandLineDtbNode} "$cmd"
|
||||
|
||||
dtbSize=$(binsize ./dtb )
|
||||
|
|
|
@ -29,13 +29,6 @@ in
|
|||
};
|
||||
boot.initramfs.enable = true;
|
||||
|
||||
# In TFTP, the device named "rootfs" is the UBI device.
|
||||
# We tell the kernel to load it.
|
||||
# This avoids interference from the other UBI volumes.
|
||||
boot.tftp.commandLine = [
|
||||
"ubi.mtd=rootfs"
|
||||
];
|
||||
|
||||
system.outputs.rootfs =
|
||||
let
|
||||
inherit (pkgs.pkgsBuildBuild) runCommand;
|
||||
|
|
|
@ -13,6 +13,7 @@ in {
|
|||
liminix = {
|
||||
builders = {
|
||||
squashfs = callPackage ./liminix-tools/builders/squashfs.nix {};
|
||||
jffs2 = callPackage ./liminix-tools/builders/jffs2.nix {};
|
||||
dtb = callPackage ./kernel/dtb.nix {};
|
||||
uimage = callPackage ./kernel/uimage.nix {};
|
||||
kernel = callPackage ./kernel {};
|
||||
|
|
17
pkgs/liminix-tools/builders/jffs2.nix
Normal file
17
pkgs/liminix-tools/builders/jffs2.nix
Normal file
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
stdenv
|
||||
, busybox
|
||||
, buildPackages
|
||||
, callPackage
|
||||
, pseudofile
|
||||
, runCommand
|
||||
, writeText
|
||||
} : { eraseBlockSize, bootableRootDirectory }:
|
||||
let
|
||||
endian = if stdenv.isBigEndian then "--big-endian" else "--little-endian";
|
||||
in runCommand "frob-jffs2" {
|
||||
depsBuildBuild = [ buildPackages.mtdutils ];
|
||||
} ''
|
||||
tree=${bootableRootDirectory}
|
||||
(cd $tree && mkfs.jffs2 --compression-mode=size ${endian} -e ${toString eraseBlockSize} --enable-compressor=lzo --pad --root . --output $out --squash --faketime)
|
||||
''
|
Loading…
Reference in a new issue