-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
enhancementNew feature or requestNew feature or requestquestionFurther information is requestedFurther information is requested
Description
Description
Add time synchronization service that runs on first boot to ensure accurate system time.
Problem
Raspberry Pi doesn't have RTC, so time is wrong on first boot until NTP sync occurs.
Implementation
1. Systemd Service
# first-boot-timesync.service
[Unit]
Description=First Boot Time Sync
After=network-online.target
Wants=network-online.target
ConditionFirstBoot=yes
[Service]
Type=oneshot
ExecStart=/usr/bin/timedatectl set-ntp true
ExecStart=/usr/bin/systemctl restart systemd-timesyncd
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target2. NTP Configuration
# /etc/systemd/timesyncd.conf
[Time]
NTP=time.google.com time.cloudflare.com
FallbackNTP=0.pool.ntp.org 1.pool.ntp.org3. Recipe
# time-sync.bb
SUMMARY = "First boot time synchronization"
LICENSE = "MIT"
SRC_URI = " \
file://first-boot-timesync.service \
file://timesyncd.conf \
"
inherit systemd
do_install() {
install -d ${D}${systemd_unitdir}/system
install -m 0644 ${WORKDIR}/first-boot-timesync.service \
${D}${systemd_unitdir}/system/
install -d ${D}${sysconfdir}/systemd
install -m 0644 ${WORKDIR}/timesyncd.conf \
${D}${sysconfdir}/systemd/
}
SYSTEMD_SERVICE:${PN} = "first-boot-timesync.service"
SYSTEMD_AUTO_ENABLE:${PN} = "enable"Acceptance Criteria
- Time syncs automatically on first boot
- Uses reliable NTP servers
- Falls back to pool.ntp.org if primary fails
- Only runs on first boot (ConditionFirstBoot)
- Logs sync status for debugging
- Works without manual intervention
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestquestionFurther information is requestedFurther information is requested