Like I wrote the other day, the Zero supports USB OTG, and you can get it to act as a virtual Ethernet port by simply appending
dtoverlay=dwc2 at the end of
config.txt to patch the device tree and add
cmdline.txt just after
That’s the work of a few seconds, and when hooked up to another computer, the Zero will simply set itself up with an IPv4 local link address and announce itself over Bonjour – which works wonderfully with my Mac and most Linux boxes, including other Pis. All I need to do is
ssh [email protected] and I’m set.
If I need to install or update something, it’s trivial to share my network connection to it – but that just doesn’t work under Windows for me. I already have enough trouble with Docker, the Hyper-V virtual switch and access to corporate Wi-Fi (right now, for whatever reason, they’re mutually exclusive), so I decided not to fiddle with my work laptop that deeply and figure out a way to know the Zero’s link-local address.
Fortunately, I had a Scroll pHAT lying around, so all I really needed to do was solder a set of headers onto the Zero…
…and tweak the network config (on
usb0) to run a little script to display the IP address on it:
#!/usr/bin/env python from scrollphat import write_string, scroll, clear, set_brightness from socket import socket, AF_INET, SOCK_DGRAM from time import sleep def get_ip_address(): """Fool the network stack into telling us what the outbound interface is without actually connecting anywhere""" s = socket(AF_INET, SOCK_DGRAM) s.connect(("22.214.171.124", 53)) return s.getsockname() set_brightness(3) write_string(" IP: %s " % get_ip_address()) for i in range(0,128): sleep(0.15) scroll() clear()
It’s a bit clunky and marquees have always been a tad cheesy, but it works and I can now move on to prototyping a few things. Also, I had to dim down the brightness a tad because those LEDs pack a serious punch. So if everything else fails, I now have myself an Internet-enabled reading light…
TechReady is an internal Microsoft event that happens twice a year. I decided to skip the summer edition to be here for the kids during their vacation, but sessions are livestreamed and recorded, so I’ve been watching videos at 1.5x speed every evening for the past week, which is a lot more comfortable than actually flying over and spending a week or two in Seattle. ↩︎