采用linux 5.2版,buildroot 2019.11版本
用户名:root
密码:iotboard
登录后请用passwd修改密码
已安装usb gadget: serial 和 rndi
开机自动设置设备的ip为10.0.3.2
通过dnsmasq设置主机ip为10.0.3.1
设备IP更改请修改/etc/network/interfaces
主机IP更改请修改/etc/dnsmasq.conf
使用gadget configfs方式比g_multi模块好用
f1c200s_5_2_spiflash_16M_bin.zip
过些时候有空写个完整的编译文档。
离线
求配制方法,我是sd卡启动
编译文档正在写,比较长,可能要过一两天,我的固件是flash的,到时我也弄个tf卡的看看。
离线
先补一个usb gadget配置,只配置了usb网卡,windows下识别为rndis,mac和linux下识别为ncm,经测试win7和win10 自动安装驱动,MAC和LINUX免驱,自动识别为USB网卡,这样就省去了mac下安装rndis驱动的麻烦。windows下自动配置的IP为10.0.4.2,主机自动设置为10.0.4.1,MAC和LINUX下自动配置的IP为10.0.3.2,主机自动设置为10.0.3.1
如果用的是我的固件,USB启动文件位于/etc/init.d/usbgadget 并通过/etc/inittab调用,因为没有配置usb串口,请注释掉inittab里的 ttyGS0::respawn:/sbin/getty -L ttyGS0 115200 vt100 这行。
#!/bin/sh -e
# Mount configfs
mount -t configfs none /sys/kernel/config
# Make directories
cd /sys/kernel/config/usb_gadget/
mkdir g && cd g
# USB Common Config
echo 0x1d6b > idVendor # Linux Foundation
echo 0x0104 > idProduct # Multifunction Composite Gadget
echo 0x0100 > bcdDevice # v1.0.0
echo 0x0200 > bcdUSB # USB2
echo 0xEF > bDeviceClass
echo 0x02 > bDeviceSubClass
echo 0x01 > bDeviceProtocol
mkdir -p strings/0x409
echo "20200107" > strings/0x409/serialnumber
echo "IOT Labs" > strings/0x409/manufacturer
echo "USB Ethernet" > strings/0x409/product
# ECM Network Config
HOST1="00:dc:c8:f7:75:14" # "HostPC"
SELF1="00:dd:dc:eb:6d:a1" # "Self"
mkdir -p configs/c.1/strings/0x409
echo 250 > configs/c.1/MaxPower
echo "Config 1: ECM network" > configs/c.1/strings/0x409/configuration
mkdir functions/ecm.usb0
echo $HOST1 > functions/ecm.usb0/host_addr
echo $SELF1 > functions/ecm.usb0/dev_addr
ln -s functions/ecm.usb0 configs/c.1/
mkdir -p configs/c.2/strings/0x409
echo 250 > configs/c.2/MaxPower
echo 0x80 > configs/c.2/bmAttributes
echo "RNDIS" > configs/c.2/strings/0x409/configuration
HOST="12:6e:27:fb:dc:88" # "HostPC"
SELF="02:6e:27:fb:dc:88" # "Self"
# RNDIS Config
mkdir -p functions/rndis.usb0
mkdir -p functions/rndis.usb0/os_desc/interface.rndis/Icons
mkdir -p functions/rndis.usb0/os_desc/interface.rndis/Label
echo $HOST > functions/rndis.usb0/host_addr
echo $SELF > functions/rndis.usb0/dev_addr
echo RNDIS > functions/rndis.usb0/os_desc/interface.rndis/compatible_id
echo 5162001 > functions/rndis.usb0/os_desc/interface.rndis/sub_compatible_id
echo 2 > functions/rndis.usb0/os_desc/interface.rndis/Icons/type
echo "%SystemRoot%\system32\shell32.dll,-233" > functions/rndis.usb0/os_desc/interface.rndis/Icons/data
echo 1 > functions/rndis.usb0/os_desc/interface.rndis/Label/type
echo "RNDIS Device" > functions/rndis.usb0/os_desc/interface.rndis/Label/data
ln -s functions/rndis.usb0 configs/c.2/
# OS descriptors
echo 1 > os_desc/use
echo 0xcd > os_desc/b_vendor_code
echo MSFT100 > os_desc/qw_sign
ln -s configs/c.2 os_desc
ls /sys/class/udc/ > UDC
dnsmasq配置:
interface=usb0,usb1
dhcp-range=usb0,10.0.3.4,10.0.3.150,48h
dhcp-host=usb0,00:dc:c8:f7:75:14,10.0.3.1,infinite
dhcp-range=usb1,10.0.4.4,10.0.4.150,48h
dhcp-host=usb1,12:6e:27:fb:dc:88,10.0.4.1,infinite
/etc/network/interfaces配置:
# interface file auto-generated by buildroot
auto lo
iface lo inet loopback
# usb network interface
auto usb0
iface usb0 inet static
address 10.0.3.2
network 10.0.3.0
netmask 255.255.255.0
broadcast 10.0.3.255
auto usb1
iface usb1 inet static
address 10.0.4.2
network 10.0.4.0
netmask 255.255.255.0
broadcast 10.0.4.255
不知道有没有什么办法确认USB插入的主机是什么系统,然后根据系统来配置usbgadget,这样就省去了配置两个usb网络接口的麻烦。
更新的固件:f1c200s_5_2_spiflash_16M_bin.zip
最近编辑记录 chickenzzz (2020-01-09 15:44:29)
离线