官方固件下USB device简单配置

1、命令输入cd /mnt/system/

2、在上面目录中有官方 点灯 blink.sh,usb网络共享 rndis.sh 等脚本文件

3、主要修改官方的rndis.sh 实现对usb device的配置,

4、rndis.sh文件内容如下:

#!/bin/sh
/etc/uhubon.sh device >> /tmp/rndis.log 2>&1
/etc/run_usb.sh probe rndis >> /tmp/rndis.log 2>&1
/etc/run_usb.sh start rndis >> /tmp/rndis.log 2>&1

sleep 0.3
ifconfig usb0 192.168.42.1
/etc/init.d/S80dnsmasq stop >> /tmp/rndis.log 2>&1 
sleep 0.2
/etc/init.d/S80dnsmasq start >> /tmp/rndis.log 2>&1

5、主要在 /etc/run_usb.sh start rndis >> /tmp/rndis.log 2>&1 的上面添加代码

6、1.添加虚拟大容量存储设备功能只需要添加 /etc/run_usb.sh msc /dev/mmcblk0 代码
······2.代码中的/dev/mmcblk0为开发板中的存在文件
······3.在/dev目录中 mmcblk0 开头都可以替代mmcblk0
······4.mmcblk0代表将整个sd卡 虚拟为大容量存储设备 mmcblk0p1或mmcblk0p2,p后面的数字为分区
······5.由于/ 目录下分区 windows无法识别,这个分区只会弹出 是否格式化的窗口

7、1.串口 添加 /etc/run_usb.sh acm
······2.在/dev/下会有一个设备文件ttyGS0
······3.在电脑上会多出一个串口,
······4.命令 echo tty > /dev/ttyGS0 会向串口写入"tty"字符串
······5.命令 cat /dev/ttyGS0 读串口收到的内容

8、其他功能由于 官方固件 没有编译 无法实现

9、例如添加串口后 代码内容:

#!/bin/sh

/etc/uhubon.sh device >> /tmp/rndis.log 2>&1
/etc/run_usb.sh probe rndis >> /tmp/rndis.log 2>&1
/etc/run_usb.sh probe acm
                                                  
/etc/run_usb.sh start rndis >> /tmp/rndis.log 2>&1
                                                  
sleep 0.3                                         
ifconfig usb0 192.168.42.1
/etc/init.d/S80dnsmasq stop >> /tmp/rndis.log 2>&1
sleep 0.2                                         
/etc/init.d/S80dnsmasq start >> /tmp/rndis.log 2>&1
1 Like

这里给出了给出了各种组合方式

  • g_zero (CONFIG_USB_ZERO)

  • g_audio (CONFIG_USB_AUDIO)

  • g_ether (CONFIG_USB_ETH) - implement a ‘Communication Device Class’ (CDC) Ethernet device to create a ‘USB to Ethernet’ network connection.

  • g_ncm (CONFIG_USB_G_NCM) - implement USB CDC NCM subclass standard. NCM is an advanced protocol for Ethernet encapsulation and allows grouping of several ethernet frames into one USB transfer.

  • g_mass_storage (CONFIG_USB_MASS_STORAGE) - acts as a USB Mass Storage disk driver. Its storage repository can use a regular file or a block device specified as a module parameter or sysfs option.

  • g_serial (CONFIG_USB_G_SERIAL) - behave as a ACM Serial device to create a ‘USB to Serial’ connection which can be used to interoperate with MS-Windows hosts or with the Linux-USB ‘cdc-acm’ driver.

  • g_midi (CONFIG_USB_MIDI_GADGET) - acts as a USB Audio device with one MIDI input and one MIDI output.

  • g_printer (CONFIG_USB_G_PRINTER) - channels data between the USB host and a user-space program driving the print engine.

  • g_cdc (CONFIG_USB_CDC_COMPOSITE) - provides two functions in one configuration: a CDC Ethernet (ECM) link, and a CDC ACM (serial port) link

  • g_acm_ms (CONFIG_USB_G_ACM_MS) - provides two functions in one configuration: a USB Mass Storage device and a CDC ACM (serial port) link

  • g_multi (CONFIG_USB_G_MULTI) - A multi-function composite gadget that can provide Ethernet (RNDIS and/or CDC), mass storage, and ACM serial link interfaces

  • g_hid (CONFIG_USB_G_HID) - A Human Interface Device (HID) gadget that provides a generic interface for things such as keyboards, mice, touchscreens

  • g_webcam - A Webcam Device

请问几种功能可以同时开启吗(凑够20字,不然发不出来)

我试了一下,好像可以同时有两种功能,文件里 rndis 也算一种,用其他代替好像也可以。加到3种就第3个功能没有反应。

usb 虚拟网卡NCM模式怎么打开,这样win、linux、Mac等系统都是免驱动的?