0

I was using wiringPi to to control the GPIO pins on a Raspberry Pi model 3 and 4b (these originally had Buster installed on them) successfully until today when I did a rpi-update to get kernel 6.1.

Now when I issue any commands based on wiringPi (including something simple like "gpio -v", I get this error on the console:

pi [01:23 AM] tmp$gpio -v gpio version: 2.52 Copyright (c) 2012-2018 Gordon Henderson This is free software with ABSOLUTELY NO WARRANTY. For details type: gpio -warranty

Oops: Unable to determine board revision from /proc/cpuinfo -> No "Hardware" line -> You'd best google the error to find out why.

I'd like to keep using wiringPi. Can you suggest how to get around this? By the way, here is the current contents of /proc/cpuinfo

pi [12:54 AM] test3$cat /proc/cpuinfo processor : 0 BogoMIPS : 108.00 Features : fp asimd evtstrm crc32 cpuid CPU implementer : 0x41 CPU architecture: 8 CPU variant : 0x0 CPU part : 0xd08 CPU revision : 3

processor : 1 BogoMIPS : 108.00 Features : fp asimd evtstrm crc32 cpuid CPU implementer : 0x41 CPU architecture: 8 CPU variant : 0x0 CPU part : 0xd08 CPU revision : 3

processor : 2 BogoMIPS : 108.00 Features : fp asimd evtstrm crc32 cpuid CPU implementer : 0x41 CPU architecture: 8 CPU variant : 0x0 CPU part : 0xd08 CPU revision : 3

processor : 3 BogoMIPS : 108.00 Features : fp asimd evtstrm crc32 cpuid CPU implementer : 0x41 CPU architecture: 8 CPU variant : 0x0 CPU part : 0xd08 CPU revision : 3

Revision : b03112 Serial : 100000006864cf37 Model : Raspberry Pi 4 Model B Rev 1.2

I think I am still in 32-bit. Apparently there is no way to edit /proc/cpuinfo since the OS creates it.

Thanks in advance for your help! Any idea how to get it working again? If not, what is the best replacement to read and write IO pins?

2
  • Which language are you using? The official wiringpi is no longer supported. There is an unofficial version. Personally I use Python and the gpiozero library.
    – CoderMike
    Nov 20, 2023 at 20:46
  • I am doing my main coding in node.js but wrote a c program using wiringPi to handle the GPIO pins for the node script because that used to be a library packaged with the Rpi and there were lots of examples online. See below for what I'm trying now. And Thanks!
    – Baxter
    Nov 21, 2023 at 1:33

3 Answers 3

1
  1. Did you not see a warning when you ran rpi-update? Why did you ignore it? sudo apt update; sudo apt install --reinstall libraspberrypi0 libraspberrypi-{bin,dev,doc} raspberrypi-bootloader raspberrypi-kernel will put it back to the latest supported kernel/bootcode. Which is 6.1.21 for Bullseye 5.10.103 for Buster.

  2. You state "these originally had Buster installed"; this is irrelevant - what you you have now?

  3. The version: 2.52 of wiringPi was deprecated by the author in 2019, but should still work - at least on the Pi models available at the time (although I have not used since Buster).

  4. "what is the best replacement to read and write IO pins" Controlling Raspberry Pi GPIO with c and Python is a review of available libraries I produced.

5
  • 1
    1. Yes, I read the warning. I did not ignore it, I backed up my SD card first. I decided to try it because I was having segmentation faults with mjpeg streamer and couldn't think of anything else to try after reading many posts about it. I can try your great suggestions to go back to a supported kernel. 2. It is Buster except for the new kernel. 3. I can try it again after the downgrade to the kernel, which apparently changes the format / content of /proc/cpuinfo, causing the problem.
    – Baxter
    Nov 21, 2023 at 1:19
  • 1
    4. On the plus side of the whole experience, I found a node.js library called "onoff" that handles the GPIO pins nicely from within node.js so I don't really need to spawn to my c program that uses wiringPi to handle the pins after all.
    – Baxter
    Nov 21, 2023 at 1:23
  • The kernel update did not help with the mjpeg streamer segmentation fault issue, by the way. It still runs fine for a variable number of minutes and then dies with a segmentation fault. If you have any suggestions on that... please post or send me a link. Otherwise, I'll keep digging or try a native node.js library I just found to see if it can control and serve my camera without crashing.
    – Baxter
    Nov 21, 2023 at 1:29
  • 1
    Segmentation fault indicates something is attempting to access non existent memory. This is extremely unlikely to be anything to do with kernel or firmware.
    – Milliways
    Nov 21, 2023 at 1:55
  • your commands to restore the kernel to 5.10.103 worked well and now wiringPI ([email protected]) is working again on the RPi 4B
    – Baxter
    Nov 21, 2023 at 8:19
0

You can solve the "No "Hardware" line" - problem by editing the file ~/WiringPi/wiringPi/wiringPi.c

There is a procedure (original at line 747) : int piGpioLayout (void)

Below that you have a line

#ifdef DONT_CARE_ANYMORE

Move this line UP just below the first call of piGpioLayoutOops().

This should now look like this : ... ... if ((cpuFd = fopen ("/proc/cpuinfo", "r")) == NULL) piGpioLayoutOops ("Unable to open /proc/cpuinfo") ; #ifdef DONT_CARE_ANYMORE

// Start by looking for the Architecture to make sure we're really running ... ...

This prevents the check of the (no longer existing) 'hardware' line, but keeps the Revision check functional.

Save the file and run the WiringPi build script again: cd ~/WiringPi ./build

WiringPi should work now as usual.

I tested it on a Raspberry Pi 4 without problems (so far), but it may lead to problems on older pis with different pinouts.

1
  • user160491, you are legend and saved my hide! Thank you! I used your method on a couple of raspberry-pi's with great success each time.
    – user160580
    Feb 20 at 10:50
0

Unfortunately the WiringPi library is abandonware despite being widely used.

Expanding on user160491's comments, you can apply the following git patch to update wiringpi so it ignores the errors and runs properly on a Raspberry Pi 3/4 (thank you user160491 for the fix).

Clone the wiringpi library and then you can run the following patch:

cd /usr/local/src/
git clone https://github.com/WiringPi/WiringPi.git
cd WiringPi

Now apply the patch

cat <<'PATCH' | patch --ignore-whitespace -p1 wiringPi/wiringPi.c
@@ -747,6 +747,7 @@ int piGpioLayout (void)
   if ((cpuFd = fopen ("/proc/cpuinfo", "r")) == NULL)
     piGpioLayoutOops ("Unable to open /proc/cpuinfo") ;

+#ifdef DONT_CARE_ANYMORE
 // Start by looking for the Architecture to make sure we're really running
 // on a Pi. I'm getting fed-up with people whinging at me because
 // they can't get it to work on weirdFruitPi boards...
@@ -769,7 +770,6 @@ int piGpioLayout (void)
 // I do not support so don't email me your bleating whinges about anything
 // other than a genuine Raspberry Pi.

-#ifdef DONT_CARE_ANYMORE
   if (! (strstr (line, "BCM2708") || strstr (line, "BCM2709") || strstr (line, "BCM2835")))
   {
     fprintf (stderr, "Unable to determine hardware version. I see: %s,\n", line) ;
PATCH

Now build and everything should work

./build

After that your packages should work as they were before.

New contributor
Stephen Wood is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.