Pi4J / pi4j-v1

DEPRECATED Java I/O library for Raspberry Pi (GPIO, I2C, SPI, UART)
http://www.pi4j.com
Apache License 2.0
1.31k stars 448 forks source link

Pi4J fails with Rpi 4.9.35 kernel - Unable to determine hardware version from wiringpi lib #349

Closed chazzG closed 6 years ago

chazzG commented 7 years ago

It seems the Rpi 4.9 kernel always puts BCM2835 into /proc/cpuinfo. The wiringpi static library linked with the latest release of Pi4J fails. I checked the source code of wiringPi.c and the 2.44 version should work with Pi4J, as the code allows BCM2708, BCM2709, and BCM2835 as hardware types. One can not simply recompile wiringPi as the shared libs are not used by Pi4J, they are static linked into Pi4J. I hope this gives u enough info to build a new release. I began to recompile Pi4j with the new wiringPi 2.44, but maven fails and also loaded more usuless crap into my little old pi than I could tolerate. Thanks for your support!

BTW, I downloaded the pi4j 1.2 SNAPSHOT, installed it, and problem is resolved with that release

ameenmohamed commented 7 years ago

having same issue

ameenmohamed commented 7 years ago

I posted question to the email that came up in error message i got this reply Standard reply as I'm fed-up typing it in every time.

So, you've upgraded to a shiny new 4.9 kernel and wiringPi has stopped working.

The simple answer is: Upgrade wiringPi.

Use

sudo apt-get update sudo apt-get upgrade

mechanism.

However...

If you are running Python/PHP/Java, or some language other than C/C++ or BASIC, or some pre-built system such as a TV/Video release or home automation release, then sorry - you're screwed.

wiringPi is a C library for C/C++ and BASIC programs. I do not support anything else.

So the morons who put together the wrappers for the language you're using, or the system you have have been complete utter twats and statically linked an old version of wiringPi into their system. I fixed this problem in December 2016 in anticipation of the 2.9 kernel being released, but it seems these incompetent buffoons haven't bothered to upgate their own system that you now have the misfortune to use.

Get in-touch with them, preferably with a very sharp stick and get them to fix the problem.

This may help for Java issues:

https://github.com/Pi4J/pi4j/issues/319

and this may help Python issues:

https://github.com/WiringPi/WiringPi-Python/issues/47

Good luck.

chazzG commented 7 years ago

I got it working by

downloading the pi4j 1.2 SNAPSHOT, installed it, and problem is resolved with that release. the download is on the Pi4j website

that download is linked to the correct version of wiringPi library

Chuck

Good Luck

On Sun, Jul 9, 2017 at 7:33 AM, Ameen notifications@github.com wrote:

I posted question to the email that came up in error message i got this reply Standard reply as I'm fed-up typing it in every time.

So, you've upgraded to a shiny new 4.9 kernel and wiringPi has stopped working.

The simple answer is: Upgrade wiringPi.

Use

sudo apt-get update sudo apt-get upgrade

mechanism.

However...

If you are running Python/PHP/Java, or some language other than C/C++ or BASIC, or some pre-built system such as a TV/Video release or home automation release, then sorry - you're screwed.

wiringPi is a C library for C/C++ and BASIC programs. I do not support anything else.

So the morons who put together the wrappers for the language you're using, or the system you have have been complete utter twats and statically linked an old version of wiringPi into their system. I fixed this problem in December 2016 in anticipation of the 2.9 kernel being released, but it seems these incompetent buffoons haven't bothered to upgate their own system that you now have the misfortune to use.

Get in-touch with them, preferably with a very sharp stick and get them to fix the problem.

This may help for Java issues:

319 https://github.com/Pi4J/pi4j/issues/319

and this may help Python issues:

WiringPi/WiringPi-Python#47 https://github.com/WiringPi/WiringPi-Python/issues/47

Good luck.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Pi4J/pi4j/issues/349#issuecomment-313920210, or mute the thread https://github.com/notifications/unsubscribe-auth/AchkpXD6_ZDnRXD55J6iUL0pNUHI0hfXks5sMNa0gaJpZM4ON4V_ .

savageautomate commented 7 years ago

The Pi4J SNAPSHOT version is (almost) always compiled against the latest WiringPi release.

We choose early on to statically link against WiringPi (by default) as a number of Java programmers struggled with maintaining WiringPi releases and managing that at a dependency for distribution. It also ensured that we could ship a release of Pi4J tested against a known stable release of WiringPi and reducing a lot of frustration when the two libs would get out of sync with ether other on a users's system.

All that being said, its unfortunate that this error message refers uses to seek support from WiringPi (Gordon) when his library was fixed ages ago. Perhaps we can implement some error handling to provide a better/more helpful error message on our end.

Pi4J also optionally supports dynamic linking against WiringPi for uses or use cases when a newer or custom version of WiringPi is needed. All you have to do is set the system property: pi4j.linking=dynamic.

I have been very busy in other parts of my life and have not been as active on this project as I would like and I really need to get a release of 1.2 tested and published. Hopefully very soon.

Thanks, Robert

GeVanCo commented 7 years ago

I hit the same stone a couple of days ago. After some investigation, I found the reason as to why wiringPi didn't work anymore.

The reason behind this is that with kernel 4.8+ the name of the processor has changed from BCM2708/BCM2709 into BCM2835. If you have the RPi up and running, check the /proc/cpuinfo content and you'll see BCM2835 next to the "Hardware" line. Revision remained the same.

The previous versions of wiringPi were only checking for the presence of BCM2708 or BCM2709 into that file and therefore, with the new kernel installed, that check failed. Hence, exit_failure was given. wiringPi has been updated to tackle that issue: it now checks for BCM2708/09 (to remain backwards compatible with older kernels) as well as for BCM2835. That solves the issue.

If you want to see the details, pls. check for wiringPi.c, line 715 and further in the latest wiringPi repo (which is downloaded into Pi4J if you also take the native build for RPi along). It now looks like this:



// OK. As of Kernel 4.8,  we have BCM2835 only, regardless of model.
//  However I still want to check because it will trap the cheapskates and rip-
//  off merchants who want to use wiringPi on non-Raspberry Pi platforms - which
//  I do not support so don't email me your bleating whinges about anything
//  other than a genuine Raspberry Pi.

  if (! (strstr (line, "BCM2708") || strstr (line, "BCM2709") || strstr (line, "BCM2835")))
  {
    fprintf (stderr, "Unable to determine hardware version. I see: %s,\n", line) ;
    fprintf (stderr, " - expecting BCM2708, BCM2709 or BCM2835.\n") ;
    fprintf (stderr, "If this is a genuine Raspberry Pi then please report this\n") ;
    fprintf (stderr, "to projects@drogon.net. If this is not a Raspberry Pi then you\n") ;
    fprintf (stderr, "are on your own as wiringPi is designed to support the\n") ;
    fprintf (stderr, "Raspberry Pi ONLY.\n") ;
    exit (EXIT_FAILURE) ;
  }
savageautomate commented 7 years ago

This is an update that I posted to a RaspberryPi forum thread and am including it here for reference. https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=182191

For clarification .....

This error is an error message output by the WiringPi library due to a change in the hardware signature starting with kernel version 4.8.

You can run the following command and see the "Hardware" information displayed by the kernel.

cat /proc/cpuinfo
...
Hardware    : BCM2835

However, Gordon updated WiringPi to support this change long ago (December 2016) in WiringPi version 2.36.
(commit: http://git.drogon.net/?p=wiringPi;a=commitdiff;h=b1dfc186efe327aa1d59de43ef631a2fa24e7c95)

And Pi4J included these updates from WiringPi somewhere around January 2017 in Pi4J version 1.2-SNAPSHOT builds.

So why does this issue continue to popup? And why does installing the latest WiringPi on my system not resolve the issues?

Early on in Pi4J development we started embedding (static linking) a pre-compiled version of WiringPi inside the native Pi4J package. We did this because at that time WiringPi was not included in the OS image and many Java programmers new to the embedded world struggled with the WiringPi dependency and making sure compatible versions of Pi4J and WiringPi were in sync.

So (by default) Pi4J does not care or use what version of WiringPi you may have installed on your system. Thus if you are using Pi4J version 1.1 or lower, then you are still using an outdated version of WiringPi. The solution is to upgrade to Pi4J version 1.2-SNAPSHOT. Most users have reported success after upgrading to Pi4J version 1.2-SNAPSHOT. However a small number of users have reported still having this issue after upgrading. For users continuing to experience this issue, I'm not sure what's going wrong and would be happy to help if you can provide some further details on your environment and steps you have attempted to solve the problem.

Another workaround users can try is to tell Pi4J not to use it's embedded WiringPi and instead use the shared WiringPi library installed on your system. Pi4J does optionally support dynamic linking against WiringPi for use cases when a newer or custom version of WiringPi is needed. All you have to do is set the system property:

> pi4j.linking=dynamic

You can also include this in your java command line when launching your java program with the "-D" argument:

java -Dpi4j.linking=dynamic

Perhaps the biggest help would be to get Pi4J version 1.2 released. Its way overdue. I have been pulled in many directions since the start of 2017 and have not been able to focus on the Pi4J project as much as I would like to. I will make an effort to get version 1.2 released soon.

Thank You, Robert

robertsbd commented 7 years ago

I received the same issue as all of you using the Pi4J lib in a clojure project on the rasp pi. I switched my project dependencies to use "https://oss.sonatype.org/content/groups/public" and the library being 1.2-SNAPSHOT and it is no longer reporting the error. So I was able to get away without having to download the libraries.

Thanks for the help everyone.

My project.clj file that works

(defproject hornsey-train "0.1.0-SNAPSHOT" :description "FIXME: write description" :url "http://example.com/FIXME" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.8.0"] [org.clojure/data.json "0.2.6"] [com.pi4j/pi4j-core "1.2-SNAPSHOT"]] :repositories [["sonatype" {:url "https://oss.sonatype.org/content/groups/public"}]] :main ^:skip-aot hornsey-train.core :target-path "target/%s" :profiles {:uberjar {:aot :all}})

Bill5203 commented 7 years ago

uname -srvo Linux 4.9.35+ #1014 Fri Jun 30 14:34:49 BST 2017 GNU/Linux

cat /etc/os-release PRETTY_NAME="Raspbian GNU/Linux 8 (jessie)" NAME="Raspbian GNU/Linux" VERSION_ID="8" VERSION="8 (jessie)" ID=raspbian ID_LIKE=debian

Pi4J Snapshot was installed as it is instructed by Robert:

sudo apt-get remove pi4j sudo dpkg -i pi4j-1.2-SNAPSHOT.deb

Still doesn't work so taking next advice: "Pi4J does optionally support dynamic linking against WiringPi for use cases when a newer or custom version of WiringPi is needed. All you have to do is set the system property":

pi4j.linking=dynamic -bash: pi4j.linking=dynamic: command not found

Now what?

Bill

eitch commented 7 years ago

Hey Bill. pi4j.linking should probably be set as a system property. So try this:

$bash: export pi4j.linking=dynamic
thegreystone commented 6 years ago

Any ETA on 1.2?

thegreystone commented 6 years ago

If not, is there anything blocking the release that the community can help out with?

mirage22 commented 6 years ago

are there any plans about to have version 1.2 released ?

jCecchetti commented 6 years ago

I had this same problem. Everything was solved after switching to 1.2-SNAPSHOT

Great Library!

DRChess commented 6 years ago

What happens if the OS calls out the correct version of the CPU in a Pi3 as BCM2837 (1.1) or version BCM2838 (1.2) instead of the generics for Broadcom's A53/Video core IV ??? Or maybe the OS can't see that deep into the chip design. It would have been better to lockout the Pi knock off with just looking for the string with BCM.

acrossi commented 6 years ago

Hoping for a 1.2 for Christmas!

I have been so good this year....

Kstarks87 commented 6 years ago

Can someone provide the exact commands to install the version 1.2 SNAPSHOT? I'm a noob and have run into this unable to determine hardware version issue.

PRETTY_NAME="Raspbian GNU/Linux 8 (jessie)" NAME="Raspbian GNU/Linux" VERSION_ID="8" VERSION="8 (jessie)" ID=raspbian ID_LIKE=debian HOME_URL="http://www.raspbian.org/" SUPPORT_URL="http://www.raspbian.org/RaspbianForums" BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

BILLyTheLiTTle commented 6 years ago

How can I get 1.2-SNAPSHOT from Gradle repository?

ChrisCarrAu commented 6 years ago

I don't know if this will help, but here are my workings to get it all going https://github.com/ChrisCarrAu/RaspberryPi-IoT/wiki

savageautomate commented 6 years ago

@BILLyTheLiTTle

1.2-SNAPSHOT builds are available in this repository: http://pi4j.com/download.html#Maven_Repository

savageautomate commented 6 years ago

This issue should be fully resolved in the latest 1.2-SNAPSHOT builds. Note, you must have the latest WiringPi installed on your Raspberry Pi separately from Pi4J 1.2-SNAPSHOT.