forked from DGNum/liminix
a5cfa37ed3
We now use MIPS_CMDLINE_DTB_EXTEND for all boot varieties (tftpboot, flash boot, kexec) with the addition of MIPS_BOOTLOADER_CMDLINE_REQUIRE_COOKIE - local patch - so that the bootloader args are ignored unless they contain the string "liminix"
59 lines
1.6 KiB
Nix
59 lines
1.6 KiB
Nix
{
|
|
config
|
|
, pkgs
|
|
, lib
|
|
, ...
|
|
}:
|
|
let
|
|
inherit (lib) mkOption types concatStringsSep;
|
|
inherit (config.boot) tftp;
|
|
in {
|
|
options = {
|
|
};
|
|
config = {
|
|
kernel = {
|
|
config = {
|
|
MTD_SPLIT_UIMAGE_FW = "y";
|
|
};
|
|
};
|
|
|
|
outputs.firmware =
|
|
let o = config.outputs; in
|
|
pkgs.runCommand "firmware" {} ''
|
|
dd if=${o.uimage} of=$out bs=128k conv=sync
|
|
dd if=${o.squashfs} of=$out bs=128k conv=sync,nocreat,notrunc oflag=append
|
|
'';
|
|
outputs.flashable =
|
|
let o = config.outputs; in
|
|
pkgs.runCommand "flashable" {} ''
|
|
mkdir $out
|
|
cd $out
|
|
ln -s ${o.firmware} firmware.bin
|
|
ln -s ${o.squashfs} squashfs
|
|
ln -s ${o.kernel} vmlinux
|
|
ln -s ${o.manifest} manifest
|
|
ln -s ${o.kernel.headers} build
|
|
ln -s ${o.uimage} uimage
|
|
ln -s ${o.dtb} dtb
|
|
ln -s ${o.flash-scr} flash.scr
|
|
'';
|
|
|
|
outputs.flash-scr =
|
|
let
|
|
inherit (pkgs.lib.trivial) toHexString;
|
|
inherit (config.hardware) flash;
|
|
in
|
|
pkgs.buildPackages.runCommand "" {} ''
|
|
imageSize=$(stat -L -c %s ${config.outputs.firmware})
|
|
cat > $out << EOF
|
|
setenv serverip ${tftp.serverip}
|
|
setenv ipaddr ${tftp.ipaddr}
|
|
tftp 0x$(printf %x ${tftp.loadAddress}) result/firmware.bin
|
|
erase 0x$(printf %x ${flash.address}) +\''${filesize})
|
|
cp.b 0x$(printf %x ${tftp.loadAddress}) 0x$(printf %x ${flash.address}) \''${filesize}
|
|
echo command line was ${builtins.toJSON (concatStringsSep " " config.boot.commandLine)}
|
|
EOF
|
|
'';
|
|
|
|
};
|
|
}
|