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.

Linux/PROCESSOR-SDK-AM335X: rtcwake command error

Part Number: PROCESSOR-SDK-AM335X


Tool/software: Linux

Hi,

I'm working on latest ti sdk ti-processor-sdk-linux-am335x-evm-03.02.00.05-Linux-x86-Install and wants to use rtcwake command but getting an error.

Could anyone suggest me the changes required to mak ertcwake up work.

Below are logs:

root@ngt:~# rtcwake -d /dev/rtc0 -m standby -s 5

wakeup from "standby" at Sat Jan  1 00:22:41 2000
rtcwake: short write

Thanks and Regards

Deshvir Malik

  • Hi Deshvir,

    Do you use TI board (AM335x EVM, SK) or custom board? What silicon version is your AM335x processor?

    Can you try to wake up from suspend with below command, will be there any difference?

    rtcwake -d /dev/rtc0 -m mem -s 5

    Regards,
    Pavel
  • Hi Pavel,

    I'm using custom board. Silicon version is Silicon Revision 2.1

     

    Below are the logs:

    For silicon version:

    root@ngt:~# devmem2 0x44E10600
    /dev/mem opened.
    Memory mapped at address 0xb6f3d000.
    Read at address  0x44E10600 (0xb6f3d600): 0x2B94402E

    For rtcwake

    root@ngt:~# rtcwake -d /dev/rtc0 -m mem -s 5

    wakeup from "mem" at Sat Jan  1 00:02:32 2000
    rtcwake: short write

     

    Thanks and Regards

    Deshvir Malik

  • Deshvir,

    Do you use the default TI root filesystem?

    ti-processor-sdk-linux-am335x-evm-03.02.00.05/filesystem/tisdk-rootfs-image-am335x-evm

    This root filesystem contains the correct rtcwake command (busybox binary). If you are using your own version of busybox, you should patch it, see the below wiki page for more info:

    processors.wiki.ti.com/.../Linux_Core_Power_Management_User's_Guide_(v4.1)

    Regards,
    Pavel
  • Hi Pavel,

    I'm not using default filesystem. But I tried with the busybox binary availble in the dafault filesystem and got same error. I need to check with kernel configuration and I'll let you know.

    If any specific kernel configuration you know, please let me know.

    Thanks and Regards

    Deshvir Malik

  • Hi,
    Did you check if "/dev/rtc0" exists before doing a write?

    Thsi error seems to be a generic return value form BusyBox without giving details hence the confusion.

    RTC would be most probably a module so you need to have your modules copied and inserted if not auto loaded.
    Check if is built in(CONFIG_RTC_DRV_OMAP=y ) otherwise
    do "lsmod | grep rtc" you should see "rtc_omap"
    If not then the rtc module is not loaded.
    do a "depmod -a" and "modprobe rtc_omap" - if no error then do "lsmod | grep rtc_omap"

    If there's an error - no such file/directory then
    compile modules an dcopy them to your rootfs "lib/modules"

    make modules

    make modules_install INSTALL_MOD_PATH=<folder name>
    usually folder name is where you have your rootfs. If you get permission issues then install to a temp folder and copy them to rootfs.


    Regards,
    RK
  • Hi RK,

    Sorry for late reply, I was on leave yesterday...I'll try your suggestion and let you know the result.

    Thanks and Regards
    Deshvir Malik
  • Hi RK,

    /dev/rtc0 exists

     

    CONFIG_RTC_DRV_OMAP=y  is present in .config file

    Below are the logs

    root@ngt:~# cd /dev/rtc

    rtc   rtc0  

    root@ngt:~# lsmod | grep rtc

    root@ngt:~# cd /lib/mod

    modprobe.d/ modules/    

    root@ngt:~# cd /lib/mod

    modprobe.d/ modules/    

    root@ngt:~# cd /lib/modules/

    3.12.10-ti2013.12.01/ 4.4.32-gadde2ca9f8/  

    root@ngt:~# cd /lib/modules/4.4.32-gadde2ca9f8/

    build                modules.builtin.bin  modules.softdep

    kernel/              modules.dep          modules.symbols

    modules.alias        modules.dep.bin      modules.symbols.bin

    modules.alias.bin    modules.devname      source

    modules.builtin      modules.order        

    root@ngt:~# cd /lib/modules/4.4.32-gadde2ca9f8/kernel/drivers/

    root@ngt:/lib/modules/4.4.32-gadde2ca9f8/kernel/drivers# ls

    ata        char       hid        media      net        spi        watchdog

    base       crypto     hwmon      memory     power      uio

    bluetooth  extcon     iio        mfd        rtc        usb

    cdrom      gpu        input      mtd        scsi       w1

    root@ngt:/lib/modules/4.4.32-gadde2ca9f8/kernel/drivers# cd rtc/

    root@ngt:/lib/modules/4.4.32-gadde2ca9f8/kernel/drivers/rtc# ls

    rtc-ds1307.ko  rtc-palmas.ko

     

    On the other hand, in old ti-sdk "ti-sdk-am335x-evm-07.00.00.00" , rtc is working and below are the logs

    Logs from working release

    umount: can't umount /mnt/.psplash: Invalid argument
    root@ngt:~#
    root@ngt:~#
    root@ngt:~# cd /dev/rtc
    rtc   rtc0  
    root@ngt:~# cd /dev/rtc0
    -sh: cd: /dev/rtc0: Not a directory
    root@ngt:~# lsmod | grep rtc
    root@ngt:~# cd /lib/mod
    modprobe.d/ modules/    
    root@ngt:~# cd /lib/modules/3.12.10-ti2013.12.01/
    root@ngt:/lib/modules/3.12.10-ti2013.12.01# ls
    build                modules.dep.bin      modules.seriomap
    kernel               modules.devname      modules.softdep
    modules.alias        modules.ieee1394map  modules.symbols
    modules.alias.bin    modules.inputmap     modules.symbols.bin
    modules.builtin      modules.isapnpmap    modules.usbmap
    modules.builtin.bin  modules.ofmap        source
    modules.ccwmap       modules.order        updates
    modules.dep          modules.pcimap
    root@ngt:/lib/modules/3.12.10-ti2013.12.01# cd kernel/drivers/
    root@ngt:/lib/modules/3.12.10-ti2013.12.01/kernel/drivers# ls
    hwmon  iio    media  net    phy    usb
    root@ngt:/lib/modules/3.12.10-ti2013.12.01/kernel/drivers#

     

    Thanks and Regards

    Deshvir Malik

     

     

  • Hi,

    Okay, so now that we are sure that RTC is built in, next step is to check if teh issue is with teh rtcwake utility.

    I see you mentioned that this happened with different rtcwake binaries but can you check if both were from BusyBox.

    A little more digging showed that the error "Short write" is output by BusyBox.

    See below mail chain for more details on the error

    http://lists.busybox.net/pipermail/busybox/2016-September/084619.html


    It says the error is usually thrown when we are out space - using commands like dd, wget..

    But I have seen this issue even with 'rtcwake' a while ago when I was using ramdisk based small FS which was resolved when I switched to full FS with all modules.

    That's whay I wanted you to check the modules first.

    Can you check with rtcwake form  "util-linux" and let us know if you still see the issue?

    You can get the source here https://www.kernel.org/pub/linux/utils/util-linux/v2.29/ and you need to cross-compile for arm.

    Regards,

    RK

  • Hi RK,

    I'll check with util-linux too but before that I want to tell you some observation I got as mentioned below. In below two cases only difference is of busybox (as suggested by Pavel).

    1. If I use my filesystem but bootloader, kernel, modules from new sdk, and old busybox, I got the following logs

    root@ngt:~#

    root@ngt:~# rtcwake -s 10 -d /dev/rtc0 -m poweroff

    [   17.149507] ***omap_rtc_read_time***

    [   17.153381] ***rtc_wait_not_busy***

    [   17.156893] ***omap_rtc_read_time_raw***

    [   17.160971] ***bcd2tm***

    [   17.163713] ***omap_rtc_read_time***

    [   17.167478] ***rtc_wait_not_busy***

    [   17.170985] ***omap_rtc_read_time_raw***

    [   17.174942] ***bcd2tm***

    [   17.177609] ***omap_rtc_read_time***

    [   17.181201] ***rtc_wait_not_busy***

    [   17.184699] ***omap_rtc_read_time_raw***

    [   17.188658] ***bcd2tm***

    [   17.191200] ***omap_rtc_set_alarm***

    [   17.194786] ***tm2bcd***

    [   17.197338] ***rtc_wait_not_busy***

    [   17.200843] ***omap_rtc_alarm_irq_enable***

    [   17.205131] ***rtc_wait_not_busy***

    [   17.208637] ***rtc_wait_not_busy***

    wakeup from "poweroff" at Sat Jan  1 00:00:27 2000

    rtcwake: short write

    root@ngt:~# [   27.863945] ***rtc_irq***

    [   27.866636] ***omap_rtc_read_time***

    [   27.870226] ***rtc_wait_not_busy***

    [   27.873727] ***omap_rtc_read_time_raw***

    [   27.877689] ***bcd2tm***

    [   27.880239] ***omap_rtc_alarm_irq_enable***

    [   27.884436] ***rtc_wait_not_busy***

    [   27.887936] ***rtc_wait_not_busy***

    root@ngt:~#

    1. If I use my filesystem but bootloader, kernel, modules from new sdk, and busybox form filesystem in latest SDK, I got the following logs

    root@ngt:~# rtcwake -s 10 -d /dev/rtc0 -m poweroff
    [   24.433329] ***omap_rtc_read_time***
    [   24.437123] ***rtc_wait_not_busy***
    [   24.440630] ***omap_rtc_read_time_raw***
    [   24.444568] ***bcd2tm***
    [   24.447326] ***omap_rtc_read_time***
    [   24.450920] ***rtc_wait_not_busy***
    [   24.454419] ***omap_rtc_read_time_raw***
    [   24.458506] ***bcd2tm***
    [   24.461070] ***omap_rtc_read_time***
    [   24.464657] ***rtc_wait_not_busy***
    [   24.468157] ***omap_rtc_read_time_raw***
    [   24.472139] ***bcd2tm***
    [   24.474682] ***omap_rtc_set_alarm***
    [   24.478285] ***tm2bcd***
    [   24.480826] ***rtc_wait_not_busy***
    [   24.484331] ***omap_rtc_alarm_irq_enable***
    [   24.488543] ***rtc_wait_not_busy***
    [   24.492044] ***rtc_wait_not_busy***
    wakeup from "poweroff" at Sat Jan  1 00:00:34 2000
    WARNING: could not determine runlevel - doing soft poweroff
      (it's better to use shutdown instead of poweroff from the command line)
    INIT: Sending processes the TERM signal
    INIT: SendiStopping telnet daemon.
    Stopping system message bus: [   31.236309] ***omap_rtc_set_time***
    [   31.239847] ***tm2bcd***
    [   31.242389] ***rtc_wait_not_busy***
    [   31.246079] ***omap_rtc_read_time***
    [   31.249673] ***rtc_wait_not_busy***
    [   31.253172] ***omap_rtc_read_time_raw***
    [   31.257503] ***bcd2tm***
    [   31.260067] ***omap_rtc_read_time***
    [   31.263653] ***rtc_wait_not_busy***
    [   31.267152] ***omap_rtc_read_time_raw***
    [   31.271126] ***bcd2tm***
    [   31.273669] ***omap_rtc_set_alarm***
    [   31.277273] ***tm2bcd***
    [   31.279814] ***rtc_wait_not_busy***
    Error opening /dev/fb0: No such file or directory
    Stopping syslogd/klogd: no syslogd found; none killed
    Stopping thttpd.
    ALSA: Storing mixer settings...
    /usr/sbin/alsactl: /usr/lib/libasound.so.2: no version information available (required by /usr/sbin/alsactl)
    Deconfiguring network interfaces... ifdown: interface lo not configured
    ifdown: interface eth0 not configured
    done.
    [   32.370138] wlcore: using inverted interrupt logic: 8
    [   32.430316] wlcore: PHY firmware version: Rev 8.2.0.0.237
    [   32.528514] wlcore: firmware booted (Rev 8.9.0.0.70)
    [   32.543218] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
    udhcpc (v1.24.1) started
    Sending discover...
    [   34.842011] ***rtc_irq***
    [   34.844705] ***omap_rtc_read_time***
    [   34.848318] ***rtc_wait_not_busy***
    [   34.851821] ***omap_rtc_read_time_raw***
    [   34.855772] ***bcd2tm***
    [   34.858322] ***omap_rtc_alarm_irq_enable***
    [   34.862518] ***rtc_wait_not_busy***
    [   34.866018] ***rtc_wait_not_busy***
    Sending discover...
    Sending discover...
    Sending discover...
    Sending discover...
    Sending discover...
    Sending discover...
    Sending discover...
    Sending discover...
    Sending discover...
    Sending discover...
    Sending discover...
    Sending discover...
    Sending discover...
    Sending discover...
    Sending discover...
    Sending discover...
    Sending discover...
    .

    .

    ..this remains continue...

    Could you please comment on this observation and there is no decrease in current.

     

    Thanks and Regards

    Deshvir Malik

  • Hi RK,

    With what options do I need to cross-compile rtcwake in util-linux?

    Best Regards
    Deshvir Malik
  • Deshvir,

    I tried this command on AM335x TI EVM with kernel and rootfs from PSDK3.02. It works fine:

    root@am335x-evm:~# ls -al /dev/rtc0

    crw-------    1 root     root      254,   0 Dec 14 23:15 /dev/rtc0

    root@am335x-evm:~# rtcwake -d /dev/rtc0 -m mem -s 5

    rtcwake: assuming RTC uses UTC ...

    rtcwake: wakeup from "mem" using /dev/rtc0 at Sat Jan  1 00:01:14 2000

    [   92.943426] PM: Syncing filesystems ... done.

    [   93.146331] Freezing user space processes ... (elapsed 0.009 seconds)

    done.

    [   93.158393] Freezing remaining freezable tasks ... (elapsed 0.001

    seconds) done.

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

    [   93.304484] PM: suspend of devices complete after 128.283 msecs

    [   93.309640] PM: late suspend of devices complete after 5.098 msecs

    [   93.314858] PM: noirq suspend of devices complete after 5.163 msecs

    [   93.314876] PM: Successfully put all powerdomains to target state

    [   93.336953] PM: noirq resume of devices complete after 21.889 msecs

    [   93.341550] PM: early resume of devices complete after 3.974 msecs

    [   93.343893] net eth0: initializing cpsw version 1.12 (0)

    [   93.343918] net eth0: initialized cpsw ale version 1.4

    [   93.343934] net eth0: ALE Table size 1024

    [   93.417889] net eth0: phy found : id is : 0x4dd074

    [   93.418037] libphy: PHY 4a101000.mdio:01 not found

    [   93.418060] net eth0: phy "4a101000.mdio:01" not found on slave 1, err -19

    [   93.657349] PM: resume of devices complete after 315.743 msecs

    [   93.734143] Restarting tasks ... done.

    root@am335x-evm:~#

     

    Have you tried with kernel and rootfs from PSDK3.02?


    Regards,
    Pavel

  • Hi Pavel,

    We are also using latest SDK ti-processor-sdk-linux-am335x-evm-03.02.00.05-Linux-x86-Install.bin. 

    We have migrated from ti-sdk-am335x-evm-07.00.00.00 to ti-processor-sdk-linux-am335x-evm-03.02.00.05 and in old SDK rtc was working.

    In my customised board, PMIC support is not present.

    I have replaced the old busybox binary with the latest busybox( busybox, busybox.nosuid, busybox.suid) binary from default filesystem.

    But still we are facing same error.

    Logs:

    root@ngt:~/test# cd
    root@ngt:~# rtcwake -d /dev/rtc0 -m standby -s 5
    wakeup from "standby" at Sat Jan  1 00:02:04 2000
    rtcwake: short write
    root@ngt:~# rtcwake -d /dev/rtc0 -m mem -s 5                                                                                                   
    wakeup from "mem" at Sat Jan  1 00:02:14 2000
    rtcwake: short write
    root@ngt:~# rtcwake -s 10 -d /dev/rtc0 -m poweroff
    wakeup from "poweroff" at Sat Jan  1 00:02:30 2000
    WARNING: could not determine runlevel - doing soft poweroff
      (it's better to use shutdown instead of poweroff from the command line)
    INIT: Sending processes the TERM signal
    INIT: SendiStopping telnet daemon.
    Stopping system message bus: Error opening /dev/fb0: No such file or directory
    Stopping syslogd/klogd: no syslogd found; none killed
    Stopping thttpd.
    ALSA: Storing mixer settings...
    /usr/sbin/alsactl: /usr/lib/libasound.so.2: no version information available (required by /usr/sbin/alsactl)
    /usr/sbin/alsactl: save_state:1580: No soundcards found...
    Deconfiguring network interfaces... ifdown: interface lo not configured
    ifdown: interface eth0 not configured
    done.
    ifconfig: SIOCGIFFLAGS: No such device
    gpio/set-value: No such file or directory
    Sending all processes the TERM signal...
    Sending all processes the KILL signal...
    Unmounting remote filesystems...
    Deactivating swap...
    Unmounting local filesystems...
    [  153.242604] EXT4-fs (mmcblk0p2): re-mounted. Opts: data=ordered
    [  155.554076] reboot: Power down
    [  155.557191] System will go to power_off state in approx. 1 second
    [  158.056772] rtc_power_off failed, bailing out.

    Thanks and Regards

    Deshvir Malik

     

  • Deshvir,

    Deshvir Malik said:
    I have replaced the old busybox binary with the latest busybox( busybox, busybox.nosuid, busybox.suid) binary from default filesystem.

    Can you try with the PSDK3.02 filesystem?

    If this is not possible for you, can you replace the below two files from your filesystem:

    ti-processor-sdk-linux-am335x-evm-03.02.00.05/filesystem/tisdk-rootfs-image-am335x-evm/usr/lib/opkg/alternatives/rtcwake

    ti-processor-sdk-linux-am335x-evm-03.02.00.05/filesystem/tisdk-rootfs-image-am335x-evm/usr/sbin/rtcwake

    Regards,
    Pavel

  • Hi Pavel,

    1.

    With the new PSDK3.02 filesystem, we are using our new customized bootloader and kernel images.

    root@am335x-evm:~#

    root@am335x-evm:~# ls -al /dev/rtc0                                                                                            

    crw-------    1 root     root      254,   0 Dec 14 23:15 /dev/rtc0

    root@am335x-evm:~# rtcwake -d /dev/rtc0 -m mem -s 5                                                                                            

    rtcwake: unrecognized suspend state 'mem'

    root@am335x-evm:~#

    2. With old filesystem and new customized bootlader and kernel images, I replaced rtcwake in /usr/sbin and below are the observations

    root@ngt:/usr/sbin# ./rtcwake -d /dev/rtc0 -m mem -s 5
    rtcwake: unrecognized suspend state 'mem'
    root@ngt:/usr/sbin#

    root@ngt:~# rtcwake -d /dev/rtc0 -m mem -s 5                                                                                                   
    wakeup from "mem" at Sat Jan  1 00:05:36 2000
    rtcwake: short write
    root@ngt:~#

    Thanks and Regards

    Deshvir Malik

  • Deshvir,

    Deshvir Malik said:

    With the new PSDK3.02 filesystem, we are using our new customized bootloader and kernel images.

    root@am335x-evm:~#

    root@am335x-evm:~# ls -al /dev/rtc0                                                                                            

    crw-------    1 root     root      254,   0 Dec 14 23:15 /dev/rtc0

    root@am335x-evm:~# rtcwake -d /dev/rtc0 -m mem -s 5                                                                                            

    rtcwake: unrecognized suspend state 'mem'

    Can you try with the below commands? What is the result then?

    rtcwake -d /dev/rtc0 -m standby -s 5

    rtcwake  -d /dev/rtc0 -m poweroff -s 10




    Deshvir Malik said:
    2. With old filesystem and new customized bootlader and kernel images, I replaced rtcwake in /usr/sbin and below are the observations


    Deshvir Malik said:
    rtcwake: short write


    You should try to patch the util-linux/rtcwake.c, and re-build new filesystem with patched rtcwake. Just re-placing executables might not work here.


  • Hi,
    To crosscompile rtcwake form util-linux

    ./configure --host=arm-linux-gnueabihf --prefix=/opt/gcc-linaro-arm-linux-gnueabihf-4.7-2013.03-20130313_linux/bin/
    make rtcwake

    Copy "rtcwake" to your rootfs.

    Regards,
    RK
  • Hi RK,

    I tried with the command as mentioned by you

    ./configure --host=arm-linux-gnueabihf --prefix=/opt/gcc-linaro-arm-linux-gnueabihf-4.7-2013.03-20130313_linux/bin/
    make rtcwake

    But it didn't create rtcwake for target platform.

    deshvir@deshvir-OptiPlex-3040:~/util-linux-2.29.2$ file rtcwake
    rtcwake: ELF 64-bit LSB  executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0ce23f8ed0d90ba2d7ed4606d50487963f1e7adf, not stripped
    deshvir@deshvir-OptiPlex-3040:~/util-linux-2.29.2$

    Could you please tell what else is required to cross compile it for arm-linux-gnueabihf

    Thanks and Regards

    Deshvir Malik

  • Hi Pavel,

    rtcwake -d /dev/rtc0 -m standby -s 5
    Above command also gives same error which I got with "rtcwake -d /dev/rtc0 -m mem -s 5"

    Thanks and Regards
    Deshvir Malik
  • Deshvir Malik said:
    rtcwake -d /dev/rtc0 -m standby -s 5
    Above command also gives same error which I got with "rtcwake -d /dev/rtc0 -m mem -s 5"

    Can you try if you can enter DeepSleep0 (mem) and/or Standby mode?

    First check if you have enable the Suspend/Resume PM option in kernel:

    [*] Suspend to RAM and standby

    Then try "$ echo mem > /sys/power/state" and/or "$ echo standby > /sys/power/state". Are you able to enter into DeepSleep0 and/or Standby mode successful?



    You can also try the below sequence:
    $ echo 1 > /sys/kernel/debug/pm_debug/enable_off_mode
    $ rtcwake -s 5 -d /dev/rtc0 -m mem


    Pavel

  • Deshvir Malik said:

    I tried with the command as mentioned by you

    ./configure --host=arm-linux-gnueabihf --prefix=/opt/gcc-linaro-arm-linux-gnueabihf-4.7-2013.03-20130313_linux/bin/
    make rtcwake

    This is how I cross-compile on my side:

    pbotev@mms-0306:~/AM335x/utils/util-linux-2.29.2$ export PATH=/home/users/pbotev/AM335x/ti-processor-sdk-linux-am335x-evm-03.02.00.05/linux-devkit/sysroots/x86_64-arago-linux/usr/bin:$PATH

    pbotev@mms-0306:~/AM335x/utils/util-linux-2.29.2$ export CROSS_COMPILE=/home/users/pbotev/AM335x/ti-processor-sdk-linux-am335x-evm-03.02.00.05/linux-devkit/sysroots/x86_64-arago-linux/usr/bin/arm-linux-gnueabihf-

    pbotev@mms-0306:~/AM335x/utils/util-linux-2.29.2$ export CC=${CROSS_COMPILE}gcc

    pbotev@mms-0306:~/AM335x/utils/util-linux-2.29.2$ export ARCH=arm

    pbotev@mms-0306:~/AM335x/utils/util-linux-2.29.2$ ./configure --host=arm-linux-gnueabihf --prefix=/home/users/pbotev/AM335x/ti-processor-sdk-linux-am335x-evm-03.02.00.05/linux-devkit/sysroots/x86_64-arago-linux/usr/bin

    pbotev@mms-0306:~/AM335x/utils/util-linux-2.29.2$ make rtcwake

    pbotev@mms-0306:~/AM335x/utils/util-linux-2.29.2$ file rtcwake
    rtcwake: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=0x2727f258cd3724f61bc5f3680420465fb12a9e2b, not stripped

    Regards,
    Pavel

  • Hi Pavel,

    Thanks a lot. Even I'm able to cross compile now following the steps provided by you.

    Best Regards
    Deshvir Malik
  • Hi Malik,
    Just for future reference and benefit of others who might visit this thread, In my case the tool chain is installed in the path showed by --prefix,
    so I set --prefix=/opt/gcc-linaro-arm-linux-gnueabihf-4.7-2013.03-20130313_linux/bin/

    You need to point to the right location on your setup.

    Glad that you were able to get it build.

    Also as Pavel mentioned, once you have teh right binary - just check if you have enabled "Suspend to memory" in config.

    Regards,
    RK
  • Hi Pavel,

    I have tried your suggestion and got the following results

    root@ngt:~# echo mem > /sys/power/state
    -sh: echo: write error: Invalid argument
    root@ngt:~# echo standby > /sys/power/state
    -sh: echo: write error: Invalid argument


    root@ngt:~# echo 1 > /sys/kernel/debug/pm_debug/enable_off_mode
    root@ngt:~# rtcwake -s 5 -d /dev/rtc0 -m mem
    wakeup from "mem" at Sat Jan  1 00:01:43 2000
    rtcwake: short write
    root@ngt:~# rtcwake -s 5 -d /dev/rtc0 -m standby
    wakeup from "standby" at Sat Jan  1 00:01:56 2000
    rtcwake: short write

    As per your suggestion, we are using the busybox from latest filesystem to avoid short write error.


    Observation: In /sys/power/state , nothing is present but in my old SDK /sys/power/state consist of standby, mem and freeze.

    Below are my power management options in kernel configuration

    #
    # Power management options
    #
    CONFIG_SUSPEND=y
    CONFIG_SUSPEND_FREEZER=y
    # CONFIG_SUSPEND_SKIP_SYNC is not set
    # CONFIG_HIBERNATION is not set
    CONFIG_PM_SLEEP=y
    # CONFIG_PM_AUTOSLEEP is not set
    # CONFIG_PM_WAKELOCKS is not set
    CONFIG_PM=y
    CONFIG_PM_DEBUG=y
    # CONFIG_PM_ADVANCED_DEBUG is not set
    # CONFIG_PM_TEST_SUSPEND is not set
    CONFIG_PM_SLEEP_DEBUG=y
    # CONFIG_APM_EMULATION is not set
    CONFIG_PM_OPP=y
    CONFIG_PM_CLK=y
    # CONFIG_WQ_POWER_EFFICIENT_DEFAULT is not set
    CONFIG_CPU_PM=y
    CONFIG_ARCH_SUSPEND_POSSIBLE=y
    CONFIG_ARM_CPU_SUSPEND=y
    CONFIG_ARCH_HIBERNATION_POSSIBLE=y

    Thanks and Regards

    Deshvir Malik

  • Hi RK and Pavel,

    You are correct, we need to set environment variables as per our system.

    I used the latest compiled rtcwake and put at /usr/sbin/
    Further, I used latest busybox from new filesystem.

    Below are the logs:

    root@ngt:/usr/sbin# ./rtcwake -d /dev/rtc0 -m standby -s 5
    rtcwake: unrecognized suspend state 'standby'
    root@ngt:/usr/sbin# ./rtcwake -d /dev/rtc0 -m mem -s 5
    rtcwake: unrecognized suspend state 'mem'

    Could you please tell how to enable "suspend to memory" in config. "Suspend to RAM and standby" is present but I didn't find suspend to memory option.

    Thanks and Regards
    Deshvir Malik
  • Deshvir,

    "Suspend to RAM and standby" should be enough for using Suspend/Resume (DeepSleep0/mem or standby). I think "suspend to memory" is the same as "suspend to RAM".

    http://processors.wiki.ti.com/index.php/Linux_Core_Power_Management_User's_Guide_%28v4.4%29#Kernel_Configuration_Options_3

    These PM features should be enabled by default in the tisdk_am335x-evm_defconfig file. Do you use tisdk_am335x-evm_defconfig when building your kernel?

    Regards,
    Pavel

  • Hi Pavel,

    I'm using "tisdk_am335x-evm_defconfig" only while building my kernel and "Suspend to RAM and standby" is enabled in it.

    Thanks and Regards
    Deshvir Malik
  • Deshvir,

    So you are using tisdk_am335x-evm_defconfig file, and you do not make any changes through menuconfig? And you still do not see "/sys/power/state" in your rootfs?

    Regards,
    Pavel
  • Hi Pavel,

    I'm using tisdk_am335x-evm_defconfig 

    I can see "/sys/power/state" but there is nothing inside "state" like standby, mem or freeze.

    Logs Below:

    root@ngt:/sys/power# cat state

    root@ngt:/sys/power#

    I'm attaching my tisdk_am335x-evm_defconfig here for reference. Could you please check it once.

    8053.tisdk_am335x-evm_defconfig.txt

    Thanks and Regards,

    Deshvir Malik

  • Deshvir Malik said:

    I'm attaching my tisdk_am335x-evm_defconfig here for reference. Could you please check it once.

    (Please visit the site to view this file)

    Do you use the default tisdk_am335x-evm_defconfig file or you have made some changes in this file? If you are using the default tisdk_am335x-evm_defconfig file, what should I check in this file?

    Regards,
    Pavel

  • Hi Pavel,

    Yes, we have done changes according to our board. It's not the default defconfig.
    Can you please check anything we need to enable in the defconfig regarding rtc and power.


    Thanks and Regards
    Deshvir Malik.
  • Hi Pavel,

    Finally moved one step !!!

    I have done the following changes and rtcwake command started working but kernel is getting crashed after that.

    1. defconfig configuration is made as mentioned below

    # Firmware Loading from rootfs

    CONFIG_FW_LOADER_USER_HELPER=y

    CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y

    # AMx3 Power Config Options

    CONFIG_MAILBOX=y

    CONFIG_OMAP2PLUS_MBOX=y

    CONFIG_WKUP_M3_RPROC=y

    CONFIG_SOC_TI=y

    CONFIG_WKUP_M3_IPC=y

    CONFIG_TI_EMIF_SRAM=y

    CONFIG_AMX3_PM=y

    CONFIG_RTC_DRV_OMAP=y

    2. am335x-pm-firmware.elf is taken from default filesystem and put in my customized filesystem at /lib/firmware

    Below are the logs:

    root@ngt:/usr/sbin# ./rtcwake -d /dev/rtc0 -m standby -s 5                                                                                     
    rtcwake: assuming RTC uses UTC ...
    rtcwake: wakeup from "standby" using /dev/rtc0 at Sat Jan  1 00:16:14 2000
    [  958.290775] PM: Syncing filesystems ... done.
    [  958.298040] Freezing user space processes ... (elapsed 0.001 seconds) done.
    [  958.306784] Freezing remaining freezable tasks ... (elapsed 0.001 seconds) done.
    [  958.315864] Suspending console(s) (use no_console_suspend to debug)
    [  958.330840] PM: suspend of devices complete after 7.207 msecs
    [  958.333144] PM: late suspend of devices complete after 2.277 msecs
    [  958.335915] PM: noirq suspend of devices complete after 2.740 msecs
    [  958.335924] PM: Successfully put all powerdomains to target state
    [  958.338803] PM: noirq resume of devices complete after 2.766 msecs
    [  958.341145] PM: early resume of devices complete after 2.113 msecs
    [  963.644005] PM: resume of devices complete after 5302.825 msecs
    [  963.644014] ------------[ cut here ]------------
    [  963.644052] WARNING: CPU: 0 PID: 580 at drivers/cpufreq/cpufreq.c:1646 cpufreq_resume+0x138/0x190()
    [  963.644152] Modules linked in: sd_mod arc4 wl18xx usb_storage wlcore scsi_mod mac80211 cfg80211 musb_dsps musb_hdrc usbcore udc_core ecb md5
     pm33xx sha1_generic sha1_arm snd_soc_simple_card wkup_m3_rproc wkup_m3_ipc remoteproc virtio virtio_ring omap_aes_driver omap_sham omap_rng c_
    can_platform c_can rng_core can_dev snd_soc_davinci_mcasp snd_soc_edma snd_soc_omap wlcore_sdio snd_soc_tlv320aic3x snd_soc_core snd_pcm_dmaeng
    ine snd_pcm snd_timer musb_am335x omap_wdt
    [  963.644167] CPU: 0 PID: 580 Comm: rtcwake Tainted: G        W       4.4.32-gadde2ca9f8 #285
    [  963.644170] Hardware name: Generic AM33XX (Flattened Device Tree)
    [  963.644177] Backtrace:
    [  963.644207] [<c00140e4>] (dump_backtrace) from [<c00142e0>] (show_stack+0x18/0x1c)
    [  963.644220]  r7:c03dbc24 r6:0000066e r5:00000009 r4:00000000
    [  963.644237] [<c00142c8>] (show_stack) from [<c02b9128>] (dump_stack+0x24/0x28)
    [  963.644255] [<c02b9104>] (dump_stack) from [<c0032e54>] (warn_slowpath_common+0x88/0xb4)
    [  963.644266] [<c0032dcc>] (warn_slowpath_common) from [<c0032f24>] (warn_slowpath_null+0x24/0x2c)
    [  963.644279]  r8:c07f9b04 r7:c07a82bc r6:c07a8298 r5:c07fa804 r4:00000000
    [  963.644292] [<c0032f00>] (warn_slowpath_null) from [<c03dbc24>] (cpufreq_resume+0x138/0x190)
    [  963.644305] [<c03dbaec>] (cpufreq_resume) from [<c035843c>] (dpm_resume+0x210/0x228)
    [  963.644320]  r9:c07a8298 r8:c07f9b04 r7:c07a82bc r6:c07a8298 r5:cf79aa28 r4:c07a82bc
    [  963.644329] [<c035822c>] (dpm_resume) from [<c0358678>] (dpm_resume_end+0x14/0x20)
    [  963.644344]  r10:c077e12c r9:c07c78a8 r8:00000000 r7:00000000 r6:00000000 r5:00000002
    [  963.644348]  r4:00000010
    [  963.644361] [<c0358664>] (dpm_resume_end) from [<c0067be0>] (suspend_devices_and_enter+0x170/0x588)
    [  963.644368]  r5:00000002 r4:c07c78bc
    [  963.644377] [<c0067a70>] (suspend_devices_and_enter) from [<c00682b4>] (pm_suspend+0x2bc/0x370)
    [  963.644392]  r10:00000051 r9:caaec3c0 r8:00000008 r7:c07bc2e8 r6:c07c78c4 r5:00000000
    [  963.644396]  r4:00000002
    [  963.644405] [<c0067ff8>] (pm_suspend) from [<c0066ca0>] (state_store+0x70/0xc0)
    [  963.644416]  r7:00000007 r6:c07c78c8 r5:c06a04f0 r4:00000002
    [  963.644428] [<c0066c30>] (state_store) from [<c02bb33c>] (kobj_attr_store+0x1c/0x28)
    [  963.644442]  r9:b6f25000 r8:c00107c4 r7:00000000 r6:00000000 r5:caaec3c0 r4:c0066c30
    [  963.644457] [<c02bb320>] (kobj_attr_store) from [<c01708c8>] (sysfs_kf_write+0x48/0x4c)
    [  963.644464]  r5:caaec3c0 r4:c02bb320
    [  963.644473] [<c0170880>] (sysfs_kf_write) from [<c0170074>] (kernfs_fop_write+0xc8/0x1d4)
    [  963.644480]  r5:caaec3c0 r4:caaec340
    [  963.644500] [<c016ffac>] (kernfs_fop_write) from [<c0105af4>] (__vfs_write+0x34/0xe4)
    [  963.644515]  r10:00000000 r9:cab3a000 r8:c00107c4 r7:cab3bf80 r6:00000008 r5:c016ffac
    [  963.644519]  r4:cf5ba780
    [  963.644531] [<c0105ac0>] (__vfs_write) from [<c010639c>] (vfs_write+0x98/0x174)
    [  963.644545]  r9:cab3a000 r8:c00107c4 r7:cab3bf80 r6:b6f25000 r5:00000008 r4:cf5ba780
    [  963.644557] [<c0106304>] (vfs_write) from [<c0106c0c>] (SyS_write+0x4c/0xa8)
    [  963.644570]  r8:c00107c4 r7:00000008 r6:b6f25000 r5:cf5ba780 r4:cf5ba780
    [  963.644582] [<c0106bc0>] (SyS_write) from [<c0010600>] (ret_fast_syscall+0x0/0x3c)
    [  963.644593]  r7:00000004 r6:b6f25000 r5:00000008 r4:00026138
    [  963.644598] ---[ end trace 7e189ad45954840f ]---
    [  963.996187] Restarting tasks ...
    [  963.999824] usb 1-1: USB disconnect, device number 4
    [  964.005920] done.
    root@ngt:/usr/sbin# [  964.323896] usb 1-1: new high-speed USB device number 5 using musb-hdrc
    [  964.486828] usb-storage 1-1:1.0: USB Mass Storage device detected
    [  964.503073] scsi host3: usb-storage 1-1:1.0
    [  965.527254] scsi 3:0:0:0: Direct-Access     TOSHIBA  TransMemory      1.00 PQ: 0 ANSI: 4
    [  965.541331] sd 3:0:0:0: [sda] 7574304 512-byte logical blocks: (3.88 GB/3.61 GiB)
    [  965.554756] sd 3:0:0:0: [sda] Write Protect is off
    [  965.570735] sd 3:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
    [  965.586794]  sda: sda1
    [  965.599190] sd 3:0:0:0: [sda] Attached SCSI removable disk
    [  965.928360] EXT4-fs (sda1): recovery complete
    [  965.932782] EXT4-fs (sda1): mounted filesystem with ordered data mode. Opts: (null)

    Could you tell me the possible issue for this crash.

    Thanks and Regards

    Deshvir Malik

  • Deshvir Malik said:
    Can you please check anything we need to enable in the defconfig regarding rtc and power.

    I have tried with your defconfig file (on my AM335x TI EVM), and I still see "mem' and "standby" entries:

    root@am335x-evm:~# cat /sys/power/state
    freeze standby mem

    These entries (freeze, standby, mem) depends on "Suspend to RAM and standby" setting. When I remove this setting (which is enabled by default in tisdk_am335x-evm_defconfig), I do not have these entries (freeze standby mem).

    rtcwake command is used first to suspend the device, then to wake it up through RTC. The first step is to invoke "echo mem > /sys/power/state" or "echo standby > /sys/power/state". I think you should focus on debugging these commands malfunctions, not rtcwake.

    Regards,
    Pavel

  • Deshvir Malik said:
    root@ngt:/usr/sbin# ./rtcwake -d /dev/rtc0 -m standby -s 5   

    Below is what I have on my side:

    root@am335x-evm:~# rtcwake -d /dev/rtc0 -m standby -s 5
    rtcwake: assuming RTC uses UTC ...
    rtcwake: wakeup from "standby" using /dev/rtc0 at Wed Dec 14 23:16:22 2016
    [   73.097442] PM: Syncing filesystems ... done.
    [   73.280173] Freezing user space processes ... (elapsed 0.003 seconds) done.
    [   73.290444] Freezing remaining freezable tasks ... (elapsed 0.001 seconds) done.
    [   73.300011] Suspending console(s) (use no_console_suspend to debug)
    [   73.442043] PM: suspend of devices complete after 133.556 msecs
    [   73.447104] PM: late suspend of devices complete after 5.005 msecs
    [   73.452725] PM: noirq suspend of devices complete after 5.561 msecs
    [   73.452744] PM: Successfully put all powerdomains to target state
    [   73.474619] PM: noirq resume of devices complete after 21.665 msecs
    [   73.479435] PM: early resume of devices complete after 4.317 msecs
    [   73.481911] net eth0: initializing cpsw version 1.12 (0)
    [   73.481937] net eth0: initialized cpsw ale version 1.4
    [   73.481954] net eth0: ALE Table size 1024
    [   73.557933] net eth0: phy found : id is : 0x4dd074
    [   73.558081] libphy: PHY 4a101000.mdio:01 not found
    [   73.558103] net eth0: phy "4a101000.mdio:01" not found on slave 1, err -19
    [   73.797356] PM: resume of devices complete after 317.859 msecs
    [   73.874251] Restarting tasks ... done.
    root@am335x-evm:~#

     

    Seems to me like you have some on-going activity before and during execution of rtcwake command. Check also if you have some changes in the CPUFreq settings specific for your board.


    Regards,
    Pavel

  • Hi Pavel,

    By using prebuilt images in beagle bone, we are getting cpu frequency as shown below

    root@am335x-evm:~# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
    300000
    root@am335x-evm:~# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies
    300000 600000 720000 800000 1000000
    root@am335x-evm:~#

    But in my customized board, I'm not getting "cpufreq"

    root@ngt:~# cd /sys/devices/system/cpu/cpu0/                                                                                                   
    root@ngt:/sys/devices/system/cpu/cpu0# ls
    cpuidle    of_node    power      subsystem  topology   uevent
    root@ngt:/sys/devices/system/cpu/cpu0#

    Could you please suggest what configurations are required to get this?

    Thanks and Regards,

    Deshvir Malik

  • Deshvir,

    Deshvir Malik said:
    But in my customized board, I'm not getting "cpufreq"

    Deshvir Malik said:
    Could you please suggest what configurations are required to get this?

    If you are using linuxkernel 4.4.x, refer to the below wiki:

    http://processors.wiki.ti.com/index.php/Linux_Core_Power_Management_User's_Guide_%28v4.4%29#Kernel_Configuration_Options

    See also the below e2e threads:

    Regards,
    Pavel

  • Hi Pavel,

    I have tried with couple of options but it didn't workout.

    I'll tell you about my old working SDK configuration and new SDK configuration.

    Old Working SDK

    In old working SDK /drivers/rtc/rtc-omap.c was modified and below I have mentioned the modified section. While giving the "rtcwake -d /dev/rtc0 -m standby -s 5" or "rtcwake -d /dev/rtc0 -m mem -s 5", current is going upto 15mA and the board used to get restart after the time mentioned. (Board doesn't restart in new SDK)

    They are few preconditions, which we need to make out board in rtc-only mode. We are satisfying these preconditions and then only board go in rtc-only mode. (This is not happening with new SDK, even after satisfying preconditiond board goes upto 55mA and if we do not satisfy preconditions, still board goes to 55mA).

    1.  power off function is commented here.

    static struct rtc_class_ops omap_rtc_ops = {

    .read_time = omap_rtc_read_time,

    .set_time = omap_rtc_set_time,

    .read_alarm = omap_rtc_read_alarm,

    .set_alarm = omap_rtc_set_alarm,

      /* .power_off  = rtc_power_off,   commented to remove compile error*/

    .alarm_irq_enable = omap_rtc_alarm_irq_enable,

    };

    2. suspend function is commented and  rtc_power_off() is called from omap_rtc_suspend() function.

    static int omap_rtc_suspend(struct device *dev)

    {

    printk(KERN_INFO "***omap_rtc_suspend***\n");

    #if 0

    u8 irqwake_stat;

    struct platform_device *pdev = to_platform_device(dev);

    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 on some platforms, and in fact this enable() call is just

    * saving a flag that's never used...

    */

    if (device_may_wakeup(dev)) {

    enable_irq_wake(omap_rtc_alarm);

    if (id_entry->driver_data & OMAP_RTC_HAS_IRQWAKEEN) {

    irqwake_stat = rtc_read(OMAP_RTC_IRQWAKEEN);

    irqwake_stat |= OMAP_RTC_IRQWAKEEN_ALARM_WAKEEN;

    rtc_write(irqwake_stat, OMAP_RTC_IRQWAKEEN);

    }

    } else {

    rtc_write(0, OMAP_RTC_INTERRUPTS_REG);

    }

    /* Disable the clock/module */

    pm_runtime_put_sync(dev);

    return 0;

    #endif

    rtc_power_off();

    return 0;

    }

    3. Some part of this function is commented

    static void rtc_power_off(void)

    {

    printk(KERN_INFO "***rtc_power_off***\n");

    u32 val;

    struct rtc_time tm;

    #if 0

    /*Configuration may or may not needed*/

    /* Set PMIC power enable SM */

    val = readl(rtc_base + OMAP_RTC_PMIC_REG);

    val |= OMAP_RTC_PWR_ENABLE_SM;

    rtc_writel(val,OMAP_RTC_PMIC_REG);

    /* Set PMIC polarity - active low */

    val = readl(rtc_base + OMAP_RTC_PMIC_REG);

    val |= OMAP_RTC_PMIC_EXT_WAKEUP_POL;

    rtc_writel(val,OMAP_RTC_PMIC_REG);

    #endif

    /* Set OMAP_RTC_PMIC_EXT_WAKEUP_EN */

    val = readl(rtc_base + OMAP_RTC_PMIC_REG);

    val |= OMAP_RTC_PMIC_EXT_WAKEUP_EN;

    rtc_writel(val,OMAP_RTC_PMIC_REG);

    /* Set PMIC power enable */

    val = readl(rtc_base + OMAP_RTC_PMIC_REG);

    val |= OMAP_RTC_PMIC_POWER_EN_EN ;

    rtc_writel(val,OMAP_RTC_PMIC_REG);

    /* Wait few seconds instead of rollover */

    do {

    omap_rtc_read_time(NULL, &tm);

    if (WAIT_AFTER <= tm.tm_sec)

    mdelay(WAIT_TIME_MS);

    } while (WAIT_AFTER <= tm.tm_sec);

    /* Add shutdown time to the current value */

    tm.tm_sec += SHUTDOWN_TIME_SEC;

    if (tm2bcd(&tm) < 0)

    return;

    pr_info("System will go to power_off state in approx. %d secs\n",

    SHUTDOWN_TIME_SEC);

    /* Set the ALARM2 time */

    rtc_write(tm.tm_sec, OMAP_RTC_ALARM2_SECONDS_REG);

    rtc_write(tm.tm_min, OMAP_RTC_ALARM2_MINUTES_REG);

    rtc_write(tm.tm_hour, OMAP_RTC_ALARM2_HOURS_REG);

    rtc_write(tm.tm_mday, OMAP_RTC_ALARM2_DAYS_REG);

    rtc_write(tm.tm_mon, OMAP_RTC_ALARM2_MONTHS_REG);

    rtc_write(tm.tm_year, OMAP_RTC_ALARM2_YEARS_REG);

    /* Enable alarm2 interrupt */

    val = readl(rtc_base + OMAP_RTC_INTERRUPTS_REG);

    writel(val | OMAP_RTC_INTERRUPTS_IT_ALARM2,

    rtc_base + OMAP_RTC_INTERRUPTS_REG);

    /* Do not allow to execute any other task */

    while (1);

    }

     

    In new SDK, we have not done any changes in /drivers/rtc/rtc-omap.c and our current is going upto 55mA rather than going upto 15mA . Whether we satisfy our preconditions or not satisfy, in both cases current is going upto 55mA.

    Also after giving rtcwake command we want the board to get restart.

    Can you please let us know how to modify the rtc-omap driver so that our condition is satisfied.

    Thanks and Regards,

    Deshvir Malik

  • Hi Deshvir,

    Deshvir Malik said:
    In new SDK, we have not done any changes in /drivers/rtc/rtc-omap.c and our current is going upto 55mA rather than going upto 15mA

    Deshvir Malik said:
    Can you please let us know how to modify the rtc-omap driver so that our condition is satisfied.

    Your latest question deviate too much from your subject "rtcwake command error". I think you are fine now with the rtcwake command, aren't you? If yes, please close this thread and open new thread regarding your new issue.

    Regards,
    Pavel

  • Thanks Pavel for your support. I will open a new thread for enabling RTC -only.

    The above issue was because am335x-pm-firmware.elf was not available in the file system. That is why the power states mem,freeze and standby was not present in /sys/power/states