Skip to content

Cross compile

AutoModelCar edited this page Jul 25, 2016 · 37 revisions

Welcome to the cross-compile wiki!

Compiler

SDK

We recommend you to use the cross compiling method to build your packages and just copy build and devel folders to your cars, instead of building the codes on the odroid. Because cross compiling has more advantages:

  • It takes less time to compile on the computer
  • You can test your codes without having the car
  • Multiple users can work on a car.
  • You can keep your codes in your computer and if you have a git repositories you can always update your repositories.

Make a folder called “odroid-x2” in /opt, copy the sdk for odroid and compiler for ARM processors in the odroid-x2 folder.

Install catkin tools

Dependencies

you may need the packages below for cross-compiling:

sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu `lsb_release -sc` main" > /etc/apt/sources.list.d/ros-latest.list'
wget http://packages.ros.org/ros.key -O - | sudo apt-key add -
sudo apt-get update
sudo apt-get install python-catkin-tools
sudo apt-get install ros-indigo-camera-info-manager
sudo apt-get install ros-indigo-pcl-ros
sudo apt-get install libc6-armel-cross libc6-dev-armel-cross
sudo apt-get install binutils-arm-linux-gnueabi
sudo apt-get install libncurses5-dev
sudo apt-get install gcc-arm-linux-gnueabihf
sudo apt-get install g++-arm-linux-gnueabihf
sudo apt-get install lib32stdc++6
sudo apt-get install lib32z1
sudo apt-get update

catkin_ws_user

Clone catkin_ws_user folder in your computer,

  $ git clone https://github.com/AutoModelCar/catkin_ws_user.git

and set the catkin tools for cross compiling using lines below:

cd catkin_ws_user
catkin config --profile odroid -b odroid-build -d odroid-devel -i odroid-install
catkin config --profile odroid --cmake-args  -DCMAKE_TOOLCHAIN_FILE=`pwd`/src/Toolchain-arm-linux-gnueabihf.cmake
catkin config --profile odroid --extend /opt/odroid-x2/sdk/opt/ros/indigo/
catkin config --merge-devel --profile odroid
catkin config --profile odroid --install

Now you can cross compile the packages using:

catkin build --profile odroid

clean build

catkin clean -b --profile odroid

Hint: You may see some errors like below:

  /opt/odroid-x2/sdk/opt/ros/indigo/include/ros/time.h:58:50: fatal error: boost/math/special_functions/round.hpp: No such file or directory
  #include <boost/math/special_functions/round.hpp>

There is a bug using catkin build for cross compiling! To solve these errors, refresh the src/Toolchain-arm-linux-gnueabihf.cmake file by:

touch src/Toolchain-arm-linux-gnueabihf.cmake

You may have to do this step several times to cross compile all the packages for the first time. After that you will not see the error "Abandoned" error anymore.

Copy to the Odroid

After that use the replace.sh file to rename some hard-coded path inside the odroid-build and odroid-devel folders. You may need to modify the replace.sh file and rename some paths and id to your computer path and the model car ip. Open the replace.sh file and change the line below to the model car ip:

 scp -r $var/catkin_ws_user/src/ root@192.168.1.199:./catkin_ws_user/
 scp -r $var/catkin_ws_user/odroid-devel/ root@192.168.1.199:./catkin_ws_user/

Then you can copy both folders inside your catkin_ws_user folder in the odroid. Be sure that you have catkin_ws_user folder in the Odroid. If you do not have make the directory:

 $ ssh root@192.168.1.199
 $ mkdir catkin_ws_user

Then run the ./replace.sh script from your computer:

./replace.sh

Update the .bashrc and autostart.sh

After copying your odroid-devel folder you have to make sure the following CMAKE_PREFIX_PATH in the odroid-devel/_setup_util.py file on odroid looks like this: (should be automatically done by ./replace.sh script now)

# environment at generation time
CMAKE_PREFIX_PATH = '/opt/ros/indigo;/root/catkin_ws/devel/'.split(';')

Remember to add/change the source file inside the .bashrc and autostart.sh in the model car. Add the line below to both folders:

source ./catkin_ws_user/odroid-devel/setup.bash

Useful commands

   ssh-copy-id root@192.168.1.199
   ssh-add ~/.ssh/id_rsa

Clone this wiki locally