# Binding WP\_GPIO\_5 (GPIO36)

**URL:** <https://mangoh.discourse.group/t/binding-wp-gpio-5-gpio36/923>\
**Category:** mangOH Red\
**Created:** [November 23, 2017, 8:57pm UTC](https://mangoh.discourse.group/t/binding-wp-gpio-5-gpio36/923 "2017-11-23T20:57:51Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![nick](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/nick/32/1380_2.png) [@nick](https://mangoh.discourse.group/u/nick)\
**Post date:** [November 23, 2017, 8:57pm UTC](https://mangoh.discourse.group/t/binding-wp-gpio-5-gpio36/923/1 "2017-11-23T20:57:51Z")

</div>

Hello all,

I’m having some trouble binding `WP_GPIO_5_wakeable` in my app.

![04 PM](https://cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/flex016/uploads/mangoh/original/1X/f600223a287deeb90bbf6d532bae715fb4e68de3.png)  
Screenshot taken from MangOH Red schematics page 2.

My app definition and component definition are as follows:

`Component.cdef`

```auto
cflags:
{
  -std=c99
  -I$BRNKL_ROOT/apps/sensorToCloud/sensors/dht
}

requires:
{
  api:
  {
    le_adc = ${LEGATO_ROOT}/interfaces/modemServices/le_adc.api
    le_digital1 = ${LEGATO_ROOT}/interfaces/le_gpio.api
    le_digital2 = ${LEGATO_ROOT}/interfaces/le_gpio.api
    le_iot1 = ${LEGATO_ROOT}/interfaces/le_gpio.api
    le_iot2 = ${LEGATO_ROOT}/interfaces/le_gpio.api
    le_iot3 = ${LEGATO_ROOT}/interfaces/le_gpio.api
    le_iot4 = ${LEGATO_ROOT}/interfaces/le_gpio.api
    le_dht = ${LEGATO_ROOT}/interfaces/le_gpio.api
    le_posCtrl = ${LEGATO_ROOT}/interfaces/positioning/le_posCtrl.api
    le_pos = ${LEGATO_ROOT}/interfaces/positioning/le_pos.api
    le_cfg = ${LEGATO_ROOT}/interfaces/le_cfg.api
    le_spi = ${LEGATO_ROOT}/interfaces/le_spi.api
  }

  file:
  {
    /sys/devices/i2c-0/0-0068/iio:device0/in_accel_x_raw /sys/devices/i2c-0/0-0068/iio:device0/
    /sys/devices/i2c-0/0-0068/iio:device0/in_accel_y_raw /sys/devices/i2c-0/0-0068/iio:device0/
    /sys/devices/i2c-0/0-0068/iio:device0/in_accel_z_raw /sys/devices/i2c-0/0-0068/iio:device0/
    /sys/devices/i2c-0/0-0068/iio:device0/in_accel_scale /sys/devices/i2c-0/0-0068/iio:device0/
    /sys/devices/i2c-0/0-0068/iio:device0/in_anglvel_x_raw /sys/devices/i2c-0/0-0068/iio:device0/
    /sys/devices/i2c-0/0-0068/iio:device0/in_anglvel_y_raw /sys/devices/i2c-0/0-0068/iio:device0/
    /sys/devices/i2c-0/0-0068/iio:device0/in_anglvel_z_raw /sys/devices/i2c-0/0-0068/iio:device0/
    /sys/devices/i2c-0/0-0068/iio:device0/in_anglvel_scale /sys/devices/i2c-0/0-0068/iio:device0/
    /sys/devices/i2c-0/0-0076/iio:device1/in_temp_input /sys/devices/i2c-0/0-0076/iio:device1/
    /sys/devices/i2c-0/0-0076/iio:device1/in_pressure_input /sys/devices/i2c-0/0-0076/iio:device1/
  }
}

sources:
{
  init.c
  sensorUtils.c
  lightSensor.c
  pressureSensor.c
  accelerometer.c 
  bilgeWater.c
  gps.c
  analoginputs.c
  batteries.c
  dht/dht.c
}

```

`sensorToCloud.adef`

```auto
sandboxed: true
start: auto
version: 0.1

executables:
{
  sensorToCloud = ( avPublisher sensors )
  spiService = ( $LEGATO_ROOT/components/spiService )
}

processes:
{
  run:
  {
    ( sensorToCloud spiService )
  }
  faultAction: restart

  envVars:
  {
    LE_LOG_LEVEL = DEBUG
  }
}

bindings:
{
  sensorToCloud.sensors.le_adc -> modemService.le_adc
  sensorToCloud.sensors.le_digital1 -> gpioExpanderServiceRed.mangoh_gpioExpPin3
  sensorToCloud.sensors.le_digital2 -> gpioExpanderServiceRed.mangoh_gpioExpPin4
  sensorToCloud.sensors.le_iot1 -> <root>.le_gpioPin42
  sensorToCloud.sensors.le_iot2 -> <root>.le_gpioPin13
  sensorToCloud.sensors.le_iot3 -> <root>.le_gpioPin7
  sensorToCloud.sensors.le_iot4 -> <root>.le_gpioPin8
  sensorToCloud.sensors.le_dht -> <root>.le_gpioPin36
  sensorToCloud.sensors.le_posCtrl -> positioningService.le_posCtrl
  sensorToCloud.sensors.le_pos -> positioningService.le_pos
  sensorToCloud.sensors.le_spi -> spiService.le_spi
  sensorToCloud.avPublisher.le_avdata -> avcService.le_avdata 
}

extern:
{
  spiService.spiService.le_spi
}

```

The app appears to hangup with this message:

`LE_FILENAME InitPool() 303 | Memory pool name 'framework.hashMap_refle_dht_ClientHandler' is truncated to 'framework.hashMap_refle_dht_Cli'`

Hopefully I’m not missing something obvious here. Any help is greatly appreciated.

---

<div class="post-metadata">

**Author:** ![gregnietsky](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/gregnietsky/32/66_2.png) [@gregnietsky](https://mangoh.discourse.group/u/gregnietsky)\
**Post date:** [November 23, 2017, 10:42pm UTC](https://mangoh.discourse.group/t/binding-wp-gpio-5-gpio36/923/2 "2017-11-23T22:42:58Z")

</div>

This pin is SYSFS only and needs to be configured via a AT command

AT+WIOCFG=36,16

You will need to export it and use /sys not legato API

---

<div class="post-metadata">

**Author:** ![nick](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/nick/32/1380_2.png) [@nick](https://mangoh.discourse.group/u/nick)\
**Post date:** [November 23, 2017, 11:50pm UTC](https://mangoh.discourse.group/t/binding-wp-gpio-5-gpio36/923/3 "2017-11-23T23:50:59Z")

</div>

Thank you @gregnietsky, I’ll give this a try. Do you know anything about binding `GPIO_0_EXP` and `GPIO_1_EXP` on the MT7697 module? I haven’t seen any examples for this. ![40 PM](https://cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/flex016/uploads/mangoh/original/1X/bd016efd65048e9b7716ed1838e01475a124e356.png)

---

<div class="post-metadata">

**Author:** ![dfrey](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/dfrey/32/303_2.png) [@dfrey](https://mangoh.discourse.group/u/dfrey)\
**Post date:** [November 29, 2017, 12:12pm UTC](https://mangoh.discourse.group/t/binding-wp-gpio-5-gpio36/923/4 "2017-11-29T12:12:15Z")

</div>

The `GPIO_*_EXP` pins you reference are connected directly to the mt7697 so there is no convenient out of the box way to control those from Linux. Technically it would be possible to write a gpiochip kernel driver that talks over SPI or the UART to the mt7697, but we haven’t done that. Is there a reason why you need those specific GPIOs controlled by Linux?

---

<div class="post-metadata">

**Author:** ![nick](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/nick/32/1380_2.png) [@nick](https://mangoh.discourse.group/u/nick)\
**Post date:** [November 29, 2017, 5:28pm UTC](https://mangoh.discourse.group/t/binding-wp-gpio-5-gpio36/923/5 "2017-11-29T17:28:21Z")

</div>

Thanks for the reply @dfrey. We were previously unaware of this constraint. We’ll simply use some different GPIO pins in that case. Is there any documentation showing which pins will require additional driver work? Or should we just assume any I/O on separate chip will require some extra work?

---

<div class="post-metadata">

**Author:** ![dfrey](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/dfrey/32/303_2.png) [@dfrey](https://mangoh.discourse.group/u/dfrey)\
**Post date:** [November 29, 2017, 5:56pm UTC](https://mangoh.discourse.group/t/binding-wp-gpio-5-gpio36/923/6 "2017-11-29T17:56:14Z")

</div>

Choose GPIOs that come directly from the WP module and you should be pretty safe. It’s also possible to write code for the MT7697 that uses the GPIOs you mentioned, but that will complicate your software design a bit.

---

<div class="post-metadata">

**Author:** ![nick](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/nick/32/1380_2.png) [@nick](https://mangoh.discourse.group/u/nick)\
**Post date:** [November 29, 2017, 10:19pm UTC](https://mangoh.discourse.group/t/binding-wp-gpio-5-gpio36/923/7 "2017-11-29T22:19:27Z")

</div>

Thanks @dfrey, we’ll keep this mind going forward.

---

<div class="post-metadata">

**Author:** ![nick](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/nick/32/1380_2.png) [@nick](https://mangoh.discourse.group/u/nick)\
**Post date:** [December 6, 2017, 11:57pm UTC](https://mangoh.discourse.group/t/binding-wp-gpio-5-gpio36/923/8 "2017-12-06T23:57:52Z")

</div>

@dfrey Is there a nice way to attach a callback function to a SYSFS GPIO value change? It was extremely convenient to use [`le_gpio_AddChangeEventHandler`](http://legato.io/legato-docs/latest/le __gpio__ interface_8h.html#ae6fc799fa2d2497bb2fe158e3090649f) for this purpose but obviously this is not an option for GPIO pins that are SYSFS only.

---

<div class="post-metadata">

**Author:** ![Raf](https://avatars.discourse-cdn.com/v4/letter/r/848f3c/32.png) [@Raf](https://mangoh.discourse.group/u/Raf)\
**Post date:** [December 7, 2017, 12:27am UTC](https://mangoh.discourse.group/t/binding-wp-gpio-5-gpio36/923/9 "2017-12-07T00:27:43Z")

</div>

I’m also interested if this is possible.

@nick  
If you have any spare (non SYSFS-locked) GPIO pins you could connect the signal to both GPIO36 and some other GPIO for monitoring in an app, enabling you to use `le_gpio_AddChangeEventHandler`.

A bit wasteful, I know - but it works.

---

<div class="post-metadata">

**Author:** ![nick](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/nick/32/1380_2.png) [@nick](https://mangoh.discourse.group/u/nick)\
**Post date:** [December 7, 2017, 1:35am UTC](https://mangoh.discourse.group/t/binding-wp-gpio-5-gpio36/923/10 "2017-12-07T01:35:02Z")

</div>

@Raf Unfortunately we’re stuck using these pins. The callback and event loop method is a very elegant so I would like to preserve it if possible.

---

<div class="post-metadata">

**Author:** ![dfrey](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/dfrey/32/303_2.png) [@dfrey](https://mangoh.discourse.group/u/dfrey)\
**Post date:** [December 7, 2017, 4:22pm UTC](https://mangoh.discourse.group/t/binding-wp-gpio-5-gpio36/923/11 "2017-12-07T16:22:27Z")

</div>

Hi @nick,

The API of interest is `interfaces/le_gpio.api` in the Legato project. The GpioExpanderService for mangOH Green and mangOH Red implement this API for the sx1509 GPIO expanders on the mangOH boards. There is a [sample program](https://github.com/legatoproject/legato-af/tree/master/apps/sample/gpioCf3Demo) in Legato which demonstrates the use of the WP GPIOs using the GpioService.

Let me know if you have any questions after reading through that sample.

---

<div class="post-metadata">

**Author:** ![nick](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/nick/32/1380_2.png) [@nick](https://mangoh.discourse.group/u/nick)\
**Post date:** [December 12, 2017, 10:11pm UTC](https://mangoh.discourse.group/t/binding-wp-gpio-5-gpio36/923/12 "2017-12-12T22:11:54Z")

</div>

Hey @dfrey,

That appears to be working. Thanks for the support.

---

<div class="post-metadata">

**Author:** ![nick](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/nick/32/1380_2.png) [@nick](https://mangoh.discourse.group/u/nick)\
**Post date:** [December 19, 2017, 7:04pm UTC](https://mangoh.discourse.group/t/binding-wp-gpio-5-gpio36/923/13 "2017-12-19T19:04:57Z")

</div>

Hello all,

We had `le_gpioPin36` and `le_gpioPin38` working using `gpioService`, however as of this morning only `le_gpioPin38` is working. We get the following message for `le_gpioPin36`: `Skipping starting GPIO Service for Pin 36 - pin not available or disabled by config`. What config does this refer to, and what would cause the pin to be unavailable?

---

<div class="post-metadata">

**Author:** ![nick](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/nick/32/1380_2.png) [@nick](https://mangoh.discourse.group/u/nick)\
**Post date:** [December 19, 2017, 7:27pm UTC](https://mangoh.discourse.group/t/binding-wp-gpio-5-gpio36/923/14 "2017-12-19T19:27:57Z")

</div>

Hello again, I believe this may be a false alarm. I’ll report back tomorrow.

---

<div class="post-metadata">

**Author:** ![nick](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/nick/32/1380_2.png) [@nick](https://mangoh.discourse.group/u/nick)\
**Post date:** [December 22, 2017, 1:05am UTC](https://mangoh.discourse.group/t/binding-wp-gpio-5-gpio36/923/15 "2017-12-22T01:05:56Z")

</div>

Confirmed this was a false alarm.
