2020-11-14 03:36 AM
Hi,
I have a Nucleo-F439ZI board and I am trying to make a simple application that echoes back a message on a UDP port.
When I generate a project using LwIP raw API, I am able to make that happen with a callback function and a PCB.
However, as soon as I turn CMSIS_V2 RTOS on in the CubeMX configuration perspective and create a few threads (e.g. blinking 2 different LEDs periodically), the execution of the program freezes right after MX_LWIP_Init() is called in "Default thread". I don't even have a chance to initialize a Netconn structure to listen for incoming packets or anything.
If I comment it out, every thread runs as expected, but with thi LwIP initialization function called, the whole execution freezes.
I was wondering if I am missing some trivial step , or this isn't the right way to use LwIP with RTOS, but I am clueless here, since this is the auto-generated code that doesn't work.
Also, in debug mode I get no HardFault or Exception or anything, it seems that the code is running as normal, but the threads are completely frozen.
When MX_LWIP_Init() is called in default thread, every task is frozen.
void StartDefaultTask(void *argument)
{
/* init code for LWIP */
//MX_LWIP_Init();
/* USER CODE BEGIN 5 */
/* Infinite loop */
for(;;)
{
HAL_UART_Transmit(&huart3, "Hello", 6, 1000);
osDelay(1000);
}
/* USER CODE END 5 */
}
void StartTask02(void *argument)
{
/* USER CODE BEGIN StartTask02 */
/* Infinite loop */
for(;;)
{
HAL_GPIO_TogglePin(LD1_GPIO_Port, LD1_Pin); //toggle running led
osDelay(500);
}
/* USER CODE END StartTask02 */
}
I would really appreciate if someone could tell mewhat I am doing wrong.
2021-06-25 02:10 PM
I guess that you have the same problem, please check the following:
The parameter LWIP_RAM_HEAP_POINTER = 0x30044000 ("LWIP" category, "Key Options" tab). This memory is probably not accessible on your CPU and the MX_LWIP_Init() fails exactly here:
MX_LWIP_Init() -> tcpip_init( NULL, NULL ) -> lwip_init() -> mem_init() -> fails during the first try to write to the "mem" variable
Solution: You have to find a different memory section that is accessible by this peripheral.