Missing GPIO export R15,R14.1.1

Hello

im using using FX30S wp77xx module with R11 + Legato 18.09.2 and we are migrating to R14.1.1 due to the recent sierra comunication about the new memory module which will not be supported by old firmwares.

Moved from devstudio to vscode+leaf dev env

Using leaf package swi-wp77_5.0.2

I have built the system with no errors , used swicwe to build a complete spk including linux+modem+legato and then flashed it onto the device.

The flash was successfull but for some reason one application using the GPIO to power the usr led has trouble binding the the gpioService.

After some debug , doing the command “sdir list” from ssh connection
i found out that the required platform service export for the GPIO pins were missing.

thinking it was a firmware build problem, i downloaded the full r14.1.1 release from sierra site and flashed the modem

doing sdir list now shows the pins 47 and 48 which are the usr led pins.

After this test i’ve rebuilt the my firmware again and flashed it onto the modem to see if maybe it was just a random case.

Still, with my build the GPIO pins 47 and 48 are not exported.

going deeper, checking the /sys/class/gpio directory on my firmware i see no gpioXX files
while with the r14.1.1 full from sierra i can see the gpioXX files.

Im aware of the GPIO_DESIGN_V2 and also checked in /sys/class/gpio/v2 folder, same result, on my firmware there are no files named gpioXX while on the sierra one there are.

in the sierra firmware doing a cat on the mask and mask_v2 file , which is used to determine if the pin is available or not under the folder /sys/class/gpio/gpiochip1 i get:
mask: 0x000003ffffbfff77
mask_v2 : 77 ff bf ff ff 03 00 00 00 00

the same result is given for my firmware

doing gpioSysfs_IsPinAvailable function my self with pen and paper i see that the pin 47 and 48 are under the “03” which should not made them available even in the sierra firmware.

because the result whill always be false when doing “check & (1 << bitInMask));”
all the pins will be available if all the hex codes are “f”

here the complete function code

bool gpioSysfs_IsPinAvailable
(
int pinNum ///< [IN] GPIO object reference
)
{
char path[64];
char result[33];
le_result_t leResult;
uint8_t check;
uint32_t index;
uint32_t bitInMask;

if ((pinNum < MIN_PIN_NUMBER) || (pinNum > MAX_PIN_NUMBER))
{
    LE_WARN("Pin number %d is out of range", pinNum);
    return false;
}

snprintf(path, sizeof(path), "%s/gpiochip1/mask%s",
         SYSFS_GPIO_PATH, (GpioDesign == SYSFS_GPIO_DESIGN_V2 ? "_v2" : ""));
leResult = ReadSysGpioSignalAttr(path, sizeof(result), result);
if (leResult != LE_OK)
{
    return false;
}

LE_DEBUG("Mask read as: %s", result);

if (GpioDesign == SYSFS_GPIO_DESIGN_V2)
{
    bitInMask = (pinNum - 1) % 8;
    index = ((pinNum - 1) / 8) * 3 + (bitInMask < 4);
    bitInMask %= 4;
}
else
{
    // The mask is 64 bits long
    // The format of the string is 0xnnnnnnnnnnnnnnnn. Each "n" represents 4 pins, starting
    // with pin 1-4 on the far right. So we can calculate where to look based on the pin number
    // e.g. 1-4 = index 17, 5-8 = index 16 etc.
    index = 17 - (pinNum - 1) / 4;
    bitInMask = (pinNum - 1) % 4;
}

// Convert the mask to a number from a hex string
LE_DEBUG("Mask calculated for %d as bit %d at index %d", pinNum, bitInMask, index);

// Convert the entry in the mask from a hex character to a number
check = toupper(result[index]) - (isdigit(result[index]) ? '0' : 'A' - 10);

LE_DEBUG("About to compare %x and %x", check, (1 << bitInMask));
return (check & (1 << bitInMask));

}

i’ve rebuilt the firmware many times , but i am unable to make the pins 47 and 48 work and im out of ideas.

I moved also to the legato source doing leaf getsrc swi-legato and rebuilt the entire framework before building my system , but the problem still persist.

To build my spk file is use the linux and modem images downloaded by leaf.

i’ve also tried the r15 (which is present only on leaf and its still in beta) but the problem is the same , also i cant test r15 firmware built by sierra because there isn’t one on the sierra site.

Any suggestion? what am i missing when build my firmware? why does the sierra firmware works if the bit mask should not let the lagato function export the pins 47 and 48?

what did you see for
AT+WIOCFG?

And what did you see for

ls /sys/class/gpio/

on my firmware built from legato src :

==============AT+WIOCFG?======================
AT+WIOCFG?
+WIOCFG: 2,16,0,0,1,0,0
+WIOCFG: 4,3,0,0,1,0,0
+WIOCFG: 6,16,0,0,1,0,0
+WIOCFG: 7,16,0,0,1,0,0
+WIOCFG: 8,4,1,0,1,0,0
+WIOCFG: 13,16,0,0,1,0,0
+WIOCFG: 21,16,0,0,1,0,0
+WIOCFG: 22,16,0,0,1,0,0
+WIOCFG: 23,4,1,1,0,0,0
+WIOCFG: 24,16,0,0,1,0,0
+WIOCFG: 25,16,0,0,1,0,0
+WIOCFG: 28,16,0,0,1,0,0
+WIOCFG: 29,16,0,0,1,0,0
+WIOCFG: 30,16,0,0,1,0,0
+WIOCFG: 31,16,0,0,1,0,0
+WIOCFG: 32,16,0,0,1,0,0
+WIOCFG: 33,16,0,0,1,0,0
+WIOCFG: 35,16,0,0,1,0,0
+WIOCFG: 42,16,0,0,1,0,0

OK

=================ls /sys/class/gpio================
root@fx30s:~# ls /sys/class/gpio
export gpiochip1 gpiochip1018 gpiochip820 gpiochip884 gpiochip948 unexport
gpiochip0 gpiochip1012 gpiochip200 gpiochip852 gpiochip916 gpiochip980 v2

================= ls /sys/class/gpio/v2=============
root@fx30s:~# ls /sys/class/gpio/v2
alias_define alias_unexport gpiochip0 gpiochip200 gpiochip916
alias_export aliases gpiochip1 gpiochip820 gpiochip948
alias_map aliases_exported gpiochip1012 gpiochip852 gpiochip980
alias_undefine export gpiochip1018 gpiochip884 unexport

on FX30_WP77xx_full_R14.1.1.002-generic-SWI9X06Y_02.36.06.00.cwe firmware by sierra:

==============AT+WIOCFG?======================
AT+WIOCFG?
+WIOCFG: 2,16,0,0,1,0,0
+WIOCFG: 4,3,0,0,1,0,0
+WIOCFG: 6,16,0,0,1,0,0
+WIOCFG: 7,16,0,0,1,0,0
+WIOCFG: 8,4,1,0,1,0,0
+WIOCFG: 13,16,0,0,1,0,0
+WIOCFG: 21,16,0,0,1,0,0
+WIOCFG: 22,16,0,0,1,0,0
+WIOCFG: 23,4,1,1,0,0,0
+WIOCFG: 24,16,0,0,1,0,0
+WIOCFG: 25,16,0,0,1,0,0
+WIOCFG: 28,16,0,0,1,0,0
+WIOCFG: 29,16,0,0,1,0,0
+WIOCFG: 30,16,0,0,1,0,0
+WIOCFG: 31,16,0,0,1,0,0
+WIOCFG: 32,16,0,0,1,0,0
+WIOCFG: 33,16,0,0,1,0,0
+WIOCFG: 35,16,0,0,1,0,0
+WIOCFG: 42,16,0,0,1,0,0

OK

=================ls /sys/class/gpio================
root@fx30s:~# ls /sys/class/gpio
export gpio7 gpioFX30S-POWER_LED_GRN
gpio2 gpioFX30-DIGITAL_INPUT1_N gpioFX30S-POWER_LED_MUX
gpio21 gpioFX30-DIGITAL_INPUT2_N gpioFX30S-POWER_LED_RED_N
gpio22 gpioFX30-DIGITAL_INPUT3_N gpioFX30S-RS485_IN_EN_N
gpio24 gpioFX30-GPIO29 gpioFX30S-RS485_OUT_EN
gpio25 gpioFX30-HUB_ENABLE gpioFX30S-RS485_POL_N
gpio29 gpioFX30-IOT_DETECT gpioFX30S-SIGNAL_LED_GRN
gpio32 gpioFX30-ON_OFF_MON_N gpioFX30S-SIGNAL_LED_RED
gpio36 gpioFX30-PB_INPUT gpioFX30S-ULPM_WAKE1_36
gpio38 gpioFX30-ULPM_WAKE1_36 gpioFX30S-ULPM_WAKE1_38
gpio43 gpioFX30-ULPM_WAKE1_38 gpioFX30S-USER_LED_GRN
gpio44 gpioFX30S-DIGITAL_INPUT1_N gpioFX30S-USER_LED_RED
gpio45 gpioFX30S-DIGITAL_INPUT2_N gpiochip0
gpio46 gpioFX30S-DIGITAL_INPUT3_N gpiochip1
gpio47 gpioFX30S-DIGITAL_OUTPUT3 gpiochip1012
gpio48 gpioFX30S-GPIO29 gpiochip1018
gpio49 gpioFX30S-GPS_BIAS_EN gpiochip200
gpio50 gpioFX30S-HUB_ENABLE gpiochip796
gpio51 gpioFX30S-IOT_DETECT gpiochip828
gpio52 gpioFX30S-IO_PULLUP_EN1 gpiochip860
gpio53 gpioFX30S-IO_PULLUP_EN2 gpiochip892
gpio54 gpioFX30S-IO_PULLUP_EN3 gpiochip924
gpio56 gpioFX30S-NETWORK_LED_GRN gpiochip956
gpio57 gpioFX30S-NETWORK_LED_RED gpiochip988
gpio58 gpioFX30S-ON_OFF_MON_N unexport
gpio60 gpioFX30S-PB_INPUT v2
gpio61 gpioFX30S-POWER_HOLD

================= ls /sys/class/gpio/v2=============
root@fx30s:~# ls /sys/class/gpio/v2
root@fx30s:~# ls /sys/class/gpio/v2
alias_define gpio1003 gpio51 gpio994 gpiochip200
alias_export gpio1005 gpio77 gpio995 gpiochip796
alias_map gpio1006 gpio8 gpio996 gpiochip828
alias_undefine gpio1007 gpio9 gpio997 gpiochip860
alias_unexport gpio11 gpio988 gpio998 gpiochip892
aliases gpio16 gpio989 gpio999 gpiochip924
aliases_exported gpio200 gpio990 gpiochip0 gpiochip956
export gpio202 gpio991 gpiochip1 gpiochip988
gpio1001 gpio38 gpio992 gpiochip1012 unexport
gpio1002 gpio46 gpio993 gpiochip1018

this is what i see from the 2 firmware flashed onto the device

you should download this one: swi-fx30-catm_3.0.0

Ok, im gonna give it a try but may i ask why? whats the difference between “SDK for WP77” packages and “SDK for FX30-CATM” i cant understand?

They use different source code.
So for FX30, you should use the FX30 yocto source.

Thank you for you help , I’ve successfully built the framework with r15 and all the apps seems to work fine all the gpios are present.

Now i have some problem with the UART , changed the serial name in my app
from /dev/ttyHSL0 to /dev/ttyMSM0, using le_tty_serial , instead of opening /dev/ttyMSM0 directly with c functions.

Here’s my code:

fd = le_tty_Open(“/dev/ttyMSM0”, O_RDWR | O_NOCTTY | O_SYNC);
le_tty_SetBaudRate(fd, LE_TTY_SPEED_1152000);
le_tty_SetFlowControl(fd,LE_TTY_FLOW_CONTROL_HARDWARE);
le_tty_SetFraming(fd,‘N’,8,1);
le_tty_SetRaw(fd,0,0);

defined in ADEF rw permissions,

set from ssh uartMode to linux application
root@fx30s:~# uartMode set 1 app
diag: Unable to get remote processor info. Continuing with just the local processor
UART1 will be set to ‘app’ after the next reboot.

rebooted , but the serial is not reading anything from the device connected to it.

what does “diag: Unable to get remote processor info. Continuing with just the local processor” mean?

you need to first set

AT!MAPUART=17,1
AT!RESET

And then in your application, you can use /dev/ttyHSL0 in the code and .cdef file.

what does this command do? do you have any doc with full list of AT commands? i cant find it anywhere

you can see the AT command user guide

https://source.sierrawireless.com/resources/airprime/software/airprime_wpx5xx_wp76xx_wp77xx_at_command_reference/#sthash.5POHwpxQ.dpbs

thanks for the user manual.

The serial still does not work aftet the AT command , using HSL0 made the app not start , with MSM0 the app starts and its listining on serial.
I menaged with tera term to send some random data to the serial and see them logged by the app , but if i change the flow controler to HARDWARE CTS/RTS i cant see anything, like its not reading anything

did you use flow control on tera tem?

using HSL0 made the app not start–> you need to check the logread to know why

yes , here my conf
Immagine 2022-01-11 104543

now im trying with the old code , configuring the serial by linux c functions instead of legato le_tty api , and this is my configuration:

struct termios tty;
        if (tcgetattr (fd, &tty) != 0)
        {
                //LE_ERROR ("error %d from tcgetattr", errno);
        	LE_INFO("error on get attributes serial");
                return -1;
        }

        cfsetospeed (&tty, speed);
        cfsetispeed (&tty, speed);

        tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS8;     // 8-bit chars
        // disable IGNBRK for mismatched speed tests; otherwise receive break
        // as \000 chars
        tty.c_iflag &= ~IGNBRK;         // disable break processing
        tty.c_lflag = 0;                // no signaling chars, no echo,
                                        // no canonical processing
        tty.c_oflag = 0;                // no remapping, no delays
        tty.c_cc[VMIN]  = 0;            // read doesn't block
        tty.c_cc[VTIME] = 1;            // 0.5 seconds read timeout

        tty.c_iflag &= ~(IXON | IXOFF | IXANY); // shut off xon/xoff ctrl

        tty.c_cflag |= (CLOCAL | CREAD);// ignore modem controls,
                                        // enable reading
        tty.c_cflag &= ~(PARENB | PARODD);      // shut off parity
        tty.c_cflag |= parity;
        tty.c_cflag &= ~CSTOPB;
        tty.c_cflag |= CRTSCTS;

        if (tcsetattr (fd, TCSANOW, &tty) != 0)
        {
                //error_message ("error %d from tcsetattr", errno);
        	LE_INFO("error on setting attributes serial");
                return -1;
        }
        return 0;
void set_blocking (int fd, int should_block)
{
        struct termios tty;
        memset (&tty, 0, sizeof tty);
        if (tcgetattr (fd, &tty) != 0)
        {
                //error_message ("error %d from tggetattr", errno);
        	LE_INFO("error get attributes blocking");
                return;
        }

        tty.c_cc[VMIN]  = should_block ? 1 : 0;
        tty.c_cc[VTIME] = 1;            // 0.5 seconds read timeout

        if (tcsetattr (fd, TCSANOW, &tty) != 0){
                //error_message ("error %d setting term attributes", errno);

        	LE_INFO("error set attributes blocking");
        }
}



LE_INFO("----- INIT SERIAL COM -----");
    fd = open("/dev/ttyMSM0", O_RDWR | O_NOCTTY | O_SYNC);
    if (fd == -1)
    {
     
    	LE_ERROR("open_port: Unable to open /dev/ttyMSM0 - ");
    }
    else{
    	set_interface_attribs (fd, B115200, 0);
    	set_blocking (fd, 0);                // set no blocking

log read says

There was an error. Application ‘vei_master_app’ could not be started.
Check the system log for error messages.

I remember you that i am using R15 , which in the linux 4.14 kernel migration doc says that

UART tty console.
/dev/ttyHSLn in Kernel3.18 is renamed to /dev/ttyMSMn in Kernel4.14.
/dev/ttyHSLn hardcoding in the code, if any, needs to be replaced with /dev/ttyMSMn.
Example:

components/portService/portDaemon/ConfigurationFile.json

/dev/ttyMSM0 corresponds to UART1 and /dev/ttyMSM1 corresponds to UART2.

You can use my code in FX30 FW R14.1 after setting
AT!MAPUART=15,1
AT!RESET

UART_Test1.rar (3.0 KB)

I’ve just compiled a new firmware on r14.1.1 and with my code the serial is working
I guess that in the R15 release there are some major differences in the UART management ?
do you have any info about?

also thanks for the sample code

Maybe there is still bug in your r15 as it is not yet official release

https://source.sierrawireless.com/resources/airlink/software_downloads/fx30-firmware/fx30-firmware-catm/