[U-Boot] [PATCH] ARM: rmobile: Add JTAG recovery support for M2 Porter

Marek Vasut marek.vasut at gmail.com
Sat Apr 7 15:06:17 UTC 2018


Add JTAG recovery support into the M2 Porter TPL. This allows the
TPL to be loaded over JTAG, initialize the system, wait for the
JTAG debugger to load U-Boot image into RAM and then resume and
start U-Boot from RAM.

The procedure is as follows:
1) Load u-boot-tpl.bin to 0xe6300000
2) Write magic number 0x1337c0de to 0xe6300020
   TPL checks for this particular magic and starts JTAG recovery
   if this number is present. This is not present by default.
3) Start U-Boot TPL from 0xe6300000
4) Wait for a message from TPL on UART indicating JTAG boot:
   "JTAG boot detected!"
5) Halt the system in JTAG debugger
6) Load U-Boot image (u-boot.img) to 0x4fffffc0
7) Write magic number 0xb33fc0de to 0xe6300024
   TPL checks for this particular magic to verify that the U-Boot
   image was loaded into DRAM by the JTAG debugger.
8) Resume the system in JTAG debugger

Signed-off-by: Marek Vasut <marek.vasut+renesas at gmail.com>
Cc: Nobuhiro Iwamatsu <iwamatsu at nigauri.org>
---
 arch/arm/mach-rmobile/include/mach/boot0.h | 24 ++++++++++++++++++++++++
 board/renesas/porter/porter_spl.c          | 21 +++++++++++++++++++++
 configs/porter_defconfig                   |  3 +++
 3 files changed, 48 insertions(+)
 create mode 100644 arch/arm/mach-rmobile/include/mach/boot0.h

diff --git a/arch/arm/mach-rmobile/include/mach/boot0.h b/arch/arm/mach-rmobile/include/mach/boot0.h
new file mode 100644
index 0000000000..3edd461cbf
--- /dev/null
+++ b/arch/arm/mach-rmobile/include/mach/boot0.h
@@ -0,0 +1,24 @@
+/*
+ * Specialty padding for the RCar Gen2 TPL JTAG loading
+ *
+ * SPDX-License-Identifier:	GPL-2.0
+ */
+
+#ifndef __BOOT0_H
+#define __BOOT0_H
+
+_start:
+	ARM_VECTORS
+
+#ifdef CONFIG_TPL_BUILD
+	.word	0x0badc0d3;
+	.word	0x0badc0d3;
+	.word	0x0badc0d3;
+	.word	0x0badc0d3;
+	.word	0x0badc0d3;
+	.word	0x0badc0d3;
+	.word	0x0badc0d3;
+	.word	0x0badc0d3;
+#endif
+
+#endif /* __BOOT0_H */
diff --git a/board/renesas/porter/porter_spl.c b/board/renesas/porter/porter_spl.c
index 533b0b41e9..f711aa9c35 100644
--- a/board/renesas/porter/porter_spl.c
+++ b/board/renesas/porter/porter_spl.c
@@ -463,6 +463,27 @@ void spl_board_init(void)
 
 void board_boot_order(u32 *spl_boot_list)
 {
+#ifdef CONFIG_TPL_BUILD
+	const u32 jtag_magic = 0x1337c0de;
+	const u32 load_magic = 0xb33fc0de;
+
+	/*
+	 * If JTAG probe sets special word at 0xe6300020, then it must
+	 * put U-Boot into RAM and TPL will start it from RAM.
+	 */
+	if (readl(CONFIG_TPL_TEXT_BASE + 0x20) == jtag_magic) {
+		printf("JTAG boot detected!\n");
+
+		while (readl(CONFIG_TPL_TEXT_BASE + 0x24) != load_magic)
+			;
+
+		spl_boot_list[0] = BOOT_DEVICE_RAM;
+		spl_boot_list[1] = BOOT_DEVICE_NONE;
+
+		return;
+	}
+#endif
+
 	/* Boot from SPI NOR with YMODEM UART fallback. */
 	spl_boot_list[0] = BOOT_DEVICE_SPI;
 	spl_boot_list[1] = BOOT_DEVICE_UART;
diff --git a/configs/porter_defconfig b/configs/porter_defconfig
index a0e44df5f8..e4a2828ed4 100644
--- a/configs/porter_defconfig
+++ b/configs/porter_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_ENABLE_ARM_SOC_BOOT0_HOOK=y
 CONFIG_ARCH_RMOBILE=y
 CONFIG_SYS_TEXT_BASE=0x50000000
 CONFIG_SPL_GPIO_SUPPORT=y
@@ -29,6 +30,8 @@ CONFIG_SPL_YMODEM_SUPPORT=y
 CONFIG_TPL=y
 CONFIG_TPL_BOARD_INIT=y
 CONFIG_TPL_NEEDS_SEPARATE_TEXT_BASE=y
+CONFIG_TPL_RAM_SUPPORT=y
+CONFIG_TPL_RAM_DEVICE=y
 CONFIG_TPL_SERIAL_SUPPORT=y
 CONFIG_TPL_SPI_FLASH_SUPPORT=y
 CONFIG_TPL_SPI_LOAD=y
-- 
2.16.2



More information about the U-Boot mailing list