c++ template library for embedded development

Openocd meets a NUCLEO-F030R8 board

[Edit: newer versions of openocd (0.8) support the stlink-v2-1 on the nucleo board without the changes described below]

STMicroelectronics recently announced a new line of mbed compatible development boards at a great price (~$10.32). The four “NUCLEO” boards support a range of Cortex M0, M3, low power M3, and an M4 STM32 chips with more boards to come in the future (see announcement link below). This post assumes you are used to working with the STM32FX Discovery boards and openocd. Knowing how to build openocd from source wouldn’t hurt either.

New Features

I snapped up one of the NUCLEO-F030 Cortex-M0 boards before they all disappeared from mouser.com and it arrived with the UPS man yesterday. These boards combine a programming device with a target user chip. The new firmware on the programming side of the NUCLEO board adds some long sought after missing features from the normal Discovery STLink-V2 versions. The NUCLEO board presents itself as a a composite USB device. In addition to the normal STLink-V2 interface, added are a CDC ACM device and a Mass Storage Device. The CDC ACM device shows up as a Serial Virtual COM Port and the Mass Storage Device provides drag and drop firmware loading to the target MCU.

Issues with openocd

The first thing I did was boot up windows even though my main operating system is linux. The device shows up as a removable disk drive with one file named mbed.htm. Opening that file with a browser takes you to the http://mbed.org login page. I created a userid and noticed that the first thing they want you to do is to upgrade the firmware on the NUCLEO board. I installed the new firmware and then rebooted into linux. I was hoping that I would be able to use the stock openocd with some minor configuration file changes. Unfortunately that didn’t happen. The new firmware shows up with a different VID/PID and the USB endpoint addresses have changed.

Let’s fix openocd

The new NUCLEO composite USB device has a new VID:PID combo 0483:374b . I noticed that the STLink-V2 portion of the device appeared to be very similar to the standard STLink-V2 one only differing in the endpoint addresses. I crossed my fingers and made the following simple modifications to the openocd source and recompiled. In addition, I created two new configuration files that describe the board and its interface, nucleo.cfg and a stlink-v2-1.cfg. I was happily surprised when I fired up openocd and it worked on the first shot.

This patch applied to the openocd github source code changes the stlnk_usb.c code so it works only with the nucleo board:

and also a new interface file with the proper VID/PID for the stlink-v2-1 firmware:

interface/stlink-v2-1.cfg

1

2

3

4

5

6

7

8

#

# STMicroelectronics ST-LINK/V2-1 in-circuit debugger/programmer

#

interfacehla

hla_layout stlink

hla_device_desc"ST-LINK/V2"

hla_vid_pid0x04830x374b

How to run it:

With those changes in place, compile and install openocd and copy the config files into the destination scripts directory. Execute openocd and see if it finds your board and connects to it. In one window run:

1

2

3

4

5

6

7

8

9

10

11

# openocd -f board/nucleo.cfg

Open On-Chip Debugger0.8.0-dev-00350-g6c74255(2014-02-20-11:42)

Licensed under GNU GPL v2

Forbug reports,read

http://openocd.sourceforge.net/doc/doxygen/bugs.html

srst_only separate srst_nogate srst_open_drain connect_deassert_srst

Info:Thisadapter doesn'tsupport configurable speed

Info:STLINK v2 JTAG v19 API v2 SWIM v3 VID0x0483PID0x374B

Info:using stlink api v2

Info:Target voltage:3.241334

Info:stm32f0x.cpu:hardware has4breakpoints,2watchpoints

in another window use arm-none-eabi-gdb to connect to the openocd gdb server: