openssl1.1
blkid
liblzma-tool
+ hal-api-device
)
pkg_check_modules(blkid_pkgs REQUIRED
BuildRequires: pkgconfig(libtzplatform-config)
BuildRequires: pkgconfig(dlog)
Buildrequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(hal-api-device)
Requires: tar
Requires: gzip
HAL_PART_MAP_FILE="label_map.list"
HAL_PART_LIST_FILE="background_copy.list"
CONFIG_FILE="update.cfg"
+SET_UPGRADE_STATUS="/usr/bin/device_board_set_upgrade_status"
#------------------------------------------------
# log msg [file]
if ! "$IMG_VERIFIER" -i "$DELTA_FILE" -l "/opt/var/log/last_iv.log"; then
log "[Error] Update package verification FAILED..." "$LOG_FILE"
echo 5 > "$STATUS_DIR"/result
- exit 1
+ exit_error
else
log "[Info] Update package verification PASSED!" "$LOG_FILE"
fi
CURRENT_AB="$(/bin/sed -E 's|.*(partition_ab=)([a-b]).*|\2|' /proc/cmdline)"
if [ "$CURRENT_AB" != "a" ] && [ "$CURRENT_AB" != "b" ]; then
flog "[Info] There is no A/B partition scheme"
- exit 1
+ exit_error
fi
NEXT_AB="b"
if [ "$CURRENT_AB" == "b" ]; then
if ! EMMC_DEVICE="/dev/$(/bin/lsblk -ndo pkname "${ROOTFS_DEVICE}")" ||\
[ "$EMMC_DEVICE" == "/dev/" ]; then
flog "[Error] Unable to find used block device: $EMMC_DEVICE, for /"
- exit 1
+ exit_error
fi
}
fi
if [ "$CURRENT_PARTITION" == "" ] || [ "$NEXT_PARTITION" = "" ]; then
flog "[Error] current: $CURRENT_PARTITION or next: $NEXT_PARTITION partition is empty on $EMMC_DEVICE device"
- exit 1
+ exit_error
fi
if [ "$CURRENT_PARTITION" == "$NEXT_PARTITION" ]; then
flog "[Info] $partition_name partition current and next are the same: $CURRENT_PARTITION on $EMMC_DEVICE device"
flog "[Info] Checksums match"
else
flog "[Info] Checksums don't match ($CURRENT_SHA != $NEW_SHA). Abort."
- exit 1
+ exit_error
fi
else
PARTS_NAME_TO_UPDATE+=( "$PART_NAME:$TYPE" )
echo "OLD_VER=$CVT_VER" > "$VERSION_FILE"
}
+
+set_upgrade_status() {
+ VALUE="$1"
+ ${SET_UPGRADE_STATUS} ${VALUE}
+}
+
+exit_error() {
+ set_upgrade_status -1
+ exit 1
+}
unpack_file "$DELTA_TAR" "$CONFIG_FILE"
load_background_copy_list
background_copy
+set_upgrade_status 20
upgrade_images "$DOWNLOAD_DELTA"
+set_upgrade_status 80
reboot_to_fota
if ! prepare_for_ua; then
flog "[Error] Unable to prepare_for_ua"
cleanup
- exit 1
+ exit_error
fi
if ! run_setup_script "$DELTA_TAR"; then
flog "[Error] Unable to run_setup_script"
cleanup
- exit 1
+ exit_error
fi
if ! run_ro_update; then
flog "[Error] Unable to run_ro_update"
cleanup
- exit 1
+ exit_error
fi
cleanup
# the appropriate partitions directly from the archive so as not to
# consume additional space on the device.
unpack_file "${DOWNLOAD_DELTA}" "${SCRIPT_UPGRADE_FULL}"
- "${FOTA_DIR}/${SCRIPT_UPGRADE_FULL}" "${DOWNLOAD_DELTA}"
+ set_upgrade_status 5
+ if ! "${FOTA_DIR}/${SCRIPT_UPGRADE_FULL}" "${DOWNLOAD_DELTA}"; then
+ exit_error
+ fi
else
# Regular A/B Upgrade
unpack_file "${DOWNLOAD_DELTA}" "${SCRIPT_UPGRADE_PREPARE_PARTITIONS}"
unpack_file "${DOWNLOAD_DELTA}" "${SCRIPT_UPGRADE_PARTIAL}"
unpack_file "${DOWNLOAD_DELTA}" "${SCRIPT_UPGRADE_FOTA}"
-
+ set_upgrade_status 5
if ! "${FOTA_DIR}/${SCRIPT_UPGRADE_PREPARE_PARTITIONS}"; then
- exit 1
+ exit_error
fi
+ set_upgrade_status 20
if ! "${FOTA_DIR}/${SCRIPT_UPGRADE_PARTIAL}" "${DOWNLOAD_DELTA}"; then
- exit 1
+ exit_error
fi
+ set_upgrade_status 40
if ! "${FOTA_DIR}/${SCRIPT_UPGRADE_FOTA}"; then
- exit 1
+ exit_error
fi
+ set_upgrade_status 80
fi
else
# Legacy upgrade (non-A/B)
log "[Info] Using <$DOWNLOAD_DELTA> delta file." "$LOG_FILE"
prepare_fota_dir
-
tar xfp "$DOWNLOAD_DELTA" -C "$FOTA_DIR" upgrade-common.inc
. "$FOTA_DIR"/upgrade-common.inc
+set_upgrade_status 1
verify_img "${DOWNLOAD_DELTA}"
check_update_type
#include <string.h>
#include <blkid/blkid.h>
+#include <hal/device/hal-board.h>
+
#include "SS_Common.h"
#include "fota_common.h"
#include "ua.h"
#define TMP_DIR "/tmp/upgrade"
#define PROGRESS_FILE TMP_DIR "/ro_progress"
+#define HAL_PROGRESS_MIN 40
+#define HAL_PROGRESS_MAX 80
+
void print_usage(const char *msg)
{
if (msg) {
LOG("Succeed to write\n");
}
+static void set_upgrade_progress(int percent)
+{
+ int relative_precent = HAL_PROGRESS_MIN + ((HAL_PROGRESS_MAX - HAL_PROGRESS_MIN) * percent)/100;
+ hal_device_board_set_upgrade_status(relative_precent);
+}
+
/*-----------------------------------------------------------------------------
fota_gui_progress
----------------------------------------------------------------------------*/
else
percent = ua_update_data->weight_offset + (ua_update_data->weight * uPercent / 100);
+ set_upgrade_progress(percent);
/**
* re-arrange progress percentage between scout & update
*
to = 100;
break;
}
+
percent = from + ((to - from) * percent / 100);
fota_gui_update_progress(percent); /* update progress bar and text */