From e3dd8abedb2216e9ce30e74827ccfe5c13a12a5f Mon Sep 17 00:00:00 2001 From: Gauthier Provost Date: Wed, 13 May 2020 11:44:44 +0800 Subject: [PATCH] [ mvebu ] Switch fake-hwclock to hardware RTC AR-159 (#1946) * [ mvebu ] Switch fake-hwclock to hardware RTC AR-159 * remove fake-hwclock dpkg * tweak /lib/udev/hwclock-set to be executed even if systemd present * move helios4 bsp file under mvebu folder for tidiness --- .../families/include/mvebu-helios4.inc | 12 +++--- config/sources/families/mvebu.conf | 9 ++++- .../helios4/90-helios4-hwmon.rules | 0 packages/bsp/{ => mvebu}/helios4/armbian-motd | 0 .../{ => mvebu}/helios4/fancontrol.service | 0 .../helios4/fancontrol_pwm-fan.conf | 0 .../{ => mvebu}/helios4/helios4-wol.service | 0 .../{ => mvebu}/helios4/mdadm-fault-led.sh | 0 packages/bsp/mvebu/hwclock-set | 38 +++++++++++++++++++ 9 files changed, 52 insertions(+), 7 deletions(-) rename packages/bsp/{ => mvebu}/helios4/90-helios4-hwmon.rules (100%) rename packages/bsp/{ => mvebu}/helios4/armbian-motd (100%) rename packages/bsp/{ => mvebu}/helios4/fancontrol.service (100%) rename packages/bsp/{ => mvebu}/helios4/fancontrol_pwm-fan.conf (100%) rename packages/bsp/{ => mvebu}/helios4/helios4-wol.service (100%) rename packages/bsp/{ => mvebu}/helios4/mdadm-fault-led.sh (100%) create mode 100755 packages/bsp/mvebu/hwclock-set diff --git a/config/sources/families/include/mvebu-helios4.inc b/config/sources/families/include/mvebu-helios4.inc index 2f92a02ba..917f9a619 100644 --- a/config/sources/families/include/mvebu-helios4.inc +++ b/config/sources/families/include/mvebu-helios4.inc @@ -42,26 +42,26 @@ family_tweaks_bsp() ### Fancontrol tweaks # copy hwmon rules to fix device mapping - install -m 644 $SRC/packages/bsp/helios4/90-helios4-hwmon.rules $destination/etc/udev/rules.d/ + install -m 644 $SRC/packages/bsp/mvebu/helios4/90-helios4-hwmon.rules $destination/etc/udev/rules.d/ # copy fancontrol config - install -m 644 $SRC/packages/bsp/helios4/fancontrol_pwm-fan.conf $destination/etc/fancontrol - install -m 644 $SRC/packages/bsp/helios4/fancontrol.service $destination/etc/systemd/system/ + install -m 644 $SRC/packages/bsp/mvebu/helios4/fancontrol_pwm-fan.conf $destination/etc/fancontrol + install -m 644 $SRC/packages/bsp/mvebu/helios4/fancontrol.service $destination/etc/systemd/system/ ### Mdadm tweaks # copy mdadm-fault-led script and set right permission - install -m 755 $SRC/packages/bsp/helios4/mdadm-fault-led.sh $destination/usr/sbin + install -m 755 $SRC/packages/bsp/mvebu/helios4/mdadm-fault-led.sh $destination/usr/sbin ### Ethernet tweaks # copy and enable helios4-wol.service - install -m 644 $SRC/packages/bsp/helios4/helios4-wol.service $destination/lib/systemd/system/ + install -m 644 $SRC/packages/bsp/mvebu/helios4/helios4-wol.service $destination/lib/systemd/system/ ### Other tweaks # add custom motd default conf file - install -m 644 $SRC/packages/bsp/helios4/armbian-motd $destination/etc/default/ + install -m 644 $SRC/packages/bsp/mvebu/helios4/armbian-motd $destination/etc/default/ # create modules file if [[ $BRANCH == dev && -n $MODULES_DEV ]]; then diff --git a/config/sources/families/mvebu.conf b/config/sources/families/mvebu.conf index 5d27408c5..00089f91d 100644 --- a/config/sources/families/mvebu.conf +++ b/config/sources/families/mvebu.conf @@ -53,5 +53,12 @@ family_tweaks() # execute specific tweaks function if present [[ $(type -t family_tweaks_s) == function ]] && family_tweaks_s - chroot $SDCARD /bin/bash -c "apt-get -y -qq remove --auto-remove linux-sound-base alsa-base alsa-utils bluez>/dev/null 2>&1" + # Tweak to force SYS time to be synced from RTC at startup + install -m 755 $SRC/packages/bsp/mvebu/hwclock-set $SDCARD/lib/udev/ + + if [[ $DISTRIBUTION == "Ubuntu" ]]; then + chroot $SDCARD /bin/bash -c "apt-get -y -qq remove --auto-remove fake-hwclock linux-sound-base alsa-base alsa-utils bluez" + else + chroot $SDCARD /bin/bash -c "apt-get -y -qq remove --auto-remove fake-hwclock alsa-utils bluez" + fi } diff --git a/packages/bsp/helios4/90-helios4-hwmon.rules b/packages/bsp/mvebu/helios4/90-helios4-hwmon.rules similarity index 100% rename from packages/bsp/helios4/90-helios4-hwmon.rules rename to packages/bsp/mvebu/helios4/90-helios4-hwmon.rules diff --git a/packages/bsp/helios4/armbian-motd b/packages/bsp/mvebu/helios4/armbian-motd similarity index 100% rename from packages/bsp/helios4/armbian-motd rename to packages/bsp/mvebu/helios4/armbian-motd diff --git a/packages/bsp/helios4/fancontrol.service b/packages/bsp/mvebu/helios4/fancontrol.service similarity index 100% rename from packages/bsp/helios4/fancontrol.service rename to packages/bsp/mvebu/helios4/fancontrol.service diff --git a/packages/bsp/helios4/fancontrol_pwm-fan.conf b/packages/bsp/mvebu/helios4/fancontrol_pwm-fan.conf similarity index 100% rename from packages/bsp/helios4/fancontrol_pwm-fan.conf rename to packages/bsp/mvebu/helios4/fancontrol_pwm-fan.conf diff --git a/packages/bsp/helios4/helios4-wol.service b/packages/bsp/mvebu/helios4/helios4-wol.service similarity index 100% rename from packages/bsp/helios4/helios4-wol.service rename to packages/bsp/mvebu/helios4/helios4-wol.service diff --git a/packages/bsp/helios4/mdadm-fault-led.sh b/packages/bsp/mvebu/helios4/mdadm-fault-led.sh similarity index 100% rename from packages/bsp/helios4/mdadm-fault-led.sh rename to packages/bsp/mvebu/helios4/mdadm-fault-led.sh diff --git a/packages/bsp/mvebu/hwclock-set b/packages/bsp/mvebu/hwclock-set new file mode 100755 index 000000000..d503fefa6 --- /dev/null +++ b/packages/bsp/mvebu/hwclock-set @@ -0,0 +1,38 @@ +#!/bin/sh +# Reset the System Clock to UTC if the hardware clock from which it +# was copied by the kernel was in localtime. + +dev=$1 + +# Armbian Tweak - Execute even if systemd is present +#if [ -e /run/systemd/system ] ; then +# exit 0 +#fi + +if [ -e /run/udev/hwclock-set ]; then + exit 0 +fi + +if [ -f /etc/default/rcS ] ; then + . /etc/default/rcS +fi + +# These defaults are user-overridable in /etc/default/hwclock +BADYEAR=no +HWCLOCKACCESS=yes +HWCLOCKPARS= +HCTOSYS_DEVICE=rtc0 +if [ -f /etc/default/hwclock ] ; then + . /etc/default/hwclock +fi + +if [ yes = "$BADYEAR" ] ; then + /sbin/hwclock --rtc=$dev --systz --badyear + /sbin/hwclock --rtc=$dev --hctosys --badyear +else + /sbin/hwclock --rtc=$dev --systz + /sbin/hwclock --rtc=$dev --hctosys +fi + +# Note 'touch' may not be available in initramfs +> /run/udev/hwclock-set