1

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 dtoverlay=dwc2

cmdline.txt add parameter modules-load=dwc2,g_ether after rootwait

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.

Investigations

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 /usr/src/linux-headers-[version]-generic/include/config/).

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).

ip addrreports

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.

3
  • Please flash a fresh Raspbian Buster image, boot it without any modifications, then configure OTG gadget. Then from the RasPi please add the output of these two commands to your question: ip addr and ip route.
    – Ingo
    Mar 4, 2020 at 10:59
  • @Ingo I can't do anything on the Pi. It's a Zero headless, no networking. The only way I can work is to put the SD card in my Linux host. I will try to add a debug file to the start up.
    – Peter bill
    Mar 5, 2020 at 12:08
  • Please add this important information to the question.
    – Ingo
    Mar 5, 2020 at 13:38

4 Answers 4

1

This is as designed!

init=/usr/lib/raspi-config/init_resize.sh

Is there to resize the root partition on 1st boot.

There are numerous settings that need to be manually configured BEFORE you can start fiddling with it. Attempting to do so BEFORE initial boot is an exercise in futility.

1
  • Well, I was investigating something that's not a fault, but what's next in finding why ping and ssh fail?
    – Peter bill
    Mar 1, 2020 at 12:07
0

I have experienced the same issue using Ubuntu 20.04 as the host pc.

I managed to get a connection to my raspberry pi by changing the network manager's IPv4 Method to Link-Local Only in Network Manager.

This then allowed the connection to complete and I could then ssh into the raspberry pi using the raspberrypi.local address.

The Link-Local setting in Network Manager

I'm still working on getting network sharing working so that the raspberry pi can then use the host's internet connection.

0

In Linux Mint 20.1, the Zero shows up as Netchip Technology Linux-USB Ethernet/RNDIS Gadget if you hover the networking icon. If you click on Wired Connections, the Zero most likely shows up as Wired Connection 2 since the Ethernet card in the PC is Wired Connection 1.

Do as gilesp wrote above about setting the IPv4 Settings --> Method to Link-Local.

0

Time is the enemy of all tutorials. Windows 10 doesn't ship with the necessary RNDIS driver. You'll have to install it manually. See https://www.factoryforward.com/pi-zero-w-headless-setup-windows10-rndis-driver-issue-resolved/ for a guide.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.