Because GPIO is not enough on WP7607 , can I use pcm , uart1 or wake_on_wwan pin as GPIO(is it support multi function? ) ?
You can use ioctl to control 8 wire uart
You can also modify the yocto source to make those uart pin to be gpio
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
#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
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)
You can see here on how to control the cts pin
Also you need to recompile yocto image to control dcd dtr dsr as gpio
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
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)
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?
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));
}
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
Some error occurred when we type
echo 17> /sys/class/gpio/export
I checked the kernel build date and found that the build date has not been updated
Is my burning method wrong? (Or choose the wrong file)
You can directly update the yocto_wp76xx.cwe
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
test result:
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