This guide assumes the following:
- You have flashed the basic Arch Linux ARM image to a MicroSD card
- You've configured WiFi using any one of the numerous guides online - see here for an example.
- You are using a Raspberry Pi Zero W.
We need to set some kernel command-line options so that our the right modules will be available to us on the Raspberry Pi.
- First mount the first partition of the MicroSD card.
- Add the line
dtoverlay=dwc2
to the bottom ofconfig.txt
- Add the word
dwc2
to the end ofcmdline.txt
- Unmount, eject, put back in the Raspberry Pi and carry on!
If you're unfamiliar with Arch Linux, then the only real difference (as far as we will be concerned) is the package manager, pacman
.
- First,
su
into root (remember, the default root password is root). - Next, update the entire system with
pacman -Syu
. This might take a little while as the RPi Zero is only small. - Now, you can install the required packages with
pacman -S sudo git dnsmasq golang
.
- We need to create the working folder for USB Ninja:
mkdir /lib/usbninja
- Optional Step: To make development easier, I prefer to change ownership of this file so I don't have to be root all the time:
chown -R alarm:alarm /lib/usbninja
- Create the USB Ninja config directory on partition one with:
mkdir /boot/usbninja
- Again, you might want to
chown -R alarm:alarm /boot/usbninja
, but it isn't necessary.
- Now you can create the Systemd service that will run at startup:
nano /etc/systemd/system/startup.service
:
[Unit]
Description=Startup Script for the USB Ninja
After=basic.target
Before=network.target
[Service]
ExecStart=/lib/usbninja/main
[Install]
WantedBy=basic.target
- We also want to add some lines to the bottom of
/etc/dnsmasq.conf
:
...
interface=usb0
dhcp-range=10.0.0.2,10.0.0.2
dhcp-option=3,10.0.0.1
- Now go back to
/lib/usbninja
. If you changed ownership toalarm
then you canexit
to leave the root account, otherwise stay as you are. - Clone this repo with
git clone https://github.com/xcellerator/usbninja.git build
andcd build/src
. - Run the
./build_all.sh
script which will attempt to compile the binaries and copy them to/lib/usbninja/
All that's left to do is enable startup.service
so it runs at startup.
(sudo) systemctl enable startup.service
If you've followed these instructions and nothing more, then you don't have any options set! This is okay in the sense that everything will still work - the USB Ninja will startup in serial
mode with all default settings. Most likely, you are going to want to change this, so you'll need to create an options.txt
(and hid.txt
) file in /boot/usbninja/
. You can find a commented example in /boot/usbninja/build/config/options.txt
or here. Alternatively, you can write your own by reading OPTIONS.md.