安装EC20调试环境

本文详细指导如何在Ubuntu 14.04环境下安装ADB,解决设备连接问题,包括安装ADB和ADBD、修改Linux内核以支持特定设备、配置USB驱动和内核模块,确保USB网络功能。适合Android开发者进行设备调试。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

此文档基于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命令查看异同,如图

  • 插入设备前
    USB设备无

  • 插入设备后
    在这里插入图片描述

可看出增加一个设备,且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 修改内核配置

  1. 进入内核根目录

  2. 设置环境变量,并导入defconfig。

    export ARCH=arm
    export CROSS_COMPILE=arm-none-linux-gnueabi-
    /* 进入arch/arm/configs目录查看有的配置,挑选一个 */
    make bcm_defconfig    
    
  3. 编译内核,并使能CONFIG_USB_SERIAL_OPTION

    make menuconfig
    [*] Device Drivers →
    	[*] USB Support →
    		[*] USB Serial Converter support →
    			[*] USB driver for GSM and CDMA modems
    

5. 构建和装载作为给PClinux内核模块的驱动

  1. 进入内核目录

  2. 构建驱动模块

    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
    
  3. 装载驱动并重启

    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执行即可使用
成功

### EC20模块串口调试方法 #### 1. 硬件连接配置 在进行EC20模块的串口调试之前,需确认硬件连接是否正确。根据相关资料[^3],EC20模块上电后的默认波特率为115200 bps。因此,在设置串口通信参数时,默认波特率应设定为115200 bps。 以下是常见的硬件连接方式: - **TXD (Pin 7)** 连接到主机设备的接收端(RXD)。 - **RXD (Pin 8)** 连接到主机设备的发送端(TXD)。 - **GND (Pin 9)** 需要与主机设备的地线相连以确保信号稳定。 #### 2. 软件环境准备 为了实现对EC20模块的有效控制,通常通过AT指令与其交互。以下是一个简单的Python代码示例,用于初始化并测试EC20模块的串口通信: ```python import serial def initialize_ec20(port='/dev/ttyUSB0', baudrate=115200, timeout=1): try: ser = serial.Serial(port, baudrate, timeout=timeout) if not ser.is_open: ser.open() # 发送基本的AT命令来验证模块状态 ser.write(b'AT\r\n') response = ser.readlines() for line in response: print(line.decode('utf-8').strip()) ser.close() except Exception as e: print(f"Error occurred: {e}") initialize_ec20() ``` 此脚本使用`pyserial`库创建了一个串口对象,并向EC20模块发送了最基本的`AT`命令以检测其响应情况。如果返回的结果包含字符串`OK`,则表明模块正常工作[^2]。 #### 3. 常见AT指令及其用途 基于官方文档中的描述[^2],一些常用的AT指令可以帮助开发者完成特定的任务。例如: - `AT+QGPS`: 启动或停止GNSS定位服务。 - `AT+COPS?`: 查询当前网络运营商信息。 - `AT+CGATT?`: 检查是否已附着到蜂窝数据网络。 每条指令的具体语法以及可能的返回值都可以从官方的手册中找到详细的解释。 #### 4. 错误排查技巧 当遇到无法成功建立通信的情况时,可以按照下列建议逐步排除问题根源: - 确认所使用的串口号无误; - 尝试调整波特率至其他常见标准(如9600bps),再重新尝试连接; - 使用专门的串口工具软件(像SecureCRT或者Putty),手动输入简单AT命令观察反馈结果。 --- ###
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值