UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

AR# 30195

10.1 EDK - What do I need to do to migrate from lwIP 2.00.a to 3.00.a?

Description

Keywords: lwIP, light, weight, internet, protocol, TCP, UDP

lwip_v3_00_a provides a different API compared to lwip_v2_00_a. However, there is no migration guide. What do I have to do to migrate from lwIP 2.00.a to 3.00.a?

Solution

Users migrating from lwip_v2_00_a to lwip_v3_00_a can follow these steps to upgrade their applications to use lwip_v3_00_a. Note that lwip_v3_00_a differs significantly from lwip_v2_00_a. However, all the changes are in the initialization code. Also, lwip_v3_00_a works only with the xps_ethernetlite and xps_ll_temac MAC cores. Older MAC cores are not supported.

1. In software platform settings dialog, the following selections are no longer required with lwip_v3_00_a:
- No need to select a MAC
- No need to set the MAC address
- Both of the above settings are done with the xemac_add function. This function takes the parameter of the ethernet MAC to use, and the MAC address to use.

2. Initialize lwIP by calling the function lwip_init().
3. All other lwIP operations should be performed only from threads that have been launched using sys_thread_new. Hence, a simplistic main_thread would look like:

int main_thread()
{

/* initialize lwIP before calling sys_thread_new */
lwip_init();

/* any thread using lwIP should be created using sys_thread_new */
sys_thread_new(network_thread, NULL, DEFAULT_THREAD_PRIO);

return 0;
}


4. The network_thread then takes care of:
- Specifying a MAC, and its MAC address
- Launching application threads

For example:

void network_thread(void *p)
{
struct netif *netif;
struct ip_addr ipaddr, netmask, gw;

/* the mac address of the board. this should be unique per board */
unsigned char mac_ethernet_address[] = { 0x00, 0x0a, 0x35, 0x00, 0x01, 0x02 };

netif = &server_netif;

/* initialize IP addresses to be used */
IP4_ADDR(&ipaddr, 192, 168, 1, 10);
IP4_ADDR(&netmask, 255, 255, 255, 0);
IP4_ADDR(&gw, 192, 168, 1, 1);

/* Add network interface to the netif_list, and set it as default */

if (!xemac_add(netif, &ipaddr, &netmask, &gw, mac_ethernet_address, EMAC_BASEADDR)) {
xil_printf("Error adding N/W interface\n\r");
return;
}

netif_set_default(netif);

/* specify that the network if is up */
netif_set_up(netif);

/* start packet receive thread - required for lwIP operation */
sys_thread_new((void(*)(void*))xemacif_input_thread, netif, DEFAULT_THREAD_PRIO);

/* launch other application specific threads */
launch_threads();
}


The application-specific threads can then use the base lwIP sockets API.

For other lwIP issues, please refer to (Xilinx Answer 29757), (Xilinx Answer 29791), and (Xilinx Answer 30155).
AR# 30195
Date Created 02/04/2008
Last Updated 03/18/2008
Status Active
Type General Article