USB connection to Pi zero stopped working - cant upload or ssh into pi zero

I had configured my Pi zero wifi connection after using the setup instructions in the build-a-weather-station-with-elixir-and-nerves_B4.0.pdf

all was working fine.

I updated a change to the NervesMOTD function and did a mix upload and lost connection to the pi zero.
Burned a firmware to a fresh sdcard and swapped over to usb cable and tried to ssh in to pi zero with fresh firmware.
ssh command just hangs now as shown below…

Tried reset of pi
reboot of Mac
I use LanScan to see what’s connected to my mac network and it no longer picks up the pi 2 when I switch it on/off.

I have been trying to find fixes all day that might help me reset my macOS USB connection.
might not be the problem
usb is still running a connected usb drive

$ export MIX_TARGET=rpi0
17:25:51~/projects/groxio/nerves/sensor_hub_poncho/sensor_hub 

$ mix firmware
==> nerves
==> sensor_hub

Nerves environment
  MIX_TARGET:   rpi0
  MIX_ENV:      dev

Compiling 3 files (.ex)
Generated sensor_hub app
|nerves_bootstrap| Building OTP Release...

* skipping runtime configuration (config/runtime.exs not found)
* creating _build/rpi0_dev/rel/sensor_hub/releases/0.1.0/vm.args
Updating base firmware image with Erlang release...
Copying rootfs_overlay: /Users/elay15/projects/groxio/nerves/sensor_hub_poncho/sensor_hub/_build/rpi0_dev/nerves/rootfs_overlay
Copying rootfs_overlay: /Users/elay15/projects/groxio/nerves/sensor_hub_poncho/sensor_hub/rootfs_overlay
Parallel mksquashfs: Using 8 processors
Creating 4.0 filesystem on /Users/elay15/projects/groxio/nerves/sensor_hub_poncho/sensor_hub/_build/_nerves-tmp/combined.squashfs, block size 131072.

Exportable Squashfs 4.0 filesystem, gzip compressed, data block size 131072
        compressed data, compressed metadata, compressed fragments,
        compressed xattrs, compressed ids
        duplicates are removed
Filesystem size 28820.77 Kbytes (28.15 Mbytes)
        54.96% of uncompressed filesystem size (52439.72 Kbytes)
Inode table size 19932 bytes (19.46 Kbytes)
        28.41% of uncompressed inode table size (70170 bytes)
Directory table size 23961 bytes (23.40 Kbytes)
        40.38% of uncompressed directory table size (59334 bytes)
Number of duplicate files found 91
Number of inodes 2119
Number of files 1714
Number of fragments 123
Number of symbolic links 160
Number of device nodes 0
Number of fifo nodes 0
Number of socket nodes 0
Number of directories 245
Number of ids (unique uids + gids) 3
Number of uids 2
        root (0)
        elay15 (502)
Number of gids 2
        wheel (0)
        staff (20)
Building /Users/elay15/projects/groxio/nerves/sensor_hub_poncho/sensor_hub/_build/rpi0_dev/nerves/images/sensor_hub.fw...
Firmware built successfully! 🎉

Now you may install it to a MicroSD card using `mix burn` or upload it
to a device with `mix upload` or `mix firmware.gen.script`+`./upload.sh`.

17:26:23~/projects/groxio/nerves/sensor_hub_poncho/sensor_hub 

$ mix upload
==> nerves
==> sensor_hub

Nerves environment
  MIX_TARGET:   rpi0
  MIX_ENV:      dev

Path: /Users/elay15/projects/groxio/nerves/sensor_hub_poncho/sensor_hub/_build/rpi0_dev/nerves/images/sensor_hub.fw

Uploading to nerves.local...

ssh: Could not resolve hostname nerves.local: nodename nor servname provided, or not known
** (Mix) Unexpected exit from ssh (:epipe)

This is known to happen when ssh interactively prompts you for a
passphrase. The following are workarounds:

1. Load your private key identity into the ssh agent by running
   `ssh-add`

2. Use the `upload.sh` script. Create one by running
   `mix firmware.gen.script`.

17:26:44~/projects/groxio/nerves/sensor_hub_poncho/sensor_hub 

$ ssh-add
Identity added: ########### - hashed out details
17:27:12~/projects/groxio/nerves/sensor_hub_poncho/sensor_hub 

$ mix firmware.gen.script
==> nerves
==> sensor_hub

Nerves environment
  MIX_TARGET:   rpi0
  MIX_ENV:      dev

OK to overwrite upload.sh? [Yn] y
Writing upload.sh...

17:27:37~/projects/groxio/nerves/sensor_hub_poncho/sensor_hub 

$ mix upload nerves.local
==> nerves
==> sensor_hub

Nerves environment
  MIX_TARGET:   rpi0
  MIX_ENV:      dev

Path: /Users/elay15/projects/groxio/nerves/sensor_hub_poncho/sensor_hub/_build/rpi0_dev/nerves/images/sensor_hub.fw

Uploading to nerves.local...

ssh: Could not resolve hostname nerves.local: nodename nor servname provided, or not known
** (Mix) Unexpected exit from ssh (:epipe)

This is known to happen when ssh interactively prompts you for a
passphrase. The following are workarounds:

1. Load your private key identity into the ssh agent by running
   `ssh-add`

2. Use the `upload.sh` script. Create one by running
   `mix firmware.gen.script`.

17:28:04~/projects/groxio/nerves/sensor_hub_poncho/sensor_hub 

$ mix burn
==> nerves
==> sensor_hub

Nerves environment
  MIX_TARGET:   rpi0
  MIX_ENV:      dev

Use 7.4 GiB memory card found at /dev/rdisk4? [Yn] y
100% [====================================] 33.80 MB in / 36.20 MB out       
Success!
Elapsed time: 4.644 s
17:32:38~/projects/groxio/nerves/sensor_hub_poncho/sensor_hub 

$ ssh nerves.local
^C
17:34:09~/projects/groxio/nerves/sensor_hub_poncho/sensor_hub 

$ ssh nerves-034e.local
$ mix nerves.info
==> nerves
==> sensor_hub

Nerves environment
  MIX_TARGET:   rpi0
  MIX_ENV:      dev

|nerves_bootstrap| Environment Package List

  Pkg:         nerves_toolchain_armv6_nerves_linux_gnueabihf
  Vsn:         1.4.3
  Type:        toolchain
  BuildRunner: {Nerves.Artifact.BuildRunners.Local, []}

  Pkg:         nerves_toolchain_ctng
  Vsn:         1.8.4
  Type:        toolchain_platform
  BuildRunner: {nil, []}

  Pkg:         nerves_system_br
  Vsn:         1.17.4
  Type:        system_platform
  BuildRunner: {nil, []}

  Pkg:         nerves_system_rpi0
  Vsn:         1.17.3
  Type:        system
  BuildRunner: {Nerves.Artifact.BuildRunners.Docker, [make_args: ["source", "all", "legal-info"]]}

|nerves_bootstrap| Loadpaths Start


Nerves environment
  MIX_TARGET:   rpi0
  MIX_ENV:      dev

|nerves_bootstrap| Environment Variable List
  target:     rpi0
  toolchain:  /Users/elay15/.nerves/artifacts/nerves_toolchain_armv6_nerves_linux_gnueabihf-darwin_x86_64-1.4.3
  system:     /Users/elay15/.nerves/artifacts/nerves_system_rpi0-portable-1.17.3
  app:        .

|nerves_bootstrap| Loadpaths End

Nerves:           1.7.12
Nerves Bootstrap: 1.10.6
Elixir:           1.12.3
|nerves_bootstrap| Info End
1 Like

Hi @elay1,

I can’t tell if you reverted the change to NervesMOTD and retried or not. It sounds like whatever is happening is related to that. I have a few ideas:

  1. Try an Elixir Circuits Quickstart image. I see a reference to Pi Zero and Pi 2 in your post. Are you using a Pi Zero 2W? If so, the image you want is the rpi3a one.
  2. What version of nerves_motd are you using? NervesMOTD runs very early on when booting and that caused problems in the past. Just want to make sure you’re using the latest.
  3. Depending on the board that you’re using, error messages get printed to the console port which is either on the UART pins or HDMI out. This is helpful when there’s anything that gets in the way of networking. However, we do like to address errors that affect networking, since this is less convenient to debug.

If you don’t have access to the console port, checking the first two might be enough to give a hint to solve this.

Hope this helps,
Frank

2 Likes

Sorry about the confusing pi naming. I am using the Raspberry Pi Zero W

I have the original project Sensor_hub firmware project which was running OK - mix upload and ssh over wifi was working. USB cable plugged into PWR skt.

I have a vanilla sensor_hub2 setup as in step 1 below which I have tried to run

1. Repeated basic project build from build-a-weather-station-with-elixir-and-nerves_B4.0.pdf - Chap2
I had reverted previously to the post to the basic project instructions from the book without using NervesMOTD and burnt the firmware to another sdcard.

moved the usb cable from PWR in socket back to USB socket.

$ mix nerves.new sensor_hub2

$ cd sensor_hub2 $ export MIX_TARGET=rpi0

$ mix deps.get ...

$ mix firmware ...

$ mix burn

$ ssh nerves.local

… ssh still hangs here
green led on rpi Zero W is flashing normally

I can still ssh into another project running on a rpi3b via wifi - no usb cable used on this rpi3b.
It feels like either my mac usb connection needs a reset or my rpi zero has blown up (after a change I made to nervesMOTD on sensor_hub and did a mix upload) that doesn’t make sense but thats how fault seemed to have started. Tried this on 2 working Raspberry Pi Zero W’s.

Tried with Elixir Circuits Quickstart image

downloaded circuits_quickstart_rpi0.fw

Burnt the image to sdcard with Etcher.

16:31:03~/projects/groxio/nerves/circuits_quickstart (main) 

$ mix burn
==> nerves
==> circuits_quickstart

Nerves environment
  MIX_TARGET:   rpi0
  MIX_ENV:      dev

Use 7.4 GiB memory card found at /dev/rdisk4? [Yn] y
100% [====================================] 23.87 MB in / 26.25 MB out       
Success!
Elapsed time: 4.661 s
16:31:29~/projects/groxio/nerves/circuits_quickstart (main) 

$ ssh circuits@nerves.local
^C

Tried with building the quickstarts firmware

$ git clone https://github.com/elixir-circuits/circuits_quickstart.git
$ cd circuits_quickstart

# Set the MIX_TARGET to the desired platform (rpi0, bbb, rpi3, etc.)
$ export MIX_TARGET=rpi0
$ mix deps.get
$ mix firmware

# Insert a MicroSD card
$ mix burn
  1. With my version of elixir and nerves I thought NervesMOTD was built in to core of Nerves so I did not need to add it to deps in mix.exs.

I tried to add it to deps and got this…

$ mix deps.get
Resolving Hex dependencies...
Dependency resolution completed:
Unchanged:
  beam_notify 1.0.0
  castore 0.1.15
  circular_buffer 0.4.0
  elixir_make 0.6.3
  gen_state_machine 3.0.0
  mdns_lite 0.8.4
  muontrap 1.0.0
  nerves 1.7.15
  nerves_motd 0.1.6
  nerves_pack 0.6.0
  nerves_runtime 0.11.8
  nerves_ssh 0.2.3
  nerves_system_bbb 2.13.2
  nerves_system_br 1.18.4
  nerves_system_osd32mp1 0.9.2
  nerves_system_rpi 1.18.2
  nerves_system_rpi0 1.18.2
  nerves_system_rpi2 1.18.2
  nerves_system_rpi3 1.18.2
  nerves_system_rpi3a 1.18.2
  nerves_system_rpi4 1.18.2
  nerves_system_x86_64 1.18.2
  nerves_time 0.4.4
  nerves_toolchain_aarch64_nerves_linux_gnu 1.5.0
  nerves_toolchain_armv6_nerves_linux_gnueabihf 1.5.0
  nerves_toolchain_armv7_nerves_linux_gnueabihf 1.5.0
  nerves_toolchain_ctng 1.8.5
  nerves_toolchain_x86_64_nerves_linux_musl 1.5.0
  one_dhcpd 1.0.0
  ring_logger 0.8.3
  shoehorn 0.8.0
  ssh_subsystem_fwup 0.6.0
  system_registry 0.8.2
  toolshed 0.2.26
  uboot_env 1.0.0
  vintage_net 0.11.5
  vintage_net_direct 0.10.4
  vintage_net_ethernet 0.10.3
  vintage_net_wifi 0.10.8
Dependencies have diverged:
* nerves_runtime (Hex package)
  the :targets option for dependency nerves_runtime

  > In mix.exs:
    {:nerves_runtime, "~> 0.11.6", [env: :prod, repo: "hexpm", hex: "nerves_runtime", targets: [:rpi, :rpi0, :rpi2, :rpi3, :rpi3a, :rpi4, :bbb, :osd32mp1, :x86_64]]}

  does not match the :targets option calculated for

  > In deps/nerves_motd/mix.exs:
    {:nerves_runtime, "~> 0.8", [env: :prod, hex: "nerves_runtime", repo: "hexpm", optional: false]}

  Remove the :targets restriction from your dep
** (Mix) Can't continue due to errors on dependencies
13:00:32~/projects/groxio/nerves/sensor_hub_poncho/sensor_hub2 

So I removed nervesMOTD from deps in mix.exs

3. Connect Console
Tried to connect Console through hdmi and a usb hub + keyboard. I haven’t got a console cable. No luck at the moment with that. I just have a flashing cursor on my monitor.

I have 2 USB ports on my 2015 macpro. I port is attached to an 8 port powered USB hub which has been working up to now. The other single port powers my external backup drive. (I know its working). I have tried disconnecting the drive and using that to test connection to both the rpi0’s

Run out of ideas at the moment.

1 Like

I have been trying to work out a way of checking that my 2 RPI0 W are still working so I downloaded Raspberry Pi OS Lite from https://www.raspberrypi.com/software/operating-systems/ and burnt it to sdcard and set up ssh access using these instructions https://www.losant.com/blog/getting-started-with-the-raspberry-pi-zero-w-without-a-monitor
and I can login via ssh on both

So the question is why does Nerves not load via a fresh firmware burn to sdcard

I have also tried to reset mDNSResponder using this link.
https://www.switchingtomac.com/macos/what-is-mdnsresponder-on-mac-and-is-it-safe/

I have also just burned a fresh image of circuits_quickstart_rpi0.zip onto another card and tried to ssh in with

ssh circuits@nerves.local

but it just hangs again.
Rpi0 led is not active either.

$ mix nerves.info
|nerves_bootstrap| Environment Package List

  No packages found
|nerves_bootstrap| Loadpaths Start


Nerves environment
  MIX_TARGET:   host
  MIX_ENV:      dev

|nerves_bootstrap| Env Start

|nerves_bootstrap| Env End

NERVES_SYSTEM is unset
NERVES_TOOLCHAIN is unset
|nerves_bootstrap| Environment Variable List
  target:     host
  toolchain:  unset
  system:     unset
  app:        .

|nerves_bootstrap| Loadpaths End

Nerves:           1.7.15
Nerves Bootstrap: 1.10.6
Elixir:           1.12.3
|nerves_bootstrap| Info End

17:07:23~/projects/groxio/nerves/sensor_hub_poncho/sensor_hub2

$ mix local.nerves
Resolving Hex dependencies...
Dependency resolution completed:
New:
  nerves_bootstrap 1.10.6
* Getting nerves_bootstrap (Hex package)
All dependencies are up to date

17:07:55.083 [info]  Application nerves_bootstrap exited: :stopped
Compiling 11 files (.ex)
Generated nerves_bootstrap app
Generated archive "nerves_bootstrap-1.10.6.ez" with MIX_ENV=prod
Found existing entry: /Users/elay15/.asdf/installs/elixir/1.12.3-otp-24/.mix/archives/nerves_bootstrap-1.10.6
Are you sure you want to replace it with "nerves_bootstrap-1.10.6.ez"? [Yn] y
* creating /Users/elay15/.asdf/installs/elixir/1.12.3-otp-24/.mix/archives/nerves_bootstrap-1.10.6
17:09:12~/projects/groxio/nerves/sensor_hub_poncho/sensor_hub2

I am looking into my SSH settings on my mac to see if that is the issue.

I can login via ssh to Raspberry Pi OS

$ ssh pi@raspberrypi.local
The authenticity of host 'raspberrypi.local (2a0e:cb01:8:5400:bdc9:7f4b:e9fe:e44e)' can't be established.
ECDSA key fingerprint is SHA256:aDiGtY18iqSszloTD70Sl9FNM4kwQ6mArv5zWUN7Yxo.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'raspberrypi.local,2a0e:cb01:8:5400:bdc9:7f4b:e9fe:e44e' (ECDSA) to the list of known hosts.
pi@raspberrypi.local's password:
Linux raspberrypi 5.10.92+ #1514 Mon Jan 17 17:35:21 GMT 2022 armv6l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Mon Mar  7 08:31:57 2022

SSH is enabled and the default password for the 'pi' user has not been changed.
This is a security risk - please login as the 'pi' user and type 'passwd' to set a new password.

pi@raspberrypi:~ $ ^C
pi@raspberrypi:~ $ exit
logout
Connection to raspberrypi.local closed.

I wonder if this is some DNS issue either in your computer or network that isn’t releasing the lease on nerves.local or something like that? Because it doesn’t sound like the problem is with the pi hardware since raspberripi.local works?

1 Like

It might be something like that. Not sure how to check that.
raspberrypi.local picks up an IP OK but ssh nerves.local just hangs.

It looks like I can’t SSH over USB data cable like I could before.
Links I am looking at suggest its something called RNDIS.
I found this link - My mac is running Catalina.

https://github.com/jwise/HoRNDIS/issues/102

Or maybe NervesSSH is the problem. But I thought this is built in to the latest version of Nerves. It was working without this before I hit this problem.

just going to try that and burn a fresh sdcard

Target.exs contains this default setup

config :shoehorn,
  init: [:nerves_runtime, :nerves_pack],
  app: Mix.Project.config()[:app]

https://github.com/nerves-project/nerves_pack
does contain NervesSSH

I have fixed the wifi connection by adding VintageNetWiFi setup to target.exs

In project directory export Wifi setttings

$ export NERVES_NETWORK_SSID=your_wifi_name
$ export NERVES_NETWORK_PSK=your_wifi_password

In Target.exs added VintageNetWiFi setup environment variables

config :vintage_net,
  regulatory_domain: "US",
  config: [
    {"usb0", %{type: VintageNetDirect}},
    {"eth0",
     %{
       type: VintageNetEthernet,
       ipv4: %{method: :dhcp}
     }},
    {"wlan0",
     %{
       type: VintageNetWiFi,
       vintage_net_wifi: %{
         key_mgmt: :wpa_psk,
         ssid: System.get_env("NERVES_NETWORK_SSID"),
         psk: System.get_env("NERVES_NETWORK_PSK")
       },
       ipv4: %{method: :dhcp}
     }}
  ]

But suspect USB Data connection is still not working.

1 Like

USB is working!

$ system_profiler SPUSBDataType
.
.
.

 RNDIS/Ethernet Gadget:

              Product ID: 0xa4a2
              Vendor ID: 0x0525  (PLX Technology, Inc.)
              Version: 5.10
              Speed: Up to 480 Mb/s
              Manufacturer: Linux 5.10.63 with 20980000.usb
              Location ID: 0x14220000 / 10
              Current Available (mA): 500
              Current Required (mA): 2
              Extra Operating Current (mA): 0

The fault was all mine - I had moved my data cable from the USB skt to the PWR skt and extended it with a switched power cable as I was connecting via wifi. When I had to burn a new sdcard I forgot that the switched extender cable did not carry data and subsequently lost wifi connection. I forgot even when I moved the cable back to the USB skt.

I learnt a lot about my mac connections and now shutdown my rpi using…

iex(1)> Nerves.Runtime.halt()

if-you-find-yourself-in-a-hole-the-first-thing-to-do-is-stop-digging-quote-1

banging_your_head_against_a_brick_wall_classic_round_sticker-rb46549076a234bb1b66705088a25c087_0ugmm_8byvr_307

2 Likes