I finally managed to set up a raspberry pi 3 as a remote agent. Since I had some difficulty on the road, I’ll share my setup script here to help others with this setup.
Comments
I’m using a system wide installation of platformio instead of the virtualenv installation, because a) it’s the only way I could get it to work and b) I’m not using the raspi for anything else.
Some of the insallation steps can take quite a while on the raspi, be patient!
Prerequisites
Raspberry Pi 3
SD card with at least 4GB space (2GB is not enough)
rpi-imager installed
Steps
Use rpi-imager to prepare the sd card
Select “Raspberry Pi OS (32-bit) Lite”
This guide was created using Version: August 2020
Mount the sd card and open the boot partition
Setup wifi (if needed)
in the boot partition, create ẁpa_supplicant.conf file with the wlan config:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=<Insert 2 letter ISO 3166-1 country code here>
network={
ssid="<Name of your wireless LAN>"
psk="<Password for your wireless LAN>"
}
In the boot partition, create an empty file called ssh to enable ssh on boot.
Insert the card into the raspberry pi and connect the power. The raspi will boot up and do the initial setup.
Connect via ssh
ssh pi@raspberrypi
the initial password is raspberry
Set a new password
passwd
Install platformio
# update system
sudo apt update
sudo apt upgrade -y
# install required packages
sudo apt install python3-pip libffi-dev libssl-dev
# install platformio
sudo pip3 install platformio
# install required libraries for the remote agent
pio remote agent
Get the platformio auth token (you can do this on any computer)
# login to platformio
pio account login
# get the auth token
pio account token
save the token for the next step
Install the remote agent as a service
create a file /etc/systemd/system/pio-remote.service:
[Unit]
Description=pio remote agent
Requires=network-online.target
After=network-online.target
[Service]
Type=simple
User=pi
Group=pi
Environment="PLATFORMIO_AUTH_TOKEN=<insert your auth token from last step>"
WorkingDirectory=/home/pi
ExecStart=/usr/local/bin/platformio remote agent start
Restart=always
[Install]
WantedBy=multi-user.target
Start the service
sudo systemctl start pio-remote
Check that the service is running
systemctl status pio-remote
In case of errors, check the error log
journalctl -e -t platformio
Done!
The service should be running and you can access the remote agent from any platformio installation by logging in to your account.
Let me know if you have any questions or issues regarding this guide.
Thanks for that tutorial, helped me to install the remote agents without errors.
Great tutorial, just one misspelling here “sudo apt install pyhton3-pip libffi-dev libssl-dev” should be “python3-pip”
Rainer
no Problem, but perhaps can you help me, Starting the service following your tutorial, I get errors. Just did cut an paste from your tutorial and added the key I generated.
error:
● pio-remote.service - pio remote agent
Loaded: error (Reason: Unit pio-remote.service failed to load properly: Invalid argument.)
Active: inactive (dead)
Oct 24 16:40:57 CAN-B systemd[1]: /etc/systemd/system/pio-remote.service:9: Invalid environment assignment, ignoring: PLATFORMIO_AUTH_T
Oct 24 16:40:57 CAN-B systemd[1]: /etc/systemd/system/pio-remote.service:15: Missing '='.
Oct 24 16:41:09 CAN-B systemd[1]: /etc/systemd/system/pio-remote.service:9: Invalid environment assignment, ignoring: PLATFORMIO_AUTH_T
Oct 24 16:41:09 CAN-B systemd[1]: /etc/systemd/system/pio-remote.service:15: Missing '='.
~
Mhm, remote development via SSH is not really what I want. I want to work locally and build all platforms, not only the Pi but also other ones. The Pi platform has to be built remote, the other ones can be built locally.
There is a new dependency for getting this install to work: apt install rustc
It would be really nice if the required dependencies were listed in the official install guide
UPDATE:
I’ve updated my remote pi, and in principle it still works. I just made a few adjustments to the install script. I added instructions to update platformio and pip python packages, so the same script can be used to update the installation. pip upgrade is required to make sure requirements can be compiled successfully.
# update system
sudo apt update
sudo apt upgrade -y
# install required packages
sudo apt install python3-pip libffi-dev libssl-dev
# install platformio
sudo pip3 install -U platformio pip
# install required libraries for the remote agent
pio remote agent