LwIP integration - mapping RTEMS FDs to LwIP ones

Pavel Pisa ppisa4lists at pikron.com
Mon Nov 19 22:21:28 UTC 2018


Hello Antonio,

I have noticed that you have tried to map
RTEMS network applications to LwIP.
You have tried to use LwIP headers instead
of NewLib provided ones. To integrate read, write,
close etc. correctly it is necessary to use
RTEMS FDs and map them to LwIP ones.

See my description in RTEMS Wiki

  https://devel.rtems.org/wiki/Packages/LWIP

I have tried to implement this mapping based on original
RETMS network stack cpukit/libnetworking/rtems/rtems_syscall.c file.
There is the result

  https://github.com/ppisa/rtems-devel/blob/master/rtems-omk-template/applwiptest/rtems_lwip_io.c

I have been able to run RTEMS provided telnetd over this
IP stack replacement on TMS570LS3137.

See telned startup fragment at starting lines 58 and 155 of example application

  https://github.com/ppisa/rtems-devel/blob/master/rtems-omk-template/applwiptest/init.c#L58

Because LwIP sockaddr type can in general differ and AF_XXX and PF_XXX differ between NewLib
and LwIP there is implemented layer to translate NewLib application types and defines to
from/to LwIP ones

  ​https://github.com/ppisa/rtems-devel/blob/master/rtems-omk-template/applwiptest/rtems_lwip_int.hhttps://github.com/ppisa/rtems-devel/blob/master/rtems-omk-template/applwiptest/rtems_lwip_sysdefs.c

I have revised actual sockaddr types and it seems that they should
compile to same fields types and offset. So that part of the
file is probably not required. I have removed RTEMS provided archives

  ar d librtemscpu.a in_proto.o ip_fw.o ip_icmp.o ip_input.o \
                     main_netstats.o main_ping.o rtems_syscall.o \
                     tcp_debug.o tcp_input.o tcp_output.o tcp_subr.o \
                     tcp_timer.o tcp_usrreq.o udp_usrreq.o

and replaced them by

   ar r librtemscpu.a rtems_lwip_sysdefs.o rtems_lwip_io.o

I have used already described mapping to LwIP

  https://sourceforge.net/p/ulan/lwip-omk/ci/master/tree/ports/os/rtems/arch/

LwIP stack is our code with OMK build system, probably some simpler
RTEMS only build tree can be prepared

  https://sourceforge.net/p/ulan/lwip-omk/ci/master/tree/

Test application together with links to LwIP has been build
from OMK templete

  https://github.com/ppisa/rtems-devel/tree/master/rtems-omk-template

config.target:
----------------------------
RTEMS_MAKEFILE_PATH=/opt/rtems5.0/arm-rtems5.0/tms570ls3137_hdk_sdram
----------------------------

config.omk:
----------------------------
CONFIG_OC_APP_APPLWIPTEST=y
CONFIG_OC_APP_APPLWIPTEST_RTEMS_IO=y
CONFIG_OC_APP_APPLWIPTEST_TELNETD=y

CONFIG_LWIP_LIB=y

CONFIG_LWIP_LWIP_IPV4=y
#CONFIG_LWIP_LWIP_SNMP=y
CONFIG_LWIP_LWIP_ARP=y

CONFIG_LWIP_OS_PORT = rtems
CONFIG_LWIP_DEVICE_DRIVERS = tms570_emac

#lwipots
CONFIG_LWIP_STATIC_IP_ADDRESS=0

CONFIG_LWIP_HOST_TMR_INTERVAL=0
#CONFIG_LWIP_DYNAMIC_HTTP_HEADERS=y vypnul jsem ja

CONFIG_LWIP_SYS_LIGHTWEIGHT_PROT=1
CONFIG_LWIP_LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT=1

#CONFIG_LWIP_MEMP_OVERFLOW_CHECK=2
#CONFIG_LWIP_MEMP_SANITY_CHECK=y
CONFIG_LWIP_MEMP_SEPARATE_POOLS=y
CONFIG_LWIP_NO_SYS=0

CONFIG_LWIP_TCPIP_THREAD_PRIO=5
CONFIG_LWIP_TCPIP_THREAD_STACKSIZE=8192

CONFIG_LWIP_MEM_LIBC_MALLOC=0
#CONFIG_LWIP_MBOX_SIZE=4
CONFIG_LWIP_MEM_ALIGNMENT=4
CONFIG_LWIP_MEM_SIZE=(64*1024)
CONFIG_LWIP_MEMP_NUM_PBUF=48
CONFIG_LWIP_MEMP_NUM_TCP_PCB=32
CONFIG_LWIP_PBUF_POOL_SIZE=256
CONFIG_LWIP_MEMP_NUM_TCPIP_MSG_INPKT=50
CONFIG_LWIP_MEMP_NUM_TCPIP_MSG_API=30 

CONFIG_LWIP_IP_REASSEMBLY=0
CONFIG_LWIP_IP_FRAG=0

CONFIG_LWIP_LWIP_DHCP=1
CONFIG_LWIP_DHCP_DOES_ARP_CHECK=0

CONFIG_LWIP_LWIP_AUTOIP=0

CONFIG_LWIP_TCP_MSS=512
CONFIG_LWIP_TCP_WND=(512*4)
CONFIG_LWIP_TCP_SND_BUF=(512*4)

CONFIG_LWIP_PBUF_LINK_HLEN=14
CONFIG_LWIP_PBUF_POOL_BUFSIZE=256

CONFIG_LWIP_ETH_PAD_SIZE=0
CONFIG_LWIP_MEMP_NUM_NETCONN=10

CONFIG_LWIP_LWIP_NETCONN=1
CONFIG_LWIP_LWIP_SOCKET=1
CONFIG_LWIP_LWIP_SO_RCVTIMEO=1

CONFIG_LWIP_TCPIP_MBOX_SIZE=100
CONFIG_LWIP_DEFAULT_RAW_RECVMBOX_SIZE=100
CONFIG_LWIP_DEFAULT_UDP_RECVMBOX_SIZE=100
CONFIG_LWIP_DEFAULT_TCP_RECVMBOX_SIZE=100
CONFIG_LWIP_DEFAULT_ACCEPTMBOX_SIZE=100

CONFIG_LWIP_LWIP_STATS_DISPLAY=y
CONFIG_LWIP_LWIP_STATS=1
CONFIG_LWIP_MEMP_STATS=y
CONFIG_LWIP_MEM_STATS=y
#CONFIG_LWIP_ALL_DBG_ON=1
CONFIG_LWIP_LWIP_NETIF_API=1
----------------------------

Best wishes,

Pavel Pisa



More information about the devel mailing list