[RTD701] Example FRDM-A-S32K344 EMAC lwIP IPv6 Baremetal/FreeRTOS S32DS 3.6 RTD 7.0.1

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

[RTD701] Example FRDM-A-S32K344 EMAC lwIP IPv6 Baremetal/FreeRTOS S32DS 3.6 RTD 7.0.1

[RTD701] Example FRDM-A-S32K344 EMAC lwIP IPv6 Baremetal/FreeRTOS S32DS 3.6 RTD 7.0.1

This example is based on AN13458: Implement IPv6 + IPv4 Communication on One ENET Port based on LWIP.

/*
 * Copyright 2017-2026 NXP
 *
 * NXP Confidential and Proprietary. This software is owned or controlled by NXP
 * and may only be used strictly in accordance with the applicable license terms.
 * By expressly accepting such terms or by downloading, installing, activating
 * and/or otherwise using the software, you are agreeing that you have read,
 * and that you agree to comply with and are bound by, such license terms.
 * If you do not agree to be bound by the applicable license terms,
 * then you may not retain, install, activate or otherwise use the software.
 *********************************************************************************
*   File              main.c
*   Owner             Julián Aragón
*   Version           1.0
*   Date              21-09-2026
*   Classification    General Business Information
*********************************************************************************
* Detailed Description:
* Updated the example lwip_baremetal_s32k344 to enable simultaneous IPv4 and
* IPv6 pinging of the lwIP stack from the command window, based on AN13458.
*
*  ping -4 192.168.0.200
*
*  Pinging 192.168.0.200 with 32 bytes of data:
*  Reply from 192.168.0.200: bytes=32 time<1ms TTL=255
*  Reply from 192.168.0.200: bytes=32 time=1ms TTL=255
*  Reply from 192.168.0.200: bytes=32 time<1ms TTL=255
*  Reply from 192.168.0.200: bytes=32 time<1ms TTL=255
*
*  Ping statistics for 192.168.0.200:
*      Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
*  Approximate round trip times in milli-seconds:
*      Minimum = 0ms, Maximum = 1ms, Average = 0ms
*
*  ping -6 FE80::3DD7:9303:126c:0df0%23
*
*  Pinging fe80::3dd7:9303:126c:df0%23 with 32 bytes of data:
*  Reply from fe80::3dd7:9303:126c:df0%23: time<1ms
*  Reply from fe80::3dd7:9303:126c:df0%23: time<1ms
*  Reply from fe80::3dd7:9303:126c:df0%23: time<1ms
*  Reply from fe80::3dd7:9303:126c:df0%23: time<1ms
*
*  Ping statistics for fe80::3dd7:9303:126c:df0%23:
*      Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
*  Approximate round trip times in milli-seconds:
*      Minimum = 0ms, Maximum = 0ms, Average = 0ms
*
*	EVB:
*		- All jumpers in default positions
*
*	Configuration:
*		- Updated pin configuration
*		- Updated clock configuration
*		- IPv4 address: 192.168.0.200
*		- IPv6 address: FE80::3DD7:9303:126c:0df0 (static link-local)
*		- Enabled LWIP_IPV6 in lwipopts.h
*		- Enabled LWIP_RAW in lwipopts.h
*		- Set has_IPv6 = 1 in netifcfg.c
*
* 	main.c
* 		- Updated header only
* 	device.c
* 		- No changes
* 	test.c
* 		- Added IPv6 static address assignment in interface_init()
* 	  	(IP6_ADDR + netif_add_ip6_address + netif_ip6_addr_set_state)
* 		- Added icmp_led_init() call in apps_init()
* 		- Added icmp_led_callback(): raw PCB for IPv4 ICMP (protocol 1)
* 	  	flashes GREEN LED on ping receive
* 		- Added icmp_led_callback(): raw PCB for IPv6 ICMPv6 (protocol 58)
* 	  	flashes BLUE LED on ping receive
* 		- Commented out TCP/IP stack shutdown timeout
*
*   -----------------------------------------------------------------------------
*   Test HW:        FRDM-A-S32K344 SCH-94921 PDF: SPF-94921 Rev. C
*   MCU:            S32K344
*   Debugger:       On Board
*   Target:         internal_FLASH
*   EVB connection: EMAC <-> USB-to-Ethernet adapter <-> Laptop DELL, Windows 11
*********************************************************************************
*   Revision History:
*   Ver  Date         Author            Description of Changes
*   1.0  Sep-21-2026  Julián Aragón 	Initial version
**********************************************************************************/

Note: In order to ping with IPv6 from Windows 11 Command Prompt, you must specify Ethernet port Idx being used:

ping -6 FE80::3DD7:9303:126c:0df0%<interface_index>

You can find your numeric index with the following command: netsh interface ipv6 show interfaces. 

Attachments
%3CLINGO-SUB%20id%3D%22lingo-sub-2415050%22%20slang%3D%22en-US%22%20mode%3D%22UPDATE%22%3E%5BRTD701%5D%20Example%20FRDM-A-S32K344%20EMAC%20lwIP%20IPv6%20Baremetal%2FFreeRTOS%20S32DS%203.6%20RTD%207.0.1%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2415050%22%20slang%3D%22en-US%22%20mode%3D%22UPDATE%22%3E%0A%3CP%3EThis%20example%20is%20based%20on%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fwww.nxp.com%2Fdocs%2Fen%2Fapplication-note%2FAN13458.pdf%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EAN13458%3A%20Implement%20IPv6%20%2B%20IPv4%20Communication%20on%20One%20ENET%20Port%20based%20on%20LWIP.%3C%2FA%3E%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-c%22%3E%3CCODE%3E%2F*%0A%20*%20Copyright%202017-2026%20NXP%0A%20*%0A%20*%20NXP%20Confidential%20and%20Proprietary.%20This%20software%20is%20owned%20or%20controlled%20by%20NXP%0A%20*%20and%20may%20only%20be%20used%20strictly%20in%20accordance%20with%20the%20applicable%20license%20terms.%0A%20*%20By%20expressly%20accepting%20such%20terms%20or%20by%20downloading%2C%20installing%2C%20activating%0A%20*%20and%2For%20otherwise%20using%20the%20software%2C%20you%20are%20agreeing%20that%20you%20have%20read%2C%0A%20*%20and%20that%20you%20agree%20to%20comply%20with%20and%20are%20bound%20by%2C%20such%20license%20terms.%0A%20*%20If%20you%20do%20not%20agree%20to%20be%20bound%20by%20the%20applicable%20license%20terms%2C%0A%20*%20then%20you%20may%20not%20retain%2C%20install%2C%20activate%20or%20otherwise%20use%20the%20software.%0A%20*********************************************************************************%0A*%20%20%20File%20%20%20%20%20%20%20%20%20%20%20%20%20%20main.c%0A*%20%20%20Owner%20%20%20%20%20%20%20%20%20%20%20%20%20Juli%C3%A1n%20Arag%C3%B3n%0A*%20%20%20Version%20%20%20%20%20%20%20%20%20%20%201.0%0A*%20%20%20Date%20%20%20%20%20%20%20%20%20%20%20%20%20%2021-09-2026%0A*%20%20%20Classification%20%20%20%20General%20Business%20Information%0A*********************************************************************************%0A*%20Detailed%20Description%3A%0A*%20Updated%20the%20example%20lwip_baremetal_s32k344%20to%20enable%20simultaneous%20IPv4%20and%0A*%20IPv6%20pinging%20of%20the%20lwIP%20stack%20from%20the%20command%20window%2C%20based%20on%20AN13458.%0A*%0A*%20%20ping%20-4%20192.168.0.200%0A*%0A*%20%20Pinging%20192.168.0.200%20with%2032%20bytes%20of%20data%3A%0A*%20%20Reply%20from%20192.168.0.200%3A%20bytes%3D32%20time%26lt%3B1ms%20TTL%3D255%0A*%20%20Reply%20from%20192.168.0.200%3A%20bytes%3D32%20time%3D1ms%20TTL%3D255%0A*%20%20Reply%20from%20192.168.0.200%3A%20bytes%3D32%20time%26lt%3B1ms%20TTL%3D255%0A*%20%20Reply%20from%20192.168.0.200%3A%20bytes%3D32%20time%26lt%3B1ms%20TTL%3D255%0A*%0A*%20%20Ping%20statistics%20for%20192.168.0.200%3A%0A*%20%20%20%20%20%20Packets%3A%20Sent%20%3D%204%2C%20Received%20%3D%204%2C%20Lost%20%3D%200%20(0%25%20loss)%2C%0A*%20%20Approximate%20round%20trip%20times%20in%20milli-seconds%3A%0A*%20%20%20%20%20%20Minimum%20%3D%200ms%2C%20Maximum%20%3D%201ms%2C%20Average%20%3D%200ms%0A*%0A*%20%20ping%20-6%20FE80%3A%3A3DD7%3A9303%3A126c%3A0df0%2523%0A*%0A*%20%20Pinging%20fe80%3A%3A3dd7%3A9303%3A126c%3Adf0%2523%20with%2032%20bytes%20of%20data%3A%0A*%20%20Reply%20from%20fe80%3A%3A3dd7%3A9303%3A126c%3Adf0%2523%3A%20time%26lt%3B1ms%0A*%20%20Reply%20from%20fe80%3A%3A3dd7%3A9303%3A126c%3Adf0%2523%3A%20time%26lt%3B1ms%0A*%20%20Reply%20from%20fe80%3A%3A3dd7%3A9303%3A126c%3Adf0%2523%3A%20time%26lt%3B1ms%0A*%20%20Reply%20from%20fe80%3A%3A3dd7%3A9303%3A126c%3Adf0%2523%3A%20time%26lt%3B1ms%0A*%0A*%20%20Ping%20statistics%20for%20fe80%3A%3A3dd7%3A9303%3A126c%3Adf0%2523%3A%0A*%20%20%20%20%20%20Packets%3A%20Sent%20%3D%204%2C%20Received%20%3D%204%2C%20Lost%20%3D%200%20(0%25%20loss)%2C%0A*%20%20Approximate%20round%20trip%20times%20in%20milli-seconds%3A%0A*%20%20%20%20%20%20Minimum%20%3D%200ms%2C%20Maximum%20%3D%200ms%2C%20Average%20%3D%200ms%0A*%0A*%09EVB%3A%0A*%09%09-%20All%20jumpers%20in%20default%20positions%0A*%0A*%09Configuration%3A%0A*%09%09-%20Updated%20pin%20configuration%0A*%09%09-%20Updated%20clock%20configuration%0A*%09%09-%20IPv4%20address%3A%20192.168.0.200%0A*%09%09-%20IPv6%20address%3A%20FE80%3A%3A3DD7%3A9303%3A126c%3A0df0%20(static%20link-local)%0A*%09%09-%20Enabled%20LWIP_IPV6%20in%20lwipopts.h%0A*%09%09-%20Enabled%20LWIP_RAW%20in%20lwipopts.h%0A*%09%09-%20Set%20has_IPv6%20%3D%201%20in%20netifcfg.c%0A*%0A*%20%09main.c%0A*%20%09%09-%20Updated%20header%20only%0A*%20%09device.c%0A*%20%09%09-%20No%20changes%0A*%20%09test.c%0A*%20%09%09-%20Added%20IPv6%20static%20address%20assignment%20in%20interface_init()%0A*%20%09%20%20%09(IP6_ADDR%20%2B%20netif_add_ip6_address%20%2B%20netif_ip6_addr_set_state)%0A*%20%09%09-%20Added%20icmp_led_init()%20call%20in%20apps_init()%0A*%20%09%09-%20Added%20icmp_led_callback()%3A%20raw%20PCB%20for%20IPv4%20ICMP%20(protocol%201)%0A*%20%09%20%20%09flashes%20GREEN%20LED%20on%20ping%20receive%0A*%20%09%09-%20Added%20icmp_led_callback()%3A%20raw%20PCB%20for%20IPv6%20ICMPv6%20(protocol%2058)%0A*%20%09%20%20%09flashes%20BLUE%20LED%20on%20ping%20receive%0A*%20%09%09-%20Commented%20out%20TCP%2FIP%20stack%20shutdown%20timeout%0A*%0A*%20%20%20-----------------------------------------------------------------------------%0A*%20%20%20Test%20HW%3A%20%20%20%20%20%20%20%20FRDM-A-S32K344%20SCH-94921%20PDF%3A%20SPF-94921%20Rev.%20C%0A*%20%20%20MCU%3A%20%20%20%20%20%20%20%20%20%20%20%20S32K344%0A*%20%20%20Debugger%3A%20%20%20%20%20%20%20On%20Board%0A*%20%20%20Target%3A%20%20%20%20%20%20%20%20%20internal_FLASH%0A*%20%20%20EVB%20connection%3A%20EMAC%20%26lt%3B-%26gt%3B%20USB-to-Ethernet%20adapter%20%26lt%3B-%26gt%3B%20Laptop%20DELL%2C%20Windows%2011%0A*********************************************************************************%0A*%20%20%20Revision%20History%3A%0A*%20%20%20Ver%20%20Date%20%20%20%20%20%20%20%20%20Author%20%20%20%20%20%20%20%20%20%20%20%20Description%20of%20Changes%0A*%20%20%201.0%20%20Sep-21-2026%20%20Juli%C3%A1n%20Arag%C3%B3n%20%09Initial%20version%0A**********************************************************************************%2F%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%3CSTRONG%3ENote%3A%26nbsp%3B%3C%2FSTRONG%3EIn%20order%20to%20ping%20with%20IPv6%20from%20Windows%2011%20Command%20Prompt%2C%20you%20must%20specify%20Ethernet%20port%20Idx%20being%20used%3A%3C%2FP%3E%0A%3CPRE%20class%3D%22_1ibi0s3d1%22%20dir%3D%22auto%22%20data-pm-slice%3D%221%201%20%5B%5D%22%3E%3CCODE%20class%3D%22language-cmd%22%3Eping%20-6%20FE80%3A%3A3DD7%3A9303%3A126c%3A0df0%25%3CINTERFACE_INDEX%3E%3C%2FINTERFACE_INDEX%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EYou%20can%20find%20your%20numeric%20index%20with%20the%20following%20command%3A%20%3CCODE%3Enetsh%20interface%20ipv6%20show%20interfaces.%3C%2FCODE%3E%26nbsp%3B%3C%2FP%3E%0A%3C%2FLINGO-BODY%3E
No ratings
Version history
Last update:
Monday
Updated by: