第 1 /28 頁 Implementation LAN91c111-NE driver on Altera cyclone NIOS SoC development board 蕭詣懋 SoC EE CCU 5/23/2005 蕭詣懋
第 2 /28 頁 outline Introduction Cyclone board ( platform introduction) lwIP Lan911c
第 3 /28 頁 introduction 1.Porting a open source TCP/IP stack (Lwip) on Altera Nios Cyclone development borad
第 4 /28 頁 Our idea Find a small TCP/IP for small device. The small TCP/IP named LW IP that is created by Adam Dunkels. We hope that we can port LW IP to Nios and develop some sample programs for verifying it “Adam Dunkels”
第 5 /28 頁 LW IP 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”
第 6 /28 頁 lwIP
第 7 /28 頁 Line of LW IP code
第 8 /28 頁 Network interface - LW IP
第 9 /28 頁 TCP Processing - LW IP
第 10 /28 頁 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
第 11 /28 頁 UDP processing flow Library Driver(Lan911c) Simhost.c tcpecho.c udpecho.c
第 12 /28 頁 Makefile of lwip LIB4=liblwip4.a âLibrary LIB=liblwip4unix.a âapplication
第 13 /28 頁 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 \
第 14 /28 頁 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
第 15 /28 頁 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
第 16 /28 頁 demo A stander socket program ( tcp_sender.c ) Linux Cyclone A lwip program (tcp_receiver.c)
第 17 /28 頁 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.
第 18 /28 頁 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.
第 19 /28 頁 Get a lot of problem Nios doesn’t support Pthread The driver which I get is for lwIP , But the version I choose was lwIP still have a lot of bugs
第 20 /28 頁 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.