The STMicroelectronics STM32F103 (ARM Cortex-M3) Nucleo boards include the on-board ST-Link v2 circuit which allows to debug the board. This circuit is similar to the OpenSDA circuit found on Freescale boards. Unlike the Freescale OpenSDA, the ST-Link is only the ST-Link: it is not possible to load a P&E Multilink or Segger J-Link or firmware on it. Luckily, the ST-Link has a SWD connector, but this connector is a non-standard one. So how can I debug that board with an Eclipse based environment with GNU ARM Eclipse plugins and a Segger J-Link?
In this article I show how to debug the STM32F103RB Nucleo board, using an Eclipse Mars based distribution with and a Segger J-Link. Using the Segger J-Link with a Nucleo board, it requires to connect to the SWD connector on the ST-Link side of the board. The steps described here can be used for any other Nucleo board, as they should have the same SWD connector.
The ST-Link v2 part of the Nucleo board has a 6-pin (CN4) header which can be used to debug the STM32F103RB on the Nucleo board.
The CN4 connector has the following pins:
The Segger J-Link uses the ‘standard’ 20 pin adapter (see https://www.segger.com/interface-description.html):
I’m connecting the Segger J-Link to the STM32 board like this (colors refer to the cables shown in the pictures):
Pin 1 is on the top on the right side. The lower row of pins are connected to GND (except the first one, pin 2). The yellow cable shown in th picture is toe connect GND to the Nucleo board, so any of the lower row pins (except the first one, pin 2) can be used.
So far so good: I need to tell to the Segger J-Link that the CPU is powered (VDD_Target): The J-Link senses the power of the target with VTref (Voltage Target Reference) pin. On the Nucleo board that pin on the CN4 header is not powered: the Resistor R9 (near the connector) is not populated on the board.
I think the idea would be that the ST-Link would control it with the AIN_1 signal, but again, it is not connected. The easiest way is to provide 3.3V from the Arduino Header 3.3V pin (brown cable in the picture):
The GNU ARM Eclipse Plugins come with project wizard and templates for the STMicroelectronics devices.
To create a new project for the STM32F103, I use the menu File > New > Project:
I could have selected ‘C++ Project’ or ‘C Project’ too. I I have selected ‘Project…’ then I can now select the kind of project:
I give a project name, select the device with the toolchain:
If using semihosting (do not forget to have it turned on in the debug configuration), Trace output can be enabled. If not using semihosting, it can be set to None:
The next dialogs I can keep with the defaults, so click next finish and create the project.
Build the project, and there should be no errors.
Open the debug configurations and create a new configuration for Segger J-Link. I use
as the device:
With this, ready to debug. And voilà I’m able to debug the Nucleo board with the Segger J-Link:
The STMicroelectronics board has an onboard ST-Link debug interface. To debug it with another debug probe like the Segger J-Link, I have to connect the debug probe with the SWD connector on the ST-Link side. Because that connector is non-standard, I need to create a special cable/connector for it. This allows me to use a standard SWD probe with the Nucleo board.
- STM32 Nucleo 64 Reference Manual: http://www.st.com/web/en/resource/technical/document/user_manual/DM00105823.pdf
- STM32F103RB Schematics: http://www.st.com/st-web-ui/static/active/en/resource/technical/layouts_and_diagrams/schematic_pack/nucleo_64pins_sch.zip
- GNU ARM Eclipse Plugins and Blog: http://gnuarmeclipse.livius.net/blog/
- Segger J-Link Debug Probes: https://segger.com/jlink-debug-probes.html