Personal tools

DART-MX8M RTC

From Variscite Wiki

Jump to: navigation, search


DART-MX8M - Real Time Clock (RTC)


1 Setting the RTC

First set the system date & time:

# date --set="20171231 23:59"

Then set the HW RTC using the system date & time:

# hwclock --systohc --utc


Power down your board, wait 5 minutes and power up again, then check you system date & time and verify it is correct:

# date

2 Wake-up using the RTC

Wake-up using the RTC requires hardware connection of RTC IRQ pin to a SoC GPIO (on DART-MX8M carrier board this is GPIO1_15).
Configure your kernel and add relevant RTC driver. For DART-MX8M carrier this is Device Drivers -> Real Time Clock -> <*> Dallas/Maxim DS1307/37/38/39/40, ST M41T00, EPSON RX-8025, ISL12057.
Edit arch/arm64/boot/dts/freescale/fsl-imx8mq-var-dart-common.dtsi under Linux kernel source directory:

&i2c2 {
	...
	rtc@0x68 {
		status = "okay";
 		compatible = "dallas,ds1337";
		reg = <0x68>;
		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_rtc>;
		interrupt-parent = <&gpio1>;
		interrupts = <15 IRQ_TYPE_EDGE_FALLING>;
        };
        ...
};

&iomuxc {
	...
	imx8m-var-dart {
                ...
		 pinctrl_rtc: rtcgrp {
			fsl,pins = <
				MX8MQ_IOMUXC_GPIO1_IO15_GPIO1_IO15 		0xc1
			>;
		};
                ...
};

Follow the "Build Linux from source code" guide to build the kernel and device trees and to copy them to your SD card. Don't forget to also build and install the kernel modules.
For example, to set the RTC to wakeup after 10 seconds type:

# echo enabled > /sys/class/rtc/rtc0/device/power/wakeup
# rtcwake -m mem -d rtc0 -s 10

For more options, like waking up at a specific time, run:

# rtcwake --help