64 bit ARM serial

I recently acquired an Odroid C2 to play with, so of course I loaded openHAB on it. I am running into a problem with the serial though. The C2 is a 64 bit machine, but the libNRJavaSerial library that is pulled in for it is 32bit. I would imagine the coming Pine64 will have the same issue as it is 64 bit ARM. My question is where should this bug be filed? @Kai

odroid@odroid64:/opt/openHAB$ file /opt/openHAB/userdata/tmp/libNRJavaSerial_odroid_0/libNRJavaSerial.so
/opt/openHAB/userdata/tmp/libNRJavaSerial_odroid_0/libNRJavaSerial.so: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, BuildID[sha1]=0827a652c6317f6bf80be484884f9447a94bceb5, not stripped

odroid@odroid64:/opt/openHAB$ uname -a
Linux odroid64 3.14.29-29 #1 SMP PREEMPT Fri Feb 26 11:00:53 BRT 2016 aarch64 aarch64 aarch64 GNU/Linux

Might this be the same as https://github.com/NeuronRobotics/nrjavaserial/issues/47?
Note that they are currently trying to fix building the native libs there, so maybe it is good if you chime in there. Thanks for the warning regarding the Pine!

So, it is not just pulling the wrong one, the correct one to use does not exist in the build yet :frowning:

The architecture is ARM64 v8 hf (hard float).

I created a new issue over there and referenced the only other ticket I could find about ARM64:

@kai were you testing z-wave on your Pine? If yes, I take it it was not a serial/USB board?

No, I will receive a Z-Wave board only by the end of next week.
@chris Did you receive yours already? If so, did you come across the problem with the serial lib?

Yes, but I’ve not had time to try and get it going yet :frowning:

@xsnrg I can confirm that the Pine has the same problem (as it is also 64-bit).
Did you solve it for yourself already? Did you compile a 64-bit version of the lib? I’ll need to have a fix for it soon and I am not sure if I can count on nrjavaserial 3.12 to be there anytime soon and have this issue addressed…

Unfortunately, I haven’t done anything with it as it is a side project at this point. I will see if I can pull it down and take a look at it this weekend if I have time.

I looked at it a little, but am not able to compile due to a missing header lockdev.h. The lockdev package does not seem to exist yet for aarch64 in Ubuntu Xenial, which is what the odroid I have shipped with. Does the pine have lockdev installed or available for it? What OS is it shipping with? Another avenue for finding it may be the Pi3, so will check there as well.

More: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=734086

It appears lockdev is EOL and is replaced by flock, so this won’t just be a simple compile to get going on the native side.

For fun, there are #ifdefs around it, so I removed them :slight_smile: What do you know, I have a .so file now to try. Will report back later.

My plan is to use Debian for it - see http://forum.pine64.org/showthread.php?tid=519.

I have a .so file now to try. Will report back later.

Cool, good luck :thumbsup:

I didn’t have much time over the weekend unfortunately, and when I did, I failed to recall the command line option to override the RXTX/NRjavaserial library. I had to use it on CentOS a while back and still have that machine shut off somewhere. Worst case, i can fire it up and get the command line, but does anyone have it handy?

For posterity, this is the command line argument to override the built-in libNRJavaSerial.so native library. At least it was before karaf. Will give it a go tomorrow.


This is more daunting that I had hoped. It is beyond the file locking and simple compile flags that I have tried. Hopefully the NR dev team can pick it up and get 3.12 done proper. Maybe we just send them an odroid C2 or Pine board as incentive?

Hm, that’s a pity that you didn’t succeed in compiling it :frowning:
Yes, I would be happy to sponsor an ODROID board for MrDOS, if this makes him add arm64 support in 3.12. But I am wondering if it enough to ask him for hints on how to compile it yourself? He mentioned that it should be fairly simple, so maybe he can help on how to do the compilation the right way?

Through the post made over there recently, I was able to piece together a Makefile that worked for me.

15:45:15.912 [INFO ] [me.event.ThingStatusInfoChangedEvent] - ‘zwave:serial_zstick:1ba63962’ changed from UNINITIALIZED to INITIALIZING
15:45:15.919 [INFO ] [ing.zwave.handler.ZWaveSerialHandler] - Connecting to serial port '/dev/ttyUSB0’
15:45:15.922 [INFO ] [me.event.ThingStatusInfoChangedEvent] - ‘zwave:serial_zstick:1ba63962’ changed from INITIALIZING to ONLINE
15:45:16.059 [INFO ] [ing.zwave.handler.ZWaveSerialHandler] - Serial port is initialized

I can make the .so available, but in the meantime, here are the steps I took:

  1. Use the Makefile provided here
  2. edit the Makefile and add -I includes for your JVM to get the jni headers. You will need $JDK/include and $JDK/include/linux .

Mike look like this as an example: -I/opt/jdk1.8.0_73/include -I/opt/jdk1.8.0_73/include/linux

  1. install liblockdev1 and liblockdev1-dev packages. Note, if you use a newer OS such as Xenial, which the Odroid ships with, you will have to go hunting for these. liblockdev1 is deprecated, but the packages can be found, they just cannot be installed with apt-get. Here is an example for xenial: liblockdev1-dev

  2. make

  3. take the resulting .so file and put it in a place that won’t get destroyed

  4. edit runtime/karaf/bin/setenv and add -DlibNRJavaSerial.userlib=/opt/libNRJavaSerial.so to the ARCH specific area. Substitute your path where I have /opt/.

The part of mine now looks like this:

case "$ARCH" in
  *arm*) ;;
      *) EXTRA_JAVA_OPTS_ARCH="-XX:+UseG1GC -DlibNRJavaSerial.userlib=/opt/libNRJavaSerial.so" ;;
  1. start openHAB

@xsnrg This is great news!

Do you think it is feasible to take https://github.com/NeuronRobotics/nrjavaserial/releases/download/3.12.0/nrjavaserial-3.12.0.jar and tweak it so that it also contains your .so? We could then put such a customized jar in the transport.serial bundle and have it all directly working for openHAB.

@Kai feasible, yes, but let me make it available for others to test first. Give this a go:

I want to make sure that it works on more than an odroid for one. A different jdk than mine would be a good test too - jdk1.8.0_73.

I tried it on a Pine64 with Ubuntu Xenial, i.e. without liblockdev1 installed - this fails with

java.lang.UnsatisfiedLinkError: /home/ubuntu/oh/lib/libNRJavaSerial.so: liblockdev.so.1: cannot open shared object file: No such file or directory thrown while loading gnu.io.RXTXCommDriver
java.lang.NoClassDefFoundError: Could not initialize class gnu.io.RXTXCommDriver thrown while loading gnu.io.RXTXCommDriver

I assume, you expected this.
As I want to use anyhow Debian Jessie for the openHAB SD card image, I will prepare a new card and test with that as well; Would you expect it to work there out of the box?

Correct, that was completely expected with Xenial. I provided the link above to download the needed packages. They are out there, just not in the default repos for easy download direct from apt.

I would expect it to work on Jessie as those packages are still available. I don’t know what the level of ARM64 support in Jessie is like though. There had to be some reason Odroid decided to go with Xenial, even pre-release.

Hmm, check this out: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=734086 maybe they are not available much longer.

Just tried it on a Pine64 with Debian Jessie - unfortunately, no luck here either:

java.lang.UnsatisfiedLinkError: /home/pine64user/openhab/lib/libNRJavaSerial.so: liblockdev.so.1: cannot open shared object file: No such file or directory (Possible cause: architecture word width mismatch) thrown while loading gnu.io.RXTXCommDriver
java.lang.NoClassDefFoundError: Could not initialize class gnu.io.RXTXCommDriver thrown while loading gnu.io.RXTXCommDriver

Here’s the system info:

pine64user@debianpine64:~$ uname -a
Linux debianpine64 3.10.65-4-pine64-longsleep #16 SMP PREEMPT Sun Apr 3 10:56:40 CEST 2016 aarch64 GNU/Linux