WP76xx not waking up from SPM on GPIO

Hi,
We are trying to wake up the module via GPIO38, but it’s not waking up from suspend.

The GPIO is configured as shown below:

root@swi-mdm9x28-wp:~# cat /sys/class/gpio/gpio38/value
0
root@swi-mdm9x28-wp:~# cat /sys/class/gpio/gpio38/direction
in
root@swi-mdm9x28-wp:~# cat /sys/class/gpio/gpio38/pull
down
root@swi-mdm9x28-wp:~# cat /sys/class/gpio/gpio38/edge
rising
root@swi-mdm9x28-wp:~# cat /sys/class/gpio/gpio38/active_low
0

Afterward the module it put to sleep with:

le_pm_Relax(_wakeSrc);

If we now apply a rising edge to the GPIO38, the module somehow recognizes the event, but doesn’t wake up:

[ 1353.120378] swimcu_gpio_irq_event_handle: Re-enabled irq 1 type 9 for MCU GPIO 2
Jan 11 13:40:24 swi-mdm9x28-wp user.info kernel: [ 1353.098914] gpio_check_and_wake: wake-n_gpio26 STATE=WAKEUP
Jan 11 13:40:24 swi-mdm9x28-wp user.err kernel: [ 1353.120378] swimcu_gpio_irq_event_handle: Re-enabled irq 1 type 9 for MCU GPIO 2
Jan 11 13:40:24 swi-mdm9x28-wp user.info kernel: [ 1353.126875] gpio_check_and_wake: wake-n_gpio26 STATE=SLEEP

After waking it up by plugging in USB, the GPIO shows the correct state:

root@swi-mdm9x28-wp:~# cat /sys/class/gpio/gpio38/value
1

We also tried to debug in several ways e.g. AT!POWERMODE?, but that always returns an error:

AT!POWERMODE?

ERROR
AT!POWERWAKE?

ERROR

This was already working on a different hardware. When we got the new hardware, we needed to adjust yocto to be able to flash like it’s written here. We aren’t sure if this somehow relevant.

How can we debug this further?

Thanks, Simon

Do you happen to official release firmware?
Or only happen to your image?

I don’t see problem with AT!POWERMODE on my module:

ati3
Manufacturer: Sierra Wireless, Incorporated
Model: WP7605
Revision: SWI9X07Y_02.37.03.00 73df45 jenkins 2020/04/08 10:59:14
IMEI: 353532101712345
IMEI SV: 14
FSN: 76238530612345
+GCAP: +CGSM

OK
at!powermode?
!POWERMODE: No request, status=9-PSM disabled

OK

Unfortunately without the modification for the COMPAT_BYTE we aren’t able to flash the offical release:

B -  31520530 - Flash device name MT29F4G08ABBFA3W
B -  31523031 - compat_tbl: device name MT29F4G08ABBFA3W compat 0x01
B -  31529253 - Imagetype=0x07 compat_id=0x00 incompatible with Flash!
B -  33736111 - VERSION=9999999_9907152_SWI9X07Y_02.37.03.00_00_GENERIC_002.095_000,SIZE 0x4270fca, IMG_TYPE=0x14,SPKG/FOTA IMG,ERROR=Flash write failed: Packa
ge not compatible (0X86),STATUS=FAIL

or is there a newer version that is compatible? what does the COMPAT_BYTE tell?

ati3 has an older version on our modules:

ati3

Manufacturer: Sierra Wireless, Incorporated
Model: WP7607
Revision: SWI9X07Y_02.18.05.00 000000 jenkins 2018/07/19 17:40:21
IMEI: 359779080852250
IMEI SV:  5
FSN: V3213632471610
+GCAP: +CGSM

This means the modem firmware is out of date, right?

you should download the new FW (all include the correct COMPAT_BYTE) from source.sierrawireless.com

Ahh! ok, that’s pretty new!
We’ll try!

So, there are news. We updated to the latest firmware on the modem and flashed the full generik package to the module:

ati3

Manufacturer: Sierra Wireless, Incorporated
Model: WP7607
Revision: SWI9X07Y_02.37.03.05 52ddef jenkins 2021/12/22 04:24:24
IMEI: 359779080852250
IMEI SV: 16
FSN: V3213632471610
+GCAP: +CGSM

If we now use pmtool bootOn gpio 38 rising and shut it down with pmtool shutdown, we are able to wake it up with a rising edge on the pin:

root@swi-mdm9x28-wp:~# pmtool bootReason gpio 38
Boot source gpio38? Yes

But when entering selective suspend by removing the USB and using le_pm_Relax(_wakeSrc);, it won’t wake up again as described above. The pin event is recognized in the log, but it’s not waking up.

Is there another way to debug this problem?

Have you tried with AT command first

which one? exactly?

We tried to set it up with at!powerwake=2,38,3,1 followed by le_pm_relax(), but that yields the same behaviour.

On the older hardware we didn’t need to do something like that.
We just configured the pin via sysfs and it was waking up without problems.

See if this document helps

We added the programm from the link above and replaced every GPIO number with the right one, but the module is still not waking up via GPIO.

We searched a lot of places and read all the posts here in the forum.

Is there any place we can have a look to debug this further?

did you test original program in “How to use GPIO as wakeup source on WP77xx MangOH Red board.docx” with the GPIO36?

Here is an iterrupt test program on GPIO35 (verified to be working in FW R13.x), you can change it to GPIO38 and see if the interrupt works in your environment first:
GPIO_CF3_Demo.rar (241.7 KB)

So we changed the GPIO_CFG3_DEMO.rar to use GPIO38 but it seems it’s crashing something when it’s started:

INFO | supervisor[7974]/supervisor T=main | proc.c proc_Start() 1363 | Execing 'gpioCf3PinDemo'
INFO | supervisor[7974]/supervisor T=main | resourceLimits.c SetRLimitValue() 301 | Setting resource limit maxCoreDumpFileBytes to value 102400.
INFO | supervisor[7974]/supervisor T=main | resourceLimits.c SetRLimitValue() 301 | Setting resource limit maxFileBytes to value 102400.
INFO | supervisor[7974]/supervisor T=main | resourceLimits.c SetRLimitValue() 301 | Setting resource limit maxLockedMemoryBytes to value 8192.
INFO | supervisor[7974]/supervisor T=main | resourceLimits.c SetRLimitValue() 301 | Setting resource limit maxFileDescriptors to value 256.
INFO | supervisor[7974]/supervisor T=main | resourceLimits.c SetRLimitValue() 301 | Setting resource limit maxMQueueBytes to value 512.
INFO | supervisor[7974]/supervisor T=main | resourceLimits.c SetRLimitValue() 301 | Setting resource limit maxThreads to value 20.
INFO | supervisor[7974]/supervisor T=main | resourceLimits.c SetRLimitValue() 301 | Setting resource limit maxQueuedSignals to value 100.
Exit (root): Disconnect received
INFO | gpioService[7586]/sysfsGpio T=main | gpioSysfsUtils.c gpioSysfs_SessionOpenHandlerFunc() 1176 | Assigning GPIO 38
-WRN- | _UNKNOWN_[7974]/framework T=main | fdMonitor.c le_fdMonitor_Create() 449 | FD Monitor object name 'gpioCf3PinDemo.gpioCf3PinComponent.le_gpioPin38' truncated to 'gpioCf3PinDemo.gpioCf3PinCompon'.
INFO | gpioCf3PinDemo[7974]/gpioCf3PinComponent T=main | gpioCf3Pin.c _gpioCf3PinComponent_COMPONENT_INIT() 135 | This is sample gpioctl Legato CF3 GPIO app by using le_gpio.api
INFO | gpioCf3PinDemo[7974]/gpioCf3PinComponent T=main | gpioCf3Pin.c Pin38GpioSignal() 63 | Pin38 read active: 0
[ 2288.041665] ------------[ cut here ]------------
[ 2288.041733] WARNING: CPU: 0 PID: 7586 at /usr/src/kernel/kernel/irq/manage.c:540 irq_set_irq_wake+0xa8/0xe8()
[ 2288.041749] Unbalanced IRQ 136 wake disable
[ 2288.041762] Modules linked in: spisvc(O) [last unloaded: spisvc]
[ 2288.041802] CPU: 0 PID: 7586 Comm: gpioService Tainted: G        W  O   3.18.140 #1
[ 2288.041859] [<c0014428>] (unwind_backtrace) from [<c00122ac>] (show_stack+0x10/0x14)
[ 2288.041888] [<c00122ac>] (show_stack) from [<c001f4a8>] (warn_slowpath_common+0x60/0x80)
[ 2288.041914] [<c001f4a8>] (warn_slowpath_common) from [<c001f4f4>] (warn_slowpath_fmt+0x2c/0x3c)
[ 2288.041940] [<c001f4f4>] (warn_slowpath_fmt) from [<c0050ee8>] (irq_set_irq_wake+0xa8/0xe8)
[ 2288.041971] [<c0050ee8>] (irq_set_irq_wake) from [<c028055c>] (gpio_setup_irq+0xd8/0x280)
[ 2288.041998] [<c028055c>] (gpio_setup_irq) from [<c0280780>] (gpio_edge_store+0x7c/0x98)
[ 2288.042025] [<c0280780>] (gpio_edge_store) from [<c012a3fc>] (kernfs_fop_write+0x138/0x168)
[ 2288.042054] [<c012a3fc>] (kernfs_fop_write) from [<c00d1f9c>] (vfs_write+0xb8/0x170)
[ 2288.042079] [<c00d1f9c>] (vfs_write) from [<c00d23d0>] (SyS_write+0x3c/0x74)
[ 2288.042103] [<c00d23d0>] (SyS_write) from [<c000e6e0>] (ret_fast_syscall+0x0/0x44)
[ 2288.042119] ---[ end trace 6c2c5e5bbfd2f68a ]---
INFO | gpioCf3PinDemo[7974]/gpioCf3PinComponent T=main | gpioCf3Pin.c PinsReadConfig() 91 | Pin 38 edge sense = both
INFO | gpioCf3PinDemo[7974]/gpioCf3PinComponent T=main | gpioCf3Pin.c PinsReadConfig() 109 | Pin 38 is output = false
INFO | gpioCf3PinDemo[7974]/gpioCf3PinComponent T=main | gpioCf3Pin.c PinsReadConfig() 114 | Pin 38 pull up/down = down

If we toggle the GPIO externally, the callback isn’t called.

This is the adapted code we use:
gpioCf3Pin.c (2.3 KB)

The crash disappears when we comment out setting the edge sense again:

    // Change the edge setting
    // le_gpioPin38_SetEdgeSense(LE_GPIOPIN38_EDGE_BOTH);
    // le_gpioPin38_DisableEdgeSense();
    // le_gpioPin38_SetEdgeSense(LE_GPIOPIN38_EDGE_BOTH);

INFO | gpioService[10589]/sysfsGpio T=main | gpioSysfsUtils.c gpioSysfs_SessionOpenHandlerFunc() 1176 | Assigning GPIO 38
-WRN- | _UNKNOWN_[10946]/framework T=main | fdMonitor.c le_fdMonitor_Create() 449 | FD Monitor object name 'gpioCf3PinDemo.gpioCf3PinComponent.le_gpioPin38' truncated to 'gpioCf3PinDemo.gpioCf3PinCompon'.
INFO | gpioCf3PinDemo[10946]/gpioCf3PinComponent T=main | gpioCf3Pin.c _gpioCf3PinComponent_COMPONENT_INIT() 88 | This is sample gpioctl Legato CF3 GPIO app by using le_gpio.api
INFO | gpioCf3PinDemo[10946]/gpioCf3PinComponent T=main | gpioCf3Pin.c Pin38GpioSignal() 34 | Pin38 read active: 0
INFO | gpioCf3PinDemo[10946]/gpioCf3PinComponent T=main | gpioCf3Pin.c PinsReadConfig() 57 | Pin 38 edge sense = rising
INFO | gpioCf3PinDemo[10946]/gpioCf3PinComponent T=main | gpioCf3Pin.c PinsReadConfig() 68 | Pin 38 is output = false
INFO | gpioCf3PinDemo[10946]/gpioCf3PinComponent T=main | gpioCf3Pin.c PinsReadConfig() 73 | Pin 38 pull up/down = down

But there is still not change detected

You can do this step by step: first try original interrupt test program on GPIO35 (verified to be working in FW R13.x)

GPIO35 is working as it should. It’s triggering the interrupt.

Why are GPIO38/36 not forwarded by the system from the ULPM-MCU to the module?

This is the ouput of at+wiocfg?:

+WIOCFG: 2,16,0,0,1,0,0
+WIOCFG: 4,3,0,0,1,0,0
+WIOCFG: 6,8,0,0,1,0,0
+WIOCFG: 7,16,0,0,1,0,0
+WIOCFG: 8,16,0,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,16,0,0,1,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

On another module we can see messages from the interrupt on GPIO38, but it’s still not waking up:

Jan 17 13:10:54 swi-mdm9x28-wp user.info kernel: [  150.791732] msm_mpm_interrupts_detectable(): gpio preventing system sleep modes during suspend
Jan 17 13:10:54 swi-mdm9x28-wp user.info kernel: [  150.791732] 	hwirq: 47
Jan 17 13:10:54 swi-mdm9x28-wp user.info kernel: [  150.791732] CPU0:msm_cpu_pm_enter_sleep mode:3 during suspend
Jan 17 13:10:54 swi-mdm9x28-wp user.info kernel: [  150.791732] resume cycles:       3811765966
Jan 17 13:10:54 swi-mdm9x28-wp user.warn kernel: [  150.791935] irq 50, desc: ced9ad80, depth: 0, count: 0, unhandled: 0
Jan 17 13:10:54 swi-mdm9x28-wp user.warn kernel: [  150.791981] ->handle_irq():  c027b6b4, msm_gpio_irq_handler+0x0/0x150
Jan 17 13:10:54 swi-mdm9x28-wp user.warn kernel: [  150.792016] ->irq_data.chip(): c0ec70e8, gic_chip+0x0/0x74
Jan 17 13:10:54 swi-mdm9x28-wp user.warn kernel: [  150.792029] ->action():   (null)
Jan 17 13:10:54 swi-mdm9x28-wp user.warn kernel: [  150.792041]    IRQ_NOPROBE set
Jan 17 13:10:54 swi-mdm9x28-wp user.warn kernel: [  150.792053]  IRQ_NOREQUEST set
Jan 17 13:10:54 swi-mdm9x28-wp user.warn kernel: [  150.792065]   IRQ_NOTHREAD set
Jan 17 13:10:54 swi-mdm9x28-wp user.info kernel: [  150.793579] PM: noirq resume of devices complete after 1.365 msecs
Jan 17 13:10:54 swi-mdm9x28-wp user.info kernel: [  150.793886] gpio_check_and_wake: wake-n_gpio26 STATE=WAKEUP
Jan 17 13:10:54 swi-mdm9x28-wp user.info kernel: [  150.793978] i2c-msm-v2 78b8000.i2c: Runtime PM-callback was not invoked.
Jan 17 13:10:54 swi-mdm9x28-wp user.info kernel: [  150.796685] PM: early resume of devices complete after 1.826 msecs
Jan 17 13:10:54 swi-mdm9x28-wp user.info kernel: [  150.800318] msm_hsic_host 7c00000.hsic_host: HSIC-USB exited from low power mode
Jan 17 13:10:54 swi-mdm9x28-wp user.err kernel: [  150.808357] swimcu_gpio_irq_event_handle: Re-enabled irq 1 type 9 for MCU GPIO 2 
Jan 17 13:10:54 swi-mdm9x28-wp user.info kernel: [  150.808399] gpio_check_and_wake: wake-n_gpio26 STATE=SLEEP

On my module they are completely missing.

Do you see mcu version in ati8?

Can gpio35 work as wake up pin in your module?

No, we can’t use GPIO35, because we want to have the ability to choose between selective suspend and ULPM. Also this is the last revision of our hardware.

ati8

Legato Ver: 19.11.6_53f7514cfa7d446dcd28d6def458786a
Yocto Ver:  SWI9X07Y_02.37.07.00 2023-01-12_12:02:18
OS Ver: Linux version 3.18.140 (oe-user@oe-host) (gcc version 7.3.0 (GCC) ) #1 PREEMPT Thu Jan 12 11:56:38 UTC 2023
LK Ver: SWI9X07Y_02.37.10.02
RootFS Ver: SWI9X07Y_02.37.07.00 2023-01-12_12:02:18
UserFS Ver: unknown
MCU Ver: 002.015

Which software part is responsible to forward the IRQs to the system?

Is this the problematic module or the working one

Testing gpio35 is just to make sure the legato code is working fine

Both have the same output except one line:
The problematic one:

LK Ver: SWI9X07Y_02.37.10.02

The other one:

LK Ver: SWI9X07Y_02.18.07.01

What is LK? We flashed the same software package with yocto, legato and modem firmware.

I’ll try GPIO35 on both modules for wakeup again.