Maple JTAG How To
This is a page about using 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.
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.
- Olimex ARM-USB-OCD - only this debugger is known to work. Olimex's ARM-USB-TINY is known not to work.
- 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.
- 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.
- Circuit diagram
- picture of PCB design
OpenOCD
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
#daemon configuration telnet_port 4444 gdb_port 3333
Replace this line:
-flash bank stm32x 0x08000000 0x00020000 0 0 $_TARGETNAME
- with this:
set _FLASHNAME $_CHIPNAME.flash flash bank $_FLASHNAME stm32x 0x08000000 0x00020000 0 0 $_TARGETNAME
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 .