Spark Logic

stm32duino core with System Workbench for bluepill

Rick Kimball Thu Apr 28, 2016 7:14 pm

[Note: since I first wrote this post, openstm32.org has released customized versions of eclipse for windows, linux and os/x. Those binaries are bundled with their plugin and other enhancements. It is best to download the latest version from http://www.openstm32.org ]

I put together our stm32duino core as an importable eclipse project. It is based on using the http://www.openstm32.org System Workbench eclipse plugin. My approach is different than what most people do, this setup isn’t using the Arduino Plugin. The required defines, and include paths, and executable paths are just set in the eclipse project properties. This project configuration might give you a quick start template for using a bluepill board and an stlink dongle with bare metal eclipse using the stm32duino arduino core. I’ve included a recent snapshot of the master github tree and made a few source code tweaks. The example “sketch” is in src/asciitable.cpp.

I’ve made a few assumptions. I assume you are using linux. I expect you to have a working Arduino 1.6.x with the arm-none-eabi-gcc installed. I assume you have eclipse mars installed along with the System Workbench for STM32 from the openstm32.org website. I assume you are using a red or blue pill stm32f103 board that uses the PA12 1.5k pull up resistor. I’m assuming you are going to program it using an Stlink V2 dongle, either the ebay clone, a real one stlink, or a discovery board wired to program an external board (the bluepill).

Just use the menu File/Import… select the General tab and the second selection item named “Existing Project into Workspace”. On the Import Dialog, click the “Select archive file:” radio button and select the bluepill.zip from the directory where you saved the file below

Then a quick build and debug should get you going.

If this get sufficient interest I’ll write more about it.

I put the archived project in bluepill.zip in a gist as it is too big to attach directly here:

https://gist.github.com/RickKimball/aa7 … uepill.zip

https://gist.github.com/RickKimball/aa7 … 0b8f92eba9

-rick

Running Debug and looking at the GPIO registers:

debug_01.gif
debug_01.gif (113.7 KiB) Viewed 3691 times

Replies

paksoft Fri Nov 24, 2017 4:44 pm

I’ve tried to use Rick’s bluepill.zip with AC6 in Windows 10 (64 bit), because setting up Linux is too difficult for me. I use blue pill and ST-Link from ebay.
I’m just newbie with eclipse software. I try to make several parameters adjustment and but finally, I’ve got error message. Does it look like fake ST-Link error?

Please give some suggestion.

pak

Rick Kimball Fri Nov 24, 2017 6:00 pm

You should probably create a new test project using System Workbench without using my project configuration. Verify that you can compile and debug on windows. It looks like you are specifying the wrong stlink device, based on the vid/pid mismatch.

VID/PID 0x0483 0x3748 for ST-Link/V2
VID/PID 0x0483 0x374b for ST-Link/V2-1

I setup the project expecting an stlink-v2 … if you are using a “nucleo like” device you could change:
source [find interface/stlink-v2.cfg] to
source [find interface/stlink-v2-1.cfg]

This was the openocd.cfg I used.
# An openocd config for the jc66_coreboard board with a single STM32F103C8Tx chip.
source [find interface/stlink-v2.cfg] set WORKAREASIZE 0x4000
transport select hla_swd
source [find target/stm32f1x_stlink.cfg] adapter_khz 950
# use software reset
reset_config none

Rick Kimball Fri Nov 24, 2017 6:32 pm

So I just upgraded my System Workbench. It seems the auto generated one now only actually works with stlink-v2-1 …

# This is an bluepill board with a single STM32F103CBTx chip
#
# Generated by System Workbench for STM32
# Take care that such file, as generated, may be overridden without any early notice. Please have a look to debug launch configuration setup(s)

source [find interface/stlink.cfg]

set WORKAREASIZE 0x5000

transport select “hla_swd”

set CHIPNAME STM32F103CBTx

# Enable debug when in low power modes
set ENABLE_LOW_POWER 1

# Stop Watchdog counters when halt
set STOP_WATCHDOG 1

# STlink Debug clock frequency
set CLOCK_FREQ 4000

# use hardware reset, connect under reset
# connect_assert_srst needed if low power mode application running (WFI…)
reset_config srst_only srst_nogate connect_assert_srst
set CONNECT_UNDER_RESET 1

source [find target/stm32f1x.cfg]

Searching in my Ac6 directory I find stlink.cfg .. has this:
$ find . -iname ‘stlink.cfg’
./SystemWorkbench/plugins/fr.ac6.mcu.debug_2.1.3.201710251246/resources/openocd/st_scripts/interface/stlink.cfg
$ vi $(find . -iname ‘stlink.cfg’)

…

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

interface hla
hla_layout stlink
hla_device_desc “ST-LINK/V2-1”
hla_vid_pid 0x0483 0x374b

You are going to have to use a custom openocd.cfg file you can’t use the auto generated one any more.

Note: It is a constant struggle to keep things working that once worked. Vendors upgrade their “features” and usually the people who are doing the changes don’t care about maintaining things working with previous versions. … I think Raul Julia got them started on this path:

https://www.youtube.com/watch?v=AjGXn249Fc0

Rick Kimball Fri Nov 24, 2017 7:45 pm

Since I last looked it seems they have added a new feature, the st-link server. It appears to offer access to both the debug interface along with the Serial Wire Viewer (SWV) monitoring port.

https://my.st.com/content/my_st_com/en/ … erver.html

You might want to check that out.

paksoft Sat Nov 25, 2017 6:54 pm

@Rick
You should probably create a new test project using System Workbench without using my project configuration. Verify that you can compile and debug on windows. It looks like you are specifying the wrong stlink device, based on the vid/pid mismatch.

I created new project with the code generated by STMCubeMx.
It works, now I need to replace CMSIS with stm32duino core. Could you please give some guidelines for porting stm32duino core?

pak

Sign in to reply