forked from DGNum/liminix
detect arch in kernel and uimage
also move kernel builder to pkgs/ FIXME we need to straighten out the mess in calling dtb.nix/uimage.nix
This commit is contained in:
parent
f1c04c7979
commit
4f29bdd3ed
6 changed files with 28 additions and 9 deletions
|
@ -24,7 +24,7 @@ in {
|
|||
extraPatchPhase = mkOption {
|
||||
default = "true";
|
||||
type = types.lines;
|
||||
} ;
|
||||
};
|
||||
config = mkOption {
|
||||
description = ''
|
||||
Kernel config options, as listed in Kconfig* files in the
|
||||
|
|
|
@ -62,14 +62,14 @@ in
|
|||
kernel = liminix.builders.kernel.override {
|
||||
inherit (config.kernel) config src extraPatchPhase;
|
||||
};
|
||||
dtb = (callPackage ../kernel/dtb.nix {}) {
|
||||
dtb = liminix.builders.dtb {
|
||||
inherit (config.boot) commandLine;
|
||||
dts = config.hardware.dts.src;
|
||||
includes = config.hardware.dts.includes ++ [
|
||||
"${kernel.headers}/include"
|
||||
];
|
||||
};
|
||||
uimage = (callPackage ../kernel/uimage.nix {}) {
|
||||
uimage = liminix.builders.uimage {
|
||||
commandLine = concatStringsSep " " config.boot.commandLine;
|
||||
inherit (config.hardware) loadAddress entryPoint;
|
||||
inherit kernel;
|
||||
|
|
|
@ -16,6 +16,8 @@ in {
|
|||
networking = callPackage ./liminix-tools/networking {};
|
||||
builders = {
|
||||
squashfs = callPackage ./liminix-tools/builders/squashfs.nix {};
|
||||
dtb = callPackage ./kernel/dtb.nix {};
|
||||
uimage = callPackage ./kernel/uimage.nix {};
|
||||
kernel = callPackage ./kernel {};
|
||||
};
|
||||
callService = path : parameters :
|
||||
|
|
|
@ -11,6 +11,12 @@
|
|||
let
|
||||
writeConfig = import ./write-kconfig.nix { inherit lib writeText; };
|
||||
kconfigFile = writeConfig "kconfig" config;
|
||||
arch = if stdenv.isMips
|
||||
then "mips"
|
||||
else if stdenv.isAarch64
|
||||
then "arm64"
|
||||
else throw "unknown arch";
|
||||
|
||||
inherit lib; in
|
||||
stdenv.mkDerivation rec {
|
||||
name = "kernel";
|
||||
|
@ -28,7 +34,7 @@ stdenv.mkDerivation rec {
|
|||
"-I${openssl.dev}/include -L${openssl.out}/lib -L${ncurses.out}/lib";
|
||||
PKG_CONFIG_PATH = "./pkgconfig";
|
||||
CROSS_COMPILE = stdenv.cc.bintools.targetPrefix;
|
||||
ARCH = "mips"; # kernel uses "mips" here for both mips and mipsel
|
||||
ARCH = arch;
|
||||
KBUILD_BUILD_HOST = "liminix.builder";
|
||||
|
||||
dontStrip = true;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
, stdenv
|
||||
, ubootTools
|
||||
, dtc
|
||||
, lib
|
||||
} :
|
||||
let
|
||||
objcopy = "${stdenv.cc.bintools.targetPrefix}objcopy";
|
||||
|
@ -37,11 +38,21 @@ stdenv.mkDerivation {
|
|||
${objcopy} --update-section .appended_dtb=tmp.dtb vmlinux.elf || ${objcopy} --add-section .appended_dtb=${dtb} vmlinux.elf
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
${objcopy} -O binary -R .reginfo -R .notes -R .note -R .comment -R .mdebug -R .note.gnu.build-id -S vmlinux.elf vmlinux.bin
|
||||
rm -f vmlinux.bin.lzma ; lzma -k -z vmlinux.bin
|
||||
mkimage -A mips -O linux -T kernel -C lzma -a ${loadAddress} -e ${entryPoint} -n 'MIPS Liminix Linux ${extraName}' -d vmlinux.bin.lzma kernel.uimage
|
||||
'';
|
||||
buildPhase =
|
||||
let arch =
|
||||
# per output of "mkimage -A list". I *think* these
|
||||
# are the same as the kernel arch convention, but
|
||||
# maybe that's coincidence
|
||||
if stdenv.isMips
|
||||
then "mips"
|
||||
else if stdenv.isAarch64
|
||||
then "arm64"
|
||||
else throw "unknown arch";
|
||||
in ''
|
||||
${objcopy} -O binary -R .reginfo -R .notes -R .note -R .comment -R .mdebug -R .note.gnu.build-id -S vmlinux.elf vmlinux.bin
|
||||
rm -f vmlinux.bin.lzma ; lzma -k -z vmlinux.bin
|
||||
mkimage -A ${arch} -O linux -T kernel -C lzma -a ${loadAddress} -e ${entryPoint} -n '${lib.toUpper arch} Liminix Linux ${extraName}' -d vmlinux.bin.lzma kernel.uimage
|
||||
'';
|
||||
installPhase = ''
|
||||
cp kernel.uimage $out
|
||||
'';
|
Loading…
Reference in a new issue