zoukankan      html  css  js  c++  java
  • 开发板的时间设置有效,但重启恢复

    使用开发板时,发现RTC的时间总是被设置为2015年11月30日11时30分,无论如何设置,通过hwclock -w或程序修改RTC芯片,修改之后时间和RTC时间均正确,但是断电重启之后,时间又变为2015年11月30日11时30分。

           通过分析和查找发现/etc/目录下的timestamp比较可疑,其值正是113011302015,于是查找包含它的文件有两个,分别为:/etc/init.d目录下的bootmisc.sh和save-rtc.sh。
           其中,bootmisc.sh中有如下内容:
    # Set the system clock from hardware clock
    # If the timestamp is 1 day or more recent than the current time,
    # use the timestamp instead.
    test -x /etc/init.d/hwclock.sh && /etc/init.d/hwclock.sh start
    if test -e /etc/timestamp
    then
    SYSTEMDATE=`date "+%Y%m%d"`
    TIMESTAMP=`cat /etc/timestamp | awk '{ print substr($0,9,4) substr($0,1,4);}'`
            NEEDUPDATE=`expr ( $TIMESTAMP > $SYSTEMDATE )`
            if [ $NEEDUPDATE -eq 1 ]; then
    date `cat /etc/timestamp`
    /etc/init.d/hwclock.sh stop
    fi
    fi
           上面的脚本会判断文件/etc/timestamp存在与否,且将里面的时间戳与当前系统时间进行比较,如果timestamp的时间比系统时间新1天或以上,则会使用timestamp,并将其写入RTC时间中。
           脚本save-rtc.sh中有如下内容:
    #! /bin/sh
    /etc/init.d/hwclock.sh stop
     
    # Update the timestamp
    date +%2m%2d%2H%2M%Y > /etc/timestamp
           上面的脚本会将当前时间写入timestamp中。
           同时,bootmis.sh脚本被链接到rcS.d中的S55bootmis.sh中,在系统启动时执行,而脚本save-rtc.sh则被链接到rc0.d和rc6.d文件夹中,在系统关闭和重启时执行。
           所以要解决上面的问题,只需:
    1、修改/etc/timestamp,使其小于或等于当前系统时间。
    2、正常关闭或重启系统而不是直接断电。
     
  • 相关阅读:
    ThinkPHP5 API 文档
    【转】移动web页面使用字体的思考
    【原】移动web页面兼容处理的思考
    20140829分享正则大纲
    javascript reverse string
    备忘“与”、“非”、“或”、“异或” 运算
    关于 Apple Metal API 的一些想法
    transform:rotate在手机上显示有锯齿的解决方案
    JS正则表达式验证数字(很全)
    去掉 wap (android/ios)网页等点击后的阴影
  • 原文地址:https://www.cnblogs.com/pengkunfan/p/3843837.html
Copyright © 2011-2022 走看看