Skip to content

Deploying Linux to Raspberry Pi

therecipe edited this page Mar 22, 2019 · 3 revisions

Docker deployment

docker pull therecipe/qt:rpi1

or

docker pull therecipe/qt:rpi2

or

docker pull therecipe/qt:rpi3
  • Deploy your application
qtdeploy -docker build rpi1

or

qtdeploy -docker build rpi2

or

qtdeploy -docker build rpi3

You should find your deployed application inside the deploy subfolder.

Please use the *.sh file to start your application.

Regular deployment

TODO: test and update instructions

Raspbian + (self-compiled or pre-built) Qt 5.7

qtdeploy build rpi1

or

qtdeploy build rpi2

or

qtdeploy build rpi3

You should find your deployed application inside the deploy subfolder.

Please use the *.sh file to start your application.

Arch Linux + self-compiled Qt 5.8

  • Install the official version of Qt (5.8.0)

  • export QT_API=5.8.0

  • mkdir $HOME/raspi

  • Download and unpack the Qt source

    • cd $HOME/raspi && wget https://download.qt.io/official_releases/qt/5.8/5.8.0/single/qt-everywhere-opensource-src-5.8.0.tar.gz
    • tar -xzf qt-everywhere-opensource-src-5.8.0.tar.gz qt-everywhere-opensource-src-5.8.0
  • Download the cross compiler; you can also define a custom location with RPI_TOOLS_DIR (but then you might need to manually change commands from here on during the setup)

    • cd $HOME/raspi && git clone --depth 1 https://github.com/raspberrypi/tools.git
  • Get dependencies and install Arch Linux on your SD card

  • Start your Raspberry Pi

  • Enable root login over ssh

    • export RASPI_IP=192.168.XXX.XXX (replace XXX.XXX with the valid ip ending)

    • ssh alarm@$RASPI_IP (password: alarm)

    • su (password: root)

    • sed -i 's/#PermitRootLogin/PermitRootLogin/' /etc/ssh/sshd_config && sed -i 's/prohibit-password/yes/' /etc/ssh/sshd_config && systemctl restart sshd.service

  • Update and install dependencies (5 min)

    • pacman -Syyu

    • pacman -S fontconfig icu libinput libjpeg-turbo libproxy libsm libxi libxkbcommon-x11 libxrender tslib xcb-util-image xcb-util-keysyms xcb-util-wm freetds gtk3 libfbclient libmariadbclient mtdev postgresql-libs unixodbc assimp bluez-libs sdl2 jasper libmng libwebp gst-plugins-base-libs libpulse openal gst-plugins-bad hunspell libxcomposite wayland gst-plugins-base libxslt gst-plugins-good ffmpeg jsoncpp libevent libsrtp libvpx libxcursor libxrandr libxss libxtst nss opus protobuf snappy xcb-util xcb-util-cursor xcb-util-renderutil xcb-util-xrm libxfixes libxshmfence libxext libx11 libxcb libice weston ttf-freefont lxde gamin xorg-server xorg-xinit xorg-server-utils mesa xf86-video-fbdev xf86-video-vesa xorg-server-xwayland xf86-input-libinput gst-plugins-ugly sqlite2 cups xorg-server-devel rsync

    • pacman -Scc

    • Raspberry Pi 1

      • sed -i 's/gpu_mem=64/gpu_mem=128/' /boot/config.txt
      • echo "exec startlxde" >> $HOME/.xinitrc && mkdir $HOME/.config/ && echo -e "[core]\nbackend=fbdev-backend.so\nmodules=xwayland.so" >> $HOME/.config/weston.ini

      experimental: enable OpenGL under X; will break most applications

      • echo "dtoverlay=vc4-kms-v3d,cma-128" >> /boot/config.txt && sed -i 's/fbdev-backend/drm-backend/' $HOME/.config/weston.ini
    • Raspberry Pi 2 or 3

      • sed -i 's/gpu_mem=64/gpu_mem=256/' /boot/config.txt
      • echo "exec startlxde" >> $HOME/.xinitrc && mkdir $HOME/.config/ && echo -e "[core]\nbackend=fbdev-backend.so\nmodules=xwayland.so" >> $HOME/.config/weston.ini

      experimental: enable OpenGL under X; will break most applications

      • echo "dtoverlay=vc4-kms-v3d,cma-256" >> /boot/config.txt && sed -i 's/fbdev-backend/drm-backend/' $HOME/.config/weston.ini
    • reboot

  • Get sysroot for cross compiling (password: root) (5 min)

    • cd $HOME/raspi && mkdir sysroot sysroot/usr sysroot/opt

    • rsync -avz root@$RASPI_IP:/lib sysroot --delete

    • rsync -avz root@$RASPI_IP:/usr/include sysroot/usr --delete

    • rsync -avz root@$RASPI_IP:/usr/lib sysroot/usr --delete

    • rsync -avz root@$RASPI_IP:/opt/vc sysroot/opt --delete

  • Prepare sysroot; you can also define a custom location with RPI1_SYSROOT_DIR, RPI2_SYSROOT_DIR or RPI3_SYSROOT_DIR (but then you might need to manually change commands from here on during the setup)

    • cd $HOME/raspi && wget https://github.com/raw/riscv/riscv-poky/master/scripts/sysroot-relativelinks.py
    • chmod +x sysroot-relativelinks.py && ./sysroot-relativelinks.py sysroot
  • Build Qt (2 hours)

    • cd $HOME/raspi/qt-everywhere-opensource-src-5.8.0

    • make sure QT_DIR points to your desktop installation of Qt; you may also want to tweak the configure command below, if you put the tools or the sysroot in an alternative location

    • Raspberry Pi 1

      • ./configure -opengl es2 -device linux-rasp-pi-g++ -device-option CROSS_COMPILE=$HOME/raspi/tools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/bin/arm-linux-gnueabihf- -sysroot $HOME/raspi/sysroot -opensource -confirm-license -make libs -skip webengine -nomake tools -nomake examples -extprefix $QT_DIR/5.8/rpi1 -I $HOME/raspi/sysroot/opt/vc/include -I $HOME/raspi/sysroot/opt/vc/include/interface/vcos -I $HOME/raspi/sysroot/opt/vc/include/interface/vcos/pthreads -I $HOME/raspi/sysroot/opt/vc/include/interface/vmcs_host/linux -silent
    • Raspberry Pi 2

      • ./configure -opengl es2 -device linux-rasp-pi2-g++ -device-option CROSS_COMPILE=$HOME/raspi/tools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/bin/arm-linux-gnueabihf- -sysroot $HOME/raspi/sysroot -opensource -confirm-license -make libs -skip webengine -nomake tools -nomake examples -extprefix $QT_DIR/5.8/rpi2 -I $HOME/raspi/sysroot/opt/vc/include -I $HOME/raspi/sysroot/opt/vc/include/interface/vcos -I $HOME/raspi/sysroot/opt/vc/include/interface/vcos/pthreads -I $HOME/raspi/sysroot/opt/vc/include/interface/vmcs_host/linux -silent
    • Raspberry Pi 3

      • ./configure -opengl es2 -device linux-rpi3-g++ -device-option CROSS_COMPILE=$HOME/raspi/tools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/bin/arm-linux-gnueabihf- -sysroot $HOME/raspi/sysroot -opensource -confirm-license -make libs -skip webengine -nomake tools -nomake examples -extprefix $QT_DIR/5.8/rpi3 -I $HOME/raspi/sysroot/opt/vc/include -I $HOME/raspi/sysroot/opt/vc/include/interface/vcos -I $HOME/raspi/sysroot/opt/vc/include/interface/vcos/pthreads -I $HOME/raspi/sysroot/opt/vc/include/interface/vmcs_host/linux -silent
    • make -k -i && sudo make -k -i install

  • Prepare the Qt directory: sudo chown -R $USER $QT_DIR

  • Run the setup: $(go env GOPATH)/bin/qtsetup full rpiX (replace X with: 1, 2 or 3)

  • Deploy your application

qtdeploy build rpi1

or

qtdeploy build rpi2

or

qtdeploy build rpi3

You should find your deployed application inside the deploy subfolder.

Please use the *.sh file to start your application.

  • Notes:

    • run startx & before starting an application with -platform xcb

    • run weston & or weston --tty=1 & (via ssh) or create your own compositor before starting an application with -platform wayland-egl

    • you can increase the available gpu memory by editing /boot/config.txt

Clone this wiki locally