This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

processor not waking up on GPIO

When low power mode is configured to wake up on ignition HIGH or LOW, and the router goes to sleep using standby mode of TI AM335x, sometimes(after 2 consecutive sleep-wake ups), the ignition trigger detection does not happen and so the router cannot be woken up.

When this happens, Ethernet interface does not come up. At this point if we reboot, then things are restored properly.

Following logic is used to arm the processor for detecting ignition trigger,before going to standby mode --

wakeonignpval=`rdb_get power.profile.$1.wakeonignpinval`
echo 1 > /debugfs/omap_mux/board/suspend_io_pad_conf/enable_suspend_io_pad_conf
if [ "$wakeonignpval" = "on" ]; then
echo gpio0_7=0x27,falling > /debugfs/omap_mux/board/standby_gpio_pad_conf
else
echo gpio0_7=0x27,rising > /debugfs/omap_mux/board/standby_gpio_pad_conf
fi


# go to sleep
echo -n standby > /sys/power/state

Can you please help me identify the root cause of the above issue and how to fix it?

  • Hi,

    I will forward this to the SW team. Please post the Linux version you use.
  • Hello Sourav,

    When the router cannot be woken up, what is the content of the /debugfs/omap_mux/board/standby_gpio_pad_conf file? Is it possible to check this. Could you also put a 2 sec. sleep after the wakeonignpval=`rdb_get power.profile.$1.wakeonignpinval` since the rdb_get command might need more time to get the feedback. Also why do you need 2 different wake up ignitions on rising and on falling edge?

    Best regards,
    Kemal

  • Hi,

    cat /debugfs/omap_mux/board/standby_gpio_pad_conf
    ecap0_in_pwm0_out.gpio0_7 (0x44e10964 = 0x27), trigger = rising

    I have dumped this just before going to sleep and the router can't be woken up.

    2 different wake up ignitions on rising and on falling is required for us as  --

    Wake when ignition pin goes HIGH or LOW can be configured from the UI.

    RDB get is not an issue here as it has been tested and is getting used in all our products. I am attaching the script which runs to put the router in standby(sleep) molde --

    #!/bin/sh
    #

    log() {
    logger -t "powersavescript" -- $@
    }

    log "start"

    . /etc/variant.sh

    #rdb_set timer_period.input 0
    #rdb_set power.profile.1.trigger 0
    #rdb_set power.profile.2.trigger 0
    #rdb_set power.profile.3.trigger 0
    #rdb_set power.profile.4.trigger 0
    #rdb_set power.profile.5.trigger 0
    #rdb_set power.profile.6.trigger 0
    #/usr/sbin/sys -u 1
    #/usr/sbin/sys -m 1
    #/usr/sbin/sys -w 1

    # ignition detection for wakeup
    # if [[ "$ignition" = "1" -a "$wonignpval" = "off" -o "$ignition" = "0" -a "$wonignpval" = "on" ]]; then
    # log "ignition detected for wakeup"

    # fi

    ignition=`rdb_get system.powersave.ignition`
    sleeponignpval=`rdb_get power.profile.$1.sleeponignpinval`
    isSleepAtTimerExpired=`rdb_get power.profile.$1.sleepAtTimerExpired`
    isSleepAfterTimerExpired=`rdb_get power.profile.$1.sleepAfterTimerExpired`
    isFeedback=`rdb_get power.profile.$1.feedback`
    wakeonignpval=`rdb_get power.profile.$1.wakeonignpinval`
    sleepmode=`rdb_get power.profile.$1.sleepmode`
    wakemode=`rdb_get power.profile.$1.wakemode`

    # determining which timer expired
    if [ "$isFeedback" = "0" ]; then

    log "Sleep At Timer Expired"
    else
    log "Sleep After Timer Expired or Awake after ignition Timer Expired"
    fi

    # getting current date time
    SECSNOW=`date +%s`
    alrmdate=`date +"%Y-%m-%d"`


    if [ "$wakemode" = "3" ]; then
    # calculating when wakeup will happen
    wakehrs=`rdb_get power.profile.$1.wakeupat | cut -c1-2`
    wakemins=`rdb_get power.profile.$1.wakeupat | cut -c3-4`
    WAKESECS=`date --date "$alrmdate $wakehrs:$wakemins:00" +%s`
    # echo +`rdb_get power.profile.$1.wakeupafter` > /sys/class/rtc/rtc0/wakealarm
    echo 0 > /sys/class/rtc/rtc0/wakealarm
    # echo $SECS > /sys/class/rtc/rtc0/wakealarm

    # setting wakeup alarm for the processor
    wakeatsecs=`expr $WAKESECS - $SECSNOW`
    if [ "$wakeatsecs" -lt 0 ]; then
    echo +`expr $WAKESECS + 86400 - $SECSNOW` > /sys/class/rtc/rtc0/wakealarm
    else
    echo +`expr $WAKESECS - $SECSNOW` > /sys/class/rtc/rtc0/wakealarm
    fi
    elif [ "$wakemode" = "2" ]; then
    # kill gpiomon
    /etc/init.d/rc.d/powersave stop

    echo 1 > /debugfs/omap_mux/board/suspend_io_pad_conf/enable_suspend_io_pad_conf
    if [ "$wakeonignpval" = "on" ]; then
    echo gpio0_7=0x27,falling > /debugfs/omap_mux/board/standby_gpio_pad_conf
    else
    echo gpio0_7=0x27,rising > /debugfs/omap_mux/board/standby_gpio_pad_conf
    fi
    fi

    pre_standby () {
    if [ "$sleepmode" = "4" ]; then
    # kill gpiomon
    /etc/init.d/rc.d/powersave stop
    fi

    # turning off the 3G/4G module
    if [ "$V_BUILTIN_UART" != "y" ]; then
    case "$V_QMI_PROTO" in
    linux)
    modprobe -r qmi_wwan 2>/dev/null
    ;;
    *)
    modprobe -r GobiNet GobiSerial 2>/dev/null
    ;;
    esac
    fi
    sys -m 0

    # turning off WIFI
    if [ "$V_WIFI" = "backports" ]; then
    sys -w 0
    /etc/init.d/rc.d/wifi stop
    fi

    # turning off LAN
    ifconfig eth0 down

    # With regard to ti_tscadc driver, wakeup option is enabled by default. Need to be disabled to avoid unexpected "wakeup".
    echo disabled > /sys/devices/platform/omap/ti_tscadc/power/wakeup

    sleep 5
    }

    post_standby () {

    echo enabled > /sys/devices/platform/omap/ti_tscadc/power/wakeup

    if [ "$sleepmode" = "4" -o "$wakemode" = "2" ]; then
    /etc/init.d/rc.d/powersave restart
    fi

    # trigger powersave.template
    rdb_set system.powersave.ignition

    # turning on WIFI
    if [ "$V_WIFI" = "backports" ]; then
    /etc/init.d/rc.d/wifi stop
    /etc/init.d/rc.d/wifi start
    sys -w 1
    sleep 1

    if [ "`rdb_get wlan.0.radio`" = "1" ]; then
    rdb_set wlan.0.radio 1
    fi
    fi

    # turning on the 3G/4G module
    if [ "$V_BUILTIN_UART" != "y" ]; then
    case "$V_QMI_PROTO" in
    linux)
    if [ "$V_BOARD" = "nguni" -a "$V_SUB_NETIF" = "none" ]; then
    modprobe qmi_wwan.ko -r
    modprobe qmi_wwan.ko multi_wwan=0
    else
    modprobe qmi_wwan.ko
    fi
    ;;
    *)
    insmod /lib/modules/GobiNet.ko 2>/dev/null
    insmod /lib/modules/GobiSerial.ko 2>/dev/null
    ;;
    esac
    fi
    sys -m 1

    # turning on LAN
    ifconfig eth0 up
    }

    if [ "$sleepmode" = "4" ]; then
    log "Sleep: Ignition detected"
    else
    log "Sleep: Timer expired"
    fi

    pre_standby

    # go to sleep
    echo -n standby > /sys/power/state

    if [ "$sleepmode" = "4" ]; then
    log "Wakeup: ignition detected"
    else
    log "Wakeup: Timer expired"
    fi

    post_standby

    log "Done"

  • I now have the power management source code from (processors.wiki.ti.com/index.php/AM335x_StarterWare_Power_management#Power_Management).

    I have also built the am335x-pm-firmware.bin from the source code using the requisite cross compile toolchain.  I can see that  a8_wake_cmdb_handler() function inside src/pm_services/pm_handlers.c is probably responsible for wakeup from standby mode. Can we put debug logs in this codebase(so that the logs are visible on the console)?

    Is there any documentation with respect to understanding the code?

    BR,

    Sourav

  • So far the am335x-pm-firmware.bin source code was not open to customers. There is a some documentation within the archive. I'll try to debug it and let you know. Before going to debug the firmware, is it possible to double check the PIN MUX configurations of PIN C18 (gpio0_7) or check this behaviour on other gpio0_x or different device for better orientation over the root cause.
  • I have checked that the GPIO0_7 pin voltage changes on toggling the ignition switch connected to it......the only observation is that when proper wakeup is happening, the voltage change is from 0V to ~3.3V.....while when the wakeup is not happening, the voltage change is from 0V to ~2.4V.

    We have put an external pull up to this pin, so that the voltage reaches ~3.3V, but that did not help.

  • Also it would be great if you can let me know how you are debugging that codebase...I mean what kind of test bed set up you are using

  • The version from this link processors.wiki.ti.com/index.php/AM335x_StarterWare_Power_management#Power_Management is 0x181 but the latest version is 0x186. Have you tested the latest firmware? It also seems to have a debug possibility, check the src/lib/debug.c, src/include/debug.h and firmware.ld file.

    Latest firmware:

    git clone git://arago-project.org/git/projects/am33x-cm3.git
  • I have tried  latest version  0x186 from 

    arago-project.org/.../projects;a=tree;f=bin

    The behaviour is still the same.