RetroArch and MDEV

Hi there,

As you may know, on embedded GNU/Linux systems it’s very common to use busybox’s MDEV instead of the more complex UDEV.

So, I am trying to use RetroArch in such a system (nothing special, just a Pi4 wich I boot using my own minimal script, so it uses busybox’s MDEV). I don’t think I am the first person trying this, but who knows.

Thing is, RetroArch has three input backends for GNU/Linux without X11:

–UDEV, which is not running on this system.

–LINUXRAW, which only seems to work with USB keyboard input, and ignores any USB joysticks since they appear to be disabled on the input settings.

–SDL2, which is OK I guess (SDL2 programs access the USB joysticks fine using MDEV), but I would like RetroArch to work without depending on SDL2.

So, what’s busybox’s MDEV missing from the RetroArch point of view? Shouldn’t RetroArch work on MDEV as if it was UDEV? (I mean, MDEV creates and manages the same /dev/input/event* nodes, which RetroArch is supposed to use).

Is SDL2 my only alternative when not using UDEV?

Thanks!

NOTE: It’s not a node access permissions problem, since this system is root-only.

This is what RetroArch accesses on a system with UDEV:

~# lsof -n -p 584 |grep dev
retroarch 584 root  mem       CHR 226,128              398 /dev/dri/renderD128
retroarch 584 root  mem       CHR  116,16              461 /dev/snd/pcmC0D0p
retroarch 584 root  mem       REG  179,11   166048 1053831 /usr/lib/aarch64-linux-gnu/libudev.so.1.6.3
retroarch 584 root    0r      CHR     4,1      0t0      22 /dev/tty1
retroarch 584 root    1w      CHR     4,1      0t0      22 /dev/tty1
retroarch 584 root    2w      CHR     4,1      0t0      22 /dev/tty1
retroarch 584 root    3u      CHR 226,128      0t0     398 /dev/dri/renderD128
retroarch 584 root    4u      CHR   226,1      0t0     475 /dev/dri/card1
retroarch 584 root    5u      CHR   226,1      0t0     475 /dev/dri/card1
retroarch 584 root    9r      CHR   13,64      0t0     350 /dev/input/event0
retroarch 584 root   10r      CHR   13,65      0t0     352 /dev/input/event1
retroarch 584 root   11r      CHR   13,67      0t0     458 /dev/input/event3
retroarch 584 root   12r      CHR   13,68      0t0     464 /dev/input/event4
retroarch 584 root   13u      CHR   13,66      0t0     388 /dev/input/event2
retroarch 584 root   14u      CHR   116,0      0t0     462 /dev/snd/controlC0
retroarch 584 root   15u      CHR  116,16      0t0     461 /dev/snd/pcmC0D0p
retroarch 584 root   16u      CHR   116,0      0t0     462 /dev/snd/controlC0

And this is with MDEV:

~# lsof -n -p 624
COMMAND   PID USER   FD      TYPE  DEVICE SIZE/OFF    NODE NAME
retroarch 624 root  cwd       DIR  179,11     4096 1442491 /root/emulation/nes
retroarch 624 root  rtd       DIR  179,11     4096       2 /
retroarch 624 root  txt       REG  179,11 12789952 1441929 /usr/local/bin/retroarch
retroarch 624 root  mem       CHR 226,128              378 /dev/dri/renderD128
retroarch 624 root  mem       CHR  116,16              365 /dev/snd/pcmC0D0p
retroarch 624 root  mem       REG  179,11  1310728 1442011 /root/.cache/mesa_shader_cache/index
retroarch 624 root  mem       REG  179,11    51640 1053729 /usr/lib/aarch64-linux-gnu/libnss_files-2.31.so
retroarch 624 root  mem       REG  179,11   104824 1053859 /usr/lib/aarch64-linux-gnu/libz.so.1.2.11
retroarch 624 root  mem       REG  179,11  9070552     105 /usr/local/lib/aarch64-linux-gnu/libvulkan_broadcom.so
retroarch 624 root  mem       REG  179,11   383576 1053848 /usr/lib/aarch64-linux-gnu/libvulkan.so.1.2.162
retroarch 624 root  mem       REG  179,11  5329264 1584704 /root/.config/retroarch/cores/nestopia_libretro.so
retroarch 624 root  mem       REG  179,11   526912 1053758 /usr/lib/aarch64-linux-gnu/libpcre2-8.so.0.10.1
retroarch 624 root  mem       REG  179,11  2227488      58 /usr/local/lib/aarch64-linux-gnu/libGLdispatch.so.0.0.0
retroarch 624 root  mem       REG  179,11   161856 1053594 /usr/lib/aarch64-linux-gnu/libexpat.so.1.6.12
retroarch 624 root  mem       REG  179,11   166032 1053792 /usr/lib/aarch64-linux-gnu/libselinux.so.1
retroarch 624 root  mem       REG  179,11  1458480 1053552 /usr/lib/aarch64-linux-gnu/libc-2.31.so
retroarch 624 root  mem       REG  179,11    80200 1053619 /usr/lib/aarch64-linux-gnu/libgcc_s.so.1
retroarch 624 root  mem       REG  179,11   633000 1053683 /usr/lib/aarch64-linux-gnu/libm-2.31.so
retroarch 624 root  mem       REG  179,11    14560 1053584 /usr/lib/aarch64-linux-gnu/libdl-2.31.so
retroarch 624 root  mem       REG  179,11  1854720 1053807 /usr/lib/aarch64-linux-gnu/libstdc++.so.6.0.28
retroarch 624 root  mem       REG  179,11   260448      90 /usr/local/lib/aarch64-linux-gnu/libEGL.so.1.1.0
retroarch 624 root  mem       REG  179,11   199016      98 /usr/local/lib/aarch64-linux-gnu/libGLESv2.so.2.1.0
retroarch 624 root  mem       REG  179,11   331216      65 /usr/local/lib/aarch64-linux-gnu/libdrm.so.2.4.0
retroarch 624 root  mem       REG  179,11    76616     107 /usr/local/lib/aarch64-linux-gnu/libgbm.so.1.0.0
retroarch 624 root  mem       REG  179,11   166048 1053831 /usr/lib/aarch64-linux-gnu/libudev.so.1.6.3
retroarch 624 root  mem       REG  179,11   160200 1053776 /usr/lib/aarch64-linux-gnu/libpthread-2.31.so
retroarch 624 root  mem       REG  179,11  1034440 1053527 /usr/lib/aarch64-linux-gnu/libasound.so.2.0.0
retroarch 624 root  mem       REG  179,11   145328 1053393 /usr/lib/aarch64-linux-gnu/ld-2.31.so
retroarch 624 root    0r      CHR     4,1      0t0      22 /dev/tty1
retroarch 624 root    1w      CHR     4,1      0t0      22 /dev/tty1
retroarch 624 root    2w      CHR     4,1      0t0      22 /dev/tty1
retroarch 624 root    3u      CHR 226,128      0t0     378 /dev/dri/renderD128
retroarch 624 root    4u      CHR   226,0      0t0     376 /dev/dri/card0
retroarch 624 root    5u      CHR   226,0      0t0     376 /dev/dri/card0
retroarch 624 root    6u  netlink              0t0   14349 KOBJECT_UEVENT
retroarch 624 root    7u  a_inode    0,12        0    7398 [eventpoll]
retroarch 624 root    8u  netlink              0t0   14350 KOBJECT_UEVENT
retroarch 624 root    9u      CHR   116,0      0t0     366 /dev/snd/controlC0
retroarch 624 root   10u      CHR  116,16      0t0     365 /dev/snd/pcmC0D0p
retroarch 624 root   11u      CHR   116,0      0t0     366 /dev/snd/controlC0

In the case of MDEV, it seems that RetroArch hasn’t opened any of the /dev/input/event* files. But on both cases, the same /dev/input nodes are present. Differences can be seen on the permissions and the owning of the /dev/input/event nodes.

This is with UDEV:

~# ls -l /dev/input/
total 0
drwxr-xr-x 2 root root     120 ene  1  1970 by-id
drwxr-xr-x 2 root root     160 ene  1  1970 by-path
crw-rw---- 1 root input 13, 64 ene  1  1970 event0
crw-rw---- 1 root input 13, 65 ene  1  1970 event1
crw-rw---- 1 root input 13, 66 ene  1  1970 event2
crw-rw---- 1 root input 13, 67 ene  1  1970 event3
crw-rw---- 1 root input 13, 68 ene  1  1970 event4
crw-rw---- 1 root input 13,  0 ene  1  1970 js0
crw-rw---- 1 root input 13, 63 ene  1  1970 mice

This is with MDEV:

~# ls -l /dev/input/
total 0
crw------- 1 root root 13, 64 ene  1  1970 event0
crw------- 1 root root 13, 65 ene  1  1970 event1
crw-rw---- 1 root root 13, 66 ene  1  1970 event2
crw-rw---- 1 root root 13, 67 ene  1  1970 event3
crw-rw---- 1 root root 13, 68 ene  1  1970 event4
crw-rw---- 1 root root 13,  0 ene  1  1970 js0
crw------- 1 root root 13, 63 ene  1  1970 mice
1 Like

Found the cause (and solution!)

First, a bit of story.

Obviously, RetroArch UDEV input backend relies on libudev/libeudev. libudev relies on the udev service, which in turn relies on stinky, awful and standard-breaking systemd, which does not run on my systems. There’s libeudev, which relies on eudev service, which does not depend on systemd, but eudev and libeudev have been deprecated. Project eudev seems dead, caput.

So, we GNU/Linux loyal people wanting to build truly lightweight systems are left with mdev, which is part of the almighty busybox (good luck f***ing this one like you did with the init system, major corps!)

Now, for the problem and the solution.

mdev does not provide a libudev implementation, so RetroArch doesn’t work because RetroArch uses libudev/libeudev which depends on the udev/eudev service, which is absent in my experimental systems (the libudev/libeudev library is present, but NOT the service). So, save your time: the problem are NOT the permissions/ownership of the /dev/input/event* files. The problem is libudev/libeudev not having an active udev/eudev daemon.

So some clever person has implemented a libudev drop-in solution that does NOT need a service! Here it is:

Just build and install this, along with a properly configured MDEV, and things just work: RetroArch has it’s complete UDEV support without an UDEV service of any kind!

You can eat my ***, L, Pottering!

An another solution: If you, MDEV user/experimenter, don’t want to install anything special, use the LINUXRAW driver which plays nicely with MDEV. Long live the LINUXRAW input driver!

1 Like