Skip to content

Commit

Permalink
Added support for Amd64 build hosts.
Browse files Browse the repository at this point in the history
  • Loading branch information
chschnell committed Jan 7, 2018
1 parent d8013c2 commit ad50e87
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 23 deletions.
57 changes: 40 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,11 @@ To run this script you need:

* Raspberry Pi 2 or 3 (tested on a Pi 3)
* Raspberry Pi OS: Raspbian Stretch Lite ([2017-11-29-raspbian-stretch-lite.img](https://www.raspberrypi.org/downloads/raspbian/))
* Host: Anything capable of running a 32-Bit Debian 9 (i.e. [Oracle VirtualBox](https://www.virtualbox.org/) or a PC)
* Host OS: Debian 9 Stretch 32-Bit netinst ([debian-9.3.0-i386-netinst.iso](https://www.debian.org/CD/netinst/index.html))

The reason for 32-Bit Debian 9 is that we can use its built-in armhf cross-compiler for Qt without relying on any 3rd party tools.

It seems currently not possible to set up a 64-Bit Debian host using its built-in i386, amd64 and armhf toolchains in the same installation (Qt builds some host tools for 32-Bit target, regardless of the host's architecture).

A [32-Bit Ubuntu](https://www.ubuntu.com/download/alternative-downloads) >= 16.04 should also work for the host (not tested).
* Host: Anything capable of running a 32 or 64 Bit Debian 9 (i.e. [Oracle VirtualBox](https://www.virtualbox.org/) or a PC)
* Host OS: One of
* Debian 9 Stretch 64-Bit netinst ([debian-9.3.0-amd64-netinst.iso](https://www.debian.org/CD/netinst/index.html))
* Debian 9 Stretch 32-Bit netinst ([debian-9.3.0-i386-netinst.iso](https://www.debian.org/CD/netinst/index.html))
* Ubuntu 32 or 64 Bit >= 16.04 should also work for the host (not tested)

### Raspberry Pi Setup

Expand Down Expand Up @@ -57,21 +54,25 @@ Keep the Pi running. You won't need the keyboard and monitor from here on.

### Host Virtual Machine Setup

If you use VirtualBox, create a 32-Bit Debian virtual machine and give it at least 16GB of hard disk space.
If you use VirtualBox, create a 32 or 64 Bit Debian virtual machine and give it at least 16GB of hard disk space.

**32-Bit hosts:**

If you plan to use only a single processor core, give your machine 4GB of RAM. If you plan to use multiple cores instead and your CPU supports PAE ([Physical Addresss Extension](https://en.wikipedia.org/wiki/Physical_Address_Extension)):
* If you plan to use only a single processor core, give your machine 4GB of RAM.
* If you plan to use multiple cores instead and your CPU supports PAE ([Physical Addresss Extension](https://en.wikipedia.org/wiki/Physical_Address_Extension)), then:
* assign as many cores and as much RAM (max. 4GB times the number of cores) as reasonably possible, and
* make sure to enable PAE and IO-APIC in the virtual machine to make the extra RAM accessible to the kernel (tested with 4 cores and 8GB of RAM).
* You can test these settings later once the host is up and running by running `uname -r` where you should read something like 4.9.0-4-686-**pae** and by running `free -h` where you can check the RAM size.

* assign as many cores and as much RAM (max. 4GB times the number of cores) as reasonably possible, and
* make sure to enable PAE and IO-APIC in the virtual machine to make the extra RAM accessible to the kernel (tested with 4 cores and 8GB of RAM).
Boot the machine, install Debian from the `.iso` and log in. You can work with the defaults in Debian setup, for a minimal setup unselect all at `tasksel` except:

Boot the machine, install Debian from `debian-9.3.0-i386-netinst.iso` and log in.
* [X] `SSH Server`
* [X] `standard system utilites`

### Host Debian Setup

If you use VirtualBox, use `ip addr` to find your host's IP address and then use a SSH terminal (like [putty](http://www.putty.org/) on Windows) from here on to interact with the host machine.

In case you did enable PAE in the virtual machine earlier, you can test it by running `uname -r` where you should read something like 4.9.0-4-686-**pae** and by running `free -h` where you can compare the RAM size.

Completely optional (the bash script does not need root permissions, only a few steps in this section) but useful, install `sudo`:

```bash
Expand Down Expand Up @@ -108,7 +109,18 @@ Finally, as root, install the apt packages required for building Qt5:

```bash
# install toolchain and cross-toolchain as well as several build tools
sudo apt-get install build-essential crossbuild-essential-armhf pkg-config git perl python gperf bison ruby flex gyp libnss3-dev libnspr4-dev
sudo apt-get install build-essential crossbuild-essential-armhf\
pkg-config git perl python gperf bison ruby flex gyp\
libnss3-dev libnspr4-dev libfreetype6-dev libpng-dev libdbus-1-dev
```

**64-Bit hosts:** Additionally install 32-Bit architecture and required apt packages:

```bash
# install compatibility packages
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install linux-libc-dev:i386 g++-6-multilib
```

## Build Qt5
Expand Down Expand Up @@ -180,9 +192,12 @@ These final touches are recommended, though not strictly required, to improve ru
* To counter the `Unable to query physical screen size` warnings, find your display's dimensions in millimeters and set these environment variables:

```bash
# add to Pi's ~./profile (example Samsung SyncMaster P2450H with 531x298 mm):
# add to Pi's ~./profile (example Samsung SyncMaster P2450H with 531mm x 298mm):
export QT_QPA_EGLFS_PHYSICAL_WIDTH=531
export QT_QPA_EGLFS_PHYSICAL_HEIGHT=298
# Raspberry Pi 7" touchscreen: 155mm x 86mm
#export QT_QPA_EGLFS_PHYSICAL_WIDTH=155
#export QT_QPA_EGLFS_PHYSICAL_HEIGHT=86
```

* To hide the mouse cursor:
Expand All @@ -197,6 +212,14 @@ These final touches are recommended, though not strictly required, to improve ru
ssh pi@raspberrypi sudo raspi-config
```

* If you use a mouse or a touchscreen without X11, consider installing console mouse support:

```bash
ssh pi@raspberrypi sudo apt-get install gpm
```

This allows you to wake the console screen saver using your mouse or touchscreen.

The builder script already installs these additional packages on the Pi (you need to install them when deploying to a different Pi):

* To counter the `org.freedesktop.UPower.GetDisplayDevice` warnings, install APT package `upower` on the Pi:
Expand Down
15 changes: 9 additions & 6 deletions build-qt5-rpi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ readonly APT_PKGS_RPI_DEV="zlib1g-dev libjpeg-dev libpng-dev\
libwebp-dev libopus-dev unixodbc-dev libsqlite0-dev libxcursor-dev\
libxcomposite-dev libxdamage-dev libxrandr-dev libxtst-dev libxss-dev\
libxkbcommon-dev libdouble-conversion-dev libbluetooth-dev\
libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev"
libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libatspi2.0-dev"

readonly APT_PKGS_RPI_X11_DEV="libx11-xcb-dev libgbm-dev libxcb-xfixes0-dev\
libxcb-glx0-dev libsm-dev libxkbcommon-x11-dev libgtk-3-dev libwayland-dev\
Expand All @@ -48,7 +48,7 @@ readonly APT_PKGS_RPI_TOOLS="ttf-mscorefonts-installer fontconfig upower"

readonly DEFAULT_QT_CONFIG="-release -opensource -confirm-license\
-platform linux-g++ -device linux-rasp-pi2-g++ -device-option\
CROSS_COMPILE=arm-linux-gnueabihf- -opengl es2 -no-gtk -nomake tests\
CROSS_COMPILE=arm-linux-gnueabihf- -opengl es2 -silent -nomake tests\
-nomake examples"

readonly ATTR_RED=`tput setaf 1`
Expand Down Expand Up @@ -125,8 +125,8 @@ function file_replace_c_str() {
sed -e "s@${OLD}\\x00@${NEW}\\x00${OLD:${#NEW}+1}\\x00@" -i "$FILE"
}

function patch_libQt5WebEngineCore_so_5() {
local LIBFILE=$(realpath "$CFG_BUILD/qtwebengine/lib/libQt5WebEngineCore.so.5")
function patch_libQt5WebEngineCore_so_5_9_3() {
local LIBFILE=$(realpath "$CFG_BUILD/qtwebengine/lib/libQt5WebEngineCore.so.5.9.3")
if [ -e $LIBFILE ]; then
file_replace_c_str "$LIBFILE" "$CFG_SYSROOT/opt/vc/lib" /opt/vc/lib
file_replace_c_str "$LIBFILE" libEGL.so.1 libEGL.so
Expand Down Expand Up @@ -278,8 +278,11 @@ CFG_EXTPREFIX=${CFG_EXTPREFIX:=$CFG_ROOT/sdk} # Host runtime insta
CFG_HOSTPREFIX=${CFG_HOSTPREFIX:=$CFG_ROOT/hosttools} # Host tools installation directory
CFG_RELPREFIX=${CFG_RELPREFIX:=$CFG_ROOT/release} # Release archives directory

export PKG_CONFIG_LIBDIR=$CFG_SYSROOT/usr/lib/pkgconfig:$CFG_SYSROOT/usr/share/pkgconfig:$CFG_SYSROOT/usr/lib/arm-linux-gnueabihf/pkgconfig:$CFG_SYSROOT/opt/vc/lib/pkgconfig
export PKG_CONFIG_SYSROOT_DIR=$CFG_SYSROOT
export PKG_CONFIG_LIBDIR=$CFG_SYSROOT/usr/lib/pkgconfig\
:$CFG_SYSROOT/usr/share/pkgconfig\
:$CFG_SYSROOT/usr/lib/arm-linux-gnueabihf/pkgconfig\
:$CFG_SYSROOT/opt/vc/lib/pkgconfig

if [ $DO_HELP = true ]; then
show_help
Expand Down Expand Up @@ -325,7 +328,7 @@ if [ $DO_BUILD = true ]; then
echo_msg "Executing command: build"
set -o xtrace
make_qt
patch_libQt5WebEngineCore_so_5
patch_libQt5WebEngineCore_so_5_9_3
set +o xtrace
echo_msg "build: ok."
fi
Expand Down

0 comments on commit ad50e87

Please sign in to comment.