BeagleBoneBlack/SGX + Qt EGLFS + Weston
Contents
Introduction
The SoC of BeagleBone Black is an AM335x by Texas Instruments.
The graphic accelerator by Imagination Technologies is PowerVR chipset, the serie 5 (SGX530).
My name is Rémi, I'm a french engineer working for the CKSQUARE company's.
After testing the robustness of the board, I advised my company to use the beaglebone black.
The integrated eMMc memory and his low price were big reasons to use this product. There isn't BeagleBoard-x15 at the time.
I would like to thank the Beaglebone community (especially Robert Nelson) and my company to share with you my researches.
Sources
BeagleBoard
Texas Instruments
- The last Porcessor SDK for AM335x
- SGX Debug Info page
- Linux SDK Graphics and Display
- The community of Texas Instruments
- Git repo (Gitorious)
Imagination Technologies
Conditions
Rules
- We must have "-ti-" on the BBB kernel. Type
uname -r
to verify your kernel version - We use only NEW PowerVR modules
- We connect a screen to the BBB with a micro HDMI to HDMI cable
- We need an ethernet cable to connect the beaglebone to the internet
- A lot of place if you want install demos and Weston without Cross Compilation
- All orders will be in "root" mode here (
sudo -i
). Sorry if it's not secure ^^ - All packages are up to date (
apt-get update
).
Download patches
During the differents steps, we will need of patches created by Texas Instruments
You need the patches only if you don't use the "Fast installation" section's
.
To get it on BBB:
cd /opt/ wget https://remi.avignon.me/bbb/BBB-Patches.zip unzip BBB-Patches.zip rm BBB-Patches.zip
I explain below how I recovered these patches.
The images tested
For my tests I use two images :
- Debian 9.3 2018-01-28 4GB SD IoT (kernel: 4.9.78-ti-r94)
- Debian 9.5 2018-10-07 4GB SD LXQT (kernel: 4.14.71-ti-r80)
you can download the last image of BBB here
Install PowerVR Modules
The OLD Version
WARNING: It's not a good solution and I didn't test it.
The older version may run on versions lower or equal than 4.4.68-bone17.
The old version use the FBDEV.
So you need a lts/bone kernel to download :
cd /opt/scripts/tools/ git pull ./update_kernel.sh --kernel 4.4.`your version here`-bone17 reboot apt-get install ti-sgx-es8-modules-`uname -r` depmod -a
Build SGX userspace for 4.4.x (must be done on an x86, due to the TI 5.01.01.02 blob extractor)
git clone https://github.com/RobertCNelson/bb-kernel.git cd bb-kernel/ git checkout origin/am33x-v4.4 -b tmp-sgx ./sgx_create_package.sh
Copy ./deploy/GFX_5.01.01.02_es8.x.tar.gz to BeagleBone/BeagleBone Black and install
tar xfv GFX_5.01.01.02_es8.x.tar.gz -C / cd /opt/gfxinstall/ apt-get install lsb-release insserv ./sgx-install.sh reboot
Verify omaplfb & pvrsrvkm loaded
debian@arm:~$ lsmod | grep omaplfb omaplfb 12065 0 pvrsrvkm 178782 1 omaplfb
But when I test with lastest 4.4-bone kernel, the omapfbl module was not loaded
The NEW Version
We must imperatively have the "-ti-" kernel. Type uname -r
to verify your kernel.
If you are on 4.9.X-ti- kernel, you don't have access to the SGX drivers, update your dtb files for solve this problem:
cd /opt/source/dtb-4.9-ti/ git pull make install reboot
Note: The git pull
command will patch dtb files (SGX Patches).
Check access of SGX drivers
Command to verify the access of SGX drivers:
ls /sys/devices/platform/ocp/56000000.sgx driver driver_override drm modalias of_node power subsystem uevent
It's very important to access the folder else you will have errors afterwards and you can not use graphical acceleration...
Install modules
apt-get install ti-sgx-ti335x-modules-`uname -r` depmod -a reboot
Verify module loaded
lsmod |grep pvr pvrsrvkm 442368 0
Fast installation with deb files (not official)
My gcc version is 6.30, it's the same that 4.9 and 4.14 kernel. Check your gcc version with gcc -v
If you haven't the same gcc version than me of if you have an error, please follow steps of GBM Library / Graphic SDK and Weston.
Install GBM Library
cd /opt/ wget https://remi.avignon.me/bbb/libgbm_2.0.0-1_armhf.deb dpkg -i libgbm_2.0.0-1_armhf.deb rm libgbm_2.0.0-1_armhf.deb
Install Graphic SDK
We need use "--force-all" argument's because there is a conflict with libgl1 and libgles2 packages...
cd /opt/ wget https://remi.avignon.me/bbb/omap5-ti335x-sgx-ddk-um_1.0.0_armhf.deb dpkg -i --force-all omap5-ti335x-sgx-ddk-um_1.0.0_armhf.deb rm omap5-ti335x-sgx-ddk-um_1.0.0_armhf.deb
To start the controller of PowerVR module:
/etc/init.d/rc.pvr start Loaded PowerVR consumer services.
If you have an error, please reboot your board and retry to start the PowerVR controller.
Install KMS++
cd /opt/ wget https://remi.avignon.me/bbb/kmsxx_1.0.0_armhf.deb dpkg -i kmsxx_1.0.0_armhf.deb rm kmsxx_1.0.0_armhf.deb
It's important to start PowerVR controller before execute kms command's! Commands availables:
- fbtest
- kmsblank
- kmscapture
- kmscube
- kmsprint
- kmstest
- kmsview
Install Weston
cd /opt/ apt-get install libxcb-composite0 libunwind8 wget https://remi.avignon.me/bbb/weston_2.0.0_armhf.deb dpkg -i weston_2.0.0_armhf.deb rm weston_2.0.0_armhf.deb
Launch weston from console mode:
weston --tty=4 --idle-time=0
The GBM Library
Introduction
The GBM library is patched by Texas Instruments for use the PowerVR module.
The library on /usr/lib/arm-linux-gnueabihf/libgbm.so.1.0.0
is not a good library for use the graphic accelerator.
Add news directories of libs
Edit /etc/ld.so.conf.d/arm-linux-gnueabihf.conf
file, and add /usr/lib
and /usr/local/lib
after the first line.
cat /etc/ld.so.conf.d/arm-linux-gnueabihf.conf # Multiarch support /lib/arm-linux-gnueabihf /usr/lib /usr/local/lib /usr/lib/arm-linux-gnueabihf
After your file saved, type ldconfig
to reload the new directories of libraries.
Download/Install library
cd /opt/ git clone git://git.ti.com/glsdk/libgbm.git -b next cd libgbm/ git apply ../patches/gbm/0001-Hack-gbm.pc.in-add-ldl-at-Libs-to-pass-the-QT5-confi.patch ./autogen.sh make install cd /opt/ rm -r libgbm ln -s /usr/local/lib/libgbm.so.2.0.0 /usr/local/lib/libgbm.so.2
Bonus: How I get the library
Note: If you want just use the graphic accelerator, this part is not important.
I explain how I sought to get the patches from Texas Instruments. You can go to the next step if you want.
I created a SD with am335x-evm-linux-XX.XX.XX.XX.img image and the graphic accelerator work fine on the BeagleBone Black..
So I download the last SDK of AM335X from this page..
Must be done on an x86 because this repo is very big, I use 05.02.00.10 PSDK for this example:
$ cd /opt/ $ git clone git://arago-project.org/git/projects/oe-layersetup.git tisdk $ cd tisdk $ ./oe-layertool-setup.sh -f configs/processor-sdk/processor-sdk-05.02.00.10-config.txt $ find /opt/tisdk/sources -iname "*libgbm*" /opt/tisdk/sources/meta-ti/recipes-graphics/gbm/libgbm_10.0.0.bb /opt/tisdk/sources/meta-processor-sdk/recipes-graphics/gbm/libgbm_10.0.0.bbappend /opt/tisdk/sources/meta-processor-sdk/recipes-graphics/gbm/libgbm $cat /opt/tisdk/sources/meta-ti/recipes-graphics/gbm/libgbm_10.0.0.bb BRANCH = "next" SRC_URI = "git://git.ti.com/glsdk/libgbm.git;protocol=git;branch=${BRANCH}" $ls /opt/tisdk/sources/meta-processor-sdk/recipes-graphics/gbm/libgbm 0001-Hack-gbm.pc.in-add-ldl-at-Libs-to-pass-the-QT5-confi.patch
I have the git source with the branch and I know there is only one patch !
The Graphic SDK
Download/Install SGX SDK
cd /opt/ git clone -b ti-img-sgx/1.14.3699939 git://git.ti.com/graphics/omap5-sgx-ddk-um-linux.git cd omap5-sgx-ddk-um-linux/ export DISCIMAGE=/ export TARGET_PRODUCT=ti335x make install cd /usr/lib/ ln -s libGLESv2.so.1.14.3699939 libGLESv2.so.1 mkdir /usr/local/lib/gbm/ cd /usr/local/lib/gbm/ ln -s ../../../lib/libpvrGBMWSEGL.so.1.14.3699939 gbm_pvr.so rm -r /opt/omap5-sgx-ddk-um-linux
File powervr.ini
As explained on the texas instruments wiki, the configuration of the /etc/powervr.ini file is important. I advise you to configure your file as mine:
cat /etc/powervr.ini [default] WindowSystem=libpvrDRMWSEGL.so DefaultPixelFormat=RGB565
Start PowerVR Controller
- It is very important that at each start the module
pvrsrvkm.ko
be loaded - The access to the SGX drivers which is found at this location
/sys/devices/platform/ocp/56000000.sgx
- The program
/usr/bin/pvrsrvctl --start --no-module
must not make erros, recovered from the graphic SDK of Texas Instruments.
There is a script on your /etc/init.d/ folder, to load modules and start the pvr controller, execute this command:
/etc/init.d/rc.pvr start Loaded PowerVR consumer services.
Whenever the BBB starts, this script need to start. Use insserv or update.rc to execute on each boot.
If you have this error:
/etc/init.d/rc.pvr start PVR:(Error): OpenServices: PVRDRMOpenRender failed [0, ] PVR:(Error): PVRSRVInitSrvConnect: PVRSRVConnect failed [0, ] PVR:(Error): SrvInit: PVRSRVInitSrvConnect failed (4) [0, ] /usr/bin/pvrsrvctl: SrvInit failed (already initialized?) (err=PVRSRV_ERROR_INIT_FAILURE)
- Verify you have access to SGX drivers:
ls /sys/devices/platform/ocp/56000000.sgx
- Verify you boot log with
dmesg
command - Verify that the powerVR module is loaded
lsmod |grep pvr
- If all is ok, please halt your board, Remove the power and put it again to boot
Dmesg analyse
dmesg |grep -i pvr [ 51.554766] pvrsrvkm: loading out-of-tree module taints kernel. ==> Module PowerVR loaded [ 51.778874] [drm] Initialized pvr 1.14.3699939 20110701 for 56000000.sgx on minor 2 ==> Module PowerVR connected with SGX Drivers [ 122.361997] PVR_K: UM DDK-(3699939) and KM DDK-(3699939) match. [ OK ] ==> PowerVR controller linked with Module and SGX Drivers
Tests graphic accelerator
The PVR Tools and Examples
The first step is to use Imagination Technologies tools and examples because they work well and it's easy to use.
Download/Install
cd /opt/ git clone git://git.ti.com/graphics/img-pvr-sdk.git cd img-pvr-sdk export DISCIMAGE=/ export TARGET_PRODUCT=ti335x make install cd /opt/ rm -r img-pvr-sdk
Example
Test with No Window System (NullWS)
cd /opt/img-powervr-sdk/Examples/Advanced/NullWS/ ./OGLES2Water
It is my favorite! I like it!
If you have a problem here, have you a monitor connected on your BBB?
Type ls -alh /sys/class/drm/
to verify your monitor:
ls -alh /sys/class/drm/ total 0 drwxr-xr-x 2 root root 0 Mar 18 03:13 . drwxr-xr-x 61 root root 0 Mar 17 15:17 .. lrwxrwxrwx 1 root root 0 Mar 17 15:43 card0 -> ../../devices/platform/ocp/4830e000.lcdc/drm/card0 lrwxrwxrwx 1 root root 0 Mar 18 03:13 card0-HDMI-1 -> ../../devices/platform/ocp/4830e000.lcdc/drm/card0/card0-HDMI-1 lrwxrwxrwx 1 root root 0 Mar 18 03:13 card1 -> ../../devices/platform/ocp/56000000.sgx/drm/card1 lrwxrwxrwx 1 root root 0 Mar 18 03:13 controlD64 -> ../../devices/platform/ocp/4830e000.lcdc/drm/controlD64 lrwxrwxrwx 1 root root 0 Mar 18 03:13 renderD128 -> ../../devices/platform/ocp/56000000.sgx/drm/renderD128 -r--r--r-- 1 root root 4.0K Mar 18 03:13 version
If you have a problem here, don't continue because it's the easiest way to use hardware acceleration!
PVRPerfServerDeveloper
It's an application to monitoring the graphics resources, cpu and memory on BBB
Go to /opt/img-powervr-sdk/PVRHub/PVRPerfServer/
and execute ./PVRPerfServerDeveloper
PVRTune
Note: You need to execute PVRPerfServerDeveloper on BeagleBone before.
Download PVRTune here for your x86 operating system, uncompress, execute ./GUI/Linux_x86_64/PVRTuneDeveloperGUI.
On PRVTuneDeveloper application:
Connect to: 192.168.7.2 (or the IP of BBB) and click on "Go" button's.
PVRTuneDeveloper analyze OGLES2Water demo. We can see a FPS and Renderer charge!
PVRTrace
/opt/img-powervr-sdk/PVRHub/Scripts/start_tracing.sh
Launch your graphic application
The log/s file/s is/are: /opt/img-powervr-sdk/PVRHub/PVRTrace
KMScube
cd /opt/ git clone git://git.ti.com/glsdk/kmscube.git cd kmscube/ ./autogen.sh make install cd /opt/ rm -r kmscube kmscube
If you have a Segmentation fault here, it's because you're not using the right GBM library! More information on GBM Library section.
If you have a failed to initialize DRM, it's that your monitor is not detected ( ls -alh /sys/class/drm/
).
With: 4.14.103-ti-r98, vgem takes card0, so you'll need to pass "-d /dev/dri/card1" to start kmscube..
debian@beaglebone:~$ uname -r ; ls -lha /sys/class/drm/ 4.14.103-ti-r98 total 0 drwxr-xr-x 2 root root 0 Mar 21 21:32 . drwxr-xr-x 64 root root 0 Mar 21 21:27 .. lrwxrwxrwx 1 root root 0 Mar 21 21:29 card0 -> ../../devices/platform/vgem/drm/card0 lrwxrwxrwx 1 root root 0 Mar 21 21:29 card1 -> ../../devices/platform/ocp/4830e000.lcdc/drm/card1 lrwxrwxrwx 1 root root 0 Mar 21 21:29 card1-HDMI-A-1 -> ../../devices/platform/ocp/4830e000.lcdc/drm/card1/card1-HDMI-A-1 lrwxrwxrwx 1 root root 0 Mar 21 21:29 card2 -> ../../devices/platform/ocp/56000000.sgx/drm/card2 lrwxrwxrwx 1 root root 0 Mar 21 21:29 renderD128 -> ../../devices/platform/ocp/56000000.sgx/drm/renderD128 -r--r--r-- 1 root root 4.0K Mar 21 21:29 version
QtQuick + EGLFS
apt-get install libqt5qml5 qml-module-qtquick-controls qt5-default qtdeclarative5-dev qtquickcontrols5-examples cd /usr/lib/arm-linux-gnueabihf/qt5/examples/quickcontrols/extras/dashboard qmake make export QT_QPA_PLATFORM=eglfs export QT_QPA_EGLFS_INTEGRATION=none ./dashboard
Do you see a dashboard on your monitor? It's perfect ^^!
Weston
I downlad the same version of Texas Instruments use on their lastest image for BBB! It's the version 2.0.
Because I can apply their patches easily!
Before get weston from git repo, we need to install a lot of packages:
apt-get install libwayland-egl1-mesa libwayland-egl-backend-dev libwayland-dev libwayland-client0 libxcb-composite0-dev libxcb-xfixes0-dev libxcursor-dev libxcb-xkb-dev apt-get install libpixman-1-dev libcairo2-dev libx11-xcb-dev libmtdev-dev libinput-dev libxkbcommon-dev wayland-protocols libpam0g-dev pam-devel libcolord-dev libwebp-dev libunwind-dev cd /opt/ git clone https://github.com/wayland-project/weston.git -b 2.0 cd weston git apply --reject --whitespace=fix -v ../patches/wayland/weston/*.patch
I Had a problem with the first patch (0001-Add-soc-performance-monitor-utilites.patch).
So I edited manually the Makefile with Makefile.rej...
./autogen.sh Native Backend drm-backend.so setuid Install yes Cairo Renderer image EGL yes libxkbcommon yes xcb_xkb yes XWayland yes dbus yes ivi-shell yes Build wcap utility yes Build Fullscreen Shell yes Enable developer documentation no weston-launch utility yes systemd-login support no systemd notify support no DRM Compositor yes X11 Compositor yes Wayland Compositor yes Headless Compositor yes FBDEV Compositor yes RDP Compositor no Screen Sharing no JUnit XML output no Build Clients yes Build EGL Clients no Build Simple Clients yes Build Simple EGL Clients yes Install Demo Clients no Colord Support yes LCMS2 Support yes libjpeg Support yes libwebp Support yes libunwind Support yes VA H.264 encoding Support yes
After I had a problem when compiling: /usr/bin/ld: ./.libs/libtimebargraph.a(libtimebargraph_la-time_bar_graph.o): undefined reference to symbol 'pthread_join@@GLIBC_2.4' But the reference exist:
readelf -s /lib/arm-linux-gnueabihf/libpthread.so.0 | grep pthread_create 135: 00005885 2804 FUNC GLOBAL DEFAULT 13 pthread_create@@GLIBC_2.4 681: 00005885 2804 FUNC LOCAL DEFAULT 13 __pthread_create_2_1 1164: 00005885 2804 FUNC GLOBAL DEFAULT 13 pthread_create@@GLIBC_2.4
So I added " -lpthread" in Makefile on line started by "LIBS=" (line 1978 for me).
it's: "LIBS = -lpthread" for use pthread library and it's good.
After type make command, you can go to buy and eat a baguette because it'll take a long time ;-P
make install cd /opt/ rm -r weston
Launch weston:
weston --tty=4 --idle-time=0
Normally, we have a desktop on our screen with an old and not very pretty wallpaper ^^
GStreamer
Version used on Debian from BB.org: GStreamer Core Library version 1.10.4
Version used on am335x-evm form Ti: GStreamer Core Library version 1.12.2