1{ stdenv, fetchurl, bc, dtc }:
2
3let
4 buildUBoot = { targetPlatforms
5 , filesToInstall
6 , installDir ? "$out"
7 , defconfig
8 , extraMeta ? {}
9 , ... } @ args:
10 stdenv.mkDerivation (rec {
11
12 name = "uboot-${defconfig}-${version}";
13 version = "2016.05";
14
15 nativeBuildInputs = [ bc dtc ];
16
17 src = fetchurl {
18 url = "ftp://ftp.denx.de/pub/u-boot/u-boot-${version}.tar.bz2";
19 sha256 = "0wdivib8kbm17qr6r7n7wyzg5vnwpagvwk5m0z80rbssc5sj5l47";
20 };
21
22 configurePhase = ''
23 make ${defconfig}
24 '';
25
26 installPhase = ''
27 runHook preInstall
28
29 mkdir -p ${installDir}
30 cp ${stdenv.lib.concatStringsSep " " filesToInstall} ${installDir}
31
32 runHook postInstall
33 '';
34
35 dontStrip = true;
36
37 crossAttrs = {
38 makeFlags = [
39 "ARCH=${stdenv.cross.platform.kernelArch}"
40 "CROSS_COMPILE=${stdenv.cross.config}-"
41 ];
42 };
43
44 meta = with stdenv.lib; {
45 homepage = "http://www.denx.de/wiki/U-Boot/";
46 description = "Boot loader for embedded systems";
47 license = licenses.gpl2;
48 maintainers = [ maintainers.dezgeg ];
49 platforms = targetPlatforms;
50 } // extraMeta;
51 } // args);
52
53in rec {
54 inherit buildUBoot;
55
56 ubootTools = buildUBoot rec {
57 defconfig = "allnoconfig";
58 installDir = "$out/bin";
59 buildFlags = "tools NO_SDL=1";
60 dontStrip = false;
61 targetPlatforms = stdenv.lib.platforms.linux;
62 filesToInstall = ["tools/dumpimage" "tools/mkenvimage" "tools/mkimage"];
63 };
64
65 ubootBananaPi = buildUBoot rec {
66 defconfig = "Bananapi_defconfig";
67 targetPlatforms = ["armv7l-linux"];
68 filesToInstall = ["u-boot-sunxi-with-spl.bin"];
69 };
70
71 ubootBeagleboneBlack = buildUBoot rec {
72 defconfig = "am335x_boneblack_defconfig";
73 targetPlatforms = ["armv7l-linux"];
74 filesToInstall = ["MLO" "u-boot.img"];
75 };
76
77 ubootJetsonTK1 = buildUBoot rec {
78 defconfig = "jetson-tk1_defconfig";
79 targetPlatforms = ["armv7l-linux"];
80 filesToInstall = ["u-boot" "u-boot.dtb" "u-boot-dtb-tegra.bin" "u-boot-nodtb-tegra.bin"];
81 };
82
83 ubootPcduino3Nano = buildUBoot rec {
84 defconfig = "Linksprite_pcDuino3_Nano_defconfig";
85 targetPlatforms = ["armv7l-linux"];
86 filesToInstall = ["u-boot-sunxi-with-spl.bin"];
87 };
88
89 ubootRaspberryPi = buildUBoot rec {
90 defconfig = "rpi_defconfig";
91 targetPlatforms = ["armv6l-linux"];
92 filesToInstall = ["u-boot.bin"];
93 };
94
95 ubootRaspberryPi2 = buildUBoot rec {
96 defconfig = "rpi_2_defconfig";
97 targetPlatforms = ["armv7l-linux"];
98 filesToInstall = ["u-boot.bin"];
99 };
100
101 ubootRaspberryPi3 = buildUBoot rec {
102 defconfig = "rpi_3_32b_defconfig";
103 targetPlatforms = ["armv7l-linux"];
104 filesToInstall = ["u-boot.bin"];
105 };
106
107 ubootWandboard = buildUBoot rec {
108 defconfig = "wandboard_defconfig";
109 targetPlatforms = ["armv7l-linux"];
110 filesToInstall = ["u-boot.img" "SPL"];
111 };
112}