RZ-G/RZG openocd: Difference between revisions

From Renesas.info
No edit summary
No edit summary
Line 62: Line 62:
* SW2405: change to (1-2) side
* SW2405: change to (1-2) side
<br>
<br>


== OpenOCD setup ==
== OpenOCD setup ==
Line 87: Line 86:
In configuration, you may need to add option โ€œ--enable-ftdiโ€ to ensure ftdi related function (which Flyswatter2 uses) will be built. Same for J-Link, with โ€œ--enable-jlinkโ€, however both should be recognized and added automatically during the configuration phase.
In configuration, you may need to add option โ€œ--enable-ftdiโ€ to ensure ftdi related function (which Flyswatter2 uses) will be built. Same for J-Link, with โ€œ--enable-jlinkโ€, however both should be recognized and added automatically during the configuration phase.


'''Run openocd'''<br>
== Run openocd ==
OpenOCD provides many setting scripts for many JTAG debugger and development boards under directory share/openocd/scripts/.
OpenOCD provides many setting scripts for many JTAG debugger and development boards under directory share/openocd/scripts/.
Users must find two suitable scripts to use for their environment, one for Debugger and one for the development board.
Normally two suitable scripts has to be chosen, one for Debugger configuration and one for the development board or chip.
For debug with Flyswatter2 on RZ/G2 development boards, below scripts are suitable:
ย 
To debug with Flyswatter2 the following scripts is available:
* Flyswatter2: interface/ftdi/flyswatter2.cfg
* Flyswatter2: interface/ftdi/flyswatter2.cfg
* RZ/G2 board: target/renesas_rcar_gen3.cfg
To debug with J-Link, instead:
For EK874 RZ/G2E board: set SOC E3
* J-Link: interface/jlink.cfg


renesas_rcar_gen3.cfg is the most suitable configure file for RZ/G2.
Then for the RZ/G2 family:
In this configure, โ€œE3โ€ SOC config is the most suitable config for EK874 RZ/G2E.
* RZ/G2 board: target/renesas_rz_g2.cfg
Thus, the run command to attach JTAG with OpenOCD is:
ย 
Finally different commands have to be used for the different devices belonging to the RZ/G2 family:
* SMARC RZ/G2L board: set SOC G2L (default), i.e. -c can be omitted
* EK874 RZ/G2E board: set SOC G2E
* HiHope RZ/G2M board: set SOC G2M
* HiHope RZ/G2N board: set SOC G2N
* HiHope RZ/G2H board: set SOC G2H
ย 
So, for example to run OpenOCD and attach to a RZ/G2L device using a Flyswatter 2 JTAG adapter:
<pre>
<pre>
$ sudo bin/openocd -f share/openocd/scripts/interface/ftdi/flyswatter2.cfg -c โ€œset SOC E3โ€ -f share/openocd/scripts/target/renesas_rcar_gen3.cfg
$ sudo bin/openocd -f share/openocd/scripts/interface/ftdi/flyswatter2.cfg -c โ€œset SOC G2Lโ€ -f share/openocd/scripts/target/renesas_rz_g2.cfg
</pre>
</pre>
Note: If below error appears
ย 
<pre>
You can modify the renesas_rz_g2.cfg configure file to tweak the clock speed (default 4MHz), for example to increase it to 15MHz:
Error: Ana adapter speed is not selected in teh init script. Insert a call to "adapter speed" or "jtag_rclk" to proceed.
</pre>
User has to modify flyswatter2.cfg configure file to fix missing โ€œadater speedโ€. Just add below line to the end of that file, then rerun the command:
<pre>Adapter speed 15000</pre>
<pre>Adapter speed 15000</pre>


If openocd command succeeds, message like bellow will appear
If openocd command succeeds, a message like below appears:
<pre>
<pre>
$ sudo bin/openocd -f share/openocd/scripts/interface/ftdi/flyswatter2.cfg -c "set SOC E3" -f share/openocd/scripts/target/renesas_rcar_gen3. cfg
Open On-Chip Debugger 0.11.0+dev-00182-gbd1569d1b-dirty (2021-05-25-10:23)
Open On-Chip Debugger 0.10.0+dev-01383-gd46f28c-dirty (2020-08-31-17: 22)
Licensed under GNU GPL v2
Licensed under GNU GPL v2
For bug reports, read
For bug reports, read
ย  ย  ย  ย  http://openocd.org/doc/doxygen/bugs.html
http://openocd.org/doc/doxygen/bugs.html
adapter speed: 15000 kHz
G2L
ย 
G2L - 0 CA57(s), 2 CA55(s), 0 CA53(s), 0 CR7(s),ย  1 CM33(s)
E3
Boot Core - CA55
ย  ย  ย  ย  E3 - 0 CA57(s), 1 CA53(s), 1 CR7(s)
ย  ย  ย  ย  Boot Core - CA53


Info : auto-selecting first available session transport "jtag". To override use 'transport select <transport>.
r9a07g044l.cpu
Info : Listening on port 6666 for tcL connections
SMP targets: r9a07g044l.a55.0 r9a07g044l.a55.1
init_reset
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : Listening on port 4444 for telnet connections
Info : ftdi : if you experience problems at higher adapter clocks, try the comamnd "ftdi_tdo_sample_ edge falling"
Info : J-Link Lite V9 compiled May 17 2019 10:18:57
Info : clock speed 15000 kHz
Info : Hardware version: 9.00
Info : JTAG tap: r8a77990.cpu tap/device found: Ox5ba00477 (mfg: Ox23b (ARM Ltd.), part: 0xba00, ver: 0x5)
Info : VTarget = 1.833 V
Info : r8a77990. a53.0: hardware has 6 breakpoi-nts, 4 watchpoints
Info : clock speed 4000 kHz
Info : starting gdb server for r8a77990.A53.0 on 3333
Info : JTAG tap: r9a07g044l.cpu tap/device found: 0x6ba00477 (mfg: 0x23b (ARM Ltd), part: 0xba00, ver: 0x6)
Info : DAP transaction stalled (WAIT) - slowing down
Info : DAP transaction stalled during replay (WAIT) - resending
Info : DAP transaction stalled (WAIT) - slowing down
Info : r9a07g044l.a55.0: hardware has 6 breakpoints, 4 watchpoints
Info : DAP transaction stalled (WAIT) - slowing down
Info : DAP transaction stalled during replay (WAIT) - resending
Info : r9a07g044l.a55.0 cluster 0 core 0 multi core
Info : starting gdb server for r9a07g044l.a55.0 on 3333
Info : Listening on port 3333 for gdb connections
Info : Listening on port 3333 for gdb connections
Info : starting gdb server for r8a77990.r7 on 3334
Info : starting gdb server for r9a07g044l.m33 on 3334
Info : Listening on port 3334 for gdb connections
Info : Listening on port 3334 for gdb connections
Info : accepting 'gdb' connection on tcp/3333
Info : gdb port disabled
Info : r8a77990.a53.0 cluster 0 core 0 multi-core r8a77990.a53.0 halted in AArch64 state due to debug-request, current mode: EL1H cpsr: 0x600003c5 pc: Ox5002fd6c
MMU: enabled, D-Cache: enabled, I-Cache: enabled
Info : New GDB Connection: 1, Target r8a77990.a53.0, state: halted
Warn : Prefer GDB command "target extended-remote 3333" instead of "target remote 3333"
</pre>
</pre>
Note that โ€œE3โ€ and โ€œr8a77990โ€ in these messages are not correct for RZ/G2 platform. They are shown because configure renesas_rcar_gen3.cfg was used.


== Start debugging ==
== Start debugging ==

Revision as of 09:21, 28 May 2021

โ† RZ-G

Introduction

This page provides a guide to use OpenOCD and compatible JTAG debugger devices on RZ/G2 platforms.

Target Device

Overview

OpenOCD is an opensource software that provides on-chip programming and debugging feature, with support from compatible JTAG hardware debugger devices.

Prerequisites
A compatible JTAG hardware debugger device is required. Different JTAG devices can have slightly different procedure.
As an example, following guidance is for:

Environment

Below illustration shows how user should connect RZ/G2 platform with JTAG debugger and OpenOCD (run on a Linux Host PC). Note that most RZ/G2 development board has 10 pin JTAG header, so a JTAG converter (20pin-10pin) is required, for example the Olimex ARM-JTAG-20-10. The following pictures illustrates how to setup the environment with a Flyswatter2 and a EK874 (RZ/G2E) board. The setup is similar if other JTAG debuggers and/or devices are used.

openocd env1.png

Hardware setup

After connecting the devices as per guide in the previous section, follow below instructions to use OpenOCD and JTAG debugger. You must change the switches setting on development board to enable the JTAG debugging feature. The switches setting may be different for each development board. Please refer to the relevant board manual or user guide for detailed information.

SMARC RZ/G2L board

Change switches as per below.

SMARC JTAG SW1.png

  • SW1: OFF - OFF


EK874 RZ/G2E board

Change switches as per below. Note that board version 3 (Rev C) or later must be used.

rzg2e openocd switch settings.png

  • SW12: change bit 4 and 5 to OFF to enable JTAG
  • SW50: change to (2-3) side
  • SW51: change to (1-2) side


HiHope RZ/G2M-N-H board

Change switches as per below. Note that board version 3 (Rev C) or later must be used.

HiHope board.jpg SW1003.jpg SW305-SW2405.jpg

  • SW1003: change bit 4 to OFF to enable JTAG
  • SW305: change to (2-3) side
  • SW2405: change to (1-2) side


OpenOCD setup

Make sure you have all the necessary packages installed:

$sudo apt-get install libtool pkg-config texinfo libusb-dev libusb-1.0.0-dev libftdi-dev autoconf

Download OpenOCD
You can get latest OpenOCD software from the repository:

$ git clone https://github.com/ntfreak/openocd
$ cd openocd

Next, follow instruction from github to build openocd.

$ ./bootstrap
$ ./configure --prefix ${PWD}/installdir
$ make
$ make install

In configuration, you may need to add option โ€œ--enable-ftdiโ€ to ensure ftdi related function (which Flyswatter2 uses) will be built. Same for J-Link, with โ€œ--enable-jlinkโ€, however both should be recognized and added automatically during the configuration phase.

Run openocd

OpenOCD provides many setting scripts for many JTAG debugger and development boards under directory share/openocd/scripts/. Normally two suitable scripts has to be chosen, one for Debugger configuration and one for the development board or chip.

To debug with Flyswatter2 the following scripts is available:

  • Flyswatter2: interface/ftdi/flyswatter2.cfg

To debug with J-Link, instead:

  • J-Link: interface/jlink.cfg

Then for the RZ/G2 family:

  • RZ/G2 board: target/renesas_rz_g2.cfg

Finally different commands have to be used for the different devices belonging to the RZ/G2 family:

  • SMARC RZ/G2L board: set SOC G2L (default), i.e. -c can be omitted
  • EK874 RZ/G2E board: set SOC G2E
  • HiHope RZ/G2M board: set SOC G2M
  • HiHope RZ/G2N board: set SOC G2N
  • HiHope RZ/G2H board: set SOC G2H

So, for example to run OpenOCD and attach to a RZ/G2L device using a Flyswatter 2 JTAG adapter:

$ sudo bin/openocd -f share/openocd/scripts/interface/ftdi/flyswatter2.cfg -c โ€œset SOC G2Lโ€ -f share/openocd/scripts/target/renesas_rz_g2.cfg

You can modify the renesas_rz_g2.cfg configure file to tweak the clock speed (default 4MHz), for example to increase it to 15MHz:

Adapter speed 15000

If openocd command succeeds, a message like below appears:

Open On-Chip Debugger 0.11.0+dev-00182-gbd1569d1b-dirty (2021-05-25-10:23)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
G2L
	G2L - 0 CA57(s), 2 CA55(s), 0 CA53(s), 0 CR7(s),  1 CM33(s)
	Boot Core - CA55

r9a07g044l.cpu
SMP targets: r9a07g044l.a55.0 r9a07g044l.a55.1
init_reset
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : J-Link Lite V9 compiled May 17 2019 10:18:57
Info : Hardware version: 9.00
Info : VTarget = 1.833 V
Info : clock speed 4000 kHz
Info : JTAG tap: r9a07g044l.cpu tap/device found: 0x6ba00477 (mfg: 0x23b (ARM Ltd), part: 0xba00, ver: 0x6)
Info : DAP transaction stalled (WAIT) - slowing down
Info : DAP transaction stalled during replay (WAIT) - resending
Info : DAP transaction stalled (WAIT) - slowing down
Info : r9a07g044l.a55.0: hardware has 6 breakpoints, 4 watchpoints
Info : DAP transaction stalled (WAIT) - slowing down
Info : DAP transaction stalled during replay (WAIT) - resending
Info : r9a07g044l.a55.0 cluster 0 core 0 multi core
Info : starting gdb server for r9a07g044l.a55.0 on 3333
Info : Listening on port 3333 for gdb connections
Info : starting gdb server for r9a07g044l.m33 on 3334
Info : Listening on port 3334 for gdb connections
Info : gdb port disabled

Start debugging

Now that openocd command has succeeded, user can run GDB on Linux Host PC and attach to GDB Server created by OpenOCD (the port is shown in OpenOCD log, default is 3333).

$ gdb
(gdb) target remote localhost:3333

After that, gdb and openocd will show message like below.
This mean GDB has connected successfully. After this, user can control and debug device by GDB (refer to GDB guide https://sourceware.org/gdb/current/onlinedocs/gdb/).

$ gdb
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16 5) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc
License GPLv3+ GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
Thus is free software: you are free to change and redustribute it.
There us NO WARRANTY, to the extent permitted by Law. Type "show copying"
and "show warranty for details.
This GDB was configured as "x86 64-1inux gnu".
Type "show configuratuon" for configuratuon details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentatuon/>
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) target remote Localhost: 3333
Remote debugging using localhost: 3333
warning: while parsing target description (at lune 4):
Target description specified unknown architecture " aarch64"
warning: Could not load XML target description, ignoring
Oxbde17ecO in ?? ( )
(gdb)