git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #140552 from samueldr/updates/u-boot-2021.10

uboot: 2021.04 -> 2021.10

commit7882b7fa236d3f96836966a6bd2a4c3c3333f1a5 authorSamuel Dionne-Riel <samuel@dionne-riel.com> dateTue 5 Oct 2021, 18:27 (5 years ago) parent63c76831ef6c4b
3 files changed+106−3
pkgs/misc/uboot/0001-rpi-Copy-properties-from-firmware-dtb-to-the-loaded-.patch+92 pkgs/misc/uboot/default.nix+13−3 pkgs/top-level/all-packages.nix+1
pkgs/misc/uboot/0001-rpi-Copy-properties-from-firmware-dtb-to-the-loaded-.patchnew file+92
@@ -0,0 +1,92 @@
1+From 65d90cd17ad7cd3f9aeeb805a08be780fc5bae1a Mon Sep 17 00:00:00 2001
2+From: Sjoerd Simons <sjoerd@collabora.com>
3+Date: Sun, 22 Aug 2021 16:36:55 +0200
4+Subject: [PATCH] rpi: Copy properties from firmware dtb to the loaded dtb
5+
6+The RPI firmware adjusts several property values in the dtb it passes
7+to u-boot depending on the board/SoC revision. Inherit some of these
8+when u-boot loads a dtb itself. Specificaly copy:
9+
10+* /model: The firmware provides a more specific string
11+* /memreserve: The firmware defines a reserved range, better keep it
12+* emmc2bus and pcie0 dma-ranges: The C0T revision of the bcm2711 Soc (as
13+ present on rpi 400 and some rpi 4B boards) has different values for
14+ these then the B0T revision. So these need to be adjusted to boot on
15+ these boards
16+* blconfig: The firmware defines the memory area where the blconfig
17+ stored. Copy those over so it can be enabled.
18+* /chosen/kaslr-seed: The firmware generates a kaslr seed, take advantage
19+ of that.
20+
21+Signed-off-by: Sjoerd Simons <sjoerd@collabora.com>
22+Origin: https://patchwork.ozlabs.org/project/uboot/patch/20210822143656.289891-1-sjoerd@collabora.com/
23+---
24+ board/raspberrypi/rpi/rpi.c | 48 +++++++++++++++++++++++++++++++++++++
25+ 1 file changed, 48 insertions(+)
26+
27+diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
28+index 372b26b6f2..64b8684b68 100644
29+--- a/board/raspberrypi/rpi/rpi.c
30++++ b/board/raspberrypi/rpi/rpi.c
31+@@ -495,10 +495,58 @@ void *board_fdt_blob_setup(void)
32+ return (void *)fw_dtb_pointer;
33+ }
34+
35++int copy_property(void *dst, void *src, char *path, char *property)
36++{
37++ int dst_offset, src_offset;
38++ const fdt32_t *prop;
39++ int len;
40++
41++ src_offset = fdt_path_offset(src, path);
42++ dst_offset = fdt_path_offset(dst, path);
43++
44++ if (src_offset < 0 || dst_offset < 0)
45++ return -1;
46++
47++ prop = fdt_getprop(src, src_offset, property, &len);
48++ if (!prop)
49++ return -1;
50++
51++ return fdt_setprop(dst, dst_offset, property, prop, len);
52++}
53++
54++/* Copy tweaks from the firmware dtb to the loaded dtb */
55++void update_fdt_from_fw(void *fdt, void *fw_fdt)
56++{
57++ /* Using dtb from firmware directly; leave it alone */
58++ if (fdt == fw_fdt)
59++ return;
60++
61++ /* The firmware provides a more precie model; so copy that */
62++ copy_property(fdt, fw_fdt, "/", "model");
63++
64++ /* memory reserve as suggested by the firmware */
65++ copy_property(fdt, fw_fdt, "/", "memreserve");
66++
67++ /* Adjust dma-ranges for the SD card and PCI bus as they can depend on
68++ * the SoC revision
69++ */
70++ copy_property(fdt, fw_fdt, "emmc2bus", "dma-ranges");
71++ copy_property(fdt, fw_fdt, "pcie0", "dma-ranges");
72++
73++ /* Bootloader configuration template exposes as nvmem */
74++ if (copy_property(fdt, fw_fdt, "blconfig", "reg") == 0)
75++ copy_property(fdt, fw_fdt, "blconfig", "status");
76++
77++ /* kernel address randomisation seed as provided by the firmware */
78++ copy_property(fdt, fw_fdt, "/chosen", "kaslr-seed");
79++}
80++
81+ int ft_board_setup(void *blob, struct bd_info *bd)
82+ {
83+ int node;
84+
85++ update_fdt_from_fw(blob, (void *)fw_dtb_pointer);
86++
87+ node = fdt_node_offset_by_compatible(blob, -1, "simple-framebuffer");
88+ if (node < 0)
89+ lcd_dt_simplefb_add_node(blob);
90+--
91+2.32.0
92+
pkgs/misc/uboot/default.nix+13−3
@@ -19,10 +19,10 @@
1919}:
2020
2121let
22− defaultVersion = "2021.04";
22+ defaultVersion = "2021.10";
2323 defaultSrc = fetchurl {
2424 url = "ftp://ftp.denx.de/pub/u-boot/u-boot-${defaultVersion}.tar.bz2";
25− sha256 = "06p1vymf0dl6jc2xy5w7p42mpgppa46lmpm2ishmgsycnldqnhqd";
25+ sha256 = "1m0bvwv8r62s4wk4w3cmvs888dhv9gnfa98dczr4drk2jbhj7ryd";
2626 };
2727 buildUBoot = {
2828 version ? null
@@ -43,6 +43,11 @@ let
4343
4444 patches = [
4545 ./0001-configs-rpi-allow-for-bigger-kernels.patch
46+
47+ # Make U-Boot forward some important settings from the firmware-provided FDT. Fixes booting on BCM2711C0 boards.
48+ # See also: https://github.com/NixOS/nixpkgs/issues/135828
49+ # Source: https://patchwork.ozlabs.org/project/uboot/patch/20210822143656.289891-1-sjoerd@collabora.com/
50+ ./0001-rpi-Copy-properties-from-firmware-dtb-to-the-loaded-.patch
4651 ] ++ extraPatches;
4752
4853 postPatch = ''
@@ -109,7 +114,6 @@ let
109114 maintainers = with maintainers; [ dezgeg samueldr lopsided98 ];
110115 } // extraMeta;
111116 } // removeAttrs args [ "extraMeta" ]);
112−
113117in {
114118 inherit buildUBoot;
115119
@@ -336,6 +340,12 @@ in {
336340 filesToInstall = ["u-boot.bin"];
337341 };
338342
343+ ubootQemuRiscv64Smode = buildUBoot {
344+ defconfig = "qemu-riscv64_smode_defconfig";
345+ extraMeta.platforms = ["riscv64-linux"];
346+ filesToInstall = ["u-boot.bin"];
347+ };
348+
339349 ubootRaspberryPi = buildUBoot {
340350 defconfig = "rpi_defconfig";
341351 extraMeta.platforms = ["armv6l-linux"];
pkgs/top-level/all-packages.nix+1
@@ -22294,6 +22294,7 @@ with pkgs;
2229422294 ubootPinebookPro
2229522295 ubootQemuAarch64
2229622296 ubootQemuArm
22297+ ubootQemuRiscv64Smode
2229722298 ubootRaspberryPi
2229822299 ubootRaspberryPi2
2229922300 ubootRaspberryPi3_32bit