GithubHelp home page GithubHelp logo

embeddedrtps-stm32's Introduction

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.>

embeddedrtps-stm32's People

Contributors

akampmann avatar david1234500 avatar davidk234500 avatar ken551 avatar takasehideki avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

embeddedrtps-stm32's Issues

please add a license

This repository don't have a LICENSE.
Without a copyright license, nobody is legally allowed to use this code. Please choose a license.

We plan to use the product you have achieved for our R&D activity.
If we may suggest it, the Apache 2.0 license is good choice because this permissive the license that also grant patent rights. And Apache 2.0 prevents you from being able to sue your users over patent infringement claims.

NOTE: also see embedded-software-laboratory/embeddedRTPS#2

Bing failed and eth connection

Thanks for all authors! But I just has some problems while using ertps-stm32f767zi.
Here is the issue:
Bing is failed and there is no rtps packets in wireshark
I did the same instructions here: https://github.com/embedded-software-laboratory/embeddedRTPS-STM32.git
but the connection still not working and this is the result:
Creating RTPS Participant...
Creating Participant...
Created Participant succesfully.
Creating RTPS reader on topic:TOLINUX
Creating FastRTPS Writer on topic TOSTM
Successfully created writer.
Waiting for reader match with STM32...
So please if you can help, I will be grateful for you.

Does it work through docker/wsl2?

First of all, thanks @akampmann for sharing this amazing project.

I'm trying to get this demo running. I managed to build and run it on the STM32 Nucleo just fine.

I also managed to build it on ubuntu 22.04 using WSL2. The network connection seems fine. i.e. i can ping the STM32 (192.168.1.103) just from both the host computer and within WSL.

However, when running the hello_world program, nothing happens.

I did a Wireshark dump, and i get the INFO_TS packets from the Nucleo board, but nothing seems to happen on the Linux side. here is the raw dump: https://www.dropbox.com/scl/fi/f7jpbl3eacsgv946y5zxm/rtps_nucleo_ubuntu_wsl.pcapng?rlkey=bs5fwsgtxa5ed9ukdq29qhyip&dl=0

Do you know of any limitations when running from within a container?

[Question] Does embeddedRTPS work with cyclonedds?

Hello!

I'm trying to make a connection between CycloneDDS on linux and embeddedRTPS on STM32F765 on custom board.

The thing is that embeddedRTPS works absolutely fine with it's linux software and I'm able to connect and send data any to and from board, but when I try to connect embeddedRTPS board and CycloneDDS on linux, there is no connection at all. I've checked that messages are sent and received on board's side and SDPD agent works fine, but no SEDP agent activity is visible.

So my question can be summarized into: "Has anyone tried that before me and if this connection is possible?"

How to assign IP address manually?

Hello.
I'm very interested in this project and trying to run this example app on stm32.

I managed to build both the Linux program (on Ubuntu 18) and the stm program.
However, they didn't start communication.

I couldn't understand what I have to do with the step3 "Manually assign an IP address (and subnet mask) to the STM32."
I tried some methods ( code generation from cubeMX, DHCP with the router, etc.) but none of them worked.

Could you tell me how to set the IP address manually?
Or, would you tell me if there's some other solution?

Thank you.

`embedded_rtps_test` seems to work only 3 times

Hi, authors! Thank you so much for publishing the awesome software!!

When we try to run the example several times in a row on this repo, embedded_rtps_test seems to work only 3 times.
According to our observation, it seems that the pointer to reader cannot be acquired at the below point (proxy cannot be acquired) in the 4th execution.

https://github.com/tlk-emb/embeddedRTPS/blob/397b9d92b47d9bd7f079204076fca0ca9e1fa60f/include/rtps/entities/StatefulWriter.tpp#L210-L218

  if (reader == nullptr) {
#if SFW_VERBOSE
    log("StatefulWriter[%s]: No proxy found with id: ",
        &this->m_attributes.topicName[0]);
    printEntityId(msg.readerId);
    log(" Dropping acknack.\n");
#endif
    return;
  }

We couldn't figure out the cause any more. Please let us know if you have any knowledge.


BTW, one more supplemental question. Is there a way to debug with serial output? We found some macros that seem to enable printf debugging, e.g., THREAD_POOL_VERBOSE and SFW_VERBOSE. However, the serial output could not be observed even if we changed these values.

Follow the latest update of embeddedRTPS

This repository refers embeddedRTPS @dc5e510 (Commits on Jan 14, 2020) as the submodule. There are many important updates to embeddedRTPS recently, so we need to update this repository to be followed.
https://github.com/embedded-software-laboratory/embeddedRTPS/commits/master

This is a note to myself, requested by Alex @akampmann
Since we are using this repository for our activity, we would like to give it back as a contribution. This is the manner of OSS.
embedded-software-laboratory/embeddedRTPS#3 (comment)

[BUG] ping failed and rtps test failed.

Thanks for all authors! But I just cannot reproduce the behavior of the ertps-stm32.

Here is the issue.

Env

  • hardware: stm32f767zi
  • toolchain: gcc8-2019-q3
  • cubeIDE: v6.4 with FW_V7 v1.16.0
  • network: ubuntu2004(192.168.1.104), stm32(192.168.1.103), router(192.168.1.1)
  • source: ZhenshengLee@3b983a3

Steps

change setting according to https://github.com/embedded-software-laboratory/embeddedRTPS-STM32/blob/master/readme.md

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;

  • change thread prio in stm32/rtps/include/rtps/config.h
       const uint8_t SPDP_WRITER_PRIO = 24;
        const uint8_t SPDP_MAX_NUMBER_FOUND_PARTICIPANTS = 5;
        const uint8_t SPDP_MAX_NUM_LOCATORS = 5;
        const Duration_t SPDP_LEASE_DURATION = {100, 0};

        const int MAX_NUM_UDP_CONNECTIONS = 10;

        const int THREAD_POOL_NUM_WRITERS = 1;
        const int THREAD_POOL_NUM_READERS = 1;
        const int THREAD_POOL_WRITER_PRIO = 24;
        const int THREAD_POOL_READER_PRIO = 24;
  • change ip setting in stm32/rtps/thirdparty/lwip/lwipcfg.h
#define LWIP_PORT_INIT_IPADDR(addr)   IP4_ADDR((addr), 192,168,1,103)
#define LWIP_PORT_INIT_GW(addr)       IP4_ADDR((addr), 192,168,1,1)
#define LWIP_PORT_INIT_NETMASK(addr)  IP4_ADDR((addr), 255,255,255,0)
  • change ip setting in stm32/rtps/include/rtps/config.h
const std::array<uint8_t, 4> IP_ADDRESS = {192,168,1,103};  // Needs to be set in lwipcfg.h too.
  • change ip setting in stm32/Src/lwip.c
void MX_LWIP_Init(void)
{
  /* IP addresses initialization */
  IP_ADDRESS[0] = 192;
  IP_ADDRESS[1] = 168;
  IP_ADDRESS[2] = 1;
  IP_ADDRESS[3] = 103;
  NETMASK_ADDRESS[0] = 255;
  NETMASK_ADDRESS[1] = 255;
  NETMASK_ADDRESS[2] = 255;
  NETMASK_ADDRESS[3] = 0;
  GATEWAY_ADDRESS[0] = 192;
  GATEWAY_ADDRESS[1] = 168;
  GATEWAY_ADDRESS[2] = 1;
  GATEWAY_ADDRESS[3] = 1;

Expected

../embedded_rtps_test show something/

Actuall

  • ../embedded_rtps_test waiting
Creating RTPS Participant...
Creating Participant...
Created Participant succesfully.
Creating RTPS reader on topic:TOLINUX
Creating FastRTPS Writer on topic TOSTM
Successfully created writer.
Waiting for reader match with STM32...
  • ping failed
  • arp -a show something with 192.168.1.103
? (169.254.169.254) at <incomplete> on enx000ec6cac70c
? (192.168.1.105) at 00:e0:4c:36:0f:51 [ether] on enx000ec6cac70c
? (192.168.1.101) at <incomplete> on enx000ec6cac70c
_gateway (192.168.157.254) at 00:00:5e:00:01:02 [ether] on wlxe84e0663b980
? (192.168.1.103) at <incomplete> on enx000ec6cac70c

disable the wifi makes no different of the result.

  • wireshark capturing no packets from 192.168.1.103

  • I added the tasklist function to show the thread report below

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.