Skip to content

Commit

Permalink
Merge branch 'master' into remove-mbedEdgeTrace-nanostack
Browse files Browse the repository at this point in the history
  • Loading branch information
Yash Goyal authored Nov 11, 2021
2 parents 1262b41 + 93ec32e commit 19d3c2c
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 10 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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).
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 9 additions & 0 deletions cmake/edge_configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()

Expand Down Expand Up @@ -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()

Expand Down
49 changes: 40 additions & 9 deletions fota/fota_app_callbacks.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <assert.h>

#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)
{
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
}

Expand All @@ -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;
}

Expand Down

0 comments on commit 19d3c2c

Please sign in to comment.