Linux – How to connect to a Raspberry Pi Zero to an Ubuntu laptop by USB

linuxnetworkingUbuntuusb

I tried following the instructions shown here so that hopefully I would be able to use my Raspberry Pi Zero without buying a usb keyboard, mouse and monitor.

After doing that I was unable to ssh in to the Raspberry Pi Zero. The output I got was:

ssh: Could not resolve hostname raspberrypi.local: Name or service not known

I tried dmesg and saw the following:

[ 2060.683489] usb 2-1: new high-speed USB device number 6 using xhci_hcd
[ 2065.979176] usb 2-1: new high-speed USB device number 7 using xhci_hcd
[ 2066.108051] usb 2-1: New USB device found, idVendor=0525, idProduct=a4a2
[ 2066.108056] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 2066.108058] usb 2-1: Product: RNDIS/Ethernet Gadget
[ 2066.108060] usb 2-1: Manufacturer: Linux 4.4.21+ with 20980000.usb
[ 2066.233624] cdc_subset: probe of 2-1:1.0 failed with error -22
[ 2066.234408] cdc_subset 2-1:1.1 usb0: register 'cdc_subset' at usb-0000:00:14.0-1, Linux Device, 6a:2b:ee:30:07:6e
[ 2066.235273] usbcore: registered new interface driver cdc_subset
[ 2066.236484] cdc_ether: probe of 2-1:1.0 failed with error -16
[ 2066.236507] usbcore: registered new interface driver cdc_ether
[ 2066.238455] cdc_subset 2-1:1.1 enp0s20u1i1: renamed from usb0
[ 2066.264145] IPv6: ADDRCONF(NETDEV_UP): enp0s20u1i1: link is not ready
[ 2066.264275] cdc_subset 2-1:1.1 enp0s20u1i1: kevent 12 may have been dropped
[ 2066.264281] cdc_subset 2-1:1.1 enp0s20u1i1: kevent 12 may have been dropped
[ 2066.264627] cdc_subset 2-1:1.1 enp0s20u1i1: kevent 12 may have been dropped
[ 2066.265568] cdc_subset 2-1:1.1 enp0s20u1i1: kevent 12 may have been dropped
[ 2066.265575] cdc_subset 2-1:1.1 enp0s20u1i1: kevent 12 may have been dropped
[ 2066.274193] cdc_subset 2-1:1.1 enp0s20u1i1: kevent 12 may have been dropped
[ 2111.934891] cdc_subset 2-1:1.1 enp0s20u1i1: kevent 12 may have been dropped
[ 2111.934898] cdc_subset 2-1:1.1 enp0s20u1i1: kevent 12 may have been dropped
[ 2111.936117] cdc_subset 2-1:1.1 enp0s20u1i1: kevent 12 may have been dropped
[ 2111.948226] cdc_subset 2-1:1.1 enp0s20u1i1: kevent 12 may have been dropped
[ 2111.948247] cdc_subset 2-1:1.1 enp0s20u1i1: kevent 12 may have been dropped
[ 2111.948251] cdc_subset 2-1:1.1 enp0s20u1i1: kevent 12 may have been dropped

Can anyone shed any light on what these logs mean? Extensive googling has yeilded no results for me.

I’m using Ubuntu 16.04.1 LTS 64-bit on a Lenovo Z50 (runs Ubuntu but a bit dodgily which is probably the source of most problems I have on this laptop). I have also tried using a Windows laptop. This worked after I installed the Bonjour software from Apple.

The output from the ifconfig says there is no IP address for the device so I’m not sure how I would connect to it.

enp0s20u3 Link encap:Ethernet  HWaddr ce:77:fe:7a:9f:66  
          inet6 addr: fe80::7af9:c911:f518:cede/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:30 errors:0 dropped:0 overruns:0 frame:0
          TX packets:84 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:5660 (5.6 KB)  TX bytes:13989 (13.9 KB)

Thanks!

Update:

Beware of red herrings in everything below this line

OK so I downloaded the linux kernal source (latest stable version which is v4.8.11) and did some grepping.

I found that the "Kevent blah may have been dropped" is thrown in a function called 'usbnet_defer_kevent'.

/* some work can't be done in tasklets, so we use keventd
 *
 * NOTE:  annoying asymmetry:  if it's active, schedule_work() fails,
 * but tasklet_schedule() doesn't.  hope the failure is rare.
 */
void usbnet_defer_kevent (struct usbnet *dev, int work)
{
    set_bit (work, &dev->flags);
    if (!schedule_work (&dev->kevent)) {
        if (net_ratelimit())
            netdev_err(dev->net, "kevent %d may have been dropped\n", work);
    } else {
        netdev_dbg(dev->net, "kevent %d scheduled\n", work);
    }
}
EXPORT_SYMBOL_GPL(usbnet_defer_kevent);

I found usbnet_defer_kevent(dev, EVENT_SET_RX_MODE); being thrown in a few places and it turns out that we have it definied in usbnet.h like so# define EVENT_SET_RX_MODE 12. Not sure what EVENT_SET_RX_MODE is yet though (well. not what it is supposed to enumerate) so if anyone can help with that please do.

cdc_subset: probe of blah failed with error blah is called in 'really_probe' in drivers/base/dd.c. Looks like linux tests drivers to see if they are suitable by 'probing' the device with the driver. That's my guess anyway. Need to find out what '-22' and '-16' are.

suspicion: I don't have a suitable driver installed

I'll keep hammering away at it anyway.

ps. sorry for the incoherant smattering of information here. I'm kind of using this as a notepad for my own digging.

Best Answer

You need to go into the network-manager menu, Edit Connections… and edit the new Ethernet connection (for me it was “Wired connection 2”). Switch to the IPv4 tab, and change the Method to “Link-Local only”. Click Save and then Close.

The usb0 network interface will then get assigned a 169.254.x.y address, and “ssh pi@raspberrypi.local” will work just like it should.

Related Question