R-Car/Boards/JTAG-Gen2

Introduction
This is the Wiki for the JTAG recovery on Renesas R-Car Gen2 SoCs and boards. Refer to the R-Car page for information about Renesas' R-Car SoC family.

Supported boards
As of OpenOCD master commit 087a162e3c64f1bd67543d0c8c902bd70044b1af, the following SoCs and boards are supported:

Prerequisites
- Supported Gen2 board

- Serial console

- JTAG adapter supported by OpenOCD, ie. Flyswatter2

Building required software
- Follow OpenOCD documentation to build the latest version of OpenOCD.

- Follow U-Boot on Gen2 documentation to build the latest version of U-Boot for the board.

Recovering a platform
Recovering a Gen2 platform is done by starting U-Boot via JTAG and flashing U-Boot onto the board.

1) Connect a JTAG adapter to the board

2) Power up the board

3) Start OpenOCD  $ openocd -s tcl/ -f tcl/interface/ftdi/flyswatter2.cfg -f board/renesas_porter.cfg   Open On-Chip Debugger 0.10.0+dev-00389-gb2ce6079 (2018-04-07-21:59)   Licensed under GNU GPL v2   For bug reports, read           http://openocd.org/doc/doxygen/bugs.html   Info : auto-selecting first available session transport "jtag". To override use 'transport select '.   trst_and_srst separate srst_nogate trst_push_pull srst_open_drain connect_deassert_srst   adapter speed: 25000 kHz   Info : Listening on port 6666 for tcl connections   Info : Listening on port 4444 for telnet connections   Info : ftdi: if you experience problems at higher adapter clocks, try the command "ftdi_tdo_sample_edge falling"   Info : clock speed 25000 kHz   Info : JTAG tap: r8a7791.cpu tap/device found: 0x4ba00477 (mfg: 0x23b (ARM Ltd.), part: 0xba00, ver: 0x4)   Info : r8a7791.ca15.0: hardware has 6 breakpoints, 4 watchpoints Info : Listening on port 3333 for gdb connections Info : Listening on port 3334 for gdb connections

4) Start U-Boot SPL via JTAG and set up special marker to indicate JTAG recovery

$ telnet localhost 4444 Trying ::1...  Trying 127.0.0.1...   Connected to localhost. Escape character is '^]'. Open On-Chip Debugger >  > reset halt JTAG tap: r8a7791.cpu tap/device found: 0x4ba00477 (mfg: 0x23b (ARM Ltd.), part: 0xba00, ver: 0x4) Debug regions are unpowered, an unexpected reset might have happened JTAG-DP STICKY ERROR Deferring arp_examine of r8a7791.ca15.1 Use arp_examine command to examine it manually! r8a7791.ca15.0: ran after reset and before halt ...  r8a7791.ca15.1: ran after reset and before halt ... r8a7791.ca15.0 rev 2, partnum c0f, arch f, variant 3, implementor 41 r8a7791.ca15.0 cluster 0 core 0 multi core target halted in ARM state due to debug-request, current mode: Supervisor cpsr: 0x800001d3 pc: 0x00002668 r8a7791.ca15.0 rev 2, partnum c0f, arch f, variant 3, implementor 41 MMU: disabled, D-Cache: disabled, I-Cache: disabled >  > load_image u-boot-spl.bin 0xe6300000 bin 14468 bytes written at address 0xe6300000 downloaded 14468 bytes in 0.052571s (268.759 KiB/s) >  > mww 0xe6300020 0x1337c0de >  > resume 0xe6300000

This will generate the following output on the serial console:

U-Boot SPL 2018.05-rc2-00121-gc95272444f (Apr 26 2018 - 16:01:11 +0200) JTAG boot detected!

5) Start U-Boot via JTAG and set up special marker to continue JTAG recovery

> halt target halted in Thumb state due to debug-request, current mode: Supervisor cpsr: 0x000001f3 pc: 0xe6300446 r8a7791.ca15.0 rev 2, partnum c0f, arch f, variant 3, implementor 41 MMU: disabled, D-Cache: disabled, I-Cache: enabled >  > load_image /mnt/work/OSAB/u-boot/u-boot.img 0x4fffffc0 bin 448768 bytes written at address 0x4fffffc0 downloaded 448768 bytes in 1.669676s (262.476 KiB/s) >  > mww 0xe6300024 0xb33fc0de >  > resume

This will generate the following output on the serial console:

U-Boot 2018.05-rc2-00121-gc95272444f (Apr 26 2018 - 16:01:11 +0200) CPU: Renesas Electronics R8A7791 rev 3.0 Model: Porter Board: Porter DRAM: 1 GiB MMC:  sd@ee100000: 0, sd@ee160000: 1 In:   serial@e6e60000 Out:  serial@e6e60000 Err:  serial@e6e60000 Net: Error: ethernet@ee700000 address not set. No ethernet found. =>

6) Set up U-Boot environment as required

NOTE: The U-Boot environment is ignored during recovery to prevent any potential interference with the recovery operation. Any and all required environment must be set manually during the recovery, ie. to get networking operational:

=> setenv ethaddr 00:gg:hh:ii:jj:kk => setenv ipaddr 192.168.1.300 => setenv netmask 255.255.255.0

7) Install fresh U-Boot onto the board

Follow standard installation procedure for Gen2 U-Boot, Updating U-Boot on Gen2.

NOTE: To reset board environment for the newly installed U-Boot, erase the U-Boot environment area: => sf probe => sf erase 0xc0000 0x40000

Known issues
- Upstreaming of board support to OpenOCD is work in progress