There are several posts that say a Pi Zero can be connected to another computer with USB to enable networking (e.g. Linux host, Windows host or https://www.circuitbasics.com/raspberry-pi-zero-ethernet-gadget/).
The USB connection provides both power and data. I have also followed this question Headless Pi Zero SSH access over USB
They say, you need to change two files in the boot partition of the Pi SD card:
config.txt add line
cmdline.txt add parameter
I have done all of that, but am still unable to connect.
ssh says “No route to host” and
ping says “Destination Host Unreachable”; both using the configured static IP address.
My Linux host reports an error, “Activation of network connection failed” (GUI notification).
On investigation, the Pi is corrupting the file
cmdline.txt. I have tried setting it to:
console=serial0,115200 console=tty1 root=PARTUUID=738a4d67-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait modules-load=dwc2,g_ether quiet init=/usr/lib/raspi-config/init_resize.sh
and, reordering the parameters:
console=serial0,115200 console=tty1 root=PARTUUID=738a4d67-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet init=/usr/lib/raspi-config/init_resize.sh modules-load=dwc2,g_ether
Both times, after a failed attempt to boot the Pi, I found the file contained
console=serial0,115200 console=tty1 root=PARTUUID=738a4d67-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait modules-load=dwc2,g_ether
with a timestamp of 1980-01-01 00:00:00 (indicating the Pi had never had time to set it’s clock).
My first thought was that the file was truncated after the new parameter, so I moved the new bit to the end, but that made no difference.
Has anyone else seen this corruption? Any ideas of how to progress?
My host has Linux Mint 19.3.
The Pi Zero appeared to boot – the green LED flashed for a few seconds, then stayed on.
On the host,
lsusb has a line
Bus 002 Device 007: ID 0525:a4a2 Netchip Technology, Inc. Linux-USB Ethernet/RNDIS Gadget
avahi-daemon is running on the host,
rndis is installed (several copies in
There are no relevant messages in
dmesg, so I don’t think it’s a firewall issue.
EDIT - It's not file corruption
Thanks to @Milliways for confirming the file is not corrupt, so that line of investigation led nowhere.
Does anyone have any other ideas?
EDIT 2 - Some debug data
In case it's not clear, I have a Pi Zero, without wifi or ethernet. As it is headless, I can't do anything until I get
ssh to work - except by mounting the SD card on my Linux host. Ethernet over USB OTG is a fundamental part of the project this is part of.
I wrote a short debug script and called it from
/etc/rc.local (please don't be offended, it's only temporary and the easiest way to run it).
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: usb0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 66:71:a4:0e:e5:bc brd ff:ff:ff:ff:ff:ff inet 192.168.1.11/24 brd 192.168.1.255 scope global usb0 valid_lft forever preferred_lft forever inet6 fe80::6471:a4ff:fe0e:e5bc/64 scope link valid_lft forever preferred_lft forever
(192.168.1.11 is the static IP address I have configured).
ip route shows
192.168.1.0/24 dev usb0 proto kernel scope link src 192.168.1.11
The IP address of my host is not shown.
EDIT 3 - Bug in Raspbian?
Further research uncovered this post, where there is a hint that lack of connectivity is caused by a bug in Raspbian Stretch. The post suggests using the older Jessie version (from June 2017).
I have flashed the latest Buster (2020-02-13-raspbian-buster-lite.img). Is it possible the Stretch bug (if that is what it is) is still present in Buster? I can find no Raspbian bug list or release notes. I don’t have time to try to download and flash a Jessie image, but may consider it later.