S32K344 lwip tcp/ip udp send issue

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

S32K344 lwip tcp/ip udp send issue

Jump to solution
6,324 Views
malove
Contributor IV

Hello,

I am implementing logic to send messages using the lwIP TCP/IP stack, and I have encountered an issue.

Here is my current situation:

  1. The S32K344 MCU is connected to a PC via UDP.
  2. The MCU sends data to the PC.
  3. During data transmission, a memory-related issue occurs (mem_free: illegal memory: non-linked: double free).
    • The issue sometimes happens in TxNotification.
    • Alternatively, it occurs in the send_udp_data function that I implemented.

The attached test.c source file is based on the S32K344 TCP/IP 1.0.3 sample code, with the addition of the send_udp_data function.

Could you please review my UDP transmission code and let me know if I have implemented anything incorrectly?

 

 

Tags (3)
0 Kudos
Reply
1 Solution
6,249 Views
PavelL
NXP Employee
NXP Employee

Hello @malove ,

Based on warnings, udp_sendto (and udp_receive_callback) requires type ip_addr. I use TCPIP_STACK for S32K3XX version 1.0.4 .

Best regards,

Pavel

View solution in original post

0 Kudos
Reply
4 Replies
6,262 Views
malove
Contributor IV

Thank you always @PavelL 

I compared the codes and it seems like all ip4_addr have been changed to ip_addr.

Can I ask why?

 

0 Kudos
Reply
6,250 Views
PavelL
NXP Employee
NXP Employee

Hello @malove ,

Based on warnings, udp_sendto (and udp_receive_callback) requires type ip_addr. I use TCPIP_STACK for S32K3XX version 1.0.4 .

Best regards,

Pavel

0 Kudos
Reply
6,239 Views
malove
Contributor IV

Thank you! 

0 Kudos
Reply
6,287 Views
PavelL
NXP Employee
NXP Employee

Hello @malove ,

I fixed warnings in your code. The code works without any issue on my S32K344EVB-T172. Wireshark sees the UDP messages. The code is attached - please check it out.

Best regards,

Pavel

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2014079%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ES32K344%20lwip%20tcp%2Fip%20udp%20send%20issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2014079%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%3CSTRONG%3EHello%2C%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EI%20am%20implementing%20logic%20to%20send%20messages%20using%20the%20%3CSTRONG%3ElwIP%20TCP%2FIP%20stack%3C%2FSTRONG%3E%2C%20and%20I%20have%20encountered%20an%20issue.%3C%2FP%3E%3CP%3EHere%20is%20my%20current%20situation%3A%3C%2FP%3E%3COL%3E%3CLI%3EThe%20%3CSTRONG%3ES32K344%20MCU%3C%2FSTRONG%3E%20is%20connected%20to%20a%20%3CSTRONG%3EPC%3C%2FSTRONG%3E%20via%20%3CSTRONG%3EUDP%3C%2FSTRONG%3E.%3C%2FLI%3E%3CLI%3EThe%20MCU%20sends%20data%20to%20the%20PC.%3C%2FLI%3E%3CLI%3EDuring%20data%20transmission%2C%20a%20%3CSTRONG%3Ememory-related%20issue%3C%2FSTRONG%3E%20occurs%20(mem_free%3A%20illegal%20memory%3A%20non-linked%3A%20double%20free).%3CUL%3E%3CLI%3EThe%20issue%20sometimes%20happens%20in%20%3CSTRONG%3ETxNotification%3C%2FSTRONG%3E.%3C%2FLI%3E%3CLI%3EAlternatively%2C%20it%20occurs%20in%20the%20%3CSTRONG%3Esend_udp_data%3C%2FSTRONG%3E%20function%20that%20I%20implemented.%3C%2FLI%3E%3C%2FUL%3E%3C%2FLI%3E%3C%2FOL%3E%3CP%3EThe%20attached%20%3CSTRONG%3Etest.c%3C%2FSTRONG%3E%20source%20file%20is%20based%20on%20the%20%3CSTRONG%3ES32K344%20TCP%2FIP%201.0.3%20sample%20code%3C%2FSTRONG%3E%2C%20with%20the%20addition%20of%20the%20%3CSTRONG%3Esend_udp_data%3C%2FSTRONG%3E%20function.%3C%2FP%3E%3CP%3ECould%20you%20please%20review%20my%20%3CSTRONG%3EUDP%20transmission%20code%3C%2FSTRONG%3E%20and%20let%20me%20know%20if%20I%20have%20implemented%20anything%20incorrectly%3F%3C%2FP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2016949%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20S32K344%20lwip%20tcp%2Fip%20udp%20send%20issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2016949%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EThank%20you!%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2016927%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20S32K344%20lwip%20tcp%2Fip%20udp%20send%20issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2016927%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F241168%22%20target%3D%22_blank%22%3E%40malove%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%0A%3CP%3EBased%20on%20warnings%2C%20udp_sendto%20(and%20udp_receive_callback)%20requires%20type%20ip_addr.%20I%20use%26nbsp%3BTCPIP_STACK%20for%20S32K3XX%20version%201.0.4%20.%3C%2FP%3E%0A%3CP%3EBest%20regards%2C%3C%2FP%3E%0A%3CP%3EPavel%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2016591%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20S32K344%20lwip%20tcp%2Fip%20udp%20send%20issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2016591%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EThank%20you%20always%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F233505%22%20target%3D%22_blank%22%3E%40PavelL%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20compared%20the%20codes%20and%20it%20seems%20like%20all%20ip4_addr%20have%20been%20changed%20to%20ip_addr.%3C%2FP%3E%3CP%3ECan%20I%20ask%20why%3F%3C%2FP%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2015271%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20S32K344%20lwip%20tcp%2Fip%20udp%20send%20issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2015271%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F241168%22%20target%3D%22_blank%22%3E%40malove%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%0A%3CP%3EI%20fixed%20warnings%20in%20your%20code.%20The%20code%20works%20without%20any%20issue%20on%20my%20S32K344EVB-T172.%20Wireshark%20sees%20the%20UDP%20messages.%20The%20code%20is%20attached%20-%20please%20check%20it%20out.%3C%2FP%3E%0A%3CP%3EBest%20regards%2C%3C%2FP%3E%0A%3CP%3EPavel%3C%2FP%3E%3C%2FLINGO-BODY%3E