本帖最后由 qq280572 于 2017-2-17 13:49 编辑
开发环境: 开发板: Raspberry Pi2 / BCM2836 内核:Linux 3.6.35 按照一般移植要素,有如下几个步骤: 1. 确定硬件连接方式; 2,加入芯片驱动,修改相关接口函数; 3,编译配置网卡信息,测试。 4,开通上层调用功能。 5,总结相关调试问题。
1. 硬件连线方式
开发板Raspberry Pi2 / BCM2836------ DM9051NP CSPI2_CLK ---> SCK CSPI2_MISO <--- SO CSPI2_MOSI ---> SI CSPI_CS ---> CS INT <--- INT VCC 3.3v --> VCC GND --> GND
demo板照片如下:
【DM9051芯片驱动+硬件资料】
网盘资料: http://pan.baidu.com/s/1qYrW7W4
【驱动】 /* drivers/net/dm9051.c (dm9r.c ) * * Copyright 2014 Davicom Semiconductor,Inc. * http://www.davicom.com.tw * 2014/03/11 Joseph CHANG v1.0 Create * 2014/05/05 Joseph CHANG v1.01 Start from Basic functions * 2015/06/08 Joseph CHANG v1.02 Formal naming (Poll version) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * Ver: Step1.2p1: Use "db->ret95" to trace bug track.. (20151127) * Ver: Step1.3 dma: mt_ DMA.. (20151203) * Ver: Step1.3p1 DMA3_PNs design for platforms' config (20151223) * Ver: 3p6s * Ver: 3p6ss * Ver: 3p11sss (kmalloc re-placement) * Remove: drwbuff_u8() * Ver: V1.1 * Ver: V1.2 Default as static 'dm9051.o' */
... 添加步骤:
1.做成 .ko 或 .o (整合在 zImage里面) 都可~
2. SPI master:
到 arch/arm/ 找到你的 board device directory
( 例如: 我用 s5pv210 , 为 mach-s5pv210 )
在 此目录裡找到board source file
(例如: 我用 s5pv210 , 为 mach-mini210.c )
在此档案裡, 改 (此例为SPI0, 若为SPI1 则
保留SPI0 這组, 改用下一组 .bus_num = 1 者, )
( 註:依此方式, 如各個平台会略有差异!)
static struct spi_board_info s3c_spi_devs[] __initdata = {
{
.modalias = "dm9051", // .modalias= "spidev", /* MMC SPI */
.mode = SPI_MODE_0,
.max_speed_hz = 33000000, //[SPEC. MAX]
/* Connected to SPI-0 as 1st Slave */
.bus_num = 0,
.chip_select = 0,
.controller_data = &smdk_spi0_csi[SMDK_MMCSPI_CS],
},
..
}
3. 增添 DM9051 Linux driver 到drivers/net/ , 3.1 Add source to the kernel $ cp dm9051.h drivers/net/ethernet/davicom/ $ cp dm9051.c drivers/net/ethernet/davicom/ 3.2 Modify source in the kernel $ vi drivers/net/ethernet/Makefile +obj-$(CONFIG_DM9051) += davicom/ $ vi drivers/net/ethernet/davicom/Makefile +obj-$(CONFIG_DM9051) += dm9051.o $ vi drivers/net/ethernet/davicom/Kconfig +config DM9051 + tristate ”DM9051 support” + depends on ARM || BLACKFIN || MIPS + select CRC32 + select MII + ---help--- + Support for DM90451 chipset. $ vi arch/arm/mach-bcm2709/bcm2709.c - .modalias = “spidev”, - .max_speed_hz = 500000, + .modalias = “dm9051”, + .max_speed_hz = 20000000,
做成 .ko 或 .o (整合在 zImage里面)
( 註:比较新的Linux核心, 路径变更为 drivers/net/ethernet/davicom/ !)
完成以上即成~
最后测试底层ping路由,ping外网均ok;
再把上层以太网设置栏选项调出来即可。
【可能会遇到的问题】
1,添加驱动后,无法查询到以太网设备;
》》检测SPI接线有无问题,关于宏定义也检查下。
2,网卡无法自动UP,每次重启都需要手动UP一次;
》》vim /etc/sysconfig/network-script/ifeth0 中的ONBOOT=NO修改为ONBOOT=YES
》》不然就写个sh脚本->/data/,ifconfig eth0 up,dhcp up等。
》》修改init.mt6735.rc让插入网卡就自动获取ip:
device/mediatek/mt6735/init.mt6735.rc
#DHCPCD
# eth0 by eric.wang
service dhcpcd_eth0 /system/bin/dhcpcd -ABKL
class main
disabled
oneshot
# IP Renew
# # eth0 by eric.wang
service iprenew_eth0 /system/bin/dhcpcd -n
class main
disabled
oneshot
3,底层能ping通,浏览器却无法访问;
》》检查dns获取情况,一般能ping IP dns是没问题的;
》》对比安卓版本之间的区别,web相关调用底层的地方是否有改动;
》》修改以太网权限文件:
PRODUCT_COPY_FILES += frameworks/native/data/etc/android.hardware.ethernet.xml:system/etc/permissions/android.hardware.ethernet.xml
然后,配置config.xml
<string-array translatable="false" name="networkAttributes">
<item>"ethernet,9,9,1,-1,true"</item>
<item>"wifi,1,1,2,-1,true"</item>
4,SPI休眠、速率等问题;
》》有些平台SPI会休眠导致以太网挂掉,建议休眠功能关闭;
》》速率来说,一般SPI可以设置0-80Mhz的时钟速率,以太网速率也会随之提升; 》》注: DM9051 SPI时钟速率可達 50MHz.
》》网口速率一般能到5-10Mbps。
5, Android4.4 以太网和DHCP启动过程介绍(转) 如还有发现更多问题,后面我会再更新上来,谢谢。
*DM9051NP芯片介紹,來自台灣聯傑國際/Davicom官网: 主芯片開發板: Raspberry Pi2 / BCM2836 SPI clock is 20 MHz, The TX/RX performance: The receive performance test by: # iperf –s We get the result RX 8.52 mbps The send performance test by: # iperf –c $IP (Note: $IP is the test opposite partner’s IP address) We get the result TX 8.65 mbps
|