In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
In this issue, the editor will bring you an example analysis of iTOP-iMX6 real-time clock RTC and Linux-c testing. The article is rich in content and analyzed and described from a professional point of view. I hope you can get something after reading this article.
When Linux developers talk about a real-time clock, they usually mean something that records wall time and has backup power.
A device that works even when the system is turned off.
Linux has two widely compatible series of user-space RTC device nodes:
/ dev/rtc: RTC interface provided by PC and compatible systems, which is not for non-x86 systems
It's light.
/ dev/rtc0,/dev/rtc1: is part of the framework supported by various RTC chips on various systems.
The iTOP-iMX6 development board supports both of the above, and the device nodes correspond to "/ dev/rtc" and "/ dev/rtc0".
The kernel image of the iTOP-iMX6 development board supports real-time clocks by default, as well as button batteries, as shown in the following figure.
If the user indicates that SF airfreight is required at the time of purchase, then the development board should not have a button battery.
The number is cr1220, and users can buy it by themselves.
ITOP-iMX6 's real-time clock RTC driver is the "drivers/rtc/rtc*" file in the kernel directory, as shown in the following figure
Show.
There is a "topeet_rtctest.tar.gz" in the package, which has source code and binaries. The source file contains the
The real-time clock and the code that prints out the real-time clock time.
If the user needs to set the time in the code, you need to use commands such as date and hwclock. If you need to use the code
You can use the function "settimeofday" to add the command to set time in the, but in most cases, directly in the code
Just call the date and hwclock commands. In addition, to call the linux command in the program, you can refer to the "iTOP- development board -"
The MiniLinux-C program calls the shell command and the iTOP- development board-QtE- calls the shell command to use the document.
First test the command line setting time and test.
As shown in the following figure, you can use the "date" command to view the system time directly, after power on (power off, unload)
Button battery, power on), the default time is "Thu Jan 1 08:02:30 CST 1970".
Use the command "date-s" 2019-07-27 10:06:00 "" to set the system time, followed by the command "date"
You can find that the system time has been updated, and then use the command "hwclock-- systohc" to synchronize the system time to the RTC real
The clock, as shown in the following figure.
Install the button battery, power off and power on, use the command "date", the time is still 2019, indicating the real-time clock
It worked.
Test program read time test
As shown in the following figure, iTOP-iMX6 's real-time clock, device node and "/ dev/rtc0" can be called normally.
The test program topeet_rtctest needs to pass the device node. If you do not pass the device node, the default is
"/ dev/rtc0", so it works by default, as shown in the following figure, using the command ". / topeet_rtctest"
Line program.
Finally, test the "/ dev/rtc" node, as shown in the following figure, using the command
". / topeet_rtctest / dev/rtc", device node "/ dev/rtc" can also run normally.
The above is the example analysis of iTOP-iMX6 real-time clock RTC and Linux-c test shared by Xiaobian. If you happen to have similar doubts, please refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.