Friday, November 14, 2014

Qt 5.3.2 Beaglebone Binaries

Overview

If you saw my Qt 5.2 Binaries post, this will look very familiar....

Prerequisites

For this build, I wanted to try to enable support for everything. I got close, but didn't want to put forth the extra effort for the packages that were not obvious to install. You can mix and match the following installs, depending on your needs.
> sudo apt-get install libicu-dev
> sudo apt-get install libcups2-dev
> sudo apt-get install libudev-dev
> sudo apt-get install libmtdev-dev
> sudo apt-get install libegl1-mesa-dev
> sudo apt-get install libopenvg1-mesa-dev

KMS seems to be already installed (libdrm-dev), but the configuration script cannot find it. Also, some more research is needed before GLX can be enabled. The Debian package search tool is an awesome resource for finding files in packages.

Configuration

Here is the command line I used to generate the make files:
> ./configure -v -opensource -confirm-license -prefix /usr/local/qt-5.3.2 -qt-xcb

The cross compile feature changed slightly from 5.2, but 5.3 detects the local environment fairly well, so you no longer need to pass "-device" into the configuration script.

The Qt configuration script takes about 20 minutes to run on a rev. C Beaglebone Black. It first builds a native version of qmake, which takes about 15 minutes, then it tests for available modules.

Here is the configuration summary:
Configure summary

Build type: linux-g++ (arm, CPU features:)
Platform notes:

- Also available for Linux: linux-kcc linux-icc linux-cxx

qmake vars .......... styles += mac fusion windows QT_LIBS_DBUS = -ldbus-1 QT_CFLAGS_DBUS = -I/usr/include/dbus-1.0 -I/usr/lib/arm-linux-gnueabihf/dbus-1.0/include QT_HOST_CFLAGS_DBUS = -I/usr/include/dbus-1.0 -I/usr/lib/arm-linux-gnueabihf/dbus-1.0/include QT_CFLAGS_GLIB = -pthread -I/usr/include/glib-2.0 -I/usr/lib/arm-linux-gnueabihf/glib-2.0/include QT_LIBS_GLIB = -pthread -lgthread-2.0 -lrt -lglib-2.0 QT_CFLAGS_QGTKSTYLE = -pthread -I/usr/include/gtk-2.0 -I/usr/lib/arm-linux-gnueabihf/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/arm-linux-gnueabihf/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 QT_LIBS_QGTKSTYLE = -lgobject-2.0 -lglib-2.0 QT_CFLAGS_QGTK2 = -pthread -I/usr/include/gtk-2.0 -I/usr/lib/arm-linux-gnueabihf/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/arm-linux-gnueabihf/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 QT_LIBS_QGTK2 = -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lglib-2.0 QT_CFLAGS_PULSEAUDIO = -D_REENTRANT -I/usr/include/glib-2.0 -I/usr/lib/arm-linux-gnueabihf/glib-2.0/include QT_LIBS_PULSEAUDIO = -lpulse-mainloop-glib -lpulse -lglib-2.0 QMAKE_CFLAGS_FONTCONFIG = -I/usr/include/freetype2 QMAKE_LIBS_FONTCONFIG = -lfontconfig -lfreetype QMAKE_INCDIR_LIBUDEV = QMAKE_LIBS_LIBUDEV = -ludev QMAKE_X11_PREFIX = /usr QMAKE_XKB_CONFIG_ROOT = /usr/share/X11/xkb QMAKE_INCDIR_EGL = /usr/include/libdrm QMAKE_LIBS_EGL = -lEGL QMAKE_CFLAGS_EGL = QMAKE_CFLAGS_XCB = QMAKE_LIBS_XCB = -lxcb QMAKE_CFLAGS_DIRECTFB = -D_REENTRANT -I/usr/include/directfb QMAKE_LIBS_DIRECTFB = -ldirectfb -lfusion -ldirect -lpthread sql-drivers = sql-plugins = sqlite
qmake switches .........

Build options:
Configuration .......... accessibility accessibility-atspi-bridge alsa audio-backend c++11 clock-gettime clock-monotonic compile_examples concurrent cups dbus directfb egl egl_x11 eglfs evdev eventfd fontconfig full-config getaddrinfo getifaddrs glib gtk2 gtkstyle iconv icu inotify ipv6ifname large-config largefile libudev linuxfb medium-config minimal-config mremap mtdev nis no-harfbuzz opengl openssl openvg pcre png posix_fallocate precompile_header pulseaudio qpa qpa reduce_exports release rpath shared small-config system-freetype system-jpeg system-png system-zlib xcb xcb-plugin xcb-qt xcb-sm xcb-xlib xinput2 xkbcommon-qt xlib xrender
Build parts ............ libs tools examples
Mode ................... release
Using C++11 ............ yes
Using PCH .............. yes
Target compiler supports:
iWMMXt/Neon .......... no/auto

Qt modules and options:
Qt D-Bus ............... yes (loading dbus-1 at runtime)
Qt Concurrent .......... yes
Qt GUI ................. yes
Qt Widgets ............. yes
Large File ............. yes
QML debugging .......... yes
Use system proxies ..... no

Support enabled for:
Accessibility .......... yes
ALSA ................... yes
CUPS ................... yes
Evdev .................. yes
FontConfig ............. yes
FreeType ............... yes (system library)
Glib ................... yes
GTK theme .............. yes
HarfBuzz ............... no
Iconv .................. yes
ICU .................... yes
Image formats:
GIF .................. yes (plugin, using bundled copy)
JPEG ................. yes (plugin, using system library)
PNG .................. yes (in QtGui, using system library)
journald ............... no
mtdev .................. yes (system library)
Networking:
getaddrinfo .......... yes
getifaddrs ........... yes
IPv6 ifname .......... yes
OpenSSL .............. yes (loading libraries at run-time)
NIS .................... yes
OpenGL / OpenVG:
EGL .................. yes
OpenGL ............... desktop
OpenVG ............... yes-auto
PCRE ................... yes (bundled copy)
pkg-config ............. yes
PulseAudio ............. yes
QPA backends:
DirectFB ............. yes
EGLFS ................ yes
KMS .................. no
LinuxFB .............. yes
XCB .................. yes (bundled copy)
EGL on X ........... yes
GLX ................ no
MIT-SHM ............ yes
Xcb-Xlib ........... yes
Xcursor ............ yes (loaded at runtime)
Xfixes ............. yes (loaded at runtime)
Xi ................. no
Xi2 ................ yes
Xinerama ........... yes (loaded at runtime)
Xrandr ............. yes (loaded at runtime)
Xrender ............ yes
XKB ................ yes
XShape ............. yes
XSync .............. yes
XVideo ............. yes
Session management ..... yes
SQL drivers:
DB2 .................. no
InterBase ............ no
MySQL ................ no
OCI .................. no
ODBC ................. no
PostgreSQL ........... no
SQLite 2 ............. no
SQLite ............... yes (plugin, using bundled copy)
TDS .................. no
udev ................... yes
xkbcommon .............. yes (bundled copy, XKB config root: /usr/share/X11/xkb)
zlib ................... yes (system library)

NOTE: libxkbcommon and libxkbcommon-x11 0.4.1 or higher not found on the system, will use the bundled version from 3rd party directory.
NOTE: Qt is using double for qreal on this system. This is binary incompatible against Qt 5.1. Configure with '-qreal float' to create a build that is binary compatible with 5.1.
Info: creating super cache file /media/sda2/qt5.3.2/bbb_all/.qmake.super

Qt is now configured for building. Just run 'make'.
Once everything is built, you must run 'make install'.
Qt will be installed into /usr/local/qt-5.3.2

Prior to reconfiguration, make sure you remove any leftovers from
the previous build.



Before calling make, ensure that you have enough free space. The qt source folder starts at 920 Mb and will grow to 1.9 Gb during the compile (building only the libs requires 1.5 Gb and building libs and tools only requires 1.7 Gb). An additional 180 Mb is needed if a 'make install' is performed. I did a shadow build on a USB Flash drive (run /path/to/configure from an empty folder), as I was cutting it close on the internal eMMC. It took the BBB 12 hours to compile the libs only, 16 hours to compile the libs and tools, and 21 hours to compile libs, tools, and examples.

For convenience, I've included three zipped archives of the binaries for this build. The unlabeled build contains libs, tools, and examples. The others should be self explanatory. Once expanded, the libs package uses 94 Mb, the libs and tools package uses 104 Mb, and the full package uses 180 Mb

MD5SUM:
6dc968164bc532bea18b550f46660c3d  qt-5.3.2-no-examples.tar.xz(22 Mb)
ae7f9b7c8d0134e7c253500a64a9b9d7  qt-5.3.2-libs.tar.xz (18 Mb)
a735f85d028e1627fbfd031c58434ea5  qt-5.3.2.tar.xz (40 Mb)


Extract to /usr/local ('tar -xf file.tar.xz'), as the tarball contains the qt-5.3.2 folder in it.

Tuesday, November 11, 2014

Beaglebone Debian Read Only Filesystem

Overview

To save the eMMC and to allow for faster bootup/shutdowns, I wanted to mount the root partition as read-only. I spent many days researching and trying to find out what areas of the filesystem needed to have write permissions. It seemed like I was going in circles. Unionfs, aufs, mount -bind, overlayfs, tmpfs.....so many options and so many modules that didn't exist in the default BBB Debian kernel. I finally got so fed up that I decided to just start hacking away at the fstab.

Details

It turns out that the basic read-only filesystem is fairly easy to create, as everything that needs to be configured is contained in /etc/fstab. We need to change the root mount to read-only and add a couple of temporary file systems to handle logs and such. Let's start with an ordinary fstab created by the eMMC flasher script:
# /etc/fstab: static file system information.
#
# Auto generated by: beaglebone-black-eMMC-flasher.sh
#
UUID=716e1ca7-bc61-4958-8c0d-665e48102cfd / ext4 ro,noatime,errors=remount-ro 0 1
UUID=0DFE-E81B /boot/uboot auto defaults 0 0
debugfs /sys/kernel/debug debugfs defaults 0 0

We could then use the following sed command to add the "ro" tag to the root mount line and save it to a temporary fstab file:
> sudo sed s:ext4\ \ noatime:ext4\ \ ro,noatime: /etc/fstab_ro

Next we need to append some tmpfs declarations to our temporary fstab file:
> sudo nano /etc/fstab_ro

and put the following lines at the end:
tmpfs /tmp tmpfs nodev,nosuid,size=32M 0 0
tmpfs /srv tmpfs nodev,size=512K 0 0
tmpfs /var/log tmpfs defaults,noatime,size=1M 0 0
tmpfs /var/tmp tmpfs defaults,noatime,size=512K 0 0
tmpfs /var/run tmpfs defaults,noatime,size=512K 0 0

Replace the real /etc/fstab with your temporary file:
> sudo cp /etc/fstab /etc/fstab.orig
> sudo mv /etc/fstab_ro /etc/fstab

Reboot and you're done!

You may have to experiment with different size limits, depending on your logging needs, but the sizes above should get you started.

Alternate Method

Systemd does the actually mounting, by parsing the fstab. The order in which the mounts are created is not guaranteed. If you need to create mounts in a particular order you need to create a systemd .mount unit for each mount:
> sudo nano /etc/systemd/system/my.mount


with content similar to the following:
[Unit]
Description=Runtime Directory
Before=local-fs.target

[Mount]
What=/mine
Where=/tmp/myfs
Type=bind
Options=bind

Remount RW

If you need to modify the filesystem, you can remount it rw, for a while, with the following command:
> sudo mount -o remount,rw /

To return to read-only mode, either reboot or run this command:
> sudo mount -o remount,ro /

References

https://groups.google.com/forum/#!topic/beagleboard/9J2r8xn3-Os
http://adis.ca/tag/beaglebone/
http://unix.stackexchange.com/questions/27449/mount-a-filesystem-read-only-and-redirect-writes-to-ram
https://help.ubuntu.com/community/aufsRootFileSystemOnUsbFlash
http://unix.stackexchange.com/questions/81959/how-to-mount-aufs-file-system-on-boot-in-archlinux
http://www.thegeekstuff.com/2013/05/linux-aufs/
https://wiki.debian.org/ReadonlyRoot
https://code.google.com/p/rootaufs/wiki/HowToUse