此文档基于ubuntu14.04 内核4.4.0.148
使用ADB
# Command basic format:
sudo adb push <local path> <module path>
sudo adb pull <module path> <local path>
# for example:
adb push ~/ql-ol-sdk/ql-ol-extsdk/example/helloWorld/hellolworld /usrdata
adb pull /home/test/file .
1. 安装必备软件
安装ADB和ADBD
sudo apt-get update
sudo apt-get install android-tools-adb android-tools-adbd
若安装失败,使用以下命令
sudo add-apt-repository ppa:nilarimogard/webupd8
sudo apt-get update
sudo apt-get install android-tools-adb android-tools-adbd
成功后使用 adb version命令出现如下提示
2. 连接
若使用虚拟机,则将USB设备映射至虚拟机内,后使用lsusb查看usb设备,若不确定哪个是,可拔除设备后使用lsusb命令,再插入设备后使用lsusb命令查看异同,如图
-
插入设备前
-
插入设备后
可看出增加一个设备,且ID号为0x2c7c
则使用如下命令,将设备ID写入配置文件
echo 0x2c7c > ~/.android/adb_usb.ini
3. 列出ADB并链接
sudo adb kill-server
sudo adb devices #列出设备
- 若成功链接则可使用adb shell连接设备,如图
- 若不成功,如图,设备为空,则可能是linux驱动不正确,参考4
4. 设备空
重新安装linux设备驱动,使用uname -r查看对应linux内核版本,下载对应版本linux源码
获取linux_kernel
sudo wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.4.148.tar.xz
sudo xz -d linux-4.4.148.tar.xz # 解压
sudo tar -xvf linux-4.4.148.tar
cd linux-4.4.148 #进入到目录linux-4.4.148
4.1 修改内核文件
4.1.1 Add VID and PID
打开[KERNEL]/drivers/usb/serial/option.c 文件
static const struct usb_device_id option_ids[] =
{
#if 1 //Added by Quectel
{ USB_DEVICE(0x05C6, 0x9090) }, /* Quectel UC15 */
{ USB_DEVICE(0x05C6, 0x9003) }, /* Quectel UC20 */
{ USB_DEVICE(0x2C7C, 0x0125) }, /* Quectel EC25 */
{ USB_DEVICE(0x2C7C, 0x0121) }, /* Quectel EC21 */
{ USB_DEVICE(0x05C6, 0x9215) }, /* Quectel EC20 */
{ USB_DEVICE(0x2C7C, 0x0191) }, /* Quectel EG91 */
{ USB_DEVICE(0x2C7C, 0x0195) }, /* Quectel EG95 */
{ USB_DEVICE(0x2C7C, 0x0306) }, /* Quectel EG06/EP06/EM06 */
{ USB_DEVICE(0x2C7C, 0x0512) }, /* Quectel EG12/EP12/EM12/EG16/EG18 */
{ USB_DEVICE(0x2C7C, 0x0296) }, /* Quectel BG96 */
{ USB_DEVICE(0x2C7C, 0x0435) }, /* Quectel AG35 */
#endif
}
如果你的芯片是 EC20 还要删除这几个冲突的东西
// File: [KERNEL]/drivers/usb/serial/qcserial.c
{USB_DEVICE(0x05c6, 0x9215)}, /* Acer Gobi 2000 Modem device (VP413) */
// File: [KERNEL]/drivers/net/usb/qmi_wwan.c
{QMI_GOBI_DEVICE(0x05c6, 0x9215)}, /* Acer Gobi 2000 Modem device (VP413) */
4.1.2 添加零包处理机制
File: [KERNEL]/drivers/usb/serial/usb_wwan.c 中添加如下
static struct urb *usb_wwan_setup_urb(struct usb_serial *serial, int endpoint,
int dir, void *ctx, char *buf, int len,void (*callback) (struct urb *))
{
//……
usb_fill_bulk_urb(urb, serial->dev,
usb_sndbulkpipe(serial->dev, endpoint) | dir,
buf, len, callback, ctx);
#if 1 //Added by Quectel for zero packet
if (dir == USB_DIR_OUT)
{
struct usb_device_descriptor *desc = &serial->dev->descriptor;
if (desc->idVendor == cpu_to_le16(0x05C6) && desc->idProduct == cpu_to_le16(0x9090))
urb->transfer_flags |= URB_ZERO_PACKET;
if (desc->idVendor == cpu_to_le16(0x05C6) && desc->idProduct == cpu_to_le16(0x9003))
urb->transfer_flags |= URB_ZERO_PACKET;
if (desc->idVendor == cpu_to_le16(0x05C6) && desc->idProduct == cpu_to_le16(0x9215))
urb->transfer_flags |= URB_ZERO_PACKET;
if (desc->idVendor == cpu_to_le16(0x2C7C))
urb->transfer_flags |= URB_ZERO_PACKET;
}
#endif
return urb;
}
4.1.3 睡眠重启
File: [KERNEL]/drivers/usb/serial/option.c
static struct usb_serial_driver option_1port_device =
{
//……
#ifdef CONFIG_PM
.suspend = usb_wwan_suspend,
.resume = usb_wwan_resume,
#if 1 //Added by Quectel
.reset_resume = usb_wwan_resume,
#endif
#endif
};
4.1.4 使用 GobiNet 拨号
还要配置这个File: [KERNEL]/drivers/usb/serial/option.c
static int option_probe(struct usb_serial *serial, const struct usb_device_id *id)
{
struct usb_wwan_intf_private *data;
//......
#if 1 //Added by Quectel
//Quectel UC20's interface 4 can be used as USB Network device
if (serial->dev->descriptor.idVendor == cpu_to_le16(0x05C6)
&& serial->dev->descriptor.idProduct == cpu_to_le16(0x9003)
&& serial->interface->cur_altsetting->desc.bInterfaceNumber >= 4)
return -ENODEV;
//Quectel EC20's interface 4 can be used as USB Network device
if (serial->dev->descriptor.idVendor == cpu_to_le16(0x05C6)
&& serial->dev->descriptor.idProduct == cpu_to_le16(0x9215)
&& serial->interface->cur_altsetting->desc.bInterfaceNumber >= 4)
return -ENODEV;
//Quectel EC25&EC21&EC20 R2.0&EG91&EG95&EG06&EP06&EM06&BG96's interface 4 can be used as USB Network device
if (serial->dev->descriptor.idVendor == cpu_to_le16(0x2C7C)
&& serial->interface->cur_altsetting->desc.bInterfaceNumber >= 4)
return -ENODEV;
#endif
/* Store device id so we can use it during attach. */
usb_set_serial_data(serial, (void *)id);
return 0;
}
4.2 修改内核配置
-
进入内核根目录
-
设置环境变量,并导入defconfig。
export ARCH=arm export CROSS_COMPILE=arm-none-linux-gnueabi- /* 进入arch/arm/configs目录查看有的配置,挑选一个 */ make bcm_defconfig
-
编译内核,并使能CONFIG_USB_SERIAL_OPTION
make menuconfig [*] Device Drivers → [*] USB Support → [*] USB Serial Converter support → [*] USB driver for GSM and CDMA modems
5. 构建和装载作为给PClinux内核模块的驱动
-
进入内核目录
-
构建驱动模块
sudo make -C /lib/modules/`uname -r`/build M=`pwd`/drivers/usb/serial obj-m=option.o modules sudo make -C /lib/modules/`uname -r`/build M=`pwd`/drivers/usb/serial obj-m=usb_wwan.o modules sudo make -C /lib/modules/`uname -r`/build M=`pwd`/drivers/usb/serial obj-m=qcserial.o modules
-
装载驱动并重启
sudo cp drivers/usb/serial/option.ko /lib/modules/`uname -r`/kernel/drivers/usb/serial sudo cp drivers/usb/serial/usb_wwan.ko /lib/modules/`uname -r`/kernel/drivers/usb/serial sudo cp drivers/usb/serial/qcserial.ko /lib/modules/`uname -r`/kernel/drivers/usb/serial sudo depmod sudo reboot
以上步骤执行后从步骤2执行即可使用