New STM32 Discovery Board Can Now Be Programmed On Linux

Last Wednesday I posted a video review of the new STM32F0-Discovery board which is built around an ARM Cortex-M0 chip. I speculated that it should work with the open source project aimed at programming these discovery boards. I tested it out and a connection could be made, but no code could be flashed. So I spent a few hours over the weekend and added support.

My updates are already in the stlink repository. After cloning the code, you can use three commands to compile the software (./, ./configure, make). That’s assuming you have all of the necessary dependencies (I had to install libusb-1.0-0-dev) and that you add the udev rule suggested in the documentation (also found in the repository). The program st-util connects to the board and provides a listening port for an ARM debugger (I’m using arm-none-eabi-gdb from CodeSourcery G++ Lite).

When I first started testing, the chip id was reporting as 0. It turns out the register address polled for this information was wrong. After finding that in the almost-900 page reference manual I went through the painstaking process of finding the hex values necessary to properly memory map the device. From there I also updated the blink example to generate an ELF file compatible with the Cortex-M0 chip. So out of the gate you should be able to use an ARM cross compiling toolchain to compile the example, connect to the board with this utility, then use the debugger from the toolchain to connect and flash that example to RAM.

There’s lots more to be done. To fully utilize the chip it is necessary to use a startup file and linker script when compiling. I’ve done nothing in this area, but I hope to work on some tutorials as I get further along. Of course if you have your own successes developing for this board using a Linux machine we want to hear about it!

12 thoughts on “New STM32 Discovery Board Can Now Be Programmed On Linux

  1. I’ve been using the STM32F1 and STM32F4 chips in Linux since November. In January, OpenOCD (from Git) got decent support for a few of the Discovery boards.

    I haven’t bothered using that free F0 board yet but I’ve tested the STLink on it to debug another STM32F4 over SWD and it still works with OpenOCD.

    That said, they’re absolutely fantastic boards, especially for the price. ST provides a very complete peripheral library with examples and ARM’s CMSIS DSP library adds a lot of value.

    I also just found out that Keil (ARM) RTX RTOS was released under a BSD licence. They don’t seem to have starter projects for any of these boards, but it’s still useful.

  2. Great job! Never mind the M0 starter code; just making the ST-Link debugger work is fantastic work. It turns this dev board into a superb low-cost ($8) full-function SWD debugger for any of our other ARM projects.

    The STM32 line (and other Cortex-M micros) already offer much more bang for the buck than 8-bit microcontrollers. Tools like the DISCOVERY & open-source developments like this are making them at least as accessible as well. Not only that, Cortex-M0 and soon even -M3 parts are going to be even cheaper than overused AVRs and PICs.

    One really has to wonder when the hacking community will wake up and push out fancier projects on beefier, more practical hardware.

    1. The wider community will probably start using them when they become as accessible as pics and avr’s and some guides show up with a complete run through using them for a finished project.

      The discovery boards look baffling to your average arduino joe and nobody is really holding any hands yet.

      Time for the STMduino? :D

  3. Slightly off-topic, but how long does it take to get the demo board sample from ST? I’ve been waiting since the first post went up, and it’s still “Pending Approval”.

    Back on topic, this is excellent news. I can use the Mac sitting in the corner for something other than testing software, freeing up the much-needed USB ports on my main box.

  4. Working startup code and linker scripts can be obtained from ST’s firmware source download for the F0.

    The startup code is under Libraries/CMSIS/ST (use the .s file from the TrueSTUDIO subdir), and a linker script can be grabbed from Project/Demonstration/TrueSTUDIO/STM32F0-Discovery_Demo/stm32_flash.ld.

    Since TrueSTUDIO is eclipse+gcc, these should work fine. Note: you will have to edit the start of the linker script to match the Flash and RAM sizes of the particular chip you are compiling for.

  5. After reading last weeks write up I ordered a couple of (different) STM32 discovery’s from Mouser. Last night they sent me the tracking info.
    I got the STM8 discovery for free last year, so I decided to pay my way this time.

  6. These ST parts are a pain to use. But the fifteen buck STM32F4DISCOVERY board is really too sweet to pass-up. This has the V2 programmer and the on-board processor is the STM32F407VGT6 micro-controller which is based on the 32-bit ARM Cortex-M4F core with 1 MB Flash and 192 KB RAM – and get this, it runs at 168 MHz/210 DMIPS and has an on-die single cycle DSP MAC and floating point unit. Whew! This ain’t nothin’ like your lame-o Arduino ;-)

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.