This guide will include a step-by-step guide on how to set up an board running Armbian to act as a gadget device (similar to how it's been advertized with the Pi Zero)
You will need a:
- Armbian supported board with an OTG port
- A temporary spare monitor, USB keyboard and display cable (or serial, if you'd like that instead)
- USB cable
- (depending on board) Seperate power cable
The first step would be to download the apropriate Armbian image for your board and flash it to an SD card. In my case, I'll be using the mainline edition of the OrangePi One image.
While downloading/flashing, please check if your device is powered via the OTG port. Some devices are and some aren't:
For example, the Raspberry Pi Zero can be powered via the USB and the Orange Pi One can't.
Once you've figured that out, please plug in cables accordingly. PLUGGING IN A POWER CABLE WHILST HAVING POWER FROM THE OTG PORT COULD FRY THE BOARD/PORT, BE WARNED (my Pi Zero suffered this fate)
For the serial people, you already know what to do; but for monitor users, plug in your display and USB keyboard into your board and start it up.
Once booted, do the inital setup. The password, user accounts and so on.
Type in reboot
and once booted again login as root with the password you've set.
Now, once logged in type in:
armbin-config
You'll get a configuration screen and a complaint about no internet. Just ignore it and you'll see the Configuration Utility screen.
Within this screen, you'll select System
> Hardware
and enable the following (by pressing Space):
usbhost0
usbhost1
usbhost2
usbhost3
Once done, press Enter to apply changes. Use Escape to return back and exit out of the utility.
(We aren't done yet though)
With your favorite text editor open /boot/armbianEnv.txt
After the overlays
line add:
extraargs=console=ttyGS0,115200 modules-load=dwc2,g_cdc
(if you want a USB serial for debugging)
and
modules-load=dwc2,g_ether
(without USB serial device)
Exit and save.
Since NetworkManager likes to create a mess (with this setup in particular) by default, we'll use systemd-networkd, which I find to work well with this. (Sorry non-systemd people :()
So, naturally the first step is to disable NetworkManager:
systemctl disable --now NetworkManager
And since systemd-networkd relies on config files, you must create a config file.
Create a /etc/systemd/network/20-usb0.network
with the following content:
[Match]
Name=usb0
[Network]
DHCP=yes
Now run
systemctl enable systemd-networkd
systemctl enable getty@ttyGS0 (if you enabled the serial, which you should)
and reboot.
Since your OrangePi r whatever will depend on the hosts network, make sure that the network that shows up on your PC is Shared. On Windows, you do this by entering into Network device properties and enabling the shared network for that "network adapter".
On Linux, nmtui
, Edit a connection
, Network name 1
, change the "IPv4 CONFIGURATION"
to Shared
and "IPv6 CONFIGURATION" to Ignore
. Expand the IPv4 CONFIGURATION
tab and
enable "Require IPv4 addressing for this connection"
Once rebooted, access the device via serial (I told you this one is better) with
sudo screen /dev/ttyACM0 115200
on Linux and Putty on Windows with serial speed set to 115200.
Log in. And run accordingly:
sudo apt update
sudo apt upgrade
sudo apt install avahi-daemon libnss-mdns libnss-mymachines
sudo systemctl enable --now ssh
Check your hostname (mine is orangepione
) and log out.
Unplug everything that's not needed, leaving only the USB + (optionally) the power cable.
ssh yourpishostname.local
Have fun.