Issue with RTC on imx8mm

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Issue with RTC on imx8mm

1,971 Views
ashikp6
Contributor I

Hi,
I am using custom board based on imx8mm with android 11.

When i use the Google desk clock application i dont see the RTC apis from drivers being called. Also the board doesnt come back from deep sleep(suspend) when the alarm triggered, even though the alarm is expected to bring the board to wakeup.
(Same application i have tried on my mobile phone and i am able to see the board coming out from suspend and showing the alarm notification)

We are using only the internal RTC.
DTS used is,
snvs_rtc

snvs_rtc: snvs-rtc-lp {
                    compatible = "fsl,sec-v4.0-mon-rtc-lp";
                    regmap = <&snvs>;
                    offset = <0x34>;
                    interrupts = <GIC_SPI 19 IRQ_TYPE_LEVEL_HIGH>,
                             <GIC_SPI 20 IRQ_TYPE_LEVEL_HIGH>;
                    clocks = <&clk IMX8MM_CLK_SNVS_ROOT>;
                    clock-names = "snvs-rtc";
                };


Also tried using the following commands,
 echo +15 > /sys/class/rtc/rtc0/wakealarm
echo mem > /sys/power/state
In this scenario board goes to suspend and wakes up after 15s and i am seeing the RTC driver prints.

Why is the application not able to use rtc driver and trigger the interrupt to wake up the board ?
Thanks,
Ashik

0 Kudos
Reply
7 Replies

1,930 Views
ashikp6
Contributor I

Hi @Dhruvit ,
Thanks for the suggestion.

Linked  RTC with system clock using hwclock command.

When i try the below command to set alarm

echo +15 > /sys/class/rtc/rtc0/wakealarm

 I can see the alarm being set,

nitrogen8mm:/ # cat /proc/driver/rtc                                                                                                                                                                         
rtc_time	: 11:10:25
rtc_date	: 2023-04-20
alrm_time	: 11:10:36
alrm_date	: 2023-04-20
alarm_IRQ	: yes
alrm_pending	: no
update IRQ enabled	: no
periodic IRQ enabled	: no
periodic IRQ frequency	: 1
max user IRQ frequency	: 64
24hr		: yes

but when i set from the alarm application, alarm IRQ is always 'no' and the alarm time doesnt change

0 Kudos
Reply

1,905 Views
Dhruvit
NXP TechSupport
NXP TechSupport

Hi @ashikp6,

I hope you are doing well.

It seems the Application is not using the correct RTC or does not have access to it.

Is there any other RTC available on the system?

 

# ls -la /dev/rtc*

 

One can refer to the below-mentioned links for more information.

https://stackoverflow.com/questions/14398127/rtc-wakeup-is-not-working

https://stackoverflow.com/questions/23821356/android-sys-rtc-wakealarm-does-not-boot-device-when-off

Please try adding the below the line in ueventd.nxp.rc 

/dev/rtc0 0666 system system

Thanks & Regards,
Dhruvit Vasavada

0 Kudos
Reply

1,855 Views
ashikp6
Contributor I

Hi @Dhruvit 

I tried the same application in my phone with android 11. There the application seems to be working as expected and brings the board from suspend mode when the alarm rings.

 

i am using only one rtc.Output of the above command is
/dev/rtc0

Tags (1)
0 Kudos
Reply

1,845 Views
Dhruvit
NXP TechSupport
NXP TechSupport

Hi @ashikp6,

I hope you are doing well.

This issue could be due to the app not having permission to use RTC.

Have you tried adding the below line in ueventd.rc

/dev/rtc0 0666 system system

Thanks & Regards,
Dhruvit Vasavada.

0 Kudos
Reply

1,810 Views
ashikp6
Contributor I

Hi @Dhruvit ,

Tried adding 

/dev/rtc0 0666 system system to /system/etc/ueventd.rc file. (Attached the updated file)

Set alarm from application( google desk clock).Still not seeing the alarm interrupt being set as shown below
rtc_time        : 11:40:56
rtc_date        : 2023-05-09
alrm_time       : 00:00:00
alrm_date       : 1970-01-01
alarm_IRQ       : no
alrm_pending    : no
updateIRQ enabled      : no
periodic IRQ enabled    : no
periodic IRQ frequency  : 1
max user IRQ frequency  : 64 2
4hr            : yes

Thanks,
Ashik

0 Kudos
Reply

1,762 Views
Dhruvit
NXP TechSupport
NXP TechSupport

Hi @ashikp6,

I hope you are doing well.

This issue seems to be with how user application interface with RTC devices.

As RTC seems to work fine with the wakealarm interface in user space.

One can try debugging on google desk clock with the highest debug logs.

Please refer to the below documentation for more information regarding this.

Declare the appropriate exact alarm permission

Schedule alarms 

Thanks & Regards,
Dhruvit Vasavada

0 Kudos
Reply

1,955 Views
Dhruvit
NXP TechSupport
NXP TechSupport

Hi @ashikp6,

I hope you are doing well.

This issue could be due to the Google desk clock application not using the correct RTC.

One can refer to the below-mentioned document to debug further.

Schedule alarms

Please sync RTC with the system clock using below command.

#hwclock -w

One can monitor alarm interrupts using the below command.

# cat /proc/driver/rtc

Please share the output of the above command after setting alarm.

Thanks & Regards,
Dhruvit Vasavada

0 Kudos
Reply