linuxboot / heads-wiki

Documentation for the Heads firmware project
84 stars 44 forks source link

RTC clock drifting problems - manual/automatic correction guides #103

Closed tlaurion closed 1 year ago

tlaurion commented 1 year ago

Not sure how that happeneds and from where (or if Mandala effect... Was that ever documented?!) , but I have found no reference under osresearch.net on ntp/skew/time/date to automatically set/manually correct time after first flash and/or in case of a bad RTC battery.

Bad RTC battery is a pretty common thing across second hand bought devices, but not as much impactful as under Heads, where valid time is needed to generate keys, sign and validate signed content and generate TOTP code which will be invalid if time skew can be of 20 years, unless synced from OS over network first thing when connected, sometimes going unnoticed per users but while still being problematic anyhow from a log perspective, if that only that matters.

There is currently no actual reference to network-recovery-init to sync time against router through NTP protocol. Nor manual instructions on fixing the time in case of https://github.com/osresearch/heads/issues/1021 (which is most probably a bad RTC clock battery, needing to be changed, but how users can know if not documented).

Menu options will permit to go to console, and give instructions in case of invalid TOTP code, but as https://github.com/osresearch/heads/issues/1021 shows us, there are real problems into not documenting this properly, since users may not reach Heads and therefore Heads menus to get to the console with proper instructions from that Heads menu option.

Basically, an Heads entree should be added under heads-wiki so that users can easily find what is documented under https://github.com/osresearch/heads/issues/1021#issuecomment-1158982540. Referenced through FAQ?

@githubuseravailable: where would you have loved to see that documented?

githubuseravailable commented 1 year ago

@tlaurion

maybe it's part of configuration, since most of 2nd hand device, will have bad RTC battery, but at the same time, it's also an issue.

so, maybe it's good idea to document it under heads-wiki, for heads issue already documented in 1021 with link to this ticket, under heads-wiki

tlaurion commented 1 year ago

https://github.com/osresearch/heads-wiki/pull/78 covers that, needs review and adaptation.

Fix fourth issue reported https://github.com/osresearch/heads/issues/1213#issuecomment-1248412613

githubuseravailable commented 1 year ago

@tlaurion

i have tried this 1st solution, in TOTP Mismatch

date -s hh:mm:ss && hwclock -w

but it will set the HW clock only, without setting the HW date, therefore the HW date still incorrect, maybe that's the reason why the TOTP still mismatch, even after setting the HW clock correctly

githubuseravailable commented 1 year ago

@tlaurion i tried

date -s 'yyyy-mm-dd hh:mm:ss' && hwclock -w

and now the date time has been set correctly, and TOTP finally match, maybe can add on into the wiki

tlaurion commented 1 year ago

Should have not been closed. PR should be modified accordingly to code changes upstream.

tlaurion commented 1 year ago

Sorry for the noise. PR that needs to be modified is here: https://github.com/osresearch/heads-wiki/pull/78