Installing Software on the Snapdragon

To get the platform running with the complete VIO system running, multiple pieces are required. The following is an overview of the different versions used. Detailed installation instructions are provided below.

Software Tested version Link/commit ID
ROS indigo here
MAVROS 0.23.1 here
MAVLink release/kinetic/mavlink/2018.5.5-0 here
PX4 master here
Snap VIO master here
Snapdragon-Linux 3.1.3.1 here
DSP Firmware 3.1.3.1 here
Qualcomm MV 1.0.2 here

Prevent Bricking

To prevent the system from hanging on boot because of anything wrong with the ADSP firmware, do the following changes before going any further. Plug your snapdragon into your computer via USB and open the android debug shell:

  1. adb shell

Note Note that the Snapdragon Flight needs to be powered by an external power source. The power over USB is not sufficient. As always, take your props off before you apply power!

Edit the file /usr/local/qr-linux/q6-admin.sh:

  1. vim /usr/local/qr-linux/q6-admin.sh

Comment out the following lines:

  1. # Wait for adsp.mdt to show up
  2. #while [ ! -s /lib/firmware/adsp.mdt ]; do
  3. # sleep 0.1
  4. #done

Finally:

  1. # Don't leave until ADSP is up
  2. #while [ "`cat /sys/kernel/debug/msm_subsys/adsp`" != "2" ]; do
  3. # sleep 0.1
  4. #done

Update Linux Image

Warning Updating the Linux image on your Snapdragon will erase everything.

Get the latest Flight_x.x_JFlash.zip from here and unzip it. In the unzipped folder is a script that has to be used to update the Linux image. Power your Snapdragon Flight, connect it using a micro USB cable and run:

  1. sudo ./jflash.sh

Update DSP Processor Firmware

Get the latest Flight_x.x_qcom_flight_controller_hexagon_sdk_add_on.zip from here and unzip it.

In the unzipped folder, run:

  1. ./installfcaddon.sh
  2. adb shell
  3. sudo reboot

Clone PX4 Firmware & Build

On your PC, clone the PX4 firmware repo and build it as described below.

If you haven’t yet cloned the Firmware repo:

  1. cd ~
  2. mkdir src
  3. cd src
  4. git clone git@github.com:PX4/Firmware.git

Once you’re in your local copy of the Firmware:

  1. cd Firmware
  2. git submodule update --init --recursive
  3. export FC_ADDON=<location-of-extracted-flight-controller-addon>
  4. make clean
  5. make atlflight_eagle_default
  6. make atlflight_eagle_default upload
  7. adb push ROMFS/px4fmu_common/mixers/quad_x.main.mix /usr/share/data/adsp

Install ROS

Set up your Snapdragon Flight to connect to your local Wi-Fi network so you can easily clone git repositories directly onto it. To do so, open an adb shell and edit the file /etc/wpa_supplicant/wpa_supplicant.conf and add your local network settings:

  1. adb shell
  2. vim /etc/wpa_supplicant/wpa_supplicant.conf

There, add your Wi-Fi settings:

  1. network={
  2. ssid="my existing network ssid"
  3. psk="my existing password"
  4. }

Finally, set the system to station mode. Also, editing the station network interface config file will keep your ssh terminal from lagging: (all inside adb shell)

  1. /usr/local/qr-linux/wificonfig.sh -s station
  2. echo 'wireless-power off' |sudo tee -a /etc/network/interfaces.d/.qca6234.cfg.station
  3. sudo reboot

Now, to install ROS, start by setting your locale, sources.list and keys (in adb or ssh shell)

  1. export LANGUAGE=en_US.UTF-8
  2. export LANG=en_US.UTF-8
  3. sudo locale-gen en_US.UTF-8
  4. sudo dpkg-reconfigure locales
  5. sudo update-locale LANG=C LANGUAGE=C LC_ALL=C LC_MESSAGES=POSIX
  6. sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu trusty main" > /etc/apt/sources.list.d/ros-latest.list'
  7. sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
  8. sudo apt-get update
  9. sudo apt-get install ros-indigo-ros-base #(yields error)
  10. sudo apt-get -f -o Dpkg::Options::="--force-overwrite" install

Edit your ~/.bashrc to source the ros environment:

  1. sudo chown -R linaro /home/linaro
  2. echo "source /opt/ros/indigo/setup.bash" >> /home/linaro/.bashrc
  3. source .bashrc

Install some Extra Packages

Before you can use ROS, you will need to initialize rosdep. Rosdep enables you to easily install system dependencies for source you want to compile and is required to run some core components in ROS:

  1. sudo rosdep init
  2. rosdep update

After installing ROS, the OpenCL library gets installed by ROS as well which causes a conflict with camera pipeline. To fix this, do the following:

  1. sudo dpkg -r libhwloc-plugins
  2. sudo dpkg -r ocl-icd-libopencl1:armhf

Now, set up your workspace:

  1. source .bashrc
  2. mkdir -p /home/linaro/ros_ws/src
  3. cd ros_ws/src
  4. catkin_init_workspace
  5. cd ..

Create a Swap Directory on the Snapdragon

In order not to run out of memory during compilation of MAVROS, you need to create a swap file:

  1. sudo fallocate -l 1G /mnt/1GB.swap
  2. sudo mkswap /mnt/1GB.swap
  3. sudo swapon /mnt/1GB.swap
  4. echo '/mnt/1GB.swap none swap sw 0 0' |sudo tee -a /etc/fstab

In order to get MAVROS and MAVLink running, you need to install some Python tools and then clone the code and check out the proper commits for compatibility.

  1. sudo apt-get install python-pip
  2. sudo apt-get install python-rosinstall
  3. sudo apt-get update
  4. sudo apt-get install python-rosinstall-generator
  5. sudo apt-get install python-catkin-tools
  6. rosinstall_generator --rosdistro kinetic mavlink | tee /tmp/mavros.rosinstall
  7. rosinstall_generator --rosdistro kinetic --upstream mavros | tee -a /tmp/mavros.rosinstall
  8. wstool init src
  9. wstool merge -t src /tmp/mavros.rosinstall
  10. wstool update -t src -j4
  11. rosdep update
  12. sudo rosdep install --rosdistro indigo --from-paths src --ignore-src -y
  13. cd src/mavros
  14. git checkout 0.23.1
  15. cd ../mavlink
  16. git checkout release/kinetic/mavlink/2018.5.5-0
  17. cd ../..
  18. catkin build
  19. echo 'source /home/linaro/ros_ws/devel/setup.bash' >> /home/linaro/.bashrc
  20. source ../bashrc

catkin build is necessary because it creates the /home/linaro/ros_ws/devel directory. This is where the generated libraries and the executables will be generated. It also generates a new bash setup script which includes the appropriate environment variables for using the “ros_ws” workspace.

Install geographiclib

MAVROS requires geographiclib to be installed on the system. Follow these steps to install it on the Snapdragon:

  1. mkdir -p /usr/share/geographiclib
  2. /home/linaro/ros_ws/src/mavros/mavros/scripts/install_geographiclib_datasets.sh
  3. mkdir /usr/share/geographiclib/GeographicLib
  4. cd /usr/share/geographiclib
  5. mv geoids/ GeographicLib/

Install Snap VIO

First, download (to your PC) version 1.0.2 Snapdragon Machine Vision SDK from here. The package name will be: mv<version>.deb.

Push the deb package to the snapdragon and install it:

  1. adb push mv<version>.deb /home/linaro
  2. adb shell sync
  3. adb shell
  4. dpkg -i /home/linaro/mv<version>.deb
  5. mkdir /opt/qcom-licenses

The Machine Vision SDK will need a license file to run. Obtain a research and development license file from here. The license file needs to be placed in the following folder on target: /opt/qcom-licenses/.

Push the license file to the target using the following command:

  1. adb push snapdragon-flight-license.bin /opt/qcom-licenses/
  2. adb shell sync

Now, we are ready to clone the snap vislam node:

  1. adb shell
  2. cd ~/ros_ws/src
  3. git clone https://github.com/PX4/ros-examples
  4. catkin build