The C/C++ project templates for generic Cortex-M microcontrollers.

Overview

The Eclipse Embedded CDT plug-ins provide template support for some of the most popular microcontrollers, but it is not reasonable to expect support for all existing ones. For the microcontrollers not supported by the specific templates, the Eclipse Embedded CDT plug-ins still provide a method to create projects, using the generic Cortex-M template.

Requirements

The projects generated by the template are almost complete, except the device specific files, which must be provided by the user.

Before starting to use the generated projects, please identify the CMSIS vendor specific files. The required files are:

  • the device CMSIS header (for example stm32f4xx.h)
  • the device CMSIS system header (for example system_stm32f4xx.h)
  • the device CMSIS system source file (for example system_stm32f4xx.c)
  • the device specific interrupt vectors (for example vectors_stm32f4xx.c)

The first 3 files should be copied from the vendor specific package. Definitions of the interrupt vectors is usually done in an assembly file; it is recommended to identify the names of the vectors, and enter them in the .c vectors file.

Create a new project

The template can create both C and C++ projects. To create a new C++ project:

  • in the Eclipse menu, go to FileNew → C++ Project
  • in the Executables group, select the Hello Arm Cortex-M C/C++ Project

New Cortex-M project

Select the core type and various project settings:

Define target core and project settings

All the above setting can be changes later, either in the project settings, or as different preprocessor definitions.

Define the names of the destination folders:

Define destination folders names

Instead of DEVICE, it is recommended to use the actual name suggested byt he vendor, for example stm32f4-stdperiph.

Accept the default configuration names:

Build configurations

Define the toolchain name and path:

Toolchain path

The generated project has the following structure:

Project structure

Copy vendor specific files

In the generates project identify the system/include/cmsis and system/src/cmsis folder, and copy the vendor specific files to them:

  • the device CMSIS header (for example stm32f4xx.h) should be copied to system/include/cmsis instead of DEVICE.h
  • the device CMSIS system header (for example system_stm32f4xx.h) should be copied to system/include/cmsis instead of system_DEVICE.h
  • the device CMSIS system source file (for example system_stm32f4xx.c) should be copied to system/src/cmsis instead of system_DEVICE.c
  • the device specific interrupt vectors (for example vectors_stm32f4xx.c) should be copied to system/src/cmsis instead of vectors_DEVICE.c

Check and correct the memory map

The defaults used for this generic project should be ok for most of the existing devices, but there might be cases when some devices have specific characteristics.

For this reason it is recommended to check the memory map generated in the ldscripts/mem.ld file, and possibly update the values that do not match your device, for example the flash origin, or the RAM origin.

You can safely edit this file, since it will not be overwritten by the plug-in during future builds.

Build

As seen in the above picture, even without the vendor specific files, the project builds without errors and, strangely enough, runs on the target, printing trace lines on the debugger output window, counting seconds.