This morning, I did an update/upgrade of my RPi Debian lite distro. Quite a lot of new things came in, amongst others, kernel related stuff.
Before, I ran an application that went fine for a long time. However, after the update/upgrade, I all of a sudden got the following output:
Unable to determine hardware version. I see: Hardware : BCM2835
,
- expecting BCM2708 or BCM2709.
If this is a genuine Raspberry Pi then please report this
to
proj...@drogon.net. If this is not a Raspberry Pi then you
are on your own as wiringPi is designed to support the
Raspberry Pi ONLY.
This was the result of the command "SystemInfo.getCpuArchitecture());"
When I checked the code in Pi4J, I came to know it's reading /proc/cpuinfo at a certain moment in the file .\pi4j-core\src\main\java\com\pi4j\system\impl\DefaultSystemInfoProvider.java, method getCpuInfo(). This method is called from the following public method:
@Override
public String getCpuArchitecture() throws IOException, InterruptedException, UnsupportedOperationException {
return getCpuInfo("CPU architecture");
}
As a result, after the upgrade, the string BCM2835 is returned.
When I look to othe RPi's I have which did not update/upgrade yet, I get BCM2709 as return value. So, the new kernel is indeed putting a different string in the /proc/cpuinfo file!
When I look into the wiringPi code, file wiringPi.c (from the original repository, not the Pi4J repository), I see in the newest version that the string BCM2835 has been added because of a change in the newer kernel. See below:
// See if it's BCM2708 or BCM2709 or the new BCM2835.
// 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 proj...@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) ;
}
So, to solve this issue, I'm afraid we have to or move to the newer wiringPi code (I don't think the current wiringPi in Pi4J 1.1 is the latest one) or modify the current wiringPi code in the Pi4J 1.1
However, it's not clear to me if wiringPi is taken along in the maven build to creat the libpi4j.so. Is it? If so, would it be an "easy" task to throw in the latest wiringPi source code and put that into libpi4j.so?
If it's not, how to cope with the above?