diff --git a/CHANGELOG.md b/CHANGELOG.md index 0105722..3b142ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog for Edge +## Release 0.19.1 + +* Implemented combined update callbacks for bootloader. This assumes that boot capsule update is implemented on the device. + +## Release 0.19.0 + +* Updated to [Pelion Device Management Client (PDMC) library version 4.11.1](https://github.com/PelionIoT/mbed-cloud-client/blob/master/CHANGELOG.md#release-4111-11102021) +* Updated to [Mbed TLS version 2.27](https://github.com/ARMmbed/mbedtls/releases/tag/v2.27.0) +* Updated parsec-se-driver version from 0.5.0 to 0.6.0 (in `lib/pal-platform.json`). +* Ported subdevice FOTA support to be compatible with new FOTA framework library. This feature is no longer supported with UC Hub library. +* Implemented callbacks to support combined update feature of Device Management Update Client introduced in PDMC 4.11.0. +* Install edge_tool.py and cbor_converter.py scripts with `edge-tool/setup.py`. +* Setting the default value of `MBED_CONF_MBED_CLIENT_MAX_RECONNECT_TIMEOUT` to 10 mins. + ## Release 0.18.0 * Updated to [Pelion Device Management Client (PDMC) library version 4.9.0](https://github.com/PelionIoT/mbed-cloud-client/blob/master/CHANGELOG.md#release-490-20052021). diff --git a/README.md b/README.md index d52e735..f74d590 100644 --- a/README.md +++ b/README.md @@ -179,6 +179,12 @@ machine used to run Edge. For standard desktop Linux the value is set in `cmake/edge_configure.cmake` to a value `ARM_UCP_LINUX_GENERIC`. +#### Combined image update + +Lets you group together multiple images on the device as requiring a simultaneous update. This is useful when the images have a strong dependency on each other during device boot in runtime. For instance, use this feature to update the boot and rootfs image of the gateway in a single update process. To enable it, add the flag `-DFOTA_COMBINED_IMAGE_SUPPORT=ON` during build time. + +`fota/fota_app_callbacks.c` implements the callbacks to support the combined image update feature. For detailed information, follow [this link](https://developer.pelion.com/docs/device-management/current/connecting/implementing-combined-update.html). + ### Enabling Parsec diff --git a/cmake/edge_configure.cmake b/cmake/edge_configure.cmake index 9c9e572..d9940f2 100644 --- a/cmake/edge_configure.cmake +++ b/cmake/edge_configure.cmake @@ -118,6 +118,12 @@ if (${FIRMWARE_UPDATE}) if (NOT DEFINED FOTA_INSTALL_MAIN_SCRIPT) SET (FOTA_INSTALL_MAIN_SCRIPT \"fota_update_activate.sh\") endif() + if (NOT DEFINED BOOT_CAPSULE_UPDATE_DIR) + SET (BOOT_CAPSULE_UPDATE_DIR \"/boot/efi/EFI/UpdateCapsule\") + endif() + if (NOT DEFINED BOOT_CAPSULE_UPDATE_FILENAME) + SET (BOOT_CAPSULE_UPDATE_FILENAME \"u-boot-caps.bin\") + endif() add_definitions(-DFOTA_DEFAULT_APP_IFS=1) add_definitions(-DTARGET_LIKE_LINUX=1) @@ -127,6 +133,8 @@ if (${FIRMWARE_UPDATE}) add_definitions(-DMBED_CLOUD_CLIENT_FOTA_SUB_COMPONENT_SUPPORT=1) add_definitions(-DFOTA_CUSTOM_PLATFORM=1) add_definitions(-DFOTA_COMBINED_IMAGE_VENDOR_MAX_DATA_SIZE=64) + add_definitions(-DBOOT_CAPSULE_UPDATE_DIR=${BOOT_CAPSULE_UPDATE_DIR}) + add_definitions(-DBOOT_CAPSULE_UPDATE_FILENAME=${BOOT_CAPSULE_UPDATE_FILENAME}) endif() endif() @@ -167,6 +175,7 @@ if (${FIRMWARE_UPDATE}) MESSAGE("Update client hub selected.") add_definitions ("-DMBED_CLOUD_CLIENT_SUPPORT_UPDATE=1") add_definitions("-DPAL_DNS_API_VERSION=1") + message("WARNING: The next release, 0.20, will deprecate the Update Client (UC) hub library. Please use the new FOTA framework library, which can be enabled by adding -DFOTA_ENABLE=ON flag.") set(ENABLE_UC_HUB ON) endif() diff --git a/fota/fota_app_callbacks.c b/fota/fota_app_callbacks.c index 34264eb..942e22d 100644 --- a/fota/fota_app_callbacks.c +++ b/fota/fota_app_callbacks.c @@ -29,6 +29,7 @@ #include #define ACTIVATE_SCRIPT_LENGTH 512 +#define CURR_SHA_FILE_NAME MBED_CLOUD_CLIENT_FOTA_LINUX_CONFIG_DIR "/fota_curr_sha" int deploy_ostree_delta_update(const char *candidate_fs_name) { @@ -64,11 +65,9 @@ int verify_ostree_delta_update(const char *commit) int length = snprintf(command, ACTIVATE_SCRIPT_LENGTH, - "ostree log %s", commit); + "ostree admin status | head -1 | grep %s", commit); FOTA_ASSERT(length < ACTIVATE_SCRIPT_LENGTH); - FOTA_TRACE_DEBUG("system cmd %s, rc %d", command, rc); - /* execute script command */ rc = system(command); if (rc) { @@ -94,6 +93,11 @@ int fota_app_on_install_candidate(const char *candidate_fs_name, const manifest_ int main_sub_component_install_handler(const char *comp_name, const char *sub_comp_name, const char *file_name, const uint8_t *vendor_data, size_t vendor_data_size) { + int rc = system("ostree admin status | head -1 | sed 's/\\\..*//' | sed 's/.* //g' > " CURR_SHA_FILE_NAME); + if (rc) { + FOTA_TRACE_ERROR("Unable to save current ostree sha"); + return FOTA_STATUS_FW_INSTALLATION_FAILED; + } return deploy_ostree_delta_update(file_name); } @@ -104,37 +108,64 @@ int main_sub_component_verify_handler(const char *comp_name, const char *sub_com int main_sub_component_rollback_handler(const char *comp_name, const char *sub_comp_name, const uint8_t *vendor_data, size_t vendor_data_size) { - FOTA_TRACE_DEBUG("main_sub_component_rollback_handler comp %s, subcomp %s", comp_name, sub_comp_name); + int rc = system("ostree admin deploy `cat " CURR_SHA_FILE_NAME "`"); + if (rc) { + FOTA_TRACE_ERROR("Unable to rollback main sub component, result %d", WEXITSTATUS(rc)); + return FOTA_STATUS_FW_INSTALLATION_FAILED; + } return FOTA_STATUS_SUCCESS; } int main_sub_component_finalize_handler(const char *comp_name, const char *sub_comp_name, const uint8_t *vendor_data, size_t vendor_data_size, fota_status_e fota_status) { - FOTA_TRACE_DEBUG("main_sub_component_finalize_handler comp %s, subcomp %s", comp_name, sub_comp_name); + remove(CURR_SHA_FILE_NAME); return FOTA_STATUS_SUCCESS; } int boot_sub_component_install_handler(const char *comp_name, const char *sub_comp_name, const char *file_name, const uint8_t *vendor_data, size_t vendor_data_size) { - FOTA_TRACE_DEBUG("boot_sub_component_install_handler comp %s, subcomp %s", comp_name, sub_comp_name); + int rc; + char command[ACTIVATE_SCRIPT_LENGTH] = {0}; + rc = system("mkdir -p " BOOT_CAPSULE_UPDATE_DIR); + if (rc) { + FOTA_TRACE_ERROR("Unable to create capsule update directory"); + return FOTA_STATUS_FW_INSTALLATION_FAILED; + } + + int length = snprintf(command, + ACTIVATE_SCRIPT_LENGTH, + "cp -f %s " BOOT_CAPSULE_UPDATE_DIR "/" BOOT_CAPSULE_UPDATE_FILENAME, file_name); + FOTA_ASSERT(length < ACTIVATE_SCRIPT_LENGTH); + + rc = system(command); + if (rc) { + FOTA_TRACE_ERROR("Unable to copy capsule file to capsule directory"); + return FOTA_STATUS_FW_INSTALLATION_FAILED; + } return FOTA_STATUS_SUCCESS; } int boot_sub_component_verify_handler(const char *comp_name, const char *sub_comp_name, const uint8_t *vendor_data, size_t vendor_data_size) { - FOTA_TRACE_DEBUG("boot_sub_component_verify_handler comp %s, subcomp %s", comp_name, sub_comp_name); + // Currently only way to verify success of capsule update is to make sure that capsule update process removed the capsule file + FILE *fp = fopen(BOOT_CAPSULE_UPDATE_DIR "/" BOOT_CAPSULE_UPDATE_FILENAME, "r"); + if (fp) { + FOTA_TRACE_ERROR("Capsule update process failed"); + fclose(fp); + return FOTA_STATUS_FW_INSTALLATION_FAILED; + } return FOTA_STATUS_SUCCESS; } int boot_sub_component_rollback_handler(const char *comp_name, const char *sub_comp_name, const uint8_t *vendor_data, size_t vendor_data_size) { - FOTA_TRACE_DEBUG("boot_sub_component_rollback_handler comp %s, subcomp %s", comp_name, sub_comp_name); + // Nothing to do here return FOTA_STATUS_SUCCESS; } int boot_sub_component_finalize_handler(const char *comp_name, const char *sub_comp_name, const uint8_t *vendor_data, size_t vendor_data_size, fota_status_e fota_status) { - FOTA_TRACE_DEBUG("boot_sub_component_finalize_handler comp %s, subcomp %s", comp_name, sub_comp_name); + remove(BOOT_CAPSULE_UPDATE_DIR "/" BOOT_CAPSULE_UPDATE_FILENAME); return FOTA_STATUS_SUCCESS; } diff --git a/lib/mbed-cloud-client b/lib/mbed-cloud-client index 105a184..8a30590 160000 --- a/lib/mbed-cloud-client +++ b/lib/mbed-cloud-client @@ -1 +1 @@ -Subproject commit 105a1846277c80e5eb15ad74de7e4d7b15e57c26 +Subproject commit 8a30590179cdfb4c6949a7f5b14cae39448d8454