U-Boot: Update to 2015.04 and major refactor

Instead of selecting the defconfig based on stdenv.platform.uboot,
provide different ubootFoo packages. Otherwise we couldn't easily build
U-Boots for different platforms than what we are currently running on.

All users of the ubootChooser function appear to be using only CLI tools
like mkimage, whose behaviour is not affected by the defconfig (their
build outputs are bitwise-identical). So add a separate package for the
CLI tools.

Of the removed patches, some version of sheevaplug-sdio.patch has
apparently been applied upstream (with at least mv_sdio.c renamed to
mvebu_mmc.c). sheevaplug-config.patch needs rebasing & re-testing on
real hardware.

Tested boards and input/output methods that upstream supports:
 - Raspberry Pi:
    - HDMI works, USB keyboard not yet supported
    - Serial via the 26-pin connector (3.3V)
 - pcDuino3 Nano:
    - HDMI + USB keyboard (only if attached to a hub)
    - Serial via the 3-pin connector (3.3V)
 - Jetson TK1: RS-232 serial port only
 - Versatile Express CA9 (for QEMU only): Serial via '-serial stdio'
This commit is contained in:
Tuomas Tynkkynen
2015-06-30 10:49:56 +03:00
parent 1793fdbfb1
commit d013de6d32
4 changed files with 73 additions and 1204 deletions
+39 -50
View File
@@ -1,71 +1,60 @@
{stdenv, fetchurl, unzip}:
{ stdenv, fetchurl, bc, dtc
, toolsOnly ? false
, defconfig ? "allnoconfig"
, targetPlatforms
, filesToInstall
}:
let
platform = stdenv.platform;
configureFun = ubootConfig :
crossPlatform = stdenv.cross.platform;
makeTarget = if toolsOnly then "tools NO_SDL=1" else "all";
installDir = if toolsOnly then "$out/bin" else "$out";
buildFun = kernelArch:
''
make mrproper
make ${ubootConfig} NBOOT=1 LE=1
'';
buildFun = kernelArch :
''
unset src
if test -z "$crossConfig"; then
make clean all
make ${makeTarget}
else
make clean all ARCH=${kernelArch} CROSS_COMPILE=$crossConfig-
make ${makeTarget} ARCH=${kernelArch} CROSS_COMPILE=$crossConfig-
fi
'';
in
stdenv.mkDerivation {
name = "uboot-2012.07";
stdenv.mkDerivation rec {
name = "uboot-${defconfig}-${version}";
version = "2015.04";
src = fetchurl {
url = "ftp://ftp.denx.de/pub/u-boot/u-boot-2012.07.tar.bz2";
sha256 = "15nli6h9a127ldizsck3g4ysy5j4m910wawspgpadz4vjyk213p0";
url = "ftp://ftp.denx.de/pub/u-boot/u-boot-${version}.tar.bz2";
sha256 = "0q2x1wh1f6rjh9rmcnkf28dxcvp9hkhi4vzspqkzamb6b3gp06ha";
};
nativeBuildInputs = [ unzip ];
nativeBuildInputs = [ bc dtc ];
dontStrip = true;
installPhase = ''
mkdir -p $out
cp u-boot.bin $out
cp u-boot u-boot.map $out
mkdir -p $out/bin
cp tools/{envcrc,mkimage} $out/bin
configurePhase = ''
make ${defconfig}
'';
# They have 'errno.h' included by a "-idirafter". As the gcc
# wrappers add the glibc include as "-idirafter", the only way
# we can make the glibc take priority is to -include errno.h.
postPatch = if stdenv ? glibc && stdenv.glibc != null then ''
sed -i 's,$(HOSTCPPFLAGS),-include ${stdenv.glibc}/include/errno.h $(HOSTCPPFLAGS),' config.mk
'' else "";
patches = [ ./sheevaplug-sdio.patch ./sheevaplug-config.patch ];
configurePhase =
assert platform ? uboot && platform.uboot != null;
assert (platform ? ubootConfig);
configureFun platform.ubootConfig;
buildPhase = assert (platform ? kernelArch);
buildFun platform.kernelArch;
crossAttrs = let
cp = stdenv.cross.platform;
in
assert cp ? uboot && cp.uboot != null;
{
configurePhase = assert (cp ? ubootConfig);
configureFun cp.ubootConfig;
installPhase = ''
mkdir -p ${installDir}
cp ${stdenv.lib.concatStringsSep " " filesToInstall} ${installDir}
'';
buildPhase = assert (cp ? kernelArch);
buildFun cp.kernelArch;
};
dontStrip = !toolsOnly;
crossAttrs = {
buildPhase = assert (crossPlatform ? kernelArch);
buildFun crossPlatform.kernelArch;
};
meta = with stdenv.lib; {
homepage = "http://www.denx.de/wiki/U-Boot/";
description = "Boot loader for embedded systems";
license = licenses.gpl2;
maintainers = [ maintainers.dezgeg ];
platforms = targetPlatforms;
};
}