Chinaunix首页 | 论坛 | 博客
  • 博客访问: 276935
  • 博文数量: 95
  • 博客积分: 2047
  • 博客等级: 大尉
  • 技术积分: 1022
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-14 16:18
文章分类

全部博文(95)

文章存档

2013年(1)

2011年(94)

我的朋友

分类: 嵌入式

2011-08-14 19:42:58

以前写过一个将2.6.24内核的DM9000AE驱动移植到2.6.27内核的文章

http://hi.baidu.com/aokikyon/blog/item/8ca56643a902f8189213c6f3.html

现在Android的内核既然升级到了2.6.29,还得从头将这些驱动再porting一遍,当然最痛苦又是这个DM9000驱动了。

还好,总体看下来改变不多。主要是2.6.29内核的netdevice.h中的net_device结构体有所调整,将(void*)priv给删去了,所以编译时会出现以下错误:

drivers/net/dm9000_con201.c: In function 'dm9000_open':
drivers/net/dm9000_con201.c:687: error: 'struct net_device' has no member named 'priv'
drivers/net/dm9000_con201.c: In function 'dm9000_init_dm9000':
drivers/net/dm9000_con201.c:722: error: 'struct net_device' has no member named 'priv'
drivers/net/dm9000_con201.c: In function 'dm9000_start_xmit':
drivers/net/dm9000_con201.c:765: error: 'struct net_device' has no member named 'priv'
drivers/net/dm9000_con201.c: In function 'dm9000_shutdown':
drivers/net/dm9000_con201.c:809: error: 'struct net_device' has no member named 'priv'
drivers/net/dm9000_con201.c: In function 'dm9000_stop':
drivers/net/dm9000_con201.c:825: error: 'struct net_device' has no member named 'priv'
drivers/net/dm9000_con201.c: In function 'dm9000_interrupt':
drivers/net/dm9000_con201.c:885: error: 'struct net_device' has no member named 'priv'
drivers/net/dm9000_con201.c: In function 'dm9000_timer':
drivers/net/dm9000_con201.c:925: error: 'struct net_device' has no member named 'priv'
drivers/net/dm9000_con201.c: In function 'dm9000_rx':
drivers/net/dm9000_con201.c:947: error: 'struct net_device' has no member named 'priv'
drivers/net/dm9000_con201.c: In function 'dm9000_hash_table':
drivers/net/dm9000_con201.c:1109: error: 'struct net_device' has no member named 'priv'
drivers/net/dm9000_con201.c: In function 'dm9000_phy_read':
drivers/net/dm9000_con201.c:1152: error: 'struct net_device' has no member named 'priv'
drivers/net/dm9000_con201.c: In function 'dm9000_phy_write':
drivers/net/dm9000_con201.c:1186: error: 'struct net_device' has no member named 'priv'
drivers/net/dm9000_con201.c: In function 'dm9000_drv_resume':
drivers/net/dm9000_con201.c:1230: error: 'struct net_device' has no member named 'priv'
drivers/net/dm9000_con201.c: In function 'dm9000_drv_remove':
drivers/net/dm9000_con201.c:1252: error: 'struct net_device' has no member named 'priv'
make[2]: *** [drivers/net/dm9000_con201.o] 错误 1
make[1]: *** [drivers/net] 错误 2
make: *** [drivers] 错误 2
[kyon@SEP4020 6410-android-kernel-2.6.29]$

刚开始偷懒,手动在/includ/linux/netdevice.h文件中添加了这个(void*)priv;

我知道这绝对不是一个好办法,果然内核可耻的崩溃了:

dm9000 Ethernet Driver
dm9000_probe()dm9000_probe2()<1>Unable to handle kernel NULL pointer dereference at virtual address 00000000
pgd = c0004000
[00000000] *pgd=00000000
Internal error: Oops: 805 [#1]
Modules linked in:
CPU: 0    Not tainted (2.6.29 #26)
PC is at __memzero+0x24/0x80
LR is at 0x0
pc : []    lr : [<00000000>]    psr: 20000013
sp : c781be0c ip : 00000000 fp : c781be5c
r10: c7833800 r9 : c02d3248 r8 : 00000000
r7 : c78ad420 r6 : c02d3878 r5 : c02d3250 r4 : c02d3250
r3 : 00000000 r2 : 00000000 r1 : 000000b0 r0 : 00000000
Flags: nzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel
Control: 00c5387d Table: 50004008 DAC: 00000017

PC: 0xc012efe4:

静下心来,仔细想想,2.6.29内核也提供了DM9000.c文件,肯定是适合内核的,因此安装dm9000.c文件修改肯定可以。果然,对比后就发现了改动之处。

比如

line932

//board_info_t *db = (board_info_t *) dev->priv;
board_info_t *db = netdev_priv(dev);

line1162

//board_info_t *db = (board_info_t *) dev->priv;
board_info_t *db = netdev_priv(dev);

line1264

//dm9000_release_board(pdev, netdev_priv(dev));
dm9000_release_board(pdev, (board_info_t *) netdev_priv(ndev));

我就不一一列举了,按照错误行对应修改即可。

附启动过程

=================================================================

Starting kernel ...

Uncompressing Linux................................................................................................. done, booting the kernel.
Linux version 2.6.29 (kyon@SEP4020.Linux) (gcc version 4.3.2 (Sourcery G++ Lite 2008q3-72) ) #28 Wed Nov 25 10:19:48 CST 2009
CPU: ARMv6-compatible processor [410fb766] revision 6 (ARMv7), cr=00c5387f
CPU: VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
Machine: SMDK6410
Memory policy: ECC disabled, Data cache writeback
CPU S3C6410 (id 0x36410101)
S3C24XX Clocks, (c) 2004 Simtec Electronics
S3C64XX: PLL settings, A=666000000, M=532000000, E=24000000
S3C64XX: HCLK2=266000000, HCLK=133000000, PCLK=66500000
mout_apll: source is fout_apll (1), rate is 666000000
mout_epll: source is fout_epll (1), rate is 24000000
mout_mpll: source is mpll (1), rate is 532000000
mmc_bus: source is mout_epll (0), rate is 24000000
mmc_bus: source is mout_epll (0), rate is 24000000
mmc_bus: source is mout_epll (0), rate is 24000000
usb-bus-host: source is clk_48m (0), rate is 48000000
uclk1: source is dout_mpll (1), rate is 66500000
spi-bus: source is mout_epll (0), rate is 24000000
spi-bus: source is mout_epll (0), rate is 24000000
audio-bus: source is mout_epll (0), rate is 24000000
audio-bus: source is mout_epll (0), rate is 24000000
irda-bus: source is mout_epll (0), rate is 24000000
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 32512
Kernel command line: /dev/nfs rw nfsroot=192.168.0.3:/nfs ip=192.168.0.2:192.168.0.3:255.255.255.0 console=ttySAC0,115200 init=/init
PID hash table entries: 512 (order: 9, 2048 bytes)
Console: colour dummy device 80x30
console [ttySAC0] enabled
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
Memory: 128MB = 128MB total
Memory: 126108KB available (2708K code, 776K data, 132K init)
SLUB: Genslabs=10, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
Calibrating delay loop... 665.19 BogoMIPS (lpj=3325952)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
net_namespace: 668 bytes
NET: Registered protocol family 16
S3C6410: Initialising architecture
S3C DMA-pl080 Controller Driver, (c) 2006-2007 Samsung Electronics
Total 32 DMA channels will be initialized.
bio: create slab at 0
SCSI subsystem initialized
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 4096 (order: 3, 32768 bytes)
TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
TCP reno registered
NET: Registered protocol family 1
NetWinder Floating Point Emulator V0.97 (double precision)
ashmem: initialized
msgmni has been set to 246
alg: No test for stdrng (krng)
io scheduler noop registered
io scheduler anticipatory registered
io scheduler deadline registered
io scheduler cfq registered (default)
S3C_LCD clock got enabled :: 133.000 Mhz
LCD TYPE :: LTE480WV will be initialized
Window[0] - FB1: map_video_memory: clear ffc00000:0007f800
            FB1: map_video_memory: dma=57900000 cpu=ffc00000 size=0007f800
Window[0] - FB2: map_video_memory: clear ffc3fc00:0003fc00
            FB2: map_video_memory: dma=5793fc00 cpu=ffc3fc00 size=0003fc00
Console: switching to colour frame buffer device 60x34
fb0: s3cfb frame buffer device
s3c6400-uart.0: s3c2410_serial0 at MMIO 0x7f005000 (irq = 16) is a S3C6400/10
s3c6400-uart.1: s3c2410_serial1 at MMIO 0x7f005400 (irq = 20) is a S3C6400/10
dm9000 Ethernet Driver
dm9000_probe()eth%d: con201 Invalid ethernet MAC address. using default config, Please set using ifconfig
eth0 (dm9000_con201): not using net_device_ops yet
eth0: dm9000 at f7200300,f7200304 IRQ 108 MAC: 00:e0:4a:bc:15:e7
Driver 'sd' needs updating - please use bus_type methods
S3C NAND Driver, (c) 2008 Samsung Electronics
S3C NAND Driver is using software ECC.
NAND device: Manufacturer ID: 0xec, Chip ID: 0xda (Samsung NAND 256MiB 3,3V 8-bit)
Creating 4 MTD partitions on "NAND 256MiB 3,3V 8-bit":
0x000000000000-0x000000100000 : "Bootloader"
0x000000100000-0x000000300000 : "Kernel"
0x000000300000-0x000008300000 : "File System"
0x000008300000-0x000010000000 : "User"
mice: PS/2 mouse device common for all mice
S3C Touchscreen driver, (c) 2008 Samsung Electronics
S3C TouchScreen got loaded successfully : 12 bits
input: S3C TouchScreen as /class/input/input0
logger: created 64K log 'log_main'
logger: created 256K log 'log_events'
logger: created 64K log 'log_radio'
TCP cubic registered
NET: Registered protocol family 17
NET: Registered protocol family 15
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
eth0: link up, 100Mbps, full-duplex, lpa 0x41E1
IP-Config: Guessing netmask 255.255.255.0
IP-Config: Gateway not on directly connected network.
Looking up port of RPC 100003/2 on 192.168.0.3
Looking up port of RPC 100005/1 on 192.168.0.3
VFS: Mounted root (nfs filesystem) on device 0:11.
Freeing init memory: 132K
Warning: unable to open an initial console.
init: cannot open '/initlogo.rle'
sh: can't access tty; job control turned off
# warning: `rild' uses 32-bit capabilities (legacy support in use)

# logcat
I/DEBUG   (   22): debuggerd: Jul 2 2009 15:03:21
I/vold    (   21): Android Volume Daemon version 2.0
E/vold    (   21): Unable to open '/sys/class/mmc_host' (m)
D/vold    (   21): Bootstrapping complete
D/AndroidRuntime(   24):
D/AndroidRuntime(   24): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<

阅读(1035) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~