Skip to content

启动流程

启动脚本init.c

启动脚本init.c

PicoXTools初始化完成并且文件系统挂载成功后,会在根目录下查找init.c文件。如果文件存在并且3 秒内用户没有按^C 打断启动流程,系统将执行init.c 因此可在init.c中定制一些启动业务比如启动webserver.

c
int main(){
    httpd();
    // lvgl_test();
    return 0;
}
int main(){
    httpd();
    // lvgl_test();
    return 0;
}

RNDIS or CDC-ECM

Host类型

  • Windows仅只支持 RNDIS,
  • MacOS仅支持CDC-ECM,
  • Linux都支持

因此非Linux的主机需要正确设置host类型,否则USB网卡不能正常工作。

  • 默认情况USB配置为RNDIS(windows操作系统支持的类型),如果是macOS的用户请在PicoXTools根目录下创建文件.init内容如下:
text
host=mac
host=mac
  • 启过过程中如果拨码轮拨至最左边状态,USB网卡将会设置为Mac模式(CDC-ECM); 拨至最右边网卡将会设置为RNDIS模式。此操作仅单次有效并且优先级高于.init配置。

Linux dmesg输出

txt
[  640.279643] usb 2-2: New USB device found, idVendor=203a, idProduct=fffe, bcdDevice= 1.01
[  640.279648] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  640.279649] usb 2-2: Product: Virtual USB1.1 HUB
[  640.279649] usb 2-2: Manufacturer: Parallels
[  640.279650] usb 2-2: SerialNumber: PW3.0
[  640.279898] hub 2-2:1.0: USB hub found
[  640.279924] hub 2-2:1.0: 15 ports detected
[  640.568128] usb 2-2.6: new full-speed USB device number 6 using xhci_hcd
[  640.679114] usb 2-2.6: New USB device found, idVendor=2e8a, idProduct=000c, bcdDevice= 1.01
[  640.679119] usb 2-2.6: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  640.679120] usb 2-2.6: Product: PicXTools
[  640.679120] usb 2-2.6: Manufacturer: PPVision
[  640.679121] usb 2-2.6: SerialNumber: 0000
[  640.687160] cdc_acm 2-2.6:1.1: ttyACM4: USB ACM device
[  640.691248] cdc_ether 2-2.6:1.3 usb0: register 'cdc_ether' at usb-0000:00:03.0-2.6, CDC Ethernet Device, fe:02:17:1b:15:34
[  640.692268] usb-storage 2-2.6:1.5: USB Mass Storage device detected
[  640.698717] scsi host6: usb-storage 2-2.6:1.5
[  640.722870] cdc_ether 2-2.6:1.3 enxfe02171b1534: renamed from usb0
[  641.713144] scsi host6: scsi scan: INQUIRY result too short (5), using 36
[  641.713156] scsi 6:0:0:0: Direct-Access     PicoXToo Mass Storage     1.0  PQ: 0 ANSI: 2
[  641.713554] scsi 6:0:0:0: Attached scsi generic sg2 type 0
[  641.720134] sd 6:0:0:0: [sdb] 3584 4096-byte logical blocks: (14.7 MB/14.0 MiB)
[  641.725494] sd 6:0:0:0: [sdb] Write Protect is off
[  641.725498] sd 6:0:0:0: [sdb] Mode Sense: 03 00 00 00
[  641.728238] sd 6:0:0:0: [sdb] No Caching mode page found
[  641.728246] sd 6:0:0:0: [sdb] Assuming drive cache: write through
[  641.756058]  sdb: sdb1
[  641.769308] sd 6:0:0:0: [sdb] Attached SCSI removable disk
[  640.279643] usb 2-2: New USB device found, idVendor=203a, idProduct=fffe, bcdDevice= 1.01
[  640.279648] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  640.279649] usb 2-2: Product: Virtual USB1.1 HUB
[  640.279649] usb 2-2: Manufacturer: Parallels
[  640.279650] usb 2-2: SerialNumber: PW3.0
[  640.279898] hub 2-2:1.0: USB hub found
[  640.279924] hub 2-2:1.0: 15 ports detected
[  640.568128] usb 2-2.6: new full-speed USB device number 6 using xhci_hcd
[  640.679114] usb 2-2.6: New USB device found, idVendor=2e8a, idProduct=000c, bcdDevice= 1.01
[  640.679119] usb 2-2.6: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  640.679120] usb 2-2.6: Product: PicXTools
[  640.679120] usb 2-2.6: Manufacturer: PPVision
[  640.679121] usb 2-2.6: SerialNumber: 0000
[  640.687160] cdc_acm 2-2.6:1.1: ttyACM4: USB ACM device
[  640.691248] cdc_ether 2-2.6:1.3 usb0: register 'cdc_ether' at usb-0000:00:03.0-2.6, CDC Ethernet Device, fe:02:17:1b:15:34
[  640.692268] usb-storage 2-2.6:1.5: USB Mass Storage device detected
[  640.698717] scsi host6: usb-storage 2-2.6:1.5
[  640.722870] cdc_ether 2-2.6:1.3 enxfe02171b1534: renamed from usb0
[  641.713144] scsi host6: scsi scan: INQUIRY result too short (5), using 36
[  641.713156] scsi 6:0:0:0: Direct-Access     PicoXToo Mass Storage     1.0  PQ: 0 ANSI: 2
[  641.713554] scsi 6:0:0:0: Attached scsi generic sg2 type 0
[  641.720134] sd 6:0:0:0: [sdb] 3584 4096-byte logical blocks: (14.7 MB/14.0 MiB)
[  641.725494] sd 6:0:0:0: [sdb] Write Protect is off
[  641.725498] sd 6:0:0:0: [sdb] Mode Sense: 03 00 00 00
[  641.728238] sd 6:0:0:0: [sdb] No Caching mode page found
[  641.728246] sd 6:0:0:0: [sdb] Assuming drive cache: write through
[  641.756058]  sdb: sdb1
[  641.769308] sd 6:0:0:0: [sdb] Attached SCSI removable disk

usb 网卡己被重命为enxfe02171b1534

sh
$ ifconfig -a
enxfe02171b1534: flags=4098<BROADCAST,MULTICAST>  mtu 1500
       ether fe:02:17:1b:15:34  txqueuelen 1000  (Ethernet)
       RX packets 0  bytes 0 (0.0 B)
       RX errors 0  dropped 0  overruns 0  frame 0
       TX packets 0  bytes 0 (0.0 B)
       TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
$ ifconfig -a
enxfe02171b1534: flags=4098<BROADCAST,MULTICAST>  mtu 1500
       ether fe:02:17:1b:15:34  txqueuelen 1000  (Ethernet)
       RX packets 0  bytes 0 (0.0 B)
       RX errors 0  dropped 0  overruns 0  frame 0
       TX packets 0  bytes 0 (0.0 B)
       TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

LINUX下配置usb网卡

  • 创建文件 `/etc/systemd/network/10-usb0.network'
text
[Match]
Driver=cdc_ether

[Link]
Name=usb0

[Network]
DHCP=ipv4
[Match]
Driver=cdc_ether

[Link]
Name=usb0

[Network]
DHCP=ipv4
  • Reset PicoXTools board

  • 应用更新

sh
sudo udevadm control -R
sudo udevadm control -R
  • 查看USB网卡状态
sh
$ifconfig -a

usb0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.3.2  netmask 255.255.255.0  broadcast 192.168.3.255
        inet6 fe80::fc02:17ff:fe1b:1534  prefixlen 64  scopeid 0x20<link>
        ether fe:02:17:1b:15:34  txqueuelen 1000  (Ethernet)
        RX packets 2  bytes 536 (536.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 33  bytes 5193 (5.1 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
$ifconfig -a

usb0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.3.2  netmask 255.255.255.0  broadcast 192.168.3.255
        inet6 fe80::fc02:17ff:fe1b:1534  prefixlen 64  scopeid 0x20<link>
        ether fe:02:17:1b:15:34  txqueuelen 1000  (Ethernet)
        RX packets 2  bytes 536 (536.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 33  bytes 5193 (5.1 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

注意

由于linux 发行版本众多,上述命令可能会有所差异。

Released under the MIT License.