As your embedded applications get more complicated an On-Chip Debugger will save you a lot of time when things don’t run quite right. On-Chip Debugging (OCD) is just what it sounds like — a way to run your program on the target chip that lets you pause execution to examine values and change them if need be. The Arduino has no built-in method of using OCD, but the AVR chips used by the boards do. The caveat is that you need a proper AVR programmer to access the Debug Wire protocol, or a JTAG interface for some of the larger chips. In this case I’m going to be using an STM32 Discovery Board to give you an overview of OCD. But this will work the same way for any chip that has hardware debugging capabilities. Many IDE’s have debugging support built right in so that you can use a nice GUI as you work. But often these are just a front end for the command line tools I’ll be using. Join me after the break and we’ll get started.
openocd17 Articles
Template For Building STM32F0-Discovery Project In GCC
Yep, that blue light is blinking and I made it happen. I’ve been hard at work since I got my free STM32F0-Discovery board in the mail. Most recently I put together a starting template for building STM32F05x project on Linux. You’ll still need to install your own tool chain (I’m using the Code Sourcery G++: Lite Edition), but this makes it a snap to compile your projects with support for STM’s peripheral libraries.
As for programming, you may remember that I added support for writing to RAM in the stlink project. I’ve wasted spent a ton of time trying to get support for writing to Flash into that project. It’s just less of a hassle to use stlink than it is to work with OpenOCD. But I’ve really hit a wall getting the flash loader code to work. If you want to check out what I’ve done so far in that area I committed a very messy branch (see the commits for what code changes I’ve made).
In the mean time you can use OpenOCD to write images compiled with the template to your device. I included the ‘make program’ option in the Makefile to do this from command line. If you need help compiling OpenOCD check the readme in the template repository.
Versaloon Ported To STM8 And STM32 Discovery Boards
[Bingo] did some work porting Versaloon for STM8 and STM32 discovery boards. Versaloon is a multiple-architecture programmer that we saw a few weeks back. At its center is an STM32 microprocessor, which greatly simplifies the work necessary to use the two discovery boards instead. Flashing the firmware to the boards will zap the ST-link firmware and [Bingo] doesn’t know of a way to restore that so be warned. This hack is still pretty fresh off the bench, but so far it looks like vsprog and OpenOCD both work just fine with the new hardware.