If you want to install and interact with a raspberry pi using only a USB cable and nothing else (no UART hardware, no physical keybord, hdmi-screen, wifi, network cable etc), this guide is for you. We will set up wifi and enable ssh while we’re at it just because we can.
We are going to:
Download and install the latest raspbian-jessie-lite on an SD-card
Configure the pi to act as a USB serial device
Configure wpa_supplicant with your wifi AP’s credentials
Create symlinks to enable systemd services on boot (wpa_supplicant, ttyGS0 and ssh)
This guide has only been tested on a Raspberry Pi Zero W, but should work fine on other Pis.
Download and transfer raspbian-jessie-light to an sdcard (assuming /dev/mmcblk0 here)
Remove the sd-card and insert it in your Pi, connect a USB cable in the “USB Data port”, then connect it to your computer. Run journalctl -f on your host machine to see what happens then the Pi boots. After a while, you will probably end up seeing
1
May 06 21:04:54baconkernel: cdc_acm 1-2:2.0: ttyACM0: USBACMdevice
Go ahead now and connect to the device using screen /dev/ttyACM0 115200 and interact with your raspi. In case you’ve never used screen before: exit using <Ctrl>-a d.
1
2
pi@raspberrypi:~$ uname -a
Linux raspberrypi 4.4.50+ #970 Mon Feb 20 19:12:50 GMT 2017 armv6l GNU/Linux
Alternative solution using qemu-arm-static (not recommended)
While writing this guide I used qemu-arm-static in order to enable the systemd services. This turned out to be really messy (segfault in strange places etc). If you want to try this approach, feel free to change the symlink steps above to the following:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Install qemu-user-static. On archlinux with AUR:
$ pacaur -S qemu-user-static
# Ubuntu:
$ sudo apt-get install qemu-user-static
# Copy qemu-arm-static to the root filesystem
$ sudo cp $(which qemu-arm-static) ./usr/bin/
# Enter the pi's root filesystem by running the local bash(dash) using `qemu-arm-static`