Raspberry Pi Zero W – Backup USB Terminal

I often get lazy and don’t want to look up the IP of some PI that I just installed the OS on, nor do I want to go find the monitor.. This is where the USB SSH terminal comes in super handy.

This is a Linux thing, so if you have windows, I’m sorry. Google it more.

So step one is to install the ISO of your choice. I used the Raspberry Pi OS Lite version from the official source at: https://www.raspberrypi.org/software/operating-systems/, even though I don’t like Debian. The configuration files are all in the wrong place… anyways.. it’s stable and runs well.

Install is fairly straight forward. Unzip the download, and run dd. Replace the img with your image, and sdX is your SD card.

dd bs=1M if=2021-01-11-raspios-buster-armhf.img of=/dev/sdX conv=fsync

This will create two drives on your device, The first being boot, and the 2nd being root. Let’s start in boot. Touch the SSH file, and edit the config.txt to add the dtoverlay line.

touch /Volumes/boot/ssh
echo 'dtoverlay=dwc2' >> /Volumes/boot/config.txt

Now open cmdline.txt using your favorite text editor, which of course is Vim.

vi /Volumes/boot/cmdline.txt

add

modules-load=dwc2,g_ether

after “rootwait”, and before anything else. make sure there is only one space between all of them otherwise it will get borked. Now I’m going to be lazy and hook up both Wifi and USB Networking, so I’m going to configure the USB on a static IP address

vi /etc/dhcpcd.conf

Skip down to the bottom and add a USB configuration. In this example, I’m not specifiying the DNS entry for the USB, because I want it to pull data though the wifi when possible.

interface usb0
static ip_address=192.168.7.2
static routers=192.168.7.1
#static domain_name_servers=192.168.7.1

I don’t have a 192.168.7.xxx network anywhere, so I’m using that. Now I just go and configure my USB network on my PC to be a Static of 192.168.7.1, and I’m done. Plug the USB cable into the center USB connection, and wait for the light to turn on. Now I can SSH into the board without issue.

  ssh pi@192.168.7.2

Raspberry Pi Zero W – Python issues

So I’m working on a quick and dirty Raspberry Pi Zero W based status light, and ran into some issues.

First of all, the version that ships with Raspberian OS light is version 2.7 of python.. that’s old, so let’s fix it.

After logging in I do a:

sudo bash

This is because I’m lazy and don’t want to type it all the time. I’ve been using unix for too long to not have a root account.. bad practice, but I’ve been using it that way since SCO unix was cool.

First thing is to run the update by doing the following:

root@raspberrypi:~# apt update
root@raspberrypi:~# apt list --upgradable
root@raspberrypi:~# apt upgrade

Now make sure Python 3 is installed

root@raspberrypi:~# apt install python3

but after the update, let’s check…

root@raspberrypi:~# python --version
 Python 2.7.16
root@raspberrypi:~# ls -l /usr/bin/python
 lrwxrwxrwx 1 root root 7 Mar 4 2019 /usr/bin/python -> python2

Well… that’s dumb… but looking into it more it looks like /usr/bin/python is just a symbolic link.

root@raspberrypi:~# rm /usr/bin/python
root@raspberrypi:~# ln -s /usr/bin/python3 /usr/bin/python
root@raspberrypi:~# ls -l /usr/bin/python
 lrwxrwxrwx 1 root root 16 Jan 18 07:01 /usr/bin/python -> /usr/bin/python3
root@raspberrypi:~# python --version
 Python 3.7.3

That part is all fixed now…