VBE serial part H: Implement VBE on Rockchip RK3399
Subsystems (3)
v5 cover VBE serial part H: Implement VBE on Rockchip RK3399
This series completes the work to enable VBE on a suitable board. Most of it is rockchip-specific patches to support the VPL phase, i.e. the one which decides which boot patch to take (A, B or recovery).
A good chunk of this series is adding an image for VBE, by creating a new Binman image. Future work in Binman may make this more automated / easier, but for now it is written out in full. The work is undertaken piecemeal so it is easier to review the steps.
VBE allows similar boards to share firmware images, with perhaps just TPL (around 75K) being different for each board. Using a common image for VPL, SPL and U-Boot saves a lot of space in the image and makes builds easier. Of course, each board still needs a separate devicetree.
Here is the layout of the image:
Name Image-pos Size Entry-type Offset Uncomp-size
----------------------------------------------------------------------------------------------
image 0 1b960cf section 0
alternates-fdt 8000 31000 alternates-fdt 8000
mkimage 8000 31000 mkimage 0
u-boot-tpl 8048 12a11 u-boot-tpl 48
vpl 208000 16200 fit 208000
image-vpl 209400 a5a3 section 1400
section 209400 a5a3 section 0
u-boot-vpl-nodtb 10348 u-boot-vpl-nodtb 0
u-boot-vpl-bss-pad 20 u-boot-vpl-bss-pad 10348
@fdt-SEQ 0 0 section 0
vbe-a 800000 39b200 section 800000
spl-a 800000 100000 fit 0
spl 801400 10c97 section 1400
section 801400 10c97 section 0
u-boot-spl-nodtb 1a908 u-boot-spl-nodtb 0
u-boot-spl-bss-pad 1b0 u-boot-spl-bss-pad 1a908
@fdt-SEQ 0 0 section 0
u-boot-a 900000 29b200 fit 100000
spl 902400 10c97 section 2400
section 902400 10c97 section 0
u-boot-spl-nodtb 1a908 u-boot-spl-nodtb 0
u-boot-spl-bss-pad 1b0 u-boot-spl-bss-pad 1a908
u-boot 913200 e4250 section 13200
u-boot-nodtb 913200 e4250 u-boot-nodtb 0
@atf-SEQ 0 0 section 0
atf-bl31 0 0 atf-bl31 0
@tee-SEQ 0 0 section 0
tee-os 0 0 tee-os 0
@fdt-SEQ 0 0 section 0
vbe-b 1000000 39b200 section 1000000
spl-b 1000000 100000 fit 0
spl 1001400 10c97 section 1400
section 1001400 10c97 section 0
u-boot-spl-nodtb 1a908 u-boot-spl-nodtb 0
u-boot-spl-bss-pad 1b0 u-boot-spl-bss-pad 1a908
@fdt-SEQ 0 0 section 0
u-boot-b 1100000 29b200 fit 100000
spl 1102400 10c97 section 2400
section 1102400 10c97 section 0
u-boot-spl-nodtb 1a908 u-boot-spl-nodtb 0
u-boot-spl-bss-pad 1b0 u-boot-spl-bss-pad 1a908
u-boot 1113200 e4250 section 13200
u-boot-nodtb 1113200 e4250 u-boot-nodtb 0
@atf-SEQ 0 0 section 0
atf-bl31 0 0 atf-bl31 0
@tee-SEQ 0 0 section 0
tee-os 0 0 tee-os 0
@fdt-SEQ 0 0 section 0
vbe-recovery 1800000 39b200 section 1800000
spl-recovery 1800000 100000 fit 0
spl 1801400 10c97 section 1400
section 1801400 10c97 section 0
u-boot-spl-nodtb 1a908 u-boot-spl-nodtb 0
u-boot-spl-bss-pad 1b0 u-boot-spl-bss-pad 1a908
@fdt-SEQ 0 0 section 0
u-boot-recovery 1900000 29b200 fit 100000
spl 1902400 10c97 section 2400
section 1902400 10c97 section 0
u-boot-spl-nodtb 1a908 u-boot-spl-nodtb 0
u-boot-spl-bss-pad 1b0 u-boot-spl-bss-pad 1a908
u-boot 1913200 e4250 section 13200
u-boot-nodtb 1913200 e4250 u-boot-nodtb 0
@atf-SEQ 0 0 section 0
atf-bl31 0 0 atf-bl31 0
@tee-SEQ 0 0 section 0
tee-os 0 0 tee-os 0
@fdt-SEQ 0 0 section 0
fdtmap 1b9b200 2ecf fdtmap 1b9b200This series still includes the bloblist reverts, at the end, just so that the board doesn't have on boot, but I have a series locally which should improve things, so I will send that when complete.
This is (mostly) the final VBE series, but there are a few loose ends to tidy up:
- cache is disabled in SPL, which slows the boot a little
- pinctrl init needs to be tidied up to avoid warnings
- bloblist logic as above
- bloblist-relocation is partly in board-specific code, partly generic
Other things may become apparently after more usage / testing.
Changes in 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
- Use 'SDRAM' instead of 'IRAM' in comment
- Drop mention of rk3399 since 64-boards always have TF-A after SPL
- Drop condition on VPL
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
- Add the BLOBLIST_RELOC condition as well
Changes in v2:
- Move VPL things into a separate file
- Move VPL things into a separate file
- Move VPL things into a separate file
- Mention RK3399 with respect to the memory limit
- Move VPL things into a separate file
- Only enable MMC when VPM is in use.
- Rewrite help for VPL_ROCKCHIP_COMMON_BOARD
- Skip spl-boot-order.c for VPL (rather than modifying it)
- Reword commit to mention comments from Jonas
- Rename to rk3399-generic-ddr3
- Update devicetree to match firefly-rk3399
- Use the firefly devicetree as the default for this board
- Move this patch to the end of the series
- Drop 0x8000 offset for SPI
- Add new patch with a bootmeth driver for abrec
- Split out the fixes for skip-at-start into a new patch
- Move this logic into board-specific code
- Move the actual relocation code to a previous board-specific patch
Simon Glass (25):
spl: Adjust xPL symbols
spl: Allow VBE to handle xPL size
vbe: Show the margin when using SPL_RELOC
rockchip: Allow RAM init to happen in SPL on rk3399
rockchip: dts: Add an fdtmap
rockchip: dts: Specify the phase in the image
rockchip: Provide a bootstd configuration
rockchip: Add SPL into the main FIT
rockchip: Add a template for SPL
rockchip: Add a VPL image
rockchip: Add TPL alternatives
rockchip: Update rk3399 bootph-tags for VPL
rockchip: Provide a VPL phase on rk3399
rockchip: Add symbols for spl_reloc
rockchip: rk3399: Adjust 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
bloblist: Temporary hacks to get VBE going
rockchip: Relocate bloblist at the end of the SPL phase
bloblist: Allow using a different bloblist address
.gitlab-ci.yml | 20 +- arch/arm/dts/rk3399-u-boot.dtsi | 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/lib/xferlist.c | 12 +- 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 | 17 ++ 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/Kconfig | 20 ++ common/bloblist.c | 127 +++++-------- common/spl/Kconfig | 3 +- common/spl/spl.c | 2 + common/spl/spl_reloc.c | 14 +- configs/rk3399-generic-ddr3_defconfig | 125 +++++++++++++ doc/board/rockchip/rockchip.rst | 13 ++ drivers/ram/rockchip/sdram_rk3399.c | 6 +- include/bloblist.h | 16 +- include/vbe.h | 3 + 27 files changed, 849 insertions(+), 121 deletions(-) create mode 100644 arch/arm/dts/rockchip-vpl-u-boot.dtsi create mode 100644 arch/arm/mach-rockchip/u-boot-vpl-v8.lds create mode 100644 arch/arm/mach-rockchip/vpl.c create mode 100644 configs/rk3399-generic-ddr3_defconfig
Signature · 4 lines
2.43.0 base-commit: bab54f5942c428be698216224fd10b91d974d4da branch: vbi5
PATCH v5 1/25 spl: Adjust xPL symbols
Update for the new xPL naming, which was missed in a previous patch which purported to do this.
---
(no changes since v1)
common/spl/spl_reloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
common/spl/spl_reloc.c +1 -1
@@ -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
PATCH v5 2/25 spl: Allow VBE to handle xPL size
In reply to Simon GlassWhen 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
@@ -200,6 +200,8 @@ ulong spl_get_image_size(void)#ifdef CONFIG_VPL if (xpl_next_phase () ==PHASE_VPL )return binman_sym (ulong, u_boot_vpl_any, size); + +return 0 ;/* VBE handles this */ #endif return xpl_next_phase () ==PHASE_SPL ? binman_sym(ulong, u_boot_spl_any, size) :
Signature · 1 line
2.43.0
PATCH v5 3/25 vbe: Show the margin when using SPL_RELOC
In reply to Simon GlassCollect 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
@@ -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
@@ -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
@@ -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
PATCH v5 4/25 rockchip: Allow RAM init to happen in SPL on rk3399
In reply to Simon GlassTPL 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
@@ -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
PATCH v5 5/25 rockchip: dts: Add an fdtmap
In reply to Simon GlassAdd an fdtmap so it is possible to look at the image with 'binman ls'.
---
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
@@ -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
PATCH v5 6/25 rockchip: dts: Specify the phase in the image
In reply to Simon GlassAdd '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
@@ -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
PATCH v5 7/25 rockchip: Provide a bootstd configuration
In reply to Simon GlassAdd 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
@@ -238,3 +238,7 @@ #endif /* CONFIG_ROCKCHIP_SPI_IMAGE */ }; #endif /* CONFIG_SPL */ + +#ifdef CONFIG_VPL +#include "rockchip-vpl-u-boot.dtsi" +#endif
arch/arm/dts/rockchip-vpl-u-boot.dtsi new file +40 -0
@@ -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
PATCH v5 8/25 rockchip: Add SPL into the main FIT
In reply to Simon GlassVBE 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
@@ -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
PATCH v5 9/25 rockchip: Add a template for SPL
In reply to Simon GlassThe 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
@@ -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
PATCH v5 10/25 rockchip: Add a VPL image
In reply to Simon GlassThe 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
@@ -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
PATCH v5 11/25 rockchip: Add TPL alternatives
In reply to Simon GlassWith 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.
---
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
@@ -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
@@ -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
PATCH v5 12/25 rockchip: Update rk3399 bootph-tags for VPL
In reply to Simon GlassWhen 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
@@ -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
PATCH v5 13/25 rockchip: Provide a VPL phase on rk3399
In reply to Simon GlassAdd 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.
---
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
@@ -30,6 +30,7 @@ enum {BOOT_DEVICE_XIP ,BOOT_DEVICE_BOOTROM ,BOOT_DEVICE_SMH , +BOOT_DEVICE_VBE ,BOOT_DEVICE_NONE };#endif
arch/arm/mach-rockchip/Kconfig +19 -4
@@ -255,17 +255,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
@@ -301,10 +302,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
@@ -569,7 +571,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
@@ -602,6 +604,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
@@ -700,6 +712,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
@@ -8,11 +8,16 @@ # inaccessible/protected memory (and the bootrom-helper assumes that # the stack-pointer is valid before switching to the U-Boot stack). obj-spl-$(CONFIG_ROCKCHIP_BROM_HELPER) += bootrom.o -obj-spl-$(CONFIG_SPL_ROCKCHIP_COMMON_BOARD) += spl.o spl-boot-order.o spl_common.o +obj-spl-$(CONFIG_SPL_ROCKCHIP_COMMON_BOARD) += spl.o spl_common.o +ifndef CONFIG_VPL +obj-spl-$(CONFIG_SPL_ROCKCHIP_COMMON_BOARD) += spl-boot-order.o +endif obj-tpl-$(CONFIG_ROCKCHIP_BROM_HELPER) += bootrom.o obj-tpl-$(CONFIG_TPL_ROCKCHIP_COMMON_BOARD) += tpl.o spl_common.o obj-tpl-$(CONFIG_ROCKCHIP_PX30) += px30-board-tpl.o +obj-vpl-$(CONFIG_VPL_ROCKCHIP_COMMON_BOARD) += vpl.o + obj-spl-$(CONFIG_ROCKCHIP_RK3036) += rk3036-board-spl.o ifeq ($(CONFIG_XPL_BUILD)$(CONFIG_TPL_BUILD),)
@@ -49,9 +54,11 @@ obj-$(CONFIG_ROCKCHIP_RK3588) += rk3588/ obj-$(CONFIG_ROCKCHIP_RV1108) += rv1108/ obj-$(CONFIG_ROCKCHIP_RV1126) += rv1126/ -# Clear out SPL objects, in case this is a TPL build +# Clear out SPL objects, in case this is a TPL or VPL build obj-spl-$(CONFIG_TPL_BUILD) = +obj-spl-$(CONFIG_VPL_BUILD) = # Now add SPL/TPL objects back into the main build obj-$(CONFIG_XPL_BUILD) += $(obj-spl-y) obj-$(CONFIG_TPL_BUILD) += $(obj-tpl-y) +obj-$(CONFIG_VPL_BUILD) += $(obj-vpl-y)
arch/arm/mach-rockchip/rk3399/Kconfig +9 -0
@@ -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
@@ -61,6 +61,9 @@ u32 spl_boot_device(void) {u32 boot_device =BOOT_DEVICE_MMC1 ; +if (IS_ENABLED (CONFIG_VPL )) +return BOOT_DEVICE_VBE ; + #if defined(CONFIG_TARGET_CHROMEBOOK_JERRY) || \ defined(CONFIG_TARGET_CHROMEBIT_MICKEY) || \ defined(CONFIG_TARGET_CHROMEBOOK_MINNIE) || \
arch/arm/mach-rockchip/tpl.c +3 -0
@@ -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
@@ -582,6 +582,7 @@ config SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR default 0x200 if ARCH_SOCFPGA || ARCH_AT91 default 0x300 if ARCH_ZYNQ || ARCH_KEYSTONE || OMAP34XX || \ OMAP54XX || AM33XX || AM43XX || ARCH_K3 + default 0x800 if ARCH_ROCKCHIP && VPL default 0x4000 if ARCH_ROCKCHIP default 0x822 if TARGET_SIFIVE_UNLEASHED || TARGET_SIFIVE_UNMATCHED help
Signature · 1 line
2.43.0
PATCH v5 14/25 rockchip: Add symbols for spl_reloc
In reply to Simon GlassAdd 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.
---
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
@@ -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
PATCH v5 15/25 rockchip: rk3399: Adjust TPL stack to allow for bloblist
In reply to Simon GlassReduce 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.
---
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
@@ -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
PATCH v5 16/25 rockchip: Allow SPL to set up SDRAM
In reply to Simon GlassThe 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
@@ -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
PATCH v5 17/25 rockchip: Add a generic-ddr3 rk3399 board
In reply to Simon GlassThis build-target is used to build an image which can run on multiple rk3399 boards, using VBE to boot.
To use it, the TPL binary for a particular board must be placed into the first part of the image. The rest of the image (i.e. VPL, SPL and U-Boot) are largely generic and can work on any supported board.
With VBE, memory-init happens in SPL so that this code is updatable in the field. Due to size constraints, the type of memory on the board is defined at build-time. So it is not possible to use the same VBE image on boards with different SDRAM (DDR3 vs LPDDR4 for example). This may become possible with newer boards with more SRAM.
---
Changes in 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 | 125 ++++++++++++++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 configs/rk3399-generic-ddr3_defconfig
board/rockchip/evb_rk3399/MAINTAINERS +6 -0
@@ -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 +125 -0
125 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v5 18/25 rockchip: Add documentation for VBE
In reply to Simon GlassNow 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
@@ -519,6 +519,19 @@ config-flash.ini: [OUTPUT] PATH=RK30xxLoader_uboot.bin +Verified Boot for Embedded (VBE) +-------------------------------- + +VBE is supported on rk3399 at present, with SDRAM being set up in SPL. The full +A/B/recovery flow is supported in U-Boot. + +To build this, use the rk3399-generic board, setting CONFIG_OF_LIST to the list +of boards you want to support. All boards must use the same SDRAM type. + +VBE uses internal SRAM (IRAM) for the TPL, VPL and early SPL phases. The stack +stop is near the top of this (0xff8eff00) with the 256-byte bloblist immediately +following. + TODO ----
Signature · 1 line
2.43.0
PATCH v5 19/25 gitlab: Add an VBE board to the sjg lab
In reply to Simon GlassAdd 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
@@ -738,3 +738,9 @@ qemu-x86_64: ROLE: qemu-x86_64 TEST_PY_TEST_SPEC: "and not sleep" <<: *lab_dfn + +# Firefly-RK3399 board running the rk3399-generic build +vbe: + variables: + ROLE: vbe + <<: *lab_dfn
Signature · 1 line
2.43.0
PATCH v5 20/25 rockchip: Set the skip-at-start property correctly
In reply to Simon GlassThe 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.
---
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 +- 3 files changed, 3 insertions(+), 1 deletion(-)
arch/arm/dts/rockchip-u-boot.dtsi +1 -0
@@ -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
@@ -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
@@ -96,7 +96,7 @@ config SPL_MAX_SIZE config SPL_PAD_TO hex "Offset to which the SPL should be padded before appending the SPL payload" - default 0x7f8000 if ARCH_ROCKCHIP + default 0x800000 if ARCH_ROCKCHIP default 0x31000 if ARCH_MX6 && MX6_OCRAM_256KB default 0x11000 if ARCH_MX7 || (ARCH_MX6 && !MX6_OCRAM_256KB) default 0x10000 if ARCH_KEYSTONE
Signature · 1 line
2.43.0
Re: [PATCH v5 20/25] rockchip: Set the skip-at-start property correctly
Hi Jonas,
Quoted 60 lines · 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
0x8000Update
CONFIG_SPL_PAD_TOto point to the offset in the image, since Binman is dealing with the 'missing' 32K now.Signed-off-by Simon Glass <[email protected]>---
Changes in v5:
- Add to VPL file alsoChanges in v2:
- Move this patch to the end of the series
- Drop0x8000offset for SPIarch/arm/dts/rockchip-u-boot.dtsi | 1 + arch/arm/dts/rockchip-vpl-u-boot.dtsi | 1 + common/spl/Kconfig | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-)arch/arm/dts/rockchip-u-boot.dtsi +1
-0@@ -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@@ -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
-2@@ -96,7 +96,7 @@ config SPL_MAX_SIZE config SPL_PAD_TO hex "Offset to which the SPL should be padded before appending the SPL payload" - default 0x7f8000 if ARCH_ROCKCHIP + default 0x800000 if ARCH_ROCKCHIP default 0x31000 if ARCH_MX6 && MX6_OCRAM_256KB default 0x11000 if ARCH_MX7 || (ARCH_MX6 && !MX6_OCRAM_256KB) default 0x10000 if ARCH_KEYSTONE --
Quoted 2 lines
2.43.0
Unfortunately this patch needs an defconfig update for CONFIG_SPL_PAD_TO for puma-rk3399 and ringneck-px30
CONFIG_SPL_PAD_TO=0x40000
I'll hold off sending a new version until this is reviewed.
Regards,
Simon
PATCH v5 21/25 vbe: Add a bootmeth driver for abrec
In reply to Simon GlassAdd 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
@@ -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
PATCH v5 22/25 rockchip: Update binman image for new skip-at-start setup
In reply to Simon GlassNow 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
@@ -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
PATCH v5 23/25 bloblist: Temporary hacks to get VBE going
In reply to Simon GlassDo not apply.
The primary issue with the patch is that U-Boot needs to set up a bloblist in the first phase where BLOBLIST is enabled. Subsequent phases can then use that bloblist.
But the first phase of U-Boot cannot assume that one exists.
While we wait for a final decision on the bloblist implementation (and thus whether VBE can be supported), revert the changes which break VBE.
The real solution is this series, but it is blocked, at least for now:
https://patchwork.ozlabs.org/project/uboot/list/?series=456263&state=*
Note that this breaks vexpress_fvp_bloblist so that test is dropped.
---
(no changes since v1)
.gitlab-ci.yml | 14 ++--- arch/arm/lib/xferlist.c | 12 +++-- common/bloblist.c | 116 ++++++++++++---------------------------- include/bloblist.h | 16 ++---- 4 files changed, 53 insertions(+), 105 deletions(-)
.gitlab-ci.yml +7 -7
@@ -530,13 +530,13 @@ vexpress_fvp test.py: - ${DEFAULT_AMD64_TAG} <<: *buildman_and_testpy_dfn -vexpress_fvp_bloblist test.py: - variables: - TEST_PY_BD: "vexpress_fvp_bloblist" - TEST_PY_TEST_SPEC: "not sleep and not hostfs" - tags: - - ${DEFAULT_AMD64_TAG} - <<: *buildman_and_testpy_dfn +#vexpress_fvp_bloblist test.py: +# variables: +# TEST_PY_BD: "vexpress_fvp_bloblist" +# TEST_PY_TEST_SPEC: "not sleep and not hostfs" +# tags: +# - ${DEFAULT_AMD64_TAG} +# <<: *buildman_and_testpy_dfn xilinx_zynq_virt test.py: variables:
arch/arm/lib/xferlist.c +7 -5
@@ -8,16 +8,18 @@#include <bloblist.h> #include "xferlist.h" -int xferlist_from_boot_arg (ulong *addr) +int xferlist_from_boot_arg (ulong addr,ulong size) {int ret; - ret =bloblist_check_reg_conv (saved_args[0 ], saved_args[2 ], - saved_args[1 ], saved_args[3 ]); + ret =bloblist_check (saved_args[3 ], size);if (ret)return ret; - *addr =bloblist_get_base (); + ret =bloblist_check_reg_conv (saved_args[0 ], saved_args[2 ], + saved_args[1 ]); +if (ret) +return ret; -return 0 ; +return bloblist_reloc ((void *)addr, size); }
common/bloblist.c +35 -81
161 lines not on this page · raw message
include/bloblist.h +4 -12
@@ -467,8 +467,9 @@ int bloblist_reloc(void *to, uint to_size);* If CONFIG_BLOBLIST_ALLOC is selected, it allocates memory for a bloblist of * size CONFIG_BLOBLIST_SIZE. * -* If CONFIG_BLOBLIST_PASSAGE_MANDATORY is selected, bloblist in the incoming -* standard passage is mandatorily required. +* If CONFIG_BLOBLIST_PASSAGE is selected, it uses the bloblist in the incoming +* standard passage. The size is detected automatically so CONFIG_BLOBLIST_SIZE +* can be 0. * * Sets GD_FLG_BLOBLIST_READY in global_data flags on success *
@@ -500,18 +501,9 @@ static inline int bloblist_maybe_init(void)* @rfdt: Register that holds the FDT base address. * @rzero: Register that must be zero. * @rsig: Register that holds signature and register conventions version. -* @xlist: Register that holds the transfer list. * Return: 0 if OK, -EIO if the bloblist is not compliant to the register * conventions. */ -int bloblist_check_reg_conv (ulong rfdt,ulong rzero,ulong rsig,ulong xlist); - -/** -* xferlist_from_boot_arg() - Get bloblist from the boot args. -* -* @addr: Address of the bloblist -* Return: 0 if OK, else on error -*/ -int xferlist_from_boot_arg (ulong *addr); +int bloblist_check_reg_conv (ulong rfdt,ulong rzero,ulong rsig);#endif /* __BLOBLIST_H */
Signature · 1 line
2.43.0
PATCH v5 24/25 rockchip: Relocate bloblist at the end of the SPL phase
In reply to Simon GlassWhere the bloblist is located in internal memory and TF-A's BL31 blob removes access to this memory, the best option seems to be to relocate the bloblist just before running TF-A.
Do this at the end of SPL.
---
Changes in v5:
- Use 'SDRAM' instead of 'IRAM' in comment
- Drop mention of rk3399 since 64-boards always have TF-A after SPL
- Drop condition on VPL
Changes in v3:
- Add the BLOBLIST_RELOC condition as well
Changes in v2:
- Move this logic into board-specific code
arch/arm/mach-rockchip/spl.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
arch/arm/mach-rockchip/spl.c +14 -0
@@ -3,6 +3,7 @@* (C) Copyright 2019 Rockchip Electronics Co., Ltd */ +#include <bloblist.h> #include <cpu_func.h> #include <debug_uart.h> #include <dm.h>
@@ -133,6 +134,19 @@ void board_init_f(ulong dummy)void spl_board_prepare_for_boot (void ) { +/* +* TF-A is executed after SPL and before U-Boot. It removes our access +* to the SRAM. So move the bloblist to RAM. +*/ +if (xpl_phase () ==PHASE_SPL &&CONFIG_IS_ENABLED (BLOBLIST_RELOC )) { +ulong addr =CONFIG_IF_ENABLED_INT (BLOBLIST_RELOC , +BLOBLIST_RELOC_ADDR ); + +log_debug ("Relocating bloblist %p to %lx\n" ,gd_bloblist (), + addr); +bloblist_reloc (map_sysmem (addr,0 ),bloblist_get_total_size ()); + } +if (!IS_ENABLED (CONFIG_ARM64 ) ||CONFIG_IS_ENABLED (SYS_DCACHE_OFF ))return ;
Signature · 1 line
2.43.0
PATCH v5 25/25 bloblist: Allow using a different bloblist address
In reply to Simon GlassWhere the bloblist is located in internal memory and TF-A's BL31 blob removes access to this memory, the best option seems to be to relocate the bloblist just before running TF-A.
We can do the relocation in board-specific code, but need an option to pick up the correct address within U-Boot proper.
---
(no changes since v2)
Changes in v2:
- Move the actual relocation code to a previous board-specific patch
common/Kconfig | 20 ++++++++++++++++++++ common/bloblist.c | 15 ++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-)
common/Kconfig +20 -0
@@ -1157,6 +1157,26 @@ config SPL_BLOBLIST_ALLOC endchoice +config SPL_BLOBLIST_RELOC + bool "Relocate the bloblist before existing SPL" + depends on BLOBLIST_FIXED + help + Some platforms locate the bloblist in SRAM in SPL. In some cases, + the TF-A BL31 blob removes access to SRAM, e.g. with Rockchip RK3399. + + Enable this option to make U-Boot copy the bloblist from SRAM to SDRAM + before leaving SPL. + +config SPL_BLOBLIST_RELOC_ADDR + hex "Relocate the bloblist before existing SPL" + depends on SPL_BLOBLIST_RELOC + default BLOBLIST_ADDR + help + Sets the address to which the bloblist is relocated at the end of SPL. + U-Boot proper uses this address when it starts up. Note that U-Boot + always relocates the bloblist again as part of its own relocation + process. + endif # SPL_BLOBLIST if TPL_BLOBLIST
common/bloblist.c +14 -1
@@ -515,9 +515,22 @@ int bloblist_init(void) expected = fixed && !xpl_is_first_phase ();if (xpl_prev_phase () ==PHASE_TPL && !IS_ENABLED (CONFIG_TPL_BLOBLIST )) expected = false; -if (fixed) +if (fixed) { addr =IF_ENABLED_INT (CONFIG_BLOBLIST_FIXED ,CONFIG_BLOBLIST_ADDR ); + +if (xpl_phase () ==PHASE_BOARD_F && +IS_ENABLED (CONFIG_SPL_BLOBLIST_RELOC )) { +ulong addr =IF_ENABLED_INT (CONFIG_SPL_BLOBLIST_RELOC , +CONFIG_SPL_BLOBLIST_RELOC_ADDR ); + +log_debug ("Using bloblist at %lx\n" , addr); +bloblist_reloc (map_sysmem (addr,0 ), +bloblist_get_total_size ()); + } +log_debug ("bloblist addr=%lx\n" , addr); + } + size =CONFIG_BLOBLIST_SIZE ;if (expected) { ret =bloblist_check (addr, size);
Signature · 1 line
2.43.0