Skip to content

Conversation

MonsterJoysticks
Copy link
Contributor

Point to an updated driver repository that uses the WiringPi library for compatibility with all Respberry Pi Versions.

Point to an updated driver repository that uses the WiringPi library for compatibility with all Respberry Pi Versions.
@cmitu
Copy link
Contributor

cmitu commented Jan 13, 2025

@MonsterJoysticks thank you for the PR. I noticed you opened also a PR on the upstream repository, I'd rather wait for it to be concluded before accepting this PR as-is. Florian might take some time to respond, so we'll have to wait a bit and see which repository can be used in this scriptmodule.

I've taken a look at the new version and even tried to install it, but I hit a couple of errors on the way, on my Pi4 system:

  • building lib/confuse doesn't work due to a too much old config.guess (error is: configure: error: cannot guess build type; you must specify one). Using a more recent config.guess from upstream solves the issue.
  • WiringPi library installaion fails due to the arch mismatch - Pi4 on 64bit, with RaspiOS Bookworm installed. This can be solved by detecting the arch of the system and downloading the appropriate .deb file from the (new) WiringPi Github repository release page.

Which system(s) did you use to test the new driver installation/operation ?

EDIT: I also tested the installation on a Pi3 with RaspiOS Buster. While the 2 previous errors are no longer present, the build step fails with:

 CC uinput_kbd.c
uinput_kbd.c: In function ‘uinput_kbd_open’:
uinput_kbd.c:49:2: warning: ‘strncpy’ output truncated before terminating nul copying 23 bytes from a string of the same length [-Wstringop-truncation]
  strncpy(uinp.name, "SNES-to-Keyboard Device", strlen("SNES-to-Keyboard Device"));
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 CC btn.c
 CC cpuinfo.c
 CC GPIO.c
 CC gamepad.c
 CC uinput_gamepad.c
uinput_gamepad.c: In function ‘uinput_gpad_open’:
uinput_gamepad.c:70:2: warning: ‘strncpy’ output truncated before terminating nul copying 22 bytes from a string of the same length [-Wstringop-truncation]
  strncpy(uinp.name, "SNES-to-Gamepad Device", strlen("SNES-to-Gamepad Device"));
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 CC SNESDev.c
SNESDev.c:40:10: fatal error: confuse.h: No such file or directory
 #include "confuse.h"
          ^~~~~~~~~~~
compilation terminated.

@MonsterJoysticks
Copy link
Contributor Author

Thanks for looking into it. Im using the 32bit versions of the Raspberry Pi OS and WiringPi on a Pi 5. I had the same issue with the confuse library but i thought i had resolved that by adding the "cd libs/confuse-2.7 && make" line to the Makefile https://github.com/MonsterJoysticks/SNESDev-RPi-Wiring-Pi/blob/master/Makefile

you'll have to forgive my lack of knowledge on these scripts but I’ll see about adding some kind of statement to detect the architecture of the system and install the corresponding library.

Let me sort these issues out and get back to you.

@cmitu
Copy link
Contributor

cmitu commented Jan 13, 2025

you'll have to forgive my lack of knowledge on these scripts but I’ll see about adding some kind of statement to detect the architecture of the system and install the corresponding library.

RetroPie has a 64bit flag you can use to check whether you're on a 64bit (aarch64) or 32bit (armhf) system. See here for instance on how it's used.

@MonsterJoysticks
Copy link
Contributor Author

MonsterJoysticks commented Jan 13, 2025

Thanks, i have already pushed an update to my repository and i believe it should work on both versions.

I ended up using the ARCH = $(shell getconf LONG_BIT) to determine 64 or 32 bit OS install, it then gets the version 3.2 of the wiringpi library and installs that. I also added an install for the libconfuse-dev package using apt-get as that was also arch dependant.

@MonsterJoysticks
Copy link
Contributor Author

sorry i think i spoke too soon, i have just made another change to the repo i'll let you know when its all ready.

@MonsterJoysticks
Copy link
Contributor Author

Ok i think that should all work correctly now. Apologies.

@cmitu
Copy link
Contributor

cmitu commented Jan 14, 2025

Ok i think that should all work correctly now. Apologies.

No need for apologies, there's nothing broken and regardless - this is your own free time you're donating.

I'll take a look and test on my systems, thanks you for changes.

@cmitu
Copy link
Contributor

cmitu commented Jan 14, 2025

@MonsterJoysticks I re-tested the installation from your repository and

  • the Pi4/aarch64 on RaspiOS Bookworm works now, due to the correct .deb being downloaded, so that's fixed.
  • the Pi3/armhf on RaspiOS Buster is still not working and assume it's because the .deb it installs requires a recent RaspiOS version. The error during compilation is:
cd src && make all
make[1]: Entering directory '/opt/retropie/supplementary/snesdev/src'
 CC uinput_kbd.c
uinput_kbd.c: In function ‘uinput_kbd_open’:
uinput_kbd.c:49:2: warning: ‘strncpy’ output truncated before terminating nul copying 23 bytes from a string of the same length [-Wstringop-truncation]
  strncpy(uinp.name, "SNES-to-Keyboard Device", strlen("SNES-to-Keyboard Device"));
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 CC btn.c
 CC cpuinfo.c
 CC GPIO.c
 CC gamepad.c
 CC uinput_gamepad.c
uinput_gamepad.c: In function ‘uinput_gpad_open’:
uinput_gamepad.c:70:2: warning: ‘strncpy’ output truncated before terminating nul copying 22 bytes from a string of the same length [-Wstringop-truncation]
  strncpy(uinp.name, "SNES-to-Gamepad Device", strlen("SNES-to-Gamepad Device"));
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 CC SNESDev.c
In file included from SNESDev.c:40:
SNESDev.c: In function ‘readConfigurationfile’:
SNESDev.c:120:42: warning: initialization of ‘long int *’ from incompatible pointer type ‘cfg_bool_t *’ {aka ‘enum <anonymous> *’} [-Wincompatible-pointer-types]
         CFG_SIMPLE_INT("button_enabled", &confres.button_enabled),
                                          ^
SNESDev.c:120:42: note: (near initialization for ‘opts[0].simple_value.number’)
SNESDev.c:121:44: warning: initialization of ‘long int *’ from incompatible pointer type ‘cfg_bool_t *’ {aka ‘enum <anonymous> *’} [-Wincompatible-pointer-types]
         CFG_SIMPLE_INT("gamepad1_enabled", &confres.gamepad1_enabled),
                                            ^
SNESDev.c:121:44: note: (near initialization for ‘opts[1].simple_value.number’)
SNESDev.c:123:44: warning: initialization of ‘long int *’ from incompatible pointer type ‘cfg_bool_t *’ {aka ‘enum <anonymous> *’} [-Wincompatible-pointer-types]
         CFG_SIMPLE_INT("gamepad2_enabled", &confres.gamepad2_enabled),
                                            ^
SNESDev.c:123:44: note: (near initialization for ‘opts[3].simple_value.number’)
 Linking...
/usr/bin/ld: /usr/lib/gcc/arm-linux-gnueabihf/8/../../../libwiringPi.so: undefined reference to `pthread_join@GLIBC_2.34'
/usr/bin/ld: /usr/lib/gcc/arm-linux-gnueabihf/8/../../../libwiringPi.so: undefined reference to `stat@GLIBC_2.33'
/usr/bin/ld: /usr/lib/gcc/arm-linux-gnueabihf/8/../../../libwiringPi.so: undefined reference to `shm_open@GLIBC_2.34'
/usr/bin/ld: /usr/lib/gcc/arm-linux-gnueabihf/8/../../../libwiringPi.so: undefined reference to `crypt@XCRYPT_2.0'
/usr/bin/ld: /usr/lib/gcc/arm-linux-gnueabihf/8/../../../libwiringPi.so: undefined reference to `pow@GLIBC_2.29'
/usr/bin/ld: /usr/lib/gcc/arm-linux-gnueabihf/8/../../../libwiringPi.so: undefined reference to `pthread_cancel@GLIBC_2.34'
/usr/bin/ld: /usr/lib/gcc/arm-linux-gnueabihf/8/../../../libwiringPi.so: undefined reference to `pthread_create@GLIBC_2.34'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:14: all] Error 1
make[1]: Leaving directory '/opt/retropie/supplementary/snesdev/src'
make: *** [Makefile:31: all] Error 2

Leaving aside the WirinPi installation, one improvement for the script would be to add specifically the libconfuse-dev as a depedency in the depends_snesdev function:

function depends_snesdev() {
    getDepends libconfuse-dev
}

I'll if WirinPi can be independently compiled and included so we don't have to rely on the .deb provided and in the mean time let's wait a bit to see if your PR on the upstream repository is accepted/considered.

@MonsterJoysticks
Copy link
Contributor Author

Thats annoying that you get those errors, on the github page they make a point of it being compatible with all verisons of the Pi so it may just be the operating system itself or maybe need compiling on the older OS. Lets see if the PR is considered/accepted and in the meantime ill look at adding the dependancy to the script.

@cmitu
Copy link
Contributor

cmitu commented Jan 15, 2025

Thats annoying that you get those errors, on the github page they make a point of it being compatible with all verisons of the Pi [..]

Sure, but that doesn't mean the .deb packages will run on any OS. Source installation is fine, so even on an old OS it still installable, just not from the pre-built packages.

@MonsterJoysticks
Copy link
Contributor Author

I have adjusted the Makefile on my fork of the SNESDev Driver so that it clones into the WiringPi git and then runs the build process. I think this should improve compatibility as mentioned, im not sure if this is considered the "correct" way to do this but it does seem to work on my tests.

@cmitu
Copy link
Contributor

cmitu commented Jan 26, 2025

I think it's best to leave the WirinPi installation alone (and mention it as a depedency, like libconfuse) or as a separate target of the makefile. I can add the wiringpi installation to the scriptmodule in a separate step so it will not be an issue for the installation of the main program - we usually don't install things in the system without a possibility to remove it and adding libwiringpi.so to /usr/local/lib without an uninstall script is not so good.

@MonsterJoysticks
Copy link
Contributor Author

MonsterJoysticks commented Feb 21, 2025

i have rolled back the building and installing of WiringPi and libconfuse in the Makefile, i have added a dependency libconfuse to the snesdev.sh file in the fork of the RetroPie-Setup script. If you can create a seperate step in the scriptmodule for the WiringPi library that would be great https://github.com/WiringPi/WiringPi i found that the build process is simpler than that mentioned in the readme.md, you only need to execute the ./build command.

@cmitu
Copy link
Contributor

cmitu commented Feb 23, 2025

@MonsterJoysticks I have a preliminary set of modifications at master...cmitu:RetroPie-Setup:snesdev-update

In order to be able to compile a local static library (for WiringPi), there's a minor modification that needs to be added to the makefile in snesdev/src:

diff --git a/src/Makefile b/src/Makefile
index e2ee013..19bb070 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,8 +1,8 @@
 CC=gcc
 SRCDIR=.
 BUILDDIR=../build
-CFLAGS=-Wall -O3
-LIBS=-lwiringPi -lpthread -lrt -lconfuse
+CFLAGS+=-Wall -O3
+LIBS=-lwiringPi -lpthread -lrt -lconfuse $(LDFLAGS)

 TARGET := SNESDev
 SRCEXT := c

I say it's preliminary since I also want to replace the service part with a systemd unit file.

@cmitu
Copy link
Contributor

cmitu commented Feb 23, 2025

Ok, added the systemd bit and reworked a bit the installation, if you want to test it, you can use the new version from master...cmitu:RetroPie-Setup:snesdev-update

@MonsterJoysticks
Copy link
Contributor Author

I have just tested it on the Pi 5 and it worked great after i removed the !rpi5 from line 16 of the snesdev.sh file. thanks so much for the help. Hopefully we can get this out into the wild so people can use it with the Pi5 and i can keep the drivers updated with the wirring pi library.

@cmitu
Copy link
Contributor

cmitu commented Feb 28, 2025

@MonsterJoysticks oh yes, I forgot to remove the Pi5 restriction, I updated my branch.

I don't see the modification to makefile in your repo though - the compilation will not work when the user doesn't have an up-to-date wiringpi package. In order to build the wiringpi statically into SNESDev (when there's no suitable wiringpi detected), the Makefile in your repoitory needs to be modified accordingly - see my previous post. Would you like me to send you a PR with the modifications or you can apply them yourself ?

@MonsterJoysticks
Copy link
Contributor Author

Apologies i must have forgot to push the change up. Thats all sorted out now.

@cmitu cmitu merged commit 71e7fbb into RetroPie:master Mar 2, 2025
@cmitu
Copy link
Contributor

cmitu commented Mar 2, 2025

@MonsterJoysticks thank you for the changes and modifications added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants