Configuring Beagle Bone Blue as Flight Controller Unit

Beagle Bone Blue as flight Controller

The most important component of any drone is the Flight Controller Unit (FCU). I have dedicated an entire chapter to explaining the configuration of Beagle Bone Blue as Flight Controller. All sensors and drone electrical components revolve mainly around FCU. Beagle Bone Blue (BBB) is an all-in-one Linux-based general purpose robotics computer with small form factor (3.5″ x 2.15″ board) running Octavo OSD3358 microprocessor. It also supports wifi/Bluetooth for networking, inbuilt IMU/barometer, power management and regulation. It has the option of being powered from 9-18 volts DC power source via barrel jack. It requires JST type connectors for interfacing with sensors It has all the commonly-needed buses for additional peripherals in embedded applications. The key aspect for the choice of this board is its fully open source and actively supported by a strong community, the real-time performance, flexible networking, and rich set of robotics-oriented capabilities making it versatile, fast, streamlined, affordable, and fun.

Technical specifications of Beagle Bone Blue (BBB) list
Technical specifications of Beagle Bone Blue (BBB) list
Technical specifications of Beagle Bone Blue (BBB) pictorial
Technical specifications of Beagle Bone Blue (BBB) pictorial
Port wise pinout details of Beagle Bone Blue (BBB)
Port wise pinout details of Beagle Bone Blue (BBB)
Pinout details of Beagle Bone Blue (BBB)
Pinout details of Beagle Bone Blue (BBB)

            This Beagle Bone Blue will be configured as Flight Controller Unit (FCU). It will run Debian Linux Operating System (OS) and Ardupilot autopilot stack as application. This process has been explained in subsequent sub chapters and paras.

Preparing Beagle Bone Board with OS (Debian Linux)

            Preparing SD Card                We need to format an SD Card preferably 16/32 GB and flash Linux Debian Operating System. Download bone-debian-9.12-console-armhf-2020-04-01-1gb.img and flash it on SD card of 16/32 Gb using Balena Etcher or any other such application. I have used Raspberry Pi imager to do the same.

Flashing SD card for Beagle Bone Blue through Raspberry Pi Imager
Flashing SD card for Beagle Bone Blue through Raspberry Pi Imager

            Insert SD card and boot Beagle Bone Blue             Connect Beagle Bone Blue with micro-USB cable to USB port of laptop. Use putty application for ssh access of Beagle Bone Blue. Default ip access to access Beagle Bone Blue is 192.168.7.2

Remote access of Beagle Bone Blue though Putty from windows laptop
Remote access of Beagle Bone Blue though Putty from windows laptop

            Accessing Beagle Bone Blue on ssh Use below mentioned default credentials to access Beagle Bone Blue-

Default username – Debian
Default password – temppwd

Successful login into Debian Linux running on Beagle Bone Blue from the Windows Laptop
Successful login into Debian Linux running on Beagle Bone Blue from the Windows Laptop

            Connecting through wifi for wireless access in future        After logging in to Beagle Bone Blue through ssh for the first time, use the below mentioned command to connect it on wifi for internet access. Also the board can also be accessed on wifi.

Step1  We need to allow the debian user to sudo without having to enter the password every (subsequent) time, enter the following command
echo "debian ALL=(ALL) NOPASSWD: ALL" | sudo tee -a /etc/sudoers.d/debian >/dev/null

Step 2 The Wifi SSID and password be automated and put in a script so that subsequent access can be on Wifi without the need of connecting with micro USB cable
sudo -s

Check Beagle Bone Blue detects the wifi, in my case wifi name is YASH1
connmanctl services | grep 'YASH1' | grep -Po 'wifi_[^ ]+'

Wifi network named YASH1 detected by Beagle Bone Blue
Wifi network named YASH1 detected by Beagle Bone Blue

Step3  Add Wifi SSID and passphrase details
cat >/var/lib/connman/wifi.config
[service_<your hash>]
Type = wifi
Security = wpa2
Name = YASH1
Passphrase = 7350604575

Adding Wifi details to wifi.config file using cat command
Adding Wifi details to wifi.config file using cat command

Step 4   Ctrl-D and ping www.google.com to check internet and DNS resolution is working successfully.

Connected to internet through YASH1 Wifi and successful DNS resolution by Beagle Bone Blue
Connected to internet through YASH1 Wifi and successful DNS resolution by Beagle Bone Blue

Step 5     Restart Beagle Bone Blue. Use any IP Scanner application on wifi to detect IP of Beagle Bone Blue over wifi network.

Beagle Bone Blue successfully detected over local LAN with allotted IP Address
Beagle Bone Blue successfully detected over local LAN with allotted IP Address

Step 6. Use Putty to access it over that that IP which was scanned and found during step 5 above. Using Putty Application to access ssh over wifi. (No need of any micro-USB cable now). Use same login credentials as above.

Remote access to Beagle Bone Blue over Wifi using Putty application
Remote access to Beagle Bone Blue over Wifi using Putty application

Default username – Debian
Default password – temppwd

Successful access to Beagle Bone Blue over ssh over Wifi
Successful access to Beagle Bone Blue over ssh over Wifi
Successful login to Beagle Bone Blue over ssh over Wifi
Successful login to Beagle Bone Blue over ssh over Wifi

Building autopilot stack on Beagle Bone Blue

Configuring OS on Beagle Bone Blue          Update and upgrade Debian Linux OS and install requisite tools/applications
sudo apt-get -y update

Debian Linux successfully updated
Debian Linux successfully updated

sudo apt-get -y dist-upgrade

Debian Linux successfully upgraded
Debian Linux successfully upgraded

Installing CPU Frequency Scaling Utility              Now we need to install CPU Frequency scaling utility which enables Operating systems to scale up or down CPU frequency to save power. It can be scaled up incase of load on CPU
sudo apt-get install -y cpufrequtils git

Installing CPU Frequency scaling utility
Installing CPU Frequency scaling utility

To get pre-built kernels. Real-time kernel is software which manages the time of microprocessor thereby ensuring that time-critical events required as Flight Controller Unit (FCU) can be processed efficiently. It simplifies the design of embedded systems and makes Linux act like  Real Time Operating System as it allows the system to be divided into multiple independent elements called tasks. These scheduling of tasks can be done in real-time.
cd /opt/scripts && git pull

Installing real-time kernels
Installing real-time kernels

sudo /opt/scripts/tools/update_kernel.sh --lts-4_19 --bone-rt-channel

Updating real-time kernels 4_19
Updating real-time kernels 4_19
Updating real-time kernels 4_19
Updating real-time kernels 4_19

Now we need to specify the device tree binary which is to be used at Linux startup
sudo sed -i 's/#dtb=/dtb=am335x-boneblue.dtb/g' /boot/uEnv.txt

Now we need to specify the device tree overlays
sudo sed -i 's|#dtb_overlay=/lib/firmware/<file8>.dtbo|dtb_overlay=/lib/firmware/BB-I2C1-00A0.dtbo\n#dtb_overlay=/lib/firmware/BB-UART4-00A0.dtbo\n#dtb_overlay=/lib/firmware/BB-ADC-00A0.dtbo|g' /boot/uEnv.txt

Now we need to specify the U-Boot overlay
sudo sed -i 's|uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-14-TI-00A0.dtbo|#uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-14-TI-00A0.dtbo|g' /boot/uEnv.txt

sudo sed -i 's|#uboot_overlay_pru=/lib/firmware/AM335X-PRU-UIO-00A0.dtbo|uboot_overlay_pru=/lib/firmware/AM335X-PRU-UIO-00A0.dtbo|g' /boot/uEnv.txt

To set clock frequency
sudo sed -i 's/GOVERNOR="ondemand"/GOVERNOR="performance"/g' /etc/init.d/cpufrequtils

Setting clock frequency
Setting clock frequency

We can disable Bluetooth as we don’t need it for FCU.
sudo systemctl disable bb-wl18xx-bluetooth.service

We can maximize the SD cards existing partition  
sudo /opt/scripts/tools/grow_partition.sh

Maximize system partition
Maximize system partition

sudo reboot

I have always carried out wiping the eMMC boot sector to ensure resolution of  RCOutputAioPRU.cpp:SIGBUS error

sudo dd if=/dev/zero of=/dev/mmcblk1 bs=1M count=10

Wiping of eMMC boot sector
Wiping of eMMC boot sector

Now we update the bootloader through the script
sudo /opt/scripts/tools/developers/update_bootloader.sh

Updating the bootloader
Updating the bootloader

Putting Ardupilot Autoilot Stack application on  Beagle Bone Blue

Step1  Before we begin the Ardupilot autopilot application stack build up, we need to understand the Ardupilot environment and its configuration file to be created at location /etc/default/ardupilot. The UARTS map to pin configuration on Beagle Bone Blue side is as below:-

UART map to pins
UART map to pins

The Ardupilot autopilot application supports upto 8 x UARTs. The mapping done by me for the utilization is as per table below: –

Suggested UART mapping between Beagle Bone Blue and Ardupilot application
Suggested UART mapping between Beagle Bone Blue and Ardupilot application

The IP Addresses in this table are of Ground Control Station (GCS) and must be changed as the existing network. This scheme of IP Addresses have been explained in later chapter on concept of MAVlink over VPN. The concept of MAVlink has also been explained in following chapters.

Step2  After getting the table ready as per our requirement, we now need to create ardupilot environment file with the data from table above: –
sudo nano /etc/default/ardupilot (later for editing use sudoedit /etc/default/ardupilot)

Add the blow mentioned lines
TELEM1="-A udp:192.168.7.1:1194"
GPS="-B /dev/ttyO2"
TELEM2="-C /dev/ttyO1"
TELEM3="-D udp:100.96.1.34:1194"
RANGER="-F /dev/ttyO5"

Creating Ardupilot environment file as per table above
Creating Ardupilot environment file as per table above

Ctrl+O and enter to save configuration followed by and Ctrl+X to exit

Step 3   Create system file for running Arducopter (version of Ardupilot) as a service at startup
sudo nano /lib/systemd/system/arducopter.service

Add the below mentioned lines
[Unit]
Description=ArduCopter Service
After=networking.service
StartLimitIntervalSec=0
Conflicts=arduplane.service ardurover.service antennatracker.service

[Service]
EnvironmentFile=/etc/default/ardupilot
ExecStartPre=/usr/bin/ardupilot/aphw
ExecStart=/usr/bin/ardupilot/arducopter $TELEM1 $TELEM2 $TELEM3 $GPS $RANGER

Restart=on-failure
RestartSec=1
[Install]
WantedBy=multi-user.target

Creating arducopter.service for execution at startup as service
Creating arducopter.service for execution at startup as service

Ctrl+O and Ctrl+X to save configuration

Step 4  We need to create ardupilot directory where we will build and compile the Ardupilot autopilot stack.
sudo mkdir -p /usr/bin/ardupilot

Step 5  We need to create Ardupilot hardware configuration file aphw at location /usr/bin/ardupilot/aphw, which is run by the services prior to running the Ardupilot executables.
sudo nano /usr/bin/ardupilot/aphw

Add the below mentioned lines
#!/bin/bash
# aphw
# ArduPilot hardware configuration.

#/bin/echo 80 >/sys/class/gpio/export
#/bin/echo out >/sys/class/gpio/gpio80/direction
#/bin/echo 1 >/sys/class/gpio/gpio80/value
/bin/echo pruecapin_pu >/sys/devices/platform/ocp/ocp:P8_15_pinmux/state

The lines 5 to 7 has been commented out by me as I don’t wish to activate or switch on power to the Beagle Bone Blue’s  +5V servo rail. I have made a conscious effort to ensure that power of 5V is fed directly from DC-DC convertor to the sensor or peripheral and nothing is powered from Beagle Bone Blue. This ensures that Beagle Bone Blue is protected from any power related issues. However, the option of doing that exists in case we uncomment the lines. In order to draw power from Beagle Bone Blue esp 5V, the recommended input power is 12V-18V through DC Barrel jack. 5V snt available when powering BBB through micro USB cable. I have provided 12V to Beagle Bone Blue through Barrel jack just to ensure enough power. Also, the only module to draw power directly from Beagle Bone Blue is the 4G LTE module connected on the USB 2.0 of Beagle Bone Blue (5V and 500mA)

Creating arducopter hardware configuration file
Creating arducopter hardware configuration file

Ctrl+O and enter to save configuration followed by and Ctrl+X to exit

Step 6   Give permission to the file/folder

sudo chmod 0755 /usr/bin/ardupilot/aphw
sudo chmod 0755 /usr/bin/ardupilot/a*

Step 7 Compiling Ardupilot on Beagle Bone Blue itself. We need to install the requisite packages before:-
sudo apt-get install g++ make pkg-config python python-dev python-lxml python-pip

Installing pre-requisites for compiling Ardupilot application on Beagle Bone Blue itself.
Installing pre-requisites for compiling Ardupilot application on Beagle Bone Blue itself.
Installing pre-requisites for compiling Ardupilot application on Beagle Bone Blue itself
Installing pre-requisites for compiling Ardupilot application on Beagle Bone Blue itself
Pre-requisites installed successfully
Pre-requisites installed successfully

sudo pip install future

Installing Future
Installing Future

git clone https://github.com/ArduPilot/ardupilot

Downloading Ardupilot repository from github successful
Downloading Ardupilot repository from github successful

cd ardupilot
git branch -a  # <-- See all available branches.  Press q to exit.

Selecting Ardupilot branch to compile. For me I have compiled latest 4.0.7 stable and also 4.1 (Beta)
Selecting Ardupilot branch to compile. For me I have compiled latest 4.0.7 stable and also 4.1 (Beta)

I have compiled Ardupilot 3.6, 4.0.5, 4.0.7 all being stable versions. Later to support the mm Wave radar which is a 3D radar, I have compiled 4.1.0 (Beta) version. Hence, select the Ardupilot version one wishes to compile.

git checkout Copter-4.0  # <-- Arducopter 4.0 is selected by this command

Git submodule init to initialize our local configuration file, and git submodule is used to update to fetch all the data from Ardupilot github repository 

git submodule update --init --recursive

Updating submodule of Ardupilot
Updating submodule of Ardupilot

Now we use the waf command which is a build automation tool. It is designed to assist in the automatic compilation and installation of application/computer software. Now we name the compilation folder Blue as its Beagle Bone Blue.
./waf configure --board=blue  # <-- BeagleBone Blue. 

The compilation will happen in folder named blue
The compilation will happen in folder named blue

The compilation starts from the step below:-
./waf

The compilation process is on
The compilation process is on
The compilation process is on
The compilation process is on
The compilation process is successfully completed
The compilation process is successfully completed

The compilation for Arducopter 3.6 took about 2 hours, while for Arducopter 4.0.5, (stable) Arducopter 4.0.7 (stable) and Arducopter 4.1.0 (Beta) took almost 12 hours !!!! Now we copy the compiled bin file to the execution folder and give permission.

sudo cp ./build/blue/bin/a* /usr/bin/ardupilot
sudo chmod 0755 /usr/bin/ardupilot/a*

Step 8.  Now we enable Arducopter service after successfully compiling it on Beagle Bone Blue itself.

sudo systemctl enable arducopter.service

The arducopter.service enabled successfully
The arducopter.service enabled successfully

To start Arducopter service, 
sudo systemctl start arducopter.service

To check arducopter service status
sudo systemctl status arducopter.service

To disable and stop arducopter service 
sudo systemctl disable arducopter.service
sudo systemctl stop arducopter.service

To restart service after making any change will require following command,
sudo systemctl daemon-reload
sudo systemctl restart arducopter. service

About the Author

9 thoughts on “Configuring Beagle Bone Blue as Flight Controller Unit

  1. Hi!

    We are currently also working on using the BBBlue as FC for ArduPilot on a plane. Is there a reason not to use the most recent real-time kernel 5.10 but 4.19 instead?

    Thanks and Greetings

  2. This is fantastic. I have been wanting to build a quad with BBB but there are gaps in the docs for my skill level, and this is definitely an improvement. Thanks

  3. What does this line in aphid do? I don’t think you explain it:
    /bin/echo pruecapin_pu >/sys/devices/platform/ocp/ocp:P8_15_pinmux/state

  4. Hello,

    Thank you. Has anyone updated this idea to newer kernels on the BBBlue and with Bullseye along with Python3?

    I have installed the required binary via rsync and upload but failed to understand how to make the motors move via transmitter/receiver within the MP source. Anyway, I have been working on the ideas revolving around ArduCopter for about three years. I never got past the checks on ArduCopter and MP source. Calibrations are these checks I am discussing.

    Anyway, thank you for posting this info. in the forum. I clicked the link and read over the info. you have listed.

    If you ever get around to it, please (I beg of you…ha) add how to make the board actually fly. I got as far as transmitter calibrations and then received nothing as output, no error, no issues. But…the calibration failed, i.e. as I could not move my motors via the BBBlue and trans/receiver combo.

    Seth

  5. Hi this post seems very helpful, I have BBblue and required omponents to bild quad, I think i will need some help. This is just a test if you are available.
    Hoping a reply soon.

  6. That’s the best description I’ve ever seen of how to setup a BBB for ArduPilot. Fantastic.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may also like these