As referenced in my JTAG Adapter post the OpenOCD project is an open source JTAG program and set of drivers. Professional JTAG programmers can commonly cost US $100 and up (some are thousands), and are often proprietary to a specific development toolset. Open source and open hardware efforts have made JTAG available at much lower cost and at least works with open source development toolsets such as gcc/gdb and Eclipse, as well as some commercial offerings that are built on Eclipse.
Olimex has collected these open source development toolsets with OpenOCD and created a single installer called Olimex OpenOCD Development Suite for use with their development boards and their JTAG programmer. Installing their suite is one of the easiest ways to get an ARM gcc toolchain installed on your system with an IDE and JTAG programmer. Their toolset includes OpenOCD, Eclipse, gcc/gdb, and Zylin Embedded CDT. Sample projects are provided for some of their Atmel, STM32, and NXP (LPC) boards. I found that I needed to perform slight revisions their OpenOCD scripts included in at least the SAM7-P256-cdc_FLASH project because they were out of date. Once that was done, I was using my JTAG adapter with their ARM7 board performing programming and debugging. This suite and examples can be leveraged to target other boards.
OpenOCD can also be used directly from the command line to make a connection with a board, and then use telnet to issue commands (see User's Guide) to direct it. From the command line you can verify and discover commands to issue to your board. In the following examples I will use my JTAG programmer to talk to the STM32F4Discovery board. I have a breakout board for this development board that includes a JTAG socket. I have disconnected the jumpers on the STM32F4Discovery for its onboard ST-LINK/V2 debugger, so I can use my JTAG programmer instead.
First you must have an interface script to talk to your JTAG programmer. From the openocd-0.6.1 directory, I copied scripts/interface/ftdi/flossjtag.cfg to the file ft2232h.cfg in the current directory. Then I commented out the ftdi_device_desc statement in that file, and appended
adapter_khz 500
to the end of the file.
$ bin/openocd-0.6.1.exe -f ft2232h.cfg -f scripts/target/stm32f4x.cfg
Open On-Chip Debugger 0.6.1 (2012-10-07-10:34)
Licensed under GNU GPL v2
For bug reports, read http://openocd.sourceforge.net/doc/doxygen/bugs.html
WARNING!
This file was not tested with real interface, it is based on code in ft2232.c.
Please report your experience with this file to openocd-devel mailing list,
so it could be marked as working or fixed.
Info : only one transport option; autoselect 'jtag'
adapter speed: 500 kHz
adapter speed: 1000 kHz
adapter_nsrst_delay: 100
jtag_ntrst_delay: 100
cortex_m3 reset_config sysresetreq
Info : clock speed 1000 kHz
Info : JTAG tap: stm32f4x.cpu tap/device found: 0x4ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x4)
Info : JTAG tap: stm32f4x.bs tap/device found: 0x06413041 (mfg: 0x020, part: 0x6413, ver: 0x0)
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints
Then I open a telnet window to localhost port 4444. From here I can issue various commands to OpenOCD to perform JTAG commands.
$ telnet localhost 4444
Open On-Chip Debugger
> reset halt
JTAG tap: stm32f4x.cpu tap/device found: 0x4ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x4)
JTAG tap: stm32f4x.bs tap/device found: 0x06413041 (mfg: 0x020, part: 0x6413, ver: 0x0)
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc
> flash probe 0
device id = 0x10016413
flash size = 1024kbytes
device id = 0x10016413
flash size = 1024kbytes
flash 'stm32f2x' found at 0x08000000
> flash banks
#0 : stm32f4x.flash (stm32f2x) at 0x08000000, size 0x00100000, buswidth 0, chipwidth 0
> flash list
{name stm32f2x base 134217728 size 1048576 bus_width 0 chip_width 0}
> flash erase_check 0
successfully checked erase state
# 0: 0x00000000 (0x4000 16kB) erased
# 1: 0x00004000 (0x4000 16kB) erased
# 2: 0x00008000 (0x4000 16kB) erased
# 3: 0x0000c000 (0x4000 16kB) erased
# 4: 0x00010000 (0x10000 64kB) erased
# 5: 0x00020000 (0x20000 128kB) erased
# 6: 0x00040000 (0x20000 128kB) erased
# 7: 0x00060000 (0x20000 128kB) erased
# 8: 0x00080000 (0x20000 128kB) erased
# 9: 0x000a0000 (0x20000 128kB) erased
# 10: 0x000c0000 (0x20000 128kB) erased
# 11: 0x000e0000 (0x20000 128kB) erased
> dump_image image.bin 0x08000000 0x100000
dumped 1048576 bytes in 14.406221s (71.080 KiB/s)
> flash write_image erase stm32f4discovery_00.s19
auto erase enabled
wrote 1048576 bytes from file stm32f4discovery_00.s19 in 31.499985s (32.508 KiB/s)
> reset run
JTAG tap: stm32f4x.cpu tap/device found: 0x4ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x4)
JTAG tap: stm32f4x.bs tap/device found: 0x06413041 (mfg: 0x020, part: 0x6413, ver: 0x0)
> exit
^C
There you have it, some example OpenOCD commands. Hope you learned something useful.
Your open ocd project looks too interesting.I am thinking to take your idea and implement those idea to my final year project as I am also working on ocd for my fyp.
ReplyDelete