[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.