We will get many times "Device or resource busy" error, when try to read or write GPIO pin of raspberry pi.

So, Is there any way to find out which GPIO pin of raspberry pi busy?

Thanks in advance.

  • If you get that error, the GPIO should be busy. That's one way to find out. Do you need a different way? If yes, why?
    – Joooeey
    Commented Feb 12 at 9:39

1 Answer 1


I suggest looking for entries in /sys/class/gpio. If GPIO X is in use by the kernel there will be a gpioX directory.

  • This isn't true. If a GPIO pin is used by the kernel, it won't show up in /sys/class/gpio; pins only show up here if they are being used by a user-space process using the sysfs filesystem interface. Anything that interacts with the gpio pins through a kernel driver (e.g, the bcm2835_gpiomem driver, which exposes /dev/gpiomem) will not create entries in the sysfs directory.
    – larsks
    Commented Nov 8, 2017 at 13:21
  • 3
    @larsks True, however I wouldn't class GPIO access via /dev/mem or /dev/gpiomem as use by the kernel, all the kernel does is allow access to the register memory. It has no knowledge of what the user process may be doing and would not raise the "Device or resource busy" error mentioned in the question.
    – joan
    Commented Nov 8, 2017 at 14:03

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.