From 96c6730a956039cef8c96473f9ab529752a8a2d4 Mon Sep 17 00:00:00 2001 From: Joel Guittet Date: Sat, 25 May 2024 22:47:38 +0200 Subject: [PATCH 01/21] troubleshoot: add handling mender-client messages --- components/mender-mcu-client/mender-mcu-client | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/mender-mcu-client/mender-mcu-client b/components/mender-mcu-client/mender-mcu-client index 3825a9c..dffb19a 160000 --- a/components/mender-mcu-client/mender-mcu-client +++ b/components/mender-mcu-client/mender-mcu-client @@ -1 +1 @@ -Subproject commit 3825a9c414b3979f9c6c561ddf86e0414419844d +Subproject commit dffb19a4177813c265a9afc88b0c33ad81d19805 From 16de51ca2a77a890145e654889eaa774d57505ca Mon Sep 17 00:00:00 2001 From: Joel Guittet Date: Sat, 25 May 2024 22:48:41 +0200 Subject: [PATCH 02/21] platform: better handling of chunked responses from esp-idf http client --- components/mender-mcu-client/mender-mcu-client | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/mender-mcu-client/mender-mcu-client b/components/mender-mcu-client/mender-mcu-client index dffb19a..f9f1b22 160000 --- a/components/mender-mcu-client/mender-mcu-client +++ b/components/mender-mcu-client/mender-mcu-client @@ -1 +1 @@ -Subproject commit dffb19a4177813c265a9afc88b0c33ad81d19805 +Subproject commit f9f1b22397e933ee615423ab431865c9ac5a999d From 68b37cc9015a23e99f32a2fbd0b6429c2c36bbbc Mon Sep 17 00:00:00 2001 From: Joel Guittet Date: Sat, 25 May 2024 22:49:18 +0200 Subject: [PATCH 03/21] client: return error in case the authentication is not done --- components/mender-mcu-client/mender-mcu-client | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/mender-mcu-client/mender-mcu-client b/components/mender-mcu-client/mender-mcu-client index f9f1b22..2af2bc5 160000 --- a/components/mender-mcu-client/mender-mcu-client +++ b/components/mender-mcu-client/mender-mcu-client @@ -1 +1 @@ -Subproject commit f9f1b22397e933ee615423ab431865c9ac5a999d +Subproject commit 2af2bc50bb9d8f0f944c053166cf6dc36144f1b5 From 769fa9fd1573c947bbb01a64ef856f84b95b482c Mon Sep 17 00:00:00 2001 From: Joel Guittet Date: Sat, 25 May 2024 22:49:59 +0200 Subject: [PATCH 04/21] platform: rtos: permit deactivate if not activated --- components/mender-mcu-client/mender-mcu-client | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/mender-mcu-client/mender-mcu-client b/components/mender-mcu-client/mender-mcu-client index 2af2bc5..081a968 160000 --- a/components/mender-mcu-client/mender-mcu-client +++ b/components/mender-mcu-client/mender-mcu-client @@ -1 +1 @@ -Subproject commit 2af2bc50bb9d8f0f944c053166cf6dc36144f1b5 +Subproject commit 081a9689697fe550ed7b81a4a741a47c2d023753 From d4c354ebfb324b04410bb6188b6af82c561f64fd Mon Sep 17 00:00:00 2001 From: Joel Guittet Date: Sat, 25 May 2024 22:50:45 +0200 Subject: [PATCH 05/21] platform: storage: remove generic word 'ota' in the apis --- components/mender-mcu-client/mender-mcu-client | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/mender-mcu-client/mender-mcu-client b/components/mender-mcu-client/mender-mcu-client index 081a968..df4326a 160000 --- a/components/mender-mcu-client/mender-mcu-client +++ b/components/mender-mcu-client/mender-mcu-client @@ -1 +1 @@ -Subproject commit 081a9689697fe550ed7b81a4a741a47c2d023753 +Subproject commit df4326a8f54af92d097b3577c01ed8e346c91848 From b9f8a68d4222c11458434f5f3665392628a99d77 Mon Sep 17 00:00:00 2001 From: Joel Guittet Date: Sat, 25 May 2024 23:00:39 +0200 Subject: [PATCH 06/21] platform: rename mender-ota to mender-flash and cleanup of the apis --- .../mender-mcu-client/mender-mcu-client | 2 +- main/main.c | 48 +++++++++---------- 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/components/mender-mcu-client/mender-mcu-client b/components/mender-mcu-client/mender-mcu-client index df4326a..2f67f39 160000 --- a/components/mender-mcu-client/mender-mcu-client +++ b/components/mender-mcu-client/mender-mcu-client @@ -1 +1 @@ -Subproject commit df4326a8f54af92d097b3577c01ed8e346c91848 +Subproject commit 2f67f3905c32f7fce5019e742eb88deb7fc87420 diff --git a/main/main.c b/main/main.c index 680190b..722d9eb 100644 --- a/main/main.c +++ b/main/main.c @@ -35,8 +35,8 @@ #include #include "mender-client.h" #include "mender-configure.h" +#include "mender-flash.h" #include "mender-inventory.h" -#include "mender-ota.h" #include "mender-troubleshoot.h" #include #include @@ -89,7 +89,7 @@ authentication_success_cb(void) { /* Validate the image if it is still pending */ /* Note it is possible to do multiple diagnosic tests before validating the image */ /* In this example, authentication success with the mender-server is enough */ - if (MENDER_OK != (ret = mender_ota_mark_app_valid_cancel_rollback())) { + if (MENDER_OK != (ret = mender_flash_confirm_image())) { ESP_LOGE(TAG, "Unable to validate the image"); return ret; } @@ -104,24 +104,22 @@ authentication_success_cb(void) { static mender_err_t authentication_failure_cb(void) { - static int tries = 0; - mender_err_t ret = MENDER_OK; + static int tries = 0; + + /* Check if confirmation of the image is still pending */ + if (true == mender_flash_is_image_confirmed()) { + ESP_LOGE(TAG, "Mender client authentication failed"); + return MENDER_OK; + } /* Increment number of failures */ tries++; - ESP_LOGI(TAG, "Mender client authentication failed (%d/%d)", tries, CONFIG_EXAMPLE_AUTHENTICATION_FAILS_MAX_TRIES); - - /* Invalidate the image if it is still pending */ - /* Note it is possible to invalid the image later to permit clean closure before reboot */ - /* In this example, several authentication failures with the mender-server is enough */ - if (tries >= CONFIG_EXAMPLE_AUTHENTICATION_FAILS_MAX_TRIES) { - if (MENDER_OK != (ret = mender_ota_mark_app_invalid_rollback_and_reboot())) { - ESP_LOGE(TAG, "Unable to invalidate the image"); - return ret; - } - } + ESP_LOGE(TAG, "Mender client authentication failed (%d/%d)", tries, CONFIG_EXAMPLE_AUTHENTICATION_FAILS_MAX_TRIES); - return ret; + /* Restart the application after several authentication failures with the mender-server */ + /* The image has not been confirmed and the bootloader will now rollback to the previous working image */ + /* Note it is possible to customize this depending of the wanted behavior */ + return (tries >= CONFIG_EXAMPLE_AUTHENTICATION_FAILS_MAX_TRIES) ? MENDER_FAIL : MENDER_OK; } /** @@ -417,15 +415,15 @@ app_main(void) { .authentication_poll_interval = 0, .update_poll_interval = 0, .recommissioning = false }; - mender_client_callbacks_t mender_client_callbacks = { .authentication_success = authentication_success_cb, - .authentication_failure = authentication_failure_cb, - .deployment_status = deployment_status_cb, - .ota_begin = mender_ota_begin, - .ota_write = mender_ota_write, - .ota_abort = mender_ota_abort, - .ota_end = mender_ota_end, - .ota_set_boot_partition = mender_ota_set_boot_partition, - .restart = restart_cb }; + mender_client_callbacks_t mender_client_callbacks = { .authentication_success = authentication_success_cb, + .authentication_failure = authentication_failure_cb, + .deployment_status = deployment_status_cb, + .flash.open = mender_flash_open, + .flash.write = mender_flash_write, + .flash.close = mender_flash_close, + .flash.set_pending_image = mender_flash_set_pending_image, + .flash.abort_deployment = mender_flash_abort_deployment, + .restart = restart_cb }; ESP_ERROR_CHECK(mender_client_init(&mender_client_config, &mender_client_callbacks)); ESP_LOGI(TAG, "Mender client initialized"); From d5db8861c328bf4fc660af10c5bbc73f0e32eee5 Mon Sep 17 00:00:00 2001 From: Joel Guittet Date: Sat, 25 May 2024 23:06:01 +0200 Subject: [PATCH 07/21] websocket: cleaning include file --- components/mender-mcu-client/mender-mcu-client | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/mender-mcu-client/mender-mcu-client b/components/mender-mcu-client/mender-mcu-client index 2f67f39..9043c95 160000 --- a/components/mender-mcu-client/mender-mcu-client +++ b/components/mender-mcu-client/mender-mcu-client @@ -1 +1 @@ -Subproject commit 2f67f3905c32f7fce5019e742eb88deb7fc87420 +Subproject commit 9043c95d187859efd2f79627e03252fe56983948 From fcac115d73c22b5726f287639696d3a5482bfd6c Mon Sep 17 00:00:00 2001 From: Joel Guittet Date: Sat, 25 May 2024 23:07:26 +0200 Subject: [PATCH 08/21] platform: storage: modify deployment apis --- components/mender-mcu-client/mender-mcu-client | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/mender-mcu-client/mender-mcu-client b/components/mender-mcu-client/mender-mcu-client index 9043c95..4e7de42 160000 --- a/components/mender-mcu-client/mender-mcu-client +++ b/components/mender-mcu-client/mender-mcu-client @@ -1 +1 @@ -Subproject commit 9043c95d187859efd2f79627e03252fe56983948 +Subproject commit 4e7de421f11f31bf7943ecf405c7014b2f9e56e2 From b877d3b6cc4d4425e23c5c176edf4dc7603aed49 Mon Sep 17 00:00:00 2001 From: Joel Guittet Date: Sat, 25 May 2024 23:08:00 +0200 Subject: [PATCH 09/21] utils: modify keystore conversion apis --- components/mender-mcu-client/mender-mcu-client | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/mender-mcu-client/mender-mcu-client b/components/mender-mcu-client/mender-mcu-client index 4e7de42..4eeb902 160000 --- a/components/mender-mcu-client/mender-mcu-client +++ b/components/mender-mcu-client/mender-mcu-client @@ -1 +1 @@ -Subproject commit 4e7de421f11f31bf7943ecf405c7014b2f9e56e2 +Subproject commit 4eeb9021cdea454370021d0d0d9f667296221844 From 04d0dd36ed32698f96f160374b940f8d6e21abd0 Mon Sep 17 00:00:00 2001 From: Joel Guittet Date: Sat, 25 May 2024 23:10:57 +0200 Subject: [PATCH 10/21] client: update to support modules --- components/mender-mcu-client/mender-mcu-client | 2 +- main/main.c | 13 ++++--------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/components/mender-mcu-client/mender-mcu-client b/components/mender-mcu-client/mender-mcu-client index 4eeb902..452d5b0 160000 --- a/components/mender-mcu-client/mender-mcu-client +++ b/components/mender-mcu-client/mender-mcu-client @@ -1 +1 @@ -Subproject commit 4eeb9021cdea454370021d0d0d9f667296221844 +Subproject commit 452d5b047e2a6329fe4470e76f465f1bc87e97bf diff --git a/main/main.c b/main/main.c index 722d9eb..08cb09b 100644 --- a/main/main.c +++ b/main/main.c @@ -415,15 +415,10 @@ app_main(void) { .authentication_poll_interval = 0, .update_poll_interval = 0, .recommissioning = false }; - mender_client_callbacks_t mender_client_callbacks = { .authentication_success = authentication_success_cb, - .authentication_failure = authentication_failure_cb, - .deployment_status = deployment_status_cb, - .flash.open = mender_flash_open, - .flash.write = mender_flash_write, - .flash.close = mender_flash_close, - .flash.set_pending_image = mender_flash_set_pending_image, - .flash.abort_deployment = mender_flash_abort_deployment, - .restart = restart_cb }; + mender_client_callbacks_t mender_client_callbacks = { .authentication_success = authentication_success_cb, + .authentication_failure = authentication_failure_cb, + .deployment_status = deployment_status_cb, + .restart = restart_cb }; ESP_ERROR_CHECK(mender_client_init(&mender_client_config, &mender_client_callbacks)); ESP_LOGI(TAG, "Mender client initialized"); From 56bcc2640867258142c7cf0dc84801ea0d3d58d0 Mon Sep 17 00:00:00 2001 From: Joel Guittet Date: Sat, 25 May 2024 23:13:36 +0200 Subject: [PATCH 11/21] main: remove trace facilities --- main/main.c | 55 ++--------------------------------------------------- 1 file changed, 2 insertions(+), 53 deletions(-) diff --git a/main/main.c b/main/main.c index 08cb09b..53c5c9b 100644 --- a/main/main.c +++ b/main/main.c @@ -315,47 +315,6 @@ shell_end_cb(void) { #endif /* CONFIG_MENDER_CLIENT_ADD_ON_TROUBLESHOOT */ -#if configUSE_TRACE_FACILITY == 1 - -/** - * @brief Print FreeRTOS stats - */ -static void -print_stats(void) { - - /* Take a snapshot of the number of tasks in case it changes while this function is executing */ - volatile UBaseType_t uxArraySize = uxTaskGetNumberOfTasks(); - - /* Allocate a TaskStatus_t structure for each task */ - TaskStatus_t *pxTaskStatusArray = pvPortMalloc(uxArraySize * sizeof(TaskStatus_t)); - if (NULL != pxTaskStatusArray) { - - /* Generate raw status information about each task */ - uxArraySize = uxTaskGetSystemState(pxTaskStatusArray, uxArraySize, NULL); - - /* For each populated position in the pxTaskStatusArray array, format the raw data as human readable ASCII data */ - printf("--------------------------------------------------------\n"); - printf("Task Name | Stack High Water Mark\n"); - printf("--------------------------------------------------------\n"); - for (UBaseType_t index = 0; index < uxArraySize; index++) { - printf("%15s | %u bytes\n", - pxTaskStatusArray[index].pcTaskName, - (unsigned int)pxTaskStatusArray[index].usStackHighWaterMark * sizeof(configSTACK_DEPTH_TYPE)); - } - - /* Release memory */ - vPortFree(pxTaskStatusArray); - } - - /* Print usage of the heap */ - printf("--------------------------------------------------------\n"); - printf("Free Heap Size: %u bytes\n", (unsigned int)xPortGetFreeHeapSize()); - printf("Minimum Ever Free Heap Size: %u bytes\n", (unsigned int)xPortGetMinimumEverFreeHeapSize()); - printf("--------------------------------------------------------\n"); -} - -#endif /* configUSE_TRACE_FACILITY == 1 */ - /** * @brief Main function */ @@ -474,18 +433,8 @@ app_main(void) { } #endif /* CONFIG_MENDER_CLIENT_ADD_ON_INVENTORY */ - /* Infinite loop, print stats periodically */ - EventBits_t event = 0; - while (!event) { - -#if configUSE_TRACE_FACILITY == 1 - /* Print stats */ - print_stats(); -#endif /* configUSE_TRACE_FACILITY == 1 */ - - /* Wait before next snapshot or the application shutdown */ - event = xEventGroupWaitBits(mender_client_events, MENDER_CLIENT_EVENT_RESTART, pdTRUE, pdFALSE, 10000 / portTICK_PERIOD_MS); - } + /* Wait for mender-mcu-client events */ + xEventGroupWaitBits(mender_client_events, MENDER_CLIENT_EVENT_RESTART, pdTRUE, pdFALSE, portMAX_DELAY); /* Deactivate mender add-ons */ #ifdef CONFIG_MENDER_CLIENT_ADD_ON_TROUBLESHOOT From 71ad34eec6702bd9f34091a24722844fd62f033e Mon Sep 17 00:00:00 2001 From: Joel Guittet Date: Sat, 25 May 2024 23:14:33 +0200 Subject: [PATCH 12/21] platform: rtos becomes scheduler to allow more generic implementations --- components/mender-mcu-client/mender-mcu-client | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/mender-mcu-client/mender-mcu-client b/components/mender-mcu-client/mender-mcu-client index 452d5b0..f127d8e 160000 --- a/components/mender-mcu-client/mender-mcu-client +++ b/components/mender-mcu-client/mender-mcu-client @@ -1 +1 @@ -Subproject commit 452d5b047e2a6329fe4470e76f465f1bc87e97bf +Subproject commit f127d8e9ad21975e6942319635943ea20237a5a1 From 27e66a8c3e2fa4465338303ea348cbf22899220c Mon Sep 17 00:00:00 2001 From: Joel Guittet Date: Sat, 25 May 2024 23:16:03 +0200 Subject: [PATCH 13/21] client: improve management of server host ant tenant token --- components/mender-mcu-client/mender-mcu-client | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/mender-mcu-client/mender-mcu-client b/components/mender-mcu-client/mender-mcu-client index f127d8e..628b33f 160000 --- a/components/mender-mcu-client/mender-mcu-client +++ b/components/mender-mcu-client/mender-mcu-client @@ -1 +1 @@ -Subproject commit f127d8e9ad21975e6942319635943ea20237a5a1 +Subproject commit 628b33f86a1ee05428d67d0f241ce41a7248c6e1 From 24867ca3185ec14076a8025bdc14ec2aa7569aaa Mon Sep 17 00:00:00 2001 From: Joel Guittet Date: Sat, 25 May 2024 23:16:40 +0200 Subject: [PATCH 14/21] readme: fix a typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 863d2b0..fcab9e1 100755 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ This project is used with an [ESP32-WROOM-32D](https://www.espressif.com/sites/d The project is built using ESP-IDF framework. There is no other dependencies. Important note: the project has been tested with ESP-IDF v4.4.x and v5.0.x successfully. There is no support for older releases. -This project is developed under [VSCode](https://code.visualstudio.com) and using [ESP-IDF Extension](https://github.com/espressif/vscode-esp-idf-extension). If you need support to use the development environnement, you can refer to the "ESP-IDF Extension help" section below. +This project is developed under [VSCode](https://code.visualstudio.com) and using [ESP-IDF Extension](https://github.com/espressif/vscode-esp-idf-extension). If you need support to use the development environment, you can refer to the "ESP-IDF Extension help" section below. To start using Mender, we recommend that you begin with the Getting started section in [the Mender documentation](https://docs.mender.io/). From a9bd4a58b091c362d7df31de4dfe98c15080a91a Mon Sep 17 00:00:00 2001 From: Joel Guittet Date: Mon, 27 May 2024 11:30:32 +0200 Subject: [PATCH 15/21] client: allow custom identity instead of using mac address by default --- components/mender-mcu-client/mender-mcu-client | 2 +- main/main.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/components/mender-mcu-client/mender-mcu-client b/components/mender-mcu-client/mender-mcu-client index 628b33f..13f4255 160000 --- a/components/mender-mcu-client/mender-mcu-client +++ b/components/mender-mcu-client/mender-mcu-client @@ -1 +1 @@ -Subproject commit 628b33f86a1ee05428d67d0f241ce41a7248c6e1 +Subproject commit 13f42555f330afe16f4a10350865d0c9f443877b diff --git a/main/main.c b/main/main.c index 53c5c9b..407620c 100644 --- a/main/main.c +++ b/main/main.c @@ -366,7 +366,8 @@ app_main(void) { char *device_type = running_app_info.project_name; /* Initialize mender-client */ - mender_client_config_t mender_client_config = { .mac_address = mac_address, + mender_keystore_t identity[] = { { .name = "mac", .value = mac_address }, { .name = NULL, .value = NULL } }; + mender_client_config_t mender_client_config = { .identity = identity, .artifact_name = artifact_name, .device_type = device_type, .host = NULL, From 2f2e1bb0d248e98b1c67e01783a18e5d8892aa86 Mon Sep 17 00:00:00 2001 From: Joel Guittet Date: Mon, 27 May 2024 22:41:07 +0200 Subject: [PATCH 16/21] client: remove usage of unsafe sprintf function --- components/mender-mcu-client/mender-mcu-client | 2 +- main/main.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/mender-mcu-client/mender-mcu-client b/components/mender-mcu-client/mender-mcu-client index 13f4255..91273f9 160000 --- a/components/mender-mcu-client/mender-mcu-client +++ b/components/mender-mcu-client/mender-mcu-client @@ -1 +1 @@ -Subproject commit 13f42555f330afe16f4a10350865d0c9f443877b +Subproject commit 91273f9a18a903e9b280f489124bbe38834197dd diff --git a/main/main.c b/main/main.c index 407620c..57f899d 100644 --- a/main/main.c +++ b/main/main.c @@ -345,7 +345,7 @@ app_main(void) { uint8_t mac[6]; char mac_address[18]; ESP_ERROR_CHECK(esp_base_mac_addr_get(mac)); - sprintf(mac_address, "%02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); + snprintf(mac_address, sizeof(mac_address), "%02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); ESP_LOGI(TAG, "MAC address of the device '%s'", mac_address); /* Create mender-client event group */ @@ -360,7 +360,7 @@ app_main(void) { /* Compute artifact name */ char artifact_name[128]; - sprintf(artifact_name, "%s-v%s", running_app_info.project_name, running_app_info.version); + snprintf(artifact_name, sizeof(artifact_name), "%s-v%s", running_app_info.project_name, running_app_info.version); /* Retrieve device type */ char *device_type = running_app_info.project_name; From ccd7baa829514a184c8b2ce6b288790e6b4b14c4 Mon Sep 17 00:00:00 2001 From: Joel Guittet Date: Wed, 29 May 2024 09:07:38 +0200 Subject: [PATCH 17/21] core: utils: remove str replace function from the client library --- .../mender-mcu-client/mender-mcu-client | 2 +- main/main.c | 104 +++++++++++++++++- 2 files changed, 103 insertions(+), 3 deletions(-) diff --git a/components/mender-mcu-client/mender-mcu-client b/components/mender-mcu-client/mender-mcu-client index 91273f9..cb6c6c0 160000 --- a/components/mender-mcu-client/mender-mcu-client +++ b/components/mender-mcu-client/mender-mcu-client @@ -1 +1 @@ -Subproject commit 91273f9a18a903e9b280f489124bbe38834197dd +Subproject commit cb6c6c0f77b2145bac092bc7bb047c06202f7eb8 diff --git a/main/main.c b/main/main.c index 57f899d..448fc25 100644 --- a/main/main.c +++ b/main/main.c @@ -40,6 +40,7 @@ #include "mender-troubleshoot.h" #include #include +#include #include "sdkconfig.h" /** @@ -180,6 +181,105 @@ config_updated_cb(mender_keystore_t *configuration) { #ifdef CONFIG_MENDER_CLIENT_ADD_ON_TROUBLESHOOT +/** + * @brief Function used to replace a string in the input buffer + * @param input Input buffer + * @param search String to be replaced or regex expression + * @param replace Replacement string + * @return New string with replacements if the function succeeds, NULL otherwise + */ +static char * +str_replace(char *input, char *search, char *replace) { + + assert(NULL != input); + assert(NULL != search); + assert(NULL != replace); + + regex_t regex; + regmatch_t match; + char * str = input; + char * output = NULL; + size_t index = 0; + int previous_match_finish = 0; + + /* Compile expression */ + if (0 != regcomp(®ex, search, REG_EXTENDED)) { + /* Unable to compile expression */ + ESP_LOGE(TAG, "Unable to compile expression '%s'", search); + return NULL; + } + + /* Loop until all search string are replaced */ + bool loop = true; + while (true == loop) { + + /* Search wanted string */ + if (0 != regexec(®ex, str, 1, &match, 0)) { + /* No more string to be replaced */ + loop = false; + } else { + if (match.rm_so != -1) { + + /* Beginning and ending offset of the match */ + int current_match_start = (int)(match.rm_so + (str - input)); + int current_match_finish = (int)(match.rm_eo + (str - input)); + + /* Reallocate output memory */ + char *tmp = (char *)realloc(output, index + (current_match_start - previous_match_finish) + 1); + if (NULL == tmp) { + ESP_LOGE(TAG, "Unable to allocate memory"); + regfree(®ex); + free(output); + return NULL; + } + output = tmp; + + /* Copy string from previous match to the beginning of the current match */ + memcpy(&output[index], &input[previous_match_finish], current_match_start - previous_match_finish); + index += (current_match_start - previous_match_finish); + output[index] = 0; + + /* Reallocate output memory */ + if (NULL == (tmp = (char *)realloc(output, index + strlen(replace) + 1))) { + ESP_LOGE(TAG, "Unable to allocate memory"); + regfree(®ex); + free(output); + return NULL; + } + output = tmp; + + /* Copy replace string to the output */ + strcat(output, replace); + index += strlen(replace); + + /* Update previous match ending value */ + previous_match_finish = current_match_finish; + } + str += match.rm_eo; + } + } + + /* Reallocate output memory */ + char *tmp = (char *)realloc(output, index + (strlen(input) - previous_match_finish) + 1); + if (NULL == tmp) { + ESP_LOGE(TAG, "Unable to allocate memory"); + regfree(®ex); + free(output); + return NULL; + } + output = tmp; + + /* Copy the end of the string after the latest match */ + memcpy(&output[index], &input[previous_match_finish], strlen(input) - previous_match_finish); + index += (strlen(input) - previous_match_finish); + output[index] = 0; + + /* Release regex */ + regfree(®ex); + + return output; +} + /** * @brief Shell vprintf function used to route logs * @param format Log format string @@ -204,7 +304,7 @@ shell_vprintf(const char *format, va_list args) { if (NULL == (buffer = strndup(data, length))) { goto END; } - if (NULL == (tmp = mender_utils_str_replace(buffer, "\r|\n", "\r\n"))) { + if (NULL == (tmp = str_replace(buffer, "\r|\n", "\r\n"))) { goto END; } buffer = tmp; @@ -273,7 +373,7 @@ shell_write_cb(uint8_t *data, size_t length) { ret = MENDER_FAIL; goto END; } - if (NULL == (tmp = mender_utils_str_replace(buffer, "\r|\n", "\r\n"))) { + if (NULL == (tmp = str_replace(buffer, "\r|\n", "\r\n"))) { ESP_LOGE(TAG, "Unable to allocate memory"); ret = MENDER_FAIL; goto END; From a6e6d45876f6bb1fb56ac85340546a05c1f578df Mon Sep 17 00:00:00 2001 From: Joel Guittet Date: Fri, 21 Jun 2024 18:11:32 +0200 Subject: [PATCH 18/21] client: rework apis so that the mender-client registers add-ons and manage them --- .../mender-mcu-client/mender-mcu-client | 2 +- main/main.c | 57 +++++++------------ 2 files changed, 20 insertions(+), 39 deletions(-) diff --git a/components/mender-mcu-client/mender-mcu-client b/components/mender-mcu-client/mender-mcu-client index cb6c6c0..78a594e 160000 --- a/components/mender-mcu-client/mender-mcu-client +++ b/components/mender-mcu-client/mender-mcu-client @@ -1 +1 @@ -Subproject commit cb6c6c0f77b2145bac092bc7bb047c06202f7eb8 +Subproject commit 78a594ef233e96f53ee3fdf43fb9b0666ed71088 diff --git a/main/main.c b/main/main.c index 448fc25..87922ed 100644 --- a/main/main.c +++ b/main/main.c @@ -65,22 +65,8 @@ authentication_success_cb(void) { ESP_LOGI(TAG, "Mender client authenticated"); - /* Activate mender add-ons */ - /* The application can activate each add-on depending of the current status of the device */ - /* In this example, add-ons are activated has soon as authentication succeeds */ -#ifdef CONFIG_MENDER_CLIENT_ADD_ON_CONFIGURE - if (MENDER_OK != (ret = mender_configure_activate())) { - ESP_LOGE(TAG, "Unable to activate configure add-on"); - return ret; - } -#endif /* CONFIG_MENDER_CLIENT_ADD_ON_CONFIGURE */ -#ifdef CONFIG_MENDER_CLIENT_ADD_ON_INVENTORY - if (MENDER_OK != (ret = mender_inventory_activate())) { - ESP_LOGE(TAG, "Unable to activate inventory add-on"); - return ret; - } -#endif /* CONFIG_MENDER_CLIENT_ADD_ON_INVENTORY */ #ifdef CONFIG_MENDER_CLIENT_ADD_ON_TROUBLESHOOT + /* Activate troubleshoot add-on (deactivated by default) */ if (MENDER_OK != (ret = mender_troubleshoot_activate())) { ESP_LOGE(TAG, "Unable to activate troubleshoot add-on"); return ret; @@ -109,7 +95,7 @@ authentication_failure_cb(void) { /* Check if confirmation of the image is still pending */ if (true == mender_flash_is_image_confirmed()) { - ESP_LOGE(TAG, "Mender client authentication failed"); + ESP_LOGI(TAG, "Mender client authentication failed"); return MENDER_OK; } @@ -490,20 +476,22 @@ app_main(void) { .config_updated = config_updated_cb, #endif /* CONFIG_MENDER_CLIENT_CONFIGURE_STORAGE */ }; - ESP_ERROR_CHECK(mender_configure_init(&mender_configure_config, &mender_configure_callbacks)); - ESP_LOGI(TAG, "Mender configure initialized"); + ESP_ERROR_CHECK(mender_client_register_addon( + (mender_addon_instance_t *)&mender_configure_addon_instance, (void *)&mender_configure_config, (void *)&mender_configure_callbacks)); + ESP_LOGI(TAG, "Mender configure add-on registered"); #endif /* CONFIG_MENDER_CLIENT_ADD_ON_CONFIGURE */ #ifdef CONFIG_MENDER_CLIENT_ADD_ON_INVENTORY mender_inventory_config_t mender_inventory_config = { .refresh_interval = 0 }; - ESP_ERROR_CHECK(mender_inventory_init(&mender_inventory_config)); - ESP_LOGI(TAG, "Mender inventory initialized"); + ESP_ERROR_CHECK(mender_client_register_addon((mender_addon_instance_t *)&mender_inventory_addon_instance, (void *)&mender_inventory_config, NULL)); + ESP_LOGI(TAG, "Mender inventory add-on registered"); #endif /* CONFIG_MENDER_CLIENT_ADD_ON_INVENTORY */ #ifdef CONFIG_MENDER_CLIENT_ADD_ON_TROUBLESHOOT mender_troubleshoot_config_t mender_troubleshoot_config = { .healthcheck_interval = 0 }; mender_troubleshoot_callbacks_t mender_troubleshoot_callbacks = { .shell_begin = shell_begin_cb, .shell_resize = shell_resize_cb, .shell_write = shell_write_cb, .shell_end = shell_end_cb }; - ESP_ERROR_CHECK(mender_troubleshoot_init(&mender_troubleshoot_config, &mender_troubleshoot_callbacks)); - ESP_LOGI(TAG, "Mender troubleshoot initialized"); + ESP_ERROR_CHECK(mender_client_register_addon( + (mender_addon_instance_t *)&mender_troubleshoot_addon_instance, (void *)&mender_troubleshoot_config, (void *)&mender_troubleshoot_callbacks)); + ESP_LOGI(TAG, "Mender troubleshoot add-on registered"); #endif /* CONFIG_MENDER_CLIENT_ADD_ON_TROUBLESHOOT */ #ifdef CONFIG_MENDER_CLIENT_ADD_ON_CONFIGURE @@ -534,26 +522,19 @@ app_main(void) { } #endif /* CONFIG_MENDER_CLIENT_ADD_ON_INVENTORY */ + /* Finally activate mender client */ + if (MENDER_OK != mender_client_activate()) { + ESP_LOGE(TAG, "Unable to activate mender-client"); + goto RELEASE; + } + /* Wait for mender-mcu-client events */ xEventGroupWaitBits(mender_client_events, MENDER_CLIENT_EVENT_RESTART, pdTRUE, pdFALSE, portMAX_DELAY); - /* Deactivate mender add-ons */ -#ifdef CONFIG_MENDER_CLIENT_ADD_ON_TROUBLESHOOT - mender_troubleshoot_deactivate(); -#endif /* CONFIG_MENDER_CLIENT_ADD_ON_TROUBLESHOOT */ - - /* Release mender add-ons */ -#ifdef CONFIG_MENDER_CLIENT_ADD_ON_TROUBLESHOOT - mender_troubleshoot_exit(); -#endif /* CONFIG_MENDER_CLIENT_ADD_ON_TROUBLESHOOT */ -#ifdef CONFIG_MENDER_CLIENT_ADD_ON_INVENTORY - mender_inventory_exit(); -#endif /* CONFIG_MENDER_CLIENT_ADD_ON_INVENTORY */ -#ifdef CONFIG_MENDER_CLIENT_ADD_ON_CONFIGURE - mender_configure_exit(); -#endif /* CONFIG_MENDER_CLIENT_ADD_ON_CONFIGURE */ +RELEASE: - /* Exit mender-client */ + /* Deactivate and release mender-client */ + mender_client_deactivate(); mender_client_exit(); /* Release event group */ From 0c367c67776c9e4ac9fd322e4cdbd9c8c5fb33e3 Mon Sep 17 00:00:00 2001 From: Joel Guittet Date: Fri, 21 Jun 2024 18:13:03 +0200 Subject: [PATCH 19/21] client: add network connect/disconnect callbacks --- .../mender-mcu-client/mender-mcu-client | 2 +- main/main.c | 60 +++++++++++++++---- 2 files changed, 50 insertions(+), 12 deletions(-) diff --git a/components/mender-mcu-client/mender-mcu-client b/components/mender-mcu-client/mender-mcu-client index 78a594e..47c9b18 160000 --- a/components/mender-mcu-client/mender-mcu-client +++ b/components/mender-mcu-client/mender-mcu-client @@ -1 +1 @@ -Subproject commit 78a594ef233e96f53ee3fdf43fb9b0666ed71088 +Subproject commit 47c9b180aee67f32ae5b4ff25064481b3ab092e5 diff --git a/main/main.c b/main/main.c index 87922ed..30d535b 100644 --- a/main/main.c +++ b/main/main.c @@ -54,6 +54,49 @@ static const char *TAG = "main"; static EventGroupHandle_t mender_client_events; #define MENDER_CLIENT_EVENT_RESTART (1 << 0) +/** + * @brief Network connnect callback + * @return MENDER_OK if network is connected following the request, error code otherwise + */ +static mender_err_t +network_connect_cb(void) { + + ESP_LOGI(TAG, "Mender client connect network"); + + /* This callback can be used to configure network connection */ + /* Note that the application can connect the network before if required */ + /* This callback only indicates the mender-client requests network access now */ + /* In this example this helper function configures Wi-Fi or Ethernet, as selected in menuconfig */ + /* Read "Establishing Wi-Fi or Ethernet Connection" section in examples/protocols/README.md for more information */ + if (ESP_OK != example_connect()) { + ESP_LOGE(TAG, "Unable to connect network"); + return MENDER_FAIL; + } + + return MENDER_OK; +} + +/** + * @brief Network release callback + * @return MENDER_OK if network is released following the request, error code otherwise + */ +static mender_err_t +network_release_cb(void) { + + ESP_LOGI(TAG, "Mender client released network"); + + /* This callback can be used to release network connection */ + /* Note that the application can keep network activated if required */ + /* This callback only indicates the mender-client doesn't request network access now */ + /* in this example this helper function disconnects the network */ + if (ESP_OK != example_disconnect()) { + ESP_LOGE(TAG, "Unable to disconnect network"); + return MENDER_FAIL; + } + + return MENDER_OK; +} + /** * @brief Authentication success callback * @return MENDER_OK if application is marked valid and success deployment status should be reported to the server, error code otherwise @@ -420,18 +463,11 @@ app_main(void) { ESP_ERROR_CHECK(esp_netif_init()); ESP_ERROR_CHECK(esp_event_loop_create_default()); - /* - * This helper function configures Wi-Fi or Ethernet, as selected in menuconfig. - * Read "Establishing Wi-Fi or Ethernet Connection" section in - * examples/protocols/README.md for more information about this function. - */ - ESP_ERROR_CHECK(example_connect()); - /* Read base MAC address of the device */ uint8_t mac[6]; char mac_address[18]; - ESP_ERROR_CHECK(esp_base_mac_addr_get(mac)); - snprintf(mac_address, sizeof(mac_address), "%02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); + ESP_ERROR_CHECK(esp_read_mac(mac, ESP_MAC_WIFI_STA)); + sprintf(mac_address, "%02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); ESP_LOGI(TAG, "MAC address of the device '%s'", mac_address); /* Create mender-client event group */ @@ -446,7 +482,7 @@ app_main(void) { /* Compute artifact name */ char artifact_name[128]; - snprintf(artifact_name, sizeof(artifact_name), "%s-v%s", running_app_info.project_name, running_app_info.version); + sprintf(artifact_name, "%s-v%s", running_app_info.project_name, running_app_info.version); /* Retrieve device type */ char *device_type = running_app_info.project_name; @@ -461,7 +497,9 @@ app_main(void) { .authentication_poll_interval = 0, .update_poll_interval = 0, .recommissioning = false }; - mender_client_callbacks_t mender_client_callbacks = { .authentication_success = authentication_success_cb, + mender_client_callbacks_t mender_client_callbacks = { .network_connect = network_connect_cb, + .network_release = network_release_cb, + .authentication_success = authentication_success_cb, .authentication_failure = authentication_failure_cb, .deployment_status = deployment_status_cb, .restart = restart_cb }; From 6f761f5819ab59e57b0ee50ba2142bacfeaf2382 Mon Sep 17 00:00:00 2001 From: Joel Guittet Date: Sat, 29 Jun 2024 23:39:27 +0200 Subject: [PATCH 20/21] mender-mcu-client: update to latest release --- components/mender-mcu-client/mender-mcu-client | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/mender-mcu-client/mender-mcu-client b/components/mender-mcu-client/mender-mcu-client index 47c9b18..5f5a1c4 160000 --- a/components/mender-mcu-client/mender-mcu-client +++ b/components/mender-mcu-client/mender-mcu-client @@ -1 +1 @@ -Subproject commit 47c9b180aee67f32ae5b4ff25064481b3ab092e5 +Subproject commit 5f5a1c400df6c8c7c6369226138f2a794e8c758e From 06e6d588e9c6ac65403d2d160e69537f38cc37f8 Mon Sep 17 00:00:00 2001 From: Joel Guittet Date: Sat, 29 Jun 2024 23:39:40 +0200 Subject: [PATCH 21/21] readme: update logs following update of the client --- README.md | 155 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 97 insertions(+), 58 deletions(-) diff --git a/README.md b/README.md index fcab9e1..b466618 100755 --- a/README.md +++ b/README.md @@ -49,30 +49,47 @@ Note this also constraints to download [esp_websocket_client](https://components After flashing the application on the ESP32 module and displaying logs, you should be able to see the following: ``` -I (6546) main: MAC address of the device '7c:9e:bd:ed:bc:1c' -I (6556) main: Running project 'mender-esp32-example' version '0.1' -I (6576) mender: ./components/mender-mcu-client/mender-mcu-client/platform/storage/esp-idf/nvs/src/mender-storage.c (90): Authentication keys are not available -I (6576) mender: ./components/mender-mcu-client/mender-mcu-client/platform/tls/generic/mbedtls/src/mender-tls.c (126): Generating authentication keys... -I (8306) main: Mender client initialized -I (8306) main: Mender inventory initialized -I (10766) wifi:idx:0 (ifx:0, 1a:18:cb:a8:e5:12), tid:0, ssn:1, winSize:64 -I (11056) mender: ./components/mender-mcu-client/mender-mcu-client/platform/storage/esp-idf/nvs/src/mender-storage.c (169): OTA ID or artifact name not available -I (13116) esp-x509-crt-bundle: Certificate validated -I (14256) HTTP_CLIENT: Body received in fetch header state, 0x3ffc8681, 86 -E (14256) mender: ./components/mender-mcu-client/mender-mcu-client/core/src/mender-api.c (854): [401] Unauthorized: dev auth: unauthorized -I (14266) main: Mender client authentication failed (1/3) +I (640) main: MAC address of the device '7c:9e:bd:ed:bc:1c' +I (650) main: Running project 'mender-esp32-example' version '0.1' +I (660) main: Mender client initialized +I (660) main: Mender inventory add-on registered +I (680) mender: ./components/mender-mcu-client/mender-mcu-client/platform/storage/esp-idf/nvs/src/mender-storage.c (163): Deployment data not available +I (680) main: Mender client connect network +I (690) example_connect: Start example_connect. + +... (wifi connecting to the network) + +I (5560) example_connect: Got IPv4 event: Interface "example_netif_sta" address: 192.168.2.140 +I (5640) example_connect: Got IPv6 event: Interface "example_netif_sta" address: fe80:0000:0000:0000:7e9e:bdff:feed:bc1c, type: +ESP_IP6_ADDR_IS_LINK_LOCAL +I (5640) example_common: Connected to example_netif_sta +I (5650) example_common: - IPv4 address: 192.168.2.140, +I (5650) example_common: - IPv6 address: fe80:0000:0000:0000:7e9e:bdff:feed:bc1c, type: ESP_IP6_ADDR_IS_LINK_LOCAL +I (7740) esp-x509-crt-bundle: Certificate validated +I (8870) HTTP_CLIENT: Body received in fetch header state, 0x3ffc9b11, 86 +E (8870) mender: ./components/mender-mcu-client/mender-mcu-client/core/src/mender-api.c (900): [401] Unauthorized: dev auth: unauthorized +I (8880) main: Mender client authentication failed +I (8880) main: Mender client released network ``` Which means you now have generated authentication keys on the device. Authentication keys are stored in NVS partition of the ESP32. You now have to accept your device on the mender interface. Once it is accepted on the mender interface the following will be displayed: ``` -I (68626) esp-x509-crt-bundle: Certificate validated -I (69956) HTTP_CLIENT: Body received in fetch header state, 0x3ffc8d39, 139 -I (69966) main: Mender client authenticated -I (69966) mender: ./components/mender-mcu-client/mender-mcu-client/core/src/mender-client.c (433): Checking for deployment... -I (70466) esp-x509-crt-bundle: Certificate validated -I (71396) mender: ./components/mender-mcu-client/mender-mcu-client/core/src/mender-client.c (441): No deployment available -I (71896) esp-x509-crt-bundle: Certificate validated +I (60670) main: Mender client connect network +I (60670) example_connect: Start example_connect. + +... (wifi connecting to the network) + +I (65640) example_common: Connected to example_netif_sta +I (65650) example_common: - IPv4 address: 192.168.2.140, +I (65650) example_common: - IPv6 address: fe80:0000:0000:0000:7e9e:bdff:feed:bc1c, type: ESP_IP6_ADDR_IS_LINK_LOCAL +I (68150) esp-x509-crt-bundle: Certificate validated +I (69290) HTTP_CLIENT: Body received in fetch header state, 0x3ffc6070, 156 +I (69290) main: Mender client authenticated +I (69290) mender: ./components/mender-mcu-client/mender-mcu-client/core/src/mender-client.c (884): Checking for deployment... +I (69740) esp-x509-crt-bundle: Certificate validated +I (70720) mender: ./components/mender-mcu-client/mender-mcu-client/core/src/mender-client.c (892): No deployment available +I (70720) main: Mender client released network ``` Congratulation! Your device is connected to the mender server. Device type is `mender-esp32-example` and the current software version is displayed. @@ -92,48 +109,70 @@ Upload the artifact `mender-esp32-example-v0.2.mender` to the mender server and The device checks for the new deployment, downloads the artifact and installs it on the next ota partition. Then it reboots to apply the update: ``` -I (249966) mender: ./components/mender-mcu-client/mender-mcu-client/core/src/mender-client.c (433): Checking for deployment... -I (250696) esp-x509-crt-bundle: Certificate validated -I (251626) HTTP_CLIENT: Body received in fetch header state, 0x3ffc7c88, 140 -I (251626) mender: ./components/mender-mcu-client/mender-mcu-client/core/src/mender-client.c (453): Downloading deployment artifact with id '895ce47b-566a-472e-b72e-9300c40c8cc9', artifact name 'mender-esp32-example-v0.2' and uri 'https://hosted-mender-artifacts.s3.amazonaws.com/6370b06a7f0deaedb279fb6a/7a463d2a-8078-4f51-bbad-9560201e80af?X-Amz-Algorit -I (252126) esp-x509-crt-bundle: Certificate validated -I (253266) main: Deployment status is 'downloading' -I (253776) esp-x509-crt-bundle: Certificate validated -I (254906) mender: ./components/mender-mcu-client/mender-mcu-client/core/src/mender-artifact.c (380): Artifact has valid version -I (254906) mender: ./components/mender-mcu-client/mender-mcu-client/platform/ota/esp-idf/src/mender-ota.c (48): Start flashing OTA artifact 'mender-esp32-example.bin' with size 1009936 -I (254926) mender: ./components/mender-mcu-client/mender-mcu-client/platform/ota/esp-idf/src/mender-ota.c (61): Next update partition is 'ota_1', subtype 17 at offset 0x210000 and with size 2031616 -I (313976) esp_image: segment 0: paddr=00210020 vaddr=3f400020 size=3ac18h (240664) map -I (314046) esp_image: segment 1: paddr=0024ac40 vaddr=3ffb0000 size=033cch ( 13260) -I (314056) esp_image: segment 2: paddr=0024e014 vaddr=40080000 size=02004h ( 8196) -I (314056) esp_image: segment 3: paddr=00250020 vaddr=400d0020 size=a3564h (669028) map -I (314256) esp_image: segment 4: paddr=002f358c vaddr=40082004 size=13358h ( 78680) -I (314296) mender: ./components/mender-mcu-client/mender-mcu-client/core/src/mender-client.c (463): Download done, installing artifact -I (314796) esp-x509-crt-bundle: Certificate validated -I (315936) main: Deployment status is 'installing' -I (315936) esp_image: segment 0: paddr=00210020 vaddr=3f400020 size=3ac18h (240664) map -I (316006) esp_image: segment 1: paddr=0024ac40 vaddr=3ffb0000 size=033cch ( 13260) -I (316016) esp_image: segment 2: paddr=0024e014 vaddr=40080000 size=02004h ( 8196) -I (316016) esp_image: segment 3: paddr=00250020 vaddr=400d0020 size=a3564h (669028) map -I (316216) esp_image: segment 4: paddr=002f358c vaddr=40082004 size=13358h ( 78680) -I (316856) esp-x509-crt-bundle: Certificate validated -I (317986) main: Deployment status is 'rebooting' -I (317996) main: Restarting system +I (249310) main: Mender client connect network +I (249310) example_connect: Start example_connect. + +... (wifi connecting to the network) + +I (254100) example_common: Connected to example_netif_sta +I (254100) example_common: - IPv4 address: 192.168.2.140, +I (254110) example_common: - IPv6 address: fe80:0000:0000:0000:7e9e:bdff:feed:bc1c, type: ESP_IP6_ADDR_IS_LINK_LOCAL +I (254120) mender: ./components/mender-mcu-client/mender-mcu-client/core/src/mender-client.c (884): Checking for deployment... +I (254190) wifi:idx:0 (ifx:0, ca:fb:00:03:97:ce), tid:0, ssn:1, winSize:64 +I (255140) esp-x509-crt-bundle: Certificate validated +I (256120) HTTP_CLIENT: Body received in fetch header state, 0x3ffcae18, 140 +I (256120) mender: ./components/mender-mcu-client/mender-mcu-client/core/src/mender-client.c (918): Downloading deployment artifact with id '2c878cbb-3268-4aac-8fd9-9fdb07430739', artifact name 'mender-esp32-example-v0.2' and uri 'https://hosted-mender-artifacts.s3.amazonaws.com/6370b06a7f0deaedb279fb6a/8041a7d0-5db2-4223-b512-15c98eab87fb?X-Amz-Algorit +I (256570) esp-x509-crt-bundle: Certificate validated +I (257650) main: Deployment status is 'downloading' +I (258420) esp-x509-crt-bundle: Certificate validated +I (259550) mender: ./components/mender-mcu-client/mender-mcu-client/core/src/mender-artifact.c (382): Artifact has valid versionI (260170) mender: ./components/mender-mcu-client/mender-mcu-client/platform/flash/esp-idf/src/mender-flash.c (48): Start flashing artifact 'mender-esp32-example.bin' with size 931696 +I (260180) mender: ./components/mender-mcu-client/mender-mcu-client/platform/flash/esp-idf/src/mender-flash.c (61): Next update +partition is 'ota_1', subtype 17 at offset 0x210000 and with size 2031616 +I (318090) esp_image: segment 0: paddr=00210020 vaddr=3f400020 size=38c98h (232600) map +I (318170) esp_image: segment 1: paddr=00248cc0 vaddr=3ffb0000 size=0328ch ( 12940) +I (318170) esp_image: segment 2: paddr=0024bf54 vaddr=40080000 size=040c4h ( 16580) +I (318180) esp_image: segment 3: paddr=00250020 vaddr=400d0020 size=93a4ch (604748) map +I (318380) esp_image: segment 4: paddr=002e3a74 vaddr=400840c4 size=0fccch ( 64716) +I (318400) mender: ./components/mender-mcu-client/mender-mcu-client/core/src/mender-client.c (930): Download done, installing artifact +I (319450) esp-x509-crt-bundle: Certificate validated +I (320580) main: Deployment status is 'installing' +I (320580) esp_image: segment 0: paddr=00210020 vaddr=3f400020 size=38c98h (232600) map +I (320660) esp_image: segment 1: paddr=00248cc0 vaddr=3ffb0000 size=0328ch ( 12940) +I (320670) esp_image: segment 2: paddr=0024bf54 vaddr=40080000 size=040c4h ( 16580) +I (320670) esp_image: segment 3: paddr=00250020 vaddr=400d0020 size=93a4ch (604748) map +I (320870) esp_image: segment 4: paddr=002e3a74 vaddr=400840c4 size=0fccch ( 64716) +I (321500) esp-x509-crt-bundle: Certificate validated +I (322630) main: Deployment status is 'rebooting' +I (322630) main: Mender client released network ... -I (5751) main: MAC address of the device '7c:9e:bd:ed:bc:1c' -I (5761) main: Running project 'mender-esp32-example' version '0.2' -I (5781) main: Mender client initialized -I (5791) main: Mender inventory initialized -I (7831) esp-x509-crt-bundle: Certificate validated -I (8991) HTTP_CLIENT: Body received in fetch header state, 0x3ffcb00d, 139 -I (8991) main: Mender client authenticated -I (9061) mender: ./components/mender-mcu-client/mender-mcu-client/platform/ota/esp-idf/src/mender-ota.c (176): Application has been mark valid and rollback canceled -I (9491) esp-x509-crt-bundle: Certificate validated -I (10631) main: Deployment status is 'success' -I (10651) mender: ./components/mender-mcu-client/mender-mcu-client/core/src/mender-client.c (433): Checking for deployment... -I (11131) esp-x509-crt-bundle: Certificate validated -I (12061) mender: ./components/mender-mcu-client/mender-mcu-client/core/src/mender-client.c (441): No deployment available +I (329220) main: Restarting system + +... (system is rebooting) + +I (696) main: MAC address of the device '7c:9e:bd:ed:bc:1c' +I (696) main: Running project 'mender-esp32-example' version '0.2' +I (706) main: Mender client initialized +I (706) main: Mender inventory add-on registered +I (726) main: Mender client connect network +I (726) example_connect: Start example_connect. + +... (wifi connecting to the network) + +I (5686) example_common: Connected to example_netif_sta +I (5696) example_common: - IPv4 address: 192.168.2.140, +I (5696) example_common: - IPv6 address: fe80:0000:0000:0000:7e9e:bdff:feed:bc1c, type: ESP_IP6_ADDR_IS_LINK_LOCAL +I (7656) esp-x509-crt-bundle: Certificate validated +I (8706) HTTP_CLIENT: Body received in fetch header state, 0x3ffca4b8, 156 +I (8706) main: Mender client authenticated +I (8776) mender: ./components/mender-mcu-client/mender-mcu-client/platform/flash/esp-idf/src/mender-flash.c (171): Application has been mark valid and rollback canceled +I (9296) esp-x509-crt-bundle: Certificate validated +I (10426) main: Deployment status is 'success' +I (10446) mender: ./components/mender-mcu-client/mender-mcu-client/core/src/mender-client.c (884): Checking for deployment... +I (10936) esp-x509-crt-bundle: Certificate validated +I (11866) mender: ./components/mender-mcu-client/mender-mcu-client/core/src/mender-client.c (892): No deployment available +I (11866) main: Mender client released network ``` Congratulation! You have updated the device. Mender server displays the success of the deployment.