Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bcm2711_defconfig: include CONFIG_RTC_HCTOSYS=y to automatically set system time from rtc on cm4io #4205

Closed
kralo opened this issue Mar 11, 2021 · 7 comments

Comments

@kralo
Copy link

kralo commented Mar 11, 2021

Considering f9b2a4d

rtc: class: support hctosys from modular RTC drivers

Due to distribution constraints it may not be possible to statically
compile the required RTC driver into the kernel.

Expand RTC_HCTOSYS support to cover all RTC devices (statically compiled
or not) by checking at the end of RTC device registration whether the
time should be synced.

I suggest to include

CONFIG_RTC_HCTOSYS=y
CONFIG_RTC_HCTOSYS_DEVICE="rtc0"

in the default kernel configuration. I have done so and compiled a kernel for CM4 (b03140 on a cm4io-board), which additionally has dtoverlay=i2c-rtc,pcf85063a,i2c_csi_dsi in config.txt

This works very well and spares of hwclock -r - shenanigans.

I have verified it works well on cm4 (note my kernel is additionally built with CONFIG_RTC_DEBUG=y for more verbose messages)

# dmesg | grep -iP 'rtc|0311' 
[    0.000000] Linux version 5.10.20-v7l-0311+ (pi@raspberrypi) (gcc (Raspbian 8.3.0-6+rpi1) 8.3.0, GNU ld (GNU Binutils for Raspbian) 2.31.1) #1 SMP Thu Mar 11 12:33:33 CET 2021
[    5.442072] usb usb1: Manufacturer: Linux 5.10.20-v7l-0311+ dwc2_hsotg
[    6.635833] rtc-pcf85063 10-0051: pcf85063_probe
[    6.662836] rtc-pcf85063 10-0051: char device (252:0)
[    6.662873] rtc-pcf85063 10-0051: registered as rtc0
[    6.665400] rtc-pcf85063 10-0051: setting system clock to 2021-03-11T14:39:59 UTC (1615473599)

and have verified it has no adverse effects on rpi without rtc, in this case rpi4b. There the first timejump is from systemd-timesyncd (without internet connection, from saved timestamp).

Feb 14 11:12:02 raspberrypi systemd[1]: Received SIGRTMIN+20 from PID 157 (plymouthd).
Feb 14 11:12:02 raspberrypi systemd[1]: plymouth-read-write.service: Succeeded.
Feb 14 11:12:02 raspberrypi systemd[1]: Started Tell Plymouth To Write Out Runtime Data.
Feb 14 11:12:02 raspberrypi systemd-timesyncd[314]: System clock time unset or jumped backwards, restoring from recorded timestamp: Thu 2021-03-11 12:11:43 CET
Mär 11 12:11:43 raspberrypi systemd-udevd[152]: Process '/usr/sbin/th-cmd --socket /var/run/thd.socket --passfd --udev' failed with exit code 1.

config diff for reference

$ diff config_*
3c3
< # Linux/arm 5.10.20 Kernel Configuration
---
> # Linux/arm 5.10.17 Kernel Configuration
5c5
< CONFIG_CC_VERSION_TEXT="gcc (Raspbian 8.3.0-6+rpi1) 8.3.0"
---
> CONFIG_CC_VERSION_TEXT="arm-linux-gnueabihf-gcc-8 (Ubuntu/Linaro 8.4.0-3ubuntu1) 8.4.0"
7,8c7,8
< CONFIG_GCC_VERSION=80300
< CONFIG_LD_VERSION=231010000
---
> CONFIG_GCC_VERSION=80400
> CONFIG_LD_VERSION=234000000
23c23
< CONFIG_LOCALVERSION="-v7l-0311"
---
> CONFIG_LOCALVERSION="-v7l"
217d216
< CONFIG_KCMP=y
1963,1964c1962,1963
< CONFIG_NVME_CORE=y
< CONFIG_BLK_DEV_NVME=y
---
> CONFIG_NVME_CORE=m
> CONFIG_BLK_DEV_NVME=m
5924,5925c5923
< CONFIG_RTC_HCTOSYS=y
< CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
---
> # CONFIG_RTC_HCTOSYS is not set
5928c5926
< CONFIG_RTC_DEBUG=y
---
> # CONFIG_RTC_DEBUG is not set
6870a6869
> # CONFIG_USB_LGM_PHY is not set

@pelwell

pelwell added a commit that referenced this issue Mar 11, 2021
The recently improved RTC_HCTOSYS option now works with RTC drivers in
modules, making it much more useful in that it removes the need to run
hwclock -s in order to synchronise the system clock.

See: #4205

Signed-off-by: Phil Elwell <[email protected]>
@pelwell
Copy link
Contributor

pelwell commented Mar 11, 2021

Thanks - f9b2a4d makes me wonder why it wasn't always implemented this way. See 4413b6e.

@kralo
Copy link
Author

kralo commented Mar 11, 2021

confused about 4413b6e
Your Commit Message says configs: Add CONFIG_RTS_HCTOSYS=y but the referenced commit only removes comment lines? Is there some kind of magic? Don't you need to explicitly set it to =y ?

@pelwell
Copy link
Contributor

pelwell commented Mar 11, 2021

defconfig files only contain differences from the norm, which is helpful when new options are added (but does have a few pitfalls). In the case of RTC_HCTOSYS the default is y, so all we have to do is not unset it.

pelwell added a commit that referenced this issue Mar 11, 2021
The recently improved RTC_HCTOSYS option now works with RTC drivers in
modules, making it much more useful in that it removes the need to run
hwclock -s in order to synchronise the system clock.

See: #4205

Signed-off-by: Phil Elwell <[email protected]>
@kralo
Copy link
Author

kralo commented Mar 11, 2021

Your handling of this issue has been a delight - fast and knowledgeable: Thank you very much!
Do you expect me to close this?

@pelwell
Copy link
Contributor

pelwell commented Mar 11, 2021

That's the usual way things work here, but I can save you the trouble this time.

@pelwell pelwell closed this as completed Mar 11, 2021
popcornmix added a commit to raspberrypi/firmware that referenced this issue Mar 15, 2021
kernel: drm/vc4: crtc: Reduce PV fifo threshold on hvs4
See: raspberrypi/linux#4207

kernel: vc4/drm: Adjustments to hdmi audio dma to reduce glitches
See: raspberrypi/linux#4208

kernel: overlays: gpio-led: new overlay
See: raspberrypi/linux#4206

kernel: bcm2835-codec tweaks
See: raspberrypi/linux#4113

kernel: Assign crypto aliases to different AES implementation modules
See: raspberrypi/linux#4198

kernel: media: bcm2835-unicam: Fix bug in buffer swapping logic
See: raspberrypi/linux#4189

kernel: configs: Add CONFIG_RTS_HCTOSYS=y
See: raspberrypi/linux#4205

kernel: overlays: Improve the i2c-rtc,i2c_csi_dsi option

firmware: video_decode: For VC1/WMV with no signalled header bytes, use start of 1st buffer
See: raspberrypi/linux#4113
popcornmix added a commit to Hexxeh/rpi-firmware that referenced this issue Mar 15, 2021
kernel: drm/vc4: crtc: Reduce PV fifo threshold on hvs4
See: raspberrypi/linux#4207

kernel: vc4/drm: Adjustments to hdmi audio dma to reduce glitches
See: raspberrypi/linux#4208

kernel: overlays: gpio-led: new overlay
See: raspberrypi/linux#4206

kernel: bcm2835-codec tweaks
See: raspberrypi/linux#4113

kernel: Assign crypto aliases to different AES implementation modules
See: raspberrypi/linux#4198

kernel: media: bcm2835-unicam: Fix bug in buffer swapping logic
See: raspberrypi/linux#4189

kernel: configs: Add CONFIG_RTS_HCTOSYS=y
See: raspberrypi/linux#4205

kernel: overlays: Improve the i2c-rtc,i2c_csi_dsi option

firmware: video_decode: For VC1/WMV with no signalled header bytes, use start of 1st buffer
See: raspberrypi/linux#4113
@nullr0ute
Copy link
Contributor

I only had a quick look but you likely also want to add the matching config pair to this which is the option to sync from from the system to the hardware clock (no, I've no idea why it's not implemented as part of the same config option):
CONFIG_RTC_SYSTOHC=y
CONFIG_RTC_SYSTOHC_DEVICE="rtc0"

@pelwell
Copy link
Contributor

pelwell commented Mar 16, 2021

Have a quick look at the .config file instead.

popcornmix pushed a commit that referenced this issue Mar 16, 2021
The recently improved RTC_HCTOSYS option now works with RTC drivers in
modules, making it much more useful in that it removes the need to run
hwclock -s in order to synchronise the system clock.

See: #4205

Signed-off-by: Phil Elwell <[email protected]>
popcornmix pushed a commit that referenced this issue Mar 22, 2021
The recently improved RTC_HCTOSYS option now works with RTC drivers in
modules, making it much more useful in that it removes the need to run
hwclock -s in order to synchronise the system clock.

See: #4205

Signed-off-by: Phil Elwell <[email protected]>
popcornmix pushed a commit that referenced this issue Mar 29, 2021
The recently improved RTC_HCTOSYS option now works with RTC drivers in
modules, making it much more useful in that it removes the need to run
hwclock -s in order to synchronise the system clock.

See: #4205

Signed-off-by: Phil Elwell <[email protected]>
popcornmix pushed a commit that referenced this issue Apr 6, 2021
The recently improved RTC_HCTOSYS option now works with RTC drivers in
modules, making it much more useful in that it removes the need to run
hwclock -s in order to synchronise the system clock.

See: #4205

Signed-off-by: Phil Elwell <[email protected]>
popcornmix pushed a commit that referenced this issue Apr 19, 2021
The recently improved RTC_HCTOSYS option now works with RTC drivers in
modules, making it much more useful in that it removes the need to run
hwclock -s in order to synchronise the system clock.

See: #4205

Signed-off-by: Phil Elwell <[email protected]>
popcornmix pushed a commit that referenced this issue Apr 27, 2021
The recently improved RTC_HCTOSYS option now works with RTC drivers in
modules, making it much more useful in that it removes the need to run
hwclock -s in order to synchronise the system clock.

See: #4205

Signed-off-by: Phil Elwell <[email protected]>
popcornmix pushed a commit that referenced this issue Apr 30, 2021
The recently improved RTC_HCTOSYS option now works with RTC drivers in
modules, making it much more useful in that it removes the need to run
hwclock -s in order to synchronise the system clock.

See: #4205

Signed-off-by: Phil Elwell <[email protected]>
popcornmix pushed a commit that referenced this issue May 7, 2021
The recently improved RTC_HCTOSYS option now works with RTC drivers in
modules, making it much more useful in that it removes the need to run
hwclock -s in order to synchronise the system clock.

See: #4205

Signed-off-by: Phil Elwell <[email protected]>
popcornmix pushed a commit that referenced this issue May 13, 2021
The recently improved RTC_HCTOSYS option now works with RTC drivers in
modules, making it much more useful in that it removes the need to run
hwclock -s in order to synchronise the system clock.

See: #4205

Signed-off-by: Phil Elwell <[email protected]>
popcornmix pushed a commit that referenced this issue May 19, 2021
The recently improved RTC_HCTOSYS option now works with RTC drivers in
modules, making it much more useful in that it removes the need to run
hwclock -s in order to synchronise the system clock.

See: #4205

Signed-off-by: Phil Elwell <[email protected]>
Noltari pushed a commit to Noltari/rpi-linux that referenced this issue Aug 20, 2021
The recently improved RTC_HCTOSYS option now works with RTC drivers in
modules, making it much more useful in that it removes the need to run
hwclock -s in order to synchronise the system clock.

See: raspberrypi#4205

Signed-off-by: Phil Elwell <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants