Skip to content

Instantly share code, notes, and snippets.

@docprofsky
Last active March 9, 2017 16:14
Show Gist options
  • Save docprofsky/bc69b9a54f559e7e6301c13b96dd9b27 to your computer and use it in GitHub Desktop.
Save docprofsky/bc69b9a54f559e7e6301c13b96dd9b27 to your computer and use it in GitHub Desktop.

Set up build stuff

Make prefix

sudo mkdir /opt/roborio
sudo chown schuyler:staff /opt/roborio
# cp -r /usr/local/arm-frc-linux-gnueabi/ /opt/roborio/

Environment variables

export TOOLCHAIN=~/development/first/allwpilib/arm-toolchain.cmake
export PREFIX=/opt/roborio
export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig

Boost

configure to build for RoboRIO

$ cat tools/build/src/user-config.jam
using gcc : arm : arm-frc-linux-gnueabi-g++ ;

build boost

./bootstrap
./b2 --debug-configuration --without-python link=shared runtime-link=shared threading=multi --toolset=gcc-arm target-os=linux

Install boost

./b2 --without-python link=shared runtime-link=shared threading=multi --toolset=gcc-arm target-os=linux  --prefix=$PREFIX install

output of b2

Performing configuration checks

    - 32-bit                   : yes (cached)
    - arm                      : yes (cached)

Building the Boost C++ Libraries.


    - symlinks supported       : yes (cached)
    - C++11 mutex              : no  (cached)
    - lockfree boost::atomic_flag : yes (cached)
    - Boost.Config Feature Check: cxx11_auto_declarations : no  (cached)
    - Boost.Config Feature Check: cxx11_constexpr : no  (cached)
    - Boost.Config Feature Check: cxx11_defaulted_functions : no  (cached)
    - Boost.Config Feature Check: cxx11_final : no  (cached)
    - Boost.Config Feature Check: cxx11_hdr_mutex : no  (cached)
    - Boost.Config Feature Check: cxx11_hdr_tuple : no  (cached)
    - Boost.Config Feature Check: cxx11_lambdas : no  (cached)
    - Boost.Config Feature Check: cxx11_noexcept : no  (cached)
    - Boost.Config Feature Check: cxx11_nullptr : no  (cached)
    - Boost.Config Feature Check: cxx11_rvalue_references : no  (cached)
    - Boost.Config Feature Check: cxx11_template_aliases : no  (cached)
    - Boost.Config Feature Check: cxx11_thread_local : no  (cached)
    - Boost.Config Feature Check: cxx11_variadic_templates : no  (cached)
    - has_icu builds           : no  (cached)
warning: Graph library does not contain MPI-based parallel components.
note: to enable them, add "using mpi ;" to your user-config.jam
    - zlib                     : no  (cached)
    - bzip2                    : no  (cached)
    - iconv (libc)             : yes (cached)
    - icu                      : no  (cached)
    - icu (lib64)              : no  (cached)
    - native-atomic-int32-supported : yes (cached)
    - native-syslog-supported  : yes (cached)
    - pthread-supports-robust-mutexes : yes (cached)
    - compiler-supports-visibility : yes (cached)
    - gcc visibility           : yes (cached)
    - long double support      : yes (cached)
warning: skipping optional Message Passing Interface (MPI) library.
note: to enable MPI support, add "using mpi ;" to user-config.jam.
note: to suppress this message, pass "--without-mpi" to bjam.
note: otherwise, you can safely ignore this message.

Component configuration:

    - atomic                   : building
    - chrono                   : building
    - container                : building
    - context                  : building
    - coroutine                : building
    - coroutine2               : building
    - date_time                : building
    - exception                : building
    - fiber                    : building
    - filesystem               : building
    - graph                    : building
    - graph_parallel           : building
    - iostreams                : building
    - locale                   : building
    - log                      : building
    - math                     : building
    - metaparse                : building
    - mpi                      : building
    - program_options          : building
    - python                   : not building
    - random                   : building
    - regex                    : building
    - serialization            : building
    - signals                  : building
    - system                   : building
    - test                     : building
    - thread                   : building
    - timer                    : building
    - type_erasure             : building
    - wave                     : building

...patience...
...patience...
...patience...
...patience...

Libusb

commands

./bootstrap.sh
./configure --host=arm-frc-linux-gnueabi --disable-udev --prefix=$PREFIX
make
make install

Pixy

git clone https://github.com/TeamCautionRobotics/pixy.git
cd pixy
git checkout java
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=$PREFIX \
    -DCMAKE_TOOLCHAIN_FILE=$TOOLCHAIN \
    -DBOOST_ROOT=$PREFIX \
    -DCMAKE_PREFIX_PATH=$PREFIX/lib \
    ..
make
make install

The CMake command for pixy has to be run twice. Ignore the error the first time. See this for more information.

Installing on the RoboRIO

Run this command on the RoboRIO

mkdir /opt/roborio
echo '/opt/roborio/lib' > /etc/ld.so.conf.d/pixy.conf

Back on your build computer:

tar cf - lib | ssh admin@roboRIO-1492-FRC.local tar xf - -C /opt/roborio/
ssh admin@roboRIO-1492-FRC.local ldconfig

Copy the libraries to to the RoboRIO. We use tar, not scp to preserve symlinks (lib.so -> lib.so.1.2.3). Rsync is not installed on the RoboRIO

Installing the pre-built Pixy Libraries and Dependencies

Java has some packaging issues that need to be figured out. swig -c++ -java -package org.usfirst.frc.team1492.robot -outdir . pixy.i libpixy_java.so will have to be rebuilt. Reason:

$ arm-frc-linux-gnueabi-nm -gC /opt/roborio/lib/libpixy_java.so
0000b02c T Java_org_usfirst_frc_team1492_robot_pixyJNI_BlockArray_1cast
0000b04c T Java_org_usfirst_frc_team1492_robot_pixyJNI_BlockArray_1frompointer
...
scp roborio-libpixy_java-csharp.tar.gz admin@roboRIO-1492-FRC.local:~

Copy the tarball of all of the libraries to the RoboRIO

SSH into the RoboRIO: ssh admin@roboRIO-1492-FRC.local

tar xzvf roborio-libpixy_java-csharp.tar.gz -C /
echo '/opt/roborio/lib' > /etc/ld.so.conf.d/pixy.conf
ldconfig
sed -i".bak" -e "s,\$CMD_FILE,<(sed 's_/usr/local/frc/lib/_\&:/opt/roborio/lib/_' &)," -e '1i#!/bin/bash' /usr/local/frc/bin/frcRunRobot.sh

Improperly escaped old version of sed command to use over ssh.

ssh admin@roboRIO-1492-FRC.local sed -i".bak" "'s,\$CMD_FILE,<(sed \"s_/usr/local/frc/lib/_\&:/opt/roborio/lib/_\" &),'" /usr/local/frc/bin/frcRunRobot.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment