0

I've a strange issue when using g_multi on my Raspberry Pi Zero W. Now I can format the SD card with archlinux system and enable the g_multi (network, serial and mass storage) and work fine with my another archlinux server.

But when connect to my Mac Mini Server, the Mac cannot detect the mass storage and network device. I check the journal log and found repeat shows usb0: Lost carrier and usb0: Gained carrier, like


 2月 21 21:47:59 rpi0w systemd-networkd[181]: usb0: Gained carrier
 2月 21 21:47:59 rpi0w systemd-timesyncd[218]: Network configuration changed, trying to establish connection.
 2月 21 21:47:59 rpi0w systemd-networkd[181]: usb0: Configured
 2月 21 21:48:02 rpi0w systemd-resolved[219]: Failed to send hostname reply: Invalid argument
 2月 21 21:48:05 rpi0w systemd-resolved[219]: Using degraded feature set (UDP) for DNS server 8.8.4.4.
 2月 21 21:48:09 rpi0w systemd-resolved[219]: Using degraded feature set (UDP) for DNS server 8.8.8.8.
 2月 21 21:48:09 rpi0w systemd-resolved[219]: Failed to send hostname reply: Invalid argument
 2月 21 21:48:11 rpi0w kernel: dwc2 20980000.usb: dwc2_hsotg_ep_stop_xfr: timeout GINTSTS.GOUTNAKEFF
 2月 21 21:48:11 rpi0w kernel: dwc2 20980000.usb: dwc2_hsotg_ep_stop_xfr: timeout DOEPCTL.EPDisable
 2月 21 21:48:11 rpi0w kernel: dwc2 20980000.usb: dwc2_hsotg_ep_stop_xfr: timeout GINTSTS.GOUTNAKEFF
 2月 21 21:48:11 rpi0w kernel: dwc2 20980000.usb: dwc2_hsotg_ep_stop_xfr: timeout DOEPCTL.EPDisable
 2月 21 21:48:11 rpi0w kernel: dwc2 20980000.usb: dwc2_hsotg_ep_stop_xfr: timeout GINTSTS.GOUTNAKEFF
 2月 21 21:48:11 rpi0w kernel: dwc2 20980000.usb: dwc2_hsotg_ep_stop_xfr: timeout DOEPCTL.EPDisable
 2月 21 21:48:11 rpi0w systemd-networkd[181]: usb0: Lost carrier
 2月 21 21:48:11 rpi0w systemd-timesyncd[218]: No network connectivity, watching for changes.
 2月 21 21:48:12 rpi0w kernel: dwc2 20980000.usb: new device is high-speed
 2月 21 21:48:12 rpi0w kernel: dwc2 20980000.usb: new device is high-speed
 2月 21 21:48:12 rpi0w kernel: dwc2 20980000.usb: new address 12
 2月 21 21:48:13 rpi0w kernel: g_multi gadget: high-speed config #1: Multifunction with RNDIS
 2月 21 21:48:13 rpi0w systemd-networkd[181]: usb0: Gained carrier

PS. when I using g_ether for simplify my question, Mac and my archlinux both can detect the network device but I always cannot route (ping or other method) to my RPi zero W.

Can you please give some advice for these issues ...

[UPDATE]

For more clear, provide the configuration I used (two systemd configuration and one binary file)

# /usr/lib/systemd/network/usb0.network
# Raspberry Pi Zero W (RPi0w) gadget
# The ethernet over USB interface
[Match]
Name        = usb0

[Network]
Description     = RPi Zero W gadget
Address         = 172.16.4.2/16
Gateway         = 172.16.4.1
# /usr/lib/systemd/system/usbgadget.service
# USB Multi-Gadget (Serial / Ethernet)
[Unit]
Description=USB Multi-Gadget
After=systemd-modules-load.service
Before=getty@ttyGS0.service

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/sbin/usbgadget

[Install]
WantedBy=sysinit.target
EOF
cat >> root/usr/lib/systemd/network/usb0.network << EOF
# Raspberry Pi Zero W (RPi0w) gadget
# The ethernet over USB interface

#! /bin/sh -e
# /usr/sbin/usbgadget

modprobe libcomposite
mkdir -p /sys/kernel/config/usb_gadget/g

cd /sys/kernel/config/usb_gadget/g

echo 0x1d6b > idVendor  # Linux Foundation
echo 0x0104 > idProduct # Multifunction Composite Gadget
echo 0x0100 > bcdDevice # v1.0.0
echo 0x0200 > bcdUSB    # USB 2.0

mkdir -p strings/0x409
echo "deadbeef00115599" > strings/0x409/serialnumber
echo "RPi0w"            > strings/0x409/manufacturer
echo "RPi0w USB Gadget" > strings/0x409/product

mkdir -p configs/c.1/strings/0x409
echo "Config 1: ECM network" > configs/c.1/strings/0x409/configuration""
echo 250                     > configs/c.1/MaxPower

# Add functions here

## Serial Adapter ##
mkdir -p functions/acm.usb0    # serial
ln -s functions/acm.usb0   configs/c.1/

## Ethernet Adapter ##
mkdir -p functions/rndis.usb0  # network
ln -s functions/rndis.usb0 configs/c.1/

udevadm settle -t 5 || :
ls /sys/class/udc/ > UDC
EOF

[UPDATE] After several try-error the ethernet over USB now is workable when I use the CDC ECM driver. Like the rndis but change to ecm and it can be detect both on ArchLinux and Mac mini server

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.