HOME
  • GM-3568JHF
  • M4-R1
  • M5-R1
  • SC-3568HA
  • M-K1HSE
  • CF-NRS1
  • CF-CRA2
  • 1684XB-32T
  • 1684X-416T
  • C-3568BQ
  • C-3588LQ
  • GC-3568JBAF
  • C-K1BA
Shop
  • English
  • 简体中文
HOME
  • GM-3568JHF
  • M4-R1
  • M5-R1
  • SC-3568HA
  • M-K1HSE
  • CF-NRS1
  • CF-CRA2
  • 1684XB-32T
  • 1684X-416T
  • C-3568BQ
  • C-3588LQ
  • GC-3568JBAF
  • C-K1BA
Shop
  • English
  • 简体中文
  • SC-3568HA

    • Introduction

      • SC-3568HA Overview
    • Quick Start Guide

      • OpenHarmony Overview
      • Image Flashing
      • Setting Up the Development Environment
      • Hello World Application and Deployment
    • Application Development

      • ArkUI

        • Chapter 1 Introduction to ArkTS Language
        • Chapter 2 Introduction to UI Components and Practical Applications (Part 1)
        • Chapter 3 Introduction to UI Components and Practical Applications (Part 2)
        • Chapter 4 Introduction to UI Components and Practical Applications (Part 3)
      • Expand

        • Chapter 1 Getting Started Guide
        • Chapter 2 Referencing and Using Third-Party Libraries
        • Chapter 3: Application Compilation and Deployment
        • Chapter 4: Command-Line Factory Reset
        • Chapter 5: System Debugging -- HDC (Huawei Device Connector) Debugging
        • Chapter 6 APP Stability Testing
        • Chapter 7 Application Testing
    • Device Development

      • Chapter 1 Environment Setup
      • Chapter 2 Download Source Code
      • Chapter 3 Compiling Source Code
    • Peripheral And Iinterface

      • Raspberry Pi interface
      • GPIO Interface
      • I2C Interface
      • SPI communication
      • PWM (Pulse Width Modulation) control
      • Serial port communication
      • TF Card
      • Display Screen
      • Touch
      • Audio
      • RTC
      • Ethernet
      • M.2
      • MINI-PCIE
      • Camera
      • WIFI&BT
      • Raspberry Pi expansion board
    • Frequently Asked Questions

      • Resource Downloads
  • M-K1HSE

    • Introduction

      • M-K1HSE Introduction
    • Quick Start

      • Development environment construction
      • Source code acquisition
      • Compilation Notes
      • Burning Guide
    • Peripherals and interfaces

      • 01 Audio
      • 02 RS485
      • 03 Display
    • System customization development

      • System transplant
      • System customization
      • Driver Development
      • System Debugging
      • OTA Update

RTC

RTC stands for Real Time Clock. It is a hardware device specially used to record time. It can usually be integrated into the soc, or selected as an external plug-in to communicate with it through i2c.

So why do we need RTC? Because the Linux system time (also known as wall time) can only be used when the system is running. The time is lost when the system is shut down. RTC can continue to work after the system is shut down, relying on an external battery or other supply, thus saving the time.

1. Use of RTC

Taking SC-3568HA as an example, this board uses an external RTC (hym8563) and the RTC function of rk809 is turned off by default.

When using an external RTC, a button battery is required

TOOL

2. RTC user interface call

Linux provides three user space calling interfaces. The corresponding paths in the board are:

  • SYSFS interface: /sys/class/rtc/rtc0/
  • PROCFS interface: /proc/driver/rtc
  • IOCTL interface: /dev/rtc0

SYSFS Interface:

    # cat /sys/class/rtc/rtc0/date
    2024-10-21
    # cat /sys/class/rtc/rtc0/time
    09:48:46

Tips

In case of the "Invalid argument" returned by the cat command, you need to enter the system settings first and set the time.

PROCFS interface:

    # cat /proc/driver/rtc
    rtc_time        : 09:50:05
    rtc_date        : 2024-10-21
    alrm_time       : 00:00:00
    alrm_date       : 1970-01-01
    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

IOCTL interface:

You can use ioctl to control /dev/rtc0

3. Commonly used commands for clocks

    date          //修改系统时钟,具体命令使用可以man下
    hwclock -s    //将硬件时间同步到系统时间
    hwclock -w    //将系统时间同步到硬件时间

     date "2023-08-14 08:00:00"  //手动设置时间
     hwclock -w     //系统时间同步到硬件rtc
     hwclock -s    //硬件rtc同步到系统
    #以上手动设置时间或者网络同步时间后,-w将系统时间写入到硬件rtc,-s再将rtc时间写回系统,这样每次重启板卡都会进行rtc时间同步到系统时间。

Edit this page on GitHub
Last Updated:
Contributors: zsl, zwhuang
Prev
Audio
Next
Ethernet