Open rdratlos opened 2 months ago
Thanks for the detailed info. V2.6 was tested on PIs with ARMv7/8 processors (4 and 5 for instance), not on ARMv6 (Pi Zero 1), as far as I know. I will need to set up a test to check if I can reproduce this...
@rdratlos it would also be interesting to see what you get out of boardinfo logging, see https://www.pi4j.com/documentation/board-info/
console.println("Board model: " + pi4j.boardInfo().getBoardModel().getLabel());
console.println("Operating system: " + pi4j.boardInfo().getOperatingSystem());
console.println("Java versions: " + pi4j.boardInfo().getJavaInfo());
console.println("Board model: " + BoardInfoHelper.current().getBoardModel().getLabel());
console.println("Raspberry Pi model with RP1 chip (Raspberry Pi 5): " + BoardInfoHelper.usesRP1());
console.println("OS is 64-bit: " + BoardInfoHelper.is64bit());
[main] INFO com.pi4j.boardinfo.util.BoardInfoHelper - Detected OS: Name: Linux, version: 6.6.28+rpt-rpi-v6, architecture: arm
[main] INFO com.pi4j.boardinfo.util.BoardInfoHelper - Detected Java: Version: 11.0.23, runtime: 11.0.23+9-LTS, vendor: Azul Systems, Inc., vendor version: Zulu11.72+19-CA
[main] INFO com.pi4j.boardinfo.util.BoardInfoHelper - Detected board type ZERO_W by code: 9000c1
[main] INFO com.pi4j.context.impl.DefaultContext - Detected board model: Raspberry Pi Zero W
@FDelporte For BoardInfoHelper I need some more time to fix, as it tries to initialize an auto-context and crashes.
@FDelporte Sorry for being late. Please find the missing BoardInfo information in the following:
[main] INFO com.pi4j.util.Console - Board model: Raspberry Pi Zero W
[main] INFO com.pi4j.util.Console - Operating system: Name: Linux, version: 6.6.28+rpt-rpi-v6, architecture: arm
[main] INFO com.pi4j.util.Console - Java versions: Version: 11.0.23, runtime: 11.0.23+9-LTS, vendor: Azul Systems, Inc., vendor version: Zulu11.72+19-CA
[main] INFO com.pi4j.util.Console - Board model: Raspberry Pi Zero W
[main] INFO com.pi4j.util.Console - Raspberry Pi model with RP1 chip (Raspberry Pi 5): false
[main] INFO com.pi4j.util.Console - OS is 64-bit: false
[main] INFO com.pi4j.util.Console - JVM memory used (MB): 3.3950881958007812
[main] INFO com.pi4j.util.Console - Board temperature (°C): 47.1
This platform is still supported by Raspberry OS Bookworm as well as Zulu Java 11. Would be good to use a "modern" GPIO API and get rid of the deprecated Linux file system based access.
After native build of GpioD libraries on the Pi Zero 1 (ARMv6) itself with hacked POM and build scripts, which force 64 bit ARM arch, we got a working libpgiod.so. autoContext() and subsequent off/on of the digital output worked. Seems that something goes wrong, when building the libraries using cross-compiler on the 64 bit production machine.
Btw.: Native GPIO build on this slow PI has become inexpensive and works pretty fast. Nothing compared to the nightmare with LinuxFS native builds two years ago.
Hi @rdratlos great to hear you could solve the problem and performance is a lot better! Can you please share the changes that need to be done so we can try to get them into the build scripts? Thanks a lot in advance!
Hi @FDelporte, at least I could prove that GpioD library native build still works on 32-bit ARMv6. The more generic hack is now as follows:
diff --git a/libraries/pi4j-library-gpiod/src/main/native/build.sh b/libraries/pi4j-library-gpiod/src/main/native/build.sh
index 64ee5b0a..6011850d 100755
--- a/libraries/pi4j-library-gpiod/src/main/native/build.sh
+++ b/libraries/pi4j-library-gpiod/src/main/native/build.sh
@@ -51,9 +51,9 @@ fi
# validate compatible CPU architecture
ARCHITECTURE=$(uname -m)
-if [[ (("$ARCHITECTURE" != "aarch64") && ("$ARCHITECTURE" != "amd64") && ("$ARCHITECTURE" != "x86_64")) ]]; then
- echo "This native build is only supported on Linux-based systems running on an Intel/AMD or ARM 64-bit platform."
- echo "BUILD ABORTED; REASON: ARCHITECTURE='$ARCHITECTURE'; EXPECTED='aarch64|amd64|x86_64'"
+if [[ (("$ARCHITECTURE" != "aarch64") && ("$ARCHITECTURE" != "armv6l") && ("$ARCHITECTURE" != "amd64") && ("$ARCHITECTURE" != "x86_64")) ]]; then
+ echo "This native build is only supported on Linux-based systems running on an Intel/AMD or ARM platform."
+ echo "BUILD ABORTED; REASON: ARCHITECTURE='$ARCHITECTURE'; EXPECTED='aarch64|armv6l|amd64|x86_64'"
exit 1
fi
@@ -78,7 +78,7 @@ if [[ "${PI4J_BUILDER}" != "" ]]; then
echo "Running inside a Pi4J Docker Builder image; [version=${PI4J_BUILDER}; arch=${PI4J_BUILDER_ARCH}]"
echo "No need to check or install build environment prerequisites."
else
- # if this is a Linux-based system and a 64-bit Intel/AMD or ARM platform, then we can install the prerequisites
+ # if this is a Linux-based system and a Intel/AMD or ARM platform, then we can install the prerequisites
# download and install development prerequisites
./build-prerequisites.sh
fi
I fear that we have now working 32 bit libraries but broken 64bit libs. I have attached a zip with a 2.6.0 Maven cache, which contains all native libs build on the Pi Zero. Would be interesting to know, if the aarch64 libs work on later 64 bit Pi.
@eitch is this something you can look into regarding the build changes?
According to @taartspi could be related to https://github.com/Pi4J/pi4j-v2/issues/354, https://github.com/Pi4J/pi4j-v2/issues/217, https://github.com/Pi4J/pi4j-v2/issues/28
I currently don't have much time to look into this. If you could send a PR, then i can look into integrating it. The issue that comes to my mind, is that the build of the 32-bit native libraries probably need a different docker container, this would make it a bit more complicated overall. It would be great if we could enable this again on the Pi Zero.
@eitch: It makes not much sense to re-enable ARMv6 native builds. These Pis are way to slow. I believe that there is an issue with the GPIO library POMs. When I download 2.6.0 and Maven build Pi4J I get the core dump. After rebuilding only the native GpioD library on a Pi Zero 1 (ARMv6) using
mvn clean install -Pnative
with hacked build script (see above) to enable ARMv6 builds everything works fine again. But if I then rebuild the complete Pi4J suite using
mvn clean install
the minimal example app crashes again with java.lang.UnsatisfiedLinkError error:
[main] INFO com.pi4j.Pi4J - New auto context
[main] INFO com.pi4j.Pi4J - New context builder
[main] TRACE com.pi4j.context.impl.DefaultContextBuilder - invoked 'build()'
[main] TRACE com.pi4j.context.impl.DefaultContext - new Pi4J runtime context initialized [config=com.pi4j.context.impl.DefaultContextBuilder$1@173813a]
[main] DEBUG com.pi4j.runtime.impl.DefaultRuntime - Pi4J runtime context successfully created & initialized.'
[main] INFO com.pi4j.boardinfo.util.BoardInfoHelper - Detected OS: Name: Linux, version: 6.6.28+rpt-rpi-v6, architecture: arm
[main] INFO com.pi4j.boardinfo.util.BoardInfoHelper - Detected Java: Version: 11.0.23, runtime: 11.0.23+9-LTS, vendor: Azul Systems, Inc., vendor version: Zulu11.72+19-CA
[main] INFO com.pi4j.boardinfo.util.BoardInfoHelper - Detected board type ZERO_W by code: 9000c1
[main] INFO com.pi4j.context.impl.DefaultContext - Detected board model: Raspberry Pi Zero W
[main] INFO com.pi4j.context.impl.DefaultContext - Running on: Name: Linux, version: 6.6.28+rpt-rpi-v6, architecture: arm
[main] INFO com.pi4j.context.impl.DefaultContext - With Java version: Version: 11.0.23, runtime: 11.0.23+9-LTS, vendor: Azul Systems, Inc., vendor version: Zulu11.72+19-CA
[main] INFO com.pi4j.runtime.impl.DefaultRuntime - Initializing Pi4J context/runtime...
[main] TRACE com.pi4j.runtime.impl.DefaultRuntime - detected plugin: [com.pi4j.plugin.gpiod.GpioDPlugin] in classpath; calling 'initialize()'
[main] TRACE com.pi4j.runtime.impl.DefaultRuntime - detected plugin: [com.pi4j.plugin.raspberrypi.RaspberryPiPlugin] in classpath; calling 'initialize()'
[main] WARN com.pi4j.runtime.impl.DefaultRuntime - Ignoring provider DIGITAL_INPUT RaspberryPi Digital Input (GPIO) Provider with priority 0 as lower priority than GpioD Digit
al Input (GPIO) Provider which has priority 150
[main] WARN com.pi4j.runtime.impl.DefaultRuntime - Ignoring provider DIGITAL_OUTPUT RaspberryPi Digital Output (GPIO) Provider with priority 0 as lower priority than GpioD Dig
ital Output (GPIO) Provider which has priority 150
[main] TRACE com.pi4j.provider.impl.DefaultRuntimeProviders - adding providers: [count=6]
[main] TRACE com.pi4j.provider.impl.DefaultRuntimeProviders - adding provider: [id=raspberrypi-serial; name=RaspberryPi Serial Provider; class=com.pi4j.plugin.raspberrypi.prov
ider.serial.RpiSerialProviderImpl]
[main] TRACE com.pi4j.provider.impl.DefaultRuntimeProviders - invoked 'add()' provider [count=1]
[main] TRACE com.pi4j.provider.impl.DefaultRuntimeProviders - adding provider to managed io map [id=raspberrypi-serial; name=RaspberryPi Serial Provider; class=com.pi4j.plugin
.raspberrypi.provider.serial.RpiSerialProviderImpl]
[main] TRACE com.pi4j.provider.impl.DefaultRuntimeProviders - initializing provider [id=raspberrypi-serial; name=RaspberryPi Serial Provider; class=com.pi4j.plugin.raspberrypi
.provider.serial.RpiSerialProviderImpl]
[main] DEBUG com.pi4j.provider.impl.DefaultRuntimeProviders - added io to managed provider map [id=raspberrypi-serial; name=RaspberryPi Serial Provider; class=com.pi4j.plugin.
raspberrypi.provider.serial.RpiSerialProviderImpl]
[main] TRACE com.pi4j.provider.impl.DefaultRuntimeProviders - adding provider: [id=raspberrypi-spi; name=RaspberryPi SPI Provider; class=com.pi4j.plugin.raspberrypi.provider.s
pi.RpiSpiProviderImpl]
[main] TRACE com.pi4j.provider.impl.DefaultRuntimeProviders - invoked 'add()' provider [count=1]
[main] TRACE com.pi4j.provider.impl.DefaultRuntimeProviders - adding provider to managed io map [id=raspberrypi-spi; name=RaspberryPi SPI Provider; class=com.pi4j.plugin.raspb
errypi.provider.spi.RpiSpiProviderImpl]
[main] TRACE com.pi4j.provider.impl.DefaultRuntimeProviders - initializing provider [id=raspberrypi-spi; name=RaspberryPi SPI Provider; class=com.pi4j.plugin.raspberrypi.provi
der.spi.RpiSpiProviderImpl]
[main] DEBUG com.pi4j.provider.impl.DefaultRuntimeProviders - added io to managed provider map [id=raspberrypi-spi; name=RaspberryPi SPI Provider; class=com.pi4j.plugin.raspbe
rrypi.provider.spi.RpiSpiProviderImpl]
[main] TRACE com.pi4j.provider.impl.DefaultRuntimeProviders - adding provider: [id=raspberrypi-pwm; name=RaspberryPi PWM Provider; class=com.pi4j.plugin.raspberrypi.provider.p
wm.RpiPwmProviderImpl]
[main] TRACE com.pi4j.provider.impl.DefaultRuntimeProviders - invoked 'add()' provider [count=1]
[main] TRACE com.pi4j.provider.impl.DefaultRuntimeProviders - adding provider to managed io map [id=raspberrypi-pwm; name=RaspberryPi PWM Provider; class=com.pi4j.plugin.raspb
errypi.provider.pwm.RpiPwmProviderImpl]
[main] TRACE com.pi4j.provider.impl.DefaultRuntimeProviders - initializing provider [id=raspberrypi-pwm; name=RaspberryPi PWM Provider; class=com.pi4j.plugin.raspberrypi.provi
[main] DEBUG com.pi4j.provider.impl.DefaultRuntimeProviders - added io to managed provider map [id=raspberrypi-pwm; name=RaspberryPi PWM Provider; class=com.pi4j.plugin.raspbe
rrypi.provider.pwm.RpiPwmProviderImpl]
[main] TRACE com.pi4j.provider.impl.DefaultRuntimeProviders - adding provider: [id=gpiod-digital-input; name=GpioD Digital Input (GPIO) Provider; class=com.pi4j.plugin.gpiod.p
rovider.gpio.digital.GpioDDigitalInputProviderImpl]
[main] TRACE com.pi4j.provider.impl.DefaultRuntimeProviders - invoked 'add()' provider [count=1]
[main] TRACE com.pi4j.provider.impl.DefaultRuntimeProviders - adding provider to managed io map [id=gpiod-digital-input; name=GpioD Digital Input (GPIO) Provider; class=com.pi
4j.plugin.gpiod.provider.gpio.digital.GpioDDigitalInputProviderImpl]
[main] TRACE com.pi4j.provider.impl.DefaultRuntimeProviders - initializing provider [id=gpiod-digital-input; name=GpioD Digital Input (GPIO) Provider; class=com.pi4j.plugin.gp
iod.provider.gpio.digital.GpioDDigitalInputProviderImpl]
[main] DEBUG com.pi4j.library.gpiod.util.NativeLibraryLoader - Attempting to load library [libgpiod.so] using path: [/lib/armhf/pi4j-gpiod/libgpiod.so]
[main] DEBUG com.pi4j.library.gpiod.util.NativeLibraryLoader - Library [libgpiod.so] loaded successfully using embedded resource file: [/lib/armhf/pi4j-gpiod/libgpiod.so]
[main] DEBUG com.pi4j.library.gpiod.util.NativeLibraryLoader - Attempting to load library [libpi4j-gpiod.so] using path: [/lib/armhf/pi4j-gpiod/libpi4j-gpiod.so]
[main] DEBUG com.pi4j.library.gpiod.util.NativeLibraryLoader - Library [libpi4j-gpiod.so] loaded successfully using embedded resource file: [/lib/armhf/pi4j-gpiod/libpi4j-gpio
d.so]
Exception in thread "main" java.lang.UnsatisfiedLinkError: 'java.lang.Long com.pi4j.library.gpiod.internal.GpioD.gpiod_chip_iter_new()'
at com.pi4j.library.gpiod@2.6.3/com.pi4j.library.gpiod.internal.GpioD.gpiod_chip_iter_new(Native Method)
at com.pi4j.library.gpiod@2.6.3/com.pi4j.library.gpiod.internal.GpioD.chipIterNew(GpioD.java:342)
at com.pi4j.library.gpiod@2.6.3/com.pi4j.library.gpiod.internal.GpioDContext.initialize(GpioDContext.java:38)
at com.pi4j.plugin.gpiod@2.6.3-SNAPSHOT/com.pi4j.plugin.gpiod.provider.gpio.digital.GpioDDigitalInputProviderImpl.initialize(GpioDDigitalInputProviderImpl.java:49)
at com.pi4j.plugin.gpiod@2.6.3-SNAPSHOT/com.pi4j.plugin.gpiod.provider.gpio.digital.GpioDDigitalInputProviderImpl.initialize(GpioDDigitalInputProviderImpl.java:15)
at com.pi4j@2.6.3-SNAPSHOT/com.pi4j.provider.impl.DefaultRuntimeProviders.initializeProvider(DefaultRuntimeProviders.java:275)
at com.pi4j@2.6.3-SNAPSHOT/com.pi4j.provider.impl.DefaultRuntimeProviders.add(DefaultRuntimeProviders.java:251)
at com.pi4j@2.6.3-SNAPSHOT/com.pi4j.provider.impl.DefaultRuntimeProviders.add(DefaultRuntimeProviders.java:231)
at com.pi4j@2.6.3-SNAPSHOT/com.pi4j.provider.impl.DefaultRuntimeProviders.initialize(DefaultRuntimeProviders.java:356)
at com.pi4j@2.6.3-SNAPSHOT/com.pi4j.runtime.impl.DefaultRuntime.initialize(DefaultRuntime.java:316)
at com.pi4j@2.6.3-SNAPSHOT/com.pi4j.context.impl.DefaultContext.<init>(DefaultContext.java:113)
at com.pi4j@2.6.3-SNAPSHOT/com.pi4j.context.impl.DefaultContext.newInstance(DefaultContext.java:76)
at com.pi4j@2.6.3-SNAPSHOT/com.pi4j.context.impl.DefaultContextBuilder.build(DefaultContextBuilder.java:287)
at com.pi4j@2.6.3-SNAPSHOT/com.pi4j.context.impl.DefaultContextBuilder.build(DefaultContextBuilder.java:48)
at com.pi4j@2.6.3-SNAPSHOT/com.pi4j.Pi4J.newAutoContext(Pi4J.java:73)
at com.pi4j.example@0.0.1-SNAPSHOT/com.pi4j.example.MinimalExample.main(MinimalExample.java:92)
If I rebuild the native library again or just overwrite the local Maven cache with the previous rebuild above, the minimal example works fine again. Downloading the native libraries from Maven repository and then uploading again seems to break things. Never experienced this with LinuxFS native libraries, which are too large to native build on a Pi Zero 1.
We wanted to migrate a project from a custom LinuxFS based GPIO digital output control implementation to the new Pi4J GpioD plugin. The reason was that LinuxFS native code uses deprecated kernel API functions. As all tests after update failed, we performed tests using the distributed Minimal Example and Pi4J v2.6.0 installed directly on Pi using Maven. All attempts failed with core dump (SIGILL fatal error) in native code and following error information:
System information:
Even though GpioD support was introduced with arrival of Raspberry Pi 5 we have not seen any information that other PIs are not supported.
Any help would be appreciated.
hs_err_pid6664.log