[PATCH 2/2] rtc: initialize emulated RTC from environment variable

Simon Glass sjg at chromium.org
Tue Nov 3 16:12:02 CET 2020


On Thu, 29 Oct 2020 at 21:20, Heinrich Schuchardt <xypron.glpk at gmx.de> wrote:
>
> Up to now the emulated RTC is initialized using the U-Boot build time.
>
> With this patch the environment variable 'rtc_emul_epoch' can be used to
> provide a better initial time. The variable is a decimal string with
> the number of seconds since 1970-01-01. Here is an example where the RTC
> had not been probed yet:
>
>     => setenv rtc_emul_epoch 1610109000
>     => date
>     Date: 2021-01-08 (Friday)    Time: 12:30:00
>
> If the variable does not exist, the U-Boot build time is used as fallback.
>
> The environment variable may be set when shutting down the operating system
> if the U-Boot environment is exposed to the OS (cf. ENV_IS_IN_FAT and
> ENV_IS_IN_EXT4).
>
> Suggested-by: Pablo Sebastián Greco <pgreco at centosproject.org>
> Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
> ---
>  drivers/rtc/Kconfig    | 13 ++++++++-----
>  drivers/rtc/emul_rtc.c | 16 +++++++++++++---
>  2 files changed, 21 insertions(+), 8 deletions(-)

Reviewed-by: Simon Glass <sjg at chromium.org>


More information about the U-Boot mailing list