3

I'm having a bit of trouble accessing GPIO23 using /sys/class/gpio/. To clarify a few terms (according to the table on this page):

  • Header pin 16 is BCM GPIO 23, which is wiringPi pin 4.
  • Header pin 11 is BCM GPIO 17, which is wiringPi pin 0.

I can turn on an LED attached to header pin 16 and 11 using the following wiringPi program:

#include <wiringPi.h>
int main (void)
{
  int pin = 0; // or 4
  wiringPiSetup () ;
  pinMode (pin, OUTPUT) ;
  for (;;)
  {
    digitalWrite (pin, HIGH) ; delay (500) ;
    digitalWrite (pin,  LOW) ; delay (500) ;
  }
  return 0 ;
}

And I can flash an LED attached to header pin 11 (GPIO pin 17, wiringPi pin 0) in the OS like so:

$ echo 17 > /sys/class/gpio/export
$ echo out > /sys/class/gpio/gpio17/direction
$ echo 1 > /sys/class/gpio/gpio17/value

but when I try to access header pin 16 (GPIO pin 23, wiringPi pin 0) I get the following error message:

$ echo 23 > /sys/class/gpio/export 
-bash: echo: write error: Device or resource busy

Some more information:

$ ls /sys/class/gpio/
export  gpio17  gpiochip0  unexport

Bringing GPIO17 up when it is already up:

$ echo 17 > /sys/class/gpio/export 
-bash: echo: write error: Device or resource busy

The gpio tool that comes with wiringPi gives me a similar error. I know wiringPi uses a memory map to write to the GPIO so there appears to be some kind of problem with the OS.

  • 2
    The gpio is already exported. Trying to export again gives that error. Have you tried the echo 1 etc to the port? By the way what model Pi are you using? – joan May 29 '15 at 11:51
  • Does this happen after you've been mucking about for a bit, or is it a consistent issue after a reboot? – goldilocks May 29 '15 at 13:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.