STM32F0-Discovery + CooCox II (english version)

We’ll continue with our little project. In my last post  I mentioned that it was posible to use CooCox with the STM32F0-Discovery board, so we can code our applications without paying a single penny for the compiler, and bring to our future projects all the GCC’s compiler power. And more over, we also can use the FreeRTOS operating system. Now it’s time to get our hands dirty.

Don’t plug the board until to do so. If it’s already plugged, then unplug it.

Instructables (for Windows only, without FreeRTOS)

1.- Download  these packages, but not try to install them until to do so.

Save these packages in a common folder, so you can easily access them.

GNU-GCC compiler for Cortex-M

CooCox IDE (through CoCenter, so look at the end of the webpage.)

ST-Link driver (Click on “Design support” tab and look at the end of the webpage for the “SW drivers”.)

STM32F0 board support package (V2). This BSP was a bit tricky and obscure to get it. I got it from a russian guy (aka Ant-On), but I’ve made it public for the masses.

Update (19-oct-2012)

Mr. Ant-On let me know that a new version (V3) is ready to download, from here or from here.


2.- Installation

a) Install the GNU-GCC compiler

I changed the default location to something more compact:


b) Install the CoCenter installer (it’s usefull for installing more stuff later on).

c) Run the CoCenter app and choose to download and install “CooCox CoIDE”. Don’t install anything else from here.

Note: While installing the CoCox IDE you might experience some strange behavior. Don’t panic. If an error screen pops-up, don’t do anything, wait until the installation completes, then you can close  it.

d) Install the ST-Link driver.

e) Open the CooCox IDE and instruct it to use the GNUARM compiler.

Go to menu Project->Select toolchain path->Browse, and look for the compiler’s bin folder location. For example, I choose c:\GNUARM for its location, so this is what I got:


Then click on Ok button.

Perhaps the window won’t close, so close it using the upper-right cross (X). The path is saved, so don’t worry.

f) Before going further it’s good idea to test the compiler.

In the IDE’s main page there is a list with some major MCU vendors. Choose ST, and the screen will change to show some members of the STM32 family. You won’t find anything about STM32F0, but don’t worry, we’re just testing the stuff. So choose, e.g. STM32F103C4 chip.

The screen will change again (step 3 at its top you can read). We’re just testing, so check these boxes:


After choosing the first one you’ll be asked for creating a new project. Write “test” in “Project name”, let the default location, and click on “Finish”.

Open the main.c file (bottom-left, in Project tab). There is nothing fancy in there, just press F7 key. If everything was ok, then you would be able to compile such a test project. This is what I got:

... some more messages ...
Program Size:
 text data bss dec hex filename
 1004 0 1024 2028 7ec test.elf
Total time: 11 seconds

We’re ready to go on.

g) Install the STM32F0 BSP package

For some obscure reasons the BSP is not included in this CooCox IDE release, so we need to install it by hand. Uncompress the CoIDE_STM32F0.7z file in the folder where CooCox IDE lives. In my machine I uncompress it in this folder:


Say “Yes to all” to your uncompress software if it asks for.

h) Create a project for the STM32F051 MCU

Project->Close project

We already have a project opened, remember? We don’t need it anymore.

(Step 1) Choose ST

(Step 2) Choose the STM32f051R8

(Step 3) Choose these boxes: M0 CMSIS core, CMSIS_boot, GPIO, RCC, DBGMCU, SYSCFG.

Again, you’ll be asked for creating a new project, so choose whatever project’s name you want, and click Ok.

You might want to go to the “Drivers” tab and choose some drivers, however I will not for this tutorial.

You can always go back for including things you forget or you want to add as your projects grows-up.

Download this main.c file and copy and paste its contents or replace the main’s project file, whatever is easier to you.

Press F7 and pray for the project to compile. If so, you’re one step away from success. Before going to the last step, take a break and return in few minutes.

i) Download and debug onto the STM32f0-Discovery board

Are you ready? Take your board and plug it into a PC’s USB free port. Are you nervous? I was the first time!!

A “New hardware found” window will show up warning you about new hardware, so say Yes, and then let the drivers will be installed. Seconds later, if a bubble shows up saying “Your new hardware is up and ready…” (or something else, I have the spanish version) you have succeeded, Cheers!!

Back into the IDE go to Debug->Debug configuration, and in the Debugger tab look for “Hardware” combo box and choose “St-Link”. Finally click on  “Apply” and “Close”.

It’s time for debugging: Look for the small bug icon, or press Ctrl-F5, or go to Debug->Debug, and the debugging session will start. The code is uploaded into the MCU’s FLASH and the cursor is set at the first sentence in your main.c file. From here you can debug step by step, set breakpoints, or just let the program to run (F5), until you pause it.

Press F5 and both leds on board will start blinking.

Congratulations!! You made it.

Next post I’ll show you how to include and use FreeRTOS  into your projects. Meanwhile let me know your success stories, or doubts or comments, or feelings, whatever you want to share.


9 comentarios sobre “STM32F0-Discovery + CooCox II (english version)

    1. Hi Ant-ON,

      I do agree you deserve the credits for your hard work; however, I don’t have the original link to your sources, so please send it to me, and I’ll mention you in the blog’s body as soon as I get it.

      Meanwhile congratulations for the BSP 🙂

      1. Hi

        As I mentioned in the text, it was tricky and obscure to get your BSP, so by now I don’t have the link to it, would you please send it to me so I can add it to the entry?


Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de

Estás comentando usando tu cuenta de Cerrar sesión /  Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión /  Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión /  Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión /  Cambiar )


Conectando a %s