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

Slammer Thu Apr 28, 2016 8:47 pm

Very nice….
I like this way of development!

Slammer Thu Apr 28, 2016 11:44 pm

I just used your project to build a simple blink program.
The build is OK but when I am trying to Debug the program I have the following error:
Error: timed out while waiting for target halted
TARGET: stm32f1x.cpu - Not halted
in procedure 'program'
in procedure 'reset' called at file "embedded:startup.tcl", line 478
in procedure 'ocd_bouncer'

Rick Kimball Fri Apr 29, 2016 12:26 am

If you used the Arduino IDE to load files without using the STLINK or BMP method, then you probably disabled the debug pins and made them GPIO pins accidentally.

You can force the bluepill to work with the stlink by switching the boot0 jumper from the default position of ‘0’ to the boot0 ‘1’. Then press reset so the chip can see the new boot0 configuration and then try again. Make sure you kill the stalled debug session in eclipse. If that works and you can successfully upload, you can switch the boot0 jumper back to ‘0’.

-rick

zmemw16 Fri Apr 29, 2016 1:08 am

i’ve installed eclipse mars cdt via the installer, installed the workbench from inside eclipse; it needed a restart and then installed gcc and openocd itself.
i pulled the bluepill.zip

i’m as usual for me, missing something.
i can select the bluepill.zip file, but i can’t seem to set the directory for the archive import destination. it has a browse button that just give 3 i assume grayed out very small home, up and into buttons???

i then tried creating an empty bluepill project, now it allows selection of workspace/bluepill as a destination folder,
but i now have a project top dir bluepill with a child dir bluepill holding the rest.

i’m not totally convinced i have the correct bluepill.zip, mainly because i can’t find the blink sketch and it looks more like the jc66_coreboard directory structure and files.

if you could confirm the following?
stephen@i7:~$ ls -l bluepill.zip
-rw-r--r-- 1 stephen stephen 3841736 Apr 28 20:20 bluepill.zip
stephen@i7:~$
stephen@i7:~$ md5sum bluepill.zip
f2fdced2541e91604b28d85ff44aaa45 bluepill.zip
stephen@i7:~$
stephen@i7:~$ cd Workspace/bluepill/bluepill/src
stephen@i7:~/Workspace/bluepill/bluepill/src$ ls -l
total 12
-rw-r--r-- 1 stephen stephen 1070 Apr 28 13:05 asciitable.cpp
-rw-r--r-- 1 stephen stephen 65 Apr 28 12:30 extra.c
-rw-r--r-- 1 stephen stephen 2727 Apr 28 08:06 streaming.h
stephen@i7:~/Workspace/bluepill/bluepill/src$

Rick Kimball Fri Apr 29, 2016 1:18 am

You need to make sure you do a File/Import … “Existing Project into Workspace” It is the second selection under General. This will create a new project entry in your workspace. The first selection “Archive File” only works with an existing project and would act as you have described. Note the attached animated images:
import_sequence.gif
import_sequence.gif (109.19 KiB) Viewed 3664 times

Rick Kimball Fri Apr 29, 2016 2:14 am

If you did want to successfully debug the asciitable.cpp that is using USBSerial, you might want to look at my debug session.
debugsession.gif
debugsession.gif (224.16 KiB) Viewed 3658 times

Slammer Fri Apr 29, 2016 11:06 am

As I can see, AC6 Workbench includes gcc 5.2.1 as default compiler :!:

Rick Kimball Fri Apr 29, 2016 11:17 am

Slammer wrote:As I can see, AC6 Workbench includes gcc 5.2.1 as default compiler :!:

Slammer Fri Apr 29, 2016 11:36 am

Yes, I saw it. With 5.2.1 the binary is almost 2KB smaller :!:
Anyway I am making some more tests to see what is different….

Rick Kimball Fri Apr 29, 2016 11:42 am

Did you successfully debug with stlink?

Slammer Fri Apr 29, 2016 11:50 am

Yes! I did it… thank you.
I am trying to make the HALMX version now….

Rick Kimball Fri Apr 29, 2016 3:06 pm

There is an annoying bug when running eclipse and the AC6 System WorkBench plugin on Ubuntu. The normal way to access the “Properties” dialog to make changes to the C/C++ Builder / Settings is to right click on the project in the Project Explorer. However, when running Ubuntu this will cause a hang for many tens of seconds. In the past, I’ve had problems with other gtk3 based apps so I tried my time honored env settings to solve the problem. I modified my Eclipse.desktop file like this:

[Desktop Entry] Type=Application
Version=0.9.4
Name=Eclipse
Comment=Eclipse Mars 2
Icon=/home/kimballr/opt/eclipse/icon.xpm
Exec=env SWT_GTK3=0 UBUNTU_MENUPROXY=0 /home/kimballr/opt64/eclipse/eclipse -showlocation
Terminal=false
Path=/home/kimballr/
Name[en_US]=Eclipse-Mars2(64bit)

zmemw16 Sat Apr 30, 2016 12:06 am

@rick
any recommendation on following the ‘updates are available’ pop-up?

i was seeing a message related to MaxPermSize as an unrecognized switch, eclipse.ini was modified deleting lines with XXMaxPermSize and the following line for each.

could you detail anywhere string *kimbal* needs to be edited away? i’m a stephen :D
in openocd path as well???

i use a modified 1.6.5r5 where it’s dot dir is arduino165r5, similar for 1.78 etc etc
i ended up using a soft link to my arduino installed arm files and adding ~/stephen/arm to the path in eclipse.
i’m wondering will happen after the updates have installed?

i’m playing with nRF24’s at the moment, adding in their includes as a see what happens, yields ‘not found’ messages.
where/how would i add local user libraries? is there a search path to be amended as well?
the libraries entry under the project lists the standard arduino_stm32 ones.

any tips on how i’d use a maple mini in this setup?
i suppose that using a bluepill programmed as a bmp might prove to be interesting?

you mentioned doing a write up somewhen? yes please.

stephen

Rick Kimball Sat Apr 30, 2016 4:34 am

zmemw16 wrote:
any recommendation on following the ‘updates are available’ pop-up?

zmemw16 Sat Apr 30, 2016 6:44 pm

i think i need another laptop for screen space! i’m either talking myself into or out of acquiring another, trouble is the price difference between a ‘decent’ i3 and not quite so decent i5 ain’t a lot. now chuck in 8gb and 1tb hard disk.

ok i’ll go off and firtle a bit with this … … …

stephen

stevestrong Sun Oct 02, 2016 5:00 pm

I decided to setup a project which enables debugging, and which allows me to build with or without Arduino IDE.
For this, I read about eclipse and I though I will try it out.

Well, it is not that simple because I am working on a Win10 computer.

First, I read about the Eclipse plugin for Arduino. After several unsuccessful tries and errors (two days of pain..) I wanted to give a try to Rick’s project.

@Rick,
After I import the project and adapted the PATH variable to find the “make.exe” now I get the error message:
“make: no rule to make the target”.
Which path should I include now?

Rick Kimball Sun Oct 02, 2016 5:41 pm

I can’t say on windows, sorry.

RogerClark Sun Oct 02, 2016 9:20 pm

Steve

You could load linux in a VM.

I know that means doing another install and setup of Eclipse, which can be a pain, but the VM installation of Linux would be simple and quite quick

Rick Kimball Sun Oct 02, 2016 10:43 pm

stevestrong wrote:First, I read about the Eclipse plugin for Arduino. After several unsuccessful tries and errors (two days of pain..) I wanted to give a try to Rick’s project.

Sign in to reply