U-Boot: refactor to allow easier extendability

[dezgeg: minor stylistic tweaks, export buildUBoot for out-of-tree users]
This commit is contained in:
Stefan Junker 2015-11-03 00:53:10 +01:00 committed by Tuomas Tynkkynen
parent 421989fb5a
commit 95ed5766d6
2 changed files with 85 additions and 81 deletions

View File

@ -1,55 +1,44 @@
{ stdenv, fetchurl, bc, dtc { stdenv, fetchurl, bc, dtc }:
, toolsOnly ? false
, defconfig ? "allnoconfig"
, targetPlatforms
, filesToInstall
}:
let let
platform = stdenv.platform; buildUBoot = { targetPlatforms
crossPlatform = stdenv.cross.platform; , filesToInstall
makeTarget = if toolsOnly then "tools NO_SDL=1" else "all"; , installDir ? "$out"
installDir = if toolsOnly then "$out/bin" else "$out"; , defconfig
buildFun = kernelArch: , extraMeta ? {}
'' , ... } @ args:
if test -z "$crossConfig"; then stdenv.mkDerivation (rec {
make ${makeTarget}
else
make ${makeTarget} ARCH=${kernelArch} CROSS_COMPILE=$crossConfig-
fi
'';
in
stdenv.mkDerivation rec {
name = "uboot-${defconfig}-${version}"; name = "uboot-${defconfig}-${version}";
version = "2015.10"; version = "2015.10";
nativeBuildInputs = [ bc dtc ];
src = fetchurl { src = fetchurl {
url = "ftp://ftp.denx.de/pub/u-boot/u-boot-${version}.tar.bz2"; url = "ftp://ftp.denx.de/pub/u-boot/u-boot-${version}.tar.bz2";
sha256 = "0m8r08izci0lzzjn5c5g5manp2rc7yc5swww0lxr7bamjigqvimx"; sha256 = "0m8r08izci0lzzjn5c5g5manp2rc7yc5swww0lxr7bamjigqvimx";
}; };
patches = [ ./vexpress-Use-config_distro_bootcmd.patch ];
nativeBuildInputs = [ bc dtc ];
configurePhase = '' configurePhase = ''
make ${defconfig} make ${defconfig}
''; '';
buildPhase = assert (platform ? kernelArch);
buildFun platform.kernelArch;
installPhase = '' installPhase = ''
runHook preInstall
mkdir -p ${installDir} mkdir -p ${installDir}
cp ${stdenv.lib.concatStringsSep " " filesToInstall} ${installDir} cp ${stdenv.lib.concatStringsSep " " filesToInstall} ${installDir}
runHook postInstall
''; '';
dontStrip = !toolsOnly; dontStrip = true;
crossAttrs = { crossAttrs = {
buildPhase = assert (crossPlatform ? kernelArch); makeFlags = [
buildFun crossPlatform.kernelArch; "ARCH=${stdenv.cross.platform.kernelArch}"
"CROSS_COMPILE=${stdenv.cross.config}-"
];
}; };
meta = with stdenv.lib; { meta = with stdenv.lib; {
@ -58,5 +47,43 @@ stdenv.mkDerivation rec {
license = licenses.gpl2; license = licenses.gpl2;
maintainers = [ maintainers.dezgeg ]; maintainers = [ maintainers.dezgeg ];
platforms = targetPlatforms; platforms = targetPlatforms;
} // extraMeta;
} // args);
in rec {
inherit buildUBoot;
ubootTools = buildUBoot rec {
installDir = "$out/bin";
buildFlags = "tools NO_SDL=1";
dontStrip = false;
targetPlatforms = stdenv.lib.platforms.linux;
filesToInstall = ["tools/dumpimage" "tools/mkenvimage" "tools/mkimage"];
};
ubootJetsonTK1 = buildUBoot rec {
defconfig = "jetson-tk1_defconfig";
targetPlatforms = ["armv7l-linux"];
filesToInstall = ["u-boot" "u-boot.dtb" "u-boot-dtb-tegra.bin" "u-boot-nodtb-tegra.bin"];
};
ubootPcduino3Nano = buildUBoot rec {
defconfig = "Linksprite_pcDuino3_Nano_defconfig";
targetPlatforms = ["armv7l-linux"];
filesToInstall = ["u-boot-sunxi-with-spl.bin"];
};
ubootRaspberryPi = buildUBoot rec {
defconfig = "rpi_defconfig";
targetPlatforms = ["armv6l-linux"];
filesToInstall = ["u-boot.bin"];
};
# Intended only for QEMU's vexpress-a9 emulation target!
ubootVersatileExpressCA9 = buildUBoot rec {
defconfig = "vexpress_ca9x4_defconfig";
targetPlatforms = ["armv7l-linux"];
filesToInstall = ["u-boot"];
patches = [ ./vexpress-Use-config_distro_bootcmd.patch ];
}; };
} }

View File

@ -10574,36 +10574,13 @@ let
ubootChooser = name: ubootTools; ubootChooser = name: ubootTools;
# Upstream U-Boots: # Upstream U-Boots:
ubootTools = callPackage ../misc/uboot { inherit (callPackage ../misc/uboot {})
toolsOnly = true; buildUBoot
targetPlatforms = lib.platforms.linux; ubootJetsonTK1
filesToInstall = ["tools/dumpimage" "tools/mkenvimage" "tools/mkimage"]; ubootPcduino3Nano
}; ubootRaspberryPi
ubootVersatileExpressCA9
ubootJetsonTK1 = callPackage ../misc/uboot { ;
defconfig = "jetson-tk1_defconfig";
targetPlatforms = ["armv7l-linux"];
filesToInstall = ["u-boot" "u-boot.dtb" "u-boot-dtb-tegra.bin" "u-boot-nodtb-tegra.bin"];
};
ubootPcduino3Nano = callPackage ../misc/uboot {
defconfig = "Linksprite_pcDuino3_Nano_defconfig";
targetPlatforms = ["armv7l-linux"];
filesToInstall = ["u-boot-sunxi-with-spl.bin"];
};
ubootRaspberryPi = callPackage ../misc/uboot {
defconfig = "rpi_defconfig";
targetPlatforms = ["armv6l-linux"];
filesToInstall = ["u-boot.bin"];
};
# Intended only for QEMU's vexpress-a9 emulation target!
ubootVersatileExpressCA9 = callPackage ../misc/uboot {
defconfig = "vexpress_ca9x4_defconfig";
targetPlatforms = ["armv7l-linux"];
filesToInstall = ["u-boot"];
};
# Non-upstream U-Boots: # Non-upstream U-Boots:
ubootSheevaplug = callPackage ../misc/uboot/sheevaplug.nix { }; ubootSheevaplug = callPackage ../misc/uboot/sheevaplug.nix { };