GBM build on Buster: unable to init windowing system – x11 works!
#1
Hi all,

I've got a raspberry pi model 4 running Buster, TV headend with the raspberry pi official DTV hat, and ZeroTier that I have not updated to Bullseye just yet. I'm located in the UK.
The last version of kodi that runs smoothly on it is v18. Inspired by a desire to keep modern add-ons that require python 3 (e.g. the BBC podcasts app in the official repository) I have tried to build my own version.

I've built several versions of kodi, and none of them work directly! 

a) The latest git checkout branch (link), built with GBM support only, compiled with
 
Code:
cmake ../Downloads/kodi/ -DWITH_CPU=cortex-a7 -DWITH_ARCH=arm -DCORE_SYSTEM_NAME="linux" -DCMAKE_INSTALL_PREFIX=/usr/local  -DAPP_RENDER_SYSTEM=gles -DCORE_PLATFORM_NAME=gbm -DVERBOSE=1 -DENABLE_OPENGL=off -DENABLE_OPENGLES=on -DENABLE_VAAPI=OFF

This builds completely cleanly with no warnings (just a few compiler notes – e.g. note: parameter passing for argument of type ‘__gnu_cxx::__normal_iterator<CHttpResponseRange*, std::vector<CHttpResponseRange> >’ changed in GCC 7.1 ) and produces a linked binary that runs cleanly, spits nothing into segfault, and dies almost immediately with the error message
 
Code:
ERROR: Unable to create GUI. Exiting

The corresponding point in the log is:
 
Code:
critical <general>: CApplication::CreateGUI - unable to init windowing system

This seems superficially very similar to this issue,  and I have placed the line
 
Code:
dtoverlay=vc4-fkms-v3d,cma-265

into my /boot/config.txt accordingly. However, I do not see this taking effect if I cat /proc/cmdline:
 
Code:
$ cat /proc/cmdline
coherent_pool=1M 8250.nr_uarts=1 snd_bcm2835.enable_compat_alsa=0 snd_bcm2835.enable_hdmi=1 video=HDMI-A-1:1920x1080M@60i,margin_left=48,margin_right=48,margin_top=48,margin_bottom=48 smsc95xx.macaddr=DC:A6:32:88:AB:B1 vc_mem.mem_base=0x3ec00000 vc_mem.mem_size=0x40000000  console=ttyS0,115200 console=tty1 root=PARTUUID=bee78e8a-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles

b) Building the above with x11 (`-DCORE_PLATFORM_NAME=x11`) produces a binary that "just works" but is not hardware accelerated at all: the CPU usage is 100% on one core and it is not very responsive. It's a backup option and is currently being used .

c) I discovered the 'popcornmix' build scripts which include a wonderfully complicated and sensible looking packaging script:

Cloning with
 
Code:
git clone --depth 1 -b gbm_nexus https://github.com/popcornmix/xbmc.git kodi_gbm

and running the `kodi_gbm/build_rpi_debian_packages.sh` build scripts again works and produces a beautifully built binary of v20 that appears to be happy and running with gbm, with a responsive UI and hardware acceleration. I initially thought that I'd "solved" it once this happened. However, if I leave live TV playing with tvheadend, stuttering increases unbearably and the sound stops – an illustration of this build in action is here. It starts off fine, but progressively gets worse. I haven't touched tvheadend at all for any of these builds and this behaviour does not happen with the x11 build mentioned above. I've increased the cache size in
 
Code:
$ cat ~/.kodi/userdata/advancedsettings.xml
 <advancedsettings>
 <cache>
         <!--- The three settings will go in this space, between the two cache tags. --->
         <buffermode>1</buffermode>
         <memorysize>209715200</memorysize>
<readfactor>10</readfactor>
 </cache>
</advancedsettings>

but to no avail.

At this point, I'd quite like some help. Can I build a working version of kodi v20 on a raspberry pi 4 with hardware support? Am I missing something obvious? There is nothing shown up either in dmesg, or in the logs beyond the somewhat cryptic "couldn't init gui" and in particular that stuttering bug has no error logged and takes about 20 minutes to appear.

Thoughts very welcome ;-).
Reply
#2
I don't think I have the privs to edit this, but the strace log can be found here and corresponding kodi log here.
Reply
#3
GBM kodi can't be launched from an active desktop (there can be only one DRM master).
Try launching from a different VT (i.e. ctrl-atl-F3 first).

The launcher script in popcornmix repo does this.

The cma setting in device tree doesn't apply to cmdline.txt.
It will be used. If you want 4k hevc decode, then you will need a larger value (e.g. 512M).
Note the desktop will also consume significant cma.

For the TVH issue, can you test a libreelec Nexus build?
That would help narrow down if the issue is due to your build, or something in TVH/kodi nexus code.
Reply
#4
(2023-02-07, 13:07)popcornmix Wrote: GBM kodi can't be launched from an active desktop (there can be only one DRM master).
Try launching from a different VT (i.e. ctrl-atl-F3 first).
Thank you very much for a prompt and helpful response. As suspected, PEBKAC.

I think you've hit the nail on the head with this comment – I thought my autostart was starting kodi before the gui but I realised after checking that it is still booting to a graphical target in the background. Changing VT let these builds work – and my lesson is learned!

Can I ask exactly which launcher script you meant in your repo? I can't easily find it.

I will investigate if the stuttering issue I linked a video of earlier is common to both v21 and v20 and get back to you. At the moment I am recompiling v21 and running my build of the gbm v20 -- it is playing surprisingly well -- I'll be interested to see if the streams stay in sync or if something breaks.

Thank you again!
Reply
#5
(2023-02-07, 13:48)landak Wrote: Can I ask exactly which launcher script you meant in your repo? I can't easily find it.
If you install from RPiOS then `which kodi` will find the script. It calls chvt to switch VT.
(kodi is a bash script that launches kodi.bin).
Reply
#6
Thank you so much for your help. I've managed to get one of the builds to work quite well.

Next stupid question: compiling the binary addons appears to give a syntax error:

Code:
ADDONS_TO_BUILD="pvr.hts" ./build_rpi_debian_packages.sh -a

[...]

[ 18%] Building CXX object CMakeFiles/pvr.hts.dir/src/addon.cpp.o
/usr/bin/c++ -DADDON_GLOBAL_VERSION_GENERAL_USED -DADDON_GLOBAL_VERSION_MAIN_USED -DADDON_GLOBAL_VERSION_NETWORK_USED -DADDON_GLOBAL_VERSION_TOOLS_USED -DADDON_INSTANCE_VERSION_INPUTSTREAM_USED -DADDON_INSTANCE_VERSION_PVR_USED -DBUILD_KODI_ADDON -Dpvr_hts_EXPORTS -I/ho
me/pi/kodi_gbm_fresh/build_armhf/addons_build/pvr.hts/lib -g -O2 -ffile-prefix-map=/home/pi/kodi_gbm_fresh/build_armhf/addons_build/pvr.hts=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -flto -O2 -g -DNDEBUG -fPIC   -DTARGET
_POSIX -DTARGET_LINUX -D_GNU_SOURCE -DHAVE_LINUX_UDMABUF=1 -DHAVE_LINUX_DMA_HEAP=1 -DHAVE_LINUX_DMA_BUF=1 -DHAVE_MKOSTEMP=1 -DHAVE_LINUX_MEMFD=1 -DHAVE_STATX=1 -std=c++17 -o CMakeFiles/pvr.hts.dir/src/addon.cpp.o -c /home/pi/kodi_gbm_fresh/build_armhf/addons_build/pvr.h
ts/src/addon.cpp
In file included from /home/pi/kodi_gbm_fresh/build_armhf/addons_build/pvr.hts/src/addon.cpp:8:
/home/pi/kodi_gbm_fresh/build_armhf/addons_build/pvr.hts/src/addon.h:20:32: error: expected initializer before ‘:’ token
   20 | class ATTR_DLL_LOCAL CHTSAddon : public kodi::addon::CAddonBase
      |                                ^
In file included from /home/pi/kodi_gbm_fresh/build_armhf/addons_build/pvr.hts/src/addon.cpp:10:
/home/pi/kodi_gbm_fresh/build_armhf/addons_build/pvr.hts/src/Tvheadend.h:59:33: error: expected initializer before ‘:’ token
   59 | class ATTR_DLL_LOCAL CTvheadend : public kodi::addon::CInstancePVRClient,
      |                                 ^
In file included from /home/pi/kodi_gbm_fresh/build_armhf/addons_build/pvr.hts/src/addon.cpp:11:
/home/pi/kodi_gbm_fresh/build_armhf/addons_build/pvr.hts/src/tvheadend/AddonSettings.h:27:70: error: ‘CSettingValue’ in namespace ‘kodi::addon’ does not name a type
   27 |   ADDON_STATUS SetSetting(const std::string& key, const kodi::addon::CSettingValue& value);
      |

Again, apologies for the inevitable PEBKAC and thanks again for any brief words of wisdom.
Reply
#7
Is it possible you are building from a directory that has previously built kodi matrix addons?
You will need to manually clean it when switching to matrix (so build script fetches nexus versions of addons).
Reply
#8
(2023-02-09, 17:49)popcornmix Wrote: Is it possible you are building from a directory that has previously built kodi matrix addons?
You will need to manually clean it when switching to matrix (so build script fetches nexus versions of addons).

Nope – newly cloned from your repo (git clone -b gbm_nexus --depth 1 https://github.com/popcornmix/xbmc.git kodi_gbm_fresh) and then ran the build script twice -- the first time building and packaging kodi (successfully) and the second for the addons (unsuccessfully). There is a system-installed version of it though, which might be playing around.

A few really dumb questions on my part:
a) Thanks so much for distributing these – are the binary .deb packages anywhere? It might save a bit of a ballache
b) Is it possible to set up a github action to build them automagically?

Random other things:
c) I have used kodi for many years to manage my DVD library (and later for internet streaming) on linux. If I were to pop £5 to its paypal address, does any of that support you / rpi efforts?
d) I once emailed the BBC directly asking if they'd consider making an official iPlayer addon -- like Danish Radio do (I've spent quite a lot of time in Denmark for work). They said they'd add it to their trellis board and I wasn't the first to ask.
Reply
#9
The launcher script available on the Popcornmix repository performs this action. It's worth noting that the device tree's CMA setting doesn't apply to the cmdline.txt file, but it will still be used. If you intend to decode 4k HEVC video, you may need to assign a higher value, such as 512 MB. Additionally, keep in mind that the desktop will use up a significant amount of CMA as well.
Reply

Logout Mark Read Team Forum Stats Members Help
GBM build on Buster: unable to init windowing system – x11 works!0