cancel
Showing results for 
Search instead for 
Did you mean: 

LWIP initialization process hangs in syscalls.c at _exit() when calling UDP_ENSURE_LOCAL_PORT_RANGE(LWIP_RAND()) in udp_init() or TCP_ENSURE_LOCAL_PORT_RANGE(LWIP_RAND()) in tcp_init()

GHeller
Associate III

Hello.

I'm trying to enable LWIP (TCP/IP) in my TouchGFX project on H750B-DK board. I am able to successfully enable LWIP and ping my device without TouchGFX (on an empty project), but when I follow exactly the same steps, but on a TouchGFX project, the LWIP fails to initialize.

I'm using the newest 3.0.6 version of H750B-DK template from TouchGFX. I edit it to my preferences and generate the code. Then I open the project from STM32CubeIDE folder in Cube and proceed to enable the LWIP in MX. I follow almost the same process as on an empty project. The only difference is that I have to delete PA2 pin that's assigned to LCD_RESET in order to enable Ethernet, and also I have to use MPU region 5, 6 and 7 instead o 0, 1 and 2, beacuse they are already defined by TouchGFX. I generate the code, then open TouchGFX project to regenerate the code. After that I proceed to add

 /* Modification start */

 .lwip_sec (NOLOAD) : {

  . = ABSOLUTE(0x30040000);

  *(.RxDecripSection) 

   

  . = ABSOLUTE(0x30040060);

  *(.TxDecripSection)

   

  . = ABSOLUTE(0x30040200);

  *(.RxArraySection) 

 } >RAM_D2

 /* Modification end */

to FLASH.ld as in tutorial. I also put DATA_IN_D2_SRAM into preprocessor symbols for GCC and G++ just to be safe. I build and upload to my board. Normally the code would have entered the infinite for loop in the task and I could ping my device, but when using TouchGFX it hangs in LWIP initialization as in the title. The screen works fine in any case. Below are screenshots that I think are important. There is no code written by me other than the edit to FLASH.ld. Only generated code.

0693W00000GVxhtQAD.png 

0693W00000GVxh5QAD.png0693W00000GVxhAQAT.png0693W00000GVxhFQAT.png0693W00000GVxhKQAT.png 

1 ACCEPTED SOLUTION

Accepted Solutions
GHeller
Associate III

0693W00000GVztNQAT.pngIt is thanks to this warning that I was able to actually find anything about this issue on the internet.

If you're facing similar issues go to this thread:

Why does rand() or random() return 0 in threads but is OK in main? - Kernel - FreeRTOS Community Forums

and remove sysmem.c from your project. I am sure this is not a proper solution though. More about this issue can be found here:

newlib and FreeRTOS (nadler.com)

View solution in original post

1 REPLY 1
GHeller
Associate III

0693W00000GVztNQAT.pngIt is thanks to this warning that I was able to actually find anything about this issue on the internet.

If you're facing similar issues go to this thread:

Why does rand() or random() return 0 in threads but is OK in main? - Kernel - FreeRTOS Community Forums

and remove sysmem.c from your project. I am sure this is not a proper solution though. More about this issue can be found here:

newlib and FreeRTOS (nadler.com)