RTC Wake-up

  • Operation confirmed on the following Odroid boards.
    • Odroid-C4
    • Odroid-HC4

You can wake your Odroid board up with our RTC Shield.

First of all, to enable your RTC shield on your Odroid board, please follow the dedicated guide.

Setup the system time

Set the system time up to your local time by following the commands below.

sudo dpkg-reconfigure tzdata

Then the final outputs will be looking like that.

$ sudo dpkg-reconfigure tzdata
 
Current default time zone: 'Asia/Seoul'
Local time is now:      Wed Jun  9 11:11:19 KST 2021.
Universal Time is now:  Wed Jun  9 02:11:19 UTC 2021.

Set the board can wake up by the GPIO pin

  • This step is only for Odroid-C4/HC4.

To wake up by the Shield's interrupt signal, you have to set the GPIO pin number to the script file that the U-boot bootloader reads.

Put the setup codes into the /media/boot/boot.ini file, to the place right after setting bootargs.

Odroid-C4/HC4

### in case of GPIOX.5 (Pin 7) of 2x20 pins connector ###
setenv gpiopower "481"
setenv bootargs ${bootargs} gpiopower=${gpiopower}

So that the result should like this.

# Boot Args
setenv bootargs "..."

### in case of GPIOX.5 (Pin 7) of 2x20 pins connector ###
setenv gpiopower "481"
setenv bootargs ${bootargs} gpiopower=${gpiopower}

# Load kernel, dtb and initrd
...

Then if a proper signal is given to the set pin, the board wakes up from the shutting-down state.

Configure the RTC shield

Write the current system time to your RTC shield.

sudo hwclock -w -f /dev/rtc0
  • If an RTC hardware is detected then there will be an RTC device file as like /dev/rtc?.
  • Since /dev/rtc0 is the default RTC device generally, you can omit the -f option of the above command.

And check if the date was written correctly. The below codes will compare the time information between the shield has and the Odroid system.

$ hwclock -r ; date
2021-06-09 11:24:48.431452+09:00
Wed Jun  9 11:24:48 KST 2021

Then put the DateTime that the time you willing to wake-up your Odroid into /sys/class/rtc/rtc0/wakealarm file.

Here's an example to enable the wakealarm feature and this lets the Odroid turns up in 3 minutes.

echo 0 | sudo tee /sys/class/rtc/rtc0/wakealarm
echo $(date '+%s' -d '+ 3 minutes') | sudo tee /sys/class/rtc/rtc0/wakealarm

Read the RTC status.

cat /proc/driver/rtc

Then it results like the below contents. To check if the wakealarm feature enabled or not, see the alarm_IRQ property. It should be yes.

rtc_time        : 02:26:18
rtc_date        : 2021-06-09
alrm_time       : 02:29:13
alrm_date       : 2021-06-09
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

Shut down your Odroid and watch that to check if it wakes up automatically or not. If all went well, your Odroid board will wake up in 3 minutes by the shield's interrupt signal.

sudo poweroff

System messages

Here is the troubleshooting list that is reported commonly, and these can be found on dmesg or standard output on the console.

hwclock: ioctl(RTC_RD_TIME) to /dev/rtc to read the time failed: Invalid argument

RTC backup battery is not connected or RTC is not configured to be accessed for some reason.

cannot access '/dev/rtc1': No such file or directory

First of all, you should check the given RTC device file is correct.

If it seems there's no device file from the RTC shield, please see the wiki page for RTC Shield to check if all the settings are correct.

And to check if the RTC shield can communicate well with the Odroid board through the I2C protocol, you can check with the I2C device detector tool like the following commands.

sudo apt install i2c-tools
sudo i2cdetect -y 0
  • That given number with -y option should match with your Odroid board.
$ ls -al /dev/i2c*
crw-rw---- 1 root i2c 89, 0 Apr  2  2020 /dev/i2c-0

Then the results should be the same as the following contents.

$ sudo i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- UU -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --

Resulting UU indicates it is normal.

rtc-pcf8563 3-0051: low voltage detected, date/time is not reliable

This error could be inaccurate but you should check the real voltages by yourself. It should close to 3V.

RTC time isn't synced at startup

Kernel's hctosys works before RTC hardware initialized because the I2C/RTC drivers are working as a module.

You can edit /etc/rc.local to synchronize the HW RTC time with the system time at boot time.

Refer to the following codes. Of course, you can check the RTC device file is correct.

if [ -f /aafirstboot ]; then /aafirstboot start ; fi
 
hwclock -s -f /dev/rtc0
 
exit 0

In order to apply the changes, reboot your Odroid.

sudo reboot