Skip to contentSkip to conversation

rockchip: Fix SPI flash SPL and payload overlap

PATCH In review Jonas Karlman 2 participants 11 messages Jul 28, 2023 – Jul 31, 2023

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

v2 cover rockchip: Fix SPI flash SPL and payload overlap

This series fixes a build issue introduced in commit 5713135ecc75 ("rockchip: rockpro64: Build u-boot-rockchip-spi.bin"), reported by Peter Robinson.

Closer inspection into how SPI flash is used revealed that current payload offset, 0x60000, is not enough to accommodate a worst-case scenario and may overlap SPL if written to SPI flash.

This series fixes this by adjusting payload offset to 0xE0000, adjusting SPL max size to 0x40000, enables build of u-boot-rockchip-spi.bin for affected boards and update the SPI flashing documentation.

Changes in v2:
- Rebase on u-boot-rockchip/master
- Collect r-b tags

Jonas Karlman (5):
rockchip: rk3399-rockpro64: Fix SPL max size and SPI flash payload
offset
rockchip: rk3399-pinebook-pro: Fix SPL max size and SPI flash payload
offset
rockchip: rk3399-pinephone-pro: Fix SPL max size and SPI flash payload
offset
rockchip: rk3399-roc-pc: Fix SPL max size and SPI flash payload offset
doc: rockchip: Update SPI flashing instruction

 arch/arm/dts/rk3399-pinebook-pro-u-boot.dtsi  |  4 ---
 arch/arm/dts/rk3399-pinephone-pro-u-boot.dtsi |  4 ---
 arch/arm/dts/rk3399-roc-pc-u-boot.dtsi        |  4 ---
 arch/arm/dts/rk3399-rockpro64-u-boot.dtsi     |  4 ---
 configs/pinebook-pro-rk3399_defconfig         |  4 ++-
 configs/pinephone-pro-rk3399_defconfig        |  4 ++-
 configs/roc-pc-mezzanine-rk3399_defconfig     |  4 ++-
 configs/roc-pc-rk3399_defconfig               |  4 ++-
 configs/rockpro64-rk3399_defconfig            |  5 ++--
 doc/board/rockchip/rockchip.rst               | 26 ++++---------------
 10 files changed, 19 insertions(+), 44 deletions(-)
Signature · 1 line
2.41.0
#1 lore raw

PATCH v2 1/5 rockchip: rk3399-rockpro64: Fix SPL max size and SPI flash payload offset

TPL max size is limited to 184 KB, SPL is loaded to 0x0 and TF-A is loaded to 0x40000, this limit SPL max size to 256 KB. With BootRom only reading first 2 KB per 4 KB page of SPI flash, 880 KB may be needed for TPL+SPL in a worst-case scenario. (184 KB + 256 KB) x 2 = 880 KB

Use 0xE0000 (896 KB) as the payload offset in SPI flash, this allows for a payload of 3168 KB before env offset start to overlap.

Also remove CONFIG_LTO=y now that there is sufficient space for SPL in SPI flash, and to fix a build issue reported by Peter Robinson.

Fixes 5713135ecc75 ("rockchip: rockpro64: Build u-boot-rockchip-spi.bin")

---
v2:
- Rebase on u-boot-rockchip/master
- Collect r-b tags

 arch/arm/dts/rk3399-rockpro64-u-boot.dtsi | 4 ----
 configs/rockpro64-rk3399_defconfig        | 5 ++---
 2 files changed, 2 insertions(+), 7 deletions(-)
arch/arm/dts/rk3399-rockpro64-u-boot.dtsi +0 -4
index bd864d067018..732727d9b036 100644
@@ -9,10 +9,6 @@
 	chosen {
 		u-boot,spl-boot-order = "same-as-spl", &spi_flash, &sdmmc, &sdhci;
 	};
-
-	config {
-		u-boot,spl-payload-offset = <0x60000>; /* @ 384KB */
-	};
 };
 
 &sdhci {
configs/rockpro64-rk3399_defconfig +2 -3
index 62daad27a6f8..4cd6b76665bd 100644
@@ -21,7 +21,6 @@ CONFIG_SPL_SPI=y
 CONFIG_SYS_LOAD_ADDR=0x800800
 CONFIG_PCI=y
 CONFIG_DEBUG_UART=y
-CONFIG_LTO=y
 CONFIG_SPL_FIT_SIGNATURE=y
 CONFIG_LEGACY_IMAGE_FORMAT=y
 CONFIG_BOOTSTAGE=y
@@ -30,7 +29,7 @@ CONFIG_USE_PREBOOT=y
 CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-rockpro64.dtb"
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_MISC_INIT_R=y
-CONFIG_SPL_MAX_SIZE=0x2e000
+CONFIG_SPL_MAX_SIZE=0x40000
 CONFIG_SPL_PAD_TO=0x7f8000
 CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
 CONFIG_SPL_BSS_START_ADDR=0x400000
@@ -40,7 +39,7 @@ CONFIG_SPL_BSS_MAX_SIZE=0x2000
 CONFIG_SPL_STACK_R=y
 CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x10000
 CONFIG_SPL_SPI_LOAD=y
-CONFIG_SYS_SPI_U_BOOT_OFFS=0x60000
+CONFIG_SYS_SPI_U_BOOT_OFFS=0xE0000
 CONFIG_SPL_ATF_NO_PLATFORM_PARAM=y
 CONFIG_TPL=y
 CONFIG_CMD_BOOTZ=y
Signature · 1 line
2.41.0
Reviewed-by on v2 1/5
#2 lore raw

Re: [PATCH v2 1/5] rockchip: rk3399-rockpro64: Fix SPL max size and SPI flash payload offset

Quoted 8 lines · Jonas Karlman

TPL max size is limited to 184 KB, SPL is loaded to 0x0 and TF-A is loaded to 0x40000, this limit SPL max size to 256 KB. With BootRom only reading first 2 KB per 4 KB page of SPI flash, 880 KB may be needed for TPL+SPL in a worst-case scenario. (184 KB + 256 KB) x 2 = 880 KB

Use 0xE0000 (896 KB) as the payload offset in SPI flash, this allows for a payload of 3168 KB before env offset start to overlap.

Quoted 7 lines

Also remove CONFIG_LTO=y now that there is sufficient space for SPL in SPI flash, and to fix a build issue reported by Peter Robinson.

Fixes 5713135ecc75 ("rockchip: rockpro64: Build u-boot-rockchip-spi.bin")

Thanks,
- Kever

Quoted 54 lines

---
v2:
- Rebase on u-boot-rockchip/master
- Collect r-b tags

  arch/arm/dts/rk3399-rockpro64-u-boot.dtsi | 4 ----
  configs/rockpro64-rk3399_defconfig        | 5 ++---
  2 files changed, 2 insertions(+), 7 deletions(-)
arch/arm/dts/rk3399-rockpro64-u-boot.dtsi +0 -4
index bd864d067018..732727d9b036 100644
@@ -9,10 +9,6 @@
  	chosen {
  		u-boot,spl-boot-order = "same-as-spl", &spi_flash, &sdmmc, &sdhci;
  	};
-
-	config {
-		u-boot,spl-payload-offset = <0x60000>; /* @ 384KB */
-	};
  };
 
  &sdhci {
configs/rockpro64-rk3399_defconfig +2 -3
index 62daad27a6f8..4cd6b76665bd 100644
@@ -21,7 +21,6 @@ CONFIG_SPL_SPI=y
  CONFIG_SYS_LOAD_ADDR=0x800800
  CONFIG_PCI=y
  CONFIG_DEBUG_UART=y
-CONFIG_LTO=y
  CONFIG_SPL_FIT_SIGNATURE=y
  CONFIG_LEGACY_IMAGE_FORMAT=y
  CONFIG_BOOTSTAGE=y
@@ -30,7 +29,7 @@ CONFIG_USE_PREBOOT=y
  CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-rockpro64.dtb"
  CONFIG_DISPLAY_BOARDINFO_LATE=y
  CONFIG_MISC_INIT_R=y
-CONFIG_SPL_MAX_SIZE=0x2e000
+CONFIG_SPL_MAX_SIZE=0x40000
  CONFIG_SPL_PAD_TO=0x7f8000
  CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
  CONFIG_SPL_BSS_START_ADDR=0x400000
@@ -40,7 +39,7 @@ CONFIG_SPL_BSS_MAX_SIZE=0x2000
  CONFIG_SPL_STACK_R=y
  CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x10000
  CONFIG_SPL_SPI_LOAD=y
-CONFIG_SYS_SPI_U_BOOT_OFFS=0x60000
+CONFIG_SYS_SPI_U_BOOT_OFFS=0xE0000
  CONFIG_SPL_ATF_NO_PLATFORM_PARAM=y
  CONFIG_TPL=y
  CONFIG_CMD_BOOTZ=y
#3 lore raw

PATCH v2 2/5 rockchip: rk3399-pinebook-pro: Fix SPL max size and SPI flash payload offset

In reply to Jonas Karlman

TPL max size is limited to 184 KB, SPL is loaded to 0x0 and TF-A is loaded to 0x40000, this limit SPL max size to 256 KB. With BootRom only reading first 2 KB per 4 KB page of SPI flash, 880 KB may be needed for TPL+SPL in a worst-case scenario. (184 KB + 256 KB) x 2 = 880 KB

Use 0xE0000 (896 KB) as the payload offset in SPI flash, this allows for a payload of 3168 KB before env offset start to overlap.

Also add CONFIG_ROCKCHIP_SPI_IMAGE=y to build a bootable SPI flash image, u-boot-rockchip-spi.bin.

---
v2:
- Rebase on u-boot-rockchip/master
- Collect r-b tags

 arch/arm/dts/rk3399-pinebook-pro-u-boot.dtsi | 4 ----
 configs/pinebook-pro-rk3399_defconfig        | 4 +++-
 2 files changed, 3 insertions(+), 5 deletions(-)
arch/arm/dts/rk3399-pinebook-pro-u-boot.dtsi +0 -4
index ea7a5a17ae0f..88a77cad8d43 100644
@@ -10,10 +10,6 @@
 	chosen {
 		u-boot,spl-boot-order = "same-as-spl", &sdhci, &spiflash, &sdmmc;
 	};
-
-	config {
-		u-boot,spl-payload-offset = <0x60000>; /* @ 384KB */
-	};
 };
 
 &edp {
configs/pinebook-pro-rk3399_defconfig +3 -1
index 5d493c910ee8..ae3211bbe9c4 100644
@@ -12,6 +12,7 @@ CONFIG_ENV_OFFSET=0x3F8000
 CONFIG_DEFAULT_DEVICE_TREE="rk3399-pinebook-pro"
 CONFIG_DM_RESET=y
 CONFIG_ROCKCHIP_RK3399=y
+CONFIG_ROCKCHIP_SPI_IMAGE=y
 CONFIG_TARGET_PINEBOOK_PRO_RK3399=y
 CONFIG_SPL_STACK=0x400000
 CONFIG_DEBUG_UART_BASE=0xFF1A0000
@@ -26,7 +27,7 @@ CONFIG_USE_PREBOOT=y
 CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-pinebook-pro.dtb"
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_MISC_INIT_R=y
-CONFIG_SPL_MAX_SIZE=0x2e000
+CONFIG_SPL_MAX_SIZE=0x40000
 CONFIG_SPL_PAD_TO=0x7f8000
 CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
 CONFIG_SPL_BSS_START_ADDR=0x400000
@@ -36,6 +37,7 @@ CONFIG_SPL_BSS_MAX_SIZE=0x2000
 CONFIG_SPL_STACK_R=y
 CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x10000
 CONFIG_SPL_SPI_LOAD=y
+CONFIG_SYS_SPI_U_BOOT_OFFS=0xE0000
 CONFIG_SPL_ATF_NO_PLATFORM_PARAM=y
 CONFIG_TPL=y
 CONFIG_CMD_BOOTZ=y
Signature · 1 line
2.41.0
Reviewed-by on v2 2/5
#4 lore raw

Re: [PATCH v2 2/5] rockchip: rk3399-pinebook-pro: Fix SPL max size and SPI flash payload offset

Quoted 5 lines · Jonas Karlman

TPL max size is limited to 184 KB, SPL is loaded to 0x0 and TF-A is loaded to 0x40000, this limit SPL max size to 256 KB. With BootRom only reading first 2 KB per 4 KB page of SPI flash, 880 KB may be needed for TPL+SPL in a worst-case scenario. (184 KB + 256 KB) x 2 = 880 KB

Quoted 8 lines

Use 0xE0000 (896 KB) as the payload offset in SPI flash, this allows for a payload of 3168 KB before env offset start to overlap.

Also add CONFIG_ROCKCHIP_SPI_IMAGE=y to build a bootable SPI flash image, u-boot-rockchip-spi.bin.

Thanks,
- Kever

Quoted 53 lines

---
v2:
- Rebase on u-boot-rockchip/master
- Collect r-b tags

  arch/arm/dts/rk3399-pinebook-pro-u-boot.dtsi | 4 ----
  configs/pinebook-pro-rk3399_defconfig        | 4 +++-
  2 files changed, 3 insertions(+), 5 deletions(-)
arch/arm/dts/rk3399-pinebook-pro-u-boot.dtsi +0 -4
index ea7a5a17ae0f..88a77cad8d43 100644
@@ -10,10 +10,6 @@
  	chosen {
  		u-boot,spl-boot-order = "same-as-spl", &sdhci, &spiflash, &sdmmc;
  	};
-
-	config {
-		u-boot,spl-payload-offset = <0x60000>; /* @ 384KB */
-	};
  };
 
  &edp {
configs/pinebook-pro-rk3399_defconfig +3 -1
index 5d493c910ee8..ae3211bbe9c4 100644
@@ -12,6 +12,7 @@ CONFIG_ENV_OFFSET=0x3F8000
  CONFIG_DEFAULT_DEVICE_TREE="rk3399-pinebook-pro"
  CONFIG_DM_RESET=y
  CONFIG_ROCKCHIP_RK3399=y
+CONFIG_ROCKCHIP_SPI_IMAGE=y
  CONFIG_TARGET_PINEBOOK_PRO_RK3399=y
  CONFIG_SPL_STACK=0x400000
  CONFIG_DEBUG_UART_BASE=0xFF1A0000
@@ -26,7 +27,7 @@ CONFIG_USE_PREBOOT=y
  CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-pinebook-pro.dtb"
  CONFIG_DISPLAY_BOARDINFO_LATE=y
  CONFIG_MISC_INIT_R=y
-CONFIG_SPL_MAX_SIZE=0x2e000
+CONFIG_SPL_MAX_SIZE=0x40000
  CONFIG_SPL_PAD_TO=0x7f8000
  CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
  CONFIG_SPL_BSS_START_ADDR=0x400000
@@ -36,6 +37,7 @@ CONFIG_SPL_BSS_MAX_SIZE=0x2000
  CONFIG_SPL_STACK_R=y
  CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x10000
  CONFIG_SPL_SPI_LOAD=y
+CONFIG_SYS_SPI_U_BOOT_OFFS=0xE0000
  CONFIG_SPL_ATF_NO_PLATFORM_PARAM=y
  CONFIG_TPL=y
  CONFIG_CMD_BOOTZ=y
#5 lore raw

PATCH v2 3/5 rockchip: rk3399-pinephone-pro: Fix SPL max size and SPI flash payload offset

In reply to Jonas Karlman

TPL max size is limited to 184 KB, SPL is loaded to 0x0 and TF-A is loaded to 0x40000, this limit SPL max size to 256 KB. With BootRom only reading first 2 KB per 4 KB page of SPI flash, 880 KB may be needed for TPL+SPL in a worst-case scenario. (184 KB + 256 KB) x 2 = 880 KB

Use 0xE0000 (896 KB) as the payload offset in SPI flash, this allows for a payload of 3168 KB before env offset start to overlap.

Also add CONFIG_ROCKCHIP_SPI_IMAGE=y to build a bootable SPI flash image, u-boot-rockchip-spi.bin.

---
v2:
- Rebase on u-boot-rockchip/master
- Collect r-b tags

 arch/arm/dts/rk3399-pinephone-pro-u-boot.dtsi | 4 ----
 configs/pinephone-pro-rk3399_defconfig        | 4 +++-
 2 files changed, 3 insertions(+), 5 deletions(-)
arch/arm/dts/rk3399-pinephone-pro-u-boot.dtsi +0 -4
index 347243fe4793..cabf0a9dae89 100644
@@ -10,10 +10,6 @@
 	chosen {
 		u-boot,spl-boot-order = "same-as-spl", &sdhci, &sdmmc;
 	};
-
-	config {
-		u-boot,spl-payload-offset = <0x60000>; /* @ 384KB */
-	};
 };
 
 &rng {
configs/pinephone-pro-rk3399_defconfig +3 -1
index f97a4003bbad..11243bc5c193 100644
@@ -12,6 +12,7 @@ CONFIG_ENV_OFFSET=0x3F8000
 CONFIG_DEFAULT_DEVICE_TREE="rk3399-pinephone-pro"
 CONFIG_DM_RESET=y
 CONFIG_ROCKCHIP_RK3399=y
+CONFIG_ROCKCHIP_SPI_IMAGE=y
 CONFIG_TARGET_PINEPHONE_PRO_RK3399=y
 CONFIG_SPL_STACK=0x400000
 CONFIG_DEBUG_UART_BASE=0xFF1A0000
@@ -25,7 +26,7 @@ CONFIG_USE_PREBOOT=y
 CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-pinephone-pro.dtb"
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_MISC_INIT_R=y
-CONFIG_SPL_MAX_SIZE=0x2e000
+CONFIG_SPL_MAX_SIZE=0x40000
 CONFIG_SPL_PAD_TO=0x7f8000
 CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
 CONFIG_SPL_BSS_START_ADDR=0x400000
@@ -35,6 +36,7 @@ CONFIG_SPL_BSS_MAX_SIZE=0x2000
 CONFIG_SPL_STACK_R=y
 CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x10000
 CONFIG_SPL_SPI_LOAD=y
+CONFIG_SYS_SPI_U_BOOT_OFFS=0xE0000
 CONFIG_SPL_ATF_NO_PLATFORM_PARAM=y
 CONFIG_TPL=y
 CONFIG_CMD_BOOTZ=y
Signature · 1 line
2.41.0
Reviewed-by on v2 3/5
#6 lore raw

Re: [PATCH v2 3/5] rockchip: rk3399-pinephone-pro: Fix SPL max size and SPI flash payload offset

Quoted 5 lines · Jonas Karlman

TPL max size is limited to 184 KB, SPL is loaded to 0x0 and TF-A is loaded to 0x40000, this limit SPL max size to 256 KB. With BootRom only reading first 2 KB per 4 KB page of SPI flash, 880 KB may be needed for TPL+SPL in a worst-case scenario. (184 KB + 256 KB) x 2 = 880 KB

Quoted 8 lines

Use 0xE0000 (896 KB) as the payload offset in SPI flash, this allows for a payload of 3168 KB before env offset start to overlap.

Also add CONFIG_ROCKCHIP_SPI_IMAGE=y to build a bootable SPI flash image, u-boot-rockchip-spi.bin.

Thanks,
- Kever

Quoted 53 lines

---
v2:
- Rebase on u-boot-rockchip/master
- Collect r-b tags

  arch/arm/dts/rk3399-pinephone-pro-u-boot.dtsi | 4 ----
  configs/pinephone-pro-rk3399_defconfig        | 4 +++-
  2 files changed, 3 insertions(+), 5 deletions(-)
arch/arm/dts/rk3399-pinephone-pro-u-boot.dtsi +0 -4
index 347243fe4793..cabf0a9dae89 100644
@@ -10,10 +10,6 @@
  	chosen {
  		u-boot,spl-boot-order = "same-as-spl", &sdhci, &sdmmc;
  	};
-
-	config {
-		u-boot,spl-payload-offset = <0x60000>; /* @ 384KB */
-	};
  };
 
  &rng {
configs/pinephone-pro-rk3399_defconfig +3 -1
index f97a4003bbad..11243bc5c193 100644
@@ -12,6 +12,7 @@ CONFIG_ENV_OFFSET=0x3F8000
  CONFIG_DEFAULT_DEVICE_TREE="rk3399-pinephone-pro"
  CONFIG_DM_RESET=y
  CONFIG_ROCKCHIP_RK3399=y
+CONFIG_ROCKCHIP_SPI_IMAGE=y
  CONFIG_TARGET_PINEPHONE_PRO_RK3399=y
  CONFIG_SPL_STACK=0x400000
  CONFIG_DEBUG_UART_BASE=0xFF1A0000
@@ -25,7 +26,7 @@ CONFIG_USE_PREBOOT=y
  CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-pinephone-pro.dtb"
  CONFIG_DISPLAY_BOARDINFO_LATE=y
  CONFIG_MISC_INIT_R=y
-CONFIG_SPL_MAX_SIZE=0x2e000
+CONFIG_SPL_MAX_SIZE=0x40000
  CONFIG_SPL_PAD_TO=0x7f8000
  CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
  CONFIG_SPL_BSS_START_ADDR=0x400000
@@ -35,6 +36,7 @@ CONFIG_SPL_BSS_MAX_SIZE=0x2000
  CONFIG_SPL_STACK_R=y
  CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x10000
  CONFIG_SPL_SPI_LOAD=y
+CONFIG_SYS_SPI_U_BOOT_OFFS=0xE0000
  CONFIG_SPL_ATF_NO_PLATFORM_PARAM=y
  CONFIG_TPL=y
  CONFIG_CMD_BOOTZ=y
#7 lore raw

PATCH v2 4/5 rockchip: rk3399-roc-pc: Fix SPL max size and SPI flash payload offset

In reply to Jonas Karlman

TPL max size is limited to 184 KB, SPL is loaded to 0x0 and TF-A is loaded to 0x40000, this limit SPL max size to 256 KB. With BootRom only reading first 2 KB per 4 KB page of SPI flash, 880 KB may be needed for TPL+SPL in a worst-case scenario. (184 KB + 256 KB) x 2 = 880 KB

Use 0xE0000 (896 KB) as the payload offset in SPI flash, this allows for a payload of 3168 KB before env offset start to overlap.

Also add CONFIG_ROCKCHIP_SPI_IMAGE=y to build a bootable SPI flash image, u-boot-rockchip-spi.bin.

---
v2:
- Rebase on u-boot-rockchip/master
- Collect r-b tags

 arch/arm/dts/rk3399-roc-pc-u-boot.dtsi    | 4 ----
 configs/roc-pc-mezzanine-rk3399_defconfig | 4 +++-
 configs/roc-pc-rk3399_defconfig           | 4 +++-
 3 files changed, 6 insertions(+), 6 deletions(-)
arch/arm/dts/rk3399-roc-pc-u-boot.dtsi +0 -4
index f85e7b62d9ad..c8f4418a7389 100644
@@ -11,10 +11,6 @@
 		u-boot,spl-boot-order = "same-as-spl", &spi_flash, &sdhci, &sdmmc;
 	};
 
-	config {
-		u-boot,spl-payload-offset = <0x60000>; /* @ 384KB */
-	};
-
 	vcc_hub_en: vcc_hub_en-regulator {
 		compatible = "regulator-fixed";
 		enable-active-high;
configs/roc-pc-mezzanine-rk3399_defconfig +3 -1
index 0d113c764f61..06d97c3e1a2d 100644
@@ -13,6 +13,7 @@ CONFIG_ENV_SECT_SIZE=0x1000
 CONFIG_DEFAULT_DEVICE_TREE="rk3399-roc-pc-mezzanine"
 CONFIG_DM_RESET=y
 CONFIG_ROCKCHIP_RK3399=y
+CONFIG_ROCKCHIP_SPI_IMAGE=y
 CONFIG_TARGET_ROC_PC_RK3399=y
 CONFIG_SPL_STACK=0x400000
 CONFIG_DEBUG_UART_BASE=0xFF1A0000
@@ -26,7 +27,7 @@ CONFIG_DEBUG_UART=y
 CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-roc-pc-mezzanine.dtb"
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_MISC_INIT_R=y
-CONFIG_SPL_MAX_SIZE=0x2e000
+CONFIG_SPL_MAX_SIZE=0x40000
 CONFIG_SPL_PAD_TO=0x7f8000
 CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
 CONFIG_SPL_BSS_START_ADDR=0x400000
@@ -37,6 +38,7 @@ CONFIG_SPL_STACK_R=y
 CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x20000
 CONFIG_SPL_ENV_SUPPORT=y
 CONFIG_SPL_SPI_LOAD=y
+CONFIG_SYS_SPI_U_BOOT_OFFS=0xE0000
 CONFIG_SPL_ATF_NO_PLATFORM_PARAM=y
 CONFIG_TPL=y
 CONFIG_CMD_BOOTZ=y
configs/roc-pc-rk3399_defconfig +3 -1
index 7e5db7419517..c53e8622431e 100644
@@ -14,6 +14,7 @@ CONFIG_ENV_SECT_SIZE=0x1000
 CONFIG_DEFAULT_DEVICE_TREE="rk3399-roc-pc"
 CONFIG_DM_RESET=y
 CONFIG_ROCKCHIP_RK3399=y
+CONFIG_ROCKCHIP_SPI_IMAGE=y
 CONFIG_TARGET_ROC_PC_RK3399=y
 CONFIG_SPL_STACK=0x400000
 CONFIG_DEBUG_UART_BASE=0xFF1A0000
@@ -27,7 +28,7 @@ CONFIG_USE_PREBOOT=y
 CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-roc-pc.dtb"
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_MISC_INIT_R=y
-CONFIG_SPL_MAX_SIZE=0x2e000
+CONFIG_SPL_MAX_SIZE=0x40000
 CONFIG_SPL_PAD_TO=0x7f8000
 CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
 CONFIG_SPL_BSS_START_ADDR=0x400000
@@ -38,6 +39,7 @@ CONFIG_SPL_STACK_R=y
 CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x20000
 CONFIG_SPL_ENV_SUPPORT=y
 CONFIG_SPL_SPI_LOAD=y
+CONFIG_SYS_SPI_U_BOOT_OFFS=0xE0000
 CONFIG_SPL_ATF_NO_PLATFORM_PARAM=y
 CONFIG_TPL=y
 CONFIG_CMD_BOOTZ=y
Signature · 1 line
2.41.0
Reviewed-by on v2 4/5
#8 lore raw

Re: [PATCH v2 4/5] rockchip: rk3399-roc-pc: Fix SPL max size and SPI flash payload offset

Quoted 5 lines · Jonas Karlman

TPL max size is limited to 184 KB, SPL is loaded to 0x0 and TF-A is loaded to 0x40000, this limit SPL max size to 256 KB. With BootRom only reading first 2 KB per 4 KB page of SPI flash, 880 KB may be needed for TPL+SPL in a worst-case scenario. (184 KB + 256 KB) x 2 = 880 KB

Quoted 8 lines

Use 0xE0000 (896 KB) as the payload offset in SPI flash, this allows for a payload of 3168 KB before env offset start to overlap.

Also add CONFIG_ROCKCHIP_SPI_IMAGE=y to build a bootable SPI flash image, u-boot-rockchip-spi.bin.

Thanks,
- Kever

Quoted 83 lines

---
v2:
- Rebase on u-boot-rockchip/master
- Collect r-b tags

  arch/arm/dts/rk3399-roc-pc-u-boot.dtsi    | 4 ----
  configs/roc-pc-mezzanine-rk3399_defconfig | 4 +++-
  configs/roc-pc-rk3399_defconfig           | 4 +++-
  3 files changed, 6 insertions(+), 6 deletions(-)
arch/arm/dts/rk3399-roc-pc-u-boot.dtsi +0 -4
index f85e7b62d9ad..c8f4418a7389 100644
@@ -11,10 +11,6 @@
  		u-boot,spl-boot-order = "same-as-spl", &spi_flash, &sdhci, &sdmmc;
  	};
 
-	config {
-		u-boot,spl-payload-offset = <0x60000>; /* @ 384KB */
-	};
-
  	vcc_hub_en: vcc_hub_en-regulator {
  		compatible = "regulator-fixed";
  		enable-active-high;
configs/roc-pc-mezzanine-rk3399_defconfig +3 -1
index 0d113c764f61..06d97c3e1a2d 100644
@@ -13,6 +13,7 @@ CONFIG_ENV_SECT_SIZE=0x1000
  CONFIG_DEFAULT_DEVICE_TREE="rk3399-roc-pc-mezzanine"
  CONFIG_DM_RESET=y
  CONFIG_ROCKCHIP_RK3399=y
+CONFIG_ROCKCHIP_SPI_IMAGE=y
  CONFIG_TARGET_ROC_PC_RK3399=y
  CONFIG_SPL_STACK=0x400000
  CONFIG_DEBUG_UART_BASE=0xFF1A0000
@@ -26,7 +27,7 @@ CONFIG_DEBUG_UART=y
  CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-roc-pc-mezzanine.dtb"
  CONFIG_DISPLAY_BOARDINFO_LATE=y
  CONFIG_MISC_INIT_R=y
-CONFIG_SPL_MAX_SIZE=0x2e000
+CONFIG_SPL_MAX_SIZE=0x40000
  CONFIG_SPL_PAD_TO=0x7f8000
  CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
  CONFIG_SPL_BSS_START_ADDR=0x400000
@@ -37,6 +38,7 @@ CONFIG_SPL_STACK_R=y
  CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x20000
  CONFIG_SPL_ENV_SUPPORT=y
  CONFIG_SPL_SPI_LOAD=y
+CONFIG_SYS_SPI_U_BOOT_OFFS=0xE0000
  CONFIG_SPL_ATF_NO_PLATFORM_PARAM=y
  CONFIG_TPL=y
  CONFIG_CMD_BOOTZ=y
configs/roc-pc-rk3399_defconfig +3 -1
index 7e5db7419517..c53e8622431e 100644
@@ -14,6 +14,7 @@ CONFIG_ENV_SECT_SIZE=0x1000
  CONFIG_DEFAULT_DEVICE_TREE="rk3399-roc-pc"
  CONFIG_DM_RESET=y
  CONFIG_ROCKCHIP_RK3399=y
+CONFIG_ROCKCHIP_SPI_IMAGE=y
  CONFIG_TARGET_ROC_PC_RK3399=y
  CONFIG_SPL_STACK=0x400000
  CONFIG_DEBUG_UART_BASE=0xFF1A0000
@@ -27,7 +28,7 @@ CONFIG_USE_PREBOOT=y
  CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-roc-pc.dtb"
  CONFIG_DISPLAY_BOARDINFO_LATE=y
  CONFIG_MISC_INIT_R=y
-CONFIG_SPL_MAX_SIZE=0x2e000
+CONFIG_SPL_MAX_SIZE=0x40000
  CONFIG_SPL_PAD_TO=0x7f8000
  CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
  CONFIG_SPL_BSS_START_ADDR=0x400000
@@ -38,6 +39,7 @@ CONFIG_SPL_STACK_R=y
  CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x20000
  CONFIG_SPL_ENV_SUPPORT=y
  CONFIG_SPL_SPI_LOAD=y
+CONFIG_SYS_SPI_U_BOOT_OFFS=0xE0000
  CONFIG_SPL_ATF_NO_PLATFORM_PARAM=y
  CONFIG_TPL=y
  CONFIG_CMD_BOOTZ=y
#9 lore raw

PATCH v2 5/5 doc: rockchip: Update SPI flashing instruction

In reply to Jonas Karlman

Update documentation on how to write a bootable u-boot-rockchip-spi.bin image into SPI flash. This removes the reference to a hardcoded and now obsolete 0x60000 payload offset.

Also remove an obsolete reference to pad_cat.

---
v2:
- Rebase on u-boot-rockchip/master
- Collect r-b tags

 doc/board/rockchip/rockchip.rst | 26 +++++---------------------
 1 file changed, 5 insertions(+), 21 deletions(-)
doc/board/rockchip/rockchip.rst +5 -21
index dfbc27a86d69..2a535f83fb1e 100644
@@ -213,7 +213,7 @@ SD Card
 ^^^^^^^
 
 All Rockchip platforms (except rk3128 which doesn't use SPL) are now
-supporting a single boot image using binman and pad_cat.
+supporting a single boot image using binman.
 
 To write an image that boots from a SD card (assumed to be /dev/sda):
 
@@ -264,31 +264,15 @@ is u-boot-dtb.img
 SPI
 ^^^
 
-The SPI boot method requires the generation of idbloader.img with help of the mkimage tool.
+Write u-boot-rockchip-spi.bin to offset 0 of SPI flash.
 
-SPL-alone SPI boot image:
-
-.. code-block:: bash
-
-        ./tools/mkimage -n rk3399 -T rkspi -d spl/u-boot-spl.bin idbloader.img
-
-TPL+SPL SPI boot image:
-
-.. code-block:: bash
-
-        ./tools/mkimage -n rk3399 -T rkspi -d tpl/u-boot-tpl.bin:spl/u-boot-spl.bin idbloader.img
-
-Copy SPI boot images into SD card and boot from SD:
+Copy u-boot-rockchip-spi.bin into SD card and boot from SD:
 
 .. code-block:: bash
 
         sf probe
-        load mmc 1:1 $kernel_addr_r idbloader.img
-        sf erase 0 +$filesize
-        sf write $kernel_addr_r 0 ${filesize}
-        load mmc 1:1 ${kernel_addr_r} u-boot.itb
-        sf erase 0x60000 +$filesize
-        sf write $kernel_addr_r 0x60000 ${filesize}
+        load mmc 1:1 $kernel_addr_r u-boot-rockchip-spi.bin
+        sf update $fileaddr 0 $filesize
 
 2. Package the image with Rockchip miniloader
 ---------------------------------------------
Signature · 1 line
2.41.0
Reviewed-by on v2 5/5
#10 lore raw

Re: [PATCH v2 5/5] doc: rockchip: Update SPI flashing instruction

Quoted 8 lines · Jonas Karlman

Update documentation on how to write a bootable u-boot-rockchip-spi.bin image into SPI flash. This removes the reference to a hardcoded and now obsolete 0x60000 payload offset.

Also remove an obsolete reference to pad_cat.

Thanks,
- Kever

Quoted 57 lines

---
v2:
- Rebase on u-boot-rockchip/master
- Collect r-b tags

  doc/board/rockchip/rockchip.rst | 26 +++++---------------------
  1 file changed, 5 insertions(+), 21 deletions(-)
doc/board/rockchip/rockchip.rst +5 -21
index dfbc27a86d69..2a535f83fb1e 100644
@@ -213,7 +213,7 @@ SD Card
  ^^^^^^^
 
  All Rockchip platforms (except rk3128 which doesn't use SPL) are now
-supporting a single boot image using binman and pad_cat.
+supporting a single boot image using binman.
 
  To write an image that boots from a SD card (assumed to be /dev/sda):
 
@@ -264,31 +264,15 @@ is u-boot-dtb.img
  SPI
  ^^^
 
-The SPI boot method requires the generation of idbloader.img with help of the mkimage tool.
+Write u-boot-rockchip-spi.bin to offset 0 of SPI flash.
 
-SPL-alone SPI boot image:
-
-.. code-block:: bash
-
-        ./tools/mkimage -n rk3399 -T rkspi -d spl/u-boot-spl.bin idbloader.img
-
-TPL+SPL SPI boot image:
-
-.. code-block:: bash
-
-        ./tools/mkimage -n rk3399 -T rkspi -d tpl/u-boot-tpl.bin:spl/u-boot-spl.bin idbloader.img
-
-Copy SPI boot images into SD card and boot from SD:
+Copy u-boot-rockchip-spi.bin into SD card and boot from SD:
 
  .. code-block:: bash
 
          sf probe
-        load mmc 1:1 $kernel_addr_r idbloader.img
-        sf erase 0 +$filesize
-        sf write $kernel_addr_r 0 ${filesize}
-        load mmc 1:1 ${kernel_addr_r} u-boot.itb
-        sf erase 0x60000 +$filesize
-        sf write $kernel_addr_r 0x60000 ${filesize}
+        load mmc 1:1 $kernel_addr_r u-boot-rockchip-spi.bin
+        sf update $fileaddr 0 $filesize
 
  2. Package the image with Rockchip miniloader
  ---------------------------------------------