Editing Maple JTAG How To

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
The [http://wiki.leaflabs.com/index.php?title=Maple_JTAG_How_To Maple JTAG How To] has moved to the [http://wiki.leaflabs.com LeafLabs wiki].
+
This is a page about using [http://en.wikipedia.org/wiki/Joint_Test_Action_Group JTAG] with Maple - JTAG will allow you to use a debugger program like GDB to debug programs running on the Maple. You can also use the JTAG adapter to re-flash (re-install) the bootloader in case you "brick" the board and can't install programs on it via the bootloader.
 +
 
 +
* [http://leaflabs.com/docs/jtag.html Maple JTAG information page]
 +
 
 +
== JTAG Debugger ==
 +
 
 +
You need a piece of hardware called a JTAG debugger to manage the connection and debugging of the Maple. These plug into your computer via USB and into the Maple via its JTAG port.
 +
 
 +
* [http://www.olimex.com/dev/arm-usb-ocd.html Olimex ARM-USB-OCD] - only this debugger is known to work. Olimex's ARM-USB-TINY is known not to work.
 +
* [http://www.sparkfun.com/products/7834 ARM-USB-OCD at Sparkfun]
 +
 
 +
If you know of other JTAG debuggers that are known to work, add them here.
 +
 
 +
== JTAG Adapter ==
 +
 
 +
Maple's 8-pin JTAG port is non-standard, so you need an adapter circuit to go between the ARM 20-pin connector and the Maple 8-pin connector.
 +
 
 +
* [https://github.com/adamfeuer/maple/tree/master/jtagadapter Maple JTAG adapter circuit and board layout] - the one in Maple's source tree may work, but has extra resistors and other errors. This circuit is known to work.
 +
* [https://github.com/adamfeuer/maple/raw/master/jtagadapter/maple-jtagadapter.png Circuit diagram]
 +
* [https://github.com/adamfeuer/maple/blob/master/jtagadapter/maple-jtagadapter-brd.png picture of PCB design]
 +
 
 +
== OpenOCD ==
 +
 
 +
[http://openocd.berlios.de/web/ OpenOCD] is a program that can talk with the JTAG debugger. You can give commands to it directly, or you can configure GDB to use it to control your Maple board.
 +
 
 +
Download the latest version of OpenOCD, build it, and install it. Then you can use Maple's build tools (Make) to run the JTAG debugger, or run it standalone so you can connect via another program.
 +
 
 +
You will need to edit the OpenOCD configuration files to make them work with recent OpenOCD versions. Make the following changes:
 +
* File support/openocd/run.cfg:
 +
** Add at the beginning of the file
 +
<pre>
 +
#daemon configuration
 +
telnet_port 4444
 +
gdb_port 3333
 +
</pre>
 +
Replace this line:
 +
<pre>
 +
flash bank stm32x 0x08000000 0x00020000 0 0 $_TARGETNAME
 +
</pre>
 +
 
 +
*: with this:
 +
 
 +
<pre>
 +
set _FLASHNAME $_CHIPNAME.flash
 +
flash bank $_FLASHNAME stm32x 0x08000000 0x00020000 0 0 $_TARGETNAME
 +
</pre>
 +
 
 +
== Eclipse C/C++ ==
 +
 
 +
If you want to use a visual debugger instead of GDB, you can use the Eclipse C/C++ tools. Here is an outline of the steps:
 +
 
 +
# OpenOCD 0.4.0 from source. I installed the Codesourcery ARM toolchain from http://static.leaflabs.com/pub/codesourcery/ The direct URL for linux is: http://static.leaflabs.com/pub/codesourcery/arm-2009q3-68-arm-none-eabi-toolchain-linux32.tar.gz
 +
# Install Eclipse C/C++ Helios from http://www.eclipse.org/downloads/
 +
# Install the Zylin remote debugger Eclipse plugin using the instructions at http://opensource.zylin.com/embeddedcdt.html
 +
# Configure OpenOCD and Zylin using this guide: http://linuxfreak.pl/elektronika/debugging-stm32-cortex-m3-microcontroller-using-eclipse-on-slackware
 +
# Then I used Eclipse to launch OpenOCD, and started the debugger using a Debug Configuration. You can copy examples/blinky.cpp to main.cpp, then start and stop the program using the debugger!
 +
 
 +
Here is a screenshot of blinky.cpp (main.cpp) stopped at a breakpoint: http://imgur.com/9CZ6q
 +
 
 +
The USB interrupts are enabled, so single-stepping lands you in the USB interrupt service routine (ISR). You can disable the USB interrupts by commenting out the setupUSB() line in wirish/wirish.c .
 +
 
 +
== Reflashing the bootloader ==
 +
 
 +
You can use OpenOCD to re-flash (re-install) the bootloader if you accidentally "brick" the board somehow - if you can't install programs via the bootloader any more and resetting doesn't help. Here's how.
 +
 
 +
* Read the guide here for background info: http://fun-tech.se/stm32/OpenOCD/gdb.php
 +
* Build the Maple bootloader
 +
** Check out a copy of the maple-bootloader from github: https://github.com/leaflabs/maple-bootloader
 +
** Build it by typing 'make' in the root of the project
 +
* Start OpenOCD:
 +
<pre>
 +
$ openocd -f support/openocd/run.cfg
 +
Open On-Chip Debugger 0.4.0 (2010-11-28-20:19)
 +
Licensed under GNU GPL v2
 +
For bug reports, read
 +
http://openocd.berlios.de/doc/doxygen/bugs.html
 +
1000 kHz
 +
jtag_nsrst_delay: 100
 +
jtag_ntrst_delay: 100
 +
trst_and_srst separate srst_gates_jtag trst_push_pull srst_open_drain
 +
Info : clock speed 1000 kHz
 +
Info : JTAG tap: stm32.cpu tap/device found: 0x3ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x3)
 +
Info : JTAG tap: stm32.bs tap/device found: 0x16410041 (mfg: 0x020, part: 0x6410, ver: 0x1)
 +
Info : stm32.cpu: hardware has 6 breakpoints, 4 watchpoints
 +
Info : JTAG tap: stm32.cpu tap/device found: 0x3ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x3)
 +
Info : JTAG tap: stm32.bs tap/device found: 0x16410041 (mfg: 0x020, part: 0x6410, ver: 0x1)
 +
</pre>
 +
* From another terminal window, telnet to the OpenOCD shell:
 +
<pre>
 +
telnet localhost 4444
 +
</pre>
 +
You should see something like:
 +
<pre>
 +
Connected to localhost.
 +
Escape character is '^]'.
 +
Open On-Chip Debugger
 +
>
 +
</pre>
 +
* Type the following into the OpenOCD shell:
 +
<pre>
 +
reset
 +
halt
 +
flash probe 0
 +
stm32x mass_erase 0
 +
flash write_bank 0 build/maple_boot.bin 0
 +
reset
 +
</pre>
 +
* Disconnect the JTAG connector from the Maple board.
 +
* Now you should be able to reset the board using the reset switch, the LED should blink rapidly, and you should be able to use the bootloader again.
 +
 
 +
== Reset Halt ==
 +
 
 +
'reset halt' is an OpenOCD command that resets the board and then immediately halts it, leaving the debugger in control of the board before it starts executing code.
 +
 
 +
You cannot do a 'reset halt' command with OpenOCD using Maple revisions up to Maple rev 5, because nJTRST and nTRST are currently connected. They may be separated on future Maple revisions, and then a 'reset halt' would work.

Please note that all contributions to OpenCircuits may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see OpenCircuits:Copyrights for details). Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)