Skip to contentSkip to conversation

VBE serial part H: Implement VBE on Rockchip RK3399

PATCH Superseded Simon Glass 2 participants 33 messages May 25, 2025

Subsystems (3)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v4 cover VBE serial part H: Implement VBE on Rockchip RK3399

This series completes the work to enable VBE on a suitable board. Most of it is rockchip-specific patches to support the VPL phase, i.e. the one which decides which boot patch to take (A, B or recovery).

A good chunk of this series is adding an image for VBE, by creating a new Binman image. Future work in Binman may make this more automated / easier, but for now it is written out in full. The work is undertaken piecemeal so it is easier to review the steps.

VBE allows similar boards to share firmware images, with perhaps just TPL (around 75K) being different for each board. Using a common image for VPL, SPL and U-Boot saves a lot of space in the image and makes builds easier. Of course, each board still needs a separate devicetree.

Here is the layout of the image:

Name Image-pos Size Entry-type Offset Uncomp-size
----------------------------------------------------------------------------------------------

image                                 0   1b960cf  section                    0
  alternates-fdt                   8000     31000  alternates-fdt          8000
    mkimage                        8000     31000  mkimage                    0
      u-boot-tpl                   8048     12a11  u-boot-tpl                48
  vpl                            208000     16200  fit                   208000
    image-vpl                    209400      a5a3  section                 1400
      section                    209400      a5a3  section                    0
        u-boot-vpl-nodtb                    10348  u-boot-vpl-nodtb           0
        u-boot-vpl-bss-pad                     20  u-boot-vpl-bss-pad     10348
    @fdt-SEQ                          0         0  section                    0
  vbe-a                          800000    39b200  section               800000
    spl-a                        800000    100000  fit                        0
      spl                        801400     10c97  section                 1400
        section                  801400     10c97  section                    0
          u-boot-spl-nodtb                  1a908  u-boot-spl-nodtb           0
          u-boot-spl-bss-pad                  1b0  u-boot-spl-bss-pad     1a908
      @fdt-SEQ                        0         0  section                    0
    u-boot-a                     900000    29b200  fit                   100000
      spl                        902400     10c97  section                 2400
        section                  902400     10c97  section                    0
          u-boot-spl-nodtb                  1a908  u-boot-spl-nodtb           0
          u-boot-spl-bss-pad                  1b0  u-boot-spl-bss-pad     1a908
      u-boot                     913200     e4250  section                13200
        u-boot-nodtb             913200     e4250  u-boot-nodtb               0
      @atf-SEQ                        0         0  section                    0
        atf-bl31                      0         0  atf-bl31                   0
      @tee-SEQ                        0         0  section                    0
        tee-os                        0         0  tee-os                     0
      @fdt-SEQ                        0         0  section                    0
  vbe-b                         1000000    39b200  section              1000000
    spl-b                       1000000    100000  fit                        0
      spl                       1001400     10c97  section                 1400
        section                 1001400     10c97  section                    0
          u-boot-spl-nodtb                  1a908  u-boot-spl-nodtb           0
          u-boot-spl-bss-pad                  1b0  u-boot-spl-bss-pad     1a908
      @fdt-SEQ                        0         0  section                    0
    u-boot-b                    1100000    29b200  fit                   100000
      spl                       1102400     10c97  section                 2400
        section                 1102400     10c97  section                    0
          u-boot-spl-nodtb                  1a908  u-boot-spl-nodtb           0
          u-boot-spl-bss-pad                  1b0  u-boot-spl-bss-pad     1a908
      u-boot                    1113200     e4250  section                13200
        u-boot-nodtb            1113200     e4250  u-boot-nodtb               0
      @atf-SEQ                        0         0  section                    0
        atf-bl31                      0         0  atf-bl31                   0
      @tee-SEQ                        0         0  section                    0
        tee-os                        0         0  tee-os                     0
      @fdt-SEQ                        0         0  section                    0
  vbe-recovery                  1800000    39b200  section              1800000
    spl-recovery                1800000    100000  fit                        0
      spl                       1801400     10c97  section                 1400
        section                 1801400     10c97  section                    0
          u-boot-spl-nodtb                  1a908  u-boot-spl-nodtb           0
          u-boot-spl-bss-pad                  1b0  u-boot-spl-bss-pad     1a908
      @fdt-SEQ                        0         0  section                    0
    u-boot-recovery             1900000    29b200  fit                   100000
      spl                       1902400     10c97  section                 2400
        section                 1902400     10c97  section                    0
          u-boot-spl-nodtb                  1a908  u-boot-spl-nodtb           0
          u-boot-spl-bss-pad                  1b0  u-boot-spl-bss-pad     1a908
      u-boot                    1913200     e4250  section                13200
        u-boot-nodtb            1913200     e4250  u-boot-nodtb               0
      @atf-SEQ                        0         0  section                    0
        atf-bl31                      0         0  atf-bl31                   0
      @tee-SEQ                        0         0  section                    0
        tee-os                        0         0  tee-os                     0
      @fdt-SEQ                        0         0  section                    0
  fdtmap                        1b9b200      2ecf  fdtmap               1b9b200

This series still bloblist reverts and changes, just so that the boar doesn't hang on boot. I have already sent a series to resolve this, but so far it has been rejected:

https://patchwork.ozlabs.org/project/uboot/list/?series=456263&state=*

This is (mostly) the final VBE series, but there are a few loose ends to tidy up:

- cache is disabled in SPL, which slows the boot a little
- pinctrl init needs to be tidied up to avoid warnings
- bloblist logic as above
- bloblist-relocation is partly in board-specific code, partly generic

Other things may become apparently after more usage / testing.

Changes in v4:
- Use FIT_ARCH instead of ARCH
- Use FIT_ARCH instead of ARCH
- Use FIT_ARCH instead of ARCH
- Use fit_template instead of common_part
- Put the fdtmap at the end of the image
- Update the comment at the end of the '#ifndef CONFIG_VPL' block
- Add a value for SPL_STACK_R_ADDR
- Drop SPL_PAD_TO value since the default is fine
- Drop ROCKCHIP_IODOMAIN since it is the default
- Add SPL_LIBCOMMON_SUPPORT and SPL_LIBGENERIC_SUPPORT
- Fix 'an' typo in commit subject
- Rebase to -next

Changes in v3:
- Add blank lines before the node
- Add a comment about the offsets
- Move template to the vpl file
- Add the BLOBLIST_RELOC condition as well

Changes in v2:
- Move VPL things into a separate file
- Move VPL things into a separate file
- Move VPL things into a separate file
- Mention RK3399 with respect to the memory limit
- Move VPL things into a separate file
- Only enable MMC when VPM is in use.
- Rewrite help for VPL_ROCKCHIP_COMMON_BOARD
- Skip spl-boot-order.c for VPL (rather than modifying it)
- Reword commit to mention comments from Jonas
- Rename to rk3399-generic-ddr3
- Update devicetree to match firefly-rk3399
- Use the firefly devicetree as the default for this board
- Move this patch to the end of the series
- Drop 0x8000 offset for SPI
- Add new patch with a bootmeth driver for abrec
- Split out the fixes for skip-at-start into a new patch
- Move this logic into board-specific code
- Move the actual relocation code to a previous board-specific patch

Simon Glass (25):
spl: Adjust xPL symbols
spl: Allow VBE to handle xPL size
vbe: Show the margin when using SPL_RELOC
rockchip: Allow RAM init to happen in SPL on rk3399
rockchip: dts: Add an fdtmap
rockchip: dts: Specify the phase in the image
rockchip: Provide a bootstd configuration
rockchip: Add SPL into the main FIT
rockchip: Add a template for SPL
rockchip: Add a VPL image
rockchip: Add TPL alternatives
rockchip: Update rk3399 bootph-tags for VPL
rockchip: Provide a VPL phase on rk3399
rockchip: Add symbols for spl_reloc
rockchip: rk3399: Adjust initial TPL-stack to match SPL
rockchip: Allow SPL to set up SDRAM
rockchip: Add a generic-ddr3 rk3399 board
rockchip: Add documentation for VBE
gitlab: Add a VBE board to the sjg lab
rockchip: Set the skip-at-start property correctly
vbe: Add a bootmeth driver for abrec
rockchip: Update binman image for new skip-at-start setup
bloblist: Temporary hacks to get VBE going
rockchip: Relocate bloblist at the end of the SPL phase
bloblist: Allow using a different bloblist address

 .gitlab-ci.yml                           |  20 ++-
 arch/arm/dts/rk3399-u-boot.dtsi          |  11 +-
 arch/arm/dts/rockchip-u-boot.dtsi        |  17 ++
 arch/arm/dts/rockchip-vpl-u-boot.dtsi    | 220 +++++++++++++++++++++++
 arch/arm/include/asm/spl.h               |   1 +
 arch/arm/lib/xferlist.c                  |  12 +-
 arch/arm/mach-rockchip/Kconfig           |  25 ++-
 arch/arm/mach-rockchip/Makefile          |  11 +-
 arch/arm/mach-rockchip/rk3399/Kconfig    |  14 +-
 arch/arm/mach-rockchip/spl.c             |  18 ++
 arch/arm/mach-rockchip/tpl.c             |  12 +-
 arch/arm/mach-rockchip/u-boot-tpl-v8.lds |  13 ++
 arch/arm/mach-rockchip/u-boot-vpl-v8.lds | 107 +++++++++++
 arch/arm/mach-rockchip/vpl.c             |  53 ++++++
 board/rockchip/evb_rk3399/MAINTAINERS    |   6 +
 boot/vbe_abrec.c                         |  99 ++++++++++
 cmd/vbe.c                                |   8 +-
 common/Kconfig                           |  20 +++
 common/bloblist.c                        | 127 +++++--------
 common/spl/Kconfig                       |   3 +-
 common/spl/spl.c                         |   2 +
 common/spl/spl_reloc.c                   |  14 +-
 configs/rk3399-generic-ddr3_defconfig    | 124 +++++++++++++
 doc/board/rockchip/rockchip.rst          |  13 ++
 drivers/ram/rockchip/sdram_rk3399.c      |   6 +-
 include/bloblist.h                       |  16 +-
 include/vbe.h                            |   3 +
 27 files changed, 852 insertions(+), 123 deletions(-)
 create mode 100644 arch/arm/dts/rockchip-vpl-u-boot.dtsi
 create mode 100644 arch/arm/mach-rockchip/u-boot-vpl-v8.lds
 create mode 100644 arch/arm/mach-rockchip/vpl.c
 create mode 100644 configs/rk3399-generic-ddr3_defconfig
Signature · 4 lines
2.34.1

base-commit: bab54f5942c428be698216224fd10b91d974d4da
branch: vbi4
#1 lore raw

PATCH v4 1/25 spl: Adjust xPL symbols

Update for the new xPL naming, which was missed in a previous patch which purported to do this.

---

(no changes since v1)

 common/spl/spl_reloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/spl/spl_reloc.c +1 -1
index 324b98eaf98..216c0f36623 100644
@@ -59,7 +59,7 @@ static int setup_layout(struct spl_image_info *image, ulong *addrp)
 	uint need_size = image->size + image->fdt_size;
 	margin = buf_size - need_size;
 	log_debug("spl_reloc %s->%s: margin%s%lx limit %lx fdt_size %lx base %lx avail %x image %x fdt %lx need %x\n",
-		  spl_phase_name(spl_phase()), spl_phase_name(spl_phase() + 1),
+		  xpl_name(xpl_phase()), xpl_name(xpl_phase() + 1),
 		  margin >= 0 ? " " : " -", abs(margin), limit, fdt_size, base,
 		  buf_size, image->size, image->fdt_size, need_size);
 	if (margin < 0) {
Signature · 1 line
2.34.1
#2 lore raw

PATCH v4 2/25 spl: Allow VBE to handle xPL size

In reply to Simon Glass

When VBE is in use, the size of each phase is obtained by reading it from a FIT. Avoid using binman symbols unless necessary, i.e. in TPL.

---

(no changes since v1)

 common/spl/spl.c | 2 ++
 1 file changed, 2 insertions(+)
common/spl/spl.c +2 -0
index 76fd56dfe4b..42053b4afa0 100644
@@ -200,6 +200,8 @@ ulong spl_get_image_size(void)
 #ifdef CONFIG_VPL
 	if (xpl_next_phase() == PHASE_VPL)
 		return binman_sym(ulong, u_boot_vpl_any, size);
+
+	return 0;	/* VBE handles this */
 #endif
 	return xpl_next_phase() == PHASE_SPL ?
 		binman_sym(ulong, u_boot_spl_any, size) :
Signature · 1 line
2.34.1
#3 lore raw

PATCH v4 3/25 vbe: Show the margin when using SPL_RELOC

In reply to Simon Glass

Collect information about the memory-margin in each phase which uses this feature. Update the 'vbe state' command to show it.

---

(no changes since v1)

 cmd/vbe.c              |  8 ++++++--
 common/spl/spl_reloc.c | 12 ++++++++++++
 include/vbe.h          |  3 +++
 3 files changed, 21 insertions(+), 2 deletions(-)
cmd/vbe.c +6 -2
index 186f6e6860d..02d224ad286 100644
@@ -92,9 +92,13 @@ static int do_vbe_state(struct cmd_tbl *cmdtp, int flag, int argc,
 
 	printf("Phases:");
 	for (i = PHASE_NONE; i < PHASE_COUNT; i++) {
-		if (handoff->phases & (1 << i))
-			printf(" %s", xpl_name(i));
+		if (handoff->phases & (1 << i)) {
+			int margin = handoff->reloc_margin[i];
 
+			printf(" %s", xpl_name(i));
+			if (margin)
+				printf(" (margin %x) ", margin);
+		}
 	}
 	if (!handoff->phases)
 		printf(" (none)");
common/spl/spl_reloc.c +12 -0
index 216c0f36623..6bfc75bc484 100644
@@ -4,11 +4,13 @@
  * Written by Simon Glass <[email protected]>
  */
 
+#include <bloblist.h>
 #include <gzip.h>
 #include <image.h>
 #include <log.h>
 #include <mapmem.h>
 #include <spl.h>
+#include <vbe.h>
 #include <asm/global_data.h>
 #include <asm/io.h>
 #include <asm/sections.h>
@@ -58,6 +60,16 @@ static int setup_layout(struct spl_image_info *image, ulong *addrp)
 	buf_size = rcode_base - base;
 	uint need_size = image->size + image->fdt_size;
 	margin = buf_size - need_size;
+
+	if (CONFIG_IS_ENABLED(BLOBLIST)) {
+		struct vbe_handoff *handoff;
+
+		handoff = bloblist_find(BLOBLISTT_VBE,
+					sizeof(struct vbe_handoff));
+		if (handoff)
+			handoff->reloc_margin[xpl_phase()] = margin;
+	}
+
 	log_debug("spl_reloc %s->%s: margin%s%lx limit %lx fdt_size %lx base %lx avail %x image %x fdt %lx need %x\n",
 		  xpl_name(xpl_phase()), xpl_name(xpl_phase() + 1),
 		  margin >= 0 ? " " : " -", abs(margin), limit, fdt_size, base,
include/vbe.h +3 -0
index 61bfa0e557d..84a996cdf7f 100644
@@ -11,6 +11,7 @@
 #define __VBE_H
 
 #include <linux/types.h>
+#include <spl.h>
 
 /**
  * enum vbe_phase_t - current phase of VBE
@@ -47,12 +48,14 @@ enum vbe_pick_t {
  * @size: Size of the area containing the FIT
  * @phases: Indicates which phases used the VBE bootmeth (1 << PHASE_...)
  * @pick: Indicates which firmware pick was used (enum vbe_pick_t)
+ * @reloc_margin: Indicates the number of bytes of margin coming into this phase
  */
 struct vbe_handoff {
 	ulong offset;
 	ulong size;
 	u8 phases;
 	u8 pick;
+	int reloc_margin[PHASE_COUNT];
 };
 
 /**
Signature · 1 line
2.34.1
#4 lore raw

PATCH v4 4/25 rockchip: Allow RAM init to happen in SPL on rk3399

In reply to Simon Glass

TPL runs before VPL. The earliest updatable phase with VBE is SPL. We want to be able to update the RAM-init code in the field.

So when VPL is being used, init the RAM later, in SPL.

---

(no changes since v1)

 drivers/ram/rockchip/sdram_rk3399.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/ram/rockchip/sdram_rk3399.c +4 -2
index 6fa8f268770..9ac16dfdc71 100644
@@ -194,6 +194,7 @@ struct io_setting {
 static bool phase_sdram_init(void)
 {
 	return xpl_phase() == PHASE_TPL ||
+		(IS_ENABLED(CONFIG_VPL) && xpl_phase() == PHASE_SPL) ||
 		(!IS_ENABLED(CONFIG_TPL) &&
 		 !IS_ENABLED(CONFIG_ROCKCHIP_EXTERNAL_TPL) &&
 		 !not_xpl());
@@ -3195,8 +3196,9 @@ U_BOOT_DRIVER(dmc_rk3399) = {
 	.of_to_plat = rk3399_dmc_of_to_plat,
 	.probe = rk3399_dmc_probe,
 	.priv_auto	= sizeof(struct dram_info),
-#if defined(CONFIG_TPL_BUILD) || \
-	(!defined(CONFIG_TPL) && defined(CONFIG_XPL_BUILD))
+#if defined(CONFIG_VPL) && defined(CONFIG_SPL_BUILD) || \
+	!defined(CONFIG_VPL) && defined(CONFIG_TPL_BUILD) || \
+	!defined(CONFIG_TPL) && defined(CONFIG_SPL_BUILD)
 	.plat_auto	= sizeof(struct rockchip_dmc_plat),
 #endif
 };
Signature · 1 line
2.34.1
#5 lore raw

PATCH v4 5/25 rockchip: dts: Add an fdtmap

In reply to Simon Glass

Add an fdtmap so it is possible to look at the image with 'binman ls'.

---

(no changes since v3)

Changes in v3:
- Add blank lines before the node

 arch/arm/dts/rockchip-u-boot.dtsi | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm/dts/rockchip-u-boot.dtsi +7 -0
index cc2feed6464..8a37a9d8e7f 100644
@@ -192,6 +192,10 @@
 #endif
 			offset = <CONFIG_SPL_PAD_TO>;
 		};
+#endif
+
+		fdtmap {
+		};
 	};
 
 #ifdef CONFIG_ROCKCHIP_SPI_IMAGE
@@ -224,6 +228,9 @@
 			/* Sync with u-boot,spl-payload-offset if present */
 			offset = <CONFIG_SYS_SPI_U_BOOT_OFFS>;
 		};
+
+		fdtmap {
+		};
 	};
 #endif /* CONFIG_ROCKCHIP_SPI_IMAGE */
 };
Signature · 1 line
2.34.1
#6 lore raw

Re: [PATCH v4 05/25] rockchip: dts: Add an fdtmap

Hi Simon,

Quoted 19 lines · Simon Glass

Add an fdtmap so it is possible to look at the image with 'binman ls'.

---

(no changes since v3)

Changes in v3:
- Add blank lines before the node

 arch/arm/dts/rockchip-u-boot.dtsi | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm/dts/rockchip-u-boot.dtsi +0 -0
index cc2feed6464..8a37a9d8e7f 100644

arch/arm/dts/rockchip-u-boot.dtsi line 195

Quoted 4 lines
arch/arm/dts/rockchip-u-boot.dtsi +1 -0
@@ -192,6 +192,10 @@
 #endif
 			offset = <CONFIG_SPL_PAD_TO>;
 		};
+#endif

This should not be added here as it breaks the build. It is reverted in a later patch in this series so your CI has not noticed the build error.

Regards,
Jonas

Quoted 16 lines
arch/arm/dts/rockchip-u-boot.dtsi +6 -0
+
+		fdtmap {
+		};
 	};
 
 #ifdef CONFIG_ROCKCHIP_SPI_IMAGE
@@ -224,6 +228,9 @@
 			/* Sync with u-boot,spl-payload-offset if present */
 			offset = <CONFIG_SYS_SPI_U_BOOT_OFFS>;
 		};
+
+		fdtmap {
+		};
 	};
 #endif /* CONFIG_ROCKCHIP_SPI_IMAGE */
 };
#7 lore raw

PATCH v4 6/25 rockchip: dts: Specify the phase in the image

In reply to Simon Glass

Add 'u-boot' as the phase for the images intended for use with U-Boot proper.

---

(no changes since v1)

 arch/arm/dts/rockchip-u-boot.dtsi | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm/dts/rockchip-u-boot.dtsi +4 -0
index 8a37a9d8e7f..4c882c4a450 100644
@@ -64,6 +64,7 @@
 				compression = FIT_UBOOT_COMP;
 				load = <CONFIG_TEXT_BASE>;
 				entry = <CONFIG_TEXT_BASE>;
+				phase = "u-boot";
 				u-boot-nodtb {
 					compress = FIT_UBOOT_COMP;
 				};
@@ -82,6 +83,7 @@
 				arch = FIT_ARCH;
 				os = "arm-trusted-firmware";
 				compression = "none";
+				phase = "u-boot";
 				fit,load;
 				fit,entry;
 				fit,data;
@@ -101,6 +103,7 @@
 				arch = FIT_ARCH;
 				os = "tee";
 				compression = "none";
+				phase = "u-boot";
 				fit,load;
 				fit,entry;
 				fit,data;
@@ -123,6 +126,7 @@
 				compression = "none";
 				load = <(CFG_SYS_SDRAM_BASE + 0x8400000)>;
 				entry = <(CFG_SYS_SDRAM_BASE + 0x8400000)>;
+				phase = "u-boot";
 
 				tee-os {
 				};
Signature · 1 line
2.34.1
#8 lore raw

PATCH v4 7/25 rockchip: Provide a bootstd configuration

In reply to Simon Glass

Add bootstd information for VBE. Put it in a separate file to avoid cluttering the main one.

---

(no changes since v3)

Changes in v3:
- Add a comment about the offsets

Changes in v2:
- Move VPL things into a separate file

 arch/arm/dts/rockchip-u-boot.dtsi     |  4 +++
 arch/arm/dts/rockchip-vpl-u-boot.dtsi | 40 +++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)
 create mode 100644 arch/arm/dts/rockchip-vpl-u-boot.dtsi
arch/arm/dts/rockchip-u-boot.dtsi +4 -0
index 4c882c4a450..18669f73402 100644
@@ -239,3 +239,7 @@
 #endif /* CONFIG_ROCKCHIP_SPI_IMAGE */
 };
 #endif /* CONFIG_SPL */
+
+#ifdef CONFIG_VPL
+#include "rockchip-vpl-u-boot.dtsi"
+#endif
arch/arm/dts/rockchip-vpl-u-boot.dtsi new file +40 -0
new file mode 100644
index 00000000000..475dbc53796
@@ -0,0 +1,40 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Jagan Teki <[email protected]>
+ */
+
+/ {
+	bootstd {
+		bootph-verify;
+		compatible = "u-boot,boot-std";
+
+		/*
+		 * This is used for the VBE OS-request tests. A FAT filesystem
+		 * created in a partition with the VBE information appearing
+		 * before the partition starts.
+		 *
+		 * Offsets are aligned to the media block-size, typically 0x200
+		 *
+		 * The start of the VBE area is set at 8MB, adjusted for the
+		 * skip-at-start offset. Before that is a block containing the
+		 * version information and before that is the state. These could
+		 * be stored in a different storage device if available, but so
+		 * far VBE only supports MMC.
+		 *
+		 * The total area size is 8MB which should be enough for a FIT
+		 * containing U-Boot and a number of devicetrees.
+		 */
+		firmware0 {
+			bootph-verify;
+			compatible = "fwupd,vbe-abrec";
+			storage = "mmc0";
+			skip-offset = <0x8000>;
+			area-start = <0x7f8000>;
+			area-size = <0x800000>;
+			state-offset = <(0x7f8000 - 0x400)>;
+			state-size = <0x40>;
+			version-offset = <(0x7f8000 - 0x200)>;
+			version-size = <0x100>;
+		};
+	};
+};
Signature · 1 line
2.34.1
#9 lore raw

PATCH v4 8/25 rockchip: Add SPL into the main FIT

In reply to Simon Glass

VBE may want to load the SPL image from the same FIT as contains U-Boot, if there is enough memory, so add it.

---

Changes in v4:
- Use FIT_ARCH instead of ARCH

Changes in v2:
- Move VPL things into a separate file

 arch/arm/dts/rockchip-vpl-u-boot.dtsi | 29 +++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
arch/arm/dts/rockchip-vpl-u-boot.dtsi +29 -0
index 475dbc53796..dc1664d7b2d 100644
@@ -38,3 +38,32 @@
 		};
 	};
 };
+
+&binman {
+	template-1 {
+		images {
+			spl {
+				description = "U-Boot SPL";
+				type = "firmware";
+				os = "u-boot";
+				arch = FIT_ARCH;
+				compression = "lz4";
+				load = <CONFIG_SPL_TEXT_BASE>;
+				entry = <CONFIG_SPL_TEXT_BASE>;
+				phase = "spl";
+				section {
+					compress = "lz4";
+					u-boot-spl-nodtb {
+					};
+					u-boot-spl-bss-pad {
+					};
+				};
+			};
+		};
+		configurations {
+			@config-SEQ {
+				fit,firmware = "atf-1", "u-boot", "spl";
+			};
+		};
+	};
+};
Signature · 1 line
2.34.1
#10 lore raw

PATCH v4 9/25 rockchip: Add a template for SPL

In reply to Simon Glass

The SPL phase has a single SPL binary plus a devicetree for each board we need to support.

The devicetree is run through fdtgrep to remove unwanted nodes and properties and reduce its size.

While it would be nicer to just have a single FIT holding both the SPL and U-Boot images, there may not be enough SRAM to support that. So we end up providing this special image just for SPL.

---

Changes in v4:
- Use FIT_ARCH instead of ARCH

Changes in v3:
- Move template to the vpl file

 arch/arm/dts/rockchip-vpl-u-boot.dtsi | 43 +++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
arch/arm/dts/rockchip-vpl-u-boot.dtsi +43 -0
index dc1664d7b2d..9604972543b 100644
@@ -66,4 +66,47 @@
 			};
 		};
 	};
+
+	spl_template: template-2 {
+		type = "fit";
+		description = "FIT image for U-Boot SPL";
+		#address-cells = <1>;
+		fit,fdt-list = "of-list";
+		fit,align = <512>;
+		fit,external-offset = <0>;
+		images {
+			spl {
+				description = "U-Boot SPL";
+				type = "firmware";
+				os = "u-boot";
+				arch = FIT_ARCH;
+				compression = "lz4";
+				load = <CONFIG_SPL_TEXT_BASE>;
+				entry = <CONFIG_SPL_TEXT_BASE>;
+				section {
+					compress = "lz4";
+					u-boot-spl-nodtb {
+					};
+					u-boot-spl-bss-pad {
+					};
+				};
+			};
+			@fdt-SEQ {
+				description = "fdt-NAME";
+				compression = "none";
+				type = "flat_dt";
+				fit,fdt-phase = "spl";
+			};
+		};
+		configurations {
+			default = "@config-DEFAULT-SEQ";
+			@config-SEQ {
+				description = "NAME.dtb";
+				fdt = "fdt-SEQ";
+				fit,firmware = "spl";
+				fit,loadables;
+				fit,compatible;
+			};
+		};
+	};
 };
Signature · 1 line
2.34.1
#11 lore raw

PATCH v4 10/25 rockchip: Add a VPL image

In reply to Simon Glass

The VPL image is immutable and has a single VPL binary plus a devicetree for each board we need to support.

The devicetree is run through fdtgrep to remove unwanted nodes and properties and reduce its size.

---

Changes in v4:
- Use FIT_ARCH instead of ARCH
- Use fit_template instead of common_part

Changes in v2:
- Move VPL things into a separate file

 arch/arm/dts/rockchip-vpl-u-boot.dtsi | 91 +++++++++++++++++++++++++++
 1 file changed, 91 insertions(+)
arch/arm/dts/rockchip-vpl-u-boot.dtsi +91 -0
index 9604972543b..0d767113408 100644
@@ -109,4 +109,95 @@
 			};
 		};
 	};
+
+	simple-bin {
+		vpl {
+			type = "fit";
+			offset = <(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 0x200 + 0x8000)>;
+			description = "FIT image for U-Boot TPL";
+			#address-cells = <1>;
+			fit,fdt-list = "of-list";
+			fit,align = <512>;
+			fit,external-offset = <0>;
+			images {
+				image-vpl {
+					description = "U-Boot VPL";
+					type = "firmware";
+					os = "u-boot";
+					arch = FIT_ARCH;
+					compression = "lz4";
+					load = <CONFIG_VPL_TEXT_BASE>;
+					entry = <CONFIG_VPL_TEXT_BASE>;
+					section {
+						compress = "lz4";
+						u-boot-vpl-nodtb {
+							symbols-base = <0>;
+						};
+						u-boot-vpl-bss-pad {
+						};
+					};
+				};
+				@fdt-SEQ {
+					description = "fdt-NAME";
+					compression = "none";
+					type = "flat_dt";
+					fit,fdt-phase = "vpl";
+				};
+			};
+			configurations {
+				default = "@config-DEFAULT-SEQ";
+				@config-SEQ {
+					description = "NAME.dtb";
+					fdt = "fdt-SEQ";
+					fit,firmware = "image-vpl";
+					fit,loadables;
+					fit,compatible;
+				};
+			};
+		};
+# ifdef CONFIG_BOOTMETH_VBE_ABREC
+		vbe-a {
+			type = "section";
+			offset = <(CONFIG_SPL_PAD_TO + 0x8000)>;
+			spl-a {
+				insert-template = <&spl_template>;
+				size = <0x100000>;
+			};
+
+			u-boot-a {
+				insert-template = <&fit_template>;
+			};
+		};
+		vbe-b {
+			type = "section";
+			offset = <0x1000000>;
+			spl-b {
+				insert-template = <&spl_template>;
+				size = <0x100000>;
+			};
+
+			u-boot-b {
+				insert-template = <&fit_template>;
+			};
+		};
+		vbe-recovery {
+			type = "section";
+			offset = <0x1800000>;
+			spl-recovery {
+				insert-template = <&spl_template>;
+				size = <0x100000>;
+			};
+
+			u-boot-recovery {
+				insert-template = <&fit_template>;
+			};
+		};
+# else /* CONFIG_BOOTMETH_VBE_SIMPLE */
+		vbe {
+			type = "fit";
+			offset = <(CONFIG_SPL_PAD_TO + 0x8000)>;
+			insert-template = <&fit_template>;
+		};
+# endif /* VBE method */
+	};
 };
Signature · 1 line
2.34.1
#12 lore raw

PATCH v4 11/25 rockchip: Add TPL alternatives

In reply to Simon Glass

The TPL image must be built for each board we need to support. It is the only part of the image which is board-specific.

This helps to save space and reduce the size of TPL, so that it can fit within the internal 192K IRAM of the RK3399 SoC.

As with other phases, the TPL devicetree is run through fdtgrep to remove unwanted nodes and properties and reduce its size.

Update the fdtmap so it is at the end of the image, since templates are added after existing nodes.

---

Changes in v4:
- Put the fdtmap at the end of the image
- Update the comment at the end of the '#ifndef CONFIG_VPL' block

Changes in v2:
- Mention RK3399 with respect to the memory limit
- Move VPL things into a separate file

 arch/arm/dts/rockchip-u-boot.dtsi     |  3 ++-
 arch/arm/dts/rockchip-vpl-u-boot.dtsi | 18 ++++++++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)
arch/arm/dts/rockchip-u-boot.dtsi +2 -1
index 18669f73402..905706c68e7 100644
@@ -171,6 +171,7 @@
 		filename = "u-boot-rockchip.bin";
 		pad-byte = <0xff>;
 
+#ifndef CONFIG_VPL
 		mkimage {
 			filename = "idbloader.img";
 			args = "-n", CONFIG_SYS_SOC, "-T", "rksd";
@@ -196,10 +197,10 @@
 #endif
 			offset = <CONFIG_SPL_PAD_TO>;
 		};
-#endif
 
 		fdtmap {
 		};
+#endif /* !VPL */
 	};
 
 #ifdef CONFIG_ROCKCHIP_SPI_IMAGE
arch/arm/dts/rockchip-vpl-u-boot.dtsi +18 -0
index 0d767113408..c5d55b87164 100644
@@ -111,6 +111,22 @@
 	};
 
 	simple-bin {
+		alternates-fdt {
+			fdt-list-dir = "dts/upstream/src/arm64/rockchip";
+			filename-pattern = "alt-NAME.bin";
+			fdt-phase = "tpl";
+
+			mkimage {
+				filename = "idbloader.img";
+				args = "-n", CONFIG_SYS_SOC, "-T", "rksd";
+				multiple-data-files;
+
+				u-boot-tpl {
+					symbols-base = <0>;
+				};
+			};
+		};
+
 		vpl {
 			type = "fit";
 			offset = <(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 0x200 + 0x8000)>;
@@ -199,5 +215,7 @@
 			insert-template = <&fit_template>;
 		};
 # endif /* VBE method */
+		fdtmap {
+		};
 	};
 };
Signature · 1 line
2.34.1
#13 lore raw

Re: [PATCH v4 11/25] rockchip: Add TPL alternatives

Hi Simon,

Quoted 2 lines · Simon Glass

The TPL image must be built for each board we need to support. It is the only part of the image which is board-specific.

This is most likely only a must for VBE/VPL use, make it clear that these changes are related to VBE/VPL in the commit message.

Quoted 38 lines

This helps to save space and reduce the size of TPL, so that it can fit within the internal 192K IRAM of the RK3399 SoC.

As with other phases, the TPL devicetree is run through fdtgrep to remove unwanted nodes and properties and reduce its size.

Update the fdtmap so it is at the end of the image, since templates are added after existing nodes.

---

Changes in v4:
- Put the fdtmap at the end of the image
- Update the comment at the end of the '#ifndef CONFIG_VPL' block

Changes in v2:
- Mention RK3399 with respect to the memory limit
- Move VPL things into a separate file

 arch/arm/dts/rockchip-u-boot.dtsi     |  3 ++-
 arch/arm/dts/rockchip-vpl-u-boot.dtsi | 18 ++++++++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)
arch/arm/dts/rockchip-u-boot.dtsi +1 -0
index 18669f73402..905706c68e7 100644
@@ -171,6 +171,7 @@
 		filename = "u-boot-rockchip.bin";
 		pad-byte = <0xff>;
 
+#ifndef CONFIG_VPL
 		mkimage {
 			filename = "idbloader.img";
 			args = "-n", CONFIG_SYS_SOC, "-T", "rksd";

arch/arm/dts/rockchip-u-boot.dtsi line 199

Quoted 4 lines
arch/arm/dts/rockchip-u-boot.dtsi +0 -1
@@ -196,10 +197,10 @@
 #endif
 			offset = <CONFIG_SPL_PAD_TO>;
 		};
-#endif

This was wrongly added in a prior patch.

arch/arm/dts/rockchip-u-boot.dtsi line 203

Quoted 4 lines
arch/arm/dts/rockchip-u-boot.dtsi +1 -0
 		fdtmap {
 		};
+#endif /* !VPL */

Since you are replacing everything inside simple-bin I think it would be better to wrap the entire node and re-declare your own vpl/vbe variant inside rockchip-vpl-u-boot.dtsi.

Regards,
Jonas

Quoted 38 lines
arch/arm/dts/rockchip-u-boot.dtsi +0 -0
 	};
 
 #ifdef CONFIG_ROCKCHIP_SPI_IMAGE
arch/arm/dts/rockchip-vpl-u-boot.dtsi +18 -0
index 0d767113408..c5d55b87164 100644
@@ -111,6 +111,22 @@
 	};
 
 	simple-bin {
+		alternates-fdt {
+			fdt-list-dir = "dts/upstream/src/arm64/rockchip";
+			filename-pattern = "alt-NAME.bin";
+			fdt-phase = "tpl";
+
+			mkimage {
+				filename = "idbloader.img";
+				args = "-n", CONFIG_SYS_SOC, "-T", "rksd";
+				multiple-data-files;
+
+				u-boot-tpl {
+					symbols-base = <0>;
+				};
+			};
+		};
+
 		vpl {
 			type = "fit";
 			offset = <(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 0x200 + 0x8000)>;
@@ -199,5 +215,7 @@
 			insert-template = <&fit_template>;
 		};
 # endif /* VBE method */
+		fdtmap {
+		};
 	};
 };
#14 lore raw

PATCH v4 12/25 rockchip: Update rk3399 bootph-tags for VPL

In reply to Simon Glass

When VPL is in use, memory init happens in SPL, so there is no need to include the DMC device before that. Adjust the tags to save space.

---

(no changes since v2)

Changes in v2:
- Only enable MMC when VPM is in use.

 arch/arm/dts/rk3399-u-boot.dtsi | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
arch/arm/dts/rk3399-u-boot.dtsi +10 -1
index 587eef9504e..c0e51a9626c 100644
@@ -46,7 +46,12 @@
 	       0x0 0xffa88800 0x0 0x1800
 	       0x0 0xffa8a000 0x0 0x2000
 	       0x0 0xffa8c000 0x0 0x1000>;
-	bootph-all;
+#ifdef CONFIG_VPL
+		bootph-pre-ram;
+		bootph-some-ram;
+#else
+		bootph-all;
+#endif
 	status = "okay";
 };
 
@@ -93,6 +98,10 @@
 };
 
 &sdmmc {
+#ifdef CONFIG_VPL
+	bootph-pre-sram;
+	bootph-verify;
+#endif
 	bootph-pre-ram;
 	bootph-some-ram;
 
Signature · 1 line
2.34.1
#15 lore raw

PATCH v4 13/25 rockchip: Provide a VPL phase on rk3399

In reply to Simon Glass

Add support for this new phase, which runs after TPL. It determines the state of the machine, then selects which SPL image to use. SDRAM init is then done in SPL, so that it is updatable.

---

Changes in v4:
- Add a value for SPL_STACK_R_ADDR

Changes in v2:
- Rewrite help for VPL_ROCKCHIP_COMMON_BOARD
- Skip spl-boot-order.c for VPL (rather than modifying it)

 arch/arm/include/asm/spl.h               |   1 +
 arch/arm/mach-rockchip/Kconfig           |  25 +++++-
 arch/arm/mach-rockchip/Makefile          |  11 ++-
 arch/arm/mach-rockchip/rk3399/Kconfig    |  12 +++
 arch/arm/mach-rockchip/spl.c             |   3 +
 arch/arm/mach-rockchip/tpl.c             |   2 +-
 arch/arm/mach-rockchip/u-boot-vpl-v8.lds | 107 +++++++++++++++++++++++
 arch/arm/mach-rockchip/vpl.c             |  53 +++++++++++
 common/spl/Kconfig                       |   1 +
 9 files changed, 208 insertions(+), 7 deletions(-)
 create mode 100644 arch/arm/mach-rockchip/u-boot-vpl-v8.lds
 create mode 100644 arch/arm/mach-rockchip/vpl.c
arch/arm/include/asm/spl.h +1 -0
index ee79a19c05c..62844d64cab 100644
@@ -30,6 +30,7 @@ enum {
 	BOOT_DEVICE_XIP,
 	BOOT_DEVICE_BOOTROM,
 	BOOT_DEVICE_SMH,
+	BOOT_DEVICE_VBE,
 	BOOT_DEVICE_NONE
 };
 #endif
arch/arm/mach-rockchip/Kconfig +21 -4
index 9210877a4a4..96f73b42a8c 100644
@@ -259,13 +259,15 @@ config ROCKCHIP_RK3399
 	select SPL_ATF
 	select SPL_BOARD_INIT if SPL
 	select SPL_LOAD_FIT
-	select SPL_CLK if SPL
+	select SPL_CLK if SPL && !VPL
 	select SPL_PINCTRL if SPL
 	select SPL_RAM if SPL
 	select SPL_REGMAP if SPL
 	select SPL_SYSCON if SPL
 	select TPL_HAVE_INIT_STACK if TPL
-	select SPL_SEPARATE_BSS
+	select VPL_HAVE_INIT_STACK if VPL
+	select SPL_SEPARATE_BSS if !VPL
+	select SPL_RAW_IMAGE_SUPPORT if VPL
 	select CLK
 	select FIT
 	select PINCTRL
@@ -275,6 +277,7 @@ config ROCKCHIP_RK3399
 	select DM_PMIC
 	select DM_REGULATOR_FIXED
 	select BOARD_LATE_INIT
+	select SUPPORT_VPL
 	imply ARMV8_CRYPTO
 	imply ARMV8_SET_SMPEN
 	imply BOOTSTD_FULL
@@ -304,13 +307,14 @@ config ROCKCHIP_RK3399
 	imply TPL_LIBCOMMON_SUPPORT
 	imply TPL_LIBGENERIC_SUPPORT
 	imply TPL_OF_CONTROL
-	imply TPL_RAM
+	imply TPL_RAM if !VPL
 	imply TPL_REGMAP
 	imply TPL_ROCKCHIP_COMMON_BOARD
 	imply TPL_SERIAL
 	imply TPL_SYS_MALLOC_SIMPLE
 	imply TPL_SYSCON
 	imply TPL_TINY_MEMSET
+	imply TPL_DM_MMC if VPL
 	help
 	  The Rockchip RK3399 is a ARM-based SoC with a dual-core Cortex-A72
 	  and quad-core Cortex-A53.
@@ -569,7 +573,7 @@ config SPL_ROCKCHIP_BACK_TO_BROM
 
 config TPL_ROCKCHIP_BACK_TO_BROM
 	bool "TPL returns to bootrom"
-	default y
+	default y if !VPL
 	select ROCKCHIP_BROM_HELPER if !ROCKCHIP_RK3066
 	select TPL_BOOTROM_SUPPORT
 	depends on TPL
@@ -609,6 +613,16 @@ config ROCKCHIP_EXTERNAL_TPL
 	  Enable this option and build with ROCKCHIP_TPL=/path/to/ddr.bin to
 	  include the external TPL in the image built by binman.
 
+config VPL_ROCKCHIP_COMMON_BOARD
+	bool "Rockchip VPL common board file"
+	depends on VPL
+	default y
+	help
+	  Enable the VPL phase for rockchip, which selects which SPL/U-Boot
+	  will be used on each boot. With this flow, used by Verified Boot for
+	  Embedded (VBE), TPL is loaded by the boot ROM. Then TPL loads VPL,
+	  VPL loads SPL and SPL loads U-Boot.
+
 config ROCKCHIP_BOOT_MODE_REG
 	hex "Rockchip boot mode flag register address"
 	help
@@ -700,6 +714,9 @@ config TPL_ROCKCHIP_EARLYRETURN_TO_BROM
 config SPL_MMC
 	default y if !SPL_ROCKCHIP_BACK_TO_BROM
 
+config TPL_MMC
+	default y if !TPL_ROCKCHIP_BACK_TO_BROM
+
 config ROCKCHIP_SPI_IMAGE
 	bool "Build a SPI image for rockchip"
 	help
arch/arm/mach-rockchip/Makefile +9 -2
index ae15a9f8a2d..6cf60bc911c 100644
@@ -8,11 +8,16 @@
 # inaccessible/protected memory (and the bootrom-helper assumes that
 # the stack-pointer is valid before switching to the U-Boot stack).
 obj-spl-$(CONFIG_ROCKCHIP_BROM_HELPER) += bootrom.o
-obj-spl-$(CONFIG_SPL_ROCKCHIP_COMMON_BOARD) += spl.o spl-boot-order.o spl_common.o
+obj-spl-$(CONFIG_SPL_ROCKCHIP_COMMON_BOARD) += spl.o spl_common.o
+ifndef CONFIG_VPL
+obj-spl-$(CONFIG_SPL_ROCKCHIP_COMMON_BOARD) += spl-boot-order.o
+endif
 obj-tpl-$(CONFIG_ROCKCHIP_BROM_HELPER) += bootrom.o
 obj-tpl-$(CONFIG_TPL_ROCKCHIP_COMMON_BOARD) += tpl.o spl_common.o
 obj-tpl-$(CONFIG_ROCKCHIP_PX30) += px30-board-tpl.o
 
+obj-vpl-$(CONFIG_VPL_ROCKCHIP_COMMON_BOARD) += vpl.o
+
 obj-spl-$(CONFIG_ROCKCHIP_RK3036) += rk3036-board-spl.o
 
 ifeq ($(CONFIG_XPL_BUILD)$(CONFIG_TPL_BUILD),)
@@ -49,9 +54,11 @@ obj-$(CONFIG_ROCKCHIP_RK3588) += rk3588/
 obj-$(CONFIG_ROCKCHIP_RV1108) += rv1108/
 obj-$(CONFIG_ROCKCHIP_RV1126) += rv1126/
 
-# Clear out SPL objects, in case this is a TPL build
+# Clear out SPL objects, in case this is a TPL or VPL build
 obj-spl-$(CONFIG_TPL_BUILD) =
+obj-spl-$(CONFIG_VPL_BUILD) =
 
 # Now add SPL/TPL objects back into the main build
 obj-$(CONFIG_XPL_BUILD) += $(obj-spl-y)
 obj-$(CONFIG_TPL_BUILD) += $(obj-tpl-y)
+obj-$(CONFIG_VPL_BUILD) += $(obj-vpl-y)
arch/arm/mach-rockchip/rk3399/Kconfig +12 -0
index 5c21b08a5ae..7b2d47fcb49 100644
@@ -150,6 +150,18 @@ config TPL_STACK
 config TPL_TEXT_BASE
         default 0xff8c2000
 
+config VPL_STACK
+        default 0xff8eff00
+
+config VPL_TEXT_BASE
+        default 0xff8c2000
+
+config VPL_LDSCRIPT
+	default "arch/arm/mach-rockchip/u-boot-vpl-v8.lds"
+
+config SPL_STACK_R_ADDR
+	default 0x04000000 if !SPL_SHARES_INIT_SP_ADDR
+
 if BOOTCOUNT_LIMIT
 
 config BOOTCOUNT_BOOTLIMIT
arch/arm/mach-rockchip/spl.c +3 -0
index f4d29bbdd17..305373a161c 100644
@@ -61,6 +61,9 @@ u32 spl_boot_device(void)
 {
 	u32 boot_device = BOOT_DEVICE_MMC1;
 
+	if (IS_ENABLED(CONFIG_VPL))
+		return BOOT_DEVICE_VBE;
+
 #if defined(CONFIG_TARGET_CHROMEBOOK_JERRY) || \
 		defined(CONFIG_TARGET_CHROMEBIT_MICKEY) || \
 		defined(CONFIG_TARGET_CHROMEBOOK_MINNIE) || \
arch/arm/mach-rockchip/tpl.c +1 -1
index 6b880f19f84..cc794a7dca2 100644
@@ -84,5 +84,5 @@ int board_return_to_bootrom(struct spl_image_info *spl_image,
 
 u32 spl_boot_device(void)
 {
-	return BOOT_DEVICE_BOOTROM;
+	return IS_ENABLED(CONFIG_VPL) ? BOOT_DEVICE_VBE : BOOT_DEVICE_BOOTROM;
 }
arch/arm/mach-rockchip/u-boot-vpl-v8.lds new file +107 -0

107 lines not on this page · raw message

arch/arm/mach-rockchip/vpl.c new file +53 -0

53 lines not on this page · raw message

common/spl/Kconfig +1 -0
index a84a0f83924..fb6c90733ee 100644
@@ -582,6 +582,7 @@ config SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR
 	default 0x200 if ARCH_SOCFPGA || ARCH_AT91
 	default 0x300 if ARCH_ZYNQ || ARCH_KEYSTONE || OMAP34XX || \
 		         OMAP54XX || AM33XX || AM43XX || ARCH_K3
+	default 0x800 if ARCH_ROCKCHIP && VPL
 	default 0x4000 if ARCH_ROCKCHIP
 	default 0x822 if TARGET_SIFIVE_UNLEASHED || TARGET_SIFIVE_UNMATCHED
 	help
Signature · 1 line
2.34.1
#16 lore raw

Re: [PATCH v4 13/25] rockchip: Provide a VPL phase on rk3399

Hi Simon,

Quoted 2 lines · Simon Glass

Add support for this new phase, which runs after TPL. It determines the state of the machine, then selects which SPL image to use.

Please mention that this new VPL phase is related to VBE.

Quoted 2 lines

SDRAM init is
then done in SPL, so that it is updatable.

DRAM init currently done in TPL is also updatable, please add more context to what you mean by this.

Quoted 59 lines

---

Changes in v4:
- Add a value for SPL_STACK_R_ADDR

Changes in v2:
- Rewrite help for VPL_ROCKCHIP_COMMON_BOARD
- Skip spl-boot-order.c for VPL (rather than modifying it)

 arch/arm/include/asm/spl.h               |   1 +
 arch/arm/mach-rockchip/Kconfig           |  25 +++++-
 arch/arm/mach-rockchip/Makefile          |  11 ++-
 arch/arm/mach-rockchip/rk3399/Kconfig    |  12 +++
 arch/arm/mach-rockchip/spl.c             |   3 +
 arch/arm/mach-rockchip/tpl.c             |   2 +-
 arch/arm/mach-rockchip/u-boot-vpl-v8.lds | 107 +++++++++++++++++++++++
 arch/arm/mach-rockchip/vpl.c             |  53 +++++++++++
 common/spl/Kconfig                       |   1 +
 9 files changed, 208 insertions(+), 7 deletions(-)
 create mode 100644 arch/arm/mach-rockchip/u-boot-vpl-v8.lds
 create mode 100644 arch/arm/mach-rockchip/vpl.c
arch/arm/include/asm/spl.h +1 -0
index ee79a19c05c..62844d64cab 100644
@@ -30,6 +30,7 @@ enum {
 	BOOT_DEVICE_XIP,
 	BOOT_DEVICE_BOOTROM,
 	BOOT_DEVICE_SMH,
+	BOOT_DEVICE_VBE,
 	BOOT_DEVICE_NONE
 };
 #endif
arch/arm/mach-rockchip/Kconfig +4 -2
index 9210877a4a4..96f73b42a8c 100644
@@ -259,13 +259,15 @@ config ROCKCHIP_RK3399
 	select SPL_ATF
 	select SPL_BOARD_INIT if SPL
 	select SPL_LOAD_FIT
-	select SPL_CLK if SPL
+	select SPL_CLK if SPL && !VPL
 	select SPL_PINCTRL if SPL
 	select SPL_RAM if SPL
 	select SPL_REGMAP if SPL
 	select SPL_SYSCON if SPL
 	select TPL_HAVE_INIT_STACK if TPL
-	select SPL_SEPARATE_BSS
+	select VPL_HAVE_INIT_STACK if VPL
+	select SPL_SEPARATE_BSS if !VPL
+	select SPL_RAW_IMAGE_SUPPORT if VPL
 	select CLK
 	select FIT
 	select PINCTRL

arch/arm/mach-rockchip/Kconfig config ROCKCHIP_RK3399 · line 280

Quoted 4 lines
arch/arm/mach-rockchip/Kconfig +1 -0
@@ -275,6 +277,7 @@ config ROCKCHIP_RK3399
 	select DM_PMIC
 	select DM_REGULATOR_FIXED
 	select BOARD_LATE_INIT
+	select SUPPORT_VPL

This should be added next to the existing SUPPORT_xPL options.

Quoted 6 lines
arch/arm/mach-rockchip/Kconfig +0 -0
 	imply ARMV8_CRYPTO
 	imply ARMV8_SET_SMPEN
 	imply BOOTSTD_FULL
@@ -304,13 +307,14 @@ config ROCKCHIP_RK3399
 	imply TPL_LIBCOMMON_SUPPORT
 	imply TPL_LIBGENERIC_SUPPORT

arch/arm/mach-rockchip/Kconfig config ROCKCHIP_RK3399 · line 317

Quoted 10 lines
arch/arm/mach-rockchip/Kconfig +2 -1
 	imply TPL_OF_CONTROL
-	imply TPL_RAM
+	imply TPL_RAM if !VPL
 	imply TPL_REGMAP
 	imply TPL_ROCKCHIP_COMMON_BOARD
 	imply TPL_SERIAL
 	imply TPL_SYS_MALLOC_SIMPLE
 	imply TPL_SYSCON
 	imply TPL_TINY_MEMSET
+	imply TPL_DM_MMC if VPL

All imply are in alphabetical order, please keep it.

Quoted 16 lines
arch/arm/mach-rockchip/Kconfig +1 -1
 	help
 	  The Rockchip RK3399 is a ARM-based SoC with a dual-core Cortex-A72
 	  and quad-core Cortex-A53.
@@ -569,7 +573,7 @@ config SPL_ROCKCHIP_BACK_TO_BROM
 
 config TPL_ROCKCHIP_BACK_TO_BROM
 	bool "TPL returns to bootrom"
-	default y
+	default y if !VPL
 	select ROCKCHIP_BROM_HELPER if !ROCKCHIP_RK3066
 	select TPL_BOOTROM_SUPPORT
 	depends on TPL
@@ -609,6 +613,16 @@ config ROCKCHIP_EXTERNAL_TPL
 	  Enable this option and build with ROCKCHIP_TPL=/path/to/ddr.bin to
 	  include the external TPL in the image built by binman.
 

arch/arm/mach-rockchip/Kconfig config ROCKCHIP_EXTERNAL_TPL · line 625

Quoted 10 lines
arch/arm/mach-rockchip/Kconfig +10 -0
+config VPL_ROCKCHIP_COMMON_BOARD
+	bool "Rockchip VPL common board file"
+	depends on VPL
+	default y
+	help
+	  Enable the VPL phase for rockchip, which selects which SPL/U-Boot
+	  will be used on each boot. With this flow, used by Verified Boot for
+	  Embedded (VBE), TPL is loaded by the boot ROM. Then TPL loads VPL,
+	  VPL loads SPL and SPL loads U-Boot.
+

This new config option should be placed before ROCKCHIP_EXTERNAL_TPL close to all other existing ROCKCHIP_COMMON_BOARD variants.

Quoted 54 lines
arch/arm/mach-rockchip/Kconfig +3 -0
 config ROCKCHIP_BOOT_MODE_REG
 	hex "Rockchip boot mode flag register address"
 	help
@@ -700,6 +714,9 @@ config TPL_ROCKCHIP_EARLYRETURN_TO_BROM
 config SPL_MMC
 	default y if !SPL_ROCKCHIP_BACK_TO_BROM
 
+config TPL_MMC
+	default y if !TPL_ROCKCHIP_BACK_TO_BROM
+
 config ROCKCHIP_SPI_IMAGE
 	bool "Build a SPI image for rockchip"
 	help
arch/arm/mach-rockchip/Makefile +9 -2
index ae15a9f8a2d..6cf60bc911c 100644
@@ -8,11 +8,16 @@
 # inaccessible/protected memory (and the bootrom-helper assumes that
 # the stack-pointer is valid before switching to the U-Boot stack).
 obj-spl-$(CONFIG_ROCKCHIP_BROM_HELPER) += bootrom.o
-obj-spl-$(CONFIG_SPL_ROCKCHIP_COMMON_BOARD) += spl.o spl-boot-order.o spl_common.o
+obj-spl-$(CONFIG_SPL_ROCKCHIP_COMMON_BOARD) += spl.o spl_common.o
+ifndef CONFIG_VPL
+obj-spl-$(CONFIG_SPL_ROCKCHIP_COMMON_BOARD) += spl-boot-order.o
+endif
 obj-tpl-$(CONFIG_ROCKCHIP_BROM_HELPER) += bootrom.o
 obj-tpl-$(CONFIG_TPL_ROCKCHIP_COMMON_BOARD) += tpl.o spl_common.o
 obj-tpl-$(CONFIG_ROCKCHIP_PX30) += px30-board-tpl.o
 
+obj-vpl-$(CONFIG_VPL_ROCKCHIP_COMMON_BOARD) += vpl.o
+
 obj-spl-$(CONFIG_ROCKCHIP_RK3036) += rk3036-board-spl.o
 
 ifeq ($(CONFIG_XPL_BUILD)$(CONFIG_TPL_BUILD),)
@@ -49,9 +54,11 @@ obj-$(CONFIG_ROCKCHIP_RK3588) += rk3588/
 obj-$(CONFIG_ROCKCHIP_RV1108) += rv1108/
 obj-$(CONFIG_ROCKCHIP_RV1126) += rv1126/
 
-# Clear out SPL objects, in case this is a TPL build
+# Clear out SPL objects, in case this is a TPL or VPL build
 obj-spl-$(CONFIG_TPL_BUILD) =
+obj-spl-$(CONFIG_VPL_BUILD) =
 
 # Now add SPL/TPL objects back into the main build
 obj-$(CONFIG_XPL_BUILD) += $(obj-spl-y)
 obj-$(CONFIG_TPL_BUILD) += $(obj-tpl-y)
+obj-$(CONFIG_VPL_BUILD) += $(obj-vpl-y)
arch/arm/mach-rockchip/rk3399/Kconfig +0 -0
index 5c21b08a5ae..7b2d47fcb49 100644
@@ -150,6 +150,18 @@ config TPL_STACK
 config TPL_TEXT_BASE

arch/arm/mach-rockchip/rk3399/Kconfig config TPL_STACK · line 160

Quoted 10 lines
arch/arm/mach-rockchip/rk3399/Kconfig +8 -0
         default 0xff8c2000
 
+config VPL_STACK
+        default 0xff8eff00
+
+config VPL_TEXT_BASE
+        default 0xff8c2000
+
+config VPL_LDSCRIPT
+	default "arch/arm/mach-rockchip/u-boot-vpl-v8.lds"

Please keep the alphabetical order with the existing config options above.

arch/arm/mach-rockchip/rk3399/Kconfig config TPL_STACK · line 163

Quoted 3 lines
arch/arm/mach-rockchip/rk3399/Kconfig +3 -0
+
+config SPL_STACK_R_ADDR
+	default 0x04000000 if !SPL_SHARES_INIT_SP_ADDR

SPL_STACK_R_ADDR was removed from here with the move to use ROCKCHIP_COMMON_STACK_ADDR for (almost) all rockchip boards.

Suggest you add this VBE/VPL specific SPL_STACK_R_ADDR to you vbe board defconfig.

Quoted 23 lines
arch/arm/mach-rockchip/rk3399/Kconfig +1 -0
+
 if BOOTCOUNT_LIMIT
 
 config BOOTCOUNT_BOOTLIMIT
arch/arm/mach-rockchip/spl.c +3 -0
index f4d29bbdd17..305373a161c 100644
@@ -61,6 +61,9 @@ u32 spl_boot_device(void)
 {
 	u32 boot_device = BOOT_DEVICE_MMC1;
 
+	if (IS_ENABLED(CONFIG_VPL))
+		return BOOT_DEVICE_VBE;
+
 #if defined(CONFIG_TARGET_CHROMEBOOK_JERRY) || \
 		defined(CONFIG_TARGET_CHROMEBIT_MICKEY) || \
 		defined(CONFIG_TARGET_CHROMEBOOK_MINNIE) || \
arch/arm/mach-rockchip/tpl.c +0 -0
index 6b880f19f84..cc794a7dca2 100644

arch/arm/mach-rockchip/tpl.c int board_return_to_bootrom(struct spl_image_info *spl_image, · line 87

Quoted 5 lines
arch/arm/mach-rockchip/tpl.c +1 -1
@@ -84,5 +84,5 @@ int board_return_to_bootrom(struct spl_image_info *spl_image,
 
 u32 spl_boot_device(void)
 {
-	return BOOT_DEVICE_BOOTROM;
+	return IS_ENABLED(CONFIG_VPL) ? BOOT_DEVICE_VBE : BOOT_DEVICE_BOOTROM;

nitpic:

Please be consistent, I would suggest you keep a similar if -> early return as you do in spl.c above.

Regards,
Jonas

Quoted 185 lines
arch/arm/mach-rockchip/tpl.c +0 -0
 }
arch/arm/mach-rockchip/u-boot-vpl-v8.lds new file +107 -0
new file mode 100644
index 00000000000..d2a5cf61581
@@ -0,0 +1,107 @@
+// SPDX-License-Identifier:	GPL-2.0+
+/*
+ * (C) Copyright 2019
+ * Rockchip Electronics Co., Ltd
+ * Kever Yang<[email protected]>
+ *
+ * (C) Copyright 2013
+ * David Feng <[email protected]>
+ *
+ * (C) Copyright 2002
+ * Gary Jennejohn, DENX Software Engineering, <[email protected]>
+ *
+ * (C) Copyright 2010
+ * Texas Instruments, <www.ti.com>
+ *	Aneesh V <[email protected]>
+ */
+
+OUTPUT_FORMAT("elf64-littleaarch64", "elf64-littleaarch64", "elf64-littleaarch64")
+OUTPUT_ARCH(aarch64)
+ENTRY(_start)
+SECTIONS
+{
+	. = 0x00000000;
+
+	.text : {
+		. = ALIGN(8);
+		__image_copy_start = .;
+		CPUDIR/start.o (.text*)
+
+		/* put relocation code all together */
+		//. = . + 0xc0;
+		_rcode_start = .;
+		*(.text.rcode)
+		*(.text.rdata)
+		_rcode_end = .;
+
+		*(.text*)
+	}
+
+	.rodata : {
+		. = ALIGN(8);
+		*(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*)))
+	}
+
+	.data : {
+		. = ALIGN(8);
+		*(.data*)
+	}
+
+	__u_boot_list : {
+		. = ALIGN(8);
+		KEEP(*(SORT(__u_boot_list*)));
+	}
+
+	.image_copy_end : {
+		. = ALIGN(8);
+		*(.__image_copy_end)
+	}
+
+	.end : {
+		. = ALIGN(8);
+		*(.__end)
+	}
+
+	_image_binary_end = .;
+	_end = .;
+	__image_copy_end = .;
+
+	__bss_start = .;
+	.bss_start (NOLOAD) : {
+		. = ALIGN(8);
+		KEEP(*(.__bss_start));
+	}
+
+	.bss (NOLOAD) : {
+		*(.bss*)
+		 . = ALIGN(8);
+	}
+
+	.bss_end (NOLOAD) : {
+		KEEP(*(.__bss_end));
+	}
+	__bss_end = .;
+	__bss_size = __bss_end - __bss_start;
+
+	/DISCARD/ : { *(.dynsym) }
+	/DISCARD/ : { *(.dynstr*) }
+	/DISCARD/ : { *(.dynamic*) }
+	/DISCARD/ : { *(.plt*) }
+	/DISCARD/ : { *(.interp*) }
+	/DISCARD/ : { *(.gnu*) }
+}
+
+#if defined(CONFIG_TPL_MAX_SIZE)
+ASSERT(__image_copy_end - __image_copy_start < (CONFIG_TPL_MAX_SIZE), \
+	"TPL image too big");
+#endif
+
+#if defined(CONFIG_TPL_BSS_MAX_SIZE)
+ASSERT(__bss_end - __bss_start < (CONFIG_TPL_BSS_MAX_SIZE), \
+	"TPL image BSS too big");
+#endif
+
+#if defined(CONFIG_TPL_MAX_FOOTPRINT)
+ASSERT(__bss_end - _start < (CONFIG_TPL_MAX_FOOTPRINT), \
+	"TPL image plus BSS too big");
+#endif
arch/arm/mach-rockchip/vpl.c new file +53 -0
new file mode 100644
index 00000000000..55a8dabc2da
@@ -0,0 +1,53 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2019 Rockchip Electronics Co., Ltd
+ */
+
+#include <bootstage.h>
+#include <debug_uart.h>
+#include <dm.h>
+#include <hang.h>
+#include <init.h>
+#include <log.h>
+#include <ram.h>
+#include <spl.h>
+#include <version.h>
+#include <asm/io.h>
+#include <asm/arch-rockchip/bootrom.h>
+#include <linux/bitops.h>
+
+#if CONFIG_IS_ENABLED(BANNER_PRINT)
+#include <timestamp.h>
+#endif
+
+void board_init_f(ulong dummy)
+{
+	int ret;
+
+#if defined(CONFIG_DEBUG_UART) && defined(CONFIG_VPL_SERIAL)
+	/*
+	 * Debug UART can be used from here if required:
+	 *
+	 * debug_uart_init();
+	 * printch('a');
+	 * printhex8(0x1234);
+	 * printascii("string");
+	 */
+	debug_uart_init();
+#ifdef CONFIG_VPL_BANNER_PRINT
+	printascii("\nU-Boot VPL " PLAIN_VERSION " (" U_BOOT_DATE " - "
+		   U_BOOT_TIME ")\n");
+#endif
+#endif
+
+	ret = spl_early_init();
+	if (ret) {
+		debug("spl_early_init() failed: %d\n", ret);
+		hang();
+	}
+}
+
+u32 spl_boot_device(void)
+{
+	return BOOT_DEVICE_VBE;
+}
common/spl/Kconfig +1 -0
index a84a0f83924..fb6c90733ee 100644
@@ -582,6 +582,7 @@ config SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR
 	default 0x200 if ARCH_SOCFPGA || ARCH_AT91
 	default 0x300 if ARCH_ZYNQ || ARCH_KEYSTONE || OMAP34XX || \
 		         OMAP54XX || AM33XX || AM43XX || ARCH_K3
+	default 0x800 if ARCH_ROCKCHIP && VPL
 	default 0x4000 if ARCH_ROCKCHIP
 	default 0x822 if TARGET_SIFIVE_UNLEASHED || TARGET_SIFIVE_UNMATCHED
 	help
#17 lore raw

PATCH v4 14/25 rockchip: Add symbols for spl_reloc

In reply to Simon Glass

Add various symbols so that this feature works as intended. This allows xPL to copy the relocating-jump code up to the top of memory, then use it to decompress and start the next phase.

---

(no changes since v1)

 arch/arm/mach-rockchip/u-boot-tpl-v8.lds | 13 +++++++++++++
 1 file changed, 13 insertions(+)
arch/arm/mach-rockchip/u-boot-tpl-v8.lds +13 -0
index 958a1b70aef..842bd4eb07f 100644
@@ -25,10 +25,21 @@ SECTIONS
 	__image_copy_start = ADDR(.text);
 	.text : {
 		. = ALIGN(8);
+		__image_copy_start = .;
 		CPUDIR/start.o (.text*)
+
+		/* put relocation code all together */
+		//. = . + 0xc0;
+		_rcode_start = .;
+		*(.text.rcode)
+		*(.text.rdata)
+		_rcode_end = .;
+
 		*(.text*)
 	}
 
+	_rcode_size = _rcode_end - _rcode_start;
+
 	.rodata : {
 		. = ALIGN(8);
 		*(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*)))
@@ -48,6 +59,7 @@ SECTIONS
 	__image_copy_end = .;
 	_end = .;
 	_image_binary_end = .;
+	__image_copy_end = .;
 
 	.bss ALIGN(8) : {
 		__bss_start = .;
@@ -55,6 +67,7 @@ SECTIONS
 		. = ALIGN(8);
 		__bss_end = .;
 	}
+	__bss_size = __bss_end - __bss_start;
 
 	/DISCARD/ : { *(.dynsym) }
 	/DISCARD/ : { *(.dynstr*) }
Signature · 1 line
2.34.1
#18 lore raw

Re: [PATCH v4 14/25] rockchip: Add symbols for spl_reloc

Hi Simon,

Quoted 17 lines · Simon Glass

Add various symbols so that this feature works as intended. This allows xPL to copy the relocating-jump code up to the top of memory, then use it to decompress and start the next phase.

---

(no changes since v1)

 arch/arm/mach-rockchip/u-boot-tpl-v8.lds | 13 +++++++++++++
 1 file changed, 13 insertions(+)
arch/arm/mach-rockchip/u-boot-tpl-v8.lds +0 -0
index 958a1b70aef..842bd4eb07f 100644

arch/arm/mach-rockchip/u-boot-tpl-v8.lds SECTIONS · line 28

Quoted 4 lines
arch/arm/mach-rockchip/u-boot-tpl-v8.lds +1 -0
@@ -25,10 +25,21 @@ SECTIONS
 	__image_copy_start = ADDR(.text);
 	.text : {
 		. = ALIGN(8);
+		__image_copy_start = .;

As mentioned in a prior version of this patch, this is already declared a few lines above.

arch/arm/mach-rockchip/u-boot-tpl-v8.lds SECTIONS · line 32

Quoted 4 lines
arch/arm/mach-rockchip/u-boot-tpl-v8.lds +3 -0
 		CPUDIR/start.o (.text*)
+
+		/* put relocation code all together */
+		//. = . + 0xc0;

What is the purpose of this?

Quoted 14 lines
arch/arm/mach-rockchip/u-boot-tpl-v8.lds +7 -0
+		_rcode_start = .;
+		*(.text.rcode)
+		*(.text.rdata)
+		_rcode_end = .;
+
 		*(.text*)
 	}
 
+	_rcode_size = _rcode_end - _rcode_start;
+
 	.rodata : {
 		. = ALIGN(8);
 		*(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*)))

arch/arm/mach-rockchip/u-boot-tpl-v8.lds SECTIONS · line 62

Quoted 4 lines
arch/arm/mach-rockchip/u-boot-tpl-v8.lds +1 -0
@@ -48,6 +59,7 @@ SECTIONS
 	__image_copy_end = .;
 	_end = .;
 	_image_binary_end = .;
+	__image_copy_end = .;

Same as before, this is already defined a few lines above.

Regards,
Jonas

Quoted 11 lines
arch/arm/mach-rockchip/u-boot-tpl-v8.lds +1 -0
 	.bss ALIGN(8) : {
 		__bss_start = .;
@@ -55,6 +67,7 @@ SECTIONS
 		. = ALIGN(8);
 		__bss_end = .;
 	}
+	__bss_size = __bss_end - __bss_start;
 
 	/DISCARD/ : { *(.dynsym) }
 	/DISCARD/ : { *(.dynstr*) }
#19 lore raw

PATCH v4 15/25 rockchip: rk3399: Adjust initial TPL-stack to match SPL

In reply to Simon Glass

There doesn't seem to be a good reason to use a different value for TPL than SPL. Change the TPL value, since it allows a 256-byte bloblist to be safely located above the stack in all phases.

Note that for most boards, SDRAM init happens in TPL so the SPL stack ends up in DRAM, at address CONFIG_SPL_STACK_R_ADDR.

---

(no changes since v2)

Changes in v2:
- Reword commit to mention comments from Jonas

 arch/arm/mach-rockchip/rk3399/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-rockchip/rk3399/Kconfig +1 -1
index 7b2d47fcb49..cbe718a428a 100644
@@ -145,7 +145,7 @@ config TPL_LDSCRIPT
 	default "arch/arm/mach-rockchip/u-boot-tpl-v8.lds"
 
 config TPL_STACK
-        default 0xff8effff
+        default 0xff8eff00
 
 config TPL_TEXT_BASE
         default 0xff8c2000
Signature · 1 line
2.34.1
#20 lore raw

Re: [PATCH v4 15/25] rockchip: rk3399: Adjust initial TPL-stack to match SPL

Hi Simon,

Quoted 3 lines · Simon Glass

There doesn't seem to be a good reason to use a different value for TPL than SPL. Change the TPL value, since it allows a 256-byte bloblist to be safely located above the stack in all phases.

As mentioned for prior versions of this, this commit message does not make any sense with the current state of SPL stack used.

This does not change the TPL stack to match SPL stack, it only moves it to make room for a 256-byte bloblist used by VBE/VPL.

Please update the commit message and subject to reflect the reason for this change.

Regards,
Jonas

Quoted 28 lines

Note that for most boards, SDRAM init happens in TPL so the SPL stack ends up in DRAM, at address CONFIG_SPL_STACK_R_ADDR.

---

(no changes since v2)

Changes in v2:
- Reword commit to mention comments from Jonas

 arch/arm/mach-rockchip/rk3399/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-rockchip/rk3399/Kconfig +1 -1
index 7b2d47fcb49..cbe718a428a 100644
@@ -145,7 +145,7 @@ config TPL_LDSCRIPT
 	default "arch/arm/mach-rockchip/u-boot-tpl-v8.lds"
 
 config TPL_STACK
-        default 0xff8effff
+        default 0xff8eff00
 
 config TPL_TEXT_BASE
         default 0xff8c2000
#21 lore raw

Re: [PATCH v4 15/25] rockchip: rk3399: Adjust initial TPL-stack to match SPL

Hi Jonas,

Quoted 8 lines · Jonas Karlman

Hi Simon,

Quoted 3 lines · Simon Glass

There doesn't seem to be a good reason to use a different value for TPL than SPL. Change the TPL value, since it allows a 256-byte bloblist to be safely located above the stack in all phases.

Quoted 8 lines

As mentioned for prior versions of this, this commit message does not make any sense with the current state of SPL stack used.

This does not change the TPL stack to match SPL stack, it only moves it to make room for a 256-byte bloblist used by VBE/VPL.

Please update the commit message and subject to reflect the reason for this change.

Thanks for the comments. Yes I found your comments on the previous version but unfortunately not before I sent this series. I'll take a look in the next few days,

I am looking forward to getting this in!!

Regards,
Simon

#22 lore raw

PATCH v4 16/25 rockchip: Allow SPL to set up SDRAM

In reply to Simon Glass

The current logic assumes that if TPL exists then it must be setting up the SDRAM. This is not true with VBE, so allow this to be controlled by whether CONFIG_TPL_RAM is enabled, or not.

---

(no changes since v1)

 arch/arm/mach-rockchip/tpl.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
arch/arm/mach-rockchip/tpl.c +6 -4
index cc794a7dca2..2a261199179 100644
@@ -60,10 +60,12 @@ void board_init_f(ulong dummy)
 
 	tpl_board_init();
 
-	ret = uclass_get_device(UCLASS_RAM, 0, &dev);
-	if (ret) {
-		printf("DRAM init failed: %d\n", ret);
-		return;
+	if (CONFIG_IS_ENABLED(RAM)) {
+		ret = uclass_get_device(UCLASS_RAM, 0, &dev);
+		if (ret) {
+			printf("DRAM init failed: %d\n", ret);
+			return;
+		}
 	}
 }
 
Signature · 1 line
2.34.1
#23 lore raw

PATCH v4 17/25 rockchip: Add a generic-ddr3 rk3399 board

In reply to Simon Glass

This build-target is used to build an image which can run on multiple rk3399 boards, using VBE to boot.

To use it, the TPL binary for a particular board must be placed into the first part of the image. The rest of the image (i.e. VPL, SPL and U-Boot) are largely generic and can work on any supported board.

With VBE, memory-init happens in SPL so that this code is updatable in the field. Due to size constraints, the type of memory on the board is defined at build-time. So it is not possible to use the same VBE image on boards with different SDRAM (DDR3 vs LPDDR4 for example). This may become possible with newer boards with more SRAM.

---

Changes in v4:
- Drop SPL_PAD_TO value since the default is fine
- Drop ROCKCHIP_IODOMAIN since it is the default
- Add SPL_LIBCOMMON_SUPPORT and SPL_LIBGENERIC_SUPPORT

Changes in v2:
- Rename to rk3399-generic-ddr3
- Update devicetree to match firefly-rk3399
- Use the firefly devicetree as the default for this board

 board/rockchip/evb_rk3399/MAINTAINERS |   6 ++
 configs/rk3399-generic-ddr3_defconfig | 124 ++++++++++++++++++++++++++
 2 files changed, 130 insertions(+)
 create mode 100644 configs/rk3399-generic-ddr3_defconfig
board/rockchip/evb_rk3399/MAINTAINERS +6 -0
index 8319db2e976..e2149e579f1 100644
@@ -95,3 +95,9 @@ M:	Jagan Teki <[email protected]>
 S:	Maintained
 F:	configs/rock-pi-n10-rk3399pro_defconfig
 F:	arch/arm/dts/rk3399pro-rock-pi-n10*
+
+RK3399-GENERIC-DDR3
+M:	Simon Glass <[email protected]>
+S:	Maintained
+F:	configs/rk3399-generic-ddr3_defconfig
+F:	arch/arm/dts/rockchip-vpl-u-boot.dtsi
configs/rk3399-generic-ddr3_defconfig new file +124 -0

124 lines not on this page · raw message

Signature · 1 line
2.34.1
#24 lore raw

PATCH v4 18/25 rockchip: Add documentation for VBE

In reply to Simon Glass

Now that VBE is running at a basic level on rk3399, add mention of it in the documentation.

---

(no changes since v1)

 doc/board/rockchip/rockchip.rst | 13 +++++++++++++
 1 file changed, 13 insertions(+)
doc/board/rockchip/rockchip.rst +13 -0
index b88299cbba2..cf983c91bd9 100644
@@ -519,6 +519,19 @@ config-flash.ini:
         [OUTPUT]
         PATH=RK30xxLoader_uboot.bin
 
+Verified Boot for Embedded (VBE)
+--------------------------------
+
+VBE is supported on rk3399 at present, with SDRAM being set up in SPL. The full
+A/B/recovery flow is supported in U-Boot.
+
+To build this, use the rk3399-generic board, setting CONFIG_OF_LIST to the list
+of boards you want to support. All boards must use the same SDRAM type.
+
+VBE uses internal SRAM (IRAM) for the TPL, VPL and early SPL phases. The stack
+stop is near the top of this (0xff8eff00) with the 256-byte bloblist immediately
+following.
+
 TODO
 ----
 
Signature · 1 line
2.34.1
#25 lore raw

PATCH v4 19/25 gitlab: Add a VBE board to the sjg lab

In reply to Simon Glass

Add a rockchip rk3399 board which runs Verified Boot for Embedded.

---

Changes in v4:
- Fix 'an' typo in commit subject

 .gitlab-ci.yml | 6 ++++++
 1 file changed, 6 insertions(+)
.gitlab-ci.yml +6 -0
index 7aadd5d8b73..cf8147fbfd5 100644
@@ -738,3 +738,9 @@ qemu-x86_64:
     ROLE: qemu-x86_64
     TEST_PY_TEST_SPEC: "and not sleep"
   <<: *lab_dfn
+
+# Firefly-RK3399 board running the rk3399-generic build
+vbe:
+  variables:
+    ROLE: vbe
+  <<: *lab_dfn
Signature · 1 line
2.34.1
#26 lore raw

PATCH v4 20/25 rockchip: Set the skip-at-start property correctly

In reply to Simon Glass

The rockchip image is written to the media at block 64, which is a 32K offset, so set the skip-at-start property to 0x8000

Update CONFIG_SPL_PAD_TO to point to the offset in the image, since Binman is dealing with the 'missing' 32K now.

---

(no changes since v2)

Changes in v2:
- Move this patch to the end of the series
- Drop 0x8000 offset for SPI

 arch/arm/dts/rockchip-u-boot.dtsi | 1 +
 common/spl/Kconfig                | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
arch/arm/dts/rockchip-u-boot.dtsi +1 -0
index 905706c68e7..8da3c1c2a98 100644
@@ -170,6 +170,7 @@
 	simple-bin {
 		filename = "u-boot-rockchip.bin";
 		pad-byte = <0xff>;
+		skip-at-start = <0x8000>;
 
 #ifndef CONFIG_VPL
 		mkimage {
common/spl/Kconfig +1 -1
index fb6c90733ee..fa28c18fa48 100644
@@ -96,7 +96,7 @@ config SPL_MAX_SIZE
 
 config SPL_PAD_TO
 	hex "Offset to which the SPL should be padded before appending the SPL payload"
-	default 0x7f8000 if ARCH_ROCKCHIP
+	default 0x800000 if ARCH_ROCKCHIP
 	default 0x31000 if ARCH_MX6 && MX6_OCRAM_256KB
 	default 0x11000 if ARCH_MX7 || (ARCH_MX6 && !MX6_OCRAM_256KB)
 	default 0x10000 if ARCH_KEYSTONE
Signature · 1 line
2.34.1
#27 lore raw

PATCH v4 21/25 vbe: Add a bootmeth driver for abrec

In reply to Simon Glass

Add a VBE-ABrec bootmeth so that the VBE state can be accessed.

---

(no changes since v2)

Changes in v2:
- Add new patch with a bootmeth driver for abrec

 boot/vbe_abrec.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 99 insertions(+)
boot/vbe_abrec.c +99 -0
index 6d0f622262d..8593082fd79 100644
@@ -8,6 +8,7 @@
 
 #define LOG_CATEGORY LOGC_BOOT
 
+#include <bootmeth.h>
 #include <dm.h>
 #include <memalign.h>
 #include <mmc.h>
@@ -81,3 +82,101 @@ int abrec_read_state(struct udevice *dev, struct abrec_state *state)
 
 	return 0;
 }
+
+static int vbe_abrec_get_state_desc(struct udevice *dev, char *buf,
+				    int maxsize)
+{
+	struct abrec_state state;
+	int ret;
+
+	ret = abrec_read_state(dev, &state);
+	if (ret)
+		return log_msg_ret("read", ret);
+
+	if (maxsize < 30)
+		return -ENOSPC;
+	snprintf(buf, maxsize, "Version: %s\nVernum: %x/%x", state.fw_version,
+		 state.fw_vernum >> FWVER_KEY_SHIFT,
+		 state.fw_vernum & FWVER_FW_MASK);
+
+	return 0;
+}
+
+static int vbe_abrec_read_bootflow(struct udevice *dev, struct bootflow *bflow)
+{
+	int ret;
+
+	if (CONFIG_IS_ENABLED(BOOTMETH_VBE_ABREC_FW)) {
+		if (vbe_phase() == VBE_PHASE_FIRMWARE) {
+			ret = abrec_read_bootflow_fw(dev, bflow);
+			if (ret)
+				return log_msg_ret("fw", ret);
+			return 0;
+		}
+	}
+
+	return -EINVAL;
+}
+
+static int vbe_abrec_read_file(struct udevice *dev, struct bootflow *bflow,
+			       const char *file_path, ulong addr,
+			       enum bootflow_img_t type, ulong *sizep)
+{
+	int ret;
+
+	if (vbe_phase() == VBE_PHASE_OS) {
+		ret = bootmeth_common_read_file(dev, bflow, file_path, addr,
+						type, sizep);
+		if (ret)
+			return log_msg_ret("os", ret);
+	}
+
+	/* To be implemented */
+	return -EINVAL;
+}
+
+static struct bootmeth_ops bootmeth_vbe_abrec_ops = {
+	.get_state_desc	= vbe_abrec_get_state_desc,
+	.read_bootflow	= vbe_abrec_read_bootflow,
+	.read_file	= vbe_abrec_read_file,
+};
+
+static int bootmeth_vbe_abrec_probe(struct udevice *dev)
+{
+	struct abrec_priv *priv = dev_get_priv(dev);
+	int ret;
+
+	ret = abrec_read_priv(dev_ofnode(dev), priv);
+	if (ret)
+		return log_msg_ret("abp", ret);
+
+	return 0;
+}
+
+static int bootmeth_vbe_abrec_bind(struct udevice *dev)
+{
+	struct bootmeth_uc_plat *plat = dev_get_uclass_plat(dev);
+
+	plat->desc = "VBE A/B/recovery";
+	plat->flags = BOOTMETHF_GLOBAL;
+
+	return 0;
+}
+
+#if CONFIG_IS_ENABLED(OF_REAL)
+static const struct udevice_id generic_simple_vbe_abrec_ids[] = {
+	{ .compatible = "fwupd,vbe-abrec" },
+	{ }
+};
+#endif
+
+U_BOOT_DRIVER(vbe_abrec) = {
+	.name	= "vbe_abrec",
+	.id	= UCLASS_BOOTMETH,
+	.of_match = of_match_ptr(generic_simple_vbe_abrec_ids),
+	.ops	= &bootmeth_vbe_abrec_ops,
+	.bind	= bootmeth_vbe_abrec_bind,
+	.probe	= bootmeth_vbe_abrec_probe,
+	.flags	= DM_FLAG_PRE_RELOC,
+	.priv_auto	= sizeof(struct abrec_priv),
+};
Signature · 1 line
2.34.1
#28 lore raw

PATCH v4 22/25 rockchip: Update binman image for new skip-at-start setup

In reply to Simon Glass

Now that the skip-at-start feature is properly used in Binman, drop the various workarounds in the image.

---

(no changes since v2)

Changes in v2:
- Split out the fixes for skip-at-start into a new patch

 arch/arm/dts/rockchip-vpl-u-boot.dtsi | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
arch/arm/dts/rockchip-vpl-u-boot.dtsi +3 -4
index c5d55b87164..ab205d5d13c 100644
@@ -28,7 +28,6 @@
 			bootph-verify;
 			compatible = "fwupd,vbe-abrec";
 			storage = "mmc0";
-			skip-offset = <0x8000>;
 			area-start = <0x7f8000>;
 			area-size = <0x800000>;
 			state-offset = <(0x7f8000 - 0x400)>;
@@ -129,7 +128,7 @@
 
 		vpl {
 			type = "fit";
-			offset = <(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 0x200 + 0x8000)>;
+			offset = <(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 0x200)>;
 			description = "FIT image for U-Boot TPL";
 			#address-cells = <1>;
 			fit,fdt-list = "of-list";
@@ -174,7 +173,7 @@
 # ifdef CONFIG_BOOTMETH_VBE_ABREC
 		vbe-a {
 			type = "section";
-			offset = <(CONFIG_SPL_PAD_TO + 0x8000)>;
+			offset = <CONFIG_SPL_PAD_TO>;
 			spl-a {
 				insert-template = <&spl_template>;
 				size = <0x100000>;
@@ -211,7 +210,7 @@
 # else /* CONFIG_BOOTMETH_VBE_SIMPLE */
 		vbe {
 			type = "fit";
-			offset = <(CONFIG_SPL_PAD_TO + 0x8000)>;
+			offset = <CONFIG_SPL_PAD_TO>;
 			insert-template = <&fit_template>;
 		};
 # endif /* VBE method */
Signature · 1 line
2.34.1
#29 lore raw

PATCH v4 23/25 bloblist: Temporary hacks to get VBE going

In reply to Simon Glass

Do not apply.

The primary issue with the patch is that U-Boot needs to set up a bloblist in the first phase where BLOBLIST is enabled. Subsequent phases can then use that bloblist.

But the first phase of U-Boot cannot assume that one exists.

While we wait for a final decision on the bloblist implementation (and thus whether VBE can be supported), revert the changes which break VBE.

The real solution is this series, but it is blocked, at least for now:

https://patchwork.ozlabs.org/project/uboot/list/?series=456263&state=*

Note that this breaks vexpress_fvp_bloblist so that test is dropped.

---

(no changes since v1)

 .gitlab-ci.yml          |  14 ++---
 arch/arm/lib/xferlist.c |  12 +++--
 common/bloblist.c       | 116 ++++++++++++----------------------------
 include/bloblist.h      |  16 ++----
 4 files changed, 53 insertions(+), 105 deletions(-)
.gitlab-ci.yml +7 -7
index cf8147fbfd5..e0d25d2be12 100644
@@ -530,13 +530,13 @@ vexpress_fvp test.py:
     - ${DEFAULT_AMD64_TAG}
   <<: *buildman_and_testpy_dfn
 
-vexpress_fvp_bloblist test.py:
-  variables:
-    TEST_PY_BD: "vexpress_fvp_bloblist"
-    TEST_PY_TEST_SPEC: "not sleep and not hostfs"
-  tags:
-    - ${DEFAULT_AMD64_TAG}
-  <<: *buildman_and_testpy_dfn
+#vexpress_fvp_bloblist test.py:
+#  variables:
+#    TEST_PY_BD: "vexpress_fvp_bloblist"
+#    TEST_PY_TEST_SPEC: "not sleep and not hostfs"
+#  tags:
+#    - ${DEFAULT_AMD64_TAG}
+#  <<: *buildman_and_testpy_dfn
 
 xilinx_zynq_virt test.py:
   variables:
arch/arm/lib/xferlist.c +7 -5
index 6425936d354..f9c5d88bd47 100644
@@ -8,16 +8,18 @@
 #include <bloblist.h>
 #include "xferlist.h"
 
-int xferlist_from_boot_arg(ulong *addr)
+int xferlist_from_boot_arg(ulong addr, ulong size)
 {
 	int ret;
 
-	ret = bloblist_check_reg_conv(saved_args[0], saved_args[2],
-				      saved_args[1], saved_args[3]);
+	ret = bloblist_check(saved_args[3], size);
 	if (ret)
 		return ret;
 
-	*addr = bloblist_get_base();
+	ret = bloblist_check_reg_conv(saved_args[0], saved_args[2],
+				      saved_args[1]);
+	if (ret)
+		return ret;
 
-	return 0;
+	return bloblist_reloc((void *)addr, size);
 }
common/bloblist.c +35 -81

161 lines not on this page · raw message

include/bloblist.h +4 -12
index f32faf78560..081eb6161fc 100644
@@ -467,8 +467,9 @@ int bloblist_reloc(void *to, uint to_size);
  * If CONFIG_BLOBLIST_ALLOC is selected, it allocates memory for a bloblist of
  * size CONFIG_BLOBLIST_SIZE.
  *
- * If CONFIG_BLOBLIST_PASSAGE_MANDATORY is selected, bloblist in the incoming
- * standard passage is mandatorily required.
+ * If CONFIG_BLOBLIST_PASSAGE is selected, it uses the bloblist in the incoming
+ * standard passage. The size is detected automatically so CONFIG_BLOBLIST_SIZE
+ * can be 0.
  *
  * Sets GD_FLG_BLOBLIST_READY in global_data flags on success
  *
@@ -500,18 +501,9 @@ static inline int bloblist_maybe_init(void)
  * @rfdt:  Register that holds the FDT base address.
  * @rzero: Register that must be zero.
  * @rsig:  Register that holds signature and register conventions version.
- * @xlist: Register that holds the transfer list.
  * Return: 0 if OK, -EIO if the bloblist is not compliant to the register
  *	   conventions.
  */
-int bloblist_check_reg_conv(ulong rfdt, ulong rzero, ulong rsig, ulong xlist);
-
-/**
- * xferlist_from_boot_arg() - Get bloblist from the boot args.
- *
- * @addr: Address of the bloblist
- * Return: 0 if OK, else on error
- */
-int xferlist_from_boot_arg(ulong *addr);
+int bloblist_check_reg_conv(ulong rfdt, ulong rzero, ulong rsig);
 
 #endif /* __BLOBLIST_H */
Signature · 1 line
2.34.1
#30 lore raw

PATCH v4 24/25 rockchip: Relocate bloblist at the end of the SPL phase

In reply to Simon Glass

Where the bloblist is located in internal memory and TF-A's BL31 blob removes access to this memory, the best option seems to be to relocate the bloblist just before running TF-A.

Do this at the end of SPL.

---

(no changes since v3)

Changes in v3:
- Add the BLOBLIST_RELOC condition as well

Changes in v2:
- Move this logic into board-specific code

 arch/arm/mach-rockchip/spl.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
arch/arm/mach-rockchip/spl.c +15 -0
index 305373a161c..a919246c4aa 100644
@@ -3,6 +3,7 @@
  * (C) Copyright 2019 Rockchip Electronics Co., Ltd
  */
 
+#include <bloblist.h>
 #include <cpu_func.h>
 #include <debug_uart.h>
 #include <dm.h>
@@ -133,6 +134,20 @@ void board_init_f(ulong dummy)
 
 void spl_board_prepare_for_boot(void)
 {
+	/*
+	 * On RK3399, TF-A is executed after SPL and before U-Boot. It removes
+	 * our access to the IRAM. So move the bloblist to RAM.
+	 */
+	if (xpl_phase() == PHASE_SPL && IS_ENABLED(CONFIG_VPL) &&
+	    CONFIG_IS_ENABLED(BLOBLIST_RELOC)) {
+		ulong addr = CONFIG_IF_ENABLED_INT(BLOBLIST_RELOC,
+						   BLOBLIST_RELOC_ADDR);
+
+		log_debug("Relocating bloblist %p to %lx\n", gd_bloblist(),
+			  addr);
+		bloblist_reloc(map_sysmem(addr, 0), bloblist_get_total_size());
+	}
+
 	if (!IS_ENABLED(CONFIG_ARM64) || CONFIG_IS_ENABLED(SYS_DCACHE_OFF))
 		return;
 
Signature · 1 line
2.34.1
#31 lore raw

Re: [PATCH v4 24/25] rockchip: Relocate bloblist at the end of the SPL phase

Hi Simon,

Quoted 34 lines · Simon Glass

Where the bloblist is located in internal memory and TF-A's BL31 blob removes access to this memory, the best option seems to be to relocate the bloblist just before running TF-A.

Do this at the end of SPL.

---

(no changes since v3)

Changes in v3:
- Add the BLOBLIST_RELOC condition as well

Changes in v2:
- Move this logic into board-specific code

 arch/arm/mach-rockchip/spl.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
arch/arm/mach-rockchip/spl.c +1 -0
index 305373a161c..a919246c4aa 100644
@@ -3,6 +3,7 @@
  * (C) Copyright 2019 Rockchip Electronics Co., Ltd
  */
 
+#include <bloblist.h>
 #include <cpu_func.h>
 #include <debug_uart.h>
 #include <dm.h>

arch/arm/mach-rockchip/spl.c void board_init_f(ulong dummy) · line 139

Quoted 6 lines
arch/arm/mach-rockchip/spl.c +3 -0
@@ -133,6 +134,20 @@ void board_init_f(ulong dummy)
 
 void spl_board_prepare_for_boot(void)
 {
+	/*
+	 * On RK3399, TF-A is executed after SPL and before U-Boot. It removes
+	 * our access to the IRAM. So move the bloblist to RAM.

Please rephrase this as TF-A is executed after SPL and before U-Boot proper for all Rockchip AArch64 not just RK3399. Also please reference SRAM instead of IRAM, as SRAM is what is referenced in Rockchip docs.

arch/arm/mach-rockchip/spl.c void board_init_f(ulong dummy) · line 141

Quoted 2 lines
arch/arm/mach-rockchip/spl.c +2 -0
+	 */
+	if (xpl_phase() == PHASE_SPL && IS_ENABLED(CONFIG_VPL) &&

It does not make sense to make this VPL only, as relocation of bloblist could possible be used without VPL?

Regards,
Jonas

Quoted 12 lines
arch/arm/mach-rockchip/spl.c +9 -0
+	    CONFIG_IS_ENABLED(BLOBLIST_RELOC)) {
+		ulong addr = CONFIG_IF_ENABLED_INT(BLOBLIST_RELOC,
+						   BLOBLIST_RELOC_ADDR);
+
+		log_debug("Relocating bloblist %p to %lx\n", gd_bloblist(),
+			  addr);
+		bloblist_reloc(map_sysmem(addr, 0), bloblist_get_total_size());
+	}
+
 	if (!IS_ENABLED(CONFIG_ARM64) || CONFIG_IS_ENABLED(SYS_DCACHE_OFF))
 		return;
 
#32 lore raw

PATCH v4 25/25 bloblist: Allow using a different bloblist address

In reply to Simon Glass

Where the bloblist is located in internal memory and TF-A's BL31 blob removes access to this memory, the best option seems to be to relocate the bloblist just before running TF-A.

We can do the relocation in board-specific code, but need an option to pick up the correct address within U-Boot proper.

---

(no changes since v2)

Changes in v2:
- Move the actual relocation code to a previous board-specific patch

 common/Kconfig    | 20 ++++++++++++++++++++
 common/bloblist.c | 15 ++++++++++++++-
 2 files changed, 34 insertions(+), 1 deletion(-)
common/Kconfig +20 -0
index 17539079f90..d2aa02edab6 100644
@@ -1157,6 +1157,26 @@ config SPL_BLOBLIST_ALLOC
 
 endchoice
 
+config SPL_BLOBLIST_RELOC
+	bool "Relocate the bloblist before existing SPL"
+	depends on BLOBLIST_FIXED
+	help
+	  Some platforms locate the bloblist in SRAM in SPL. In some cases,
+	  the TF-A BL31 blob removes access to SRAM, e.g. with Rockchip RK3399.
+
+	  Enable this option to make U-Boot copy the bloblist from SRAM to SDRAM
+	  before leaving SPL.
+
+config SPL_BLOBLIST_RELOC_ADDR
+	hex "Relocate the bloblist before existing SPL"
+	depends on SPL_BLOBLIST_RELOC
+	default BLOBLIST_ADDR
+	help
+	  Sets the address to which the bloblist is relocated at the end of SPL.
+	  U-Boot proper uses this address when it starts up. Note that U-Boot
+	  always relocates the bloblist again as part of its own relocation
+	  process.
+
 endif # SPL_BLOBLIST
 
 if TPL_BLOBLIST
common/bloblist.c +14 -1
index 197b609fc23..0ca9fbf8ba8 100644
@@ -515,9 +515,22 @@ int bloblist_init(void)
 	expected = fixed && !xpl_is_first_phase();
 	if (xpl_prev_phase() == PHASE_TPL && !IS_ENABLED(CONFIG_TPL_BLOBLIST))
 		expected = false;
-	if (fixed)
+	if (fixed) {
 		addr = IF_ENABLED_INT(CONFIG_BLOBLIST_FIXED,
 				      CONFIG_BLOBLIST_ADDR);
+
+		if (xpl_phase() == PHASE_BOARD_F &&
+		    IS_ENABLED(CONFIG_SPL_BLOBLIST_RELOC)) {
+			ulong addr = IF_ENABLED_INT(CONFIG_SPL_BLOBLIST_RELOC,
+					    CONFIG_SPL_BLOBLIST_RELOC_ADDR);
+
+			log_debug("Using bloblist at %lx\n", addr);
+			bloblist_reloc(map_sysmem(addr, 0),
+				       bloblist_get_total_size());
+		}
+		log_debug("bloblist addr=%lx\n", addr);
+	}
+
 	size = CONFIG_BLOBLIST_SIZE;
 	if (expected) {
 		ret = bloblist_check(addr, size);
Signature · 1 line
2.34.1