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 {
|
extraPatchPhase = mkOption {
|
||||||
default = "true";
|
default = "true";
|
||||||
type = types.lines;
|
type = types.lines;
|
||||||
} ;
|
};
|
||||||
config = mkOption {
|
config = mkOption {
|
||||||
description = ''
|
description = ''
|
||||||
Kernel config options, as listed in Kconfig* files in the
|
Kernel config options, as listed in Kconfig* files in the
|
||||||
|
|
|
@ -62,14 +62,14 @@ in
|
||||||
kernel = liminix.builders.kernel.override {
|
kernel = liminix.builders.kernel.override {
|
||||||
inherit (config.kernel) config src extraPatchPhase;
|
inherit (config.kernel) config src extraPatchPhase;
|
||||||
};
|
};
|
||||||
dtb = (callPackage ../kernel/dtb.nix {}) {
|
dtb = liminix.builders.dtb {
|
||||||
inherit (config.boot) commandLine;
|
inherit (config.boot) commandLine;
|
||||||
dts = config.hardware.dts.src;
|
dts = config.hardware.dts.src;
|
||||||
includes = config.hardware.dts.includes ++ [
|
includes = config.hardware.dts.includes ++ [
|
||||||
"${kernel.headers}/include"
|
"${kernel.headers}/include"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
uimage = (callPackage ../kernel/uimage.nix {}) {
|
uimage = liminix.builders.uimage {
|
||||||
commandLine = concatStringsSep " " config.boot.commandLine;
|
commandLine = concatStringsSep " " config.boot.commandLine;
|
||||||
inherit (config.hardware) loadAddress entryPoint;
|
inherit (config.hardware) loadAddress entryPoint;
|
||||||
inherit kernel;
|
inherit kernel;
|
||||||
|
|
|
@ -16,6 +16,8 @@ in {
|
||||||
networking = callPackage ./liminix-tools/networking {};
|
networking = callPackage ./liminix-tools/networking {};
|
||||||
builders = {
|
builders = {
|
||||||
squashfs = callPackage ./liminix-tools/builders/squashfs.nix {};
|
squashfs = callPackage ./liminix-tools/builders/squashfs.nix {};
|
||||||
|
dtb = callPackage ./kernel/dtb.nix {};
|
||||||
|
uimage = callPackage ./kernel/uimage.nix {};
|
||||||
kernel = callPackage ./kernel {};
|
kernel = callPackage ./kernel {};
|
||||||
};
|
};
|
||||||
callService = path : parameters :
|
callService = path : parameters :
|
||||||
|
|
|
@ -11,6 +11,12 @@
|
||||||
let
|
let
|
||||||
writeConfig = import ./write-kconfig.nix { inherit lib writeText; };
|
writeConfig = import ./write-kconfig.nix { inherit lib writeText; };
|
||||||
kconfigFile = writeConfig "kconfig" config;
|
kconfigFile = writeConfig "kconfig" config;
|
||||||
|
arch = if stdenv.isMips
|
||||||
|
then "mips"
|
||||||
|
else if stdenv.isAarch64
|
||||||
|
then "arm64"
|
||||||
|
else throw "unknown arch";
|
||||||
|
|
||||||
inherit lib; in
|
inherit lib; in
|
||||||
stdenv.mkDerivation rec {
|
stdenv.mkDerivation rec {
|
||||||
name = "kernel";
|
name = "kernel";
|
||||||
|
@ -28,7 +34,7 @@ stdenv.mkDerivation rec {
|
||||||
"-I${openssl.dev}/include -L${openssl.out}/lib -L${ncurses.out}/lib";
|
"-I${openssl.dev}/include -L${openssl.out}/lib -L${ncurses.out}/lib";
|
||||||
PKG_CONFIG_PATH = "./pkgconfig";
|
PKG_CONFIG_PATH = "./pkgconfig";
|
||||||
CROSS_COMPILE = stdenv.cc.bintools.targetPrefix;
|
CROSS_COMPILE = stdenv.cc.bintools.targetPrefix;
|
||||||
ARCH = "mips"; # kernel uses "mips" here for both mips and mipsel
|
ARCH = arch;
|
||||||
KBUILD_BUILD_HOST = "liminix.builder";
|
KBUILD_BUILD_HOST = "liminix.builder";
|
||||||
|
|
||||||
dontStrip = true;
|
dontStrip = true;
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
, stdenv
|
, stdenv
|
||||||
, ubootTools
|
, ubootTools
|
||||||
, dtc
|
, dtc
|
||||||
|
, lib
|
||||||
} :
|
} :
|
||||||
let
|
let
|
||||||
objcopy = "${stdenv.cc.bintools.targetPrefix}objcopy";
|
objcopy = "${stdenv.cc.bintools.targetPrefix}objcopy";
|
||||||
|
@ -37,10 +38,20 @@ stdenv.mkDerivation {
|
||||||
${objcopy} --update-section .appended_dtb=tmp.dtb vmlinux.elf || ${objcopy} --add-section .appended_dtb=${dtb} vmlinux.elf
|
${objcopy} --update-section .appended_dtb=tmp.dtb vmlinux.elf || ${objcopy} --add-section .appended_dtb=${dtb} vmlinux.elf
|
||||||
'';
|
'';
|
||||||
|
|
||||||
buildPhase = ''
|
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
|
${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
|
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
|
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 = ''
|
installPhase = ''
|
||||||
cp kernel.uimage $out
|
cp kernel.uimage $out
|
Loading…
Reference in a new issue