.Modelica_DeviceDrivers.EmbeddedTargets.STM32F4

Information

EXPERIMENTAL: Support for the STM32F4 family of STM boards

Experimental feature with unstable API! Don't use it, except you want to experiment and you are prepared for severe bugs and other limitations.

As of MDD v1.6.0, only the STM32F4-Discovery board is supported. The code can easily be extended, but requires checking the data sheets in order to write to the correct bits.

So far only known to work with OpenModelica's ExperimentalEmbeddedC code generation. However, in principle it should work similarly with other (low foot-print) code generators.

Translation using OpenModelica v1.12.0

OpenModelica v1.12.0 includes an experimental code generator for low foot-print code. The code generator supports a subset of the Modelica language which will be extended in future versions. The current version is capable of translating the examples in the subpackages, but it is not as automated (no generation of Makefiles). For the examples within package Examples.STM32F4_Discovery corresponding build scripts and Makefiles are shipped with this library. They can be found below the library's Resources subfolder (Resources/Scripts/OpenModelica/EmbeddedTargets/STM32F4/Examples/STM32F4_Discovery). These scripts and Makefiles have only be tested using Linux as the host system.

Debian Linux (tested with jessy 64 bit)

Following packages are required:

sudo aptitude install arm-none-eabi-gcc
sudo aptitude installarm-none-eabi-gdb
sudo aptitude install arm-none-eabi-binutils
sudo aptitude install openocd
Ubuntu 16.04.4 LTS (and presumably later)

Following packages are required (tested version 16.04.4 LTS):

sudo apt-get install gdb-arm-none-eabi

(should automatically also install binutils-arm-none-eabi and gcc-arm-none-eabi).

Ubuntu 14.04.5 LTS

Using Ubuntu Linux 14.04.5 LTS with the default repository packages was not successful. Instead follow the installation guide lines in doc.

Create C-code, object debug code, binary and hex file for the Blink example

Download STM32F4CUBE from STM43F4CUBE and unpack to folder of your choice. Set environment variable pointing to the STM32F4 HAL package:

export STM23F4CUBEROOT=/path/to/STM32Cube_FW_F4_V1.XX.X

Go to the directory Script and Makefile Directory. Call "make" When successful, all object code will be in the "Debug" directory and ".elf" and ".hex" file will be created in the current directory.

Debugging, flashing and running the application

There are several options how this can be done, e.g., using gdb or using openocd.

Using gdb

First set up stlink:

sudo apt-get install git libusb-1.0.0-dev pkg-config autotools-dev
git clone https://github.com/texane/stlink.git
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make
sudo make install
# Reload udev rules or reboot system:
sudo udevadm control --reload-rules
sudo udevadm trigger

Now do:

sudo st-util

Check the port which opened (default for me: 4242). Start the debugger:

sudo arm-none-eabi-gdb

In the debugger console enter:

target remote localhost:4242
monitor reset halt
file Blink_main.elf
load
monitor reset
continue
Using openocd
openocd -f /usr/share/openocd/scripts/board/stm32f4discovery.cfg

In a new console open a telnet terminal:

telnet localhost 4444

In the telnet terminal enter:

> reset halt
> flash write_image erase Blink_main.hex
> reset run

Contents

NameDescription
Blocks
Functions
Constants
Types
Examples

Generated at 2024-04-26T18:16:04Z by OpenModelicaOpenModelica 1.22.3 using GenerateDoc.mos