forked from DGNum/liminix
tftpboot omnia using bootz not bootm
because kernel size is now beyond the u-boot size limit for bootm
This commit is contained in:
parent
f4f4387861
commit
d1e2d525a4
2 changed files with 93 additions and 4 deletions
|
@ -14,7 +14,7 @@
|
|||
let openwrt = pkgs.openwrt; in {
|
||||
imports = [
|
||||
../../modules/arch/arm.nix
|
||||
../../modules/outputs/tftpboot.nix
|
||||
../../modules/outputs/tftpbootlz.nix
|
||||
../../modules/outputs/ext4fs.nix
|
||||
../../modules/outputs/mbrimage.nix
|
||||
../../modules/outputs/extlinux.nix
|
||||
|
@ -115,7 +115,9 @@
|
|||
};
|
||||
};
|
||||
};
|
||||
boot.tftp.loadAddress = lim.parseInt "0x01800000";
|
||||
|
||||
boot.tftp.loadAddress = lim.parseInt "0x1000000";
|
||||
|
||||
hardware = let
|
||||
mac80211 = pkgs.mac80211.override {
|
||||
drivers = ["ath9k_pci" "ath10k_pci"];
|
||||
|
@ -123,9 +125,9 @@
|
|||
};
|
||||
in {
|
||||
defaultOutput = "mtdimage";
|
||||
loadAddress = lim.parseInt "0x00008000";
|
||||
loadAddress = lim.parseInt "0x00800000"; # "0x00008000";
|
||||
|
||||
entryPoint = lim.parseInt "0x00008000";
|
||||
entryPoint = lim.parseInt "0x00800000"; # "0x00008000";
|
||||
rootDevice = "/dev/mtdblock0";
|
||||
dts = {
|
||||
src = "${config.system.outputs.kernel.modulesupport}/arch/arm/boot/dts/armada-385-turris-omnia.dts";
|
||||
|
|
87
modules/outputs/tftpbootlz.nix
Normal file
87
modules/outputs/tftpbootlz.nix
Normal file
|
@ -0,0 +1,87 @@
|
|||
{
|
||||
config
|
||||
, pkgs
|
||||
, lib
|
||||
, ...
|
||||
}:
|
||||
let
|
||||
inherit (lib) mkOption types concatStringsSep;
|
||||
inherit (pkgs.lib.trivial) toHexString;
|
||||
o = config.system.outputs;
|
||||
cmdline = concatStringsSep " " config.boot.commandLine;
|
||||
cfg = config.boot.tftp;
|
||||
boot-scr =
|
||||
pkgs.buildPackages.runCommand "boot-scr" { nativeBuildInputs = [ pkgs.pkgsBuildBuild.dtc ]; } ''
|
||||
uimageSize=$(($(stat -L -c %s ${o.zimage}) + 0x1000 &(~0xfff)))
|
||||
rootfsStart=0x$(printf %x $((${toString cfg.loadAddress} + 0x100000 + $uimageSize &(~0xfffff) )))
|
||||
rootfsBytes=$(($(stat -L -c %s ${o.rootfs}) + 0x100000 &(~0xfffff)))
|
||||
rootfsBytes=$(($rootfsBytes + ${toString cfg.freeSpaceBytes} ))
|
||||
rootfsMb=$(($rootfsBytes >> 20))
|
||||
cmd="mtdparts=phram0:''${rootfsMb}M(rootfs) phram.phram=phram0,''${rootfsStart},''${rootfsBytes},${toString config.hardware.flash.eraseBlockSize} root=/dev/mtdblock0";
|
||||
|
||||
dtbStart=$(printf %x $((${toString cfg.loadAddress} + $rootfsBytes + 0x100000 + $uimageSize )))
|
||||
|
||||
mkdir $out
|
||||
cat ${o.dtb} > $out/dtb
|
||||
fdtput -p -t s $out/dtb /reserved-memory/phram-rootfs compatible phram
|
||||
fdtput -p -t lx $out/dtb /reserved-memory/phram-rootfs reg 0 $rootfsStart 0 $(printf %x $rootfsBytes)
|
||||
|
||||
dtbBytes=$(($(stat -L -c %s $out/dtb) + 0x1000 &(~0xfff)))
|
||||
|
||||
cat > $out/script << EOF
|
||||
setenv serverip ${cfg.serverip}
|
||||
setenv ipaddr ${cfg.ipaddr}
|
||||
setenv bootargs 'liminix ${cmdline} $cmd'
|
||||
tftpboot 0x${lib.toHexString cfg.loadAddress} result/zImage; tftpboot 0x$(printf %x $rootfsStart) result/rootfs ; tftpboot 0x$dtbStart result/dtb
|
||||
setexpr bootaddr 0x$dtbStart + \$filesize
|
||||
# lzmadec 0x${lib.toHexString cfg.loadAddress} \$bootaddr
|
||||
# bootz \$bootaddr - 0x$dtbStart
|
||||
bootz 0x${lib.toHexString cfg.loadAddress} - 0x$dtbStart
|
||||
EOF
|
||||
'';
|
||||
in {
|
||||
imports = [ ../ramdisk.nix ];
|
||||
options.boot.tftp.freeSpaceBytes = mkOption {
|
||||
type = types.int;
|
||||
default = 0;
|
||||
};
|
||||
options.system.outputs = {
|
||||
tftpbootlz = mkOption {
|
||||
type = types.package;
|
||||
description = ''
|
||||
tftpbootlz
|
||||
**********
|
||||
|
||||
This is a variant of the tftpboot output intended for the
|
||||
Turris Omnia. It builds a uimage containing an uncompressed
|
||||
kernel, then compresses the resulting image to be decompressed
|
||||
using the u-boot lzmadec command. This is a workaround for an
|
||||
awkwardly low CONFIG_SYS_BOOTM_LEN setting in the U-Boot build
|
||||
for the device, which means that the regular tftpboot output
|
||||
would only work for very small kernels.
|
||||
'';
|
||||
};
|
||||
};
|
||||
config = {
|
||||
boot.ramdisk.enable = true;
|
||||
|
||||
system.outputs = {
|
||||
tftpbootlz =
|
||||
let
|
||||
o = config.system.outputs; in
|
||||
pkgs.runCommand "tftpboot" {
|
||||
depsBuildBuild = [ pkgs.pkgsBuildBuild.lzma ];
|
||||
} ''
|
||||
mkdir $out
|
||||
cd $out
|
||||
ln -s ${o.rootfs} rootfs
|
||||
ln -s ${o.zimage} zImage
|
||||
ln -s ${o.manifest} manifest
|
||||
ln -s ${o.kernel.headers} build
|
||||
# lzma -c -z -9 < {uimage} > uimage.lz
|
||||
ln -s ${boot-scr}/dtb dtb
|
||||
ln -s ${boot-scr}/script boot.scr
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue