none
Suspend and resume from a button RRS feed

  • Question

  • Hi all,

    i need an explanation on suspend and resume events.

    WinCE600R3, iMX51.

    The board has a power on/off button connected to a GPIO: i modified the default driver for PwrButton to detect the suspend request and, when it meets the requirement (no longer than 3 secs), it fires the suspend mode calling the SetSystemPowerState( NULL, POWER_STATE_SUSPEND, POWER_FORCE).

    Here i have two problems:

    1. the suspend process starts but it doesn't run the PowerDown calls of the drivers and he sequence is stopped

    2. the documentation states that 'this function [SetSystemPowerState] returns only after system operation resumes and related PBT_RESUME...' but, if the driver is blocked inn this SetSystemPowerState(), how can it detect the next press to resume the system??

    Thanks!


    SteMMo

    Friday, July 27, 2012 10:19 AM

All replies

  • 1. Enable debug messages for PM so you can see which driver crashes and fix that

    2. Interrupts are still enabled. On the iMX51 you have to set the button interrupt up to be able to wake the system.


    Good luck,

    Michel Verhagen, eMVP
    Check out my blog: http://guruce.com/blog

    GuruCE
    Microsoft Embedded Partner
    http://guruce.com
    Consultancy, training and development services.

    Monday, July 30, 2012 5:30 AM
    Moderator
  • 1. Do you mean to add the "PM" DebugZone to 0xFF.FFFF ? Your guess is a driver crash, is it?

    2. Do I need to call

    DDKGpioClearIntrPin(BSP_PWRBTN_GPIO_PORT, BSP_PWRBTN_GPIO_PIN);
    InterruptDone(g_dwPwrBtnSysIntr);

    just before the SystremPowerState() call?


    SteMMo

    Monday, July 30, 2012 9:57 AM
  • 1. You don't need to set all PM zones, just those dealing with suspend/resume

    2. You need to call IOCTL_HAL_ENABLE_WAKE for the power button SYSINTR as well.


    Good luck,

    Michel Verhagen, eMVP
    Check out my blog: http://guruce.com/blog

    GuruCE
    Microsoft Embedded Partner
    http://guruce.com
    Consultancy, training and development services.



    Monday, July 30, 2012 10:12 AM
    Moderator
  • This is the last log with both 1. and 2. done:

    The value of ControlStatus is = 8880h
    The value of ControlStatus is = 880h
    The value of ControlStatus is = 880h
    The value of ControlStatus is = 880h
    The value of ControlStatus is = 880h
    .. press button for a while ..
    --> PwrBtn Evnt pwrstate=12010000
    SM PmicIsrThreadProc Evnt
    PMIC_INT:  stat0 = 0x80001, msk0 = 0xffffbb
    PMIC_INT:  stat1 = 0x9, msk1 = 0xffffe1
    PMIC_INT:  Active Interrupts 0 = 0x0
    PMIC_INT:  Active Interrupts 1 = 0x8
    pending interrupts 0 =0x0, interrupt 1 =0x8 35
    --> SetEvent 35
    SM BSPPmicClearIrq
    SM end of wait --> 0
    SM PmicButtonServThread PWRBTN1
    SM PmicButtonServThread waiting button ...
    > msec=938
    > PwrBtn suspend ..
    +BSPBacklightEnable
    -BSPBacklightEnable
    +BSPBacklightSetIntensity 0
     BSPBacklightSetIntensity 10
    -BSPBacklightSetIntensity
    SM PmicIsrThreadProc Evnt
    PMIC_INT:  stat0 = 0x80001, msk0 = 0xffffbf
    PMIC_INT:  stat1 = 0x9, msk1 = 0xffffe1
    PMIC_INT:  Active Interrupts 0 = 0x0
    PMIC_INT:  Active Interrupts 1 = 0x8
    pending interrupts 0 =0x0, interrupt 1 =0x8 35
    --> SetEvent 35
    SM BSPPmicClearIrq
    DPDisable: Disabling DP!
    DMFCDisable: Disabling DMFC!
    LVDSDisablePanel()
    UIO:: Exiting ndisuioWaitForPendingIO with [0] pending TX.
    Ndisuio: PnPEvent: Open D4A941A0, SetPower to 4
    .. display powered off ..
    .. press button ..
    SM PmicIsrThreadProc Evnt
    PMIC_INT:  stat0 = 0x80001, msk0 = 0xffffbf
    PMIC_INT:  stat1 = 0x9, msk1 = 0xffffe1
    PMIC_INT:  Active Interrupts 0 = 0x0
    PMIC_INT:  Active Interrupts 1 = 0x8
    pending interrupts 0 =0x0, interrupt 1 =0x8 35
    --> SetEvent 35
    SM BSPPmicClearIrq
    SM PmicIsrThreadProc Evnt
    PMIC_INT:  stat0 = 0x80001, msk0 = 0xffffbf
    PMIC_INT:  stat1 = 0x9, msk1 = 0xffffe1
    PMIC_INT:  Active Interrupts 0 = 0x0
    PMIC_INT:  Active Interrupts 1 = 0x8
    pending interrupts 0 =0x0, interrupt 1 =0x8 35
    --> SetEvent 35
    SM BSPPmicClearIrq

    The current code is:

     // Check if button press indicates user wants to suspend the 
     // system
     if (msec >= BSP_PWRBTN_DEBOUNCE_SUSPEND_MSEC)
     {
    	DDKGpioClearIntrPin(BSP_PWRBTN_GPIO_PORT, BSP_PWRBTN_GPIO_PIN);
    	InterruptDone(g_dwPwrBtnSysIntr);
    	// Enable wakeup
              KernelIoControl(IOCTL_HAL_ENABLE_WAKE, &g_dwPwrBtnSysIntr, sizeof(g_dwPwrBtnSysIntr), NULL, 0, NULL);
    				
    	RETAILMSG( 1, (L"> PwrBtn suspend ..\r\n"));
              SetSystemPowerState(NULL, POWER_STATE_SUSPEND, POWER_FORCE);
    	// only after PBT_RESUME
    	RETAILMSG( 1, (L"> Out of PwrBtn suspend !!\r\n"));
     }


    SteMMo

    Monday, July 30, 2012 12:35 PM
  • Did you set a breakpoint on the line that outputs "SM BSPPmicClearIrq" and did you step through after that? I'm still not seeing any PM debug output... Are you sure you enabled the debugzones of PM and you are running a debug build?

    Good luck,

    Michel Verhagen, eMVP
    Check out my blog: http://guruce.com/blog

    GuruCE
    Microsoft Embedded Partner
    http://guruce.com
    Consultancy, training and development services.

    Tuesday, July 31, 2012 12:36 AM
    Moderator
  • I compiled a debug build and i defined into the platform.reg file the definitions :)

    [HKEY_LOCAL_MACHINE\DebugZones]

    "FILESYS"=dword:FFFFF

    "FSDMGR"=dword:FFFFF

    "SDBUS"=dword:FFFFF

    "SDMEMORY"=dword:FFFFF

    "ESDHC"=dword:FFFFF

    "PM"=dword:FFFFF

    "PMI"=dword:FFFFF

    "PMIC"=dword:FFF


    SteMMo

    Tuesday, July 31, 2012 4:10 PM
  • And still no PM debug output? That is very odd... Did you check reginit.ini to see if those settings are actually in and listed as last?

    Good luck,

    Michel Verhagen, eMVP
    Check out my blog: http://guruce.com/blog

    GuruCE
    Microsoft Embedded Partner
    http://guruce.com
    Consultancy, training and development services.

    Tuesday, July 31, 2012 10:05 PM
    Moderator
  • Yes, they are listed in reginit.ini.

    I also checked on the nk.bin, registry sectionk...

    To insert a breakpoint, do i need a RAM image, instead of a SD image, downloaded from the PB?


    SteMMo

    Wednesday, August 1, 2012 7:45 AM
  • The resume is strange too.

    Only the interrupt tied with the 13892 is fired (twice??), and the power button interrupt only once.

    .. press button .. .. button driver interrupt event fired .. > PwrBtnThread Evnt - pwrstate=12010000

    . 13892 interrupt event fired .. SM PmicIsrThreadProc Evnt PMIC_INT: stat0 = 0x80001, msk0 = 0xffffbb PMIC_INT: stat1 = 0x9, msk1 = 0xffffe1 PMIC_INT: Active Interrupts 0 = 0x0 PMIC_INT: Active Interrupts 1 = 0x8 --> SetEvent 35 SM BSPPmicClearIrq SM PmicButtonServThread end of wait --> 0 SM PmicButtonServThread PWRBTN1 SM PmicButtonServThread waiting button ... .. now power button thread is active and measures the press duration .. > PwrBtnThread msec=1150 > PwrBtnThread suspend .. .. Suspend starts !! .. +BSPBacklightEnable -BSPBacklightEnable +BSPBacklightSetIntensity 0 BSPBacklightSetIntensity 10 -BSPBacklightSetIntensity .. other pmic event ?? .. (button release??) .. SM PmicIsrThreadProc Evnt PMIC_INT: stat0 = 0x80001, msk0 = 0xffffbf PMIC_INT: stat1 = 0x9, msk1 = 0xffffe1 PMIC_INT: Active Interrupts 0 = 0x0 PMIC_INT: Active Interrupts 1 = 0x8 --> SetEvent 35 SM BSPPmicClearIrq .. even if the SetEvent, the 'PmicButtonServThread end of wait' not fired ?? .. .. suspend goes on ... DPDisable: Disabling DP! DMFCDisable: Disabling DMFC! LVDSDisablePanel() UIO:: Exiting ndisuioWaitForPendingIO with [0] pending TX. Ndisuio: PnPEvent: Open D4A94DA0, SetPower to 4 .. sleep (suspend not complete!) ..

    .. .. press button to resume ..

    .. pmin envet is fired .. SM PmicIsrThreadProc Evnt PMIC_INT: stat0 = 0x80001, msk0 = 0xffffbf PMIC_INT: stat1 = 0x9, msk1 = 0xffffe1 PMIC_INT: Active Interrupts 0 = 0x0 PMIC_INT: Active Interrupts 1 = 0x8 --> SetEvent 35 SM BSPPmicClearIrq SM PmicIsrThreadProc Evnt PMIC_INT: stat0 = 0x80001, msk0 = 0xffffbf PMIC_INT: stat1 = 0x9, msk1 = 0xffffe1 PMIC_INT: Active Interrupts 0 = 0x0 PMIC_INT: Active Interrupts 1 = 0x8 --> SetEvent 35 SM BSPPmicClearIrq .. again two signalled events but no 'end of wait in PmicButtonServThread' .. .. again no power button wakeup event ..



    SteMMo

    Wednesday, August 1, 2012 10:09 AM
  • If I press the button for a short time, just to avoid to fire the suspend, all the events stay alive:

    The value of ControlStatus is = 8880h
    The value of ControlStatus is = 880h
    The value of ControlStatus is = 880h
    The value of ControlStatus is = 880h
    -- Short press --
    > PwrBtn Evnt - pwrstate=12010000
    SM PmicIsrThreadProc Evnt
    PMIC_INT:  stat0 = 0x80001, msk0 = 0xffffbb
    PMIC_INT:  stat1 = 0x9, msk1 = 0xffffe1
    PMIC_INT:  Active Interrupts 0 = 0x0
    PMIC_INT:  Active Interrupts 1 = 0x8
    --> SetEvent 35
    SM BSPPmicClearIrq
    SM end of wait --> 0
    SM PmicButtonServThread PWRBTN1
    SM PmicButtonServThread waiting button ...
    > msec=80
    SM PmicIsrThreadProc Evnt
    PMIC_INT:  stat0 = 0x80001, msk0 = 0xffffbb
    PMIC_INT:  stat1 = 0x9, msk1 = 0xffffe1
    PMIC_INT:  Active Interrupts 0 = 0x0
    PMIC_INT:  Active Interrupts 1 = 0x8
    --> SetEvent 35
    SM BSPPmicClearIrq
    SM end of wait --> 0
    SM PmicButtonServThread PWRBTN1
    SM PmicButtonServThread waiting button ...
    > PwrBtnThread 1 >2>3
    -- Again short press --
    > PwrBtn Evnt - pwrstate=12010000
    SM PmicIsrThreadProc Evnt
    PMIC_INT:  stat0 = 0x80001, msk0 = 0xffffbb
    PMIC_INT:  stat1 = 0x9, msk1 = 0xffffe1
    PMIC_INT:  Active Interrupts 0 = 0x0
    PMIC_INT:  Active Interrupts 1 = 0x8
    --> SetEvent 35
    SM BSPPmicClearIrq
    SM end of wait --> 0
    SM PmicButtonServThread PWRBTN1
    SM PmicButtonServThread waiting button ...
    > msec=69
    SM PmicIsrThreadProc Evnt
    PMIC_INT:  stat0 = 0x80001, msk0 = 0xffffbb
    PMIC_INT:  stat1 = 0x9, msk1 = 0xffffe1
    PMIC_INT:  Active Interrupts 0 = 0x0
    PMIC_INT:  Active Interrupts 1 = 0x8
    --> SetEvent 35
    SM BSPPmicClearIrq
    SM end of wait --> 0
    SM PmicButtonServThread PWRBTN1
    SM PmicButtonServThread waiting button ...
    > PwrBtnThread 1 >2>3
    The value of ControlStatus is = 880h
    The value of ControlStatus is = 8880h
    The value of ControlStatus is = 880h
    My guess is the

    SetSystemPowerState(NULL, POWER_STATE_SUSPEND, POWER_FORCE);

    call inside the PowerBtnThread. It seems that the thread is frozen inside it.

    Is it possibile to call the function inside a thread that handles an event/interrupt ?



    SteMMo


    • Edited by SteMMo Wednesday, August 1, 2012 10:52 AM
    Wednesday, August 1, 2012 10:51 AM