Skip to content

embedded-software-laboratory/embeddedRTPS-STM32

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

embeddedRTPS on STM32Nucleo-F767ZI

This repository contains all components necessary to create a minimal working example of communication between an STM32F767ZI using embeddedRTPS and a Linux system using FastRTPS. This repository contains two projects:

  1. The first project in the stm32/ directory is a STM32CubeIDE project which uses EmbeddedRTPS and is deployed to the STM32Nucleo-F767ZI.
  2. The second project in the linux/ directory is a C++ project that uses eProsima FastRTPS for the Linux system. It can also be compiled and executed on macOS.

When both of these projects are executed, the Linux system will send RTPS messages with test data to the STM32F767ZI, to which the STM32F767ZI will then respond. This simple communication test is executed 10 times.

The main embeddedRTPS repository is located here.

Dependencies

STM32F767ZI Project

To compile the project for the STM32, install the following Software:

  • STM32CubeIDE (version 1.9.0 or later)
  • st-stlink-server.1.2.0-5.1 (Provided with the IDE)

Linux/macOS Project

To compile the project for Linux, install the following Software:

Ubuntu 18.04

Packages to install using apt-get:

sudo apt-get -y update && sudo apt-get -y upgrade
sudo apt-get install -y \
    software-properties-common \
    libboost-all-dev \
    libssl-dev \
    build-essential \
    cmake

Fast DDS

For linux/ side application, eProsima Fast DDS v2.3.2 or later is required. The simplest way to prepare is to install from sources according to the follow guide. Note that preparing the environment (e.g. source ~/Fast-DDS/install/setup.bash) is also needed before building or executing.

https://fast-dds.docs.eprosima.com/en/latest/installation/sources/sources_linux.html#linux-sources

Compilation

After installing the required dependencies, both projects can first cloned and compiled using the following instructions:

git clone --recursive https://github.com/embedded-software-laboratory/embeddedRTPS-STM32

STM32F767ZI Project

To compile and deploy the STM32 project, first open the STM32CubeIDE.

File -> Open projects from File System -> Directory -> Select the stm32/ directory

Then press finish to import the project into your local workspace.

Now select the project in the project explorer:

Project Explorer -> embedded_rtps_stm32

Then, right click the hammer button in the navigation bar. This opens the menu to select the build configuration:

  • debug: The debug configuration compiles the code with debug symbols and lowers optimization for debugging.
  • release: This configuration disables debug symbols and increases optimizations to maximum.

The selected configuration is then compiled by STM32CubeIDE.

Code generation using CubeMX

You also can use the CubeMX code generating feature in CubeIDE to configure the project. After code generation, you have to do the following steps:

  • delete auto-generated Src/main.c (not main.cpp)
  • edit Middlewares/Third_Party/LwIP/system/arc/cc.h l41 as follows
//#define LWIP_PROVIDE_ERRNO
#define LWIP_ERRNO_INCLUDE <sys/errno.h>
  • edit Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_eth.c l1877 as follows
 macinit.PromiscuousMode = ETH_PROMISCUOUS_MODE_ENABLE;

Note that when you change the STM's IP address, you also have to change the IP address configure in Core/Inc/rtps/config.h l40

Flashing the STM32F767ZI

The STM32 should now be connected to the Linux/macOS computer using a micro-USB cable. The cable should be plugged into a USB socket on your computer and into the debugger side of the STM32 Nucleo board.

The compiled configuration can then be flashed on to the STM32 in the following steps:

Navigation bar -> Run -> Debug

It might now be necessary to select the target, in which case "STM32 Application" should be selected. The IDE will then flash the STM32 with your selected configuration.

Tips

  • The IDE may prompt you to update the firmware of the onboard ST-Link debugger, this is normal and you can follow the process to update the firmware to the newest version.
  • The IDE may also ask you to switch to the Run/Debug display after flashing a configuration to the STM32, this is the debug screen of the IDE and thus usefull to see the current callstack and more.

Linux/macOS Project

To compile the Linux/macOS project navigate to the linux/ directory. Then compile the CMakeLists project using the following commands:

cd linux
mkdir build
cd build
cmake -DTHIRDPARTY=ON ..
make 

The resulting executable can then be found in the build directory and is called hello_world.

Testing Communication with STM32

After compiling both projects the communication between both devices can be tested. To conduct this test follow these steps:

Setup on Linux/macOS

  1. Connect the STM32 to your computer using a ethernet cable.
  2. Ensure all firewalls are disable. (probably an OSX issue)
  3. Manually assign an IP address (and subnet mask) to the STM32.
    (for example: IP:192.168.1.1, subnet: 255.255.255.0)
  4. (It may be necessary to disable other network connections, like wifi, if the chosen IP address is in your local network, necessary with the example adresses provided here.)
  5. (You can also communicate with the STM32 via a router. Network settings such as IP address are in Core/Inc/rtps/config.h and LWIP/App/lwip.c.)

Executing the Test

  1. Flash a configuration to the STM32 and run it.
  2. The debugger will halt on the first line of the main method, press either F8 or the Resume button.
  3. The STM32 should now wait for a subscriber match (to verify this flash the debug configuration and execute steps one and two, then halt the debugger after a couple of seconds after clicking resume in step 2, the debugger should halt on line 495).
  4. Execute the hello_world executable in the linux/build directory.
  5. The executable will then send test data to the STM32 and the STM32 should respond to by returning other test data of the following form:
Received Hello World Data 0
Sending data
Received Hello World Data 1
Sending data
Received Hello World Data 2
Sending data
Received Hello World Data 3
Sending data
<sniped.>