Chromebook2

From Qt Wiki
Jump to navigation Jump to search

The ARM-based Samsung Chromebook2 (both the 11" and 13" variants) can also be used like a development board - by dual booting Linux from an SD card. The capabilities are similar to the ODROID-XU3: Quad-core big.LITTLE Cortex-A15 + A7 CPU, Mali-T628 GPU with support for EGL, OpenGL ES 3, and OpenCL 1.1 under either X11 or fbdev.

Based on ARM's existing guide, we will go through the additional steps needed to set up WiFi networking, GL, a little development environment, and finally build qtbase from git on the device. For faster build times, cross compilation is recommended, we will take a look at this too.

The usual disclaimer applies: The steps below may void your warranty and data loss may occur. If in doubt, do not proceed.

OpenGL ES and OpenCL (CL-GL interop) in action under X11

Let the fun begin

1. To enable developer mode and create the base system on the memory card, follow ARM's excellent guide. Do not boot just yet.

Before running the script get the fbdev and x11 driver binaries and place them into the same directory.

2. External ethernet adapters are uncool, so we want WiFi. Once the SD card is ready, mount it on the host PC and download the firmware blob and place it to /lib/firmware/mrvl on the memory card. Then we need some tools. Download these from http://ports.ubuntu.com/pool/main and place them to /root on the memory card.

  • libiw30_30~pre9-5ubuntu2_armhf.deb
  • wireless-tools_30~pre9-5ubuntu2_armhf.deb
  • libnl-3-200_3.2.3-2ubuntu2_armhf.deb
  • libnl-genl-3-200_3.2.3-2ubuntu2_armhf.deb
  • libpcsclite1_1.8.11-3ubuntu1_armhf.deb
  • wpasupplicant_0.7.3-6ubuntu2.3_armhf.deb

3. Boot the Chromebook from the memory card (CTRL+U at the boot screen)

4. Login with 'root'. There is no password by default.

5. Do dpkg -i deb_file for the files we downloaded above (in that order).

6. Let's connect to a Wifi network ssid that uses WPA with key key:

ifconfig mlan0 up
(iwlist scan to verify it indeed worked)
wpa_passphrase ssid key > wpa.conf
wpa_supplicant -Dwext -imlan0 -c/root/wpa.conf -B
dhclient mlan0

7. If everything went fine, we are connected to the network. Do e.g. apt-get update to verify.

8. Install X11 using the provided script:

 ~$ ./install-x11.sh

9. Now we can start X11 and openbox and get a wonderful xfce-terminal by doing startx. Switching consoles is possible with Ctrl+Alt+Fx as usual. It's time to install some additional stuff:

 apt-get install openssh-server firefox emacs24
 apt-get build-deps qt4-x11
 apt-get install '.*xcb.*'

10. Now we can edit, build, ssh into the machine remotely, and have the dependencies needed for Qt 5. Now fix up the graphics drivers: After the above we will have Mesa installed which is not quite what we need. The Mali drivers are located in /root/mali/x11. Go to /usr/lib/arm-linux-gnueabihf and replace the symlinks to point to the Mali X11 drivers (note that relative paths are important if doing cross-compilation later).

 /usr/lib/arm-linux-gnueabihf$ rm libEGL.so libGLESv2.so
 /usr/lib/arm-linux-gnueabihf$ ln -s ../../../root/mali/x11/libmali.so libEGL.so
 /usr/lib/arm-linux-gnueabihf$ ln -s ../../../root/mali/x11/libmali.so libGLESv2.so
 /usr/lib/arm-linux-gnueabihf$ ln -s ../../../root/mali/x11/libmali.so libOpenCL.so

If fbdev is wanted later on, the symlinks will have to be changed. Before building Qt, it is also recommended to get fbdev_window.h from somewhere (Google helps, as usual) so that eglfs' Mali backend gets built:

 /usr/include/EGL$ wget https://raw.githubusercontent.com/Pivosgroup/buildroot-linux/master/package/amlogic/opengl/src/include/EGL/fbdev_window.h

11. Now get qtbase (5.5 branch) from Gerrit or code.qt.io:

 ~$ git clone git://code.qt.io/qt/qtbase.git -b 5.5

12. Configure and build it. Both xcb and eglfs will get built and the default will be xcb. Here we build a release version, for development purposes. This takes a lot of time. Debug builds may be faster but will be much larger due to debug info.

 ~/qtbase$ ./configure -release -developer-build -opengl es2 -qpa xcb -make libs -opensource -confirm-license
 ~/qtbase$ make -j2

13. Try some GL examples from qtbase/examples/opengl. Before anything else, verify that contextinfo works.

Cross-compilation based alternative to steps 11-13

1. On the host PC checkout qtbase and the other wanted modules. Then mount the Chromebook's content. This implies naturally the the Chromebook will not get disconnected until build & installation has finished. It will also need the sysroot to be mounted when building any applications later on.

 ~/chromebook$ mkdir sysroot
 ~/chromebook$ sshfs root@chromebooks_ip_address:/ sysroot

You might want to first copy your public SSH key to the device to avoid ssh password prompts:

 ~/.ssh$ scp id_rsa.pub root@chromebooks_ip_address:/root/.ssh/authorized_keys

2. Fix up the sysroot. Some library symlinks use absolute paths instead of relative. This is bad. So get the attached script and run it. (note: this is an updated, cleaned version of script that is in the Raspberry Pi and ODROID-XU3 wikis)

 ~/chromebook$ ./fixlibs.sh ./sysroot

3. The card setup script checked out a toolchain in mali_chromebook-setup_004/gcc-linaro-arm-linux-gnueabihf-4.8-2014.04_linux. We will use this. Qt will be deployed to /usr/local/qt5 on the Chromebook. Host tools, like qmake, that are used when building (cross-compiling) apps and other Qt modules will be installed into the host directory qt5-build. We will reuse the ODROID-XU3 configuration when it comes to compiler flags. Check out qtbase and run:

 ./configure -release -opengl es2 -qpa xcb -make libs -opensource -confirm-license -prefix /usr/local/qt5 -hostprefix ~/chromebook/qt5-build -device odroid-xu3 -device-option CROSS_COMPILE=~/chromebook/mali_chromebook-setup_004/gcc-linaro-arm-linux-gnueabihf-4.8-2014.04_linux/bin/arm-linux-gnueabihf- -sysroot ~/chromebook/sysroot
 make -j20
 make install

4. We can now build apps using ~/chromebook/qt5-build/bin/qmake && make, copy the binaries to the device and run them. For example:

 ~/chromebook/qtbase/examples/opengl/contextinfo$ ~/chromebook/qt5-build/bin/qmake
 ~/chromebook/qtbase/examples/opengl/contextinfo$ make
 ~/chromebook/qtbase/examples/opengl/contextinfo$ scp contextinfo root@chromebook_ip_address:/root

Then on the device under X11:

 ~$ ./contextinfo

5. To build and deploy additional qt modules, e.g. qtdeclarative, check them out and then run:

 ~/chromebook/qt5-build/bin/qmake -r && make -j20 && make install

If the sshfs approach becomes too slow (it's fine for building qtbase but will get annoyingly slow for others), unmount, remount with sshfs into a different directory, and then cp -r the following into the same sysroot directory we used previously:

 lib
 usr/include
 usr/lib
 usr/local/qt5
 root/mali 

Attachments:

fixlibs.sh:

#!/bin/bash

if [ "$#" -ne 1 ]; then
    echo "usage ./cmd target-rootfs"
    exit -1
fi

ROOTFS=$1
INITIAL_DIR=$PWD

function adjustSymLinks
{
    echo "Adjusting the symlinks in $1 to be relative"
    cd $1
    find . -maxdepth 1 -type l | while read i;
    do qualifies=$(file $i | sed -e "s/.*\`\(.*\)'/\1/g" | grep ^/lib)
    if [ -n "$qualifies" ]; then
    newPath=$(file $i | sed -e "s/.*\`\(.*\)'/\1/g" | sed -e "s,\`,,g" | sed -e "s,',,g" | sed -e "s,^/lib,$2/lib,g");
    echo $i
    echo $newPath;
    rm $i;
    ln -s $newPath $i;
    fi
    done
    cd $INITIAL_DIR
}

adjustSymLinks $ROOTFS/lib ".."
adjustSymLinks $ROOTFS/lib/arm-linux-gnueabihf "../.."
adjustSymLinks $ROOTFS/usr/lib "../.."
adjustSymLinks $ROOTFS/usr/lib/arm-linux-gnueabihf "../../.."