Debugging the STM32 using IAR, OpenOCD, GDB, and OpenJTAG
Update: ST has made it so much easier if you get their STM32F4Discovery board. It costs about $20, has a STM32F407VGT6 and a smaller ARM as a programmer, a few LEDs, a sound decoder, and a MEMS accelerometer. All you need to program this thing is a USB port.
If only I had access to these technologies when I started learning...
- - - - -
Finally got two LEDs blinking on a STM32 Cortex-M3 breakout board. The chip is STM32F103RBT6, which has 20 kB of RAM and 128 kB of FLASH memory.
Programming was done using the "IAR Embedded Workbench IDE 6.10 for ARM", GDB, and OpenOCD.
Physical connection from PC to the target was done with a FT2232-based USB OpenJTAG dongle. In summary,
IAR -> GDB -> OpenOCD -JTAG-> STM32
This was done in Windows, so the GDB Server and ARM-GCC in YAGATO were used. The program is a sample IAR project that came with the breakout board, and is written in C.
A few notes after several days of trial and error:
- GDB and GDB server are two different things. A GDB server starts when OpenOCD connects to the target chip; the GDB then connects to this GDB server.
- After everything is installed, it should be possible to flash program/run/halt/poll... using any one of OpenOCD, GDB, and IAR IDE. OpenOCD is the lowest level. GDB is a standard debug interface that IAR and all others know, and GDB uses OpenOCD. IAR IDE knows the language of GDB, so it uses GDB to talks to OpenOCD, which in turns talk to your target chip.
- Keeping everything as default, to connect to OpenOCD: "telnet localhost 4444"; to GDB server (with YAGATO installed on WinXP): "arm-elf-gdb.exe", then "target remote localhost:3333". However when entering in the IAR IDE Options page, it is "localhost,3333". A COMMA, NOT A COLON:
- It is absolutely worthwhile to spend a little more and purchase a complete set of development tool with a board, a programmer, a matching compiler tool set, and a complete set of sample project source files. Should spend a little more to get the proper tools and get the job done instead of fighting with your own hammer, or even "compiling and debugging your own hammer". (IAR has a free KickStart version)
- IAR can generate a binary image file for Flash download besides the .out file it generates for debugging. To do this, turn on the "Generate additional output" in the Options page:
The config file I used for stm32 chips is here:
The config file for the specific OpenJTAG dongle is here:
All Rights Reserved. Stanley Lio, 2013