Controlling WP_GPIO_1 / GPIO22 problem



I try to control gpio22 (WP_GPIO_2 on the mangoh Red, pin13 on PI header) but I get a warning when starting the app:

-WRN- | gpioService[789]/sysfsGpio T=main | gpioSysfsUtils.c gpioSysfs_SessionOpenHandlerFunc() 1112 | Unable to export GPIO gpio22 for use - stopping session

Changing to gpio21 and the app works fine.
Any tips to get gpio22 working?



The pin on the Raspberry Pi header labeled WP_GPIO_1_lvl corresponds to GPIO22 on the outer ring of the CF3 socket. WP_GPIO_2_lvl corresponds to GPIO23 on the outer ring of the CF3 socket.

Lets try to isolate whether this is a Linux problem or a GpioService problem. On my mangOH Red with wp85, I was able to do the following:

# cd /sys/class/gpio
# echo 22 > export
# cd gpio22
# cat direction

Now I connect Raspberry Pi header pin 11 (WP_GPIO_1_lvl) to pin 25 (ground)

# cat value

Now I connect Raspberry Pi header pin 11 (WP_GPIO_1_lvl) to pin 1 (3.3V)

# cat value

The sysfs interface to the GPIO seems to be working. Can you check and see if it works for you?


Sorry, ment WP_GPIO_1. WP_GPIO_2 works.

root@swi-mdm9x15:/sys/class/gpio# echo 22 > export
sh: write error: Device or resource busy



Can you confirm that there isn’t already a /sys/class/gpio/gpio22/ directory before running the echo command?

Please also supply the output of lsmod


Can confirm there is no gpio22 folder. See screenshot below:


Thank you @nilsarve for reporting this problem. There was a bug in a kernel driver which meant that GPIO22 was being taken by the kernel when it shouldn’t have been.

Fixed in this commit


Ok, glad you fixed it. :clap:

I have updated the 2 files.
How do I update my kernel driver?

Cannot get Heartbeat app to work

Assuming you are building the mangOH Red system, then all you need to do is:

$ cd location/of/mangOH
$ git pull
$ git submodule update
$ make clean
$ make red_wp85
$ update mangOH_Red.wp85.update


Got it working! Thank you! :+1:


I am encountering same kind of problem when trying to get the CAN IoT driver to work. I am following:
“How to build MCP2515 CAN drivers for mangOH for mangOH Red”

step 10) To use on mangOH IoT slot, run ssh root@ and do the following commands:
echo 2 > /sys/class/gpio/export
gives me this error:
sh: write error: Device or resource busy
How can I get it to work?