Skip to content
Snippets Groups Projects

fng-install:rtc: Added device check to RTC post-install

Merged Tobias Kahlki requested to merge fix_rtc_postinst into dunfell
1 file
+ 12
3
Compare changes
  • Side-by-side
  • Inline
@@ -10,15 +10,22 @@ if ! . /usr/sbin/gf-prepare-common.sh; then
fi
poll_rtc() {
# Check if there is an I2C device at the know bus and address.
# If the tool returns 'Device or resource busy' we assume a
# driver has grabed the existing RTC device.
if i2cget -y 2 "$1" 0x00 2>&1 | grep -E '.*0x.*|.*Device or resource busy.*'; then
echo "Device found at address $1"
return 0
else
echo "No device found at address $1"
return 1
fi
}
# The RTC detection only applies to the Tanaro at the moment.
if ! grep -q -i Tanaro /sys/devices/soc0/machine; then
echo "The device is not a 'Tanaro'; Skipping the RTC detection ..."
exit 0
fi
# Get the directory containing the bootfiles
mount_bootpartition BOOTFILES_DIR
@@ -27,13 +34,15 @@ cd "$BOOTFILES_DIR" || exit 1
# RX8803
if poll_rtc 0x32; then
echo "Selecting overlay 'rx8803-overlay.dtb'"
append_overlay "rx8803-overlay.dtb"
else
# PCF8563
if poll_rtc 0x51; then
echo "Selecting overlay 'pcf8563-overlay.dtb'"
append_overlay "pcf8563-overlay.dtb"
else
echo "Error: Unable to find any valid device"
echo "Error: Unable to find any valid RTC device, not applying any overlay."
exit 1
fi
fi
Loading