forked from DGNum/liminix
generate probably-non-functional firmware image for gl-ar750
This commit is contained in:
parent
a1a1abb8c7
commit
f9626d00f4
6 changed files with 141 additions and 10 deletions
20
default.nix
20
default.nix
|
@ -16,10 +16,21 @@ let
|
||||||
kernel = callPackage ./kernel {
|
kernel = callPackage ./kernel {
|
||||||
inherit (config.kernel) config checkedConfig;
|
inherit (config.kernel) config checkedConfig;
|
||||||
};
|
};
|
||||||
in {
|
outputs = rec {
|
||||||
outputs = {
|
|
||||||
inherit squashfs kernel;
|
inherit squashfs kernel;
|
||||||
default = nixpkgs.pkgs.runCommand "both-kinds" {} ''
|
uimage = kernel.uimage {
|
||||||
|
inherit (device.boot) loadAddress entryPoint;
|
||||||
|
inherit (kernel) vmlinux;
|
||||||
|
};
|
||||||
|
|
||||||
|
combined-image = nixpkgs.pkgs.runCommand "firmware.bin" {
|
||||||
|
nativeBuildInputs = [ nixpkgs.buildPackages.ubootTools ];
|
||||||
|
} ''
|
||||||
|
dd if=${uimage} of=$out bs=128k conv=sync
|
||||||
|
dd if=${squashfs} of=$out bs=128k conv=sync,nocreat,notrunc oflag=append
|
||||||
|
'';
|
||||||
|
|
||||||
|
directory = nixpkgs.pkgs.runCommand "both-kinds" {} ''
|
||||||
mkdir $out
|
mkdir $out
|
||||||
cd $out
|
cd $out
|
||||||
ln -s ${squashfs} squashfs
|
ln -s ${squashfs} squashfs
|
||||||
|
@ -29,6 +40,9 @@ in {
|
||||||
# out what's in the image, which is nice if it's unexpectedly huge
|
# out what's in the image, which is nice if it's unexpectedly huge
|
||||||
manifest = writeText "manifest.json" (builtins.toJSON config.filesystem.contents);
|
manifest = writeText "manifest.json" (builtins.toJSON config.filesystem.contents);
|
||||||
};
|
};
|
||||||
|
in {
|
||||||
|
outputs = outputs // { default = outputs.${device.outputs.default}; };
|
||||||
|
|
||||||
# this is just here as a convenience, so that we can get a
|
# this is just here as a convenience, so that we can get a
|
||||||
# cross-compiling nix-shell for any package we're customizing
|
# cross-compiling nix-shell for any package we're customizing
|
||||||
inherit (nixpkgs) pkgs;
|
inherit (nixpkgs) pkgs;
|
||||||
|
|
|
@ -1,3 +1,21 @@
|
||||||
|
# GL.INet GL-AR750 "Creta" travel router
|
||||||
|
# - QCA9531 @650Mhz SoC
|
||||||
|
# - dual band wireless: IEEE 802.11a/b/g/n/ac
|
||||||
|
# - two 10/100Mbps LAN ports and one WAN
|
||||||
|
# - 128MB DDR2 RAM / 16MB NOR Flash
|
||||||
|
# - "ath79" soc family
|
||||||
|
# https://www.gl-inet.com/products/gl-ar750/
|
||||||
|
|
||||||
|
# I like GL.iNet devices because they're relatively accessible to
|
||||||
|
# DIY users: the serial port connections have headers preinstalled
|
||||||
|
# and don't need soldering
|
||||||
|
|
||||||
|
# The default output is a combined image containing a kernel
|
||||||
|
# packaged as a "uimage" and initrd filesystem. This can be
|
||||||
|
# downloaded to the device using TFTP and then written into
|
||||||
|
# flash, or if PHRAM suport is enabled (handy for development)
|
||||||
|
# unpacked and run directly into RAM
|
||||||
|
|
||||||
{
|
{
|
||||||
system = {
|
system = {
|
||||||
crossSystem = {
|
crossSystem = {
|
||||||
|
@ -8,4 +26,55 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
kernel = {
|
||||||
|
checkedConfig = {
|
||||||
|
"MIPS_RAW_APPENDED_DTB" = "y";
|
||||||
|
};
|
||||||
|
config = {
|
||||||
|
# this is all copied from nixwrt ath79 config. Clearly not all
|
||||||
|
# of it is device config, some of it is wifi config or
|
||||||
|
# installation method config or ...
|
||||||
|
"BLK_DEV_INITRD" = "n";
|
||||||
|
"CMDLINE_PARTITION" = "y";
|
||||||
|
"DEBUG_INFO" = "y";
|
||||||
|
"DEVTMPFS" = "y";
|
||||||
|
"EARLY_PRINTK" = "y";
|
||||||
|
"FW_LOADER" = "y";
|
||||||
|
# we don't have a user helper, so we get multiple 60s pauses
|
||||||
|
# at boot time unless we disable trying to call it
|
||||||
|
"FW_LOADER_USER_HELPER" = "n";
|
||||||
|
"IMAGE_CMDLINE_HACK" = "n";
|
||||||
|
"IP_PNP" = "y";
|
||||||
|
"JFFS2_FS" = "n";
|
||||||
|
"MIPS_RAW_APPENDED_DTB" = "y";
|
||||||
|
"MODULE_SIG" = "y";
|
||||||
|
"MTD_CMDLINE_PARTS" = "y";
|
||||||
|
"MTD_SPLIT_FIRMWARE" = "y";
|
||||||
|
"PARTITION_ADVANCED" = "y";
|
||||||
|
"PRINTK_TIME" = "y";
|
||||||
|
"SQUASHFS" = "y";
|
||||||
|
"SQUASHFS_XZ" = "y";
|
||||||
|
"ASN1" = "y";
|
||||||
|
"ASYMMETRIC_KEY_TYPE" = "y";
|
||||||
|
"ASYMMETRIC_PUBLIC_KEY_SUBTYPE" = "y";
|
||||||
|
"CRC_CCITT" = "y";
|
||||||
|
"CRYPTO" = "y";
|
||||||
|
"CRYPTO_ARC4" = "y";
|
||||||
|
"CRYPTO_CBC" = "y";
|
||||||
|
"CRYPTO_CCM" = "y";
|
||||||
|
"CRYPTO_CMAC" = "y";
|
||||||
|
"CRYPTO_GCM" = "y";
|
||||||
|
"CRYPTO_HASH_INFO" = "y";
|
||||||
|
"CRYPTO_LIB_ARC4" = "y";
|
||||||
|
"CRYPTO_RSA" = "y";
|
||||||
|
"CRYPTO_SHA1" = "y";
|
||||||
|
"ENCRYPTED_KEYS" = "y";
|
||||||
|
"KEYS" = "y";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
outputs.default = "combined-image";
|
||||||
|
boot = {
|
||||||
|
loadAddress = "0x80060000";
|
||||||
|
entryPoint = "0x80060000";
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
# This "device" generates images that can be used with the QEMU
|
||||||
|
# emulator. The default output is a directory containing separate
|
||||||
|
# kernel (uncompressed vmlinux) and initrd (squashfs) images
|
||||||
|
|
||||||
{
|
{
|
||||||
system = {
|
system = {
|
||||||
crossSystem = {
|
crossSystem = {
|
||||||
|
@ -446,4 +450,5 @@
|
||||||
VIRTIO_NET = "y";
|
VIRTIO_NET = "y";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
outputs.default = "directory";
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,9 +34,9 @@ let
|
||||||
cp -a . $out
|
cp -a . $out
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
in
|
in rec {
|
||||||
{
|
|
||||||
vmlinux = callPackage ./vmlinux.nix {
|
vmlinux = callPackage ./vmlinux.nix {
|
||||||
inherit tree config checkedConfig;
|
inherit tree config checkedConfig;
|
||||||
};
|
};
|
||||||
|
uimage = callPackage ./uimage.nix { };
|
||||||
}
|
}
|
||||||
|
|
42
kernel/uimage.nix
Normal file
42
kernel/uimage.nix
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
{
|
||||||
|
lzma
|
||||||
|
, stdenv
|
||||||
|
, ubootTools
|
||||||
|
} :
|
||||||
|
let
|
||||||
|
objcopy = "${stdenv.cc.bintools.targetPrefix}objcopy";
|
||||||
|
in {
|
||||||
|
vmlinux
|
||||||
|
# , commandLine
|
||||||
|
# , fdt ? null
|
||||||
|
, entryPoint
|
||||||
|
# , extraName ? "" # e.g. socFamily
|
||||||
|
, loadAddress
|
||||||
|
} :
|
||||||
|
# patchDtbCommand = if (fdt != null) then ''
|
||||||
|
# ( cat vmlinux.stripped ${fdt} > vmlinux.tmp ) && mv vmlinux.tmp vmlinux.stripped
|
||||||
|
# '' else ''
|
||||||
|
# echo patch-cmdline vmlinux.stripped '${commandLine}'
|
||||||
|
# patch-cmdline vmlinux.stripped '${commandLine}'
|
||||||
|
# echo
|
||||||
|
# '';
|
||||||
|
stdenv.mkDerivation {
|
||||||
|
name = "kernel.image";
|
||||||
|
phases = [ "buildPhase" "installPhase" ];
|
||||||
|
nativeBuildInputs = [
|
||||||
|
# patchImage
|
||||||
|
lzma
|
||||||
|
stdenv.cc
|
||||||
|
ubootTools
|
||||||
|
];
|
||||||
|
buildPhase = ''
|
||||||
|
${objcopy} -O binary -R .reginfo -R .notes -R .note -R .comment -R .mdebug -R .note.gnu.build-id -S ${vmlinux} vmlinux.stripped
|
||||||
|
# {patchDtbCommand}
|
||||||
|
rm -f vmlinux.stripped.lzma
|
||||||
|
lzma -k -z vmlinux.stripped
|
||||||
|
mkimage -A mips -O linux -T kernel -C lzma -a ${loadAddress} -e ${entryPoint} -n 'MIPS Liminix Linux ' -d vmlinux.stripped.lzma kernel.image
|
||||||
|
'';
|
||||||
|
installPhase = ''
|
||||||
|
cp kernel.image $out
|
||||||
|
'';
|
||||||
|
}
|
|
@ -31,6 +31,7 @@ in {
|
||||||
};
|
};
|
||||||
checkedConfig = mkOption {
|
checkedConfig = mkOption {
|
||||||
type = types.attrsOf types.nonEmptyStr;
|
type = types.attrsOf types.nonEmptyStr;
|
||||||
|
default = {};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
groups = mkOption {
|
groups = mkOption {
|
||||||
|
|
Loading…
Reference in a new issue