Skip to content

Instantly share code, notes, and snippets.

@itsdsk
Created February 14, 2018 10:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itsdsk/2859febbbc934ae98645e256e635533f to your computer and use it in GitHub Desktop.
Save itsdsk/2859febbbc934ae98645e256e635533f to your computer and use it in GitHub Desktop.

note: there are unsolved errors with this method - two are described below but I expect more to pop up with further testing. please take this as a warning and follow the steps knowing they're a bit of a bodge!

Compile and run the openFrameworks empty example on a headless Raspberry Pi 3 running Debian Stretch

  1. Create a resinOS device (see guide here) and clone a sample project to your computer e.g. this.

  2. Install modified openFrameworks and its dependencies by replacing the contents of Dockerfile.template with:

# use raspbian stretch image as container base
FROM resin/raspberrypi3-debian:stretch
 
# install deps 
RUN apt-get update && apt-get -y install \ 
    libraspberrypi-dev \
    raspberrypi-kernel-headers \
    mesa-utils \
    libgl1-mesa-glx \
    libgl1-mesa-dri \
    rsync \
    git \
    wget \
    build-essential \
    make \
    xvfb \
    libxrender1 \
    libxtst6 \
    libxi6 \
  && apt-get upgrade \
  && apt-get clean \
  && rm -rf /var/lib/apt/lists/*

# enable systemd init system in the container
ENV INITSYSTEM on

# install openframeworks
RUN cd ~ && git clone --depth=1 https://github.com/itsdsk/openFrameworks.git
RUN cd ~/openFrameworks/scripts/linux/debian && ./install_dependencies.sh
RUN cd ~/openFrameworks/scripts/linux/debian && ./install_codecs.sh
RUN cd ~/openFrameworks/scripts/linux && ./download_libs.sh --platform linuxarmv6l
RUN cp ~/openFrameworks/scripts/templates/linuxarmv6l/Makefile ~/openFrameworks/examples/templates/emptyExample/
ENV DISPLAY :1
RUN Xvfb :1 -screen 0 256x256x24+32 & \
    export DISPLAY=":1" \
  && cd ~/openFrameworks/examples/templates/emptyExample/ \
  && make HOST_ARCH=armv6l PLATFORM_ARCH=armv6l -j2 -s
  1. Enable OpenGL driver by setting the envelope variables (find more info here):
Key Value
RESIN_HOST_CONFIG_gpu_mem 196
RESIN_HOST_CONFIG_dtoverlay vc4-kms-v3d
  1. Start virtual framebuffer in the terminal of the container and set the display environment variable:
Xvfb :0 -screen 0 1280x720x24 -fbdir /var/tmp +extension GLX &
export DISPLAY=":0"
  1. Run the OF empty example from the terminal:
cd ~/openFrameworks/examples/templates/emptyExample/ && make RunRelease

Known issues

  • The app will successfully save a screenshot in the normal openFrameworks way, but querying colours of the app's display via the command-line gives this error:
root@bdd360b:/app# convert /var/tmp/Xvfb_screen0 -format '%[pixel:p{x,y}]' info:-
convert-im6.q16: no decode delegate for this image format `' @ error/constitute.c/ReadImage/504.
convert-im6.q16: no images defined `info:-' @ error/convert.c/ConvertImageCommand/3258.

The command above works (returns the RGB colour of the pixel at x,y) on Processing sketches run in the same system.

  • The whole OF library recompiles when building an app after the container has started despite it already being compiled and functional. It seems to be caused by the compile flags in the cross compilation of OF (in the Dockerfile) being in a different order on the RPi:
-O3 -DNDEBUG -Wall -Werror=return-type -std=c++14 -DGCC_HAS_REGEX -march=armv6 -mfpu=vfp -mfloat-abi=hard -fPIC -ftree-vectorize -Wno-psabi -pipe -DOF_USING_GTK -DOF_USING_GTK -DOF_USING_MPG123 -DTARGET_RASPBERRY_PI -DSTANDALONE -DPIC -D_REENTRANT -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -DTARGET_POSIX -DHAVE_LIBOPENMAX=2 -DOMX -DOMX_SKIP64BIT -DUSE_EXTERNAL_OMX -DHAVE_LIBBCM_HOST -DUSE_EXTERNAL_LIBBCM_HOST -DUSE_VCHIQ_ARM -I/opt/vc/include -I/opt/vc/include/IL -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux -pthread -D_REENTRANT -pthread -I/usr/include/gstreamer-1.0 -I/usr/include/AL -I/usr/include/arm-linux-gnueabihf -I/usr/include/rtaudio -I/usr/include/alsa -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0-I/usr/include/dbus-1.0 -I/usr/lib/arm-linux-gnueabihf/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/glib-2.0 -I/usr/lib/arm-linux-gnueabihf/glib-2.0/include -I/root/openFrameworks/libs/glm/include -I/root/openFrameworks/libs/glm/include/glm -I/root/openFrameworks/libs/glm/include/glm/gtc -I/root/openFrameworks/libs/glm/include/glm/simd -I/root/openFrameworks/libs/glm/include/glm/gtx -I/root/openFrameworks/libs/glm/include/glm/detail -I/root/openFrameworks/libs/json/include -I/root/openFrameworks/libs/kiss/include -I/root/openFrameworks/libs/tess2/include -I/root/openFrameworks/libs/utf8/include -I/root/openFrameworks/libs/utf8/include/utf8 -I/root/openFrameworks/libs/openFrameworks -I/root/openFrameworks/libs/openFrameworks/sound -I/root/openFrameworks/libs/openFrameworks/app -I/root/openFrameworks/libs/openFrameworks/video -I/root/openFrameworks/libs/openFrameworks/events -I/root/openFrameworks/libs/openFrameworks/gl -I/root/openFrameworks/libs/openFrameworks/graphics -I/root/openFrameworks/libs/openFrameworks/utils -I/root/openFrameworks/libs/openFrameworks/3d -I/root/openFrameworks/libs/openFrameworks/communication -I/root/openFrameworks/libs/openFrameworks/types -I/root/openFrameworks/libs/openFrameworks/math

-O3 -DNDEBUG -Wall -Werror=return-type -std=c++14 -DGCC_HAS_REGEX -march=armv6 -mfpu=vfp -mfloat-abi=hard -fPIC -ftree-vectorize -Wno-psabi -pipe -DOF_USING_GTK -DOF_USING_GTK -DOF_USING_MPG123 -DTARGET_RASPBERRY_PI -DSTANDALONE -DPIC -D_REENTRANT -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -DTARGET_POSIX -DHAVE_LIBOPENMAX=2 -DOMX -DOMX_SKIP64BIT -DUSE_EXTERNAL_OMX -DHAVE_LIBBCM_HOST -DUSE_EXTERNAL_LIBBCM_HOST -DUSE_VCHIQ_ARM -I/opt/vc/include -I/opt/vc/include/IL -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux -pthread -D_REENTRANT -pthread -I/usr/include/gstreamer-1.0 -I/usr/include/AL -I/usr/include/arm-linux-gnueabihf -I/usr/include/rtaudio -I/usr/include/alsa -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/arm-linux-gnueabihf/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/glib-2.0 -I/usr/lib/arm-linux-gnueabihf/glib-2.0/include -I/root/openFrameworks/libs/glm/include -I/root/openFrameworks/libs/glm/include/glm -I/root/openFrameworks/libs/glm/include/glm/simd -I/root/openFrameworks/libs/glm/include/glm/gtc -I/root/openFrameworks/libs/glm/include/glm/gtx -I/root/openFrameworks/libs/glm/include/glm/detail -I/root/openFrameworks/libs/json/include -I/root/openFrameworks/libs/kiss/include -I/root/openFrameworks/libs/tess2/include -I/root/openFrameworks/libs/utf8/include -I/root/openFrameworks/libs/utf8/include/utf8 -I/root/openFrameworks/libs/openFrameworks -I/root/openFrameworks/libs/openFrameworks/app -I/root/openFrameworks/libs/openFrameworks/types -I/root/openFrameworks/libs/openFrameworks/events -I/root/openFrameworks/libs/openFrameworks/sound -I/root/openFrameworks/libs/openFrameworks/video -I/root/openFrameworks/libs/openFrameworks/3d -I/root/openFrameworks/libs/openFrameworks/math -I/root/openFrameworks/libs/openFrameworks/communication -I/root/openFrameworks/libs/openFrameworks/utils -I/root/openFrameworks/libs/openFrameworks/graphics -I/root/openFrameworks/libs/openFrameworks/gl

The flags prefixing library includes, such as -std=c++14, are the same for normal and cross compilation. Maybe the recompilation is a bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment