Enables Headless Driver Station on FRC robots with ethernet connection. Design on a NanoPi NEO

- NanoPi NEO on Amazon
- NanoPi NEO Heatsink on Amazon
- 4 x M3 x 22mm Hex Socket Head Cap Screws Bolts on Amazon
- 4 x M3 x 3 x 5mm Female Press in Thread Brass Heat Set Inserts Embedment Nuts on Amazon
- Download DietPI Debian Stretch
- It is xz-compressed so you will need to install either 7zip for Windows or The Unarchiver (Macintosh). Both are free of charge and have been tested to decompress the image correctly.
- Plug in microSD card
- Flash the DietPi image
- At first, download and install balenaEtcher. This application flashes OS images to SD cards and USB drives, safely and easily on Windows, macOS, Linux.
- Start balenaEtcher and make sure you have your drive or SD card inserted into your computer. Locate and select the DietPi image. When Flashing is completed, Remove the drive resp. SD card from the PC and insert it into your NanoPi device, preparing to boot for the first time.
- Connect NanoPi to ethernet and put in SD card and connect power supply.
- SSH into NanoPi (default user = root, pw = dietpi) or use the serial monitor (USB)
ssh root@<dhcp-ip-address> - Set up new user as "frcuser" with pw "admin"
sudo adduser frcuser- SSH into the NanoPi again (default user = root, pw = dietpi). To enable SSH Client on Windows 11, please read this Microsoft article
- Set the new unix password to the default pw and continue installer until config screen comes up.
- Search for "pip" and "git client" packages and install those
- Proceed by selecting "Install" and selecting "Opt Out" when prompted for the survey. Wifi is not needed, nor is the serial port.
- Change the default SSH client to OpenSSH using dietpi-software
- SSH back into the system after reboot and run
dietpi-config - Scroll to "advanced options" then "Swapfile". Press "OK" when prompted to run DietPi-Drive_Manager.
- Select
/dev/mmcblk0p1or equivalent and enter "0" for the swapfile value - Go back out to "Network Options: Misc" and press "Boot Net Wait". Select "0: Disabled" and press OK
- Back out again and select "Network Options: Adapters" and turn off the WiFi adapter option.
- Change the "dietpi" user to "frcuser" by running
usermod -l frcuser -d /home/frcuser -m dietpi - Exit all the way out of the config and run
apt-get install avahi-daemon net-tools libnss-mdns info install-info tshark apache2 python3 sshd-server php policykit-1 libapache2-mod-dnssd. This will install the avahi hostname daemon, ifconfig, mdns resolver, http server, and packet analyzer. - Enable the http server on startup by running
systemctl enable apache2.service - Enable the avahi mdns resolver by executing
systemctl enable avahi-daemon.service - Give root permissions to "www-data" so the http server can execute systemctl commands:
sudo visudoorsudo nano /etc/sudoersand add this to the bottom:www-data ALL = NOPASSWD: /bin/systemctl - Edit the apache2 configs file for dnssd through nano using
nano /etc/apache2/mods-enabled/dnssd.loadand add this line:
LoadModule dnssd_module /usr/lib/apache2/modules/mod_dnssd.soEdit the apache2 config file through nano usingnano /etc/apache2/mods-enabled/dnssd.confand add this line:DNSSDEnable on
- Set the hostname to "headless-ds" by executing
sudo dietpi-configthen selecting Security and Hostname. Change the contents to "headless-ds" (without the quotes), then exit. - Run
apt-get updateandapt-get upgrade - Ensure that the current directory is
/home/frcuser/by issuing the commandsu - frcuserfollowed bypwd(if not change it to that usingcd /home/frcuser/as user frcuser). Clone the headless-ds Git repository usinggit clone https://github.com/AusTINCANsProgrammingTeam/Headless-DS.git. - Remove existing files and create symlinks in their place. Run
sudo rm <dest>thensudo ln -s <src> <dest>for each of the following pairs of<src><dest>:
Source <src> |
Destination <dest> |
Description |
|---|---|---|
/home/frcuser/Headless-DS/headless-ds.service |
/lib/systemd/system/headless-ds.service |
systemctl service config |
/home/frcuser/Headless-DS/team.py |
/usr/bin/team |
team number utility |
/home/frcuser/Headless-DS/index.php |
/var/www/html/index.php |
web config page |
/home/frcuser/Headless-DS/CanMan_Left.png |
/var/www/html/CanMan_Left.png |
FRC: 2158 the ausTIN CANs logo via web config |
/home/frcuser/Headless-DS/dietpi-banner |
/boot/dietpi/.dietpi-banner_custom |
ssh login banner |
/sbin/ifconfig |
/usr/bin/ifconfig |
ifconfig through frcuser |
| The following files need to be executable: /usr/bin/team and .dietpi-banner_custom |
- Ensure that the Apache web server can access the symlinked files by changing the owner to
www-data. Execute the following:
sudo chown -R www-data /home/frcuser/Headless-DS/sudo chmod -R g+s /home/frcuser/Headless-DS/
- Start the service by running
sudo systemctl start headless-ds.service - Have the service start on bootup/startup by running
sudo systemctl enable headless-ds.service
The included install.sh script will perform steps 22-33 if placed in the correct /home/frcuser/Headless-DS folder. The Git repository should be present in its entirety before this time. Run as sudo.
The "Update Device" button on the web dashboard will update the headless-ds with any new software published. The latest version will automatically be downloaded and applied. This requires an internet connection.
- Use the web interface at
http://headless-ds.local - SSH into the Pi:
ssh frcuser@headless-ds.localif on the same network and running an mdns resolver. - Restart the Pi:
sudo systemctl reboot -i - Reload systemctl configuration:
sudo systemctl daemon-reload - Start/Stop/Restart/View logs (service):
sudo systemctl <start|stop|restart|status> headless-ds.service - Check the packet output with a packet analyzer (tshark, a CLI of Wireshark)
- Run
tshark -c 100 -Y "udp". Check for packets directed at the RoboRIO address (typically 10.21.58.2) or of length 6. If you see a bunch of TCP discovery requests, the device can't find the RoboRIO but has a "correct" network configuration. If you don't see anything relevant, either the network is set up incorrectly or the packets aren't being sent for some reason.
- Run
- If the service doesn't run, try changing the "User" and "Group" in the service file to the same as the owner/user of the python script. If set up correctly, they should both be "root". If not, run
ls -la /home/frcuser/Headless-DS/headless-ds.py. The two names on the left should be the same as those in the service, editable by runningnano /lib/systemd/system/headless-ds.service. Reload the systemctl configuration and restart the service to save the changes. - If everything looks fine but no packets are being sent,
libnss-mdnsmay not have been installed. To install it without having the pi connected to the internet, download it, scp it onto the pi, and use dpkg to install it. For other packages, the architecture isarmhf, and Armbian is Debian-based, so any Debian packages built for armhf should work.wget http://http.us.debian.org/debian/pool/main/n/nss-mdns/libnss-mdns_0.10-8_armhf.debscp libnss-mdns_0.10-8_armhf.deb root@headless-ds.local:.ssh root@headless-ds.localdpkg -i libnss-mdns_0.10-8_armhf.deb
- Insert the working SD card to a linux computer
- (Optional) If the primary partition is larger than the SD card you want to copy to and has space left over, it should be resized before copying. To do this, use
gpartedon a GUI-based Linux distro with the partition in question unmounted. The same can be done from the command line using a combination ofresize2fs,e2fsck, andlvresize. - Find the end sector of the partition desired to copy. To do this, run
fdisk -l. Look for the partition you want, and record the number under "End". That number plus one is the number to be entered as the count parameter in the followingddcommand. - Run
sudo dd bs=512 if=<sdDeviceName> of=<pathToOutImgFile> status=progress count=<last sector of primary partition + 1>to get a.imgfile, an exact copy of the leading space and primary partition with offset (the 910 MiB = 954MB partition, the main one). We want to copy the partition and the space in front of it, giving the device as much space as possible. Note that the img file is not mountable because it encompasses an offset partition. The device name can be found using steps 4 and 5 above. The path to img file can be whatever you want. - Remove the SD card and insert another SD card, the one you want to copy to.
- Run the command in reverse, swapping
ifandof, but making sure your partitions are not mounted.
- To unmount a partition, run
umount /dev/mmcblk0pXas root
Under the NanoPi NEO Case directory, you will find the two STLs for printing the enclosure for this project. This case is for a NanoPi Neo with heatsink. Slice and Print using your favorite printer. Currently printed with ASA material and finest resolution.
