Wednesday, December 9, 2015

Getting started with STM32 on Ubuntu

I have received an entry-level STM32F103C8T6 board and was eager to take it for a spin. After some digging it occurred to me that the board isn't quite as easy to get started with as Arduino is (even though it was advertised as such). But let's take it one step at a time.

For the sake of clarity I am using Linux Mint but the instructions should be fine for whatever Debian-based Linux distro out there.

Install Arduino

This step is fairly easy. You go to the Arduino website and download the package. I'm using the one for Linux 64 bits.

After downloading extract it somewhere (I like having a programs folder somewhere but you can use /opt for all I care.

Install Arduino STM32 Hardware support

That step we can actually automate quite nicely (not that we can't do the same with installing the Arduino IDE :))

Done. Now the problem is that once you start uploading your sketches you'll bump into all sort of compilation and linkage errors. To overcome them execute the following:

Now I know it ain't the nicest way of putting it all together but unfortunately I didn't find a nicer way of installing the needed stdc++ library.

Start using Arduino

My chosen way of working with the board was to use a USB-to-TTL board. To hook it up properly one uses the +3.3V and GND first then the RX and TX to A9 and A10 (if it isn't working right away swap RX and TX).

Start Arduino IDE. From Tools select Board: STM32F103C series, Variant: 20k RAM, 64K Flash, Upload method: serial. That should set you up nicely.

Hardware setup

Now don't you be forgetting the jumper settings!

Test drive

Now we need an app to run. We're not going to be very sophisticated here and do a blink on PC13.

Now hit the upload button. The compilation step takes a while so don't be alarmed. Once it is done the green LED should blink :)

Happy coding

No comments: