Merge pull request #140552 from samueldr/updates/u-boot-2021.10

uboot: 2021.04 -> 2021.10

authored by Samuel Dionne-Riel and committed by GitHub 7882b7fa 63c76837

+106 -3
+92
pkgs/misc/uboot/0001-rpi-Copy-properties-from-firmware-dtb-to-the-loaded-.patch
··· 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 +
+13 -3
pkgs/misc/uboot/default.nix
··· 19 19 }: 20 20 21 21 let 22 - defaultVersion = "2021.04"; 22 + defaultVersion = "2021.10"; 23 23 defaultSrc = fetchurl { 24 24 url = "ftp://ftp.denx.de/pub/u-boot/u-boot-${defaultVersion}.tar.bz2"; 25 - sha256 = "06p1vymf0dl6jc2xy5w7p42mpgppa46lmpm2ishmgsycnldqnhqd"; 25 + sha256 = "1m0bvwv8r62s4wk4w3cmvs888dhv9gnfa98dczr4drk2jbhj7ryd"; 26 26 }; 27 27 buildUBoot = { 28 28 version ? null ··· 43 43 44 44 patches = [ 45 45 ./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 46 51 ] ++ extraPatches; 47 52 48 53 postPatch = '' ··· 109 114 maintainers = with maintainers; [ dezgeg samueldr lopsided98 ]; 110 115 } // extraMeta; 111 116 } // removeAttrs args [ "extraMeta" ]); 112 - 113 117 in { 114 118 inherit buildUBoot; 115 119 ··· 333 337 ubootQemuArm = buildUBoot { 334 338 defconfig = "qemu_arm_defconfig"; 335 339 extraMeta.platforms = ["armv7l-linux"]; 340 + filesToInstall = ["u-boot.bin"]; 341 + }; 342 + 343 + ubootQemuRiscv64Smode = buildUBoot { 344 + defconfig = "qemu-riscv64_smode_defconfig"; 345 + extraMeta.platforms = ["riscv64-linux"]; 336 346 filesToInstall = ["u-boot.bin"]; 337 347 }; 338 348
+1
pkgs/top-level/all-packages.nix
··· 22294 22294 ubootPinebookPro 22295 22295 ubootQemuAarch64 22296 22296 ubootQemuArm 22297 + ubootQemuRiscv64Smode 22297 22298 ubootRaspberryPi 22298 22299 ubootRaspberryPi2 22299 22300 ubootRaspberryPi3_32bit