Skip to contentSkip to conversation

rockchip: Use external TPL binary to create a working firmware image

PATCH Superseded Jonas Karlman 4 participants 11 messages Feb 19, 2023 – Feb 25, 2023

Subsystems (4)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v4 cover rockchip: Use external TPL binary to create a working firmware image

Rockchip SoCs typically use U-Boot TPL to initialize DRAM, then jumps back to BootRom to load next stage, U-Boot SPL, into DRAM. BootRom then jumps to U-Boot SPL to continue the boot flow.

For RK356x there is no support to initialize DRAM using U-Boot TPL and instead an external TPL binary must be used to generate a bootable u-boot-rockchip.bin image.

This adds a new rockchip-tpl entry to binman and make use of this new entry in rockchip-u-boot.dtsi.

Build U-Boot with ROCKCHIP_TPL=/path/to/ddr.bin to generate a bootable u-boot-rockchip.bin image for RK356x.

I have dropped the RFC patch that was related to showing a friendly message instead of a generic file not found message when TPL blob is missing in v3. Will address that in a follow-up series.

The last patch that updates evb-rk3568_defconfig was dropped in v4. Will address that and more config options in a follow-up series.

Changes in v4:
- Only change init size limit for rk3328 and rk3568
- Drop update evb-rk3568_defconfig patch

Changes in v3:
- Move test function last
- Add help text to Kconfig option
- Add build step for rk3568 to documentation
- Resync init size limit table
- Drop missing message RFC patch

Changes in v2:
- Renamed external-tpl to rockchip-tpl
- Renamed EXTERNAL_TPL to ROCKCHIP_TPL
- Add CONFIG_ROCKCHIP_EXTERNAL_TPL Kconfig option
- New patch to sync init size limit in mkimage
- New RFC patch to improve allow-missing/fake-ext-blobs handling for binman mkimage entry

Jonas Karlman (4):
binman: Add support for a rockchip-tpl entry
rockchip: Use an external TPL binary on RK3568
Revert "board: rockchip: Fix binman_init failure on EVB-RK3568"
rockchip: mkimage: Update init size limit for RK3328 and RK3568

 Makefile                               |  1 +
 arch/arm/dts/rockchip-u-boot.dtsi      | 10 ++++++++--
 arch/arm/mach-rockchip/Kconfig         |  8 ++++++++
 configs/evb-rk3568_defconfig           |  1 -
 doc/board/rockchip/rockchip.rst        | 11 +++++++++++
 tools/binman/entries.rst               | 14 ++++++++++++++
 tools/binman/etype/rockchip_tpl.py     | 20 ++++++++++++++++++++
 tools/binman/ftest.py                  |  7 +++++++
 tools/binman/missing-blob-help         |  5 +++++
 tools/binman/test/277_rockchip_tpl.dts | 16 ++++++++++++++++
 tools/rkcommon.c                       |  4 ++--
 11 files changed, 92 insertions(+), 5 deletions(-)
 create mode 100644 tools/binman/etype/rockchip_tpl.py
 create mode 100644 tools/binman/test/277_rockchip_tpl.dts
Signature · 1 line
2.39.2
#1 lore raw

PATCH v4 1/4 binman: Add support for a rockchip-tpl entry

The rockchip-tpl entry can be used when an external TPL binary should be used instead of the normal U-Boot TPL.

---
v4:
- No change

v3:
- Move test function last
- Collect r-b and t-b tags

v2:
- Rename external-tpl to rockchip-tpl
- Missing message moved to this patch

 tools/binman/entries.rst               | 14 ++++++++++++++
 tools/binman/etype/rockchip_tpl.py     | 20 ++++++++++++++++++++
 tools/binman/ftest.py                  |  7 +++++++
 tools/binman/missing-blob-help         |  5 +++++
 tools/binman/test/277_rockchip_tpl.dts | 16 ++++++++++++++++
 5 files changed, 62 insertions(+)
 create mode 100644 tools/binman/etype/rockchip_tpl.py
 create mode 100644 tools/binman/test/277_rockchip_tpl.dts
tools/binman/entries.rst +14 -0
index 7a04a613992d..e177860a6a82 100644
@@ -1386,6 +1386,20 @@ For example, this creates an image with a pre-load header and a binary::
 
 
 
+.. _etype_rockchip_tpl:
+
+Entry: rockchip-tpl: Rockchip TPL binary
+----------------------------------------
+
+Properties / Entry arguments:
+    - rockchip-tpl-path: Filename of file to read into the entry,
+                         typically <soc>_ddr_<version>.bin
+
+This entry holds an external TPL binary used by some Rockchip SoCs
+instead of normal U-Boot TPL, typically to initialize DRAM.
+
+
+
 .. _etype_scp:
 
 Entry: scp: System Control Processor (SCP) firmware blob
tools/binman/etype/rockchip_tpl.py new file +20 -0
new file mode 100644
index 000000000000..74f58ba8570c
@@ -0,0 +1,20 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Entry-type module for Rockchip TPL binary
+#
+
+from binman.etype.blob_named_by_arg import Entry_blob_named_by_arg
+
+class Entry_rockchip_tpl(Entry_blob_named_by_arg):
+    """Rockchip TPL binary
+
+    Properties / Entry arguments:
+        - rockchip-tpl-path: Filename of file to read into the entry,
+                             typically <soc>_ddr_<version>.bin
+
+    This entry holds an external TPL binary used by some Rockchip SoCs
+    instead of normal U-Boot TPL, typically to initialize DRAM.
+    """
+    def __init__(self, section, etype, node):
+        super().__init__(section, etype, node, 'rockchip-tpl')
+        self.external = True
tools/binman/ftest.py +7 -0
index 062f54adb0ed..48ac1540bfd8 100644
@@ -90,6 +90,7 @@ TEE_OS_DATA           = b'this is some tee OS data'
 ATF_BL2U_DATA         = b'bl2u'
 OPENSBI_DATA          = b'opensbi'
 SCP_DATA              = b'scp'
+ROCKCHIP_TPL_DATA     = b'rockchip-tpl'
 TEST_FDT1_DATA        = b'fdt1'
 TEST_FDT2_DATA        = b'test-fdt2'
 ENV_DATA              = b'var1=1\nvar2="2"'
@@ -205,6 +206,7 @@ class TestFunctional(unittest.TestCase):
         TestFunctional._MakeInputFile('bl2u.bin', ATF_BL2U_DATA)
         TestFunctional._MakeInputFile('fw_dynamic.bin', OPENSBI_DATA)
         TestFunctional._MakeInputFile('scp.bin', SCP_DATA)
+        TestFunctional._MakeInputFile('rockchip-tpl.bin', ROCKCHIP_TPL_DATA)
 
         # Add a few .dtb files for testing
         TestFunctional._MakeInputFile('%s/test-fdt1.dtb' % TEST_FDT_SUBDIR,
@@ -6386,6 +6388,11 @@ fdt         fdtmap                Extract the devicetree blob from the fdtmap
         self.assertEqual(['u-boot', 'atf-2'],
                          fdt_util.GetStringList(node, 'loadables'))
 
+    def testPackRockchipTpl(self):
+        """Test that an image with a Rockchip TPL binary can be created"""
+        data = self._DoReadFile('277_rockchip_tpl.dts')
+        self.assertEqual(ROCKCHIP_TPL_DATA, data[:len(ROCKCHIP_TPL_DATA)])
+
 
 if __name__ == "__main__":
     unittest.main()
tools/binman/missing-blob-help +5 -0
index 4448ac93112a..f3a44d08acce 100644
@@ -34,6 +34,11 @@ If CONFIG_WDT_K3_RTI_LOAD_FW is enabled, a firmware image is needed for
 the R5F core(s) to trigger the system reset. One possible source is
 https://github.com/siemens/k3-rti-wdt.
 
+rockchip-tpl:
+An external TPL is required to initialize DRAM. Get the external TPL
+binary and build with ROCKCHIP_TPL=/path/to/ddr.bin. One possible source
+for the external TPL binary is https://github.com/rockchip-linux/rkbin.
+
 tee-os:
 See the documentation for your board. You may need to build Open Portable
 Trusted Execution Environment (OP-TEE) with TEE=/path/to/tee.bin
tools/binman/test/277_rockchip_tpl.dts new file +16 -0
new file mode 100644
index 000000000000..269f56e2545c
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/dts-v1/;
+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	binman {
+		size = <16>;
+
+		rockchip-tpl {
+			filename = "rockchip-tpl.bin";
+		};
+	};
+};
Signature · 1 line
2.39.2
#2 lore raw

PATCH v4 2/4 rockchip: Use an external TPL binary on RK3568

In reply to Jonas Karlman

Rockchip SoCs typically use U-Boot TPL to initialize DRAM, then jumps back to BootRom to load next stage, U-Boot SPL, into DRAM. BootRom then jumps to U-Boot SPL to continue the normal boot flow.

However, there is no support to initialize DRAM on RK35xx SoCs using U-Boot TPL and instead an external TPL binary must be used to generate a bootable u-boot-rockchip.bin image.

Add CONFIG_ROCKCHIP_EXTERNAL_TPL to indicate that an external TPL should be used. Build U-Boot with ROCKCHIP_TPL=/path/to/ddr.bin to generate a bootable u-boot-rockchip.bin image for RK3568.

---
v4:
- No change

v3:
- Add help text to Kconfig option
- Add build step for rk3568 to documentation
- Collect r-b and t-b tags

v2:
- Rename external-tpl-path to rockchip-tpl-path
- Rename EXTERNAL_TPL to ROCKCHIP_TPL
- Add CONFIG_ROCKCHIP_EXTERNAL_TPL option

 Makefile                          |  1 +
 arch/arm/dts/rockchip-u-boot.dtsi | 10 ++++++++--
 arch/arm/mach-rockchip/Kconfig    |  8 ++++++++
 doc/board/rockchip/rockchip.rst   | 11 +++++++++++
 4 files changed, 28 insertions(+), 2 deletions(-)
Makefile +1 -0
index 54f894dab841..58f8c7a35335 100644
@@ -1335,6 +1335,7 @@ cmd_binman = $(srctree)/tools/binman/binman $(if $(BINMAN_DEBUG),-D) \
 		-a opensbi-path=${OPENSBI} \
 		-a default-dt=$(default_dt) \
 		-a scp-path=$(SCP) \
+		-a rockchip-tpl-path=$(ROCKCHIP_TPL) \
 		-a spl-bss-pad=$(if $(CONFIG_SPL_SEPARATE_BSS),,1) \
 		-a tpl-bss-pad=$(if $(CONFIG_TPL_SEPARATE_BSS),,1) \
 		-a spl-dtb=$(CONFIG_SPL_OF_REAL) \
arch/arm/dts/rockchip-u-boot.dtsi +8 -2
index 6c662a72d4f9..2878b80926c4 100644
@@ -20,9 +20,12 @@
 		mkimage {
 			filename = "idbloader.img";
 			args = "-n", CONFIG_SYS_SOC, "-T", "rksd";
-#ifdef CONFIG_TPL
 			multiple-data-files;
 
+#ifdef CONFIG_ROCKCHIP_EXTERNAL_TPL
+			rockchip-tpl {
+			};
+#elif defined(CONFIG_TPL)
 			u-boot-tpl {
 			};
 #endif
@@ -134,9 +137,12 @@
 		mkimage {
 			filename = "idbloader-spi.img";
 			args = "-n", CONFIG_SYS_SOC, "-T", "rkspi";
-#ifdef CONFIG_TPL
 			multiple-data-files;
 
+#ifdef CONFIG_ROCKCHIP_EXTERNAL_TPL
+			rockchip-tpl {
+			};
+#elif defined(CONFIG_TPL)
 			u-boot-tpl {
 			};
 #endif
arch/arm/mach-rockchip/Kconfig +8 -0
index b678ec41318e..0b191b364264 100644
@@ -401,6 +401,14 @@ 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 ROCKCHIP_EXTERNAL_TPL
+	bool "Use external TPL binary"
+	default y if ROCKCHIP_RK3568
+	help
+	  Some Rockchip SoCs require an external TPL to initialize DRAM.
+	  Enable this option and build with ROCKCHIP_TPL=/path/to/ddr.bin to
+	  include the external TPL in the image built by binman.
+
 config ROCKCHIP_BOOT_MODE_REG
 	hex "Rockchip boot mode flag register address"
 	help
doc/board/rockchip/rockchip.rst +11 -0
index 28c837a38200..ac4dcce1a77d 100644
@@ -86,6 +86,8 @@ List of mainline supported Rockchip boards:
      - Radxa ROCK Pi 4 (rock-pi-4-rk3399)
      - Rockchip Evb-RK3399 (evb_rk3399)
      - Theobroma Systems RK3399-Q7 SoM - Puma (puma_rk3399)
+* rk3568
+     - Rockchip Evb-RK3568 (evb-rk3568)
 * rv1108
      - Rockchip Evb-rv1108 (evb-rv1108)
      - Elgin-R1 (elgin-rv1108)
@@ -167,6 +169,15 @@ To build rk3399 boards:
         make evb-rk3399_defconfig
         make CROSS_COMPILE=aarch64-linux-gnu-
 
+To build rk3568 boards:
+
+.. code-block:: bash
+
+        export BL31=../rkbin/bin/rk35/rk3568_bl31_v1.34.elf
+        export ROCKCHIP_TPL=../rkbin/bin/rk35/rk3568_ddr_1560MHz_v1.13.bin
+        make evb-rk3568_defconfig
+        make CROSS_COMPILE=aarch64-linux-gnu-
+
 Flashing
 --------
 
Signature · 1 line
2.39.2
#3 lore raw

Re: [PATCH v4 2/4] rockchip: Use an external TPL binary on RK3568

Hi Jonas, Simon,

    I got below error in buildman with BINMAN_ALLOW_MISSING=1

Building current source for 1 boards (1 thread, 16 jobs per thread)
   aarch64:  +   evb-rk3568
+binman: Filename 'rockchip-tpl' bbb not found in input path (.,/home/kever/src/u-boot,board/rockchip/evb_rk3568,arch/arm/dts) (cwd='/home/kever/src/.bm-work/00/build') +make[1]: *** [Makefile:1107: .binman_stamp] Error 1
+make: *** [Makefile:177: sub-make] Error 2

    It should be like atf-bl31, only below warining is output, anything is missing?

Building current source for 1 boards (1 thread, 16 jobs per thread) aarch64:  w+   evb-rk3399
+Image 'simple-bin' aaais missing external blobs and is non-functional: atf-bl31 +
+/binman/simple-bin/fit/images/@atf-SEQ/atf-bl31:
+   See the documentation for your board. You may need to build ARM Trusted +   Firmware and build with BL31=/path/to/bl31.bin
+Some images are invalid
    0    1    0 /1              evb-rk3399

Thanks,

- Kever

Quoted 128 lines · Jonas Karlman

Rockchip SoCs typically use U-Boot TPL to initialize DRAM, then jumps back to BootRom to load next stage, U-Boot SPL, into DRAM. BootRom then jumps to U-Boot SPL to continue the normal boot flow.

However, there is no support to initialize DRAM on RK35xx SoCs using U-Boot TPL and instead an external TPL binary must be used to generate a bootable u-boot-rockchip.bin image.

Add CONFIG_ROCKCHIP_EXTERNAL_TPL to indicate that an external TPL should be used. Build U-Boot with ROCKCHIP_TPL=/path/to/ddr.bin to generate a bootable u-boot-rockchip.bin image for RK3568.

---
v4:
- No change

v3:
- Add help text to Kconfig option
- Add build step for rk3568 to documentation
- Collect r-b and t-b tags

v2:
- Rename external-tpl-path to rockchip-tpl-path
- Rename EXTERNAL_TPL to ROCKCHIP_TPL
- Add CONFIG_ROCKCHIP_EXTERNAL_TPL option

  Makefile                          |  1 +
  arch/arm/dts/rockchip-u-boot.dtsi | 10 ++++++++--
  arch/arm/mach-rockchip/Kconfig    |  8 ++++++++
  doc/board/rockchip/rockchip.rst   | 11 +++++++++++
  4 files changed, 28 insertions(+), 2 deletions(-)
Makefile +1 -0
index 54f894dab841..58f8c7a35335 100644
@@ -1335,6 +1335,7 @@ cmd_binman = $(srctree)/tools/binman/binman $(if $(BINMAN_DEBUG),-D) \
  		-a opensbi-path=${OPENSBI} \
  		-a default-dt=$(default_dt) \
  		-a scp-path=$(SCP) \
+		-a rockchip-tpl-path=$(ROCKCHIP_TPL) \
  		-a spl-bss-pad=$(if $(CONFIG_SPL_SEPARATE_BSS),,1) \
  		-a tpl-bss-pad=$(if $(CONFIG_TPL_SEPARATE_BSS),,1) \
  		-a spl-dtb=$(CONFIG_SPL_OF_REAL) \
arch/arm/dts/rockchip-u-boot.dtsi +8 -2
index 6c662a72d4f9..2878b80926c4 100644
@@ -20,9 +20,12 @@
  		mkimage {
  			filename = "idbloader.img";
  			args = "-n", CONFIG_SYS_SOC, "-T", "rksd";
-#ifdef CONFIG_TPL
  			multiple-data-files;
 
+#ifdef CONFIG_ROCKCHIP_EXTERNAL_TPL
+			rockchip-tpl {
+			};
+#elif defined(CONFIG_TPL)
  			u-boot-tpl {
  			};
  #endif
@@ -134,9 +137,12 @@
  		mkimage {
  			filename = "idbloader-spi.img";
  			args = "-n", CONFIG_SYS_SOC, "-T", "rkspi";
-#ifdef CONFIG_TPL
  			multiple-data-files;
 
+#ifdef CONFIG_ROCKCHIP_EXTERNAL_TPL
+			rockchip-tpl {
+			};
+#elif defined(CONFIG_TPL)
  			u-boot-tpl {
  			};
  #endif
arch/arm/mach-rockchip/Kconfig +8 -0
index b678ec41318e..0b191b364264 100644
@@ -401,6 +401,14 @@ 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 ROCKCHIP_EXTERNAL_TPL
+	bool "Use external TPL binary"
+	default y if ROCKCHIP_RK3568
+	help
+	  Some Rockchip SoCs require an external TPL to initialize DRAM.
+	  Enable this option and build with ROCKCHIP_TPL=/path/to/ddr.bin to
+	  include the external TPL in the image built by binman.
+
  config ROCKCHIP_BOOT_MODE_REG
  	hex "Rockchip boot mode flag register address"
  	help
doc/board/rockchip/rockchip.rst +11 -0
index 28c837a38200..ac4dcce1a77d 100644
@@ -86,6 +86,8 @@ List of mainline supported Rockchip boards:
       - Radxa ROCK Pi 4 (rock-pi-4-rk3399)
       - Rockchip Evb-RK3399 (evb_rk3399)
       - Theobroma Systems RK3399-Q7 SoM - Puma (puma_rk3399)
+* rk3568
+     - Rockchip Evb-RK3568 (evb-rk3568)
  * rv1108
       - Rockchip Evb-rv1108 (evb-rv1108)
       - Elgin-R1 (elgin-rv1108)
@@ -167,6 +169,15 @@ To build rk3399 boards:
          make evb-rk3399_defconfig
          make CROSS_COMPILE=aarch64-linux-gnu-
 
+To build rk3568 boards:
+
+.. code-block:: bash
+
+        export BL31=../rkbin/bin/rk35/rk3568_bl31_v1.34.elf
+        export ROCKCHIP_TPL=../rkbin/bin/rk35/rk3568_ddr_1560MHz_v1.13.bin
+        make evb-rk3568_defconfig
+        make CROSS_COMPILE=aarch64-linux-gnu-
+
  Flashing
  --------
 
#4 lore raw

Re: [PATCH v4 2/4] rockchip: Use an external TPL binary on RK3568

Hi Kever,

Quoted 13 lines · Kever Yang

Hi Jonas, Simon,

    I got below error in buildman with BINMAN_ALLOW_MISSING=1

Building current source for 1 boards (1 thread, 16 jobs per thread)
   aarch64:  +   evb-rk3568
+binman: Filename 'rockchip-tpl' bbb not found in input path (.,/home/kever/src/u-boot,board/rockchip/evb_rk3568,arch/arm/dts) (cwd='/home/kever/src/.bm-work/00/build')

(quoted diff) +2 -0
+make[1]: *** [Makefile:1107: .binman_stamp] Error 1
+make: *** [Makefile:177: sub-make] Error 2
 
     It should be like atf-bl31, only below warining is output, anything 
Quoted 1 line

is missing?

This is a known issue, builds only work with ROCKCHIP_TPL/rockchip-tpl-path defined, the allow-missing flag is not fully functional for the mkimage entry in binman. Fixing that issue grew into its own series, see [1].

[1] https://patchwork.ozlabs.org/project/uboot/cover/[email protected]/

Regards,
Jonas

Quoted 145 lines

Building current source for 1 boards (1 thread, 16 jobs per thread)
   aarch64:  w+   evb-rk3399
+Image 'simple-bin' aaais missing external blobs and is non-functional:
atf-bl31

(quoted diff) +5 -0
+
+/binman/simple-bin/fit/images/@atf-SEQ/atf-bl31:
+   See the documentation for your board. You may need to build ARM Trusted
+   Firmware and build with BL31=/path/to/bl31.bin
+Some images are invalid
     0    1    0 /1              evb-rk3399

Thanks,

- Kever

Quoted 128 lines · Jonas Karlman

Rockchip SoCs typically use U-Boot TPL to initialize DRAM, then jumps back to BootRom to load next stage, U-Boot SPL, into DRAM. BootRom then jumps to U-Boot SPL to continue the normal boot flow.

However, there is no support to initialize DRAM on RK35xx SoCs using U-Boot TPL and instead an external TPL binary must be used to generate a bootable u-boot-rockchip.bin image.

Add CONFIG_ROCKCHIP_EXTERNAL_TPL to indicate that an external TPL should be used. Build U-Boot with ROCKCHIP_TPL=/path/to/ddr.bin to generate a bootable u-boot-rockchip.bin image for RK3568.

---
v4:
- No change

v3:
- Add help text to Kconfig option
- Add build step for rk3568 to documentation
- Collect r-b and t-b tags

v2:
- Rename external-tpl-path to rockchip-tpl-path
- Rename EXTERNAL_TPL to ROCKCHIP_TPL
- Add CONFIG_ROCKCHIP_EXTERNAL_TPL option

  Makefile                          |  1 +
  arch/arm/dts/rockchip-u-boot.dtsi | 10 ++++++++--
  arch/arm/mach-rockchip/Kconfig    |  8 ++++++++
  doc/board/rockchip/rockchip.rst   | 11 +++++++++++
  4 files changed, 28 insertions(+), 2 deletions(-)
Makefile +1 -0
index 54f894dab841..58f8c7a35335 100644
@@ -1335,6 +1335,7 @@ cmd_binman = $(srctree)/tools/binman/binman $(if $(BINMAN_DEBUG),-D) \
  		-a opensbi-path=${OPENSBI} \
  		-a default-dt=$(default_dt) \
  		-a scp-path=$(SCP) \
+		-a rockchip-tpl-path=$(ROCKCHIP_TPL) \
  		-a spl-bss-pad=$(if $(CONFIG_SPL_SEPARATE_BSS),,1) \
  		-a tpl-bss-pad=$(if $(CONFIG_TPL_SEPARATE_BSS),,1) \
  		-a spl-dtb=$(CONFIG_SPL_OF_REAL) \
arch/arm/dts/rockchip-u-boot.dtsi +8 -2
index 6c662a72d4f9..2878b80926c4 100644
@@ -20,9 +20,12 @@
  		mkimage {
  			filename = "idbloader.img";
  			args = "-n", CONFIG_SYS_SOC, "-T", "rksd";
-#ifdef CONFIG_TPL
  			multiple-data-files;
 
+#ifdef CONFIG_ROCKCHIP_EXTERNAL_TPL
+			rockchip-tpl {
+			};
+#elif defined(CONFIG_TPL)
  			u-boot-tpl {
  			};
  #endif
@@ -134,9 +137,12 @@
  		mkimage {
  			filename = "idbloader-spi.img";
  			args = "-n", CONFIG_SYS_SOC, "-T", "rkspi";
-#ifdef CONFIG_TPL
  			multiple-data-files;
 
+#ifdef CONFIG_ROCKCHIP_EXTERNAL_TPL
+			rockchip-tpl {
+			};
+#elif defined(CONFIG_TPL)
  			u-boot-tpl {
  			};
  #endif
arch/arm/mach-rockchip/Kconfig +8 -0
index b678ec41318e..0b191b364264 100644
@@ -401,6 +401,14 @@ 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 ROCKCHIP_EXTERNAL_TPL
+	bool "Use external TPL binary"
+	default y if ROCKCHIP_RK3568
+	help
+	  Some Rockchip SoCs require an external TPL to initialize DRAM.
+	  Enable this option and build with ROCKCHIP_TPL=/path/to/ddr.bin to
+	  include the external TPL in the image built by binman.
+
  config ROCKCHIP_BOOT_MODE_REG
  	hex "Rockchip boot mode flag register address"
  	help
doc/board/rockchip/rockchip.rst +11 -0
index 28c837a38200..ac4dcce1a77d 100644
@@ -86,6 +86,8 @@ List of mainline supported Rockchip boards:
       - Radxa ROCK Pi 4 (rock-pi-4-rk3399)
       - Rockchip Evb-RK3399 (evb_rk3399)
       - Theobroma Systems RK3399-Q7 SoM - Puma (puma_rk3399)
+* rk3568
+     - Rockchip Evb-RK3568 (evb-rk3568)
  * rv1108
       - Rockchip Evb-rv1108 (evb-rv1108)
       - Elgin-R1 (elgin-rv1108)
@@ -167,6 +169,15 @@ To build rk3399 boards:
          make evb-rk3399_defconfig
          make CROSS_COMPILE=aarch64-linux-gnu-
 
+To build rk3568 boards:
+
+.. code-block:: bash
+
+        export BL31=../rkbin/bin/rk35/rk3568_bl31_v1.34.elf
+        export ROCKCHIP_TPL=../rkbin/bin/rk35/rk3568_ddr_1560MHz_v1.13.bin
+        make evb-rk3568_defconfig
+        make CROSS_COMPILE=aarch64-linux-gnu-
+
  Flashing
  --------
 
#5 lore raw

Re: [PATCH v4 2/4] rockchip: Use an external TPL binary on RK3568

Quoted 14 lines · Jonas Karlman

Hi Kever,

Quoted 12 lines · Kever Yang

Hi Jonas, Simon,

    I got below error in buildman with BINMAN_ALLOW_MISSING=1

Building current source for 1 boards (1 thread, 16 jobs per thread)
   aarch64:  +   evb-rk3568
+binman: Filename 'rockchip-tpl' bbb not found in input path (.,/home/kever/src/u-boot,board/rockchip/evb_rk3568,arch/arm/dts) (cwd='/home/kever/src/.bm-work/00/build')

(quoted diff) +2 -0
+make[1]: *** [Makefile:1107: .binman_stamp] Error 1
+make: *** [Makefile:177: sub-make] Error 2
Quoted 6 lines
Quoted 2 lines

    It should be like atf-bl31, only below warining is output, anything
is missing?

This is a known issue, builds only work with ROCKCHIP_TPL/rockchip-tpl-path defined, the allow-missing flag is not fully functional for the mkimage entry in binman. Fixing that issue grew into its own series, see [1].

I have just sent out a v5 that includes the required parts of [1] to solve the issue with allow-missing flag, hopefully the CI pipeline can succeed with the required parts moved back to this series.

Regards,
Jonas

Quoted 152 lines

[1] https://patchwork.ozlabs.org/project/uboot/cover/[email protected]/

Regards,
Jonas

Quoted 145 lines

Building current source for 1 boards (1 thread, 16 jobs per thread)
   aarch64:  w+   evb-rk3399
+Image 'simple-bin' aaais missing external blobs and is non-functional:
atf-bl31

(quoted diff) +5 -0
+
+/binman/simple-bin/fit/images/@atf-SEQ/atf-bl31:
+   See the documentation for your board. You may need to build ARM Trusted
+   Firmware and build with BL31=/path/to/bl31.bin
+Some images are invalid
     0    1    0 /1              evb-rk3399

Thanks,

- Kever

Quoted 128 lines · Jonas Karlman

Rockchip SoCs typically use U-Boot TPL to initialize DRAM, then jumps back to BootRom to load next stage, U-Boot SPL, into DRAM. BootRom then jumps to U-Boot SPL to continue the normal boot flow.

However, there is no support to initialize DRAM on RK35xx SoCs using U-Boot TPL and instead an external TPL binary must be used to generate a bootable u-boot-rockchip.bin image.

Add CONFIG_ROCKCHIP_EXTERNAL_TPL to indicate that an external TPL should be used. Build U-Boot with ROCKCHIP_TPL=/path/to/ddr.bin to generate a bootable u-boot-rockchip.bin image for RK3568.

---
v4:
- No change

v3:
- Add help text to Kconfig option
- Add build step for rk3568 to documentation
- Collect r-b and t-b tags

v2:
- Rename external-tpl-path to rockchip-tpl-path
- Rename EXTERNAL_TPL to ROCKCHIP_TPL
- Add CONFIG_ROCKCHIP_EXTERNAL_TPL option

  Makefile                          |  1 +
  arch/arm/dts/rockchip-u-boot.dtsi | 10 ++++++++--
  arch/arm/mach-rockchip/Kconfig    |  8 ++++++++
  doc/board/rockchip/rockchip.rst   | 11 +++++++++++
  4 files changed, 28 insertions(+), 2 deletions(-)
Makefile +1 -0
index 54f894dab841..58f8c7a35335 100644
@@ -1335,6 +1335,7 @@ cmd_binman = $(srctree)/tools/binman/binman $(if $(BINMAN_DEBUG),-D) \
  		-a opensbi-path=${OPENSBI} \
  		-a default-dt=$(default_dt) \
  		-a scp-path=$(SCP) \
+		-a rockchip-tpl-path=$(ROCKCHIP_TPL) \
  		-a spl-bss-pad=$(if $(CONFIG_SPL_SEPARATE_BSS),,1) \
  		-a tpl-bss-pad=$(if $(CONFIG_TPL_SEPARATE_BSS),,1) \
  		-a spl-dtb=$(CONFIG_SPL_OF_REAL) \
arch/arm/dts/rockchip-u-boot.dtsi +8 -2
index 6c662a72d4f9..2878b80926c4 100644
@@ -20,9 +20,12 @@
  		mkimage {
  			filename = "idbloader.img";
  			args = "-n", CONFIG_SYS_SOC, "-T", "rksd";
-#ifdef CONFIG_TPL
  			multiple-data-files;
 
+#ifdef CONFIG_ROCKCHIP_EXTERNAL_TPL
+			rockchip-tpl {
+			};
+#elif defined(CONFIG_TPL)
  			u-boot-tpl {
  			};
  #endif
@@ -134,9 +137,12 @@
  		mkimage {
  			filename = "idbloader-spi.img";
  			args = "-n", CONFIG_SYS_SOC, "-T", "rkspi";
-#ifdef CONFIG_TPL
  			multiple-data-files;
 
+#ifdef CONFIG_ROCKCHIP_EXTERNAL_TPL
+			rockchip-tpl {
+			};
+#elif defined(CONFIG_TPL)
  			u-boot-tpl {
  			};
  #endif
arch/arm/mach-rockchip/Kconfig +8 -0
index b678ec41318e..0b191b364264 100644
@@ -401,6 +401,14 @@ 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 ROCKCHIP_EXTERNAL_TPL
+	bool "Use external TPL binary"
+	default y if ROCKCHIP_RK3568
+	help
+	  Some Rockchip SoCs require an external TPL to initialize DRAM.
+	  Enable this option and build with ROCKCHIP_TPL=/path/to/ddr.bin to
+	  include the external TPL in the image built by binman.
+
  config ROCKCHIP_BOOT_MODE_REG
  	hex "Rockchip boot mode flag register address"
  	help
doc/board/rockchip/rockchip.rst +11 -0
index 28c837a38200..ac4dcce1a77d 100644
@@ -86,6 +86,8 @@ List of mainline supported Rockchip boards:
       - Radxa ROCK Pi 4 (rock-pi-4-rk3399)
       - Rockchip Evb-RK3399 (evb_rk3399)
       - Theobroma Systems RK3399-Q7 SoM - Puma (puma_rk3399)
+* rk3568
+     - Rockchip Evb-RK3568 (evb-rk3568)
  * rv1108
       - Rockchip Evb-rv1108 (evb-rv1108)
       - Elgin-R1 (elgin-rv1108)
@@ -167,6 +169,15 @@ To build rk3399 boards:
          make evb-rk3399_defconfig
          make CROSS_COMPILE=aarch64-linux-gnu-
 
+To build rk3568 boards:
+
+.. code-block:: bash
+
+        export BL31=../rkbin/bin/rk35/rk3568_bl31_v1.34.elf
+        export ROCKCHIP_TPL=../rkbin/bin/rk35/rk3568_ddr_1560MHz_v1.13.bin
+        make evb-rk3568_defconfig
+        make CROSS_COMPILE=aarch64-linux-gnu-
+
  Flashing
  --------
 
#6 lore raw

PATCH v4 3/4 Revert "board: rockchip: Fix binman_init failure on EVB-RK3568"

In reply to Jonas Karlman

An external TPL binary is now expected to be provided using ROCKCHIP_TPL when building RK3568 targets.

This reverts commit 31500e7bcfaca08ab7c2879f502a6cf852410244.

---
v4:
- No change

v3:
- Collect r-b tag

v2:
- Collect r-b tag

 configs/evb-rk3568_defconfig | 1 -
 1 file changed, 1 deletion(-)
configs/evb-rk3568_defconfig +0 -1
index c7e0e5a796f4..0f72925b3a32 100644
@@ -65,5 +65,4 @@ CONFIG_BAUDRATE=1500000
 CONFIG_DEBUG_UART_SHIFT=2
 CONFIG_SYS_NS16550_MEM32=y
 CONFIG_SYSRESET=y
-# CONFIG_BINMAN_FDT is not set
 CONFIG_ERRNO_STR=y
Signature · 1 line
2.39.2
#7 lore raw

PATCH v4 4/4 rockchip: mkimage: Update init size limit for RK3328 and RK3568

In reply to Jonas Karlman

Latest vendor TPL for RK3328 has grown past the current init size limit of 28KiB and the current init size limit for RK3568 of 76KiB is too big to fit in 64KiB SRAM.

Sync init size limit from vendor u-boot for the following SoCs:

rk3328: 30KiB (+2KiB)
rk3568: 60KiB (-16KiB)

This makes it possible to use latest vendor TPL on RK3328 without getting a size limit error running the mkimage command.

---
v4:
- Only change limit for rk3328 and rk3568

v3:
- Sync with vendor u-boot as-is
- Update commit message to include size changes

v2:
- New patch

 tools/rkcommon.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/rkcommon.c +2 -2
index 1f1eaa16752b..0d29110a4dec 100644
@@ -129,12 +129,12 @@ static struct spl_info spl_infos[] = {
 	{ "rk322x", "RK32", 0x8000 - 0x1000, false, RK_HEADER_V1 },
 	{ "rk3288", "RK32", 0x8000, false, RK_HEADER_V1 },
 	{ "rk3308", "RK33", 0x40000 - 0x1000, false, RK_HEADER_V1 },
-	{ "rk3328", "RK32", 0x8000 - 0x1000, false, RK_HEADER_V1 },
+	{ "rk3328", "RK32", 0x8000 - 0x800, false, RK_HEADER_V1 },
 	{ "rk3368", "RK33", 0x8000 - 0x1000, false, RK_HEADER_V1 },
 	{ "rk3399", "RK33", 0x30000 - 0x2000, false, RK_HEADER_V1 },
 	{ "rv1108", "RK11", 0x1800, false, RK_HEADER_V1 },
 	{ "rv1126", "110B", 0x10000 - 0x1000, false, RK_HEADER_V1 },
-	{ "rk3568", "RK35", 0x14000 - 0x1000, false, RK_HEADER_V2 },
+	{ "rk3568", "RK35", 0x10000 - 0x1000, false, RK_HEADER_V2 },
 };
 
 /**
Signature · 1 line
2.39.2
#8 lore raw

Re: [PATCH v4 4/4] rockchip: mkimage: Update init size limit for RK3328 and RK3568

Hi Jonas,

Quoted 6 lines · Jonas Karlman

Latest vendor TPL for RK3328 has grown past the current init size limit of 28KiB and the current init size limit for RK3568 of 76KiB is too big to fit in 64KiB SRAM.

Sync init size limit from vendor u-boot for the following SoCs:

Quoted 7 lines

rk3328: 30KiB (+2KiB)
rk3568: 60KiB (-16KiB)

This makes it possible to use latest vendor TPL on RK3328 without getting a size limit error running the mkimage command.

I don't have any feedback on the content of the patchset other than it'd make sense to have this one split in two commits, one for each SoC so that in the event we need to revert one we don't revert the other at the same time.

Cheers,
Quentin

Reviewed-by on v4 4/4
#9 lore raw

Re: [PATCH v4 4/4] rockchip: mkimage: Update init size limit for RK3328 and RK3568

In reply to Jonas Karlman
Quoted 6 lines · Jonas Karlman

Latest vendor TPL for RK3328 has grown past the current init size limit of 28KiB and the current init size limit for RK3568 of 76KiB is too big to fit in 64KiB SRAM.

Sync init size limit from vendor u-boot for the following SoCs:

Quoted 7 lines

rk3328: 30KiB (+2KiB)
rk3568: 60KiB (-16KiB)

This makes it possible to use latest vendor TPL on RK3328 without getting a size limit error running the mkimage command.

Thanks,
- Kever

Quoted 33 lines

---
v4:
- Only change limit for rk3328 and rk3568

v3:
- Sync with vendor u-boot as-is
- Update commit message to include size changes

v2:
- New patch

  tools/rkcommon.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
tools/rkcommon.c +2 -2
index 1f1eaa16752b..0d29110a4dec 100644
@@ -129,12 +129,12 @@ static struct spl_info spl_infos[] = {
  	{ "rk322x", "RK32", 0x8000 - 0x1000, false, RK_HEADER_V1 },
  	{ "rk3288", "RK32", 0x8000, false, RK_HEADER_V1 },
  	{ "rk3308", "RK33", 0x40000 - 0x1000, false, RK_HEADER_V1 },
-	{ "rk3328", "RK32", 0x8000 - 0x1000, false, RK_HEADER_V1 },
+	{ "rk3328", "RK32", 0x8000 - 0x800, false, RK_HEADER_V1 },
  	{ "rk3368", "RK33", 0x8000 - 0x1000, false, RK_HEADER_V1 },
  	{ "rk3399", "RK33", 0x30000 - 0x2000, false, RK_HEADER_V1 },
  	{ "rv1108", "RK11", 0x1800, false, RK_HEADER_V1 },
  	{ "rv1126", "110B", 0x10000 - 0x1000, false, RK_HEADER_V1 },
-	{ "rk3568", "RK35", 0x14000 - 0x1000, false, RK_HEADER_V2 },
+	{ "rk3568", "RK35", 0x10000 - 0x1000, false, RK_HEADER_V2 },
  };
 
  /**
Tested-by on the v4 series
#10 lore raw
In reply to Jonas Karlman

Hi,

tested this series on top of 2023.04-rc2 on bananapi r2, works well if i disable CONFIG_OF_SYSTEM_SETUP

else i get this error:

LD u-boot
aarch64-linux-gnu-ld.bfd: boot/image-fdt.o: in function `image_setup_libfdt':
/media/data_nvme/git/uboot/u-boot/boot/image-fdt.c:661: undefined reference to ft_system_setup' aarch64-linux-gnu-ld.bfd: cmd/fdt.o: in function do_fdt':
/media/data_nvme/git/uboot/u-boot/cmd/fdt.c:272: undefined reference to `ft_system_setup' Segmentation fault (core dumped)
make: *** [Makefile:1753: u-boot] Error 139
make: *** Deleting file 'u-boot'
build failed!

because there is no implementation for this function for rockchip:

https://elixir.bootlin.com/u-boot/v2023.04-rc2/C/ident/ft_system_setup

i had this option set in my defconfig from 2022-04 before it was broken by binman patches, but do not remember why i have added it.

but basicly it works again, so

regards Frank

Quoted 71 lines

Gesendet: Sonntag, 19. Februar 2023 um 16:06 Uhr
Von: "Jonas Karlman" <[email protected]>
An: "Simon Glass" <[email protected]>, "Philipp Tomsich" <[email protected]>, "Kever Yang" <[email protected]>, "Joseph Chen" <[email protected]>, "Alper Nebi Yasak" <[email protected]>
Cc: "Quentin Schulz" <[email protected]>, "Jagan Teki" <[email protected]>, "Heinrich Schuchardt" <[email protected]>, [email protected], "Jonas Karlman" <[email protected]>
Betreff: [PATCH v4 0/4] rockchip: Use external TPL binary to create a working firmware image

Rockchip SoCs typically use U-Boot TPL to initialize DRAM, then jumps back to BootRom to load next stage, U-Boot SPL, into DRAM. BootRom then jumps to U-Boot SPL to continue the boot flow.

For RK356x there is no support to initialize DRAM using U-Boot TPL and instead an external TPL binary must be used to generate a bootable u-boot-rockchip.bin image.

This adds a new rockchip-tpl entry to binman and make use of this new entry in rockchip-u-boot.dtsi.

Build U-Boot with ROCKCHIP_TPL=/path/to/ddr.bin to generate a bootable u-boot-rockchip.bin image for RK356x.

I have dropped the RFC patch that was related to showing a friendly message instead of a generic file not found message when TPL blob is missing in v3. Will address that in a follow-up series.

The last patch that updates evb-rk3568_defconfig was dropped in v4. Will address that and more config options in a follow-up series.

Changes in v4:
- Only change init size limit for rk3328 and rk3568
- Drop update evb-rk3568_defconfig patch

Changes in v3:
- Move test function last
- Add help text to Kconfig option
- Add build step for rk3568 to documentation
- Resync init size limit table
- Drop missing message RFC patch

Changes in v2:
- Renamed external-tpl to rockchip-tpl
- Renamed EXTERNAL_TPL to ROCKCHIP_TPL
- Add CONFIG_ROCKCHIP_EXTERNAL_TPL Kconfig option
- New patch to sync init size limit in mkimage
- New RFC patch to improve allow-missing/fake-ext-blobs handling for binman mkimage entry

Jonas Karlman (4):
binman: Add support for a rockchip-tpl entry
rockchip: Use an external TPL binary on RK3568
Revert "board: rockchip: Fix binman_init failure on EVB-RK3568"
rockchip: mkimage: Update init size limit for RK3328 and RK3568

 Makefile                               |  1 +
 arch/arm/dts/rockchip-u-boot.dtsi      | 10 ++++++++--
 arch/arm/mach-rockchip/Kconfig         |  8 ++++++++
 configs/evb-rk3568_defconfig           |  1 -
 doc/board/rockchip/rockchip.rst        | 11 +++++++++++
 tools/binman/entries.rst               | 14 ++++++++++++++
 tools/binman/etype/rockchip_tpl.py     | 20 ++++++++++++++++++++
 tools/binman/ftest.py                  |  7 +++++++
 tools/binman/missing-blob-help         |  5 +++++
 tools/binman/test/277_rockchip_tpl.dts | 16 ++++++++++++++++
 tools/rkcommon.c                       |  4 ++--
 11 files changed, 92 insertions(+), 5 deletions(-)
 create mode 100644 tools/binman/etype/rockchip_tpl.py
 create mode 100644 tools/binman/test/277_rockchip_tpl.dts

--
2.39.2