Skip to content

Commit

Permalink
hostapp-update-hooks: use os logging functions
Browse files Browse the repository at this point in the history
Changelog-entry: use os logging functions in update hooks
Signed-off-by: Alex Gonzalez <alexg@balena.io>
  • Loading branch information
alexgg committed Apr 29, 2024
1 parent 7b7205d commit 7dcff92
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

set -o errexit

. /usr/libexec/os-helpers-logging

CURR_IMG=pieeprom-current.bin.tmp
CURR_IMG_PATH=/dev/shm
NEW_IMG=pieeprom-latest-stable.bin
Expand All @@ -22,14 +24,14 @@ function spi_modules() {
rmmod spidev
rmmod spi-bcm2835
else
echo "[WARN] spi_modules: no arugment provided"
warn "spi_modules: no arugment provided"
fi
}

# According to documentation, custom EEPROM update scripts
# must also check for FREEZE_VERSION flag
if [ $(/usr/bin/vcgencmd bootloader_config | grep "FREEZE_VERSION=1" || true) ]; then
echo "[WARN] Bootloader config contains FREEZE_VERSION=1. Will NOT update SPI EEPROM firmware!"
warn "Bootloader config contains FREEZE_VERSION=1. Will NOT update SPI EEPROM firmware!"
exit 0
fi

Expand All @@ -47,9 +49,9 @@ curr_eeprom_md5sum=$(md5sum ${CURR_IMG_PATH}/${CURR_IMG} | awk '{print $1}')
new_eeprom_md5sum=$(md5sum ${NEW_IMG_PATH}/${NEW_IMG} | awk '{print $1}')

if [ $curr_eeprom_md5sum = $new_eeprom_md5sum ]; then
echo "[INFO] SPI EEPROM fw update is not necessary"
info "SPI EEPROM fw update is not necessary"
else
echo "[INFO] Performing SPI EEPROM fw update..."
info "Performing SPI EEPROM fw update..."
flashrom -p "linux_spi:dev=/dev/spidev0.0,spispeed=${SPI_SPEED}" --write ${NEW_IMG_PATH}/${NEW_IMG}
fi

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
set -o errexit

. /usr/sbin/balena-config-vars
. /usr/libexec/os-helpers-logging

DURING_UPDATE=${DURING_UPDATE:-0}

Expand All @@ -17,8 +18,8 @@ if [ "$DURING_UPDATE" = "1" ]; then
# instead as all future roots will have the kernel in root partition in /boot
# This leaves the kernel lying around in boot partition until the next HUP
if [ -e "/boot/zImage" ]; then
printf "[INFO] u-boot boot.scr now reads kernel from root partitions but found zImage in boot \n"
printf "[INFO] removing $BALENA_BOOT_MOUNTPOINT/zImage \n"
info "u-boot boot.scr now reads kernel from root partitions but found zImage in boot \n"
info "removing $BALENA_BOOT_MOUNTPOINT/zImage \n"
rm -f "$BALENA_BOOT_MOUNTPOINT/zImage" || true
sync -f "$BALENA_BOOT_MOUNTPOINT"
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@

set -o errexit

printf "[INFO] Applying quirk to remove dtoverlay=mmc from config.txt"
. /usr/libexec/os-helpers-logging

info "Applying quirk to remove dtoverlay=mmc from config.txt"
sed "/dtoverlay=mmc/d" /mnt/boot/config.txt > /mnt/boot/config.txt.new

printf "[INFO] Checking and applying if needed the quirks for removing older kunbus overlay"
info "Checking and applying if needed the quirks for removing older kunbus overlay"
sed "/Enable RevPi specific pins for i2c/d" /mnt/boot/config.txt > /mnt/boot/config.txt.new
sed "/dtoverlay=i2c1-bcm2708,sda1_pin=44,scl1_pin=45,pin_func=6/d" /mnt/boot/config.txt > /mnt/boot/config.txt.new
sed "/Enable RevPi realtime clock/d" /mnt/boot/config.txt > /mnt/boot/config.txt.new
Expand All @@ -20,4 +22,4 @@ sed "s/dtoverlay=kunbus/dtoverlay=revpi-core/g" /mnt/boot/config.txt > /mnt/boot
sync -f /mnt/boot
mv /mnt/boot/config.txt.new /mnt/boot/config.txt
sync -f /mnt/boot
printf " done.\n"
info " done."

0 comments on commit 7dcff92

Please sign in to comment.