Using DRT with STM32 devices

Posted on September 13, 2016

SOMNIUM DRT is is a set of development tools for ARM Cortex-M based devices such as the STM32 devices from STMicroelectronics. It is fully compatible with industry-standard tools such as the GNU toolchain and Eclipse IDE. DRT uses our patented techniques to produce highly optimized code by exploiting information about the embedded processor and the memory system to deliver improved performance, lower code size and reduced energy use.

There are three main routes for creating an STM32 project in DRT.

1. You can use the New Project Wizard in DRT to quickly create a project targeted at the STM32 device you are using. This will not immediately give you access to all the STM32Cube software enablement.

2. You can use the STM32CubeFx package for the board or device you are using. This includes a number of example projects that can get you started with specific peripherals and middleware. It also includes a blank "template" project to get you started.

3. You can use the STM32CubeMX program to create a new project for your target, including all the necessary libraries, drivers, middleware and initialization code.

This articles will discuss those last two options in a bit more detail. We also have a couple of videos that will talk you through the process.

Using STM32Cube

STM32Cube is a set of tools and software from STMicroelectronics to make it easier to develop applications for STM32 microcontrollers. It consists of firmware and software package for specific device families. These include the hardware abstraction layer (HAL), drivers, middleware, examples, and so on. There is also a tool called STM32CubeMX which provides a graphical interface to create and configure a project then generate the appropriate initialization code.

There is an STM32Cube software package for each class of devices, for example STM32CubeF0, STM32CubeF4 and so on. You can download the software for your target from the STMicroelectronics website. This is a zip file containing the libraries, drivers, middleware, documentation and examples.

Under the Projects directory there are examples for several boards. These are organized as follows:

  • The Example programs only use the hardware abstraction layer (HAL) and board support package (BSP) libraries.
  • The Application demos show how to use the available middleware. They are organized either by middleware or by product feature.
  • The Demonstrations directory contains programs that use the maximum number of peripherals and middleware stacks to demonstrate the product features.
  • Then there is a Template directory, which contains an "empty" program with the essential infrastructure to get started with your target hardware.

All of these examples are available for several different developments systems. You can easily import any of these examples into DRT by selecting the Atollic TrueSTUDIO project. DRT will import that and convert it into a DRT project. You can then build it, run it one the target hardware, and use it as the basis for your own application.

This video will explain the whole process in more detail. It shows how to import one of the standard STM32Cube examples.

Creating a project with STM32CubeMX

STM32CubeMX is a program that runs on your PC to generate projects for STM32 systems. You can select the target for the project by choosing a specific microcontroller or a development board. This creates an initial configuration for the project. You can use the GUI to set up the pinouts, select middleware components, configure the clocks and other settings. For example, you can configure the GPIO pins to drive an LED.

When you click the "generate code" button, a project will be created in the workspace you specify. You should choose the Atollic project format as this can be automatically imported into DRT. After importing the project into DRT, you can add your own code, build and run the project on the target hardware.

This video will explain the whole process in more detail. It uses STM32CubeMX to create a program that flashes the LED on the board.


DRT provides industry-leading optimization, resulting in smaller and faster code which uses less energy. It supports the latest C and C++ standards, including C++ exceptions and is extensively tested by several test and validation suites. Comparing the "out of the box" (that is, with no attempt to apply any toolchain-specific optimizations) figures for one of the standard STM32Cube demo programs we can see that DRT significantly reduces the memory requirements.

.text .data .bss ROM RAM
DRT 3.3 31,368 212 18,916 30.8 18.7
SW4STM32 38,784 224 18,923 38.1 18.7
Atollic 50,332 1,448 18,968 50.6 19.9

When built using DRT, the program uses significantly less ROM space. This could mean that you can use a lower cost device, or you can add more functions to your system. For more information on benchmarking and results, see the white paper on our website.

In addition, DRT has some advanced debugging tools which can speed your development process. This includes live view of expressions while the program is running, trace and fault diagnosis.

A free trial of DRT is available from the SOMNIUM Portal.

DRT provides automatic import of projects from other Eclipse-based development environments, making it simple to evaluate. Download your free trial today from the SOMNIUM Portal and try it for yourself.


Download a free trial of SOMNIUM DRT

   Got a question?