SDL2 kmsdrm keyboard locks up - ubuntu server

Post Reply
C1-10P
Posts: 19
Joined: Sat Jan 09, 2021 9:34 pm
languages_spoken: dutch, english, french
ODROIDs: XU4, N2plus
Has thanked: 3 times
Been thanked: 5 times
Contact:

SDL2 kmsdrm keyboard locks up - ubuntu server

Post by C1-10P »

Hello,

every time I compile SDL2 and tests on my N2plus my keyboard locks up if I dare to run an application that uses it.

I do it like this

Code: Select all

sudo apt install mercurial autoconf automake libtool libwayland-dev libxkbcommon-dev wayland-protocols libxext-dev libpulse-dev libaudio-dev libasound2-dev libudev-dev libdbus-1-dev -y

hg clone http://hg.libsdl.org/SDL
cd SDL
./configure --disable-video-x11 --disable-video-rpi --enable-video-kmsdrm
make -j $(nproc) CFLAGS='-mcpu=cortex-a73.cortex-a53 -mtune=cortex-a73.cortex-a53'
sudo make install
and then compile the tests and if I run any test or application that uses SDL2 my keyboard locks up and there's nothing I can do to get it back besides rebooting.

It for sure is a SDL2 problem because I can run for example kmscube in kmsdrm after a reboot and exit with <enter>

The SDL2 version is 2.0.15

I already tried a ton of stuff but I can't find it. Does anybody knows what's going on? A keyboard is kind of an absolute necessity on a computer :? so ...

Thanks
Last edited by C1-10P on Wed Mar 17, 2021 5:58 am, edited 1 time in total.

C1-10P
Posts: 19
Joined: Sat Jan 09, 2021 9:34 pm
languages_spoken: dutch, english, french
ODROIDs: XU4, N2plus
Has thanked: 3 times
Been thanked: 5 times
Contact:

Re: SDL2 kmsdrm keyboard locks up - headless ubuntu server

Post by C1-10P »

I managed to get it working using this ./configure

Code: Select all

./configure --prefix=/usr/local --enable-video-opengl --enable-video-opengles1 --enable-video-opengles2 --disable-video-x11 --disable-pulseaudio --disable-esd --disable-dbus --disable-video-wayland --enable-alsa --disable-video-rpi --disable-video-vulkan --enable-video-kmsdrm --host=armv7l-unknown-linux-gnueabihf --build=armv7l-unknown-linux-gnueabihf
I haven't pinpointed the exact config error/cause yet.
These users thanked the author C1-10P for the post:
odroid (Mon Mar 08, 2021 10:24 am)

C1-10P
Posts: 19
Joined: Sat Jan 09, 2021 9:34 pm
languages_spoken: dutch, english, french
ODROIDs: XU4, N2plus
Has thanked: 3 times
Been thanked: 5 times
Contact:

Re: SDL2 kmsdrm keyboard locks up - ubuntu server

Post by C1-10P »

I figured out he cause a while ago. I was compiling it using gcc and optimization for the architecture using

Code: Select all

make -j $(nproc) CFLAGS='-mcpu=cortex-a73.cortex-a53 -mtune=cortex-a73.cortex-a53'

but apparently this is causing runtime errors. For some reason using the above configure options the keyboard works. I stumbled up on it because I got segfaults trying to use the joysticks in SDL.
One can configure it as one wishes and compile it with

Code: Select all

make -j $(nproc)
and everything works.
These users thanked the author C1-10P for the post:
odroid (Mon Apr 05, 2021 8:26 am)

User avatar
odroid
Site Admin
Posts: 37286
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 1749 times
Been thanked: 1127 times
Contact:

Re: SDL2 kmsdrm keyboard locks up - ubuntu server

Post by odroid »

Thank you for sharing useful tips.

Can you please tell us your current kernel version and gcc version?

C1-10P
Posts: 19
Joined: Sat Jan 09, 2021 9:34 pm
languages_spoken: dutch, english, french
ODROIDs: XU4, N2plus
Has thanked: 3 times
Been thanked: 5 times
Contact:

Re: SDL2 kmsdrm keyboard locks up - ubuntu server

Post by C1-10P »

Sure

Code: Select all

****@n2plus:~$ uname -r
5.11.8-odroid-arm64
****@n2plus:~$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/aarch64-linux-gnu/9/lto-wrapper
Target: aarch64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.3.0-17ubuntu1~20.04' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=aarch64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --enable-fix-cortex-a53-843419 --disable-werror --enable-checking=release --build=aarch64-linux-gnu --host=aarch64-linux-gnu --target=aarch64-linux-gnu
Thread model: posix
gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04) 
But I think I was on 5.11.0-odroid-arm64 then. I doubt it'll make a difference. I always try to compile with optimizations. Especially on arm that can have a big performance impact. I should experiment some more but typing this I suddenly realize that the performance drop in my application might stem from the fact that I'm now running the non optimized SDL build. Makes sense :? ...
Should you give it a go, It's easy to reproduce. If you build SDL as described above you should have the same behaviour. Once you build the tests and launch the joystick test program

Code: Select all

testjoystick 
it'll segfault.
Should you figure it out do post back please. I would like to run an optimized build.

User avatar
odroid
Site Admin
Posts: 37286
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 1749 times
Been thanked: 1127 times
Contact:

Re: SDL2 kmsdrm keyboard locks up - ubuntu server

Post by odroid »

Thank you for the information.

I hope @tobetter will check the SDL2 functionality one day.

User avatar
tobetter
Posts: 7666
Joined: Mon Feb 25, 2013 10:55 am
languages_spoken: Korean, English
ODROIDs: Many
Location: Paju, South Korea
Has thanked: 421 times
Been thanked: 1175 times
Contact:

Re: SDL2 kmsdrm keyboard locks up - ubuntu server

Post by tobetter »

C1-10P wrote:
Mon Apr 05, 2021 4:23 pm
Sure

Code: Select all

****@n2plus:~$ uname -r
5.11.8-odroid-arm64
****@n2plus:~$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/aarch64-linux-gnu/9/lto-wrapper
Target: aarch64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.3.0-17ubuntu1~20.04' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=aarch64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --enable-fix-cortex-a53-843419 --disable-werror --enable-checking=release --build=aarch64-linux-gnu --host=aarch64-linux-gnu --target=aarch64-linux-gnu
Thread model: posix
gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04) 
But I think I was on 5.11.0-odroid-arm64 then. I doubt it'll make a difference. I always try to compile with optimizations. Especially on arm that can have a big performance impact. I should experiment some more but typing this I suddenly realize that the performance drop in my application might stem from the fact that I'm now running the non optimized SDL build. Makes sense :? ...
Should you give it a go, It's easy to reproduce. If you build SDL as described above you should have the same behaviour. Once you build the tests and launch the joystick test program

Code: Select all

testjoystick 
it'll segfault.
Should you figure it out do post back please. I would like to run an optimized build.
I've tested SDL on Linux kernel 5.11 in console mode and can run testjoystick and not having segfault error, absolutely I've compiled the library with the optimization options.

Code: Select all

$ CFLAGS='-frecord-gcc-switches -mcpu=cortex-a73.cortex-a53 -mtune=cortex-a73.cortex-a53' ./configure --prefix=/usr/local --enable-video-opengl --enable-video-opengles1 --enable-video-opengles2 --disable-video-x11 --disable-pulseaudio --disable-esd --disable-dbus --disable-video-wayland --enable-alsa --disable-video-rpi --disable-video-vulkan --enable-video-kmsdrm --enable-kmsdrm-shared
...
SDL2 Configure Summary:
Building Shared Libraries
Building Static Libraries
Enabled modules : atomic audio video render events joystick haptic sensor power filesystem threads timers file loadso cpuinfo assembly
Assembly Math   :
Audio drivers   : disk dummy oss alsa(dynamic) nas(dynamic)
Video drivers   : dummy kmsdrm(dynamic) opengl_es2
Input drivers   : linuxev linuxkd
Enable virtual joystick APIs : YES
Using libsamplerate : NO
Using libudev       : YES
Using dbus          : NO
Using ime           : YES
Using ibus          : NO
Using fcitx         : NO
...
$ make $(nproc)
...
libtool: compile:  gcc -mcpu=cortex-a73.cortex-a53 -mtune=cortex-a73.cortex-a53 -DUSING_GENERATED_CONFIG_H -Iinclude -I/home/tobetter/SDL/include -idirafter /home/tobetter/SDL/src/video/khronos -Wall -fno-strict-aliasing -fvisibility=hidden -Wdeclaration-after-statement -Werror=declaration-after-statement -DMESA_EGL_NO_X11_HEADERS -DEGL_NO_X11 -I/usr/include/libdrm -I/home/tobetter/SDL/src/hidapi/hidapi -D_REENTRANT -DHAVE_LINUX_VERSION_H -MMD -MT build/SDL_test_common.lo -c /home/tobetter/SDL/src/test/SDL_test_common.c -o build/SDL_test_common.o >/dev/null 2>&1
...
$ sudo make install
I confirmed the library if it's built with the options.

Code: Select all

$ ldd  testjoystick
        linux-vdso.so.1 (0x0000ffffb2519000)
        libSDL2-2.0.so.0 => /usr/local/lib/libSDL2-2.0.so.0 (0x0000ffffb22df000)
        libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x0000ffffb214a000)
        /lib/ld-linux-aarch64.so.1 (0x0000ffffb24e6000)
        libm.so.6 => /lib/aarch64-linux-gnu/libm.so.6 (0x0000ffffb20a0000)
        libdl.so.2 => /lib/aarch64-linux-gnu/libdl.so.2 (0x0000ffffb208c000)
        libpthread.so.0 => /lib/aarch64-linux-gnu/libpthread.so.0 (0x0000ffffb205c000)
$ readelf -p .GCC.command.line /usr/local/lib/libSDL2-2.0.so.0  | grep -e cortex
  [   16d]  -mcpu=cortex-a73.cortex-a53
  [   189]  -mtune=cortex-a73.cortex-a53

C1-10P
Posts: 19
Joined: Sat Jan 09, 2021 9:34 pm
languages_spoken: dutch, english, french
ODROIDs: XU4, N2plus
Has thanked: 3 times
Been thanked: 5 times
Contact:

Re: SDL2 kmsdrm keyboard locks up - ubuntu server

Post by C1-10P »

It's good to know that it works on your end.
On mine it doesn't however. On my current kernel I don't have the segfaults any more, it just locks up.
I compiled it exactly as you did this time.
I don't get it ... I still have an emmc around and I could rebuild the system ...
Thank you for verifying. At least now I know it's not a structural but a local issue.

User avatar
tobetter
Posts: 7666
Joined: Mon Feb 25, 2013 10:55 am
languages_spoken: Korean, English
ODROIDs: Many
Location: Paju, South Korea
Has thanked: 421 times
Been thanked: 1175 times
Contact:

Re: SDL2 kmsdrm keyboard locks up - ubuntu server

Post by tobetter »

C1-10P wrote:
Sat Apr 10, 2021 8:51 pm
It's good to know that it works on your end.
On mine it doesn't however. On my current kernel I don't have the segfaults any more, it just locks up.
I compiled it exactly as you did this time.
I don't get it ... I still have an emmc around and I could rebuild the system ...
Thank you for verifying. At least now I know it's not a structural but a local issue.
I'm wondering if you have resolved the segfault issue and how you are measuring the performance. :)

C1-10P
Posts: 19
Joined: Sat Jan 09, 2021 9:34 pm
languages_spoken: dutch, english, french
ODROIDs: XU4, N2plus
Has thanked: 3 times
Been thanked: 5 times
Contact:

Re: SDL2 kmsdrm keyboard locks up - ubuntu server

Post by C1-10P »

Hi, no, I haven't resolved the segfault/lockup with the optimized build. I haven't booted the n2plus since actually.

I don't really measure the SDL2 performance as such.

The application outputs its performance with different workloads. With the non optimized SDL2 build a given load runs at about 78% and with the optimized build it ran at 85% speed.
Nothing else had changed and deduction wise it has to be the difference in the build.

I plan to rebuild everything from scratch to document the whole procedure so I hope that my segfault/lockup issue will be gone with a new build.
I tinkered a lot figuring everything out and I must have broken something along the way I guess ... I really wouldn't know where to look actually ...

Post Reply

Return to “General Topics”

Who is online

Users browsing this forum: No registered users and 1 guest