Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
aports
aports
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 650
    • Issues 650
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 214
    • Merge Requests 214
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Repository
    • Value Stream
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • alpine
  • aportsaports
  • Issues
  • #9032

Closed
Open
Opened Jun 25, 2018 by Tyler A@tyler

Add hardware clock earlier Raspberry Pi

I have a Raspberry Pi operating as a router.

Normally the Raspberry Pi does not have an RTC clock, however one can be added as a module eg http://www.piface.org.uk/products/piface\_clock

In this wiki entry https://wiki.alpinelinux.org/wiki/Saving\_time\_with\_Hardware\_Clock it says to add to /etc/conf.d/hwclock

start_pre() {
    if [ -d "/sys/class/i2c-adapter/i2c-1/i2c-dev/i2c-1" ]; then
        einfo "Creating RTC device";
        echo mcp7941x 0x6f > /sys/class/i2c-adapter/i2c-1/new_device
    fi
}

I have to do this otherwise no RTC device is found. Could this be moved to a dtparam and then added in usercfg.txt?

I am noticing a couple of problems because the clock is added late:

  • The system time upon boot ie before OpenRC 0.35.5.87b1ff59 is starting up Linux 4.14.51-0-rpi2 (armv71) is obviously set to Jan 1 1970 which causes apk to think the cache is old. Therefore it tries to update it, which will never work because this system is a router and no WAN link exists. There doesn’t seem to be a way to turn that off.
  • OpenRC seems to have some issues with clockskew eg:

* /proc is already mounted
* Mounting /run …
* /run/openrc: creating directory
* /run/lock: creating directory
* /run/lock: correcting owner
* Caching service dependencies …
* Clock skew detected with `(null)’
* Adjusting mtime of `/run/openrc/deptree’ to
* WARNING: clock skew detected!

Then further down:

* Loading hardware drivers …
* rc is deprecated, please use openrc instead.
* WARNING: clock skew detected!
* Loading modules …
* Creating RTC device
* Setting system clock using the hardware clock [UTC] …
hwclock: settimeofday: Invalid argument
* Failed to set the system clock

I have observed:

# stat -c "%y %s %n" /run/openrc/*
1970-01-01 09:30:36.000000000 7 /run/openrc/clock-skewed
2018-06-25 00:56:45.000000000 280 /run/openrc/daemons
1970-01-01 09:30:36.000000000 11 /run/openrc/depconfig
2018-06-24 05:06:00.000000000 26866 /run/openrc/deptree
2018-06-25 00:56:45.000000000 40 /run/openrc/exclusive
1970-01-01 09:30:35.000000000 40 /run/openrc/failed
1970-01-01 09:30:35.000000000 40 /run/openrc/hotplugged
1970-01-01 09:30:35.000000000 40 /run/openrc/inactive
2018-06-25 00:56:45.000000000 260 /run/openrc/options
1970-01-01 09:30:35.000000000 40 /run/openrc/scheduled
1970-01-01 09:30:42.000000000 7 /run/openrc/softlevel
2018-06-25 00:56:45.000000000 640 /run/openrc/started
2018-06-25 00:56:45.000000000 40 /run/openrc/starting
2018-06-25 00:56:45.000000000 40 /run/openrc/stopping
1970-01-01 09:30:35.000000000 40 /run/openrc/tmp
1970-01-01 09:30:35.000000000 40 /run/openrc/wasinactive

Some of these files are dated to 1970-01-01.

I know the hwclock works because I can manually operate it from the terminal ie hwclock -s and hwclock -w.

(from redmine: issue id 9032, created on 2018-06-25)

To upload designs, you'll need to enable LFS and have admin enable hashed storage. More information
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: alpine/aports#9032