# GPIO is not enough on WP7607

**URL:** <https://mangoh.discourse.group/t/gpio-is-not-enough-on-wp7607/7395>\
**Category:** mangOH Yellow\
**Created:** [March 31, 2021, 8:26am UTC](https://mangoh.discourse.group/t/gpio-is-not-enough-on-wp7607/7395 "2021-03-31T08:26:17Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![bruceke](https://avatars.discourse-cdn.com/v4/letter/b/0ea827/32.png) [@bruceke](https://mangoh.discourse.group/u/bruceke)\
**Post date:** [March 31, 2021, 8:26am UTC](https://mangoh.discourse.group/t/gpio-is-not-enough-on-wp7607/7395/1 "2021-03-31T08:26:17Z")

</div>

Because GPIO is not enough on WP7607 , can I use pcm , uart1 or wake\_on\_wwan pin as GPIO(is it support multi function? ) ?

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)\
**Post date:** [March 31, 2021, 8:37am UTC](https://mangoh.discourse.group/t/gpio-is-not-enough-on-wp7607/7395/2 "2021-03-31T08:37:48Z")

</div>

You can use ioctl to control 8 wire uart

You can also modify the yocto source to make those uart pin to be gpio

> **[Controlling DCD, DTR, DSR lines by legato application](https://forum.legato.io/t/controlling-dcd-dtr-dsr-lines-by-legato-application/3944/15)**
>
> i remember those numbers are correct for DCD,DTR and DSR.

---

<div class="post-metadata">

**Author:** ![bruceke](https://avatars.discourse-cdn.com/v4/letter/b/0ea827/32.png) [@bruceke](https://mangoh.discourse.group/u/bruceke)\
**Post date:** [April 12, 2021, 11:49am UTC](https://mangoh.discourse.group/t/gpio-is-not-enough-on-wp7607/7395/3 "2021-04-12T11:49:17Z")

</div>

Hi jyijyi,

I tried to use ioctl() call to control uart1 RTS pin (and check pin status on CN601.15) , but did not see the status change

```auto
#include <sys/ioctl.h> //ioctl() call defenitions
#include <fcntl.h>

main()
{
   int fd;
   fd = open("/dev/ttyHS0",O_RDWR | O_NOCTTY );//Open Serial Port
   int RTS_flag;
   RTS_flag = TIOCM_RTS;
   while(1){
    printf("RTS High\n");
    ioctl(fd,TIOCMBIS,&RTS_flag);//Set RTS pin
    sleep 2
    //getchar();
    printf("RTS Low\n");
    ioctl(fd,TIOCMBIC,&RTS_flag);//Clear RTS pin       
   }

   close(fd);
}

```

So I use sysfs way to do it DCD control (should it be GPIO24?) , But it seems that there is no state change

```auto
echo 24 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio24/direction
echo 1 > /sys/class/gpio/gpio24/value

```

Do I want to modify the kernel or is there any error in setting? (on mangOH yellow)

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)\
**Post date:** [April 12, 2021, 12:44pm UTC](https://mangoh.discourse.group/t/gpio-is-not-enough-on-wp7607/7395/4 "2021-04-12T12:44:40Z")

</div>

You can see here on how to control the cts pin

> **[UART flow control with WP7608](https://forum.legato.io/t/uart-flow-control-with-wp7608/4597/32)**
>
> To set RI pin as input pin: you need to first send an AT command: AT!RIOWNER=1 after that you can control the RI in linux console: echo RI \> /sys/class/gpio/export echo in \> /sys/class/gpio/gpioRI/direction cat...

Also you need to recompile yocto image to control dcd dtr dsr as gpio

---

<div class="post-metadata">

**Author:** ![bruceke](https://avatars.discourse-cdn.com/v4/letter/b/0ea827/32.png) [@bruceke](https://mangoh.discourse.group/u/bruceke)\
**Post date:** [April 15, 2021, 9:12am UTC](https://mangoh.discourse.group/t/gpio-is-not-enough-on-wp7607/7395/5 "2021-04-15T09:12:12Z")

</div>

Hi jyijyi,

Thank you for kind explanation, but I use ioctl to execute on mangoh yellow and still cannot make RTS, DCD, DTR, CTS… and other pin output status change

```auto
   int fd;
   fd = open("/dev/ttyHS0",O_RDWR | O_NOCTTY );//Open Serial Port
   
   int RTS_flag = TIOCM_RTS;
   int DCD_flag = TIOCM_CD;
   int DTR_flag = TIOCM_DTR;
   int CTS_flag = TIOCM_CTS;
   while(1){
    printf("RTS High\n");
    ioctl(fd,TIOCMBIS,&RTS_flag);//Set RTS pin
    sleep(1);
    ioctl(fd,TIOCMBIC,&RTS_flag);
    ioctl(fd, TIOCMSET, &DCD_flag);
    sleep(1);
    ioctl(fd,TIOCMBIC,&DCD_flag);
    ioctl(fd, TIOCMSET, &DTR_flag);
    sleep(1);
    ioctl(fd,TIOCMBIC,&DTR_flag);
    ioctl(fd, TIOCMSET, &CTS_flag);
    sleep(1);
    ioctl(fd,TIOCMBIC,&CTS_flag);

```

(The FW version on my platform)

 ![image](https://us1.discourse-cdn.com/flex016/uploads/mangoh/original/2X/0/007be9c243067342082120ff20af00e4cca83043.png)

So I tried to modify gpiolib-sysfs so that flow-control can be changed by sysfs , and I found that there is no “ext\_gpio\_map ext\_gpio\_wp” in my gpiolib-sysfs.c , the yocto sourcecode I used is “Legato-Dist-Source-mdm9x28-SWI9X07Y\_02.37.07.00.tar.bz2” (R16 firmware).

Where can I download the appropriate FW version for compilation?

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)\
**Post date:** [April 15, 2021, 9:27am UTC](https://mangoh.discourse.group/t/gpio-is-not-enough-on-wp7607/7395/6 "2021-04-15T09:27:08Z")

</div>

Is that you must use R16?  
I remember i used R13 at that time.

Your code is not changing the pin status  
This is the code to change CTS pin

```
     int arg;
	 if (ioctl(fd1, TIOCMGET, &arg) == -1)
	 {
	 	LE_DEBUG("ERROR: %s", strerror(errno));
	 }

	 if (level)
		  arg |= TIOCM_RTS;
	   else
	   	  arg &= ~TIOCM_RTS;

	  if (ioctl(fd1, TIOCMSET, &arg) == -1) {
	    		LE_DEBUG("ERROR: %s", strerror(errno));
	      }
```

---

<div class="post-metadata">

**Author:** ![bruceke](https://avatars.discourse-cdn.com/v4/letter/b/0ea827/32.png) [@bruceke](https://mangoh.discourse.group/u/bruceke)\
**Post date:** [April 19, 2021, 9:19am UTC](https://mangoh.discourse.group/t/gpio-is-not-enough-on-wp7607/7395/7 "2021-04-19T09:19:30Z")

</div>

Hi jyijyi,

Thanks for your quick reply

I tried to rebuild the source code of Yocto and change gpiolib-sysfs.c  
After generating the .cwe file, combine cwe into custom-firmware image and -reflash

 ![image](https://us1.discourse-cdn.com/flex016/uploads/mangoh/original/2X/b/b9620a0f7fb6a13f5327646e03fb144eafc1dfd1.png)

Some error occurred when we type  
`echo 17> /sys/class/gpio/export`  
 ![image](https://us1.discourse-cdn.com/flex016/uploads/mangoh/original/2X/c/ce307a62f483292371193188d40fb4bf6f3d3515.png)

I checked the kernel build date and found that the build date has not been updated

 ![image](https://us1.discourse-cdn.com/flex016/uploads/mangoh/original/2X/6/617fa8fbe3b38bf0baf1b525d8c8ff12d7de4a7c.png)  
Is my burning method wrong? (Or choose the wrong file)

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)\
**Post date:** [April 19, 2021, 9:23am UTC](https://mangoh.discourse.group/t/gpio-is-not-enough-on-wp7607/7395/8 "2021-04-19T09:23:41Z")

</div>

You can directly update the yocto\_wp76xx.cwe

---

<div class="post-metadata">

**Author:** ![bruceke](https://avatars.discourse-cdn.com/v4/letter/b/0ea827/32.png) [@bruceke](https://mangoh.discourse.group/u/bruceke)\
**Post date:** [April 19, 2021, 9:53am UTC](https://mangoh.discourse.group/t/gpio-is-not-enough-on-wp7607/7395/9 "2021-04-19T09:53:40Z")

</div>

Thanks your comment  
I’d re-flash mangoh with yocto\_wp76xx.4k.cwe only, but the test result is still the same, the build date and gpio sysfs have not been updated

 ![image](https://us1.discourse-cdn.com/flex016/uploads/mangoh/original/2X/e/e1f3d77dae48017c3a4714b66dc024437554a727.png)

test result:

 ![image](https://us1.discourse-cdn.com/flex016/uploads/mangoh/original/2X/3/3b494d624be1263c086650275b95cba697ec4767.png)

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jyijyi/32/997_2.png) [@jyijyi](https://mangoh.discourse.group/u/jyijyi)\
**Post date:** [April 19, 2021, 10:58am UTC](https://mangoh.discourse.group/t/gpio-is-not-enough-on-wp7607/7395/10 "2021-04-19T10:58:07Z")

</div>

didn’t Apr19 22:05:25 already updated?

How do you change for gpiolib-sysfs.c ?

You can use my yocto image for WP76 on R13:  
root@swi-mdm9x28-wp:~# echo 101 \> /sys/class/gpio/export  
root@swi-mdm9x28-wp:~# echo 102 \> /sys/class/gpio/export  
root@swi-mdm9x28-wp:~# microcom /dev/ttyAT  
ati8  
Legato Ver: 20.04.0\_96205776d64ef766ba918ebe5586c885\_modified  
Yocto Ver: SWI9X07Y\_02.28.03.05 2020-03-09\_02:35:57  
OS Ver: Linux version 3.18.131 (oe-user@oe-host) (gcc version 7.3.0 (GCC) ) #1 PREEMPT Wed Feb 26 04:17:04 UTC 2020  
LK Ver: SWI9X07Y\_02.28.03.05  
RootFS Ver: SWI9X07Y\_02.28.03.05 2020-03-09\_02:35:57  
UserFS Ver: unknown  
MCU Ver: 002.011

OK

> **[yocto\_wp76xx.4k\_R13\_DTR\_DSR\_DCD.cwe](https://drive.google.com/file/d/1zqsTJwtxJcBrgv6yccdE8-vzSB_YUN4G/view?usp=sharing)**
>
> Google Drive file.

---

<div class="post-metadata">

**Author:** ![bruceke](https://avatars.discourse-cdn.com/v4/letter/b/0ea827/32.png) [@bruceke](https://mangoh.discourse.group/u/bruceke)\
**Post date:** [April 20, 2021, 9:30am UTC](https://mangoh.discourse.group/t/gpio-is-not-enough-on-wp7607/7395/11 "2021-04-20T09:30:18Z")

</div>

Thanks

It looks like an incorrect flash command caused no update

 ![image](https://us1.discourse-cdn.com/flex016/uploads/mangoh/original/2X/6/679159d2107164faad974b8659d0761966aa0f80.png)
