使能客户所需串口驱动(例如ch340)修改/kernel/arch/arm64/configs/rockchip_defconfig文件,添加CONFIG_USB_SERIAL_CH341=y将ch340驱动编译进内核 android固定USB串口设备端口号采用打补丁的方式修改/kernel/drivers/usb/serial/usb-serial.c文件。 参考链接:https://wenku.baidu.com/view/c6a00d1240323968011ca300a6c30c225901f02b.html 通过USB设备名去识别USB转串口插入的哪个U口,再根据不同的U口分配一个不同的节点。 static int allocate_minors(struct usb_serial *serial, int num_ports) { struct usb_serial_port *port; unsigned int i, j; int minor; dev_dbg(&serial->inte**ce->dev, "%s %d\n", __func__, num_ports); mutex_lock(&table_lock); for (i = 0; i < num_ports; ++i) { port = serial->port[i]; minor = idr_alloc(&serial_minors, port, 0, 0, GFP_KERNEL); //固定USB转串口设备名 if(!strcmp(dev_name,"5-1")) { minor=1; } else if(!strcmp(dev_name,"7-1.1")) { minor=2; } else if(!strcmp(dev_name,"7-1.2")) { minor=3; } if (minor < 0) goto error; port->minor = minor; port->port_number = i; } serial->minors_reserved = 1; mutex_unlock(&table_lock); return 0; error: /* unwind the already allocated minors */ for (j = 0; j < i; ++j) idr_remove(&serial_minors, serial->port[j]->minor); mutex_unlock(&table_lock); return minor; }
static int usb_serial_probe(struct usb_inte**ce *inte**ce, const struct usb_device_id *id) { ...内容省略... if (allocate_minors(serial, num_ports)) { 替换为 if (allocate_minors(serial, num_ports,dev_name(&port->serial->dev->dev))) { dev_err(ddev, "No more free serial minor numbers\n"); goto probe_error; } ...内容省略... } 配置环境变量 source build/envsetup.sh lunch rk3399_all-userdebug 单独编译内核文件。 ./mklinux.sh 打包镜像烧写文件。 ./mkimage.sh 将/kernel/rockdev/Image-rk3399_all/boot.img分区烧写到开发板。 |
|小黑屋| 飞凌嵌入式 ( 冀ICP备12004394号-1 )
GMT+8, 2024-11-22 11:06
Powered by Discuz! X3.4
© 2001-2013 Comsenz Inc.