openHAB on Synology DS418 - Serial Binding Problem

Hi,

I installed the Openhab 2.3 Synology .spk on my diskstation. Openhab runs OK, but I am having trouble getting serial ports running.

I tried all kinds of solutions on the internet, like adding usergroups dialout and uucd, access rights to /run/lock and /dev/tty* etc.

Nothing helps…

When I start Openhab from the command line using start.sh I get the message:

/volume1/SmartHome/openHAB/userdata/tmp/libNRJavaSerial_root_0/libNRJavaSerial.so: /volume1/SmartHome/openHAB/userdata/tmp/libNRJavaSerial_root_0/libNRJavaSerial.so: wrong ELF class: ELFCLASS32 (Possible cause: can’t load IA 32-bit .so on a ARM-64bit platform)

It looks like the problem is that Openhab tries to load a 32bit Intel library. My Synology has a Realtek RTD1296 CPU, which has a 64bit ARMv8 hardfloat architecture.

It seems the problem is in the package nrjavaserial. In my Openhab release version 3.12OH is included. I uninstalled this package through the karaf command line and put version 3.15 in the addons folder. From version 3.14 nrjavaserial supports ARMv8. The problem is still there, so it seems the problem is in Openhab itself, it tries to load the wrong .so

Can somebody please help me with this issue? I have spent many hours on this, but still no success. Thank you

Regards,

Robin

I don’t use Synology but from the log I see that the old library is still in tmp
did you try to clean cache & tmp after you deployed the new nrjavaserial jar in the addons folder to see if this helps?

Yes that was my first thought as well. Unfortunately Openhab still copies the x32 version of libNRJavaSerial.so when I delete the tmp folder

Can you try the latest Snapshot? (OH 2.4.0 Build #1431) from here: https://ci.openhab.org/job/openHAB-Distribution/

From what I remember, it includes a lot of improvements with regards to the serial handling.

Thanks for your quick reply. Can you tell me how I update the Openhab version on my ds418? I tried to reinstall the spk, but that install the 2.3 version

I don’t think that there is an available spk package of 2.4.0 Snapshot (https://github.com/openhab/openhab-syno-spk/releases)
Can you try to install it manually using the openhab-2.4.0-SNAPSHOT.tar.gz ? (I really don’t know if this is possible)

What you can try is: leave the 2.3.0 spk installed and overwrite everything from the tar.gz

1 Like

I’ll try that tonight. Have to work now :-). Thanks!

1 Like

found a relevant issue on: https://github.com/openhab/openhab-syno-spk/issues/136

I tried to install nrjavaserial 3.15.0 OH from the link above. Unfortunately the problem still exists. I had no time yet to try to install openhab 2.4.

I copied all files from the 2.4 snapshot version to the openHAB directory, cleared the tmp folder and after setting up folder permissions I got a fresh install of Openhab 2.4 running. I installed the Z-wave binding and I got two nrjavaserial installed, version 3.14 en 3.15 OH.

On karaf I still got the same error, but in Paper UI I have a thing in my inbox, the Aeon z-stick. When I add this as a thing it hangs on status initializing. The console says:

/volume1/@appstore/openHAB/userdata/tmp/libNRJavaSerial_root_0/libNRJavaSerial.so: /volume1/@appstore/openHAB/userdata/tmp/libNRJavaSerial_root_0/libNRJavaSerial.so: wrong ELF class:
 ELFCLASS32 (Possible cause: can't load IA 32-bit .so on a ARM-bit platform)
/volume1/@appstore/openHAB/userdata/tmp/libNRJavaSerial_legacy_root_0/libNRJavaSerial_legacy.so: /volume1/@appstore/openHAB/userdata/tmp/libNRJavaSerial_legacy_root_0/libNRJavaSerial_legacy.so: wrong ELF class: ELFCLASS32 (Possible cause: can't load IA 32-bit .so on a ARM-bit platform)
java.lang.UnsatisfiedLinkError: /volume1/@appstore/openHAB/userdata/tmp/libNRJavaSerial_root_0/libNRJavaSerial.so: /volume1/@appstore/openHAB/userdata/tmp/libNRJavaSerial_root_0/libNRJavaSerial.so: wrong ELF class: 
ELFCLASS32 (Possible cause: can't load IA 32-bit .so on a ARM-bit platform)
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824)
    at java.lang.Runtime.load0(Runtime.java:809)
    at java.lang.System.load(System.java:1086)

I tried to uninstall 3.14 and 3.15 OH to have only one nrjavaserial, but they both give the same error. This is what my openHAB logfile says:

2018-11-19 10:50:04.125 [INFO ] [thome.model.lsp.internal.ModelServer] - Started Language Server Protocol (LSP) service on port 5007
2018-11-19 10:50:07.423 [INFO ] [basic.internal.servlet.WebAppServlet] - Started Basic UI at /basicui/app
2018-11-19 10:50:08.046 [INFO ] [arthome.ui.paper.internal.PaperUIApp] - Started Paper UI at /paperui
2018-11-19 10:50:08.259 [INFO ] [panel.internal.HABPanelDashboardTile] - Started HABPanel at /habpanel
2018-11-19 10:50:08.804 [ERROR] [e.smarthome.io.transport.serial.rxtx] - FrameworkEvent ERROR - org.eclipse.smarthome.io.transport.serial.rxtx
org.osgi.framework.BundleException: Could not resolve module: org.eclipse.smarthome.io.transport.serial.rxtx [206]
  Unresolved requirement: Import-Package: gnu.io

	at org.eclipse.osgi.container.Module.start(Module.java:444) [?:?]
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1634) [?:?]
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1614) [?:?]
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1585) [?:?]
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1528) [?:?]
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) [?:?]
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) [?:?]
	at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340) [?:?]
2018-11-19 10:50:08.887 [ERROR] [org.openhab.binding.dsmr            ] - FrameworkEvent ERROR - org.openhab.binding.dsmr
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.dsmr [207]
  Unresolved requirement: Import-Package: gnu.io

	at org.eclipse.osgi.container.Module.start(Module.java:444) [?:?]
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1634) [?:?]
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1614) [?:?]
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1585) [?:?]
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1528) [?:?]
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) [?:?]
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) [?:?]
	at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340) [?:?]
2018-11-19 10:50:09.382 [ERROR] [org.openhab.binding.zwave           ] - FrameworkEvent ERROR - org.openhab.binding.zwave
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.zwave [209]
  Unresolved requirement: Import-Package: gnu.io

	at org.eclipse.osgi.container.Module.start(Module.java:444) [?:?]
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1634) [?:?]
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1614) [?:?]
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1585) [?:?]
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1528) [?:?]
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) [?:?]
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) [?:?]
	at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340) [?:?]
2018-11-19 10:50:34.894 [INFO ] [ing.zwave.handler.ZWaveSerialHandler] - Connecting to serial port '/dev/ttyACM0'

Any thoughts on this issue? It looks like openHAB still picks the wrong driver for my ARM64 architecture.

Thanks,

Robin

try from the OH2 console:

feature:install openhab-transport-serial 

edit: this might not work since you have played around with the libraries… I will think of another method :slight_smile:

Thanks for the suggestion! I already tried it, but no luck :frowning:

1 Like

According to the issue os.arch returns aarch64 whereas nrjavaserial expects ARM architectures to return an os.arch value starting with arm.

So perhaps you can test as workaround changing the Java os.arch value by appending:

export JAVA_OPTS="${JAVA_OPTS} -Dos.arch=arm"

to runtime/bin/setenv

E.g. by

echo 'export JAVA_OPTS="${JAVA_OPTS} -Dos.arch=arm"' >> runtime/bin/setenv
1 Like

Another step in the right direction, but we are not there yet. The ARM libraries are selected, but the error is still there. I also tried os.arch=arm64, but also no success.

 /volume1/@appstore/openHAB/userdata/tmp/libNRJavaSerialv8_HF_root_0/libNRJavaSerialv8_HF.so: /volume1/@appstore/openHAB/userdata/tmp/libNRJavaSerialv8_HF_root_0/libNRJavaSerialv8_HF.so: wrong ELF class: ELFCLASS32
/volume1/@appstore/openHAB/userdata/tmp/libNRJavaSerialv8_root_0/libNRJavaSerialv8.so: /volume1/@appstore/openHAB/userdata/tmp/libNRJavaSerialv8_root_0/libNRJavaSerialv8.so: wrong ELF class: ELFCLASS32
/volume1/@appstore/openHAB/userdata/tmp/libNRJavaSerialv7_HF_root_0/libNRJavaSerialv7_HF.so: /volume1/@appstore/openHAB/userdata/tmp/libNRJavaSerialv7_HF_root_0/libNRJavaSerialv7_HF.so: wrong ELF class: ELFCLASS32
/volume1/@appstore/openHAB/userdata/tmp/libNRJavaSerialv7_root_0/libNRJavaSerialv7.so: /volume1/@appstore/openHAB/userdata/tmp/libNRJavaSerialv7_root_0/libNRJavaSerialv7.so: wrong ELF class: ELFCLASS32
/volume1/@appstore/openHAB/userdata/tmp/libNRJavaSerialv6_HF_root_0/libNRJavaSerialv6_HF.so: /volume1/@appstore/openHAB/userdata/tmp/libNRJavaSerialv6_HF_root_0/libNRJavaSerialv6_HF.so: wrong ELF class: ELFCLASS32
/volume1/@appstore/openHAB/userdata/tmp/libNRJavaSerialv6_root_0/libNRJavaSerialv6.so: /volume1/@appstore/openHAB/userdata/tmp/libNRJavaSerialv6_root_0/libNRJavaSerialv6.so: wrong ELF class: ELFCLASS32
/volume1/@appstore/openHAB/userdata/tmp/libNRJavaSerialv5_root_0/libNRJavaSerialv5.so: /volume1/@appstore/openHAB/userdata/tmp/libNRJavaSerialv5_root_0/libNRJavaSerialv5.so: wrong ELF class: ELFCLASS32
java.lang.UnsatisfiedLinkError: gnu.io.RXTXCommDriver.nativeGetVersion()Ljava/lang/String; thrown while loading gnu.io.RXTXCommDriver
java.lang.NoClassDefFoundError: Could not initialize class gnu.io.RXTXCommDriver thrown while loading gnu.io.RXTXCommDriver

I tried installing 32bit java, but then openhab doesn’t run at all. I tried os.arch=arm,arm32 and arm64, but all give the following message.

    Launching the openHAB runtime...
    /volume1/@appstore/openHAB/runtime/bin/inc: line 233: [: : integer expression expected
    /volume1/@appstore/openHAB/runtime/bin/inc: line 233: [: : integer expression expected
    /volume1/@appstore/openHAB/runtime/bin/karaf: line 285: [: : integer expression expected
    /volume1/@appstore/openHAB/runtime/bin/karaf: line 316: /var/packages/Java8/target/j2sdk-image/bin/java: No such file or directory

Any thought on this? I have the feeling I am close solving this

1 Like

something may have gone wrong with your effort to deploy the 32bit JVM
did you remove the previous 64bit JVM before also?
changed your paths/environment variables etc?
do you see the new 32bit JVM if you type java -version?
I don’t know if the DSM has a command similar to update-alternatives --config java

this checks for Java (if [ "${VERSION}" -lt "8" ]; then)

checkJvmVersion() {
    # Use in priority xpg4 awk or nawk on SunOS as standard awk is outdated 
    AWK=awk
    if ${solaris}; then
        if [ -x /usr/xpg4/bin/awk ]; then
            AWK=/usr/xpg4/bin/awk
        elif [ -x /usr/bin/nawk ]; then
            AWK=/usr/bin/nawk
        fi
    fi
    
    VERSION=$("${JAVA}" -version 2>&1 | ${AWK} -F '"' '/version/ {print $2}' | sed -e 's/_.*//g; s/^1\.//g; s/\..*//g; s/-.*//g;')
    
    # java must be at least version 8 
    if [ "${VERSION}" -lt "8" ]; then
        die "JVM must be greater than 1.8"
    fi
}

I am struggling to install the 32bit java version. I remove the java8 package in the Synology package manager. I can upgrade java version through the synology UI:

image

It is in Dutch, so I hope you understand it a bit. It instructs to go to the oracle java website, download the 64bit linux hardfloat abi version of java SE and upload the .tar.gz. I have the feeling it replaces the existing java. The 32bit is installed in the same folder as the 64 bit.

When the 32bit version is installed java -version gives the same error as openhab does. The java update-alternatives does not work on synology unfortunately.

When I have the 64bit hardfloat installed the output is:
java version “1.8.0_191”
Java™ SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot™ 64-Bit Server VM (build 25.191-b12, mixed mode)

My conclusion is: This won’t work, since…

You can’t use the 32bit JVM in the 64bit SDM
The libNRJavaSerial has been compiled with 32bit dependencies only

I may be wrong

when you have the 32bit installed: is that path valid?

I found references for:

Java8/j2sdk-image/jre/bin/java

and some people setting JAVACOMMON to the java binary

Looks like the current ARM libraries are 32-bit versions and will not work with a 64-bit ARM JVM. So I recompiled the library for arm64 and updated the Java code so it loads it when os.arch is arm64 or aarch64. I haven’t tested it myself since I don’t have a arm64 system running currently but it might just work for you. :slight_smile:

To test it:

  1. Stop openHAB
  2. Download this nrjavaserial-3.15.0.OH.jar and copy it over the existing runtime/system/org/openhab/nrjavaserial/3.15.0.OH/nrjavaserial-3.15.0.OH.jar
  3. Clean userdata/tmp and userdata/cache
  4. Make sure you are using os.arch=aarch64 again by removing the line from setenv or updating it
  5. Restart openHAB

If I run openHAB with this JAR and os.arch=aarch64 it unpacks the right library in the tmp dir:

$ file libNRJavaSerialv8.so 
libNRJavaSerialv8.so: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, BuildID[sha1]=a4c0cd025ab5624d0e3f92dde361bec51eae0380, not stripped
$ md5sum libNRJavaSerialv8.so 
c6cd3a4df19de95e46cf8634c26f888f  libNRJavaSerialv8.so

These are the code changes I made to the library:

It should also be possible to test this with my Raspberry Pi 3 but currently it runs Raspbian which runs the processor in 32-bit mode. There are arm64 Ubuntu and Fedora images for the RPi3.

1 Like