Fazecast / jSerialComm

Platform-independent serial port access for Java
GNU Lesser General Public License v3.0
1.33k stars 283 forks source link

Cannot load native library on Raspberry Pi Zero 2W #503

Closed toca21 closed 1 year ago

toca21 commented 1 year ago

Hi I have a RasbperryPi Zero 2W

uname -m gives "armv7l"

I am using latest jSerialComm 2.10.1

I cannot see this arch (explicitly) in the list of supported platform and wounder if this is the reason I get this when I try to setup a serial port: (Same program works perfectly on my Rpi CM4 arch aarch64)

From the lib at setup:

java.lang.Exception: java.lang.UnsatisfiedLinkError: Cannot load native library. Errors as follows: [1]: Loading for arch: armv5 [2]: /tmp/jSerialComm/2.10.1/libjSerialComm.so: /tmp/jSerialComm/2.10.1/libjSerialComm.so: cannot open shared object file: No such file or directory [3]: Loading for arch: armv6 [4]: /tmp/jSerialComm/2.10.1/libjSerialComm.so: /tmp/jSerialComm/2.10.1/libjSerialComm.so: cannot open shared object file: No such file or directory [5]: Loading for arch: armv7 [6]: /tmp/jSerialComm/2.10.1/libjSerialComm.so: /tmp/jSerialComm/2.10.1/libjSerialComm.so: cannot open shared object file: No such file or directory [7]: Loading for arch: armv8_64 [8]: /tmp/jSerialComm/2.10.1/libjSerialComm.so: /tmp/jSerialComm/2.10.1/libjSerialComm.so: wrong ELF class: ELFCLASS64 (Possible cause: architecture word width mismatch) [9]: Loading for arch: x86_64 [10]: /tmp/jSerialComm/2.10.1/libjSerialComm.so: /tmp/jSerialComm/2.10.1/libjSerialComm.so: wrong ELF class: ELFCLASS64 (Possible cause: architecture word width mismatch) [11]: Loading for arch: armv8_32 [12]: /tmp/jSerialComm/2.10.1/libjSerialComm.so: /tmp/jSerialComm/2.10.1/libjSerialComm.so: cannot open shared object file: No such file or directory [13]: Loading for arch: ppc64le [14]: /tmp/jSerialComm/2.10.1/libjSerialComm.so: /tmp/jSerialComm/2.10.1/libjSerialComm.so: wrong ELF class: ELFCLASS64 (Possible cause: architecture word width mismatch) [15]: Loading for arch: x86 [16]: /tmp/jSerialComm/2.10.1/libjSerialComm.so: /tmp/jSerialComm/2.10.1/libjSerialComm.so: cannot open shared object file: No such file or directory (Possible cause: can't load IA 32-bit .so on a ARM-bit platform) [17]: Loading for arch: armv5 [18]: /root/.jSerialComm/2.10.1/libjSerialComm.so: /root/.jSerialComm/2.10.1/libjSerialComm.so: cannot open shared object file: No such file or directory [19]: Loading for arch: armv6 [20]: /root/.jSerialComm/2.10.1/libjSerialComm.so: /root/.jSerialComm/2.10.1/libjSerialComm.so: cannot open shared object file: No such file or directory [21]: Loading for arch: armv7 [22]: /root/.jSerialComm/2.10.1/libjSerialComm.so: /root/.jSerialComm/2.10.1/libjSerialComm.so: cannot open shared object file: No such file or directory [23]: Loading for arch: armv8_64 [24]: /root/.jSerialComm/2.10.1/libjSerialComm.so: /root/.jSerialComm/2.10.1/libjSerialComm.so: wrong ELF class: ELFCLASS64 (Possible cause: architecture word width mismatch) [25]: Loading for arch: x86_64 [26]: /root/.jSerialComm/2.10.1/libjSerialComm.so: /root/.jSerialComm/2.10.1/libjSerialComm.so: wrong ELF class: ELFCLASS64 (Possible cause: architecture word width mismatch) [27]: Loading for arch: armv8_32 [28]: /root/.jSerialComm/2.10.1/libjSerialComm.so: /root/.jSerialComm/2.10.1/libjSerialComm.so: cannot open shared object file: No such file or directory [29]: Loading for arch: ppc64le [30]: /root/.jSerialComm/2.10.1/libjSerialComm.so: /root/.jSerialComm/2.10.1/libjSerialComm.so: wrong ELF class: ELFCLASS64 (Possible cause: architecture word width mismatch) [31]: Loading for arch: x86 [32]: /root/.jSerialComm/2.10.1/libjSerialComm.so: /root/.jSerialComm/2.10.1/libjSerialComm.so: cannot open shared object file: No such file or directory (Possible cause: can't load IA 32-bit .so on a ARM-bit platform) in null at line -1

From error log: OpenJDK Server VM warning: You have loaded library /tmp/jSerialComm/2.10.1/libjSerialComm.so which might have disabled stack guard. The VM will try to fix the stack guard now. It's highly recommended that you fix the library with 'execstack -c ', or link it with '-z noexecstack'.

java -version gives: openjdk version "11.0.18" 2023-01-17 OpenJDK Runtime Environment (build 11.0.18+10-post-Raspbian-1deb11u1) OpenJDK Server VM (build 11.0.18+10-post-Raspbian-1deb11u1, mixed mode)

toca21 commented 1 year ago

I can add that I have already tried with -Dos.arch_full=armv7-hf and -Dos.arch_full=armv7 that gives same error, but less logs.

java.lang.Exception: java.lang.UnsatisfiedLinkError: Cannot load native library. Errors as follows: [1]: Loading for arch: armv7 [2]: /tmp/jSerialComm/2.10.1/libjSerialComm.so: /tmp/jSerialComm/2.10.1/libjSerialComm.so: cannot open shared object file: No such file or directory [3]: Loading for arch: armv7 [4]: /root/.jSerialComm/2.10.1/libjSerialComm.so: /root/.jSerialComm/2.10.1/libjSerialComm.so: cannot open shared object file: No such file or directory in null at line -1

toca21 commented 1 year ago

Ah, I backed down to version 2.9.3 and it works!

hedgecrw commented 1 year ago

Ah yes, I see the issue. Could you please test the latest 2.10.2-SNAPSHOT version and see if it fixes your issue.

SNAPSHOT Version: 2.10.2-SNAPSHOT SNAPSHOT Direct Download Link SNAPSHOT Instructions

hedgecrw commented 1 year ago

Updated Direct Download Link

toca21 commented 1 year ago

Works perfectly with jSerialComm-2.10.2-20230706.195811-4.jar on my Rpi Z W2 now!

However, I also have some Rpi Z W with armv6l cores and had the exact same issue there with same error logs and everything when running 2.10.1. Now when testing this new version of jSerialComm on the armv6l it creates a fatal crash and the JVM stops. Note, I did not confirm with 2.9.3 on the armv6l as I did with the W2. Should I do that or was this version not a release candidate for multi platform perhaps?

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGILL (0x4) at pc=0xa8cb93da, pid=785, tid=853
#
# JRE version: OpenJDK Runtime Environment Zulu11.41+75-CA (11.0.8+10) (build 11.0.8+10-LTS)
# Java VM: OpenJDK Client VM Zulu11.41+75-CA (11.0.8+10-LTS, mixed mode, serial gc, linux-arm)
# Problematic frame:
# C  [libjSerialComm.so+0x53da]  Java_com_fazecast_jSerialComm_SerialPort_uninitializeLibrary+0x19
hedgecrw commented 1 year ago

Please try the most recent release v2.10.2

hedgecrw commented 1 year ago

Any update as to whether the latest release solved this issue?

toca21 commented 1 year ago

Will, sorry for not getting back. Will test by the end of this week and give you an update!

Den ons 19 juli 2023 17:36Will Hedgecock @.***> skrev:

Any update as to whether the latest release solved this issue?

— Reply to this email directly, view it on GitHub https://github.com/Fazecast/jSerialComm/issues/503#issuecomment-1642317921, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADEG4KQANH32YOLMGIYRM53XQ75GRANCNFSM6AAAAAAZ763YDM . You are receiving this because you authored the thread.Message ID: @.***>

toca21 commented 1 year ago

I can now confirm that 2.10.2 is working on (at least): Raspberry Pi 1W Raspberry Pi 2W Raspberry CM4 Banana PiZ

Good work and excellent support! Let me know if you need some more verification's in the future. I have apps running on several pi:s variants.

hedgecrw commented 1 year ago

Great! Thanks for the offer…I’ll definitely reach out in the future if I need some cross-device testing! Appreciate it.