蓝点工坊(http://www.bluedrum.cn) 创始人,App和嵌入式产品开发。同时也做相应培训和外包工作。 详细介绍 http://pan.baidu.com/s/1y2g88
全部博文(311)
分类: 嵌入式
2010-04-16 23:02:13
|
2) 把编译器改为ARM编译器
在Makefile的开始,加入(注意要与内核的编译器版本一致)
CC=/usr/local/3.4.1/bin/arm-linux-gcc
3) 注释Makefile中如下语句
#CFLAGS += $(DEBFLAGS)?
新版的OS已经不需要这个选项,否则会提示如下选项
scripts/Makefile.build:49: *** CFLAGS was changed in "/home/hxy/dm9601_drv/Makefile". Fix it to use EXTRA_CFLAGS. Stop.以下是改好的Makefile
# Comment/uncomment the following line to disable/enable debugging
#DEBUG = y
CC = /usr/local/arm/3.4.1/bin/arm-linux-gcc
# Add your debugging flag (or not) to CFLAGS
ifeq ($(DEBUG),y)
DEBFLAGS = -O -g # "-O" is needed to expand inlines
else
DEBFLAGS = -O2
endif
EXTRA_CFLAGS += $(DEBFLAGS) -I$(LDDINCDIR)
ifneq ($(KERNELRELEASE),)
# call from kernel build system
obj-m := dm9601.o
else
#KERNELDIR ?= /lib/modules/$(shell uname -r)/build
KERNELDIR ?= /kernel-2.6.13
PWD := $(shell pwd)
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) LDDINCDIR=$(PWD)/../include modules
endif
clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions
depend .depend dep:
$(CC) $(CFLAGS) -M *.c > .depend
ifeq (.depend,$(wildcard .depend))
include .depend
endif
|
1.插入USB网卡,如果网卡指示灯亮起表示开始工作,屏幕也会有相应提示
2.配置IP,因为开发板上已经有DM9000作为第一块网卡,所以这个DM9601将作为eth1来工作
ifconfig eth1 192.168.3.240
3.将其与网络其它3网段机器进行互ping,如果能互相PING通表示网卡完全工作正常
ping 192.168.3.147
config DM9601
tristate "DM9601 USB support"
depends on NET_ETHERNET
select CRC32
select MII
---help---
Support for DM9601 chipset.
A Davicom DM9601 USB Fast Ethernet driver for Linux.
|
obj-$(CONFIG_S2IO) += s2io.o obj-$(CONFIG_ARM) += arm/ |
5.1 移植要点
必须是支持eabi 的arm-linux-gcc编译,这里是用4.3.3
内核成功编译过一次.并可以被驱动源码目录的Makefile访问
5.2 源码分析
在2.6.31后,USB网卡整体源码被折分成两大块,一块是通用的usbnet操作.另一块是各产家自行的代码操作
dm9601的驱动包含两块源码 dm9601.c 和usbnet.c
|
只要加上固定的2.6的Makefile进行编写
# If KERNELRELEASE is defined, we've been invoked from the
# kernel build system and can use its language.
ifneq ($(KERNELRELEASE),)
obj-m := usbnet.o dm9601.o
# Otherwise we were called directly from the command
# line; invoke the kernel build system.
else
KERNELDIR ?= /2.6.30.4/linux-2.6.30.4
PWD := $(shell pwd)
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
clean:
rm -rf .*.cmd *.o *.mod.c *.ko .tmp_versions
endif
|
5.3 测试网卡
安装驱动
insmod usbnet.ko
insmod dm9601.ko
配置/测试网络
ifconfig eth1 192.168.3.107 up
使用ping 来测试网络正确性.