Template For Building STM32F0-Discovery Project In GCC

Yep, that blue light is blinking and I made it happen. I’ve been hard at work since I got my free STM32F0-Discovery board in the mail. Most recently I put together a starting template for building STM32F05x project on Linux. You’ll still need to install your own tool chain (I’m using the Code Sourcery G++: Lite Edition), but this makes it a snap to compile your projects with support for STM’s peripheral libraries.

As for programming, you may remember that I added support for writing to RAM in the stlink project. I’ve wasted spent a ton of time trying to get support for writing to Flash into that project. It’s just less of a hassle to use stlink than it is to work with OpenOCD. But I’ve really hit a wall getting the flash loader code to work. If you want to check out what I’ve done so far in that area I committed a very messy branch (see the commits for what code changes I’ve made).

In the mean time you can use OpenOCD to write images compiled with the template to your device. I included the ‘make program’ option in the Makefile to do this from command line. If you need help compiling OpenOCD check the readme in the template repository.

17 thoughts on “Template For Building STM32F0-Discovery Project In GCC

  1. That’s awesome Mike. Projects on the Discovery kit are showing up slowly.
    Also, I’m trying to build a small ARM community around all the Raspis, Discoveries and Beagleboards so it acts for a one stop place for all things arm.
    Link is below.

    http://forum.arm-hq.com

    You are welcome to say hi. Continue your awesome tutorials.

  2. I ordered an STM32F4 Discovery a few months ago as my first Microcontroller and I found it quite hard to use with free software on Linux. I still didn’t manage to use the STM lib with eclipse and had many problems with it in general. I recently tried chibios which seemed pretty promising especially with the hal, but it doesn’t really abstract the hardware that much, when you have to use specific register definitions that aren’t documented in the project…
    I will definitely check out your forum akismet, but is there another page with good tutorials and examples (especially) for STM32 stuff?

    1. Hi Mathias, We are still building the community up slowly. There is a discovery kits subforum if your interested. The board is fairly new and will take some time to catch on. I’m sure there will be a HAL soon enough.

      Unsure why my name came up as “akismet”, I’ll change it in my profile later.

      1. Not all tutorials are as epic as that one. Here’s a shorter one. (I know its windows but follow it replacing linux equivalents as you go. I did and it works nicely)

        First follow (skip requirement d & f)(make sure you apply enviroment variables when installing codesourcery):
        http://shareee.netne.net/wordpress/?p=5

        Then (make sure to setup udev rules):
        http://gpio.kaltpost.de/?page_id=148

        Setup your debugger as so (replace zach with your name of course)(Make sure to use GDB Hardware Debugging):
        GDB Command – /home/zach/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-eabi-gdb
        Port – 4242

        External tools config (location of your installed st-util):
        Location – /home/zach/stlink.git/st-util

        This isn’t a too terribly nice format, but I don’t have much time as of late to write a full tutorial. Hope this helps you out.

  3. “Distribution of this file (unmodified or modified) is not permitted.”

    You seem to have some legal issues with the linkerscript you distribute:
    https://github.com/szczys/stm32f0-discovery-basic-template/blob/master/Device/stm32_flash.ld
    ** (c)Copyright Atollic AB.
    ** You may use this file as-is or modify it according to the needs of your
    ** project. Distribution of this file (unmodified or modified) is not
    ** permitted. Atollic AB permit registered Atollic TrueSTUDIO(R) users the
    ** rights to distribute the assembled, compiled & linked contents of this
    ** file as part of an application binary file, provided that it is built
    ** using the Atollic TrueSTUDIO(R) toolchain.

    1. Well isn’t that just FANTASTIC?

      Thanks for bringing it to my attention. I’ve deleted the file from the repo history. Not sure how to replace it but I’ll start learning about how to write one myself I guess.

      It’s unfortunate that STM is distributing a file with that much restriction on it along with their much-less restrictive peripheral libraries.

    2. Don’t distribute the file but rather write instructions on how to modify the existing file a user would have if they registered True Studio . Dumb restriction but it can be bypassed. Good work on figuring it out.

  4. Hey there,
    that’s great work. I cleaned it up and now it fits perfectly into my own little project.

    But is there any way to compile C++ instead of C code? As long I compile it with a .cpp-extension, the LED doesn’t light up.

    Suggestions are welcome!

    Greetings
    Michael

  5. I found these products to be a great deal. The Lida lida daidaihua makes me less hungry and the fat burn is helping me wipe out my flab. The instructions that came with it told me that getting my eating in check was necessary for a winning approach. I really took that to heart and have owned a lot more discipline when I am eating and the hoodia makes all that easier. I am doing sit ups and taking these products every day and so far, My flab is going away. I dont own a working scale but more than likely that things are improving.

Leave a Reply to akismet-d4f06bf8cb803502684f1683ad779e95Cancel 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.