From 395e99e16239630263d5892e2462f1333236ae99 Mon Sep 17 00:00:00 2001 From: Marek Niepieklo Date: Thu, 9 Sep 2021 20:36:45 +0200 Subject: [PATCH] [CP-583] Update failure due to version.json on the phone Added version.json to the image --- cmake/modules/DiskImage.cmake | 3 +++ tools/generate_image.sh | 25 +++++++++++++++++-------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/cmake/modules/DiskImage.cmake b/cmake/modules/DiskImage.cmake index 79e8476ed630018bb2a1d31e6ac850a093d98ad0..fe809fd0b4dcac9d4c512329b8fc45b2c85d1bce 100644 --- a/cmake/modules/DiskImage.cmake +++ b/cmake/modules/DiskImage.cmake @@ -24,6 +24,8 @@ function(add_image) set(BIN_FILE_PATH "") endif() + set(VERSION_FILE_PATH ${CMAKE_BINARY_DIR}/${_ARG_PRODUCT}-version.json) + if(HAS_UPDATER) set(UPDATER_FILE_PATH ${CMAKE_BINARY_DIR}/updater.bin) else() @@ -50,6 +52,7 @@ function(add_image) ${SCRIPT_PATH} ${DISK_IMAGE_NAME} ${CMAKE_BINARY_DIR}/${_ARG_SYSROOT} + "${VERSION_FILE_PATH}" "${BIN_FILE_PATH}" "${UPDATER_FILE_PATH}" WORKING_DIRECTORY ${CMAKE_BINARY_DIR} diff --git a/tools/generate_image.sh b/tools/generate_image.sh index 221bab2f1663ab4891c369fe47ebd40d43e444d3..d8311e947354fccf196c08e8e4cd12e513a438b1 100755 --- a/tools/generate_image.sh +++ b/tools/generate_image.sh @@ -4,15 +4,16 @@ usage() { cat << ==usage -Usage: $(basename $0) image_path build_dir [boot.bin_file] [updater.bin_file] - image_path - Destination image path name e.g., PurePhone.img - sysroot - product's system root e.g., build-rt1051-RelWithDebInfo/sysroot - boot.bin_file - optional for linux image - name of the boot.bin file (for different targets) - updater.bin_file - optional for linux image - name of the updater.bin file +Usage: $(basename $0) image_path build_dir version.json_file [boot.bin_file] [updater.bin_file] + image_path - Destination image path name e.g., PurePhone.img + sysroot - product's system root e.g., build-rt1051-RelWithDebInfo/sysroot + version.json_file - version file + boot.bin_file - optional for linux image - name of the boot.bin file (for different targets) + updater.bin_file - optional for linux image - name of the updater.bin file ==usage } -if [[ ( $# -ne 2 ) && ( $# -ne 4 ) ]]; then +if [[ ( $# -ne 3 ) && ( $# -ne 5 ) ]]; then echo "Error! Invalid argument count" usage exit -1 @@ -20,8 +21,9 @@ fi IMAGE_NAME=$(realpath $1) SYSROOT=$(realpath $2) -BIN_FILE=$3 -UPDATER_FILE=$4 +VERSION_FILE=$3 +BIN_FILE=$4 +UPDATER_FILE=$5 if [ ! -d "$SYSROOT" ]; then echo "Error! ${SYSROOT} is not a directory" @@ -110,6 +112,13 @@ for i in $CURRENT_DATA; do fi done +if [[ -n "${VERSION_FILE}" && -f "${VERSION_FILE}" ]]; then + mcopy -v -s -i "$PART1" ${VERSION_FILE} ::/current/version.json +else + echo "Warning! Missing version.json" + echo "(it's fine for a Linux build)" +fi + if [[ -n "${BIN_FILE}" && -f "${BIN_FILE}" ]]; then mcopy -v -s -i "$PART1" ${BIN_FILE} ::/current/boot.bin else