Skip to contentSkip to conversation

rockchip: rk3288: Add TPL_LDSCRIPT

PATCH Superseded Jagan Teki 2 participants 7 messages Feb 14, 2018 – Feb 20, 2018

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jagan Teki

author
#0 lore raw

PATCH 1/2 rockchip: rk3288: Add TPL_LDSCRIPT

Due to size limitations in SPL by adding falcon mode, rk3288 support TPL. In order to not overlap SPL_TEXT_BASE add TPL_TEXT_BASE with u-boot-tpl.lds that intern call u-boot-spl.lds with proper TEXT_BASE values.

---
 arch/arm/mach-rockchip/Kconfig               |  7 +++++++
 arch/arm/mach-rockchip/rk3288/u-boot-tpl.lds | 10 ++++++++++
 2 files changed, 17 insertions(+)
 create mode 100644 arch/arm/mach-rockchip/rk3288/u-boot-tpl.lds
arch/arm/mach-rockchip/Kconfig +7 -0
index 1e5a7bb..d9218da 100644
@@ -72,6 +72,13 @@ config ROCKCHIP_RK3288
 	  and video codec support. Peripherals include Gigabit Ethernet,
 	  USB2 host and OTG, SDIO, I2S, UARTs, SPI, I2C and PWMs.
 
+if ROCKCHIP_RK3288
+
+config TPL_LDSCRIPT
+	default "arch/arm/mach-rockchip/rk3288/u-boot-tpl.lds"
+
+endif
+
 config ROCKCHIP_RK3328
 	bool "Support Rockchip RK3328"
 	select ARM64
arch/arm/mach-rockchip/rk3288/u-boot-tpl.lds new file +10 -0
new file mode 100644
index 0000000..c7a6092
@@ -0,0 +1,10 @@
+/*
+ * Copyright (C) 2018 Jagan Teki <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#undef CONFIG_SPL_TEXT_BASE
+#define CONFIG_SPL_TEXT_BASE	CONFIG_TPL_TEXT_BASE
+
+#include "../../cpu/u-boot-spl.lds"
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH 2/2 rockchip: rk3288: Fix TPL_TEXT_BASE

rockchip boot0 add 4 bytes data (0xeaffffff) at beginning of executable(0x800) in order to make generic and compatible boot0 for all platforms and the resulting executable will be input to mkimage and the output of mkimage with initial 4 bytes will overwritten by 'spl_hdr'

Since the TPL_TEXT_BASE in rk3288 is 0xff704004 which is improper align to branch-to-next-instruction-word, so the resulting 4 bytes are written at ff704020 of executable instead of beginning ff704000

Hexdump with overlaped bytes:
-----------------------------
0000000 0000 0000 0000 0000 0000 0000 0000 0000
0000010 0000 0000 0000 0000 0000 0000 ffff eaff

So, fix this improper TEXT_BASE which is wrong even before and update it to 0xff704000 so-that the boot0 will add 4 bytes at beginning.

Disassembly:
-----------
with 0xff704020 TEXT_BASE:

ff704004 <__image_copy_start>:
b 1f /* if overwritten, entry-address is at the next word */
ff704020: eaffffff b ff704024 <__image_copy_start+0x20>

with 0xff704000 TEXT_BASE:

ff704000 <__image_copy_start>:
b 1f /* if overwritten, entry-address is at the next word */
ff704000: eaffffff b ff704004 <__image_copy_start+0x4>

This patch will also move TPL_TEXT_BASE into kconfig.

---
 arch/arm/mach-rockchip/Kconfig | 3 +++
 configs/vyasa-rk3288_defconfig | 1 -
 2 files changed, 3 insertions(+), 1 deletion(-)
arch/arm/mach-rockchip/Kconfig +3 -0
index d9218da..0adaed4 100644
@@ -77,6 +77,9 @@ if ROCKCHIP_RK3288
 config TPL_LDSCRIPT
 	default "arch/arm/mach-rockchip/rk3288/u-boot-tpl.lds"
 
+config TPL_TEXT_BASE
+	default 0xff704000
+
 endif
 
 config ROCKCHIP_RK3328
configs/vyasa-rk3288_defconfig +0 -1
index 1a8a9a8..4c76041 100644
@@ -5,7 +5,6 @@ CONFIG_ARCH_ROCKCHIP=y
 CONFIG_SYS_TEXT_BASE=0x00100000
 CONFIG_SYS_MALLOC_F_LEN=0x2000
 CONFIG_ROCKCHIP_RK3288=y
-CONFIG_TPL_TEXT_BASE=0xff704004
 CONFIG_TARGET_VYASA_RK3288=y
 CONFIG_SPL_STACK_R_ADDR=0x80000
 CONFIG_DEFAULT_DEVICE_TREE="rk3288-vyasa"
Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/2 rockchip: rk3288: Fix TPL_TEXT_BASE

Quoted 33 lines

rockchip boot0 add 4 bytes data (0xeaffffff) at beginning of executable(0x800) in order to make generic and compatible boot0 for all platforms and the resulting executable will be input to mkimage and the output of mkimage with initial 4 bytes will overwritten by 'spl_hdr'

Since the TPL_TEXT_BASE in rk3288 is 0xff704004 which is improper align to branch-to-next-instruction-word, so the resulting 4 bytes are written at ff704020 of executable instead of beginning ff704000

Hexdump with overlaped bytes:
-----------------------------
0000000 0000 0000 0000 0000 0000 0000 0000 0000
0000010 0000 0000 0000 0000 0000 0000 ffff eaff

So, fix this improper TEXT_BASE which is wrong even before and update it to 0xff704000 so-that the boot0 will add 4 bytes at beginning.

Disassembly:
-----------
with 0xff704020 TEXT_BASE:

ff704004 <__image_copy_start>:
b 1f /* if overwritten, entry-address is at the next word */
ff704020: eaffffff b ff704024 <__image_copy_start+0x20>

with 0xff704000 TEXT_BASE:

ff704000 <__image_copy_start>:
b 1f /* if overwritten, entry-address is at the next word */
ff704000: eaffffff b ff704004 <__image_copy_start+0x4>

Quoted 8 lines

This patch will also move TPL_TEXT_BASE into kconfig.

---
 arch/arm/mach-rockchip/Kconfig | 3 +++
 configs/vyasa-rk3288_defconfig | 1 -
 2 files changed, 3 insertions(+), 1 deletion(-)
#3 lore raw

PATCH 2/2 rockchip: rk3288: Fix TPL_TEXT_BASE

In reply to Jagan Teki
Quoted 5 lines · Jagan Teki

rockchip boot0 add 4 bytes data (0xeaffffff) at beginning of executable(0x800) in order to make generic and compatible boot0 for all platforms and the resulting executable will be input to mkimage and the output of mkimage with initial 4 bytes will overwritten by 'spl_hdr'

This is factually wrong (the beginning of the executable is neither at 0x800 nor are 4 bytes of data inserted by boot0 ... boot0 inserts a branch-instruction w/ an immediate offset). Please rewrite.

Quoted 22 lines

Since the TPL_TEXT_BASE in rk3288 is 0xff704004 which is improper align to branch-to-next-instruction-word, so the resulting 4 bytes are written at ff704020 of executable instead of beginning ff704000

Hexdump with overlaped bytes:
-----------------------------
0000000 0000 0000 0000 0000 0000 0000 0000 0000
0000010 0000 0000 0000 0000 0000 0000 ffff eaff

So, fix this improper TEXT_BASE which is wrong even before and update it to 0xff704000 so-that the boot0 will add 4 bytes at beginning.

Disassembly:
-----------
with 0xff704020 TEXT_BASE:

ff704004 <__image_copy_start>:
b 1f /* if overwritten, entry-address is at the next word */
ff704020: eaffffff b ff704024 <__image_copy_start+0x20>

Quoted 5 lines

with 0xff704000 TEXT_BASE:

ff704000 <__image_copy_start>:
b 1f /* if overwritten, entry-address is at the next word */
ff704000: eaffffff b ff704004 <__image_copy_start+0x4>

This is confusing. Please rewrite so it is clear what the problem is and why the wrong TEXT_BASE is causing these effects.

Quoted 36 lines

This patch will also move TPL_TEXT_BASE into kconfig.

---
arch/arm/mach-rockchip/Kconfig | 3 +++
configs/vyasa-rk3288_defconfig | 1 -

2 files changed, 3 insertions(+), 1 deletion(-)
arch/arm/mach-rockchip/Kconfig +0 -0
index d9218da..0adaed4 100644
@@ -77,6 +77,9 @@ if ROCKCHIP_RK3288

config TPL_LDSCRIPT

	default "arch/arm/mach-rockchip/rk3288/u-boot-tpl.lds"
arch/arm/mach-rockchip/Kconfig +3 -0
+config TPL_TEXT_BASE
+	default 0xff704000
+

endif

config ROCKCHIP_RK3328

configs/vyasa-rk3288_defconfig +0 -0
index 1a8a9a8..4c76041 100644
@@ -5,7 +5,6 @@ CONFIG_ARCH_ROCKCHIP=y

CONFIG_SYS_TEXT_BASE=0x00100000
CONFIG_SYS_MALLOC_F_LEN=0x2000
CONFIG_ROCKCHIP_RK3288=y
-CONFIG_TPL_TEXT_BASE=0xff704004
CONFIG_TARGET_VYASA_RK3288=y
CONFIG_SPL_STACK_R_ADDR=0x80000
CONFIG_DEFAULT_DEVICE_TREE="rk3288-vyasa"

#4 lore raw

PATCH 1/2 rockchip: rk3288: Add TPL_LDSCRIPT

In reply to Jagan Teki
Quoted 5 lines

Due to size limitations in SPL by adding falcon mode, rk3288 support TPL. In order to not overlap SPL_TEXT_BASE add TPL_TEXT_BASE with u-boot-tpl.lds that intern call u-boot-spl.lds with proper TEXT_BASE values.

Quoted 7 lines
---
 arch/arm/mach-rockchip/Kconfig               |  7 +++++++
 arch/arm/mach-rockchip/rk3288/u-boot-tpl.lds | 10 ++++++++++
 2 files changed, 17 insertions(+)
 create mode 100644 arch/arm/mach-rockchip/rk3288/u-boot-tpl.lds
#5 lore raw

PATCH 1/2 rockchip: rk3288: Add TPL_LDSCRIPT

In reply to Jagan Teki
Quoted 4 lines · Jagan Teki

Due to size limitations in SPL by adding falcon mode, rk3288 support TPL. In order to not overlap SPL_TEXT_BASE add TPL_TEXT_BASE with u-boot-tpl.lds that intern call u-boot-spl.lds with proper TEXT_BASE values.

A separate TPL_LDSCRIPT is needed only, if the SPL and TPL text base are to be different... is this the case (from include/configs/rk3288_common.h it seems that both SPL and TPL are starting in SRAM)?

Quoted 44 lines

---
arch/arm/mach-rockchip/Kconfig | 7 +++++++
arch/arm/mach-rockchip/rk3288/u-boot-tpl.lds | 10 ++++++++++

2 files changed, 17 insertions(+)

create mode 100644 arch/arm/mach-rockchip/rk3288/u-boot-tpl.lds

arch/arm/mach-rockchip/Kconfig +7 -0
index 1e5a7bb..d9218da 100644
@@ -72,6 +72,13 @@ config ROCKCHIP_RK3288
 	  and video codec support. Peripherals include Gigabit Ethernet,
 	  USB2 host and OTG, SDIO, I2S, UARTs, SPI, I2C and PWMs.
 
+if ROCKCHIP_RK3288
+
+config TPL_LDSCRIPT
+	default "arch/arm/mach-rockchip/rk3288/u-boot-tpl.lds"
+
+endif
+

config ROCKCHIP_RK3328
bool "Support Rockchip RK3328"
select ARM64

arch/arm/mach-rockchip/rk3288/u-boot-tpl.lds new file +10 -0
new file mode 100644
index 0000000..c7a6092
@@ -0,0 +1,10 @@
+/*
+ * Copyright (C) 2018 Jagan Teki <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#undef CONFIG_SPL_TEXT_BASE
+#define CONFIG_SPL_TEXT_BASE	CONFIG_TPL_TEXT_BASE
+
+#include "../../cpu/u-boot-spl.lds"
author
#6 lore raw

PATCH 1/2 rockchip: rk3288: Add TPL_LDSCRIPT

Quoted 10 lines · Philipp Tomsich
Quoted 4 lines · Jagan Teki

Due to size limitations in SPL by adding falcon mode, rk3288 support TPL. In order to not overlap SPL_TEXT_BASE add TPL_TEXT_BASE with u-boot-tpl.lds that intern call u-boot-spl.lds with proper TEXT_BASE values.

Quoted 3 lines

A separate TPL_LDSCRIPT is needed only, if the SPL and TPL text base are to be different... is this the case (from include/configs/rk3288_common.h it seems that both SPL and TPL are starting in SRAM)?

Yes, with TPL_BOOTROM

TPL_TEXT is 0xff704000
SPL_TEXT is 0x0