PilotPi with Ubuntu Server
:::warning Ubuntu Server on RPi 4B consumes a lot of current and generates a lot of heat. Design for better heat dissipation and high power consumption when using this hardware. :::
Developer Quick Start
OS Image
Both armhf and arm64 arch are supported.
armhf
arm64
Latest OS
Please refer to official cdimage page for any new updates.
First boot
When setting up RaPi's WiFi for the first time we recommended using a wired Ethernet connection between your home router and RPi, and a monitor and keyboard.
Before booting
Mount the SD card onto your computer and modify the network settings. Please follow the official instruction here.
Now plug the SD card onto your Pi and boot for the first time. Make sure you have shell access to the RPi - either SSH connection over wired Ethernet, or direct accessing with keyboard and monitor.
WiFi region
First install required package:
Edit the file /etc/default/crda
to change the correct WiFi region. Reference List
Then your Pi will able to join your WiFi network after reboot.
Hostname and mDNS
Let's set up hostname at first.
Change the hostname to whatever you like. Then install the package required by mDNS:
Perform a reboot.
Regain the accessibility through WiFi connection after the above operation.
Password-less Auth (Optional)
You may want to setup passwordless auth as well.
Setting up OS
config.txt
The corresponding file in Ubuntu is /boot/firmware/usercfg.txt
.
Replace the file with:
cmdline.txt
On Ubuntu Server 20.04:
On Ubuntu Server 18.04 or earlier, nobtcmd.txt
and btcmd.txt
should both be modified.
Find console=/dev/ttyAMA0,115200
and remove that part to disable the login shell on serial interface.
Append isolcpus=2
after the last word. The whole file will then look like:
The above line tells the Linux kernel do not schedule any process on CPU core 2. We will manually run PX4 onto that core later.
Reboot and SSH onto your Pi.
Check UART interface:
There should be /dev/ttyAMA0
, /dev/ttySC0
and /dev/ttySC1
.
Check I2C interface:
There should be /dev/i2c-0
and /dev/i2c-1
Check SPI interface:
There should be /dev/spidev0.0
.
rc.local
In this section we will configure the auto-start script in rc.local. Note that we need to create this file, as it is not present on a fresh Ubuntu OS.
Append the content below to the file:
Save and exit. Then set the correct permissions:
:::note Don't forget to turn off the switch when it is not needed! :::
CSI camera
:::warning Enable CSI camera will stop anything works on I2C-0. :::
Append the following line at the end of file:
Building the code
To get the very latest version onto your computer, enter the following command into a terminal:
:::note This is all you need to do just to build the latest code. :::
Set RPi upload target
Set the IP (or hostname) of your RPi using:
or
Additionally, we need to set the username:
Build for armhf target
Build the executable file:
Then upload it with:
Alternative build method for armhf (using docker)
If you are compiling for the first time with docker, please refer to the official docs.
Execute the command in firmware folder:
:::note mDNS is not supported within docker. You must specify the correct IP address every time when uploading. :::
:::note If your IDE doesn't support ninja build, NO_NINJA_BUILD=1
option will help. You can compile without uploading too. Just remove upload
target. :::
It is also possible to just compile the code with command:
Build for arm64 target
:::note This step requires aarch64-linux-gnu
tool-chain to be installed. :::
Build the executable file:
Then upload it with:
Alternative build method for arm64 (using docker)
If you are compiling for the first time with docker, please refer to the official docs.
Execute the command in PX4-Autopilot
folder:
:::note mDNS is not supported within docker. You must specify the correct IP address every time when uploading. :::
:::note If your IDE doesn't support ninja build, NO_NINJA_BUILD=1
option will help. You can compile without uploading too - just remove the upload
target. :::
It is also possible to just compile the code with command:
Manually run PX4
Connect over SSH and run it with:
Now PX4 is started with multi-rotor configuration.
If you encountered the similar problem executing bin/px4
on your Pi as following:
Then you should compile with docker instead.
Before proceeding to next step, clear the existing building at first:
Then go back to the corresponding chapter above.
Post-configuration
Please refer to the instructions here
Last updated