200 likes | 406 Views
Implementation LAN91c111-NE driver on Altera cyclone NIOS SoC development board. 蕭詣懋 SoC EE CCU 5/23/2005. 蕭詣懋 “93mowmow@vlsi.ee.ccu.edu.tw”. outline. Introduction Cyclone board ( platform introduction) lwIP Lan911c. introduction.
E N D
Implementation LAN91c111-NE driver on Altera cyclone NIOS SoC development board 蕭詣懋 SoC EE CCU 5/23/2005 蕭詣懋“93mowmow@vlsi.ee.ccu.edu.tw”
outline • Introduction • Cyclone board ( platform introduction) • lwIP • Lan911c
introduction • Porting a open source TCP/IP stack (Lwip) on Altera Nios Cyclone development borad
Our idea • Find a small TCP/IP for small device. The small TCP/IP named LWIP that is created by Adam Dunkels. • We hope that we can port LWIP to Nios and develop some sample programs for verifying it “Adam Dunkels” http://www.sics.se/~adam/
LWIP feature lwIP is an implementation of the TCP/IP protocol stack. The focus of the lwIP stack is to reduce memory usage and code size, making lwIP suitable for use in small clients with very limited resources such as embedded systems. In order to reduce processing and memory demands,lwIP uses a tailor made API that does not require any data copying. This report describes the design and implementation of lwIP. The algorithms and data structures used both in the protocol implementations and in the sub systems such as the memory and buffer management systems are described. “lwip” http://savannah.nongnu.org/projects/lwip/
Design flow • Find a workable lwIP version .make sure it can work on Linux on X86 PC. • Then write a Makefile which nios cross compiler can use. • Verify the lwIP TCP/IP stack can work on nios cyclone platform • Write the lan driver for lwIP • Trace connection between PC & cyclone
UDP processing flow Simhost.c tcpecho.c udpecho.c Library Driver(Lan911c)
Makefile of lwip • LIB4=liblwip4.a • Library • LIB=liblwip4unix.a • application
liblwip4.a • IPV4=$(LWIPDIR)/core/ipv4/icmp.c.o $(LWIPDIR)/core/ipv4/ip.c.o $(LWIPDIR)/core/inet.c.o • CWFILES=$(LWIPDIR)/api/api_lib.c.o $(LWIPDIR)/api/api_msg.c.o $(LWIPDIR)/api/tcpip.c.o $(LWIPDIR)/api/err.c.o \ • # $(LWIPDIR)/netif/loopif.c.o $(LWIPDIR)/netif/tcpdump.c.o \
liblwip4.a(con’t) • $(LWIPDIR)/netif/etharp.c.o \ • $(LWIPDIR)/netif/altera_avalon_lan91c111.c.o\ • $(LWIPDIR)/core/mem.c.o $(LWIPDIR)/core/memp.c.o $(LWIPDIR)/core/netif.c.o $(LWIPDIR)/core/pbuf.c.o \ • $(LWIPDIR)/core/stats.c.o $(LWIPDIR)/core/sys.c.o \ • $(LWIPDIR)/core/tcp.c.o $(LWIPDIR)/core/tcp_input.c.o \ • $(LWIPDIR)/core/tcp_output.c.o $(LWIPDIR)/core/udp.c.o
liblwip4unix.a • ACFILES=$(wildcard $(LWIPDIR)/arch/unix/*.c $(LWIPDIR)/arch/unix/netif/*.c) \ • # ../../../../../../../altera/kits/nios/bin/nios-gnupro/newlib/libc/sys/arm/syscalls.c • # apps/fs.c apps/httpd.c \ • # apps/udpecho.c apps/tcpecho.c \ • # apps/shell.c
demo Linux Cyclone A lwip program (tcp_receiver.c) A stander socket program ( tcp_sender.c )
How to port lwIP to any platform • The general idea is that porting lwIP to new architectures requires only small changes to a few header files and a new sys_arch implementation • The sys_arch provides semaphores and mailboxes to lwIP.
sys_arch • The following functions must be implemented by the sys_arch: • void sys_init(void) Is called to initialize the sys_arch layer. • sys_sem_t sys_sem_new(u8_t count) Creates and returns a new semaphore. The "count" argument specifies the initial state of the semaphore. • void sys_sem_free(sys_sem_t sem) Deallocates a semaphore.
Get a lot of problem • Nios doesn’t support Pthread • The driver which I get is for lwIP 6.0.03, But the version I choose was lwIP 5.0.0.1 • still have a lot of bugs
Conclusion • If you want to get ( learn ) something------just pay your time on it , sleep less ,trace code ,debug ,try and error .…And that is why we are here !! • System software is interesting and is more complicated • Especially, thanks very much to Mr.Pan for a lot of teaching.