From 92316f1330c74ee700980a377b0a563910a3310a Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Sun, 28 Jul 2024 15:59:33 +0800 Subject: [PATCH 1/4] Move OTA max data buffer number to project configurations. --- .../CMakeLists.txt | 2 +- main/Kconfig.projbuild | 16 ++++++++-------- .../ota_over_mqtt_demo/ota_over_mqtt_demo.c | 5 ++--- .../ota_over_mqtt_demo_config.h | 5 +++++ sdkconfig.defaults | 2 +- 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/components/FreeRTOS-Libraries-Integration-Tests/CMakeLists.txt b/components/FreeRTOS-Libraries-Integration-Tests/CMakeLists.txt index f78715b..3d74940 100644 --- a/components/FreeRTOS-Libraries-Integration-Tests/CMakeLists.txt +++ b/components/FreeRTOS-Libraries-Integration-Tests/CMakeLists.txt @@ -8,7 +8,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/FreeRTOS-Libraries-Integration-Tests/src/trans include(${CMAKE_CURRENT_LIST_DIR}/FreeRTOS-Libraries-Integration-Tests/src/mqtt_test.cmake) # This gives OTA_PAL_TEST_SOURCES, and OTA_PAL_TEST_INCLUDE_DIRS -include(${CMAKE_CURRENT_LIST_DIR}/FreeRTOS-Libraries-Integration-Tests/src/ota_pal_test.cmake) +# include(${CMAKE_CURRENT_LIST_DIR}/FreeRTOS-Libraries-Integration-Tests/src/ota_pal_test.cmake) # This gives PKCS11_TEST_SOURCES, and PKCS11_TEST_INCLUDE_DIRS include(${CMAKE_CURRENT_LIST_DIR}/FreeRTOS-Libraries-Integration-Tests/src/pkcs11_test.cmake) diff --git a/main/Kconfig.projbuild b/main/Kconfig.projbuild index a929b77..12e751e 100644 --- a/main/Kconfig.projbuild +++ b/main/Kconfig.projbuild @@ -44,14 +44,6 @@ menu "Featured FreeRTOS IoT Integration" bool "Transport Interface Test." default n - config GRI_OTA_PAL_TEST_ENABLED - bool "OTA PAL Test." - default n - - config GRI_OTA_E2E_TEST_ENABLED - bool "OTA end-to-end Test." - default n - config GRI_CORE_PKCS11_TEST_ENABLED bool "CorePKCS#11 Test." default n @@ -211,6 +203,10 @@ menu "Featured FreeRTOS IoT Integration" int "OTA demo task stack size." default 3072 + config GRI_OTA_MAX_NUM_DATA_BUFFERS + int "OTA buffer number." + default 2 + endmenu # OTA demo configurations endmenu # Qualification Test Configurations @@ -463,6 +459,10 @@ menu "Featured FreeRTOS IoT Integration" int "Application version build." default 0 + config GRI_OTA_MAX_NUM_DATA_BUFFERS + int "OTA buffer number." + default 2 + endmenu # OTA demo configurations endmenu # Golden Reference Integration diff --git a/main/demo_tasks/ota_over_mqtt_demo/ota_over_mqtt_demo.c b/main/demo_tasks/ota_over_mqtt_demo/ota_over_mqtt_demo.c index 47c583b..01ee522 100644 --- a/main/demo_tasks/ota_over_mqtt_demo/ota_over_mqtt_demo.c +++ b/main/demo_tasks/ota_over_mqtt_demo/ota_over_mqtt_demo.c @@ -167,7 +167,6 @@ #define MAX_THING_NAME_SIZE 128U #define MAX_JOB_ID_LENGTH ( 64U ) -#define MAX_NUM_OF_OTA_DATA_BUFFERS ( 2U ) /** * @brief Used to clear bits in a task's notification value. @@ -898,7 +897,7 @@ static uint16_t getFreeOTABuffers( void ) if( xSemaphoreTake( bufferSemaphore, portMAX_DELAY ) == pdTRUE ) { - for( ulIndex = 0; ulIndex < MAX_NUM_OF_OTA_DATA_BUFFERS; ulIndex++ ) + for( ulIndex = 0; ulIndex < otaconfigMAX_NUM_OTA_DATA_BUFFERS; ulIndex++ ) { if( dataBuffers[ ulIndex ].bufferUsed == false ) { @@ -940,7 +939,7 @@ static OtaDataEvent_t * getOtaDataEventBuffer( void ) if( xSemaphoreTake( bufferSemaphore, portMAX_DELAY ) == pdTRUE ) { - for( ulIndex = 0; ulIndex < MAX_NUM_OF_OTA_DATA_BUFFERS; ulIndex++ ) + for( ulIndex = 0; ulIndex < otaconfigMAX_NUM_OTA_DATA_BUFFERS; ulIndex++ ) { if( dataBuffers[ ulIndex ].bufferUsed == false ) { diff --git a/main/demo_tasks/ota_over_mqtt_demo/ota_over_mqtt_demo_config.h b/main/demo_tasks/ota_over_mqtt_demo/ota_over_mqtt_demo_config.h index 453b993..cad1e39 100644 --- a/main/demo_tasks/ota_over_mqtt_demo/ota_over_mqtt_demo_config.h +++ b/main/demo_tasks/ota_over_mqtt_demo/ota_over_mqtt_demo_config.h @@ -89,6 +89,11 @@ */ #define otademoconfigDEMO_TASK_STACK_SIZE ( CONFIG_GRI_OTA_DEMO_DEMO_TASK_STACK_SIZE ) +/** + * @brief The number of OTA data buffer. + */ +#define otaconfigMAX_NUM_OTA_DATA_BUFFERS ( CONFIG_GRI_OTA_MAX_NUM_DATA_BUFFERS ) + /** * @brief The version for the firmware which is running. OTA agent uses this * version number to perform anti-rollback validation. The firmware version for the diff --git a/sdkconfig.defaults b/sdkconfig.defaults index d50e27c..a728902 100644 --- a/sdkconfig.defaults +++ b/sdkconfig.defaults @@ -40,7 +40,7 @@ CONFIG_LWIP_MAX_SOCKETS=8 # AWS OTA CONFIG_LOG2_FILE_BLOCK_SIZE=12 CONFIG_MAX_NUM_BLOCKS_REQUEST=8 -CONFIG_MAX_NUM_OTA_DATA_BUFFERS=8 +CONFIG_GRI_OTA_MAX_NUM_DATA_BUFFERS=2 CONFIG_ALLOW_DOWNGRADE=0 CONFIG_OTA_DATA_OVER_MQTT=y # CONFIG_OTA_DATA_OVER_HTTP is not set From e5b1f279318b37ee439d0fbeda15465a699abeeb Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Sun, 28 Jul 2024 16:27:43 +0800 Subject: [PATCH 2/4] Fix CI build tests --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1033698..72cbdaf 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -56,4 +56,4 @@ jobs: esp_idf_version: ${{ matrix.esp_idf_version }} target: ${{ matrix.esp_target }} path: './' - command: python -m pip install --upgrade idf-component-manager || idf.py build + command: python -m pip install --upgrade idf-component-manager && idf.py build From 1af93ba91e62e7c697267ca156079769d6d3133b Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Sun, 28 Jul 2024 19:35:18 +0800 Subject: [PATCH 3/4] Rename otaconfigMAX_NUM_OTA_DATA_BUFFERS to otademoconfigMAX_NUM_OTA_DATA_BUFFERS --- .../FreeRTOS-Libraries-Integration-Tests/CMakeLists.txt | 3 --- main/demo_tasks/ota_over_mqtt_demo/ota_over_mqtt_demo.c | 6 +++--- .../ota_over_mqtt_demo/ota_over_mqtt_demo_config.h | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/components/FreeRTOS-Libraries-Integration-Tests/CMakeLists.txt b/components/FreeRTOS-Libraries-Integration-Tests/CMakeLists.txt index 3d74940..9c218a1 100644 --- a/components/FreeRTOS-Libraries-Integration-Tests/CMakeLists.txt +++ b/components/FreeRTOS-Libraries-Integration-Tests/CMakeLists.txt @@ -7,9 +7,6 @@ include(${CMAKE_CURRENT_LIST_DIR}/FreeRTOS-Libraries-Integration-Tests/src/trans # This gives MQTT_TEST_SOURCES, and MQTT_TEST_INCLUDE_DIRS include(${CMAKE_CURRENT_LIST_DIR}/FreeRTOS-Libraries-Integration-Tests/src/mqtt_test.cmake) -# This gives OTA_PAL_TEST_SOURCES, and OTA_PAL_TEST_INCLUDE_DIRS -# include(${CMAKE_CURRENT_LIST_DIR}/FreeRTOS-Libraries-Integration-Tests/src/ota_pal_test.cmake) - # This gives PKCS11_TEST_SOURCES, and PKCS11_TEST_INCLUDE_DIRS include(${CMAKE_CURRENT_LIST_DIR}/FreeRTOS-Libraries-Integration-Tests/src/pkcs11_test.cmake) diff --git a/main/demo_tasks/ota_over_mqtt_demo/ota_over_mqtt_demo.c b/main/demo_tasks/ota_over_mqtt_demo/ota_over_mqtt_demo.c index 01ee522..1a568a3 100644 --- a/main/demo_tasks/ota_over_mqtt_demo/ota_over_mqtt_demo.c +++ b/main/demo_tasks/ota_over_mqtt_demo/ota_over_mqtt_demo.c @@ -228,7 +228,7 @@ static uint8_t currentFileId = 0; static uint32_t totalBytesReceived = 0; char globalJobId[ MAX_JOB_ID_LENGTH ] = { 0 }; -static OtaDataEvent_t dataBuffers[ otaconfigMAX_NUM_OTA_DATA_BUFFERS ] = { 0 }; +static OtaDataEvent_t dataBuffers[ otademoconfigMAX_NUM_OTA_DATA_BUFFERS ] = { 0 }; static OtaJobEventData_t jobDocBuffer = { 0 }; static AfrOtaJobDocumentFields_t jobFields = { 0 }; static uint8_t OtaImageSignatureDecoded[ OTA_MAX_SIGNATURE_SIZE ] = { 0 }; @@ -897,7 +897,7 @@ static uint16_t getFreeOTABuffers( void ) if( xSemaphoreTake( bufferSemaphore, portMAX_DELAY ) == pdTRUE ) { - for( ulIndex = 0; ulIndex < otaconfigMAX_NUM_OTA_DATA_BUFFERS; ulIndex++ ) + for( ulIndex = 0; ulIndex < otademoconfigMAX_NUM_OTA_DATA_BUFFERS; ulIndex++ ) { if( dataBuffers[ ulIndex ].bufferUsed == false ) { @@ -939,7 +939,7 @@ static OtaDataEvent_t * getOtaDataEventBuffer( void ) if( xSemaphoreTake( bufferSemaphore, portMAX_DELAY ) == pdTRUE ) { - for( ulIndex = 0; ulIndex < otaconfigMAX_NUM_OTA_DATA_BUFFERS; ulIndex++ ) + for( ulIndex = 0; ulIndex < otademoconfigMAX_NUM_OTA_DATA_BUFFERS; ulIndex++ ) { if( dataBuffers[ ulIndex ].bufferUsed == false ) { diff --git a/main/demo_tasks/ota_over_mqtt_demo/ota_over_mqtt_demo_config.h b/main/demo_tasks/ota_over_mqtt_demo/ota_over_mqtt_demo_config.h index cad1e39..d410786 100644 --- a/main/demo_tasks/ota_over_mqtt_demo/ota_over_mqtt_demo_config.h +++ b/main/demo_tasks/ota_over_mqtt_demo/ota_over_mqtt_demo_config.h @@ -92,7 +92,7 @@ /** * @brief The number of OTA data buffer. */ -#define otaconfigMAX_NUM_OTA_DATA_BUFFERS ( CONFIG_GRI_OTA_MAX_NUM_DATA_BUFFERS ) +#define otademoconfigMAX_NUM_OTA_DATA_BUFFERS ( CONFIG_GRI_OTA_MAX_NUM_DATA_BUFFERS ) /** * @brief The version for the firmware which is running. OTA agent uses this From be24b76fdff506e5dab7f42eb9365f43f0cd4afb Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Sun, 28 Jul 2024 19:37:54 +0800 Subject: [PATCH 4/4] Formatting. --- .../ota_over_mqtt_demo_config.h | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/main/demo_tasks/ota_over_mqtt_demo/ota_over_mqtt_demo_config.h b/main/demo_tasks/ota_over_mqtt_demo/ota_over_mqtt_demo_config.h index d410786..9398a93 100644 --- a/main/demo_tasks/ota_over_mqtt_demo/ota_over_mqtt_demo_config.h +++ b/main/demo_tasks/ota_over_mqtt_demo/ota_over_mqtt_demo_config.h @@ -43,56 +43,56 @@ /** * @brief The thing name of the device. */ -#define otademoconfigCLIENT_IDENTIFIER ( CONFIG_GRI_THING_NAME ) +#define otademoconfigCLIENT_IDENTIFIER ( CONFIG_GRI_THING_NAME ) /** * @brief The maximum size of the file paths used in the demo. */ -#define otademoconfigMAX_FILE_PATH_SIZE ( CONFIG_GRI_OTA_DEMO_MAX_FILE_PATH_SIZE ) +#define otademoconfigMAX_FILE_PATH_SIZE ( CONFIG_GRI_OTA_DEMO_MAX_FILE_PATH_SIZE ) /** * @brief The maximum size of the stream name required for downloading update file * from streaming service. */ -#define otademoconfigMAX_STREAM_NAME_SIZE ( CONFIG_GRI_OTA_DEMO_MAX_STREAM_NAME_SIZE ) +#define otademoconfigMAX_STREAM_NAME_SIZE ( CONFIG_GRI_OTA_DEMO_MAX_STREAM_NAME_SIZE ) /** * @brief The delay used in the OTA demo task to periodically output the OTA * statistics like number of packets received, dropped, processed and queued per connection. */ -#define otademoconfigTASK_DELAY_MS ( CONFIG_GRI_OTA_DEMO_TASK_DELAY_MS ) +#define otademoconfigTASK_DELAY_MS ( CONFIG_GRI_OTA_DEMO_TASK_DELAY_MS ) /** * @brief The maximum time for which OTA demo waits for an MQTT operation to be complete. * This involves receiving an acknowledgment for broker for SUBSCRIBE, UNSUBSCRIBE and non * QOS0 publishes. */ -#define otademoconfigMQTT_TIMEOUT_MS ( CONFIG_GRI_OTA_DEMO_MQTT_TIMEOUT_MS ) +#define otademoconfigMQTT_TIMEOUT_MS ( CONFIG_GRI_OTA_DEMO_MQTT_TIMEOUT_MS ) /** * @brief The task priority of OTA agent task. */ -#define otademoconfigAGENT_TASK_PRIORITY ( CONFIG_GRI_OTA_DEMO_AGENT_TASK_PRIORITY ) +#define otademoconfigAGENT_TASK_PRIORITY ( CONFIG_GRI_OTA_DEMO_AGENT_TASK_PRIORITY ) /** * @brief The stack size of OTA agent task. */ -#define otademoconfigAGENT_TASK_STACK_SIZE ( CONFIG_GRI_OTA_DEMO_AGENT_TASK_STACK_SIZE ) +#define otademoconfigAGENT_TASK_STACK_SIZE ( CONFIG_GRI_OTA_DEMO_AGENT_TASK_STACK_SIZE ) /** * @brief The task priority of the OTA demo task. */ -#define otademoconfigDEMO_TASK_PRIORITY ( CONFIG_GRI_OTA_DEMO_DEMO_TASK_PRIORITY ) +#define otademoconfigDEMO_TASK_PRIORITY ( CONFIG_GRI_OTA_DEMO_DEMO_TASK_PRIORITY ) /** * @brief The task stack size of the OTA demo task. */ -#define otademoconfigDEMO_TASK_STACK_SIZE ( CONFIG_GRI_OTA_DEMO_DEMO_TASK_STACK_SIZE ) +#define otademoconfigDEMO_TASK_STACK_SIZE ( CONFIG_GRI_OTA_DEMO_DEMO_TASK_STACK_SIZE ) /** * @brief The number of OTA data buffer. */ -#define otademoconfigMAX_NUM_OTA_DATA_BUFFERS ( CONFIG_GRI_OTA_MAX_NUM_DATA_BUFFERS ) +#define otademoconfigMAX_NUM_OTA_DATA_BUFFERS ( CONFIG_GRI_OTA_MAX_NUM_DATA_BUFFERS ) /** * @brief The version for the firmware which is running. OTA agent uses this @@ -100,9 +100,9 @@ * download image should be higher than the current version, otherwise the new image is * rejected in self test phase. */ -#define APP_VERSION_MAJOR ( CONFIG_GRI_OTA_DEMO_APP_VERSION_MAJOR ) -#define APP_VERSION_MINOR ( CONFIG_GRI_OTA_DEMO_APP_VERSION_MINOR ) -#define APP_VERSION_BUILD ( CONFIG_GRI_OTA_DEMO_APP_VERSION_BUILD ) +#define APP_VERSION_MAJOR ( CONFIG_GRI_OTA_DEMO_APP_VERSION_MAJOR ) +#define APP_VERSION_MINOR ( CONFIG_GRI_OTA_DEMO_APP_VERSION_MINOR ) +#define APP_VERSION_BUILD ( CONFIG_GRI_OTA_DEMO_APP_VERSION_BUILD ) /* *INDENT-OFF* */ #ifdef __cplusplus