A40i-linux5.10-支持usb虚拟网卡 一、加载内核驱动 进入图形化配置界面 forlinx@ubuntu:~/work/OKA40i-linux-sdk$ ./build.sh menuconfig 按如下配置 Device Drivers ---> [ * ] USB support ---> <*> USB Gadget Support ---> [ * ] Ethernet Control Model (CDC ECM) [ * ] RNDIS Device Drivers ---> [ * ] USB support ---> <*> USB Gadget Support ---> USB Gadget precomposed configurations ---> <M> Ethernet Gadget (with CDC Ethernet support) [ * ] RNDIS support 二、修改驱动 如下为修改patch: OKA40i-linux-sdk/kernel diff --git a/linux-5.10/drivers/usb/gadget/function/u_ether.c b/linux-5.10/drivers/usb/gadget/function/u_ether.c old mode 100644 new mode 100755 index 64ef97ab9..45590e3ef --- a/linux-5.10/drivers/usb/gadget/function/u_ether.c +++ b/linux-5.10/drivers/usb/gadget/function/u_ether.c @@ -218,7 +218,11 @@ rx_submit(struct eth_dev *dev, struct usb_request *req, gfp_t gfp_flags) size = max_t(size_t, size, dev->port_usb->fixed_out_len); spin_unlock_irqrestore(&dev->lock, flags); - skb = __netdev_alloc_skb(dev->net, size + NET_IP_ALIGN, gfp_flags); + #ifdef CONFIG_USB_SUNXI_UDC0 + skb = netdev_alloc_skb_ip_align((struct net_device *)dev, size); + #else + skb = __netdev_alloc_skb((struct net_device *)dev, size + NET_IP_ALIGN, gfp_flags); + #endif if (skb == NULL) { DBG(dev, "no rx skb\n"); goto enomem; OKA40i-linux-sdk/bsp diff --git a/drivers/usb/sunxi_usb/udc/sunxi_udc.c b/drivers/usb/sunxi_usb/udc/sunxi_udc.c old mode 100644 new mode 100755 index 4972dbb..1402213 --- a/drivers/usb/sunxi_usb/udc/sunxi_udc.c +++ b/drivers/usb/sunxi_usb/udc/sunxi_udc.c @@ -2620,6 +2620,7 @@ static int sunxi_udc_queue(struct usb_ep *_ep, struct sunxi_udc *dev = NULL; unsigned long flags = 0; u8 old_ep_index = 0; + int ret; if (_ep == NULL || _req == NULL) { DMSG_PANIC("ERR: invalid argment\n"); @@ -2650,13 +2651,18 @@ static int sunxi_udc_queue(struct usb_ep *_ep, return -EINVAL; } - sunxi_udc_handle_unaligned_buf_start(ep, req); + //sunxi_udc_handle_unaligned_buf_start(ep, req); spin_lock_irqsave(&ep->dev->lock, flags); _req->status = -EINPROGRESS; _req->actual = 0; if (is_sunxi_udc_dma_capable(req, ep)) { spin_unlock_irqrestore(&ep->dev->lock, flags); + + ret = sunxi_udc_handle_unaligned_buf_start(ep, req); + if (ret) + return ret; + sunxi_udc_map_dma_buffer(req, dev, ep); spin_lock_irqsave(&ep->dev->lock, flags); } 三、其他修改 取消adb服务开机自启,有两种操作方式: 1. 开发板里操作 删除 /etc/init.d/S50adb_start 文件或者将其重命名为bak-S50adb_start 2. 源码里操作(改完后再编译) 删除 OKA40i-linux-sdk/out/a40i_h/OKA40i-C/buildroot/buildroot/target/etc/init.d/S50adb_start 文件或者将其重命名为bak-S50adb_start 四、使用方式 做完上述修改后,执行全编译,然后打包生成新镜像 在开发板中加载对应模块 [root@Tina5 ~]# insmod /lib/modules/5.10.149/g_ether.ko 之后可以看到对应的usb0网卡 |
|小黑屋| 飞凌嵌入式 ( 冀ICP备12004394号-1 )
GMT+8, 2024-12-23 04:26
Powered by Discuz! X3.4
© 2001-2013 Comsenz Inc.