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.

Need help with rtcwake

Other Parts Discussed in Thread: AM3358

Hi

I am using:

Device: Beaglebone (white) A6 (with AM3358 silicon version 2.0)
OS: Arago Linux (ti-sdk-am335x-evm-05.07.00.00-Linux)

I want to use rtcwake to wake up the processor from (save-to-RAM) sleep. However, I get a message that it is not enabled for wake up events

root@beaglebone:~# rtcwake -m mem -s 100
rtcwake: /dev/rtc0 not enabled for wakeup events

Has anyone been able to wake the processor up from sleep with this statement? Is there a workaround?


I have been able to put my device to sleep with

echo mem > /sys/power/state, though.


Secondly, this linux doesn't come with gcc pre-installed. I need to setup CCS for cross compilation. That is an elaborate procedure. Once I do that, I can program RTC using ioctl and try to setup a wake up interrupt. Meanwhile I want to get rtcwake working for proof of concept (that I can use RTC to wake up beaglebone from sleep).

Thanks
Abhijeet

  • Perhaps try a newer kernel from v3.2-staging, and use standby instead of mem.  Please let me know if it works for you.  

    Ref: http://arago-project.org/git/projects/?p=linux-am33x.git;a=commit;h=ae298d4a5a55786aee7df53aa8f1a4addad8ab1d

    "ARM: OMAP: AM33XX: PM: Enable RTC wakeup for standby"

  • Hi John

    Thank you for your reply. 

    I tried the standby mode as well. I getting the same error again. (That rtc0 is not enabled for wakeup). I am currently using the latest version of Arago Linux. I have tried Angstrom as well (both kernel v3.8 and v3.2). I see a similar behavior.

    Am I missing something? Do I need to enlist rtc as a wake up source somewhere? 

    Thanks

    Abhijeet

  • You will need to download the latest v3.2-staging kernel (using git) and build it as the RTC wake change isn't in the TI SDK kernel release.

    See:

    http://arago-project.org/git/projects/?p=linux-am33x.git;a=shortlog;h=refs/heads/v3.2-staging

  • Hi John

    I see your point now! I am not familiar with git. Hence the confusion! I will do as you say and let you know if it works.

    Thanks again.

    Abhijeet

  • I was expecting rtcwake feature to be enabled in the TI SDK 06.00.00 release. But it is still not functional. I still get the error:

    rtcwake: /dev/rtc not enabled for wakeup events

    I have not tried the latest v3.2 staging kernel yet.

  • We got RTC0 wakealarm from DeepSleep0 working on an AM335x PG2.x EVM  (not EVM-Starter Kit) with (Arago) AM335xSDK_05.06.00.00 (with help from a very smart and amiable TI customer). 

    Please note that you MUST have AM335x PG2.x silicon (errata in PG1.0 which I believe is Advisory 1.0.5 RTC: 32.768-kHZ Clock is Gating Off ).

     

    >>I was expecting rtcwake feature to be enabled in the TI SDK 06.00.00 release.

    I'm a little surprised to hear this but have not tried any later SDK versions.

     

    On AM335xSDK_05.06.00.00, we had to make 2 changes in the Linux kernel:

    In /board-support/linux-3.2.0-psp05.06.00.00/arch/arm/mach-omap2/board-am335xevm.c line 1991, change from 0 to 1:

    .wakeup_capable = 1,

    In /board-support/linux-3.2.0-psp05.06.00.00/drivers/rtc/rtc-omap.c, near the end of the function omap_rtc_probe() there are two lines:

    if (pdata->wakeup_capable)

                    device_init_wakeup(&pdev->dev, 1);

    Those two lines need to be moved to just before the lines:

    rtc = rtc_device_register(pdev->name, &pdev->dev,

                    &omap_rtc_ops, THIS_MODULE);

     

    This is following the RTC driver documented here: http://processors.wiki.ti.com/index.php/AM335x_PSP_User's_Guide#RTC_Driver to get the wakealarm run time:

    root@am335x-evm:/sys/class/rtc/rtc0# ls

    date           hctosys        power          time

    dev            max_user_freq  since_epoch    uevent

    device         name           subsystem      wakealarm

     

    Then you can use hwclock to prove RTC is running, wakealarm to set the alarm, and then suspend as usual. Log below (wakealarm in 60 sec).

    root@am335x-evm:/sys/class/rtc/rtc0# hwclock --show Mon Dec 17 08:59:20 2012  0.000000 seconds

    root@am335x-evm:/sys/class/rtc/rtc0#

    root@am335x-evm:/sys/class/rtc/rtc0# echo +60 > /sys/class/rtc/rtc0/wakealarm

    root@am335x-evm:/sys/class/rtc/rtc0# echo mem > /sys/power/state [ 2603.475067] PM: Syncing filesystems ... done.

    [ 2603.483245] Freezing user space processes ... (elapsed 0.01 seconds) done.

    [ 2603.507568] Freezing remaining freezable tasks ... (elapsed 0.01 seconds) done.

    [ 2603.527587] Suspending console(s) (use no_console_suspend to debug)

    [ 2608.529754] LCD Controller timed out

    [ 2608.644927] PM: suspend of devices complete after 5109.954 msecs

    [ 2608.646667] PM: late suspend of devices complete after 1.647 msecs

    [ 2659.905792] GFX domain entered low power state

    [ 2659.905853] Successfully transitioned all domains to low power state

    [ 2660.114929] PM: early resume of devices complete after 208.586 msecs

    [ 2660.489624] net eth0: CPSW phy found : id is : 0x4dd074

    [ 2660.496551] PM: resume of devices complete after 381.189 msecs

    [ 2660.560577] Restarting tasks ... done.

    root@am335x-evm:/sys/class/rtc/rtc0# [ 2662.486602] PHY: 0:00 - Link is Up - 100/Full

    root@am335x-evm:/sys/class/rtc/rtc0# hwclock --show Mon Dec 17 09:19:19 2012  0.000000 seconds

    root@am335x-evm:/sys/class/rtc/rtc0#

  • Thank you for such an elaborate answer. This really helps. Let me try out your suggestions and check if the RTC alarm wakes BB up from sleep.

    >>>>I was expecting rtcwake feature to be enabled in the TI SDK 06.00.00 release.

    >>I'm a little surprised to hear this but have not tried any later SDK versions.

    I was surprised too. In fact I was waiting for SDK 06.00.00 release to be able to try out RTC wake up.

    Abhijeet

  • Hi

    I made the changes on SDK 06.00.00 Arago Linux. I could see the wakealarm application enabled with these changes. However, my Beaglebone (white) A6 board still does not wake up from a scheduled alarm. I don't understand what I am missing! :( 

    Please take a look at these snapshots from my terminal. (Comments in green)

    Snapshot 1

    root@am335x-evm:~# ls /sys/class/rtc/rtc0
    date hctosys power time
    dev max_user_freq since_epoch uevent
    device name subsystem wakealarm   <-------------- wakealarm enabled
    root@am335x-evm:~# echo +90 > /sys/class/rtc/rtc0/wakealarm   <------ Alarm set for 90 seconds in the future
    root@am335x-evm:~# cat /proc/driver/rtc  

    RTC status after setting this alarm:
    rtc_time : 23:37:32
    rtc_date : 2013-06-25
    alrm_time : 23:38:53
    alrm_date : 2013-06-25
    alarm_IRQ : yes   <---- interrupt enabled
    alrm_pending : no  <----- fishy? Why is this still a "no"?
    update IRQ enabled : no
    periodic IRQ enabled : no
    periodic IRQ frequency : 1
    max user IRQ frequency : 64
    24hr : yes

    root@am335x-evm:~# echo mem > /sys/power/state  <----- Save-to-RAM sleep
    [ 547.471557] PM: Syncing filesystems ... done.
    [ 549.555786] Freezing user space processes ... (elapsed 0.01 seconds) done.
    [ 549.573822] Freezing remaining freezable tasks ... (elapsed 0.01 seconds) don e.
    [ 549.593872] Suspending console(s) (use no_console_suspend to debug)
    [ 549.721191] PM: suspend of devices complete after 120.056 msecs
    [ 549.722869] PM: late suspend of devices complete after 1.586 msecs

    <keystroke>

    881 - 550 = 331 seconds. Well over 90 seconds.

    [ 881.383575] GFX domain entered low power state
    [ 881.383636] Successfully transitioned all domains to low power state
    [ 881.592559] PM: early resume of devices complete after 208.457 msecs
    [ 881.682373] net eth0: CPSW phy found : id is : 0x7c0f1
    [ 881.686431] PM: resume of devices complete after 93.528 msecs
    [ 881.729034] Restarting tasks ... done.
    root@am335x-evm:~# cat /proc/driver/rtc

    RTC status after wakeup:
    rtc_time : 23:43:28        <------|
    rtc_date : 2013-06-25             |   Alarm definitely triggered
    alrm_time : 23:38:53    <------|
    alrm_date : 2013-06-25
    alarm_IRQ : no
    alrm_pending : no
    update IRQ enabled : no
    periodic IRQ enabled : no
    periodic IRQ frequency : 1
    max user IRQ frequency : 64
    24hr : yes

    Snapshot 2:

    I see a similar behaviour with rtcwake:

    root@am335x-evm:~# rtcwake -s 90 -m mem -d /dev/rtc0
    wakeup from "mem" at Tue Jun 25 23:57:59 2013
    [ 1678.369598] PM: Syncing filesystems ... done.
    [ 1678.378417] Freezing user space processes ... (elapsed 0.01 seconds) done.
    [ 1678.405334] Freezing remaining freezable tasks ... (elapsed 0.01 seconds) done.
    [ 1678.425323] Suspending console(s) (use no_console_suspend to debug)
    [ 1678.552673] PM: suspend of devices complete after 120.086 msecs
    [ 1678.554321] PM: late suspend of devices complete after 1.586 msecs

    <keystroke>

    1992 - 1678 = 314 seconds. Well over 90 seconds.


    [ 1992.169189] GFX domain entered low power state
    [ 1992.169281] Successfully transitioned all domains to low power state
    [ 1992.378173] PM: early resume of devices complete after 208.393 msecs
    [ 1992.468017] net eth0: CPSW phy found : id is : 0x7c0f1
    [ 1992.472076] PM: resume of devices complete after 93.533 msecs
    [ 1992.514739] Restarting tasks ... done.
    root@am335x-evm:~# cat /proc/driver/rtc
    rtc_time : 00:01:56
    rtc_date : 2013-06-26
    alrm_time : 23:57:59
    alrm_date : 2013-06-25
    alarm_IRQ : no
    alrm_pending : no
    update IRQ enabled : no
    periodic IRQ enabled : no
    periodic IRQ frequency : 1
    max user IRQ frequency : 64
    24hr : yes

  • Hi

    I found some (possible) inconsistencies: (in SDK 06.00.00)

    1. In debugfs, I can see that the rtc_pwrdm (I assume it is RTC Power Domain) is always OFF.

    root@am335x-evm:/# cat /sys/kernel/debug/pm_debug/time
    cefuse_pwrdm (OFF),OFF:52090423584,RET:0,INA:0,ON:1007500457763
    mpu_pwrdm (ON),OFF:0,RET:0,INA:0,ON:1059590911865
    per_pwrdm (ON),OFF:0,RET:0,INA:0,ON:1059590911865
    rtc_pwrdm (OFF),OFF:1059590911865,RET:0,INA:0,ON:0
    gfx_pwrdm (ON),OFF:0,RET:0,INA:0,ON:1059590881347

    2. Only one wakeup source is listed in debugfs. All the parameters here are zero. I tried using wakealarm and rtcwake as before to see if these values change. But they remain '0'. Is this normal?

    root@am335x-evm:/# cat /sys/kernel/debug/wakeup_sources
    name          active_count event_count hit_count active_since total_time max_time last_change
    am33xx-rtc         0                      0                    0                    0                 0                 0                 0

    rtc is OFF and never accessed... (RET-LOGIC-OFF value changes to a non zero value for other pwrdms (other than rtc_pwrdm). I had just rebooted my board. Hence all values are zero.)

    root@am335x-evm:/# cat /sys/kernel/debug/pm_debug/count
    [ 2802.466461] pwrdm state mismatch(cefuse_pwrdm) 3 != 0
    cefuse_pwrdm (ON),OFF:0,RET:0,INA:0,ON:1,RET-LOGIC-OFF:0
    mpu_pwrdm (ON),OFF:0,RET:0,INA:0,ON:1,RET-LOGIC-OFF:0,RET-MEMBANK1-OFF:0,RET-MEMBANK2-OFF:0,RET-MEMBANK3-OFF:0
    per_pwrdm (ON),OFF:0,RET:0,INA:0,ON:1,RET-LOGIC-OFF:0,RET-MEMBANK1-OFF:0,RET-MEMBANK2-OFF:0,RET-MEMBANK3-OFF:0
    rtc_pwrdm (OFF),OFF:1,RET:0,INA:0,ON:0,RET-LOGIC-OFF:0
    gfx_pwrdm (ON),OFF:0,RET:0,INA:0,ON:1,RET-LOGIC-OFF:0,RET-MEMBANK1-OFF:0
    l4_cefuse_clkdm->cefuse_pwrdm (0)
    gfx_l4ls_gfx_clkdm->gfx_pwrdm (0)
    gfx_l3_clkdm->gfx_pwrdm (0)
    l4_rtc_clkdm->rtc_pwrdm (1)
    mpu_clkdm->mpu_pwrdm (1)
    l4_wkup_aon_clkdm->wkup_pwrdm (3)
    l3_aon_clkdm->wkup_pwrdm (1)
    l4_wkup_clkdm->wkup_pwrdm (6)
    clk_24mhz_clkdm->per_pwrdm (1)
    lcdc_clkdm->per_pwrdm (0)
    cpsw_125mhz_clkdm->per_pwrdm (2)
    pruss_ocp_clkdm->per_pwrdm (0)
    ocpwp_l3_clkdm->per_pwrdm (0)
    l4hs_clkdm->per_pwrdm (1)
    l3_clkdm->per_pwrdm (10)
    l4fw_clkdm->per_pwrdm (2)
    l3s_clkdm->per_pwrdm (3)
    l4ls_clkdm->per_pwrdm (18)

    3. In the kernel source code, in /drivers/rtc/rtc-omap.c, in the function omap_rtc_suspend (), I noticed a comment (in red):

    static int omap_rtc_suspend(struct platform_device *pdev, pm_message_t state)
    {
    u8 irqwake_stat;
    const struct platform_device_id *id_entry =
    platform_get_device_id(pdev);

    irqstat = rtc_read(OMAP_RTC_INTERRUPTS_REG);

    /* FIXME the RTC alarm is not currently acting as a wakeup event
    * source, and in fact this enable() call is just saving a flag
    * that's never used...
    */
    if (device_may_wakeup(&pdev->dev)) {
    enable_irq_wake(omap_rtc_alarm);

    ......................................

    ....................

    Is this fixed or is the comment still valid? 

    Thanks,

    Abhijeet.

  • >>However, my Beaglebone (white) A6 board still does not wake up from a scheduled alarm

    Are you sure that is PG2.x silicon?

    You can check the chip markings from http://www.ti.com/litv/pdf/sprz360e

    I'm pretty sure BB Black is PG2.x silicon.

  • Hi Joe

    I am sure it is PG2.x silicon. It is a Beaglebone white A6 board. The if statement:

    if (omap_rev() >= AM335X_REV_ES2_0)

    executes as TRUE.

    Although, I am a little confused with the markings. The format doesn't match (rightmost image is the MCU on my beaglebone white)

    Additionally, with some prints in kernel code, when the beaglebone is not in sleep, I can see the RTC interrupt when an alarm is triggered. (rtcwake -s 30 -m no)

    Thanks and Regards,

    Abhijeet

  • Sorry, I might be missing something. But yours looks like PG1.0 to me. 

    My PG2.0 EVM says XAM3359AZCZ.  So the device revision code is "A" so PG2.0 (like the middle image above).

    >>rightmost image is the MCU on my beaglebone white

    But yours says XAM3359ZCZD72. So the device revision code is "blank" so PG1.0 (like my old PG1.0 EVM).

    That also corresponds with the BOM here: http://circuitco.com/support/index.php?title=BeagleBone#Rev_A6 

  • Hi Joe

    Of course! Now it makes sense!

    I could not identify the marking correctly. Also I wrongly assumed the latest A6 version of BB had a processor with corrected silicon.

    Let me try it on a Beaglebone Black.

    Thanks and Regards,

    Abhijeet

  • Hi Joe

    I am now able to wake my Beaglebone Black from standby sleep (after setting wakeup_capable = 1, of course). For some reason, the board isn't waking up from Save-to-RAM sleep.

    However, the main issue is solved.

    Thanks for your help.

    Best Regards,

    Abhijeet

  • Hello guys,

    I did the fix for wake up capable as per Joe suggestions and recompiled a new kernel using the TI SDK 05.06.00.00.
    But I am not sure which files (UImage, zImage, u-boot.img??......) I need to download to the beagle bone black board to get suspend/resume via RTC wake alarm working.
  • TI SDK 05.06.00.00 doesn't support BB Black as far as I know.

    Have you tried on TI SDK06.00.00?

    The patch might already be implemented there.  I can try tomorrow when I have access to HW.

  • Hi Joe

    SDK 06.00.00 does not have the patch yet. I had to hack the code as per your instructions. And it works great! :)

    Thanks and Regards,

    Abhijeet

  • Hi Ali

    After you build the modified kernel, the binaries appear in the following directories:

    MLO, u-boot: <tisdk root>/board_support/u-boot-XXXXX/

    uImage: <tisdk root>/board_support/linux-XXXXX/arch/arm/boot/

    Use create_sdcard.sh script to flash these custom binaries to the SD card.

    To disable eMMC boot on the BBB, remove/rename the bootloader "MLO" from the existing boot partition. Now insert the SD card with Arago linux and it should boot up just fine.

    Hope this helps

    Thanks and Regards,

    Abhijeet

  • Hi Joe and Abhijeet,

    Thanks for your replies.

    I used the create_sdcard.sh script from TI SDK 06.00.00.

    I then followed faithfully the setup.sh script steps from the wiki to write the prebuilt image (or the custom built image):

    http://circuitco.com/support/index.php?title=3.2_SDK_On_BeagleBone_Black

    Finally, when I try to boot from the board, I cannot communicate and login via the minicom terminal (it simply echos few CCCC characters on startup). So I am not sure if the board is booting properly or not!

    Abhijeet,

    Can you please share with me the steps you followed to write the image successfully to the BeagleBone Black?

  • Sorry, I've used BB Black very sparingly (mostly EVM and BB White).

    I usually see the "CCCC" error with a bad or loose SD card or even if uImage did not get copied onto the FA32 partition.

    Have you gotten any SD card to boot with BB Black?

  • Hi

    Make sure you have safely ejected the SD card before physically removing it from the slot. Lot of pending data is flushed out to the SD card when u do that. 

    Abhijeet

  • Thanks again Abhijeet and Joe.

    Actually, I was able to wake the BBB from standby using RTC (mem is not working yet).

    The main problem lies in the create-sdcard.sh script, at lines 573 and 582 where "p1" should be concatenated to the ${DRIVE} variable instead of "1". This confusion is due to the fact that the OS is calling the SDcard "mmcblk0" and not "sd". 

  • Hi Abhijeet and Joe,

    I am trying to wakeup the BBB from deep sleep (mem) using RTCwake or wakealarm but I was not successful (waking the BBB from standby using RTCwake is working fine).

    Do I need to do any patch to the code to get this feature to work ? (knowing that I am using TI SDK 06.00.00.00 and BBB silicon revision 2.0.)

    --

    Thanks

  • >>Do I need to do any patch to the code to get this feature to work ?

    I haven't tried on SDK6.0 or BBB, but Abhijeet seems to confirm above (and my customer confirmed on AM335x EVM).

  • Hi Ali

    I got the same results as you. I patched the code as described in this conversation. I did not make any other code changes. 

    Abhijeet

  • Thanks again Abhijeet and Joe.

    Dear Joe,

    It seems Abhijeet too was not able to wakeup the BBB from deep sleep (mem) using RTCwake or wakealarm.

    Can you please provide me with some insights to work on that problem (maybe changes your customer had to do)?