STM32F0 discovery + GCC + Eclipse + OpenOCD + Ubuntu – Part I

Hello there!

In this post I’ll show how to set up your IDE to debug the STM32F0 discovery board using open source tools.
The STM32F0 is a kit (very cheap) from ST micro to introduces the ARM Cortex – M0. This little boards has integrated a STM32F051R8T6 microcontroller with a button, leds and I/Os and also a st-linkV2 which is used to program and debug. That’s why this little board is so amazing! We can use the st-linkV2 embedded to program and debug others microcontrollers, you need only to change two jumpers and we’re ready!

I must say that everything I did here was based in what Mike Szczys did here. So THANK YOU Mike!!!
Ok, let’s start! First of all, create a folder stm32 in your home. We’ll use this folder to save all files.

1) Installing basic tools

2) Installing toolchain
a) You can download toolchain from code sourcery (or if you prefer, you can use crosstool-ng and generate your own toolchain)
https://sourcery.mentor.com/sgpp/lite/arm/portal/subscription?@template=lite

b) Install toolchain

if you have the error “ERROR: DASH shell not supported as system shell”, type

c) Chose: Minimal installation, default folder, check “Modify path for user”, check “Don’t create links”

3) Installing OpenOCD
Get here the latest version of OpenOCD (I got openocd-0.6.0-rc1) and save

4) Install udev rules

5) Install Eclipse
a)Get the latest version Eclipse C/C++ here. My version is Indigo.
b) Install plugins. Go to Help/Install New Software…
c) Work with: http://gnuarmeclipse.sourceforge.net/updates and chose GNU ARM C/C++ Developement Support. Install it.
d) Work with: http://download.eclipse.org/tools/cdt/releases/indigo and chose GDB hardware debugging. Install it.

6) Get templates and setting up file directory
a) Create a workspace, a Template and a src folder inside at /home/stm32 (or somewhere)

b) Download the following templates:
STM32F0discovery_fw.zip (link was not working 24/12/2013)

(updated 24/12/2013) stm32f0discovery_fw.zip

git clone https://github.com/szczys/stm32f0-discovery-basic-template.git

b) Unzip STM32F0discovery_fw.zip and copy the Libraries folder into /home/stm32/workspace/Template
c) Copy STM32F0-Discovery_FW_V1.0.0/Project/Demonstration/stm32f0xx_conf.h into src folder.
d) Copy and paste the files in stm32f0-discovery-basic-template/Device/ldscripts/ into src folder.
e) Edit stm32f0.ld in src folder. Change paths in both include:
INCLUDE “/home/stm32/workspace/Template/src/stm32f0discovery_def.ld”INCLUDE “/home/stm32/workspace/Template/src/sections_flash.ld”f) Copy stm32f0-discovery-basic-template/Device/startup_stm32f0xx.s into src folder. RENAME IT TO .S. It’s an eclipse issue.
g) Copy folder stm32f0-discovery-basic-template/Extra to /home/stm32/workspace/Template/


This post is already too long. In next post I’ll show how to start a new project and set up debugger and OpenOCD in Eclipse. I promise that it will be soon!

Bye

Marcelo

Marcelo Jo

Marcelo Jo is an electronics engineer with 10+ years of experience in embedded system, postgraduate in computer networks and masters student in computer vision at Université Laval in Canada. He shares his knowledge in this blog when he is not enjoying his wonderful family – wife and 3 kids. Live couldn’t be better.

LinkedIn 

5 Responses to 'STM32F0 discovery + GCC + Eclipse + OpenOCD + Ubuntu – Part I'

  1. klen says:

    hy marcel, i wan to ask about stm32f0
    i want to access eeprom external using stm32f0 by i2c
    can you help me?

  2. STM32F0discovery_fw.zip is no longer available from the ST site. Could you please attach a copy to the tutorial?

  3. Roney Monte says:

    otimas dicas para quem esta iniciando!
    nice tricks. I would like to talk about Microchip XC compiler…
    thanks

Leave a Reply