Nucleo F767ZI + lwIP + FreeRTOS (CubeMX), can't get ping to work
Hi,
Since before I have used USART for sending data with protocol buffers and SLIP encoding, thought that I should try to move over to Ethernet and UDP instead. It became harder than I thought, to say the least.
I'm using STM32CubeMX 6.8.1.202304191431 for generation.
I can get the ping to work without FreeRTOS, as soon as I add FreeRTOS, ping stops working.
ETH Configuration:

MPU Config:

lwIP Config:
Bottom of my STM32F767ZITX_FLASH.ld :
.lwip(NOLOAD) :
{
. = ABSOLUTE(0x2007c000);
*(.RxDecripSection)
. = ABSOLUTE(0x2007c0a0);
*(.TxDecripSection)
} >RAM
.ARM.attributes 0 : { *(.ARM.attributes) }
}
My main-function looks like:
#include "main.h"
#include "lwip.h"
void SystemClock_Config(void);
static void MPU_Config(void);
static void MX_GPIO_Init(void);
extern struct netif gnetif;
int main(void)
{
MPU_Config();
SCB_EnableICache();
SCB_EnableDCache();
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
MX_LWIP_Init();
while (1)
{
ethernetif_input(&gnetif);
sys_check_timeouts();
}
}
No problem to ping the device.
Now adding FreeRTOS to the mix:
Changed these settings in FreeRTOS:
USE_NEWLIB_REENTRANT Enabled
MINIMAL_STACK_SIZE 512
TOTAL_HEAP_SIZE 64000
Interface: CMSIS_V2
ETH Changes:
RX Mode: Interrupt Mode
NVIC Enabled Ethernet global interrupt preemption priority 5
No changes to: STM32F767ZITX_FLASH.ld from before with No-OS.
SYS:
Timebase Source: TIM6
lwIP some of the settings changed, it enabled OS-Mode for lwIP. (I haven't actively changed any):
WITH_RTOS (Use FREERTOS ** CubeMX specific **): Enabled
CMSIS_VERSION (CMSIS API Version used): CMSIS v2
RTOS_USE_NEWLIB_REENTRANT (RTOS used - 1): Enabled
NO_SYS (OS Awarness): OS Used

In main.c:
#include "main.h"
#include "cmsis_os.h"
#include "lwip.h"
osThreadId_t defaultTaskHandle;
const osThreadAttr_t defaultTask_attributes = {
.name = "defaultTask",
.stack_size = 512 * 4,
.priority = (osPriority_t) osPriorityNormal,
};
void SystemClock_Config(void);
static void MPU_Config(void);
static void MX_GPIO_Init(void);
void StartDefaultTask(void *argument);
int main(void)
{
MPU_Config();
SCB_EnableICache();
SCB_EnableDCache();
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
osKernelInitialize();
defaultTaskHandle = osThreadNew(StartDefaultTask, NULL, &defaultTask_attributes);
osKernelStart();
while (1)
{
}
}
void StartDefaultTask(void *argument)
{
MX_LWIP_Init();
for(;;)
{
osDelay(1);
}
}
If I pause the execution the program hasn't crashed, it seems to be running.

CubeID Projects was huge so I didn't attach these but if they are needed, ask and I will solve it.
It feels like I have missed something in my understanding how this works.
In the No-OS Mode I call ethernetif_input(...) and sys_checks_timeouts() which calls the lwip-stack. However, with FreeRTOS implementation I don't do this, but it is my understanding looking in the code that it should create a lwip task that handles the stack so I think I shouldn't need to call anything to get it working with ping?
I have also tried an example with NetCONN FreeRTOS for F767ZI and it works to ping the device with it, that example is unfortunately not generated with CubeMX I think?https://github.com/STMicroelectronics/STM32CubeF7/tree/master/Projects/STM32F767ZI-Nucleo/Applications/LwIP/LwIP_HTTP_Server_Netconn_RTOS
