Date command in U-boot

Source: Internet
Author: User

[U-boot: v2013.07-RC3]

[Author: Bo Shen <voice.shen@gmail.com>]

1. enable the date command

It needs to be defined: config_1__date. Because the date command reads the time in RTC, you must use the relevant SOC built-in RTC driver or the RTC chip on the board. Depends on the board.
. After both of them are combined, you can enable the date command.

Source code: <Common/cmd_date.c>

2.
Use of the date command

The 2.1 date command, without parameters, reads the RTC time and displays it in readable format.

The 2.2 date command carries parameters to set the RTC time.

2.2.1 set the RTC time to: January 1, July 19

Date 07192250

3. Source Code Analysis

Do_date

| --> Define an rtc_time <include/RTC. h> struct

| --> Set the correct I2C bus. (For RTC on chip, the value 0 is always returned here)

| --> Determine the number of parameters of the date command.

| --> If it is one, it is the display time. Call the rtc_get function. If reading fails, the system displays the error message and exits.

| --> If there are two, further judgment is made.

| --> For reset, The rtc_reset function is called after "Reset RTC..." Is output.

| --> If it is not a reset, call the ret_get function to obtain the time. If it is correct, use mk_date to convert the parameter of the date command to the rtc_time struct. Finally, call the rtc_set function.

Note: From the code analysis above, we can find that in U-boot, to implement the RTC driver, you only need to implement rtc_get,
Rtc_reset,
You can use the rtc_set function.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.