Archive for February, 2013

Debugging STM32 with GDB and OpenOCD

Screenshot from 2013-02-23 00:28:10

When developing my Valentine’s day puzzle box, I found myself really wanting to single-step through some code to figure out where things were going wrong.  Fortunately, the STM32F3 Discovery board that I was using supports on-chip debugging.  Unfortunately, it wasn’t already integrated into the template that I was using for the project.


Valentine’s day puzzle box



***UPDATE*** I’m going to make some updates to the code, so I’ve modified all the github links below to point to a tagged version. For the latest-and-greatest code, look here.

After I saw this post on about ST Microelectronics giving away STM32F3 Discovery boards for free, I knew I had to have one, but I didn’t really have a specific project in mind for a while.  Then, one day I remembered a reverse geocache box that was also featured on hackaday, and realized that I could do something similar.  The F3 Discover board includes a 3-axis accelerometer & 3-axis gyroscope, so instead of using GPS, I would only have the box open when it was rotated through the correct sequence of orientations.

For those who don’t want to read the whole post below, the code is posted on my github repository.  Also, those looking for photos should skip to the last half of the post.

Since I had ordered the free sample in late November, I figured that I’d have enough time to make this puzzle box as a Christmas gift for my wife.  Unfortunately, it didn’t arrive until the day that we celebrated our early Christmas (before we travelled to see our families). Not quite enough time to throw it together…  Fortunately, that just meant that I had more time to put something together by the next gift-giving opportunity…St. Valentine’s day.


I know USB

I’ve been trying to get my STM32F3 Discovery board to register as a Virtual COM Port (i.e. RS232 serial over USB) when I plug it in via the “USB User” port.  I had a false start trying to use the code for the F4 Discovery from here…Apparently, the USB hardware is too different between the 2 boards.

However, I did manage to get the example USB joystick/mouse code from the F3 Discovery firmware package from the ST website to run.  It is pretty neat…tilt the board one way or another, and the cursor moves!

That code, along with this “USB in a NutShell” guide, and this description of the USB CDC Virtual COM Port should give me enough info to implement what I want.  After reading through “USB in a NutShell”, I feel like this meme is appropriate…