For a while now, I’ve been meaning to document my development configuration for a clean ARM CMSIS development environment. To be honest, the post acts more of a logbook for my work and for that reason i will only maintain this post as when new technology changes my workflow.

I feel that I should first start by pointing out that you can download various pieces of software that makes this process easier. However, knowing how to configure your own development environment will help in situation where you are developing at the edge of technology, as I quite often do. Look at it this way, if you are using the latest micro-controller that is only a few weeks old, chances are that the OpenOCD that you are using for programming and debugging wont have support for that micro. However, if you know how OpenOCD device profiles are created and used, then you can simply roll your own.

My objective for this post is to document the process of how I go about configuring a development environment for the ARM cores. I’m going to be using the NUCLEO-F030R8 Board by STMicroelectronics and I’m going to be doing the whole configuration on a linux (ubuntu) OS.

Because ARM is trying so hard to make it easier for us developers to migrate project code between vendor microcontrollers, If I can help it, I will be avoiding the use of vendor specific library and tools. if I have to, I will make sure that I make it clear why and comment on what you will need to look out for if you are using a different vendor MCU.

As final note, I wanted to say that it always bothers me when you find a tutorial online that goes through the step of doing something and the person doesn’t bother to briefly mention that a particular steps was done in such way because of personal preference. So in this post I will try my best to leave a comment where possible to highlight what was as a personal preference so that you have the choice to do it the way you want to do it. That said, if doing this sort of configuration is new to you, then I highly recommend that you stick to my method and attempt it your way once you are happy with the process.

Important Links

ARM CMSIS-Pack documentation

ARM CMSIS (Cortex Microcontroller software interface standard)

 

Downloads

before we begin, we should start by downloading all the files that you need.

Process

install cross compiler

  1. Install ARM GCC compiler by running the following command in Ubuntu. [sudo apt-get install gcc-arm-none-eabi]
  2. Install openOCD [sudo apt-get install openocd]

 

  Installing OpenOCD

mkdir -p ~/sandbox cd ~/sandbox mkdir openocd git clone git://repo.or.cz/openocd.git cd openocd sudo apt-get install make libtool pkg-config autoconf automake texinfo ./bootstrap ./configure make sudo make install

Install Eclipse

To start with, Download and install Eclipse IDE. Make sure that its the C/C++ variant. Once installed, go ahead open eclipse. The first time you open eclipse it will ask where to put your workspace. For the purpose of this post, create a folder in your desktop called “Sandbox“. This will serve as a place for us to test out our new environment. Ok, now that eclipse has loaded, close off the welcome page if its shows up. Then on the title menu, click on the “Help” followed by clicking on “Install New software” InstallNewSoftware   In “Work with:” type the following GNU ARM Eclipse Plug-ins – https://gnuarmeclipse.sourceforge.net/updates and then press add and then OK Add_Repository When the list loads, Tick the GNU ARM C/C++ Cross Development tools option and click Next. GNU ARM C_C++ cross Development tools Then Click next. Accept the term and conditions and click on finish. This will install the tools that we need as well as ask you to restart eclipse. Don’t worry if it warns you that the source can’t be trusted.

Creating project template

 

 

 

 

 

 

 

 

Create Eclipse Template

              1. Start by first create a new project in Eclipse.New_Project

 

 

 

 

 

 

 

CProject

 

 

 

 

 

 

 

 

 

 

 

Now that we’ve created a clean eclipse template, lets go ahead and add the extra folders that we are going to need for organising our project.

This is one of those personal preference I was talking about. the compiler that side behind the scene doesn't care how you organised your files nor that it care what you named the folders. 
The compiler simply gets told where and what to compile by eclipse and eclipse only knows that because of how we configure it.

So this are my intention for the three folders:

Source – this is where I would stick the project .c and .a files.

Header – This is where I would stick the project .h files

CMSIS/Source – This is where I would directly stick ARM CMSIS .c and.S files.

CMSIS/Source – This is where I would directly stick ARM CMSIS  .h files.

Now that the folder are ready, we are going to go ahead and copy over the CMSIS files that we need from the CMSIS-pack we download and extracted earlier. The microcontroller we are creating the template for is the STM32F030.

So copy the following files into the CMSIS folder we created:

Keil.STM32F0xx_DFP.1.4.0/Device/Source/ARM/system_stm32f0xx.c  ->  Sandbox/CMSISTest/CMSIS/Source/system_stm32f0xx.c Keil.STM32F0xx_DFP.1.4.0/Device/Source/ARM/startup_stm32f030.s  ->  Sandbox/CMSISTest/CMSIS/Source/startup_stm32f030.s Keil.STM32F0xx_DFP.1.4.0/Device/include/stm32f0xx.h >  -> Sandbox/CMSISTest/CMSIS/Header/stm32f0xx.h

STM32Cube_FW_F0_V1.4.0/Projects/STM32F030R8-Nucleo/Templates/Src/system_stm32f0xx.h  ->  Sandbox/CMSISTest/CMSIS/Header/system_stm32f0xx.h

STM32Cube_FW_F0_V1.4.0/Projects/STM32F030R8-Nucleo/Templates/TrueSTUDIO/STM32F030R8-Nucleo/startup_stm32f030x8.s  ->  Sandbox/CMSISTest/CMSIS/Source/startup_stm32f030.S

Make sure that you capitalise the .S

Now will need to copy core_cm0.h,  cmsis_gcc.h, core_cmInstr.h and core_cmFunc.h from the CMSIS-pack folder that we extracted earlier.

ARM.CMSIS.4.4.0/CMSIS/Include/core_cm0.h  ->  Sandbox/CMSISTest/CMSIS/Source/core_cm0.h

ARM.CMSIS.4.4.0/CMSIS/Include/cmsis_gcc.h  ->  Sandbox/CMSISTest/CMSIS/Source/cmsis_gcc.h

ARM.CMSIS.4.4.0/CMSIS/Include/core_cmInstr.h  ->  Sandbox/CMSISTest/CMSIS/Source/core_cmInstr.h

ARM.CMSIS.4.4.0/CMSIS/Include/core_cmFunc.h  ->  Sandbox/CMSISTest/CMSIS/Source/core_cmFunc.h

Screenshot from 2015-10-14 01:35:42

 

Now lets copy the microcontroller linker. this linker is what provides all the information the compiler needs to know about where to place our compiled code in the micro flash memory. For example, it tell the compiler how big the flash is.

Screenshot from 2015-10-13 19:48:03

If you are wondering how I knew where the linker was located in the STM32cube folder, I simply search the folder with the following search term “.ld” and copied the first linker named “STM32F030R8_FLASH.ld“. Also it worth noting that even though STM have labelled the linker file as STM32F030R8, This linker is used on the STM32F030C8. Feel free to do a comparison of the two files.

Linker_Searched

 

The final thing we need to do before we start to configure eclipse is to create the a simple test program. For the purpose of this project, we are going to uses a pre-made test program that blinks the NUCLEO board LED. Now depending on which micro-controller you have, you will need to re-write the led.c functions to suite your MCU.

For now, you will need to download copy into your project the following three files:

main.c – It have the program main loop. copy to ./Source

led.c – this have the set-up and control code for the NUCLEO user led. Copy to ./Source

led.h – this has the C header files for the led functions defined in led.c. Copy to ./Header

Main_Led_source

Configuring Eclipse

Screenshot from 2015-10-13 20:09:16

Screenshot from 2015-10-13 20:14:25

Screenshot from 2015-10-13 20:49:46

 

Enabling this two compiler warnings is completely optional. However, if you are new to C programming then I would advice that you have them on while you’re starting out. To be honest, even if you are a grand master of C you are still better off having them on.

Screenshot from 2015-10-13 21:49:50

The STM32F030 tell the compiler to enable of C code used by our specific microcontroller.

For more definitions that you could add, see the CMSIS header files.

Add “${workspace_loc:/${ProjName}/Header}” and “${workspace_loc:/${ProjName}/CMSIS}”

Screenshot from 2015-10-14 01:40:43

Now the last thing we need to do is add the CMSIS and your project source folders.

You should now have something that looks like this.

Now we are going to repeat the last five steps, but this time we are going to set the configuration to Debug.

 

 

Screenshot from 2015-10-14 01:54:24

 

Configuring Eclipse Programmer/Debbuger

We are now going to configure OpenOCD in eclipse. Make sure that you’ve installed openOCD and had no error while compiling the project. We need the compile to create the project binary. .elf

Screenshot from 2015-10-14 01:47:49

Screenshot from 2015-10-14 01:49:19

Screenshot from 2015-10-14 01:51:37

Screenshot from 2015-10-14 01:59:10

If everything has gone to plan then you should get a request by eclipse to change perceptive and it should start to debug.

Screenshot from 2015-10-14 03:02:20

Possible Issue

If you are having libusb() permission issues then the instructions in this  link to fix it.

 

 

Leave a comment.

Please note that all comments are moderated by a person and so it may take some time for it to show on the site. if you have an urgent issue then please feel free send us a message via our contact form below.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Get in touch.

Whether you have an existing project that you need help with or if you want us to take care of the whole design process, we are happy to talk to you about your project and see if we can help. At the very least we should be able to point you in the right direction.

Comments or questions are welcome.