usb_modeswitch移植到海思3531D平台(华为E8372h-155)

usb_modeswitch移植到Hi3531D平台

PC宿主机:ubuntu 16.04LTS

板子处理器:Hi3531DV100

4G Dongle:华为随行WiFi 2mini (E8372h-155)

linux内核:3.18

 

移植简介说明:

该文档详细说明了HUEWEI 4G Dongle(E8372h-155) 在海思Hi3531D上的移植过程包括以下内容

  1. libusb-1.0.6.tar.gz的编译配置//这个是usb_modeswitch生成所需要的依赖库文件。
  2. usb-modeswitch-data-20121109.tar.gz的编译配置//这个是为了支持各个网卡所需要的设备参数文件(可以查找相应的设备的测试文件)可以参考我自己写的配置文件格式
  3. usb-modeswitch-2.2.1.tar.gz的编译配置//这个是生成usb_modeswitch程序的源代码

http://www.draisberghof.de/usb_modeswitch/

 

 

内核准备配置

 

 

重新编译

    make ARCH=arm CROSS_COMPILE=arm-hisiv600-linux- menuconfig

    make ARCH=arm CROSS_COMPILE=arm-hisiv600-linux- uImage

 

 

 

 

 

 

libusb移植总结

总结这个阶段中移植libusb到嵌入平台的过程和问题:

libusb提供了一套相对能够屏蔽不同linux版本,减少不同平台的驱动移植困恼的工具,工具提供了1.0版本和0.1版本(旧方式),开发者不建议使用0.1了。本次使用的1.0版本开发.

1.包含文件和下载:

1.0版本有libusb和liusb-compat两个模块,后者用来扩展支持0.1.

我使用的是libusb-1.0.6和liusb-compat-0.1.5。

2.交叉编译:

先编译libusb-1.0.6

解压后在libusb-1.0.6执行mkdir install:

注意config时要添加–disable-udev,否则运行时和编译compat都会出现问题。

<1>./configure--build=i686-linux--host=arm-hisiv600-linux-gnueabi--prefix=/home/wrt/work/libusb-1.0.6/install--disable-shared--enable-static--disable-udev(发现没有设置交叉编译工具的路径编译有问题)

***********************************************************************************

./configure --host=arm-linux--prefix=/home/wrt/testusb/libusb-1.0.6/install CC=/usr/local/arm/arm-hisiv600-linux/bin/arm-hisiv600-linux-gnueabi-gcc//按照这个 编译正常

 

./configure --host=arm-hisiv500-linux-uclibcgnueabi --prefix=/home/wrt/R8_4GDongle/libusb-1.0.6/install --disable-udev

 

  1. –build=i686-linux表示该软件在x86平台被编译
  2. –host=arm-linux表示该软件编译完成后在arm平台上运行
  3. –prefix后面为软件安装目录。
  4. CC=,CXX等于指定了交叉编译使用的C,C++交叉编译器

 

//<2>exportPATH=/usr/local/arm/arm-hisiv600-linux/arm-hisiv600-linux/bin:$PATH

<3>make

<4>make install

设置PKG_CONFIG_PATH环境变量,使后面的编译能够顺利找到libusb库

  1. 设置环境变量export PKG_CONFIG_PATH=/home/wrt/testusb/libusb-1.0.6/install/lib/pkgconfig:$PKG_CONFIG_PATH 
  2. 查看设置是否正确echo $PKG_CONFIG_PATH

 

再编译liusb-compat-0.1.4

compat依赖于libusb编译结果,config需要指明libusb的install目录

<1>解压后在liusb-compat-0.1.4执行mkdir install:

<2>./configure --build=i686-linux --host=arm-hisiv600-linux-gnueabi --prefix=/home/wrt/testusb/libusb-compat-0.1.4/install

./configure --host=arm-hisiv500-linux-uclibcgnueabi --prefix=/home/wrt/R8_4GDongle/libusb-compat-0.1.4/install

在编译的过程中发现添加—build编译选项 编译不成功 所以去掉这个选项

//<3>exportPKG_CONFIG_PATH=/home/wrt/work/libusb-compat-//0.1.4/install/lib/pkgconfig

<4>make

<5>make install

把对应的so文件放到文件系统的/usr/lib目录就可以了。

编译usb-modeswitch

进入解压目录,cd usb-modeswitch-2.2.1

该文件夹没有提供,./configure工具,因此需要我们自己手动对Makefile文件进行修改。以下几项需要修改。

第一行增加ExportPKG_CONFIG_PATH=/home/wrt/R8_4GDongle/libusb-1.0.6/install/lib/pkgconfig

CC = arm-hisiv600-linux-gnueabi-gcc//使用交叉编译工具

INCLUDEDIR  = /home/wrt/libusb-1.0.6/install/include

LDFLAGS     = /home/wrt/libusb-1.0.6/install/lib

下面这一行是编译命令,添加-I、-L选项

$(CC) -o $(PROG) $(OBJS) $(CFLAGS) $(LIBS) $(LDFLAGS)

$(CC) -o $(PROG) $(OBJS) $(CFLAGS) $(LIBS) -I $(INCLUDEDIR) -L $(LDFLAGS) -static -pthread

下面可以通过make编译文件,但是在编译之前,需要修改一个环境变量。

exportPKG_CONFIG_PATH=/home/wrt/work/libusb-compat-0.1.4/install/lib/pkgconfig   //  修改环境变量

 

 

 

make  // 编译

make install

 

 

移植到板子上注意的事项:

usb_modeswitch.conf的配置

#weiNewMode=1

NoDriverLoading=1 Configuration for the usb_modeswitch package, a mode switching tool for

# USB devices providing multiple states or modes

#

# Evaluated by the wrapper script /usr/sbin/usb_modeswitch_dispatcher

#

# To enable an option, set it to "1", "yes" or "true" (case doesn't matter)

# Everything else counts as "disable"

 

 

# Disable automatic mode switching globally (e.g. to access the original

# install storage)

 

DisableSwitching=0

 

 

# Enable logging (results in a extensive report file in /var/log, named

# "usb_modeswitch_<interface-name>" and probably others

 

EnableLogging=0

 

 

# Optional increase of "delay_use" for the usb-storage driver; there are hints

# that a recent kernel default change to 1 sec. may lead to problems, particu-

# larly with USB 3.0 ports. Set this to at least 3 (seconds) in that case.

# Does nothing if the current system value is same or higher

 

#SetStorageDelay=4

 

# Huawei,E8372h-155

HuaweiAltModeGlobal=0

 

DefaultVendor= 0x12d1

DefaultProduct= 0x1f01

 

TargetVendor= 0x12d1

TargetProduct= 0x14dc

HuaweiNewMode=1

NoDriverLoading=1

EnableLogging=1

DetechStorageOnly=0

CheckSuccess=4

 

40-usb_modeswitch.rules文件末尾添加

ATTR{idVendor}=="12d1",ATTR{idProduct}=="1f01", RUN+="/usr/sbin/usb_modeswitch -W -c /home/app/usb_modeswitch.conf"

 

usb_modeswitch放在 use/sbin目录下

 

 

40-usb_modeswitch.rules该文件放在/etc/udev/rules.d目录下最后添加相应设备的执行。

ATTR{idVendor}=="12d1", ATTR{idProduct}=="1f01", RUN+="/usr/sbin/usb_modeswitch -w -c /home/usb_modeswitch.conf"

路径添加::::::

或者使用usb-modeswitch-data-20150115.tar中对应设备的文件(例如

华为E8372h-155的文件为12d1:1f01)执行下列命令-----

./usb_modeswitch -W -c 12d1\:1f01 &

 

参考:./usb_modeswitch -W -c 12d1\:1446 &

https://blog.csdn.net/jackjones_008/article/details/41750445

 

https://www.cnblogs.com/aaronLinux/p/7159660.html

 

https://www.cnblogs.com/gexin/p/7655056.html

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值