18 , armTrustedFirmwareAllwinner
19 , armTrustedFirmwareAllwinnerH6
20 , armTrustedFirmwareAllwinnerH616
21 , armTrustedFirmwareRK3328
22 , armTrustedFirmwareRK3399
23 , armTrustedFirmwareS905
28 defaultVersion = "2023.07.02";
29 defaultSrc = fetchurl {
30 url = "https://ftp.denx.de/pub/u-boot/u-boot-${defaultVersion}.tar.bz2";
31 hash = "sha256-a2pIWBwUq7D5W9h8GvTXQJIkBte4AQAqn5Ryf93gIdU=";
34 # Dependencies for the tools need to be included as either native or cross,
35 # depending on which we're building
37 ncurses # tools/kwboot
38 libuuid # tools/mkeficapsule
39 gnutls # tools/mkeficapsule
40 openssl # tools/mkimage
43 buildUBoot = lib.makeOverridable ({
54 , ... } @ args: stdenv.mkDerivation ({
55 pname = "uboot-${defconfig}";
57 version = if src == null then defaultVersion else version;
59 src = if src == null then defaultSrc else src;
62 ./0001-configs-rpi-allow-for-bigger-kernels.patch
71 ncurses # tools/kwboot
77 (buildPackages.python3.withPackages (p: [
79 p.setuptools # for pkg_resources
83 which # for scripts/dtc-version.sh
84 ] ++ lib.optionals (!crossTools) toolsDeps;
85 depsBuildBuild = [ buildPackages.stdenv.cc ];
86 buildInputs = lib.optionals crossTools toolsDeps;
88 hardeningDisable = [ "all" ];
90 enableParallelBuilding = true;
94 "CROSS_COMPILE=${stdenv.cc.targetPrefix}"
97 passAsFile = [ "extraConfig" ];
104 cat $extraConfigPath >> .config
106 runHook postConfigure
112 mkdir -p ${installDir}
113 cp ${lib.concatStringsSep " " filesToInstall} ${installDir}
115 mkdir -p "$out/nix-support"
116 ${lib.concatMapStrings (file: ''
117 echo "file binary-dist ${installDir}/${builtins.baseNameOf file}" >> "$out/nix-support/hydra-build-products"
126 homepage = "https://www.denx.de/wiki/U-Boot/";
127 description = "Boot loader for embedded systems";
128 license = licenses.gpl2;
129 maintainers = with maintainers; [ bartsch dezgeg samueldr lopsided98 ];
131 } // removeAttrs args [ "extraMeta" ]));
135 ubootTools = buildUBoot {
136 defconfig = "tools-only_defconfig";
137 installDir = "$out/bin";
138 hardeningDisable = [];
140 extraMeta.platforms = lib.platforms.linux;
143 extraMakeFlags = [ "HOST_TOOLS_ALL=y" "NO_SDL=1" "cross_tools" ];
145 outputs = [ "out" "man" ];
148 installManPage doc/*.1
159 ubootA20OlinuxinoLime = buildUBoot {
160 defconfig = "A20-OLinuXino-Lime_defconfig";
161 extraMeta.platforms = ["armv7l-linux"];
162 filesToInstall = ["u-boot-sunxi-with-spl.bin"];
165 ubootA20OlinuxinoLime2EMMC = buildUBoot {
166 defconfig = "A20-OLinuXino-Lime2-eMMC_defconfig";
167 extraMeta.platforms = ["armv7l-linux"];
168 filesToInstall = ["u-boot-sunxi-with-spl.bin"];
171 ubootAmx335xEVM = buildUBoot {
172 defconfig = "am335x_evm_defconfig";
173 extraMeta.platforms = ["armv7l-linux"];
174 filesToInstall = ["MLO" "u-boot.img"];
177 ubootBananaPi = buildUBoot {
178 defconfig = "Bananapi_defconfig";
179 extraMeta.platforms = ["armv7l-linux"];
180 filesToInstall = ["u-boot-sunxi-with-spl.bin"];
183 ubootBananaPim3 = buildUBoot {
184 defconfig = "Sinovoip_BPI_M3_defconfig";
185 extraMeta.platforms = ["armv7l-linux"];
186 filesToInstall = ["u-boot-sunxi-with-spl.bin"];
189 ubootBananaPim64 = buildUBoot {
190 defconfig = "bananapi_m64_defconfig";
191 extraMeta.platforms = ["aarch64-linux"];
192 BL31 = "${armTrustedFirmwareAllwinner}/bl31.bin";
194 filesToInstall = ["u-boot-sunxi-with-spl.bin"];
197 # http://git.denx.de/?p=u-boot.git;a=blob;f=board/solidrun/clearfog/README;hb=refs/heads/master
198 ubootClearfog = buildUBoot {
199 defconfig = "clearfog_defconfig";
200 extraMeta.platforms = ["armv7l-linux"];
201 filesToInstall = ["u-boot-with-spl.kwb"];
204 ubootCubieboard2 = buildUBoot {
205 defconfig = "Cubieboard2_defconfig";
206 extraMeta.platforms = ["armv7l-linux"];
207 filesToInstall = ["u-boot-sunxi-with-spl.bin"];
210 ubootGuruplug = buildUBoot {
211 defconfig = "guruplug_defconfig";
212 extraMeta.platforms = ["armv5tel-linux"];
213 filesToInstall = ["u-boot.bin"];
216 ubootJetsonTK1 = buildUBoot {
217 defconfig = "jetson-tk1_defconfig";
218 extraMeta.platforms = ["armv7l-linux"];
219 filesToInstall = ["u-boot" "u-boot.dtb" "u-boot-dtb-tegra.bin" "u-boot-nodtb-tegra.bin"];
220 # tegra-uboot-flasher expects this exact directory layout, sigh...
223 cp spl/u-boot-spl $out/spl/
227 # Flashing instructions:
228 # dd if=u-boot.gxl.sd.bin of=<sdcard> conv=fsync,notrunc bs=512 skip=1 seek=1
229 # dd if=u-boot.gxl.sd.bin of=<sdcard> conv=fsync,notrunc bs=1 count=444
230 ubootLibreTechCC = let
231 firmwareImagePkg = fetchFromGitHub {
233 repo = "amlogic-boot-fip";
234 rev = "4369a138ca24c5ab932b8cbd1af4504570b709df";
235 sha256 = "sha256-mGRUwdh3nW4gBwWIYHJGjzkezHxABwcwk/1gVRis7Tc=";
236 meta.license = lib.licenses.unfreeRedistributableFirmware;
239 assert stdenv.buildPlatform.system == "x86_64-linux"; # aml_encrypt_gxl is a x86_64 binary
241 defconfig = "libretech-cc_defconfig";
242 extraMeta.platforms = ["aarch64-linux"];
243 filesToInstall = ["u-boot.bin"];
245 # Copy binary files & tools from LibreELEC/amlogic-boot-fip, and u-boot build to working dir
247 cp ${firmwareImagePkg}/lepotato/{acs.bin,bl2.bin,bl21.bin,bl30.bin,bl301.bin,bl31.img} \
248 ${firmwareImagePkg}/lepotato/{acs_tool.py,aml_encrypt_gxl,blx_fix.sh} \
251 python3 acs_tool.py bl2.bin bl2_acs.bin acs.bin 0
253 bash -e blx_fix.sh bl2_acs.bin zero bl2_zero.bin bl21.bin bl21_zero.bin bl2_new.bin bl2
254 [ -f zero ] && rm zero
256 bash -e blx_fix.sh bl30.bin zero bl30_zero.bin bl301.bin bl301_zero.bin bl30_new.bin bl30
257 [ -f zero ] && rm zero
259 ./aml_encrypt_gxl --bl2sig --input bl2_new.bin --output bl2.n.bin.sig
260 ./aml_encrypt_gxl --bl3enc --input bl30_new.bin --output bl30_new.bin.enc
261 ./aml_encrypt_gxl --bl3enc --input bl31.img --output bl31.img.enc
262 ./aml_encrypt_gxl --bl3enc --input u-boot.bin --output bl33.bin.enc
263 ./aml_encrypt_gxl --bootmk --output $out/u-boot.gxl \
264 --bl2 bl2.n.bin.sig --bl30 bl30_new.bin.enc --bl31 bl31.img.enc --bl33 bl33.bin.enc
268 ubootNanoPCT4 = buildUBoot rec {
269 rkbin = fetchFromGitHub {
272 rev = "3bd0321cae5ef881a6005fb470009ad5a5d1462d";
273 sha256 = "09r4dzxsbs3pff4sh70qnyp30s3rc7pkc46v1m3152s7jqjasp31";
276 defconfig = "nanopc-t4-rk3399_defconfig";
279 platforms = ["aarch64-linux"];
280 license = lib.licenses.unfreeRedistributableFirmware;
282 BL31="${armTrustedFirmwareRK3399}/bl31.elf";
283 filesToInstall = ["u-boot.itb" "idbloader.img"];
285 ./tools/mkimage -n rk3399 -T rksd -d ${rkbin}/rk33/rk3399_ddr_800MHz_v1.24.bin idbloader.img
286 cat ${rkbin}/rk33/rk3399_miniloader_v1.19.bin >> idbloader.img
290 ubootNovena = buildUBoot {
291 defconfig = "novena_defconfig";
292 extraMeta.platforms = ["armv7l-linux"];
293 filesToInstall = ["u-boot-dtb.img" "SPL"];
296 # Flashing instructions:
297 # dd if=bl1.bin.hardkernel of=<device> conv=fsync bs=1 count=442
298 # dd if=bl1.bin.hardkernel of=<device> conv=fsync bs=512 skip=1 seek=1
299 # dd if=u-boot.gxbb of=<device> conv=fsync bs=512 seek=97
301 firmwareBlobs = fetchFromGitHub {
303 repo = "odroidc2-blobs";
304 rev = "47c5aac4bcac6f067cebe76e41fb9924d45b429c";
305 sha256 = "1ns0a130yxnxysia8c3q2fgyjp9k0nkr689dxk88qh2vnibgchnp";
306 meta.license = lib.licenses.unfreeRedistributableFirmware;
309 defconfig = "odroid-c2_defconfig";
310 extraMeta.platforms = ["aarch64-linux"];
311 filesToInstall = ["u-boot.bin" "u-boot.gxbb" "${firmwareBlobs}/bl1.bin.hardkernel"];
313 # BL301 image needs at least 64 bytes of padding after it to place
314 # signing headers (with amlbootsig)
315 truncate -s 64 bl301.padding.bin
316 cat '${firmwareBlobs}/gxb/bl301.bin' bl301.padding.bin > bl301.padded.bin
317 # The downstream fip_create tool adds a custom TOC entry with UUID
318 # AABBCCDD-ABCD-EFEF-ABCD-12345678ABCD for the BL301 image. It turns out
319 # that the firmware blob does not actually care about UUIDs, only the
320 # order the images appear in the file. Because fiptool does not know
321 # about the BL301 UUID, we would have to use the --blob option, which adds
322 # the image to the end of the file, causing the boot to fail. Instead, we
323 # take advantage of the fact that UUIDs are ignored and just put the
324 # images in the right order with the wrong UUIDs. In the command below,
325 # --tb-fw is really --scp-fw and --scp-fw is the BL301 image.
327 # See https://github.com/afaerber/meson-tools/issues/3 for more
329 '${buildPackages.armTrustedFirmwareTools}/bin/fiptool' create \
331 --tb-fw '${firmwareBlobs}/gxb/bl30.bin' \
332 --scp-fw bl301.padded.bin \
333 --soc-fw '${armTrustedFirmwareS905}/bl31.bin' \
336 cat '${firmwareBlobs}/gxb/bl2.package' fip.bin > boot_new.bin
337 '${buildPackages.meson-tools}/bin/amlbootsig' boot_new.bin u-boot.img
338 dd if=u-boot.img of=u-boot.gxbb bs=512 skip=96
342 ubootOdroidXU3 = buildUBoot {
343 defconfig = "odroid-xu3_defconfig";
344 extraMeta.platforms = ["armv7l-linux"];
345 filesToInstall = ["u-boot-dtb.bin"];
348 ubootOlimexA64Olinuxino = buildUBoot {
349 defconfig = "a64-olinuxino-emmc_defconfig";
350 extraMeta.platforms = ["aarch64-linux"];
351 BL31 = "${armTrustedFirmwareAllwinner}/bl31.bin";
353 filesToInstall = ["u-boot-sunxi-with-spl.bin"];
356 ubootOrangePiPc = buildUBoot {
357 defconfig = "orangepi_pc_defconfig";
358 extraMeta.platforms = ["armv7l-linux"];
359 filesToInstall = ["u-boot-sunxi-with-spl.bin"];
362 ubootOrangePiZeroPlus2H5 = buildUBoot {
363 defconfig = "orangepi_zero_plus2_defconfig";
364 extraMeta.platforms = ["aarch64-linux"];
365 BL31 = "${armTrustedFirmwareAllwinner}/bl31.bin";
367 filesToInstall = ["u-boot-sunxi-with-spl.bin"];
370 ubootOrangePiZero = buildUBoot {
371 defconfig = "orangepi_zero_defconfig";
372 extraMeta.platforms = ["armv7l-linux"];
373 filesToInstall = ["u-boot-sunxi-with-spl.bin"];
376 ubootOrangePiZero2 = buildUBoot {
377 defconfig = "orangepi_zero2_defconfig";
378 extraMeta.platforms = ["aarch64-linux"];
379 BL31 = "${armTrustedFirmwareAllwinnerH616}/bl31.bin";
380 filesToInstall = ["u-boot-sunxi-with-spl.bin"];
383 ubootOrangePi3 = buildUBoot {
384 defconfig = "orangepi_3_defconfig";
385 extraMeta.platforms = ["aarch64-linux"];
386 BL31 = "${armTrustedFirmwareAllwinnerH6}/bl31.bin";
388 filesToInstall = ["u-boot-sunxi-with-spl.bin"];
391 ubootPcduino3Nano = buildUBoot {
392 defconfig = "Linksprite_pcDuino3_Nano_defconfig";
393 extraMeta.platforms = ["armv7l-linux"];
394 filesToInstall = ["u-boot-sunxi-with-spl.bin"];
397 ubootPine64 = buildUBoot {
398 defconfig = "pine64_plus_defconfig";
399 extraMeta.platforms = ["aarch64-linux"];
400 BL31 = "${armTrustedFirmwareAllwinner}/bl31.bin";
402 filesToInstall = ["u-boot-sunxi-with-spl.bin"];
405 ubootPine64LTS = buildUBoot {
406 defconfig = "pine64-lts_defconfig";
407 extraMeta.platforms = ["aarch64-linux"];
408 BL31 = "${armTrustedFirmwareAllwinner}/bl31.bin";
410 filesToInstall = ["u-boot-sunxi-with-spl.bin"];
413 ubootPinebook = buildUBoot {
414 defconfig = "pinebook_defconfig";
415 extraMeta.platforms = ["aarch64-linux"];
416 BL31 = "${armTrustedFirmwareAllwinner}/bl31.bin";
418 filesToInstall = ["u-boot-sunxi-with-spl.bin"];
421 ubootPinebookPro = buildUBoot {
422 defconfig = "pinebook-pro-rk3399_defconfig";
423 extraMeta.platforms = ["aarch64-linux"];
424 BL31 = "${armTrustedFirmwareRK3399}/bl31.elf";
425 filesToInstall = [ "u-boot.itb" "idbloader.img"];
428 ubootQemuAarch64 = buildUBoot {
429 defconfig = "qemu_arm64_defconfig";
430 extraMeta.platforms = ["aarch64-linux"];
431 filesToInstall = ["u-boot.bin"];
434 ubootQemuArm = buildUBoot {
435 defconfig = "qemu_arm_defconfig";
436 extraMeta.platforms = ["armv7l-linux"];
437 filesToInstall = ["u-boot.bin"];
440 ubootQemuRiscv64Smode = buildUBoot {
441 defconfig = "qemu-riscv64_smode_defconfig";
442 extraMeta.platforms = ["riscv64-linux"];
443 filesToInstall = ["u-boot.bin"];
446 ubootQemuX86 = buildUBoot {
447 defconfig = "qemu-x86_defconfig";
449 CONFIG_USB_UHCI_HCD=y
450 CONFIG_USB_EHCI_HCD=y
451 CONFIG_USB_EHCI_GENERIC=y
452 CONFIG_USB_XHCI_HCD=y
454 extraMeta.platforms = [ "i686-linux" "x86_64-linux" ];
455 filesToInstall = [ "u-boot.rom" ];
458 ubootRaspberryPi = buildUBoot {
459 defconfig = "rpi_defconfig";
460 extraMeta.platforms = ["armv6l-linux"];
461 filesToInstall = ["u-boot.bin"];
464 ubootRaspberryPi2 = buildUBoot {
465 defconfig = "rpi_2_defconfig";
466 extraMeta.platforms = ["armv7l-linux"];
467 filesToInstall = ["u-boot.bin"];
470 ubootRaspberryPi3_32bit = buildUBoot {
471 defconfig = "rpi_3_32b_defconfig";
472 extraMeta.platforms = ["armv7l-linux"];
473 filesToInstall = ["u-boot.bin"];
476 ubootRaspberryPi3_64bit = buildUBoot {
477 defconfig = "rpi_3_defconfig";
478 extraMeta.platforms = ["aarch64-linux"];
479 filesToInstall = ["u-boot.bin"];
482 ubootRaspberryPi4_32bit = buildUBoot {
483 defconfig = "rpi_4_32b_defconfig";
484 extraMeta.platforms = ["armv7l-linux"];
485 filesToInstall = ["u-boot.bin"];
488 ubootRaspberryPi4_64bit = buildUBoot {
489 defconfig = "rpi_4_defconfig";
490 extraMeta.platforms = ["aarch64-linux"];
491 filesToInstall = ["u-boot.bin"];
494 ubootRaspberryPiZero = buildUBoot {
495 defconfig = "rpi_0_w_defconfig";
496 extraMeta.platforms = ["armv6l-linux"];
497 filesToInstall = ["u-boot.bin"];
501 rkbin = fetchFromGitHub {
502 owner = "ayufan-rock64";
504 rev = "f79a708978232a2b6b06c2e4173c5314559e0d3a";
505 sha256 = "0h7xm4ck3p3380c6bqm5ixrkxwcx6z5vysqdwvfa7gcqx5d6x5zz";
508 defconfig = "rock64-rk3328_defconfig";
510 platforms = [ "aarch64-linux" ];
511 license = lib.licenses.unfreeRedistributableFirmware;
513 BL31="${armTrustedFirmwareRK3328}/bl31.elf";
514 filesToInstall = [ "u-boot.itb" "idbloader.img"];
515 # Derive MAC address from cpuid
516 # Submitted upstream: https://patchwork.ozlabs.org/patch/1203686/
520 # Close to being blob free, but the U-Boot TPL causes random memory
523 ./tools/mkimage -n rk3328 -T rksd -d ${rkbin}/rk33/rk3328_ddr_786MHz_v1.13.bin idbloader.img
524 cat spl/u-boot-spl.bin >> idbloader.img
528 ubootRockPro64 = buildUBoot {
530 # https://patchwork.ozlabs.org/project/uboot/list/?series=237654&archive=both&state=*
532 url = "https://patchwork.ozlabs.org/series/237654/mbox/";
533 sha256 = "0aiw9zk8w4msd3v8nndhkspjify0yq6a5f0zdy6mhzs0ilq896c3";
536 defconfig = "rockpro64-rk3399_defconfig";
537 extraMeta.platforms = ["aarch64-linux"];
538 BL31="${armTrustedFirmwareRK3399}/bl31.elf";
539 filesToInstall = [ "u-boot.itb" "idbloader.img"];
542 ubootROCPCRK3399 = buildUBoot {
543 defconfig = "roc-pc-rk3399_defconfig";
544 extraMeta.platforms = ["aarch64-linux"];
545 filesToInstall = [ "spl/u-boot-spl.bin" "u-boot.itb" "idbloader.img"];
546 BL31 = "${armTrustedFirmwareRK3399}/bl31.elf";
549 ubootSheevaplug = buildUBoot {
550 defconfig = "sheevaplug_defconfig";
551 extraMeta.platforms = ["armv5tel-linux"];
552 filesToInstall = ["u-boot.kwb"];
555 ubootSopine = buildUBoot {
556 defconfig = "sopine_baseboard_defconfig";
557 extraMeta.platforms = ["aarch64-linux"];
558 BL31 = "${armTrustedFirmwareAllwinner}/bl31.bin";
560 filesToInstall = ["u-boot-sunxi-with-spl.bin"];
563 ubootUtilite = buildUBoot {
564 defconfig = "cm_fx6_defconfig";
565 extraMeta.platforms = ["armv7l-linux"];
566 filesToInstall = ["u-boot-with-nand-spl.imx"];
567 buildFlags = [ "u-boot-with-nand-spl.imx" ];
571 # sata init; load sata 0 $loadaddr u-boot-with-nand-spl.imx
572 # sf probe; sf update $loadaddr 0 80000
575 ubootWandboard = buildUBoot {
576 defconfig = "wandboard_defconfig";
577 extraMeta.platforms = ["armv7l-linux"];
578 filesToInstall = ["u-boot.img" "SPL"];
581 ubootRockPi4 = buildUBoot {
582 defconfig = "rock-pi-4-rk3399_defconfig";
583 extraMeta.platforms = ["aarch64-linux"];
584 BL31 = "${armTrustedFirmwareRK3399}/bl31.elf";
585 filesToInstall = [ "u-boot.itb" "idbloader.img"];