Showing results for 
Search instead for 
Did you mean: 

FreeRTOS + LwIP in C++ project on STM32F7

Associate II

Hello everyone,

I want to get 4Diac Forte, which will be added as a static library, working on my Nucleo F767Zi.

I need FreeRTOS with LwIP, so I created a base Project in CubeIDE with FreeRTOS+LwIP which was running fine.

Since the library I want to add is written in C++ I only got it to work after converting my Project to C++ in CubeIDE. Now I can add the library without any errors, however I noticed that after a couple seconds up to a few minutes, ethernet communication stopped working on my Board.

After some fruitless debugging I decided to retrace my steps and start with a fresh project to see at which point the error occurs.

Long story short, after trying a clean Project with FreeRTOS + LwIP both as C aswell as C++ Project, after max. 5 minutes the Ethernet connection crashes, but only in the C++ Project.

My C Project was running fine for 30+ minutes, after I converted it to C++ it stopped working aswell.

It is stuck in ethernetif_input(), specifically at LOCK_TCPIP_CORE(), which is a macro for sys_mutex_lock(&lock_tcpip_core).

#define LOCK_TCPIP_CORE()     sys_mutex_lock(&lock_tcpip_core)

sys_mutex_lock is stuck in osMutexAcquire in cmsis_os2.c at:

if (xSemaphoreTake (hMutex, timeout) != pdPASS) {

My steps to get to this point where:

  • Create new STM32 Project for Nucleo F767Zi with targeted language C++ (CubeIDE 1.5.1 with STM32Cube_FW_F7_V1.16.0)
  • In CubeMX change Systick to TIM6, enable LwIP and FreeRTOS with CMSIS V2 (I just realized i never tried cmsis v1, will try later.)
  • Build and Debug
  • continuously ping the board and wait for it to crash

Am I missing something to get FreeRTOS + LwIP to work in a C++ Project?

Or, alternatively, is there a way to add a C++ library to a C Project? I only know that I can add a C library to a C++ project but not sure how that would work the other way around.

Any help is greatly appreciated

Associate II

If I switch to CMSIS V1 it works fine (running for 10+ min now).

So I guess the bug has to be in the CMSIS V2 layer

Chief II

There is no "some bug". It's all a broken bloatware. You cannot make it working with clicking CubeMX.

Yes I would prefer to do it myself but I dont want to spend days getting a basic Project running just to test some library for a prototype.

Abstraction layers aren't necessarily bad

Abstraction layers are not bad, but STM32 HAL/CubeMX implementation is terrible.


Ok, yep. Same here!