Mailbox_test - non-root user unable to run (open failed! fd = -1)

I have created a non-root user on the milkv-duo named david (me) and login, shell, etc. all works fine. However, after building the mailbox_test example and transferring it to the duo, root can run the file just fine, but attempting to run as david results in the following error:

03:07 milkv-duo:~> ./tmp/mailbox_test
open failed! fd = -1

root has no problem:

[03:08 milkv-duo:~] # /home/david/tmp/mailbox_test
C906B: cmd.param_ptr = 0x4
C906B: cmd.param_ptr = 0x3

The user david has UID 10011. The user belongs to the david group GID 1060 as the primary group, as well as the wheel group. Unix file-permissions are not the problem:

03:26 milkv-duo:~> l tmp/mailbox_test
-rwxr-xr-x    1 david    david        10064 Jan  1  1970 tmp/mailbox_test

and the file can be opened and read by the user without issue:

03:27 milkv-duo:~> hexdump -Cv -n 64 tmp/mailbox_test
00000000  7f 45 4c 46 02 01 01 00  00 00 00 00 00 00 00 00  |.ELF............|
00000010  02 00 f3 00 01 00 00 00  70 06 01 00 00 00 00 00  |........p.......|
00000020  40 00 00 00 00 00 00 00  d0 1f 00 00 00 00 00 00  |@...............|
00000030  05 00 00 00 40 00 38 00  07 00 40 00 1e 00 1d 00  |....@.8...@.....|

The user logs in on tty /dev/pts/1, and the device permissions seem fine, e.g.

03:23 milkv-duo:~> l /dev/pts
total 0
drwxr-xr-x    2 root     root             0 Jan  1  1970 .
drwxr-xr-x    6 root     root          1480 Jan  1  1970 ..
crw--w----    1 root     tty       136,   0 Jan  7 03:22 0
crw--w----    1 david    tty       136,   1 Jan  7 03:23 1
crw-rw-rw-    1 root     root        5,   2 Jan  1  1970 ptmx

I’ve also tried adding the user to adm, sys and tty groups (logging out/in) following each change and sync, so I’m left scratching my head.

Anybody know why the non-root user cannot execute the mailbox_test example on the duo?

Footnotes:

1 dhcpcd already had UID 1000 – poor choice as most distros start user UIDs at 1000 – which will cause issues with file mapping if the user on the host was the first user and has UID 1000 and now has something different on the duo.

The crux of the issue is /dev/mem and for reasons unexplained the current sdk creates files where wiringX directly access /dev/mem instead of access through /proc/. There is no way the non-root user can access /dev/mem directly and only by kernel config can root directly manipulate the physical RAM on a Linux virtual memory system.

After resolving other permission issues, I found:

$ blink15
ERROR: wiringX failed to open /dev/mem for raw memory access
ERROR: The Sophgo CV180 has not yet been setup by wiringX
ERROR: The Sophgo CV180 has not yet been setup by wiringX
 1  Duo LED GPIO (wiringX) 15: High ==> Low
ERROR: The Sophgo CV180 has not yet been setup by wiringX
ERROR: The Sophgo CV180 has not yet been setup by wiringX
 2  Duo LED GPIO (wiringX) 15: High ==> Low
...

So no program run by a non-root user that uses wiringX will ever be able to run.

Where does the wiringX library included in the buildroot come from?

I’ve checked the buildroot source and wiringx is not build from source, but instead has a non-standard libwiringx.so in duo-buildroot-sdk/buildroot-2021.05/package/wiringx/src (which includes PWM functions not found in the wiringX git repository).

Where is the source for the wiringX including in the duo-buildroot-sdk?