NeuronRobotics / nrjavaserial

A Java Serial Port system. This is a fork of the RXTX project that uses in jar loading of the native code.
Other
345 stars 143 forks source link

Arm64 v8hf support #72

Closed xsnrg closed 4 years ago

xsnrg commented 8 years ago

I didn't see an issue that called this out in particular, but is there any plan to support the new 64bit ARM v8 cpus? The Odroid C2 sports this CPU and is in the wild (I have one). If I understand correctly, the Pine64 that just started shipping is also of this arch. OpenHAB uses nrjavaserial and as such cannot support (without some tinkering) serial devices on these new cpus. They currently try to load the 32 bit library, and fail.

libNRJavaSerial.so: wrong ELF class: ELFCLASS32 (Possible cause: can't load IA 32-bit .so on a ARM-bit platform)

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

specs here: http://www.hardkernel.com/main/products/prdt_info.php

Other mention of ARM64 here: https://github.com/NeuronRobotics/nrjavaserial/issues/51

MrDOS commented 8 years ago

Yep, I'd love to support them. The only reason we currently don't is lack of resources. I don't have any ARM64 devices on hand but I've been meaning to buy a couple of different ODROIDs to get some more ARM variants on hand for testing (I have access to ARMv5 and v6 but no v7 or v8). As far as the native code support is concerned, I don't suspect much effort to be involved: the code doesn't seem to explicitly call out ARM support anywhere, so it's hopefully just a matter of recompilation given that other 64-bit architectures are supported happily.

xsnrg commented 8 years ago

it's hopefully just a matter of recompilation given that other 64-bit architectures are supported happily.

I was hoping that was the case. Thanks for the quick reply. I'd be willing to test a build when the time comes.

kaikreuzer commented 8 years ago

Is there any chance to have that included in the upcoming 3.12 release, potentially with https://github.com/NeuronRobotics/nrjavaserial/pull/71?

umiddelb commented 8 years ago

This Makefile builds a native libNRJavaSerial.so on aarch64 (PINE64 or ODROID-C2) (make sure that you have installed the liblockdev1-dev package first):

LINOBJ=build/fixup.o build/fuserImp.o build/SerialImp.o
LININCLUDE=-I/usr/lib/jvm/java-7-openjdk-arm64/include/ -I"./include" -I"./include/target"

CCLINARM=gcc $(LININCLUDE) -DLIBLOCKDEV -O3 -Wall -c -fmessage-length=0 -fPIC -MMD -MP
LINKLINARM=gcc -shared -fPIC

dirs:
        if (test -d build); then rm -rf build;mkdir build;else mkdir build; fi
        if (test -d resources/native);\
         then echo Native output directories seem to exist.;else\
         mkdir -p resources/native/linux/ARM/; \
         fi

arm:    dirs
        $(CCLINARM) src/fixup.c -o build/fixup.o
        $(CCLINARM) src/fuserImp.c -o build/fuserImp.o
        $(CCLINARM) src/SerialImp.c -o build/SerialImp.o
        $(LINKLINARM) -o"resources/native/linux/ARM/libNRJavaSerial.so" $(LINOBJ) -llockdev
        rm -rf build
xsnrg commented 8 years ago

Thanks for the Makefile. It appears that liblockdev1 is deprecated, replaced with flock: https://launchpad.net/ubuntu/xenial/arm64/liblockdev1

The packages are still available when you hunt them down, but that will come to an end. This is with Ubuntu xenial.

umiddelb commented 8 years ago

You're welcome. I prefer using Debian Jessie on the C2 and PINE64 due to several issues in Ubuntu Xenial at this time (may be they are fixed until the official release date). Debian Jessie doesn't label liblockdev1 as deprecated.

Replacing liblockdev1 by flock might affect the original Makefile (this file may require some refactoring / modularization) as well.