implementation lan91c111-ne driver on altera cyclone nios soc development board

20
第 1 /28 第 Implementation LAN91c111-NE driver Implementation LAN91c111-NE driver on on Altera cyclone NIOS Altera cyclone NIOS SoC development SoC development board board 蕭蕭蕭 SoC EE CCU 5/23/2005 蕭蕭蕭 [email protected]

Upload: yuri

Post on 15-Jan-2016

52 views

Category:

Documents


0 download

DESCRIPTION

Implementation LAN91c111-NE driver on Altera cyclone NIOS SoC development board. 蕭詣懋 SoC EE CCU 5/23/2005. 蕭詣懋 “[email protected]”. outline. Introduction Cyclone board ( platform introduction) lwIP Lan911c. introduction. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Implementation LAN91c111-NE driver on  Altera cyclone NIOS  SoC development board

第 1 /28 頁

Implementation LAN91c111-NE driver on Implementation LAN91c111-NE driver on Altera Altera cyclone NIOScyclone NIOS SoC development board SoC development board

蕭詣懋 SoC EE CCU

5/23/2005

蕭詣懋 “ [email protected]

Page 2: Implementation LAN91c111-NE driver on  Altera cyclone NIOS  SoC development board

第 2 /28 頁

outlineoutline

• Introduction

• Cyclone board ( platform introduction)

• lwIP

• Lan911c

Page 3: Implementation LAN91c111-NE driver on  Altera cyclone NIOS  SoC development board

第 3 /28 頁

introductionintroduction

1. Porting a open source TCP/IP stack (Lwip) on Altera Nios Cyclone development borad

Page 4: Implementation LAN91c111-NE driver on  Altera cyclone NIOS  SoC development board

第 4 /28 頁

Our ideaOur 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/

Page 5: Implementation LAN91c111-NE driver on  Altera cyclone NIOS  SoC development board

第 5 /28 頁

LWLWIP featureIP 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/

Page 6: Implementation LAN91c111-NE driver on  Altera cyclone NIOS  SoC development board

第 6 /28 頁

lwIPlwIP

Page 7: Implementation LAN91c111-NE driver on  Altera cyclone NIOS  SoC development board

第 7 /28 頁

Line of Line of LWLWIP codeIP code

Page 8: Implementation LAN91c111-NE driver on  Altera cyclone NIOS  SoC development board

第 8 /28 頁

Network interface - Network interface - LWLWIPIP

Page 9: Implementation LAN91c111-NE driver on  Altera cyclone NIOS  SoC development board

第 9 /28 頁

TCP Processing - TCP Processing - LWLWIPIP

Page 10: Implementation LAN91c111-NE driver on  Altera cyclone NIOS  SoC development board

第 10 /28 頁

Design flowDesign 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

Page 11: Implementation LAN91c111-NE driver on  Altera cyclone NIOS  SoC development board

第 11 /28 頁

UDP processing flowUDP processing flow

Library

Driver(Lan911c)

Simhost.c tcpecho.c udpecho.c

Page 12: Implementation LAN91c111-NE driver on  Altera cyclone NIOS  SoC development board

第 12 /28 頁

Makefile of lwipMakefile of lwip

• LIB4=liblwip4.aLibrary

• LIB=liblwip4unix.aapplication

Page 13: Implementation LAN91c111-NE driver on  Altera cyclone NIOS  SoC development board

第 13 /28 頁

liblwip4.aliblwip4.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 \

Page 14: Implementation LAN91c111-NE driver on  Altera cyclone NIOS  SoC development board

第 14 /28 頁

liblwip4.a(con’t)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

Page 15: Implementation LAN91c111-NE driver on  Altera cyclone NIOS  SoC development board

第 15 /28 頁

liblwip4unix.aliblwip4unix.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

Page 16: Implementation LAN91c111-NE driver on  Altera cyclone NIOS  SoC development board

第 16 /28 頁

demodemo

A stander socket program

( tcp_sender.c )

Linux

Cyclone

A lwip program(tcp_receiver.c)

Page 17: Implementation LAN91c111-NE driver on  Altera cyclone NIOS  SoC development board

第 17 /28 頁

How to port lwIP to any platformHow 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.

Page 18: Implementation LAN91c111-NE driver on  Altera cyclone NIOS  SoC development board

第 18 /28 頁

sys_archsys_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.

Page 19: Implementation LAN91c111-NE driver on  Altera cyclone NIOS  SoC development board

第 19 /28 頁

Get a lot of problemGet 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

Page 20: Implementation LAN91c111-NE driver on  Altera cyclone NIOS  SoC development board

第 20 /28 頁

ConclusionConclusion

• 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.