Skip to main content

Quick Setup

Quick Setup on Debian Wheezy

NOTE: This is a quick setup. For more details and explanations on each item, see individual pages linked to at the bottom of the page.

Update BBB to the Latest Image

NOTE: This was done and confirmed from Mac OSX 10.10 with tcsh.

Download the Debian OS Image

Official latest Debian SD or EMMC image. http://beagleboard.org/latest-images

Or get the latest from this. http://elinux.org/Beagleboard:BeagleBoneBlack_Debian#Debian_Releases

Copy the image to SD

# Find out you SD card device's name
df -h

# Unmount the disk partition (but not the disk itself).
# Change it to fit your SD card device's name.
diskutil unmount /dev/disk7s1

# Write the image to the SD Card by decompressing it with xzcat|gzcat|zcat and piping the decompressed data to dd.
xzcat bone-debian-7.8-lxde-4gb-armhf-2015-07-28-4gb.img.xz | sudo dd of=/dev/disk6 bs=1m

# To Flash eMMC, use eMMC flasher image
xzcat BBB-eMMC-flasher-debian-7.5-2014-05-14-2gb.img.xz | sudo dd of=/dev/disk7 bs=1m

# Small letter 'm' is used for BSD based systems like Mac OSX to specify block size for the dd command. On Linux, use `bs=1M` instead of `bs=1m`
xzcat BBB-eMMC-flasher-debian-7.5-2014-05-14-2gb.img.xz | sudo dd of=/dev/disk7 bs=1M
# Wait around 15 min for dd to finish copying the image.

Flash the image to eMMC on BBB

  • Insert the SD card to BBB
  • Only connect the power to BBB (Must use external power supply. USB power will NOT work!
  • Push and hold the boot button while plugging in the power
  • Wait for the flashing to stop (all 4 LEDs should be lit when finished)
  • Remove SD card and reboot BBB

Boot off of SD Card

When using debian or ubuntu snappy bootable images, there's no need to flash the eMMC as you can simply insert the SD and boot off of it.

Connect to BBB

Install the drivers on host Mac

You need to install FTDI and RNDIS drivers on your Mac first. The driver installers are located on the FAT disk that gets mounted on your Mac when BBB is atteched via USB.

NOTE: On older version of the disk image, unmount the FAT disk from you Mac to use the USB as network IF or serial console instead of Mass Storage class device. This is not needed with latest images.

Connect to BBB via SSH

By default, BBB will assign 192.168.7.2 to it's USB interface (usb0). On the host machine, assign 192.168.7.1 to the USB interface of the BBB. Login via ssh if the network interface comes up.

ssh root@192.168.7.2
# The root password is blank for default beaglebone OS images.

For Debian Wheezy image

ssh debian@192.168.7.2
(password: temppwd)

Or login via serial console:

screen /dev/tty.usbmodem* 115200

Basic Configuration

User Account

# Add user account and add it to admin group for sudo privilegde
sudo adduser userid
sudo /usr/sbin/usermod -G admin userid

Network Setup

# If using Ethernet for Internet connection, plug an Ethernet cable in and do the following
ifconfig eth0 up
dhclient eth0

# If not using DCHP, setup network interface and setup routing manually
ifconfig eth0 10.0.0.111
ifconfig eth0 netmask 255.255.255.0
route -n
route add default gw 10.0.0.1

# Change Hostname
vim /etc/hostname
vim /etc/hosts
# Change the network settings loaded at boot
vim /etc/network/interfaces

Expand Partition

Do this if your SD Card is larger than the OS image size.

cd /opt/scripts/tools/
git pull
sudo ./grow_partition.sh
sudo reboot

Update Packages

apt-get install ntpdate
sudo /usr/sbin/ntpdate -b -s -u asia.pool.ntp.org

# Generate locale to avoid spurious perl warnings.
# `apt-get upgrade` should do this for you.
locale-gen en_US en_US.UTF-8

# Update packages
sudo apt-get update
sudo apt-get upgrade

## Install basic packages
apt-get install vim less git zip cpufrequtils

# Also install other packages you use

# Reboot to make sure deamons are reloaded
reboot

Disable Unwanted Init Scripts

update-rc.d -f apache2 remove
update-rc.d -f xrdp remove
# etc.

Adjust CPU Clock

# Make sure you reset the CPU Frequency back to 1GHz (1,000 Hz)
cpufreq-info

Edit the config file. This file may not exist, in which case you should just create it.

vim /etc/default/cpufrequtils

# Add the following line to the file and save
GOVERNOR="performance"

OR do this in a startup script

cpufreq-set -f 1000MHz

Reboot and confirm the change

shutdown -r now

# Check to see if the setting is reflected.
cpufreq-info

Update Kernel

Debian Wheezy:

# On beaglebone default debian images
# Check current kernel version
uname -r

cd /opt/scritps/tools/
git pull
./update_kernel.sh
reboot

uname -r
# You should see something like `3.8.13-bone79`

# Install headers for building drivers
apt-get install linux-headers-$(uname -r)

Setup WiFi

NOTE: Be sure to do this before updating the compiler to v4.8 as described below

Download the driver

Updated version of rtl8812au driver (official driver from 2013 is outdated): https://github.com/senzai/rtl8812au

Install the Driver

mkdir ~/src
cd ~/src/
git clone git://github.com/senzai/rtl8812au
# Build the WiFi dongle driver
cd rtl8812au
make ARCH=arm

# Test it
insmod 8812au.ko

make install

reboot

Setup WiFi network

# Install usbutils
apt-get install usbutils

# Check settings
lsusb
lsmod
iwconfig

vim /etc/network/interfaces

# WiFi
auto wlan0
iface wlan0 inet dhcp

Test settings

/etc/init.d/networking reload
/etc/init.d/networking restart
ifconfig wlan0 up

# Reboot to make sure the settings stick
reboot

Setup APM:Copter

Install Support Stuff

Update Compiler to compile APM code on BBB

C++11 code started to creep into APM codebase in early 2015. Use apt-pinning to get gcc 4.8 with C++11 support from Jessie repo.

vim /etc/apt/sources.list

# add the following line to the file above.
deb http://ftp.uk.debian.org/debian/ jessie main non-free contrib

Edit the apt pref. to tweak the priority.

vim /etc/apt/preferences

Package: *
Pin: release a=wheezy
Pin-Priority: 900

Package: gcc*
Pin: release a=jessie
Pin-Priority: 910

Update apt and install gcc

sudo aptitude update
sudo aptitude install gcc-4.8/jessie
sudo aptitude install g++-4.8/jessie

# Register alternatives so that the linker, etc. can find proper components to call.
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 20
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.6 20
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 50
update-alternatives --install /usr/bin/arm-linux-gnueabihf-g++ arm-linux-gnueabihf-g++ /usr/bin/g++-4.8 50

Clone ArduPilot to BBB

# Clone git repo
git clone git://github.com/diydrones/ardupilot.git

# OR if using a git repo hosted on local network, get it via SSH
git clone user@host:~/your/git/repo/directory localreponame

# Check out your branch
git checkout feature/NAV_IDLE/3.3.1

Install Devicetree Stuff

Make sure cape support is compiled in the kernel

zcat /proc/config.gz | grep CONFIG_CAPE_BEAGLEBONE
# should return: CONFIG_CAPE_BEAGLEBONE=y

Add PXF dtbo to build target

cd ~/ardupilot/Tools/Linux_HAL_Essentials/devicetree/pxf/

vim Makefile

# add BB-PXF-01-00A0.dtbo to all: target

Build .dtbo files

make clean
make
make install

# Load .dtbo files
./startup.sh load
./startup.sh reload

vim /boot/uEnv.txt

# uncomment the line below
##Disable HDMI/eMMC (v3.8.x)
cape_disable=capemgr.disable_partno=BB-BONELT-HDMI,BB-BONELT-HDMIN,BB-BONE-EMMC-2G

# Add the following line
# This doesn't work, so use startup script to load capes
#cape_enable=capemgr.enable_partno=BB-PXF-01

Copy the .dtbo

This doesn't work, so use startup script to load capes

# `make intsall` should have copied it
# cp ~/ardupilot/Tools/Linux_HAL_Essentials/devicetree/pxf/BB-PXF-01-00A0.dtbo /lib/firmware

vim /etc/default/capemgr

# add the following line
# CAPE=BB-PXF-01

Reboot to see if cape loads fine

reboot

# check dmesg and bone_capemgr slots for loading errors
# Loaded capes should be indicated with 'L' on the status column
dmesg
cat /sys/devices/bone_capemgr.9/slots

# To remove a cape
echo -6 > /sys/devices/platform/bone_capemgr/slots

Build and Run APM

NOTE: The latest APM codebase requires g++11 which is not available with g++4.7, the latest available on wheezy, so complie it on desktop linux with arm cross compiler package and copy the binary over to BBB. or install gcc 4.8 as explained above.

Install build tools

apt-get install make gawk

Build APM

cd ardupilot/ArduCopter
make pxf-quad -j 2

Run it

# Once it's been compiled, you can just run the program on BBB
./ArduCopter.elf

Startup Options:

#   -A switch: Primary Telemetry Port
#   -B switch: GPS Port
#   -C switch: Secondary Telemetry Port
./ArduCopter.elf -A udp:192.168.7.1:6000 -B /dev/ttyO5 -C /dev/ttyO4

Launch Copter on OS boot

mkdir ~/logs

vim /etc/init.d/start-copter.sh

#!/bin/bash
# The following is based on apm4-startup.sh by Victor Mayoral Vilches of Erle Robotics

echo BB-BONE-PRU-05 > /sys/devices/bone_capemgr.*/slots
echo BB-SPI0-PXF-01 > /sys/devices/bone_capemgr.*/slots
echo BB-SPI1-PXF-01 > /sys/devices/bone_capemgr.*/slots
echo BB-UART5 > /sys/devices/bone_capemgr.*/slots
echo BB-UART4 > /sys/devices/bone_capemgr.*/slots
echo BB-UART2 > /sys/devices/bone_capemgr.*/slots
echo am33xx_pwm > /sys/devices/bone_capemgr.*/slots
echo bone_pwm_P8_36 > /sys/devices/bone_capemgr.*/slots
echo BB-ADC   > /sys/devices/bone_capemgr.*/slots

sleep 1
cd /root
(
    date
    init 3
    while :; do
        # Set CPU at max speed
        cpufreq-set -f 1000MHz
        ./ArduCopter.elf -A udp:10.0.0.110:6000 -B /dev/ttyO5 -C /dev/ttyO4
    done
) >> ~/logs/copter.log 2>&1

Register init script

chmod a+x /etc/init.d/start-copter.sh

update-rc.d start-copter.sh defaults

# Reboot too see if the script is running
reboot

ps aux

To restart APM

systemctl kill start-copter.service
systemctl restart start-copter.service

More Detailed Descriptions of Each Steps

  1. Update Beaglebone Black
  2. Build RT Kernel
  3. Install WiFi Driver
  4. Build-ArduPilto on BBB
  5. Setup OpticalFlow