Raspberry Pi 零处的 Buildroot/Busybox 和 OTG 以太网适配器 -> 缺少以太网接口
Buildroot / Busybox and OTG Ethernet Adapter at Raspberry Pi Zero -> Missing ethernet interface
我有一个 Raspberry Pi 零,带有一个带有网络适配器的 OTG 微型 USB 集线器。如果我使用 Raspbian:
适配器工作正常
$ lsusb
Bus 001 Device 003: ID 0fe6:9700 ICS Advent DM9601 Fast Ethernet Adapter
Bus 001 Device 002: ID 1a40:0101 Terminus Technology Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
$ ls /sys/class/net/ -lah
insgesamt 0
drwxr-xr-x 2 root root 0 Jul 20 13:53 .
drwxr-xr-x 54 root root 0 Feb 14 2019 ..
lrwxrwxrwx 1 root root 0 Jul 17 14:50 eth0 -> ../../devices/platform/soc/20980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/net/eth0
lrwxrwxrwx 1 root root 0 Jul 17 14:49 lo -> ../../devices/virtual/net/lo
lrwxrwxrwx 1 root root 0 Jul 17 14:50 wlan0 -> ../../devices/platform/soc/20300000.mmcnr/mmc_host/mmc1/mmc1:0001/mmc1:0001:1/net/wlan0
$ cat /proc/net/dev
Inter-| Receive | Transmit
face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
eth0: 262496 2737 0 989 0 0 0 0 37106 301 0 0 0 0 0 0
lo: 78 2 0 0 0 0 0 0 78 2 0 0 0 0 0 0
wlan0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
实际上我正在通过 SSH 连接此适配器。
所以我需要让这个适配器与嵌入式适配器一起工作:因此我将 Buildroot 与 Busybox 一起使用。
$ git clone https://github.com/buildroot/buildroot.git buildroot_rpi_zero
$ cd buildroot_rpi_zero
buildroot_rpi_zero$ git checkout tags/2020.02.3
buildroot_rpi_zero$ make raspberrypi0w_defconfig
buildroot_rpi_zero$ make all
buildroot_rpi_zero$ make savedefconfig
附上我的配置:
BR2_arm=y
BR2_arm1176jzf_s=y
BR2_CCACHE=y
BR2_CCACHE_DIR="/mnt/Daten/buildroot-ccache"
BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_19=y
BR2_TOOLCHAIN_BUILDROOT_WCHAR=y
BR2_TOOLCHAIN_BUILDROOT_CXX=y
BR2_ROOTFS_POST_BUILD_SCRIPT="board/raspberrypi0w/post-build.sh"
BR2_ROOTFS_POST_IMAGE_SCRIPT="board/raspberrypi0w/post-image.sh"
BR2_ROOTFS_POST_SCRIPT_ARGS="--add-miniuart-bt-overlay"
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_TARBALL=y
BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION="$(call github,raspberrypi,linux,64d0a9870ac14d5eb5253f67d984ae348eec1393)/linux-64d0a9870ac14d5eb5253f67d984ae348eec1393.tar.gz"
BR2_LINUX_KERNEL_DEFCONFIG="bcmrpi"
BR2_LINUX_KERNEL_DTS_SUPPORT=y
BR2_LINUX_KERNEL_INTREE_DTS_NAME="bcm2708-rpi-zero-w"
BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
BR2_PACKAGE_RPI_FIRMWARE=y
BR2_PACKAGE_PYTHON3=y
BR2_PACKAGE_PYTHON3_PY_ONLY=y
BR2_PACKAGE_PYTHON3_BZIP2=y
BR2_PACKAGE_PYTHON3_CODECSCJK=y
BR2_PACKAGE_PYTHON3_CURSES=y
BR2_PACKAGE_PYTHON3_DECIMAL=y
BR2_PACKAGE_PYTHON3_OSSAUDIODEV=y
BR2_PACKAGE_PYTHON3_READLINE=y
BR2_PACKAGE_PYTHON3_SSL=y
BR2_PACKAGE_PYTHON3_SQLITE=y
BR2_PACKAGE_PYTHON3_PYEXPAT=y
BR2_PACKAGE_PYTHON3_XZ=y
BR2_PACKAGE_PYTHON3_ZLIB=y
BR2_PACKAGE_LIBSSH=y
BR2_PACKAGE_LIBSSH_SERVER=y
BR2_PACKAGE_LIBOPENSSL_BIN=y
BR2_PACKAGE_OPENSSH=y
BR2_TARGET_ROOTFS_EXT2=y
BR2_TARGET_ROOTFS_EXT2_4=y
BR2_TARGET_ROOTFS_EXT2_SIZE="120M"
# BR2_TARGET_ROOTFS_TAR is not set
BR2_PACKAGE_HOST_DOSFSTOOLS=y
BR2_PACKAGE_HOST_GENIMAGE=y
BR2_PACKAGE_HOST_MTOOLS=y
开机后会检测到USB设备:
$ lsusb
Bus 001 Device 001: ID 1d6b:0002
Bus 001 Device 002: ID 1a40:0101
Bus 001 Device 003: ID 0fe6:9700
$ ls -lah /sys/class/net/
total 0
drwxr-xr-x 2 root root 0 Jan 1 00:00 .
drwxr-xr-x 47 root root 0 Jan 1 00:00 ..
lrwxrwxrwx 1 root root 0 Jan 1 00:00 lo -> ../../devices/virtual/net/lo
cat /proc/net/dev
Inter-| Receive | Transmit
face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
lo: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
$ dmesg | grep usb
[ 0.174140] usbcore: registered new interface driver usbfs
[ 0.174290] usbcore: registered new interface driver hub
[ 0.174558] usbcore: registered new device driver usb
[ 0.441374] usbcore: registered new interface driver smsc95xx
[ 0.476557] dwc_otg 20980000.usb: base=(ptrval)
[ 0.942503] dwc_otg 20980000.usb: DWC OTG Controller
[ 0.945622] dwc_otg 20980000.usb: new USB bus registered, assigned bus number 1
[ 0.948924] dwc_otg 20980000.usb: irq 56, io mem 0x00000000
[ 0.958646] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 4.19
[ 0.964920] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 0.968365] usb usb1: Product: DWC OTG Controller
[ 0.971671] usb usb1: Manufacturer: Linux 4.19.97 dwc_otg_hcd
[ 0.974980] usb usb1: SerialNumber: 20980000.usb
[ 0.987968] usbcore: registered new interface driver usb-storage
[ 1.031124] usbcore: registered new interface driver usbhid
[ 1.034612] usbhid: USB HID core driver
[ 3.017388] usb 1-1: new high-speed USB device number 2 using dwc_otg
[ 3.277596] usb 1-1: New USB device found, idVendor=1a40, idProduct=0101, bcdDevice= 1.11
[ 3.292825] usb 1-1: New USB device strings: Mfr=0, Product=1, SerialNumber=0
[ 3.303663] usb 1-1: Product: USB 2.0 Hub
[ 3.746900] usb 1-1.2: new full-speed USB device number 3 using dwc_otg
[ 3.989493] usb 1-1.2: New USB device found, idVendor=0fe6, idProduct=9700, bcdDevice= 1.01
[ 4.005150] usb 1-1.2: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[ 4.016385] usb 1-1.2: Product: USB 2.0 10/100M Ethernet Adaptor
现在似乎检测到适配器但是没有网络接口...?我必须手动添加吗?
同时我做了一些测试,发现我们已经需要这个以太网卡的内核驱动程序:
$ make linux-menuconfig
Location:
-> Kernel configuration
-> Device Drivers
-> Network device support
-> USB Network Adapters
-> Davicom DM96xx based USB 10/100 ethernet devices
我们用以下方法重建了内核:
$ make linux-rebuild
启动此图像将导致:
$ dmesg | grep usb
...
[ 4.057510] usb 1-1.2: Product: USB 2.0 10/100M Ethernet Adaptor
[ 4.113284] dm9601 1-1.2:1.0 eth0: register 'dm9601' at usb-20980000.usb-1.2, Davicom DM96xx USB 10/100 Ethernet, zz:zz:zz:zz:zz:zz
我们可以继续进行 IP4V 设置:
$ ifconfig eth0 192.168.08.15 netmask 255.255.255.0 up
[ 1013.827270] dm9601 1-1.2:1.0 eth0: link up, 100Mbps, full-duplex, lpa 0xFFFF
[ 1013.896358] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[ 1013.906626] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
我有一个 Raspberry Pi 零,带有一个带有网络适配器的 OTG 微型 USB 集线器。如果我使用 Raspbian:
适配器工作正常$ lsusb
Bus 001 Device 003: ID 0fe6:9700 ICS Advent DM9601 Fast Ethernet Adapter
Bus 001 Device 002: ID 1a40:0101 Terminus Technology Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
$ ls /sys/class/net/ -lah
insgesamt 0
drwxr-xr-x 2 root root 0 Jul 20 13:53 .
drwxr-xr-x 54 root root 0 Feb 14 2019 ..
lrwxrwxrwx 1 root root 0 Jul 17 14:50 eth0 -> ../../devices/platform/soc/20980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/net/eth0
lrwxrwxrwx 1 root root 0 Jul 17 14:49 lo -> ../../devices/virtual/net/lo
lrwxrwxrwx 1 root root 0 Jul 17 14:50 wlan0 -> ../../devices/platform/soc/20300000.mmcnr/mmc_host/mmc1/mmc1:0001/mmc1:0001:1/net/wlan0
$ cat /proc/net/dev
Inter-| Receive | Transmit
face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
eth0: 262496 2737 0 989 0 0 0 0 37106 301 0 0 0 0 0 0
lo: 78 2 0 0 0 0 0 0 78 2 0 0 0 0 0 0
wlan0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
实际上我正在通过 SSH 连接此适配器。
所以我需要让这个适配器与嵌入式适配器一起工作:因此我将 Buildroot 与 Busybox 一起使用。
$ git clone https://github.com/buildroot/buildroot.git buildroot_rpi_zero
$ cd buildroot_rpi_zero
buildroot_rpi_zero$ git checkout tags/2020.02.3
buildroot_rpi_zero$ make raspberrypi0w_defconfig
buildroot_rpi_zero$ make all
buildroot_rpi_zero$ make savedefconfig
附上我的配置:
BR2_arm=y
BR2_arm1176jzf_s=y
BR2_CCACHE=y
BR2_CCACHE_DIR="/mnt/Daten/buildroot-ccache"
BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_19=y
BR2_TOOLCHAIN_BUILDROOT_WCHAR=y
BR2_TOOLCHAIN_BUILDROOT_CXX=y
BR2_ROOTFS_POST_BUILD_SCRIPT="board/raspberrypi0w/post-build.sh"
BR2_ROOTFS_POST_IMAGE_SCRIPT="board/raspberrypi0w/post-image.sh"
BR2_ROOTFS_POST_SCRIPT_ARGS="--add-miniuart-bt-overlay"
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_TARBALL=y
BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION="$(call github,raspberrypi,linux,64d0a9870ac14d5eb5253f67d984ae348eec1393)/linux-64d0a9870ac14d5eb5253f67d984ae348eec1393.tar.gz"
BR2_LINUX_KERNEL_DEFCONFIG="bcmrpi"
BR2_LINUX_KERNEL_DTS_SUPPORT=y
BR2_LINUX_KERNEL_INTREE_DTS_NAME="bcm2708-rpi-zero-w"
BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
BR2_PACKAGE_RPI_FIRMWARE=y
BR2_PACKAGE_PYTHON3=y
BR2_PACKAGE_PYTHON3_PY_ONLY=y
BR2_PACKAGE_PYTHON3_BZIP2=y
BR2_PACKAGE_PYTHON3_CODECSCJK=y
BR2_PACKAGE_PYTHON3_CURSES=y
BR2_PACKAGE_PYTHON3_DECIMAL=y
BR2_PACKAGE_PYTHON3_OSSAUDIODEV=y
BR2_PACKAGE_PYTHON3_READLINE=y
BR2_PACKAGE_PYTHON3_SSL=y
BR2_PACKAGE_PYTHON3_SQLITE=y
BR2_PACKAGE_PYTHON3_PYEXPAT=y
BR2_PACKAGE_PYTHON3_XZ=y
BR2_PACKAGE_PYTHON3_ZLIB=y
BR2_PACKAGE_LIBSSH=y
BR2_PACKAGE_LIBSSH_SERVER=y
BR2_PACKAGE_LIBOPENSSL_BIN=y
BR2_PACKAGE_OPENSSH=y
BR2_TARGET_ROOTFS_EXT2=y
BR2_TARGET_ROOTFS_EXT2_4=y
BR2_TARGET_ROOTFS_EXT2_SIZE="120M"
# BR2_TARGET_ROOTFS_TAR is not set
BR2_PACKAGE_HOST_DOSFSTOOLS=y
BR2_PACKAGE_HOST_GENIMAGE=y
BR2_PACKAGE_HOST_MTOOLS=y
开机后会检测到USB设备:
$ lsusb
Bus 001 Device 001: ID 1d6b:0002
Bus 001 Device 002: ID 1a40:0101
Bus 001 Device 003: ID 0fe6:9700
$ ls -lah /sys/class/net/
total 0
drwxr-xr-x 2 root root 0 Jan 1 00:00 .
drwxr-xr-x 47 root root 0 Jan 1 00:00 ..
lrwxrwxrwx 1 root root 0 Jan 1 00:00 lo -> ../../devices/virtual/net/lo
cat /proc/net/dev
Inter-| Receive | Transmit
face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
lo: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
$ dmesg | grep usb
[ 0.174140] usbcore: registered new interface driver usbfs
[ 0.174290] usbcore: registered new interface driver hub
[ 0.174558] usbcore: registered new device driver usb
[ 0.441374] usbcore: registered new interface driver smsc95xx
[ 0.476557] dwc_otg 20980000.usb: base=(ptrval)
[ 0.942503] dwc_otg 20980000.usb: DWC OTG Controller
[ 0.945622] dwc_otg 20980000.usb: new USB bus registered, assigned bus number 1
[ 0.948924] dwc_otg 20980000.usb: irq 56, io mem 0x00000000
[ 0.958646] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 4.19
[ 0.964920] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 0.968365] usb usb1: Product: DWC OTG Controller
[ 0.971671] usb usb1: Manufacturer: Linux 4.19.97 dwc_otg_hcd
[ 0.974980] usb usb1: SerialNumber: 20980000.usb
[ 0.987968] usbcore: registered new interface driver usb-storage
[ 1.031124] usbcore: registered new interface driver usbhid
[ 1.034612] usbhid: USB HID core driver
[ 3.017388] usb 1-1: new high-speed USB device number 2 using dwc_otg
[ 3.277596] usb 1-1: New USB device found, idVendor=1a40, idProduct=0101, bcdDevice= 1.11
[ 3.292825] usb 1-1: New USB device strings: Mfr=0, Product=1, SerialNumber=0
[ 3.303663] usb 1-1: Product: USB 2.0 Hub
[ 3.746900] usb 1-1.2: new full-speed USB device number 3 using dwc_otg
[ 3.989493] usb 1-1.2: New USB device found, idVendor=0fe6, idProduct=9700, bcdDevice= 1.01
[ 4.005150] usb 1-1.2: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[ 4.016385] usb 1-1.2: Product: USB 2.0 10/100M Ethernet Adaptor
现在似乎检测到适配器但是没有网络接口...?我必须手动添加吗?
同时我做了一些测试,发现我们已经需要这个以太网卡的内核驱动程序:
$ make linux-menuconfig
Location:
-> Kernel configuration
-> Device Drivers
-> Network device support
-> USB Network Adapters
-> Davicom DM96xx based USB 10/100 ethernet devices
我们用以下方法重建了内核:
$ make linux-rebuild
启动此图像将导致:
$ dmesg | grep usb
...
[ 4.057510] usb 1-1.2: Product: USB 2.0 10/100M Ethernet Adaptor
[ 4.113284] dm9601 1-1.2:1.0 eth0: register 'dm9601' at usb-20980000.usb-1.2, Davicom DM96xx USB 10/100 Ethernet, zz:zz:zz:zz:zz:zz
我们可以继续进行 IP4V 设置:
$ ifconfig eth0 192.168.08.15 netmask 255.255.255.0 up
[ 1013.827270] dm9601 1-1.2:1.0 eth0: link up, 100Mbps, full-duplex, lpa 0xFFFF
[ 1013.896358] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[ 1013.906626] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready