Skip to contentSkip to conversation

VBE serial part H: Implement VBE on Rockchip RK3399

PATCH In review Simon Glass 3 participants 27 messages May 28 – Jun 14

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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

This series largely 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. Perhaps more importantly it means that both SPL and U-Boot proper can be safely updated (with VBE's A/B mechanism) in the field.

Of course, each board still needs a separate devicetree.

The current bloblist implementation has a few problems which need to be resolved. I will sort this out separately so as to coordinate with Ilias' global_data changes.

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

Here is an example boot:

  $ ub-int vbe
  Building U-Boot in sourcedir for rk3399-generic-ddr3
  Bootstrapping U-Boot from dir /tmp/b/rk3399-generic-ddr3
  Writing U-Boot using method rockchip

U-Boot TPL 2026.07-rc3-00184-g311970460601 (May 28 2026 - 09:23:10) Trying to boot from vbe_abrec
load: Firefly-RK3399 Board
## Loading firmware (any) from FIT Image at ff8ecb38 ...
Using 'config-7' configuration
Trying 'image-vpl' firmware subimage
## Loading fdt (any) from FIT Image at ff8ecb38 ...
Using 'config-7' configuration
Trying 'fdt-7' fdt subimage

U-Boot VPL 2026.07-rc3-00184-g311970460601 (May 28 2026 - 09:23:10) Trying to boot from vbe_abrec
load: Firefly-RK3399 Board
Starting with empty state
VBE: Firmware pick A at 800000
## Loading firmware (SPL Phase) from FIT Image at ff8ec858 ...
Using 'config-7' configuration
Trying 'spl' firmware subimage
## Loading fdt (SPL Phase) from FIT Image at ff8ec858 ...
Using 'config-7' configuration
Trying 'fdt-7' fdt subimage
Channel 0: DDR3, 800MHz
BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB Channel 1: DDR3, 800MHz
BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB 256B stride

U-Boot SPL 2026.07-rc3-00184-g311970460601 (May 28 2026 - 09:23:10 -0600)
Trying to boot from vbe_abrec
load: Firefly-RK3399 Board
VBE: Firmware pick A at 900000
## Checking hash(es) for config config-7 ... OK
## Checking hash(es) for Image atf-1 ... sha256+ OK
## Checking hash(es) for Image u-boot ... sha256+ OK
## Checking hash(es) for Image fdt-7 ... sha256+ OK
## Checking hash(es) for Image fdt-7 ... sha256+ OK
## Checking hash(es) for Image atf-2 ... sha256+ OK
## Checking hash(es) for Image atf-3 ... sha256+ OK
## Checking hash(es) for Image atf-4 ... sha256+ OK
load_simple_fit: Skip load 'atf-5': image size is 0!
## Checking hash(es) for Image tee-1 ... sha256+ OK
ns16550_serial serial@ff1a0000: pinctrl_select_state_full: uclass_get_device_by_phandle_id: err=-19

U-Boot 2026.07-rc3-00184-g311970460601 (May 28 2026 - 09:23:10 -0600)

SoC: Rockchip rk3399
Reset cause: POR
Model: Firefly-RK3399 Board

  DRAM:  4 GiB (total 3.9 GiB)
  PMIC:  RK808
  Core:  307 devices, 32 uclasses, devicetree: separate
  MMC:   mmc@fe310000: 3, mmc@fe320000: 1, mmc@fe330000: 0

Loading Environment from MMC... Reading from MMC(0)... *** Warning - bad CRC, using default environment

  In:    serial,usbkbd
  Out:   serial,vidconsole
  Err:   serial,vidconsole

Model: Firefly-RK3399 Board
Net: eth0: ethernet@fe300000

Hit any key to stop autoboot: 0
Scanning for bootflows in all bootdevs

  Seq  Method       State   Uclass    Part  Name                      Filename
  ---  -----------  ------  --------  ----  ------------------------  ----------------

Scanning global bootmeth 'firmware0':
Scanning bootdev '[email protected]':
Scanning bootdev '[email protected]':
rockchip_pcie pcie@f8000000: PCIe link training gen1 timeout!
Unknown uclass 'scsi' in label
USB EHCI 1.00
USB EHCI 1.00
USB XHCI 1.10
Bus usb@fe380000: 1 USB Device(s) found
Bus usb@fe3c0000: 2 USB Device(s) found
Bus usb@fe900000: 1 USB Device(s) found
rockchip_pcie pcie@f8000000: PCIe link training gen1 timeout!
Scanning bootdev '[email protected]':
Scanning bootdev '[email protected]':
Scanning global bootmeth 'firmware0':
--- ----------- ------ -------- ---- ------------------------ ---------------- (0 bootflows, 0 valid)
=> vbe state
Phases: TPL (margin 91bb) VPL (margin 231e) SPL

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

- pinctrl init needs to be tidied up to avoid warnings
- bloblist logic as mentioned above

Other things may become apparently after more usage / testing.

Changes in v8:
- Drop bloblist changes
- Update cover letter and add an example boot

Changes in v6:
- Update CONFIG_SPL_PAD_TO for puma-rk3399 and ringneck-px30

Changes in v5:
- Drop stray #endif
- Drop removal of stray #ifdef
- Mention VBE in the first paragraph of the commit message
- Wrap the entire simple-bin node and add the properties to vpl
- Expand commit message to mention VBE
- Move SUPPORT_VPL next to other SUPPORT_xxx options
- Put TPL_DM_MMC in alpha order
- Move VPL_ROCKCHIP_COMMON_BOARD up a bit
- Move VPL_LDSCRIPT up a bit
- Drop config SPL_STACK_R_ADDR
- Use if() instead of ? in spl_boot_device()
- Drop mention of SPL_RAW_IMAGE_SUPPORT since it is already the default
- Drop mention of SPL_SEPARATE_BSS since VPL doesn't need it
- Drop duplicate __image_copy_start and __image_copy_end
- Drop unwanted comment in script
- Reword first paragraph to mention bloblist instead of other stacks
- Add value for CONFIG_SPL_STACK_R_ADDR
- Add to VPL file also

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

Changes in v3:
- Add blank lines before the node
- Add a comment about the offsets
- Move template to the vpl file
- Unindent bootph tags

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

Simon Glass (22):
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 TPL stack to allow for bloblist
rockchip: Allow SPL to set up SDRAM
rockchip: Add a generic-ddr3 rk3399 board
rockchip: Add documentation for VBE
gitlab: Add an 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

 .gitlab-ci.yml                           |   6 +
 arch/arm/dts/rk3399-u-boot.dtsi          |   9 +
 arch/arm/dts/rockchip-u-boot.dtsi        |  17 ++
 arch/arm/dts/rockchip-vpl-u-boot.dtsi    | 224 +++++++++++++++++++++++
 arch/arm/include/asm/spl.h               |   1 +
 arch/arm/mach-rockchip/Kconfig           |  23 ++-
 arch/arm/mach-rockchip/Makefile          |  11 +-
 arch/arm/mach-rockchip/rk3399/Kconfig    |  11 +-
 arch/arm/mach-rockchip/spl.c             |   3 +
 arch/arm/mach-rockchip/tpl.c             |  13 +-
 arch/arm/mach-rockchip/u-boot-tpl-v8.lds |  10 +
 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/spl/Kconfig                       |   3 +-
 common/spl/spl.c                         |   2 +
 common/spl/spl_reloc.c                   |  14 +-
 configs/puma-rk3399_defconfig            |   2 +-
 configs/ringneck-px30_defconfig          |   2 +-
 configs/rk3399-generic-ddr3_defconfig    | 126 +++++++++++++
 doc/board/rockchip/rockchip.rst          |  13 ++
 drivers/ram/rockchip/sdram_rk3399.c      |   6 +-
 include/vbe.h                            |   3 +
 25 files changed, 753 insertions(+), 19 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

---
base-commit: 746a986fe247fc0b3d52ad7ae7027e0a6d57d12c
branch: vbi-us7

Signature · 1 line
2.43.0
#1 lore raw

PATCH v7 1/22 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.43.0
#2 lore raw

PATCH v7 2/22 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 722b18c98ed..14fc5644663 100644
@@ -205,6 +205,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.43.0
#3 lore raw

PATCH v7 3/22 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.43.0
#4 lore raw

PATCH v7 4/22 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.43.0
#5 lore raw

PATCH v7 5/22 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 v5)

Changes in v5:
- Drop stray #endif

Changes in v3:
- Add blank lines before the node

 arch/arm/dts/rockchip-u-boot.dtsi | 6 ++++++
 1 file changed, 6 insertions(+)
arch/arm/dts/rockchip-u-boot.dtsi +6 -0
index 4ba6a87e78a..ca2003fe5c0 100644
@@ -192,6 +192,9 @@
 #endif
 			offset = <CONFIG_SPL_PAD_TO>;
 		};
+
+		fdtmap {
+		};
 	};
 
 #ifdef CONFIG_ROCKCHIP_SPI_IMAGE
@@ -224,6 +227,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.43.0
#6 lore raw

PATCH v7 6/22 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 ca2003fe5c0..f4c6a14fefd 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.43.0
#7 lore raw

PATCH v7 7/22 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 f4c6a14fefd..daf4f489d44 100644
@@ -273,3 +273,7 @@
 #endif /* CONFIG_ROCKCHIP_MASKROM_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.43.0
#8 lore raw

PATCH v7 8/22 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.

---

(no changes since v4)

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.43.0
#9 lore raw

PATCH v7 9/22 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.

---

(no changes since v4)

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.43.0
#10 lore raw

PATCH v7 10/22 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.

---

(no changes since v4)

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.43.0
#11 lore raw

PATCH v7 11/22 rockchip: Add TPL alternatives

In reply to Simon Glass

With VBE, the TPL image must be built separately for each board we need to support. It is the only part of the VBE 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.

---

(no changes since v5)

Changes in v5:
- Drop removal of stray #ifdef
- Mention VBE in the first paragraph of the commit message
- Wrap the entire simple-bin node and add the properties to vpl

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     |  2 ++
 arch/arm/dts/rockchip-vpl-u-boot.dtsi | 21 +++++++++++++++++++++
 2 files changed, 23 insertions(+)
arch/arm/dts/rockchip-u-boot.dtsi +2 -0
index daf4f489d44..7ca2d6d7663 100644
@@ -167,6 +167,7 @@
 	};
 #endif /* HAS_FIT */
 
+#ifndef CONFIG_VPL
 	simple-bin {
 		filename = "u-boot-rockchip.bin";
 		pad-byte = <0xff>;
@@ -200,6 +201,7 @@
 		fdtmap {
 		};
 	};
+#endif /* !VPL */
 
 #ifdef CONFIG_ROCKCHIP_SPI_IMAGE
 	simple-bin-spi {
arch/arm/dts/rockchip-vpl-u-boot.dtsi +21 -0
index 0d767113408..ac67b29c57a 100644
@@ -111,6 +111,25 @@
 	};
 
 	simple-bin {
+		filename = "u-boot-rockchip.bin";
+		pad-byte = <0xff>;
+
+		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 +218,7 @@
 			insert-template = <&fit_template>;
 		};
 # endif /* VBE method */
+		fdtmap {
+		};
 	};
 };
Signature · 1 line
2.43.0
#12 lore raw

PATCH v7 12/22 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 v3)

Changes in v3:
- Unindent bootph tags

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

 arch/arm/dts/rk3399-u-boot.dtsi | 9 +++++++++
 1 file changed, 9 insertions(+)
arch/arm/dts/rk3399-u-boot.dtsi +9 -0
index 587eef9504e..8b530401541 100644
@@ -46,7 +46,12 @@
 	       0x0 0xffa88800 0x0 0x1800
 	       0x0 0xffa8a000 0x0 0x2000
 	       0x0 0xffa8c000 0x0 0x1000>;
+#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.43.0
#13 lore raw

PATCH v7 13/22 rockchip: Provide a VPL phase on rk3399

In reply to Simon Glass

Add support for this new phase, related to VBE, 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 (rather than TPL as normal for Rockchip), so that VBE can update the SDRAM-intit code in the field.

---

(no changes since v5)

Changes in v5:
- Expand commit message to mention VBE
- Move SUPPORT_VPL next to other SUPPORT_xxx options
- Put TPL_DM_MMC in alpha order
- Move VPL_ROCKCHIP_COMMON_BOARD up a bit
- Move VPL_LDSCRIPT up a bit
- Drop config SPL_STACK_R_ADDR
- Use if() instead of ? in spl_boot_device()
- Drop mention of SPL_RAW_IMAGE_SUPPORT since it is already the default
- Drop mention of SPL_SEPARATE_BSS since VPL doesn't need it

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           |  23 ++++-
 arch/arm/mach-rockchip/Makefile          |  11 ++-
 arch/arm/mach-rockchip/rk3399/Kconfig    |   9 ++
 arch/arm/mach-rockchip/spl.c             |   3 +
 arch/arm/mach-rockchip/tpl.c             |   3 +
 arch/arm/mach-rockchip/u-boot-vpl-v8.lds | 107 +++++++++++++++++++++++
 arch/arm/mach-rockchip/vpl.c             |  53 +++++++++++
 common/spl/Kconfig                       |   1 +
 9 files changed, 205 insertions(+), 6 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 dd462ea6ad8..7e49a70e0bd 100644
@@ -31,6 +31,7 @@ enum {
 	BOOT_DEVICE_BOOTROM,
 	BOOT_DEVICE_SMH,
 	BOOT_DEVICE_UFS,
+	BOOT_DEVICE_VBE,
 	BOOT_DEVICE_NONE
 };
 #endif
arch/arm/mach-rockchip/Kconfig +19 -4
index 108713488af..df9bcb26b99 100644
@@ -253,17 +253,18 @@ config ROCKCHIP_RK3399
 	select ARM64
 	select SUPPORT_SPL
 	select SUPPORT_TPL
+	select SUPPORT_VPL
 	select SPL
 	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 CLK
 	select FIT
 	select PINCTRL
@@ -299,10 +300,11 @@ config ROCKCHIP_RK3399
 	imply SYS_BOOTCOUNT_SINGLEWORD if BOOTCOUNT_LIMIT
 	imply TPL_CLK
 	imply TPL_DM
+	imply TPL_DM_MMC if VPL
 	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
@@ -610,7 +612,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
@@ -643,6 +645,16 @@ config TPL_ROCKCHIP_COMMON_BOARD
 	  common board is a basic TPL board init which can be shared for most
 	  of SoCs to avoid copy-paste for different SoCs.
 
+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_EXTERNAL_TPL
 	bool "Use external TPL binary"
 	help
@@ -741,6 +753,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 d3bc0689f89..aca0dc699f0 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 spl_common.o
 
+obj-vpl-$(CONFIG_VPL_ROCKCHIP_COMMON_BOARD) += vpl.o
+
 obj-spl-$(CONFIG_ROCKCHIP_RK3036) += rk3036-board-spl.o spl_common.o
 
 ifeq ($(CONFIG_XPL_BUILD)$(CONFIG_TPL_BUILD),)
@@ -50,9 +55,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 +9 -0
index 5c21b08a5ae..e2f235066e4 100644
@@ -150,6 +150,15 @@ config TPL_STACK
 config TPL_TEXT_BASE
         default 0xff8c2000
 
+config VPL_LDSCRIPT
+	default "arch/arm/mach-rockchip/u-boot-vpl-v8.lds"
+
+config VPL_STACK
+	default 0xff8eff00
+
+config VPL_TEXT_BASE
+	default 0xff8c2000
+
 if BOOTCOUNT_LIMIT
 
 config BOOTCOUNT_BOOTLIMIT
arch/arm/mach-rockchip/spl.c +3 -0
index e989c148079..88c964b393b 100644
@@ -78,6 +78,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 +3 -0
index 6b880f19f84..a350ba56da7 100644
@@ -84,5 +84,8 @@ int board_return_to_bootrom(struct spl_image_info *spl_image,
 
 u32 spl_boot_device(void)
 {
+	if (IS_ENABLED(CONFIG_VPL))
+		return BOOT_DEVICE_VBE;
+
 	return 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 5fa94098e49..4b256abe6af 100644
@@ -587,6 +587,7 @@ config SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR
 	default 0x200 if ARCH_SOCFPGA_GEN5 || 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.43.0
#14 lore raw

Re: [PATCH v7 13/22] rockchip: Provide a VPL phase on rk3399

Hi Simon

Quoted 41 lines · Simon Glass

Add support for this new phase, related to VBE, 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 (rather than TPL as normal for Rockchip), so that VBE can update the SDRAM-intit code in the field.

---

(no changes since v5)

Changes in v5:
- Expand commit message to mention VBE
- Move SUPPORT_VPL next to other SUPPORT_xxx options
- Put TPL_DM_MMC in alpha order
- Move VPL_ROCKCHIP_COMMON_BOARD up a bit
- Move VPL_LDSCRIPT up a bit
- Drop config SPL_STACK_R_ADDR
- Use if() instead of ? in spl_boot_device()
- Drop mention of SPL_RAW_IMAGE_SUPPORT since it is already the default
- Drop mention of SPL_SEPARATE_BSS since VPL doesn't need it

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           |  23 ++++-
 arch/arm/mach-rockchip/Makefile          |  11 ++-
 arch/arm/mach-rockchip/rk3399/Kconfig    |   9 ++
 arch/arm/mach-rockchip/spl.c             |   3 +
 arch/arm/mach-rockchip/tpl.c             |   3 +
 arch/arm/mach-rockchip/u-boot-vpl-v8.lds | 107 +++++++++++++++++++++++
 arch/arm/mach-rockchip/vpl.c             |  53 +++++++++++
 common/spl/Kconfig                       |   1 +
 9 files changed, 205 insertions(+), 6 deletions(-)
 create mode 100644 arch/arm/mach-rockchip/u-boot-vpl-v8.lds
 create mode 100644 arch/arm/mach-rockchip/vpl.c

[...]

Quoted 32 lines
arch/arm/mach-rockchip/vpl.c new file +26 -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;
+

arch/arm/mach-rockchip/vpl.c line 36

Quoted 10 lines
arch/arm/mach-rockchip/vpl.c new file +10 -0
+#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();

Looks like you're initializing debug UART for the second time. debug_uart_init is already called in _main in crt0.S/crt_64.S. Jonas has corresponding fix for TPL in his ci branch [1].

Quoted 32 lines
arch/arm/mach-rockchip/vpl.c new file +17 -0
+#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 5fa94098e49..4b256abe6af 100644
@@ -587,6 +587,7 @@ config SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR
 	default 0x200 if ARCH_SOCFPGA_GEN5 || 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.43.0

[1] https://source.denx.de/u-boot/contributors/kwiboo/u-boot/-/commit/ca73bffba06734f73a2e8d6f0665a1e774ac4f94

Regards,
Pavel

#15 lore raw

PATCH v7 14/22 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 v5)

Changes in v5:
- Drop duplicate __image_copy_start and __image_copy_end
- Drop unwanted comment in script

 arch/arm/mach-rockchip/u-boot-tpl-v8.lds | 10 ++++++++++
 1 file changed, 10 insertions(+)
arch/arm/mach-rockchip/u-boot-tpl-v8.lds +10 -0
index 2c0f5c3e5f3..94f0fc61719 100644
@@ -26,9 +26,18 @@ SECTIONS
 	.text : {
 		. = ALIGN(8);
 		CPUDIR/start.o (.text*)
+
+		/* put relocation code all together */
+		_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*)))
@@ -55,6 +64,7 @@ SECTIONS
 		. = ALIGN(8);
 		__bss_end = .;
 	}
+	__bss_size = __bss_end - __bss_start;
 
 	/DISCARD/ : { *(.dynsym) }
 	/DISCARD/ : { *(.dynstr*) }
Signature · 1 line
2.43.0
#16 lore raw

PATCH v7 15/22 rockchip: rk3399: Adjust TPL stack to allow for bloblist

In reply to Simon Glass

Reduce the TPL value a little to allow for 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 v5)

Changes in v5:
- Reword first paragraph to mention bloblist instead of other stacks

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 e2f235066e4..fcf87ca0e28 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.43.0
#17 lore raw

PATCH v7 16/22 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 a350ba56da7..a2d6079d1d6 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.43.0
#18 lore raw

PATCH v7 17/22 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) is 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.

---

(no changes since v5)

Changes in v5:
- Add value for CONFIG_SPL_STACK_R_ADDR

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 | 126 ++++++++++++++++++++++++++
 2 files changed, 132 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 +126 -0

126 lines not on this page · raw message

Signature · 1 line
2.43.0
#19 lore raw

PATCH v7 18/22 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 141071f528a..f90d27cac78 100644
@@ -533,6 +533,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.43.0
#20 lore raw

PATCH v7 19/22 gitlab: Add an VBE board to the sjg lab

In reply to Simon Glass

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

---

(no changes since v1)

 .gitlab-ci.yml | 6 ++++++
 1 file changed, 6 insertions(+)
.gitlab-ci.yml +6 -0
index 245e422d72f..234b1cfd07b 100644
@@ -797,3 +797,9 @@ qemu-x86_64:
     ROLE: qemu-x86_64
     TEST_PY_TEST_SPEC: "not sleep"
   <<: *sjg_lab_dfn
+
+# Firefly-RK3399 board running the rk3399-generic build
+vbe:
+  variables:
+    ROLE: vbe
+  <<: *sjg_lab_dfn
Signature · 1 line
2.43.0
#21 lore raw

PATCH v7 20/22 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 v6)

Changes in v6:
- Update CONFIG_SPL_PAD_TO for puma-rk3399 and ringneck-px30

Changes in v5:
- Add to VPL file also

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 +
 arch/arm/dts/rockchip-vpl-u-boot.dtsi | 1 +
 common/spl/Kconfig                    | 2 +-
 configs/puma-rk3399_defconfig         | 2 +-
 configs/ringneck-px30_defconfig       | 2 +-
 5 files changed, 5 insertions(+), 3 deletions(-)
arch/arm/dts/rockchip-u-boot.dtsi +1 -0
index 7ca2d6d7663..e300d7bc051 100644
@@ -171,6 +171,7 @@
 	simple-bin {
 		filename = "u-boot-rockchip.bin";
 		pad-byte = <0xff>;
+		skip-at-start = <0x8000>;
 
 		mkimage {
 			filename = "idbloader.img";
arch/arm/dts/rockchip-vpl-u-boot.dtsi +1 -0
index ac67b29c57a..66dcf36010e 100644
@@ -113,6 +113,7 @@
 	simple-bin {
 		filename = "u-boot-rockchip.bin";
 		pad-byte = <0xff>;
+		skip-at-start = <0x8000>;
 
 		alternates-fdt {
 			fdt-list-dir = "dts/upstream/src/arm64/rockchip";
common/spl/Kconfig +1 -1
index 4b256abe6af..2cf0f03accb 100644
@@ -88,7 +88,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
configs/puma-rk3399_defconfig +1 -1
index 09b965d4637..7a129b7389a 100644
@@ -23,7 +23,7 @@ CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-puma-haikou.dtb"
 CONFIG_CONSOLE_MUX=y
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_SPL_MAX_SIZE=0x2e000
-CONFIG_SPL_PAD_TO=0x38000
+CONFIG_SPL_PAD_TO=0x40000
 # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x200
 CONFIG_SPL_I2C=y
configs/ringneck-px30_defconfig +1 -1
index 75646935105..ca7c143fe17 100644
@@ -26,7 +26,7 @@ CONFIG_DEFAULT_FDT_FILE="rockchip/px30-ringneck-haikou.dtb"
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_MISC_INIT_R=y
 CONFIG_SPL_MAX_SIZE=0x20000
-CONFIG_SPL_PAD_TO=0x38000
+CONFIG_SPL_PAD_TO=0x40000
 CONFIG_SPL_BOARD_INIT=y
 CONFIG_SPL_BOOTROM_SUPPORT=y
 # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set
Signature · 1 line
2.43.0
#22 lore raw

PATCH v7 21/22 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.43.0
#23 lore raw

PATCH v7 22/22 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 66dcf36010e..63e6a5416c5 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)>;
@@ -133,7 +132,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";
@@ -178,7 +177,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>;
@@ -215,7 +214,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.43.0
#24 lore raw
In reply to Simon Glass

Hi Jonas and Quentin,

Quoted 313 lines · Simon Glass

This series largely 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. Perhaps more importantly it means that both SPL and U-Boot proper can be safely updated (with VBE's A/B mechanism) in the field.

Of course, each board still needs a separate devicetree.

The current bloblist implementation has a few problems which need to be resolved. I will sort this out separately so as to coordinate with Ilias' global_data changes.

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

Here is an example boot:

  $ ub-int vbe
  Building U-Boot in sourcedir for rk3399-generic-ddr3
  Bootstrapping U-Boot from dir /tmp/b/rk3399-generic-ddr3
  Writing U-Boot using method rockchip

U-Boot TPL 2026.07-rc3-00184-g311970460601 (May 28 2026 - 09:23:10) Trying to boot from vbe_abrec
load: Firefly-RK3399 Board
## Loading firmware (any) from FIT Image at ff8ecb38 ...
Using 'config-7' configuration
Trying 'image-vpl' firmware subimage
## Loading fdt (any) from FIT Image at ff8ecb38 ...
Using 'config-7' configuration
Trying 'fdt-7' fdt subimage

U-Boot VPL 2026.07-rc3-00184-g311970460601 (May 28 2026 - 09:23:10) Trying to boot from vbe_abrec
load: Firefly-RK3399 Board
Starting with empty state
VBE: Firmware pick A at 800000
## Loading firmware (SPL Phase) from FIT Image at ff8ec858 ...
Using 'config-7' configuration
Trying 'spl' firmware subimage
## Loading fdt (SPL Phase) from FIT Image at ff8ec858 ...
Using 'config-7' configuration
Trying 'fdt-7' fdt subimage
Channel 0: DDR3, 800MHz
BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB Channel 1: DDR3, 800MHz
BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB 256B stride

U-Boot SPL 2026.07-rc3-00184-g311970460601 (May 28 2026 - 09:23:10 -0600)
Trying to boot from vbe_abrec
load: Firefly-RK3399 Board
VBE: Firmware pick A at 900000
## Checking hash(es) for config config-7 ... OK
## Checking hash(es) for Image atf-1 ... sha256+ OK
## Checking hash(es) for Image u-boot ... sha256+ OK
## Checking hash(es) for Image fdt-7 ... sha256+ OK
## Checking hash(es) for Image fdt-7 ... sha256+ OK
## Checking hash(es) for Image atf-2 ... sha256+ OK
## Checking hash(es) for Image atf-3 ... sha256+ OK
## Checking hash(es) for Image atf-4 ... sha256+ OK
load_simple_fit: Skip load 'atf-5': image size is 0!
## Checking hash(es) for Image tee-1 ... sha256+ OK
ns16550_serial serial@ff1a0000: pinctrl_select_state_full: uclass_get_device_by_phandle_id: err=-19

U-Boot 2026.07-rc3-00184-g311970460601 (May 28 2026 - 09:23:10 -0600)

SoC: Rockchip rk3399
Reset cause: POR
Model: Firefly-RK3399 Board

  DRAM:  4 GiB (total 3.9 GiB)
  PMIC:  RK808
  Core:  307 devices, 32 uclasses, devicetree: separate
  MMC:   mmc@fe310000: 3, mmc@fe320000: 1, mmc@fe330000: 0

Loading Environment from MMC... Reading from MMC(0)... *** Warning - bad CRC, using default environment

  In:    serial,usbkbd
  Out:   serial,vidconsole
  Err:   serial,vidconsole

Model: Firefly-RK3399 Board
Net: eth0: ethernet@fe300000

Hit any key to stop autoboot: 0
Scanning for bootflows in all bootdevs

  Seq  Method       State   Uclass    Part  Name                      Filename
  ---  -----------  ------  --------  ----  ------------------------  ----------------

Scanning global bootmeth 'firmware0':
Scanning bootdev '[email protected]':
Scanning bootdev '[email protected]':
rockchip_pcie pcie@f8000000: PCIe link training gen1 timeout!
Unknown uclass 'scsi' in label
USB EHCI 1.00
USB EHCI 1.00
USB XHCI 1.10
Bus usb@fe380000: 1 USB Device(s) found
Bus usb@fe3c0000: 2 USB Device(s) found
Bus usb@fe900000: 1 USB Device(s) found
rockchip_pcie pcie@f8000000: PCIe link training gen1 timeout!
Scanning bootdev '[email protected]':
Scanning bootdev '[email protected]':
Scanning global bootmeth 'firmware0':
--- ----------- ------ -------- ---- ------------------------ ---------------- (0 bootflows, 0 valid)
=> vbe state
Phases: TPL (margin 91bb) VPL (margin 231e) SPL

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

- pinctrl init needs to be tidied up to avoid warnings
- bloblist logic as mentioned above

Other things may become apparently after more usage / testing.

Changes in v8:
- Drop bloblist changes
- Update cover letter and add an example boot

Changes in v6:
- Update CONFIG_SPL_PAD_TO for puma-rk3399 and ringneck-px30

Changes in v5:
- Drop stray #endif
- Drop removal of stray #ifdef
- Mention VBE in the first paragraph of the commit message
- Wrap the entire simple-bin node and add the properties to vpl
- Expand commit message to mention VBE
- Move SUPPORT_VPL next to other SUPPORT_xxx options
- Put TPL_DM_MMC in alpha order
- Move VPL_ROCKCHIP_COMMON_BOARD up a bit
- Move VPL_LDSCRIPT up a bit
- Drop config SPL_STACK_R_ADDR
- Use if() instead of ? in spl_boot_device()
- Drop mention of SPL_RAW_IMAGE_SUPPORT since it is already the default
- Drop mention of SPL_SEPARATE_BSS since VPL doesn't need it
- Drop duplicate __image_copy_start and __image_copy_end
- Drop unwanted comment in script
- Reword first paragraph to mention bloblist instead of other stacks
- Add value for CONFIG_SPL_STACK_R_ADDR
- Add to VPL file also

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

Changes in v3:
- Add blank lines before the node
- Add a comment about the offsets
- Move template to the vpl file
- Unindent bootph tags

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

Simon Glass (22):
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 TPL stack to allow for bloblist
rockchip: Allow SPL to set up SDRAM
rockchip: Add a generic-ddr3 rk3399 board
rockchip: Add documentation for VBE
gitlab: Add an 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

 .gitlab-ci.yml                           |   6 +
 arch/arm/dts/rk3399-u-boot.dtsi          |   9 +
 arch/arm/dts/rockchip-u-boot.dtsi        |  17 ++
 arch/arm/dts/rockchip-vpl-u-boot.dtsi    | 224 +++++++++++++++++++++++
 arch/arm/include/asm/spl.h               |   1 +
 arch/arm/mach-rockchip/Kconfig           |  23 ++-
 arch/arm/mach-rockchip/Makefile          |  11 +-
 arch/arm/mach-rockchip/rk3399/Kconfig    |  11 +-
 arch/arm/mach-rockchip/spl.c             |   3 +
 arch/arm/mach-rockchip/tpl.c             |  13 +-
 arch/arm/mach-rockchip/u-boot-tpl-v8.lds |  10 +
 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/spl/Kconfig                       |   3 +-
 common/spl/spl.c                         |   2 +
 common/spl/spl_reloc.c                   |  14 +-
 configs/puma-rk3399_defconfig            |   2 +-
 configs/ringneck-px30_defconfig          |   2 +-
 configs/rk3399-generic-ddr3_defconfig    | 126 +++++++++++++
 doc/board/rockchip/rockchip.rst          |  13 ++
 drivers/ram/rockchip/sdram_rk3399.c      |   6 +-
 include/vbe.h                            |   3 +
 25 files changed, 753 insertions(+), 19 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
Quoted 7 lines

---
base-commit: 746a986fe247fc0b3d52ad7ae7027e0a6d57d12c
branch: vbi-us7

--
2.43.0

Do you have any thoughts on this series? I would very much like to get an example VBE implementation into mainline, if possible.

Regards,
Simon

#25 lore raw

Hi Simon,

Quoted 320 lines · Simon Glass

Hi Jonas and Quentin,

Quoted 317 lines · Simon Glass

This series largely 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. Perhaps more importantly it means that both SPL and U-Boot proper can be safely updated (with VBE's A/B mechanism) in the field.

Of course, each board still needs a separate devicetree.

The current bloblist implementation has a few problems which need to be resolved. I will sort this out separately so as to coordinate with Ilias' global_data changes.

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

Here is an example boot:

  $ ub-int vbe
  Building U-Boot in sourcedir for rk3399-generic-ddr3
  Bootstrapping U-Boot from dir /tmp/b/rk3399-generic-ddr3
  Writing U-Boot using method rockchip

U-Boot TPL 2026.07-rc3-00184-g311970460601 (May 28 2026 - 09:23:10) Trying to boot from vbe_abrec
load: Firefly-RK3399 Board
## Loading firmware (any) from FIT Image at ff8ecb38 ...
Using 'config-7' configuration
Trying 'image-vpl' firmware subimage
## Loading fdt (any) from FIT Image at ff8ecb38 ...
Using 'config-7' configuration
Trying 'fdt-7' fdt subimage

U-Boot VPL 2026.07-rc3-00184-g311970460601 (May 28 2026 - 09:23:10) Trying to boot from vbe_abrec
load: Firefly-RK3399 Board
Starting with empty state
VBE: Firmware pick A at 800000
## Loading firmware (SPL Phase) from FIT Image at ff8ec858 ...
Using 'config-7' configuration
Trying 'spl' firmware subimage
## Loading fdt (SPL Phase) from FIT Image at ff8ec858 ...
Using 'config-7' configuration
Trying 'fdt-7' fdt subimage
Channel 0: DDR3, 800MHz
BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB Channel 1: DDR3, 800MHz
BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB 256B stride

U-Boot SPL 2026.07-rc3-00184-g311970460601 (May 28 2026 - 09:23:10 -0600)
Trying to boot from vbe_abrec
load: Firefly-RK3399 Board
VBE: Firmware pick A at 900000
## Checking hash(es) for config config-7 ... OK
## Checking hash(es) for Image atf-1 ... sha256+ OK
## Checking hash(es) for Image u-boot ... sha256+ OK
## Checking hash(es) for Image fdt-7 ... sha256+ OK
## Checking hash(es) for Image fdt-7 ... sha256+ OK
## Checking hash(es) for Image atf-2 ... sha256+ OK
## Checking hash(es) for Image atf-3 ... sha256+ OK
## Checking hash(es) for Image atf-4 ... sha256+ OK
load_simple_fit: Skip load 'atf-5': image size is 0!
## Checking hash(es) for Image tee-1 ... sha256+ OK
ns16550_serial serial@ff1a0000: pinctrl_select_state_full: uclass_get_device_by_phandle_id: err=-19

U-Boot 2026.07-rc3-00184-g311970460601 (May 28 2026 - 09:23:10 -0600)

SoC: Rockchip rk3399
Reset cause: POR
Model: Firefly-RK3399 Board

  DRAM:  4 GiB (total 3.9 GiB)
  PMIC:  RK808
  Core:  307 devices, 32 uclasses, devicetree: separate
  MMC:   mmc@fe310000: 3, mmc@fe320000: 1, mmc@fe330000: 0

Loading Environment from MMC... Reading from MMC(0)... *** Warning - bad CRC, using default environment

  In:    serial,usbkbd
  Out:   serial,vidconsole
  Err:   serial,vidconsole

Model: Firefly-RK3399 Board
Net: eth0: ethernet@fe300000

Hit any key to stop autoboot: 0
Scanning for bootflows in all bootdevs

  Seq  Method       State   Uclass    Part  Name                      Filename
  ---  -----------  ------  --------  ----  ------------------------  ----------------

Scanning global bootmeth 'firmware0':
Scanning bootdev '[email protected]':
Scanning bootdev '[email protected]':
rockchip_pcie pcie@f8000000: PCIe link training gen1 timeout!
Unknown uclass 'scsi' in label
USB EHCI 1.00
USB EHCI 1.00
USB XHCI 1.10
Bus usb@fe380000: 1 USB Device(s) found
Bus usb@fe3c0000: 2 USB Device(s) found
Bus usb@fe900000: 1 USB Device(s) found
rockchip_pcie pcie@f8000000: PCIe link training gen1 timeout!
Scanning bootdev '[email protected]':
Scanning bootdev '[email protected]':
Scanning global bootmeth 'firmware0':
--- ----------- ------ -------- ---- ------------------------ ---------------- (0 bootflows, 0 valid)
=> vbe state
Phases: TPL (margin 91bb) VPL (margin 231e) SPL

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

- pinctrl init needs to be tidied up to avoid warnings
- bloblist logic as mentioned above

Other things may become apparently after more usage / testing.

Changes in v8:
- Drop bloblist changes
- Update cover letter and add an example boot

Changes in v6:
- Update CONFIG_SPL_PAD_TO for puma-rk3399 and ringneck-px30

Changes in v5:
- Drop stray #endif
- Drop removal of stray #ifdef
- Mention VBE in the first paragraph of the commit message
- Wrap the entire simple-bin node and add the properties to vpl
- Expand commit message to mention VBE
- Move SUPPORT_VPL next to other SUPPORT_xxx options
- Put TPL_DM_MMC in alpha order
- Move VPL_ROCKCHIP_COMMON_BOARD up a bit
- Move VPL_LDSCRIPT up a bit
- Drop config SPL_STACK_R_ADDR
- Use if() instead of ? in spl_boot_device()
- Drop mention of SPL_RAW_IMAGE_SUPPORT since it is already the default
- Drop mention of SPL_SEPARATE_BSS since VPL doesn't need it
- Drop duplicate __image_copy_start and __image_copy_end
- Drop unwanted comment in script
- Reword first paragraph to mention bloblist instead of other stacks
- Add value for CONFIG_SPL_STACK_R_ADDR
- Add to VPL file also

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

Changes in v3:
- Add blank lines before the node
- Add a comment about the offsets
- Move template to the vpl file
- Unindent bootph tags

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

Simon Glass (22):
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 TPL stack to allow for bloblist
rockchip: Allow SPL to set up SDRAM
rockchip: Add a generic-ddr3 rk3399 board
rockchip: Add documentation for VBE
gitlab: Add an 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

 .gitlab-ci.yml                           |   6 +
 arch/arm/dts/rk3399-u-boot.dtsi          |   9 +
 arch/arm/dts/rockchip-u-boot.dtsi        |  17 ++
 arch/arm/dts/rockchip-vpl-u-boot.dtsi    | 224 +++++++++++++++++++++++
 arch/arm/include/asm/spl.h               |   1 +
 arch/arm/mach-rockchip/Kconfig           |  23 ++-
 arch/arm/mach-rockchip/Makefile          |  11 +-
 arch/arm/mach-rockchip/rk3399/Kconfig    |  11 +-
 arch/arm/mach-rockchip/spl.c             |   3 +
 arch/arm/mach-rockchip/tpl.c             |  13 +-
 arch/arm/mach-rockchip/u-boot-tpl-v8.lds |  10 +
 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/spl/Kconfig                       |   3 +-
 common/spl/spl.c                         |   2 +
 common/spl/spl_reloc.c                   |  14 +-
 configs/puma-rk3399_defconfig            |   2 +-
 configs/ringneck-px30_defconfig          |   2 +-
 configs/rk3399-generic-ddr3_defconfig    | 126 +++++++++++++
 doc/board/rockchip/rockchip.rst          |  13 ++
 drivers/ram/rockchip/sdram_rk3399.c      |   6 +-
 include/vbe.h                            |   3 +
 25 files changed, 753 insertions(+), 19 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

---
base-commit: 746a986fe247fc0b3d52ad7ae7027e0a6d57d12c
branch: vbi-us7

Quoted 6 lines
Quoted 3 lines

--
2.43.0

Do you have any thoughts on this series? I would very much like to get an example VBE implementation into mainline, if possible.

I should be able take a deeper look next week or the week after that. At least this version applied cleanly on mainline U-Boot ;-)

Regards,
Jonas

Quoted 3 lines

Regards,
Simon

#26 lore raw

Hi Jonas,

Quoted 328 lines · Jonas Karlman

Hi Simon,

Quoted 324 lines · Simon Glass

Hi Jonas and Quentin,

Quoted 320 lines · Simon Glass

This series largely 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. Perhaps more importantly it means that both SPL and U-Boot proper can be safely updated (with VBE's A/B mechanism) in the field.

Of course, each board still needs a separate devicetree.

The current bloblist implementation has a few problems which need to be resolved. I will sort this out separately so as to coordinate with Ilias' global_data changes.

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

Here is an example boot:

  $ ub-int vbe
  Building U-Boot in sourcedir for rk3399-generic-ddr3
  Bootstrapping U-Boot from dir /tmp/b/rk3399-generic-ddr3
  Writing U-Boot using method rockchip

U-Boot TPL 2026.07-rc3-00184-g311970460601 (May 28 2026 - 09:23:10) Trying to boot from vbe_abrec
load: Firefly-RK3399 Board
## Loading firmware (any) from FIT Image at ff8ecb38 ...
Using 'config-7' configuration
Trying 'image-vpl' firmware subimage
## Loading fdt (any) from FIT Image at ff8ecb38 ...
Using 'config-7' configuration
Trying 'fdt-7' fdt subimage

U-Boot VPL 2026.07-rc3-00184-g311970460601 (May 28 2026 - 09:23:10) Trying to boot from vbe_abrec
load: Firefly-RK3399 Board
Starting with empty state
VBE: Firmware pick A at 800000
## Loading firmware (SPL Phase) from FIT Image at ff8ec858 ...
Using 'config-7' configuration
Trying 'spl' firmware subimage
## Loading fdt (SPL Phase) from FIT Image at ff8ec858 ...
Using 'config-7' configuration
Trying 'fdt-7' fdt subimage
Channel 0: DDR3, 800MHz
BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB Channel 1: DDR3, 800MHz
BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB 256B stride

U-Boot SPL 2026.07-rc3-00184-g311970460601 (May 28 2026 - 09:23:10 -0600)
Trying to boot from vbe_abrec
load: Firefly-RK3399 Board
VBE: Firmware pick A at 900000
## Checking hash(es) for config config-7 ... OK
## Checking hash(es) for Image atf-1 ... sha256+ OK
## Checking hash(es) for Image u-boot ... sha256+ OK
## Checking hash(es) for Image fdt-7 ... sha256+ OK
## Checking hash(es) for Image fdt-7 ... sha256+ OK
## Checking hash(es) for Image atf-2 ... sha256+ OK
## Checking hash(es) for Image atf-3 ... sha256+ OK
## Checking hash(es) for Image atf-4 ... sha256+ OK
load_simple_fit: Skip load 'atf-5': image size is 0!
## Checking hash(es) for Image tee-1 ... sha256+ OK
ns16550_serial serial@ff1a0000: pinctrl_select_state_full: uclass_get_device_by_phandle_id: err=-19

U-Boot 2026.07-rc3-00184-g311970460601 (May 28 2026 - 09:23:10 -0600)

SoC: Rockchip rk3399
Reset cause: POR
Model: Firefly-RK3399 Board

  DRAM:  4 GiB (total 3.9 GiB)
  PMIC:  RK808
  Core:  307 devices, 32 uclasses, devicetree: separate
  MMC:   mmc@fe310000: 3, mmc@fe320000: 1, mmc@fe330000: 0

Loading Environment from MMC... Reading from MMC(0)... *** Warning - bad CRC, using default environment

  In:    serial,usbkbd
  Out:   serial,vidconsole
  Err:   serial,vidconsole

Model: Firefly-RK3399 Board
Net: eth0: ethernet@fe300000

Hit any key to stop autoboot: 0
Scanning for bootflows in all bootdevs

  Seq  Method       State   Uclass    Part  Name                      Filename
  ---  -----------  ------  --------  ----  ------------------------  ----------------

Scanning global bootmeth 'firmware0':
Scanning bootdev '[email protected]':
Scanning bootdev '[email protected]':
rockchip_pcie pcie@f8000000: PCIe link training gen1 timeout!
Unknown uclass 'scsi' in label
USB EHCI 1.00
USB EHCI 1.00
USB XHCI 1.10
Bus usb@fe380000: 1 USB Device(s) found
Bus usb@fe3c0000: 2 USB Device(s) found
Bus usb@fe900000: 1 USB Device(s) found
rockchip_pcie pcie@f8000000: PCIe link training gen1 timeout!
Scanning bootdev '[email protected]':
Scanning bootdev '[email protected]':
Scanning global bootmeth 'firmware0':
--- ----------- ------ -------- ---- ------------------------ ---------------- (0 bootflows, 0 valid)
=> vbe state
Phases: TPL (margin 91bb) VPL (margin 231e) SPL

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

- pinctrl init needs to be tidied up to avoid warnings
- bloblist logic as mentioned above

Other things may become apparently after more usage / testing.

Changes in v8:
- Drop bloblist changes
- Update cover letter and add an example boot

Changes in v6:
- Update CONFIG_SPL_PAD_TO for puma-rk3399 and ringneck-px30

Changes in v5:
- Drop stray #endif
- Drop removal of stray #ifdef
- Mention VBE in the first paragraph of the commit message
- Wrap the entire simple-bin node and add the properties to vpl
- Expand commit message to mention VBE
- Move SUPPORT_VPL next to other SUPPORT_xxx options
- Put TPL_DM_MMC in alpha order
- Move VPL_ROCKCHIP_COMMON_BOARD up a bit
- Move VPL_LDSCRIPT up a bit
- Drop config SPL_STACK_R_ADDR
- Use if() instead of ? in spl_boot_device()
- Drop mention of SPL_RAW_IMAGE_SUPPORT since it is already the default
- Drop mention of SPL_SEPARATE_BSS since VPL doesn't need it
- Drop duplicate __image_copy_start and __image_copy_end
- Drop unwanted comment in script
- Reword first paragraph to mention bloblist instead of other stacks
- Add value for CONFIG_SPL_STACK_R_ADDR
- Add to VPL file also

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

Changes in v3:
- Add blank lines before the node
- Add a comment about the offsets
- Move template to the vpl file
- Unindent bootph tags

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

Simon Glass (22):
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 TPL stack to allow for bloblist
rockchip: Allow SPL to set up SDRAM
rockchip: Add a generic-ddr3 rk3399 board
rockchip: Add documentation for VBE
gitlab: Add an 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

 .gitlab-ci.yml                           |   6 +
 arch/arm/dts/rk3399-u-boot.dtsi          |   9 +
 arch/arm/dts/rockchip-u-boot.dtsi        |  17 ++
 arch/arm/dts/rockchip-vpl-u-boot.dtsi    | 224 +++++++++++++++++++++++
 arch/arm/include/asm/spl.h               |   1 +
 arch/arm/mach-rockchip/Kconfig           |  23 ++-
 arch/arm/mach-rockchip/Makefile          |  11 +-
 arch/arm/mach-rockchip/rk3399/Kconfig    |  11 +-
 arch/arm/mach-rockchip/spl.c             |   3 +
 arch/arm/mach-rockchip/tpl.c             |  13 +-
 arch/arm/mach-rockchip/u-boot-tpl-v8.lds |  10 +
 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/spl/Kconfig                       |   3 +-
 common/spl/spl.c                         |   2 +
 common/spl/spl_reloc.c                   |  14 +-
 configs/puma-rk3399_defconfig            |   2 +-
 configs/ringneck-px30_defconfig          |   2 +-
 configs/rk3399-generic-ddr3_defconfig    | 126 +++++++++++++
 doc/board/rockchip/rockchip.rst          |  13 ++
 drivers/ram/rockchip/sdram_rk3399.c      |   6 +-
 include/vbe.h                            |   3 +
 25 files changed, 753 insertions(+), 19 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

---
base-commit: 746a986fe247fc0b3d52ad7ae7027e0a6d57d12c
branch: vbi-us7

--
2.43.0

Quoted 5 lines
Quoted 2 lines

Do you have any thoughts on this series? I would very much like to get an example VBE implementation into mainline, if possible.

I should be able take a deeper look next week or the week after that. At least this version applied cleanly on mainline U-Boot ;-)

OK thank you, yes it does at present!

Regards,
Simon