From e630c0d7cf3d7af0ad3b3831cca966a0b1f4480a Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Wed, 14 Sep 2022 16:47:02 +0800 Subject: [PATCH 01/32] Update LTS 2.0 libraries. --- .gitmodules | 9 ++++++--- components/esp-aws-iot | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.gitmodules b/.gitmodules index 705cee2..0b33e9d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,9 @@ -[submodule "components/esp-aws-iot"] - path = components/esp-aws-iot - url = https://github.com/espressif/esp-aws-iot.git [submodule "components/esp_secure_cert_mgr"] path = components/esp_secure_cert_mgr url = https://github.com/espressif/esp_secure_cert_mgr.git +[submodule "components/FreeRTOS-Libraries-Integration-Tests/FreeRTOS-Libraries-Integration-Tests"] + path = components/FreeRTOS-Libraries-Integration-Tests/FreeRTOS-Libraries-Integration-Tests + url = git@github.com:ActoryOu/FreeRTOS-Libraries-Integration-Tests.git +[submodule "components/esp-aws-iot"] + path = components/esp-aws-iot + url = https://github.com/ActoryOu/esp-aws-iot/ diff --git a/components/esp-aws-iot b/components/esp-aws-iot index dd1d2c6..3b3f998 160000 --- a/components/esp-aws-iot +++ b/components/esp-aws-iot @@ -1 +1 @@ -Subproject commit dd1d2c668bc3cfee76984ae0c52795177900bb41 +Subproject commit 3b3f9987e9396c05bb8b76830f8e8a0a7baeb057 From 8e27b2a561a6e67fdc17adcdd11638b94802eb47 Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Thu, 15 Sep 2022 15:53:27 +0800 Subject: [PATCH 02/32] Update esp-aws-iot to LTA 2.0 libraries + tinycbor. --- components/esp-aws-iot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/esp-aws-iot b/components/esp-aws-iot index 3b3f998..06ff4c0 160000 --- a/components/esp-aws-iot +++ b/components/esp-aws-iot @@ -1 +1 @@ -Subproject commit 3b3f9987e9396c05bb8b76830f8e8a0a7baeb057 +Subproject commit 06ff4c09b4dc1e0c84bd860ea60ddc76e7762a25 From c03a59237861c23f1a8d41ace58d818a8b8bc47d Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Fri, 16 Sep 2022 15:24:36 +0800 Subject: [PATCH 03/32] Update README for ESP-IDF v4.4.2 after updating LTS 2.0 libraries. --- GettingStartedGuide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GettingStartedGuide.md b/GettingStartedGuide.md index 15e3955..05053d5 100644 --- a/GettingStartedGuide.md +++ b/GettingStartedGuide.md @@ -15,7 +15,7 @@ Once completed, one can progress to the [Use Security Features](UseSecurityFeatu ### 1.2 Software Requirements -* ESP-IDF 4.4 or higher to configure, build, and flash the project. To setup for the ESP32-C3, follow Espressif's [Getting Started Guide for the ESP32-C3](https://docs.espressif.com/projects/esp-idf/en/latest/esp32c3/get-started/index.html). +* ESP-IDF 4.4.2 or higher to configure, build, and flash the project. To setup for the ESP32-C3, follow Espressif's [Getting Started Guide for the ESP32-C3](https://docs.espressif.com/projects/esp-idf/en/latest/esp32c3/get-started/index.html). * [Python3](https://www.python.org/downloads/) and the Package Installer for Python [pip](https://pip.pypa.io/en/stable/installation/) to use the AWS CLI to import certificates and perform OTA Job set up. Pip is included when you install from Python 3.10. From 3174a025f81032229fc6e062b7af56a01d1fc91a Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Fri, 16 Sep 2022 15:26:08 +0800 Subject: [PATCH 04/32] Remove tinycbor in esp-aws-iot and use cbor in esp-idf directly. --- components/esp-aws-iot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/esp-aws-iot b/components/esp-aws-iot index 06ff4c0..96b584c 160000 --- a/components/esp-aws-iot +++ b/components/esp-aws-iot @@ -1 +1 @@ -Subproject commit 06ff4c09b4dc1e0c84bd860ea60ddc76e7762a25 +Subproject commit 96b584c0fa7419fbb774cdaae7d680daf43378de From e7bf6a5dc52cf2965fcafbfd1f56524350f7df4a Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Thu, 22 Sep 2022 14:10:33 +0800 Subject: [PATCH 05/32] Add integration submodule and add integration test into project. --- .gitmodules | 4 + GettingStartedGuide.md | 106 +++- .../CMakeLists.txt | 51 ++ .../FreeRTOS-Libraries-Integration-Tests | 1 + .../config/qualification_wrapper_config.h | 70 +++ .../config/test_execution_config.h | 74 +++ .../config/test_param_config.h | 185 ++++++ .../port/platform_function.c | 140 +++++ components/esp-aws-iot | 2 +- main/CMakeLists.txt | 12 +- main/Kconfig.projbuild | 14 + .../ota_over_mqtt_demo_config.h | 3 + .../sub_pub_unsub_demo_config.h | 4 + main/main.c | 86 ++- .../networking/mqtt/core_mqtt_agent_manager.c | 98 ++- .../mqtt/core_mqtt_agent_manager_config.h | 4 + main/qualification_app_main.c | 590 ++++++++++++++++++ 17 files changed, 1402 insertions(+), 42 deletions(-) create mode 100644 components/FreeRTOS-Libraries-Integration-Tests/CMakeLists.txt create mode 160000 components/FreeRTOS-Libraries-Integration-Tests/FreeRTOS-Libraries-Integration-Tests create mode 100644 components/FreeRTOS-Libraries-Integration-Tests/config/qualification_wrapper_config.h create mode 100644 components/FreeRTOS-Libraries-Integration-Tests/config/test_execution_config.h create mode 100644 components/FreeRTOS-Libraries-Integration-Tests/config/test_param_config.h create mode 100644 components/FreeRTOS-Libraries-Integration-Tests/port/platform_function.c create mode 100644 main/qualification_app_main.c diff --git a/.gitmodules b/.gitmodules index 0b33e9d..094f14f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,7 @@ [submodule "components/esp-aws-iot"] path = components/esp-aws-iot url = https://github.com/ActoryOu/esp-aws-iot/ +[submodule "components/FreeRTOS-Libraries-Integration-Tests/FreeRTOS-Libraries-Integration-Tests"] + path = components/FreeRTOS-Libraries-Integration-Tests/FreeRTOS-Libraries-Integration-Tests + url = https://github.com/ActoryOu/FreeRTOS-Libraries-Integration-Tests + branch = lts-2.0 diff --git a/GettingStartedGuide.md b/GettingStartedGuide.md index 05053d5..fd6cc40 100644 --- a/GettingStartedGuide.md +++ b/GettingStartedGuide.md @@ -4,6 +4,31 @@ This guide contains instructions on how to setup, build and run the demo without Once completed, one can progress to the [Use Security Features](UseSecurityFeatures.md) guide. +[1 Pre-requisites](#1-pre-requisites) +    [1.1 Hardware Requirements](#11-hardware-requirements) +    [1.2 Software Requirements](#12-software-requirements) + +[2 Demo setup](#2-demo-setup) +    [2.1 Setup AWS IoT Core](#21-setup-aws-iot-core) +    [2.2 Configure the project with the AWS IoT Thing Name and AWS device Endpoint](#22-configure-the-project-with-the-aws-iot-thing-name-and-aws-device-endpoint) +    [2.3 Provision the ESP32-C3 with the private key, device certificate and CA certificate in Development Mode](#23-provision-the-esp32-c3-with-the-private-key-device-certificate-and-ca-certificate-in-development-mode) + +[3 Build and flash the demo project](#3-build-and-flash-the-demo-project) + +[4 Monitoring the demo](#4-monitoring-the-demo) + +[5 Perform firmware Over-the-Air Updates with AWS IoT](#5-perform-firmware-over-the-air-updates-with-aws-iot) +    [5.1 Setup pre-requisites for OTA cloud resources](#51-setup-pre-requisites-for-ota-cloud-resources) +    [5.2 Provision the project with the code-signing public key certificate](#52-provision-the-project-with-the-code-signing-public-key-certificate) +    [5.3 Build an application binary with a higher version number, to be downloaded and activated on the device](#53-build-an-application-binary-with-a-higher-version-number-to-be-downloaded-and-activated-on-the-device) +    [5.4 Build and flash the device with a binary with a lower version number](#54-build-and-flash-the-device-with-a-binary-with-a-lower-version-number) +    [5.5 Upload the binary with the higher version number (created in step 5.3) and create an OTA Update Job](#55-upload-the-binary-with-the-higher-version-number-created-in-step-53-and-create-an-ota-update-job) +    [5.6 Monitor OTA](#56-monitor-ota) + +[7 Run AWS IoT Qualification Test](#7-run-aws-iot-qualification-test) +    [7.1 Prerequisite](#71-prerequisite) +    [7.2 Steps for each test case](#72-steps-for-each-test-case) + ## 1 Pre-requisites ### 1.1 Hardware Requirements @@ -32,7 +57,7 @@ Once completed, one can progress to the [Use Security Features](UseSecurityFeatu ## 2 Demo setup -### 2.1 Setup AWS IoT Core: +### 2.1 Setup AWS IoT Core To setup AWS IoT Core, follow the [AWS IoT Core Setup Guide](AWSSetup.md). The guide shows you how to sign up for an AWS account, create a user, and register your device with AWS IoT Core. After you have followed the instructions in the AWS IoT Core Setup Guide, you will have created a **device Endpoint**, an AWS IoT **thing**, a **PEM-encoded device certificate**, a **PEM-encoded private key**, and a **PEM-encoded root CA certificate**. (An explanation of these entities is given in the Setup Guide.) The root CA certificate can also be downloaded [here](https://www.amazontrust.com/repository/AmazonRootCA1.pem). Your ESP23-C3 board must now be provisioned with these entities in order for it to connect securely with AWS IoT Core. @@ -421,3 +446,82 @@ I (3444) coreMQTT: Packet received. ReceivedBytes=3. I (3444) ota_over_mqtt_demo: Subscribed to topic $aws/things/thing_esp32c3_nonOta/jobs/notify-next. ``` +## 7 Run AWS IoT Qualification Test + +### 7.1 Prerequisite +- Run [OTA](#5-perform-firmware-over-the-air-updates-with-aws-iot) once manually. +- Enable "Run qualification test" by menuconfig (Featured FreeRTOS IoT Integration -> Run qualification test). +- Enable Unity and Unity/Fixture by menuconfig. + +### 7.2 Steps for each test case + +1. DEVICE_ADVISOR_TEST_ENABLED - device advisor test + - Set DEVICE_ADVISOR_TEST_ENABLED to 1 in [test_execution_config.h](./components/FreeRTOS-Libraries-Integration-Tests/config/test_execution_config.h). + - Create a device advisor test on website. ( Iot Console -> Test -> Device Advisor ) + - Create test suite. + - Run test suite and set the device advisor endpoint to MQTT_SERVER_ENDPOINT in [test_param_config.h](./components/FreeRTOS-Libraries-Integration-Tests/config/test_param_config.h). + - Set MQTT_SERVER_PORT and IOT_THING_NAME (Same as provisioned one) in [test_param_config.h](./components/FreeRTOS-Libraries-Integration-Tests/config/test_param_config.h). + - Build and run. + - See device advisor test result on website. +1. MQTT_TEST_ENABLED - MQTT test + - Set MQTT_TEST_ENABLED to 1 in [test_execution_config.h](./components/FreeRTOS-Libraries-Integration-Tests/config/test_execution_config.h). + - Set the MQTT endpoint to MQTT_SERVER_ENDPOINT in [test_param_config.h](./components/FreeRTOS-Libraries-Integration-Tests/config/test_param_config.h). + - Set MQTT_SERVER_PORT and IOT_THING_NAME (Same as provisioned one) in [test_param_config.h](./components/FreeRTOS-Libraries-Integration-Tests/config/test_param_config.h). + - Build and run. + - See test result on target output. + - Example output + ``` + I (821) qual_main: Run qualification test. + ... + ----------------------- + 7 Tests 0 Failures 0 Ignored + OK + I (84381) qual_main: End qualification test. + ``` +1. TRANSPORT_INTERFACE_TEST_ENABLED - Transport layer test + - Set TRANSPORT_INTERFACE_TEST_ENABLED to 1 [test_execution_config.h](./components/FreeRTOS-Libraries-Integration-Tests/config/test_execution_config.h). + - Follow [Run The Transport Interface Test](https://github.com/FreeRTOS/FreeRTOS-Libraries-Integration-Tests/tree/main/src/transport_interface#6-run-the-transport-interface-test) to start a echo server. + - Set ECHO_SERVER_ENDPOINT / ECHO_SERVER_PORT / ECHO_SERVER_ROOT_CA / TRANSPORT_CLIENT_CERTIFICATE and TRANSPORT_CLIENT_PRIVATE_KEY in [test_param_config.h](./components/FreeRTOS-Libraries-Integration-Tests/config/test_param_config.h). + - Build and run. + - See test result on target output. + - Example output + ``` + I (855) qual_main: Run qualification test. + ... + ----------------------- + 14 Tests 0 Failures 0 Ignored + OK + I (612755) qual_main: End qualification test. + ``` +1. OTA_PAL_TEST_ENABLED - OTA PAL test + - Set OTA_PAL_TEST_ENABLED to 1 [test_execution_config.h](./components/FreeRTOS-Libraries-Integration-Tests/config/test_execution_config.h). + - Set OTA_PAL_FIRMWARE_FILE to "b_u585i_iot02a_ntz.bin" in [test_param_config.h](./components/FreeRTOS-Libraries-Integration-Tests/config/test_param_config.h). + - Build and run. + - See test result on target output. + - Example output + ``` + I (905) qual_main: Run qualification test. + ... + ----------------------- + 15 Tests 0 Failures 0 Ignored + OK + I (113755) qual_main: End qualification test. + ``` +1. CORE_PKCS11_TEST_ENABLED - Core PKCS11 test + - Set CORE_PKCS11_TEST_ENABLED to 1 [test_execution_config.h](./components/FreeRTOS-Libraries-Integration-Tests/config/test_execution_config.h). + - Build and run. + - See test result on target output. + - Example output + ``` + I (858) qual_main: Run qualification test. + ... + ----------------------- + 17 Tests 0 Failures 0 Ignored + OK + I (7518) qual_main: End qualification test. + ``` +1. OTA_E2E_TEST_ENABLED - OTA E2E test + - Disable all configurations in [test_execution_config.h](./components/FreeRTOS-Libraries-Integration-Tests/config/test_execution_config.h). + - Follow [FreeRTOS IDT 2.0](https://docs.aws.amazon.com/freertos/latest/userguide/lts-idt-freertos-qualification.html) to set-up tool. + - Run IDT OTA E2E test cases. + - See test result on tool output. \ No newline at end of file diff --git a/components/FreeRTOS-Libraries-Integration-Tests/CMakeLists.txt b/components/FreeRTOS-Libraries-Integration-Tests/CMakeLists.txt new file mode 100644 index 0000000..f4d06b9 --- /dev/null +++ b/components/FreeRTOS-Libraries-Integration-Tests/CMakeLists.txt @@ -0,0 +1,51 @@ +# This gives QUALIFICATION_TEST_SOURCES, and QUALIFICATION_TEST_INCLUDE_DIRS +include(${CMAKE_CURRENT_LIST_DIR}/FreeRTOS-Libraries-Integration-Tests/qualification_test.cmake) + +# This gives TRANSPORT_TEST_SOURCES, and TRANSPORT_TEST_INCLUDE_DIRS +include(${CMAKE_CURRENT_LIST_DIR}/FreeRTOS-Libraries-Integration-Tests/src/transport_interface_test.cmake) + +# 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) + +set(IDT_INCLUDE_DIRS + ${QUALIFICATION_TEST_INCLUDE_DIRS} + ${TRANSPORT_TEST_INCLUDE_DIRS} + ${MQTT_TEST_INCLUDE_DIRS} + ${OTA_PAL_TEST_INCLUDE_DIRS} + ${PKCS11_TEST_INCLUDE_DIRS} + ${CMAKE_CURRENT_LIST_DIR}/config +) + +set(IDT_SRCS + ${QUALIFICATION_TEST_SOURCES} + ${TRANSPORT_TEST_SOURCES} + ${MQTT_TEST_SOURCES} + ${OTA_PAL_TEST_SOURCES} + ${PKCS11_TEST_SOURCES} + ${CMAKE_CURRENT_LIST_DIR}/port/platform_function.c + ${CMAKE_CURRENT_LIST_DIR}/../esp-aws-iot/libraries/corePKCS11/corePKCS11/source/dependency/3rdparty/mbedtls_utils/mbedtls_utils.c +) + +set(IDT_REQUIRES + unity + coreMQTT + coreHTTP + freertos + corePKCS11 + ota-for-aws-iot-embedded-sdk +) + +idf_component_register( + SRCS + ${IDT_SRCS} + INCLUDE_DIRS + ${IDT_INCLUDE_DIRS} + REQUIRES + ${IDT_REQUIRES} +) diff --git a/components/FreeRTOS-Libraries-Integration-Tests/FreeRTOS-Libraries-Integration-Tests b/components/FreeRTOS-Libraries-Integration-Tests/FreeRTOS-Libraries-Integration-Tests new file mode 160000 index 0000000..e43aea7 --- /dev/null +++ b/components/FreeRTOS-Libraries-Integration-Tests/FreeRTOS-Libraries-Integration-Tests @@ -0,0 +1 @@ +Subproject commit e43aea769347329ef717bd8f297c5f241b3d990b diff --git a/components/FreeRTOS-Libraries-Integration-Tests/config/qualification_wrapper_config.h b/components/FreeRTOS-Libraries-Integration-Tests/config/qualification_wrapper_config.h new file mode 100644 index 0000000..fcde9cd --- /dev/null +++ b/components/FreeRTOS-Libraries-Integration-Tests/config/qualification_wrapper_config.h @@ -0,0 +1,70 @@ +/* + * ESP32-C3 Featured FreeRTOS IoT Integration V202204.00 + * Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + +#ifndef QUALIFICATION_WRAPPER_CONFIG_H +#define QUALIFICATION_WRAPPER_CONFIG_H + +/* ESP-IDF sdkconfig include. */ +#include + +#if CONFIG_GRI_RUN_QUALIFICATION_TEST + #include "test_execution_config.h" + #include "test_param_config.h" + + /* Common config */ + #define CONFIG_GRI_THING_NAME ( IOT_THING_NAME ) + #define CONFIG_GRI_MQTT_ENDPOINT ( MQTT_SERVER_ENDPOINT ) + #define CONFIG_GRI_MQTT_PORT ( MQTT_SERVER_PORT ) + + /* OTA config */ + #define CONFIG_GRI_OTA_DEMO_MAX_FILE_PATH_SIZE ( 260 ) + #define CONFIG_GRI_OTA_DEMO_MAX_STREAM_NAME_SIZE ( 128 ) + #define CONFIG_GRI_OTA_DEMO_TASK_DELAY_MS ( 1000 ) + #define CONFIG_GRI_OTA_DEMO_MQTT_TIMEOUT_MS ( 5000 ) + #define CONFIG_GRI_OTA_DEMO_AGENT_TASK_PRIORITY ( 4 ) + #define CONFIG_GRI_OTA_DEMO_AGENT_TASK_STACK_SIZE ( 4096 ) + #define CONFIG_GRI_OTA_DEMO_DEMO_TASK_PRIORITY ( 1 ) + #define CONFIG_GRI_OTA_DEMO_DEMO_TASK_STACK_SIZE ( 3072 ) + #define CONFIG_GRI_OTA_DEMO_APP_VERSION_MAJOR ( OTA_APP_VERSION_MAJOR ) + #define CONFIG_GRI_OTA_DEMO_APP_VERSION_MINOR ( OTA_APP_VERSION_MINOR ) + #define CONFIG_GRI_OTA_DEMO_APP_VERSION_BUILD ( OTA_APP_VERSION_BUILD ) + + /* SubPubUnsub demo config */ + #define CONFIG_GRI_SUB_PUB_UNSUB_DEMO_STRING_BUFFER_LENGTH ( 100 ) + #define CONFIG_GRI_SUB_PUB_UNSUB_DEMO_DELAY_BETWEEN_SUB_PUB_UNSUB_LOOPS_MS ( 5000 ) + #define CONFIG_GRI_SUB_PUB_UNSUB_DEMO_MAX_COMMAND_SEND_BLOCK_TIME_MS ( 500 ) + #define CONFIG_GRI_SUB_PUB_UNSUB_DEMO_QOS_LEVEL ( 1 ) + #define CONFIG_GRI_SUB_PUB_UNSUB_DEMO_NUM_TASKS_TO_CREATE ( 1 ) + #define CONFIG_GRI_SUB_PUB_UNSUB_DEMO_TASK_PRIORITY ( 1 ) + #define CONFIG_GRI_SUB_PUB_UNSUB_DEMO_TASK_STACK_SIZE ( 3072 ) + + #if ( OTA_E2E_TEST_ENABLED == 1 ) + /* Enable OTA demo. */ + #define CONFIG_GRI_ENABLE_OTA_DEMO ( 1 ) + #endif /* OTA_E2E_TEST_ENABLED == 1 */ +#endif /* CONFIG_GRI_RUN_QUALIFICATION_TEST */ + +#endif /* QUALIFICATION_WRAPPER_CONFIG_H */ diff --git a/components/FreeRTOS-Libraries-Integration-Tests/config/test_execution_config.h b/components/FreeRTOS-Libraries-Integration-Tests/config/test_execution_config.h new file mode 100644 index 0000000..fa99b86 --- /dev/null +++ b/components/FreeRTOS-Libraries-Integration-Tests/config/test_execution_config.h @@ -0,0 +1,74 @@ +/* + * FreeRTOS FreeRTOS LTS Qualification Tests preview + * Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * @file test_execution_config_template.h + * @brief This is a template to setup the execution configurations for LTS qualification test. + */ + +#ifndef TEST_EXECUTION_CONFIG_H +#define TEST_EXECUTION_CONFIG_H + +/** + * @brief Configuration to enable Device Advisor testing. + * + * #define DEVICE_ADVISOR_TEST_ENABLED (0) + */ +#define DEVICE_ADVISOR_TEST_ENABLED ( 0 ) + +/** + * @brief Configuration to enable the MQTT test. + * + * #define MQTT_TEST_ENABLED (0) + */ +#define MQTT_TEST_ENABLED ( 0 ) + +/** + * @brief Configuration to enable the transport interface test. + * + * #define TRANSPORT_INTERFACE_TEST_ENABLED (0) + */ + +#define TRANSPORT_INTERFACE_TEST_ENABLED ( 0 ) + +/** + * @brief Configuration to enable the OTA PAL test. + * + * #define OTA_PAL_TEST_ENABLED (0) + */ +#define OTA_PAL_TEST_ENABLED ( 0 ) + +/** + * @brief Configuration to enable the OTA End-to-end test. + * + * #define OTA_E2E_TEST_ENABLED (0) + */ +#define OTA_E2E_TEST_ENABLED ( 0 ) + +/** + * @brief Configuration to enable the corePKCS11 test. + * + * #define CORE_PKCS11_TEST_ENABLED (0) + */ +#define CORE_PKCS11_TEST_ENABLED ( 0 ) + +#endif /* TEST_EXECUTION_CONFIG_H */ diff --git a/components/FreeRTOS-Libraries-Integration-Tests/config/test_param_config.h b/components/FreeRTOS-Libraries-Integration-Tests/config/test_param_config.h new file mode 100644 index 0000000..080dd16 --- /dev/null +++ b/components/FreeRTOS-Libraries-Integration-Tests/config/test_param_config.h @@ -0,0 +1,185 @@ +/* + * FreeRTOS FreeRTOS LTS Qualification Tests preview + * Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * @file test_param_config.h + * @brief This setup the test parameters for LTS qualification test. + */ + +#ifndef TEST_PARAM_CONFIG_H +#define TEST_PARAM_CONFIG_H + +/** + * @brief Configuration that indicates if the device should generate a key pair. + * + * @note When FORCE_GENERATE_NEW_KEY_PAIR is set to 1, the device should generate + * a new on-device key pair and output public key. When set to 0, the device + * should keep existing key pair. + * + * #define FORCE_GENERATE_NEW_KEY_PAIR 0 + */ + + +/** + * @brief Endpoint of the MQTT broker to connect to in mqtt test. + * + * #define MQTT_SERVER_ENDPOINT "PLACE_HOLDER" + */ + +/** + * @brief Port of the MQTT broker to connect to in mqtt test. + * + * #define MQTT_SERVER_PORT (8883) + */ + +/** + * @brief The IoT Thing name for the device for OTA test and MQTT test. + * + * #define IOT_THING_NAME "PLACE_HOLDER" + */ + + /** + * @brief Network buffer size specified in bytes. Must be large enough to hold the maximum + * anticipated MQTT payload. + * + * #define MQTT_TEST_NETWORK_BUFFER_SIZE ( 5000 ) + */ + +/** + * @brief Endpoint of the echo server to connect to in transport interface test. + * + * #define ECHO_SERVER_ENDPOINT "PLACE_HOLDER" + */ + +/** + * @brief Port of the echo server to connect to in transport interface test. + * + * #define ECHO_SERVER_PORT (9000) + */ + +/** + * @brief Root certificate of the echo server. + * + * @note This certificate should be PEM-encoded. + * + * Must include the PEM header and footer: + * "-----BEGIN CERTIFICATE-----\n"\ + * "...base64 data...\n"\ + * "-----END CERTIFICATE-----\n" + * + * #define ECHO_SERVER_ROOT_CA "PLACE_HOLDER" + */ + + +/** + * @brief Client certificate to connect to echo server. + * + * @note This certificate should be PEM-encoded. + * + * Must include the PEM header and footer: + * "-----BEGIN CERTIFICATE-----\n"\ + * "...base64 data...\n"\ + * "-----END CERTIFICATE-----\n" + * + * #define TRANSPORT_CLIENT_CERTIFICATE NULL + */ + + +/** + * @brief Client private key to connect to echo server. + * + * @note This is should only be used for testing purpose. + * + * For qualification, the key should be generated on-device. + * + * #define TRANSPORT_CLIENT_PRIVATE_KEY NULL + */ + + +#define PKCS11_TEST_RSA_KEY_SUPPORT ( 1 ) +#define PKCS11_TEST_EC_KEY_SUPPORT ( 0 ) +#define PKCS11_TEST_IMPORT_PRIVATE_KEY_SUPPORT ( 1 ) +#define PKCS11_TEST_GENERATE_KEYPAIR_SUPPORT ( 0 ) +#define PKCS11_TEST_PREPROVISIONED_SUPPORT ( 0 ) +#define PKCS11_TEST_LABEL_DEVICE_PRIVATE_KEY_FOR_TLS pkcs11configLABEL_DEVICE_PRIVATE_KEY_FOR_TLS +#define PKCS11_TEST_LABEL_DEVICE_PUBLIC_KEY_FOR_TLS pkcs11configLABEL_DEVICE_PUBLIC_KEY_FOR_TLS +#define PKCS11_TEST_LABEL_DEVICE_CERTIFICATE_FOR_TLS pkcs11configLABEL_DEVICE_CERTIFICATE_FOR_TLS + + +#define OTA_RSA_SHA1 1 +#define OTA_RSA_SHA256 2 +#define OTA_ECDSA_SHA256 3 + +/** + * @brief Certificate type for OTA PAL test. + * Valid options are: OTA_RSA_SHA1, OTA_RSA_SHA256, OTA_ECDSA_SHA256. + * + * #define OTA_PAL_TEST_CERT_TYPE OTA_ECDSA_SHA256 + */ +#define OTA_PAL_TEST_CERT_TYPE OTA_ECDSA_SHA256 + +/** + * @brief Path to cert for OTA test PAL. Used to verify signature. + * If applicable, the device must be pre-provisioned with this certificate. Please see + * test/common/ota/test_files for the set of certificates. + */ +#define OTA_PAL_CERTIFICATE_FILE "" + +/** + * @brief Some devices have a hard-coded name for the firmware image to boot. + */ +#define OTA_PAL_FIRMWARE_FILE "/" + +/** + * @brief Some boards OTA PAL layers will use the file names passed into it for the + * image and the certificates because their non-volatile memory is abstracted by a + * file system. Set this to 1 if that is the case for your device. + */ +#define OTA_PAL_USE_FILE_SYSTEM 0 + +/** + * @brief 1 if using PKCS #11 to access the code sign certificate from NVM. + */ +#define OTA_PAL_READ_CERTIFICATE_FROM_NVM_WITH_PKCS11 0 + +/** + * @brief Major version for OTA E2E test. + * + * #define OTA_APP_VERSION_MAJOR 0 + */ +#define OTA_APP_VERSION_MAJOR 0 + +/** + * @brief Major version for OTA E2E test. + * + * #define OTA_APP_VERSION_MINOR 9 + */ +#define OTA_APP_VERSION_MINOR 9 + +/** + * @brief Major version for OTA E2E test. + * + * #define OTA_APP_VERSION_BUILD 1 + */ +#define OTA_APP_VERSION_BUILD 1 + +#endif /* TEST_PARAM_CONFIG_H */ diff --git a/components/FreeRTOS-Libraries-Integration-Tests/port/platform_function.c b/components/FreeRTOS-Libraries-Integration-Tests/port/platform_function.c new file mode 100644 index 0000000..a1356ed --- /dev/null +++ b/components/FreeRTOS-Libraries-Integration-Tests/port/platform_function.c @@ -0,0 +1,140 @@ +#include "platform_function.h" + +#include +#include +#include "freertos/FreeRTOS.h" +#include "freertos/FreeRTOSConfig.h" +#include "freertos/task.h" +#include "freertos/semphr.h" +#include "esp_log.h" +#include + +/* Random number generator include. */ +#include "esp_random.h" + +#define TEST_RESULT_BUFFER_CAPACITY 2048 + +static const char * TAG = "idt_platform_function"; + +typedef struct TaskParam +{ + StaticSemaphore_t joinMutexBuffer; + SemaphoreHandle_t joinMutexHandle; + FRTestThreadFunction_t threadFunc; + void * pParam; + TaskHandle_t taskHandle; +} TaskParam_t; + +/*----------------------- Log Helper -----------------------*/ + +/* The buffer to store test result. The content will be printed if an eol character + * is received */ +static char pcTestResultBuffer[ TEST_RESULT_BUFFER_CAPACITY ] = { 0 }; +static int16_t xBufferSize = 0; +/*-----------------------------------------------------------*/ + +int FRTest_GenerateRandInt() +{ + return (int) esp_random(); +} + +/*-----------------------------------------------------------*/ + +static void ThreadWrapper( void * pParam ) +{ + TaskParam_t * pTaskParam = pParam; + + if( ( pTaskParam != NULL ) && ( pTaskParam->threadFunc != NULL ) && ( pTaskParam->joinMutexHandle != NULL ) ) + { + pTaskParam->threadFunc( pTaskParam->pParam ); + + /* Give the mutex. */ + xSemaphoreGive( pTaskParam->joinMutexHandle ); + } + + vTaskDelete( NULL ); +} +/*-----------------------------------------------------------*/ + +FRTestThreadHandle_t FRTest_ThreadCreate( FRTestThreadFunction_t threadFunc, + void * pParam ) +{ + TaskParam_t * pTaskParam = NULL; + FRTestThreadHandle_t threadHandle = NULL; + BaseType_t xReturned; + + pTaskParam = malloc( sizeof( TaskParam_t ) ); + configASSERT( pTaskParam != NULL ); + + pTaskParam->joinMutexHandle = xSemaphoreCreateBinaryStatic( &pTaskParam->joinMutexBuffer ); + configASSERT( pTaskParam->joinMutexHandle != NULL ); + + pTaskParam->threadFunc = threadFunc; + pTaskParam->pParam = pParam; + + xReturned = xTaskCreate( ThreadWrapper, /* Task code. */ + "ThreadWrapper", /* All tasks have same name. */ + 8192, /* Task stack size. */ + pTaskParam, /* Where the task writes its result. */ + tskIDLE_PRIORITY, /* Task priority. */ + &pTaskParam->taskHandle ); + configASSERT( xReturned == pdPASS ); + + threadHandle = pTaskParam; + + return threadHandle; +} + +/*-----------------------------------------------------------*/ + +int FRTest_ThreadTimedJoin( FRTestThreadHandle_t threadHandle, + uint32_t timeoutMs ) +{ + TaskParam_t * pTaskParam = threadHandle; + BaseType_t xReturned; + int retValue = 0; + + /* Check the parameters. */ + configASSERT( pTaskParam != NULL ); + configASSERT( pTaskParam->joinMutexHandle != NULL ); + + /* Wait for the thread. */ + xReturned = xSemaphoreTake( pTaskParam->joinMutexHandle, pdMS_TO_TICKS( timeoutMs ) ); + + if( xReturned != pdTRUE ) + { + ESP_LOGW( TAG, "Waiting thread exist failed after %u %d. Task abort.", timeoutMs, xReturned ); + + /* Return negative value to indicate error. */ + retValue = -1; + + /* There may be used after free. Assert here to indicate error. */ + configASSERT( 0 ); + } + + free( pTaskParam ); + + return retValue; +} + +/*-----------------------------------------------------------*/ + +void FRTest_TimeDelay( uint32_t delayMs ) +{ + vTaskDelay( pdMS_TO_TICKS( delayMs ) ); +} + +/*-----------------------------------------------------------*/ + +void * FRTest_MemoryAlloc( size_t size ) +{ + return pvPortMalloc( size ); +} + +/*-----------------------------------------------------------*/ + +void FRTest_MemoryFree( void * ptr ) +{ + return vPortFree( ptr ); +} +/*-----------------------------------------------------------*/ diff --git a/components/esp-aws-iot b/components/esp-aws-iot index 96b584c..367b816 160000 --- a/components/esp-aws-iot +++ b/components/esp-aws-iot @@ -1 +1 @@ -Subproject commit 96b584c0fa7419fbb774cdaae7d680daf43378de +Subproject commit 367b8168d92509e4b1ed4fbe1193905a43935c15 diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index 7b52e20..76e452e 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -26,6 +26,14 @@ if(CONFIG_GRI_ENABLE_OTA_DEMO) list(APPEND MAIN_SRCS "demo_tasks/ota_over_mqtt_demo/ota_over_mqtt_demo.c") endif() +# Qualification Test +if( CONFIG_GRI_RUN_QUALIFICATION_TEST ) + list(APPEND MAIN_SRCS + "qualification_app_main.c" + "demo_tasks/ota_over_mqtt_demo/ota_over_mqtt_demo.c" + "demo_tasks/sub_pub_unsub_demo/sub_pub_unsub_demo.c") +endif() + set(MAIN_INCLUDE_DIRS "." "demo_tasks/ota_over_mqtt_demo" @@ -47,6 +55,8 @@ set(MAIN_REQUIRES backoffAlgorithm esp_secure_cert_mgr ota-for-aws-iot-embedded-sdk + FreeRTOS-Libraries-Integration-Tests + unity ) idf_component_register( @@ -59,6 +69,6 @@ idf_component_register( ) # OTA demo -if(CONFIG_GRI_ENABLE_OTA_DEMO) +if( CONFIG_GRI_ENABLE_OTA_DEMO OR CONFIG_GRI_RUN_QUALIFICATION_TEST ) target_add_binary_data(${COMPONENT_TARGET} "certs/aws_codesign.crt" TEXT) endif() diff --git a/main/Kconfig.projbuild b/main/Kconfig.projbuild index a44cdbc..97c7632 100644 --- a/main/Kconfig.projbuild +++ b/main/Kconfig.projbuild @@ -22,16 +22,26 @@ menu "Featured FreeRTOS IoT Integration" default 1 if APP_WIFI_PROV_TRANSPORT_SOFTAP default 2 if APP_WIFI_PROV_TRANSPORT_BLE + config GRI_RUN_QUALIFICATION_TEST + bool "Run qualification test." + default n + help + Enable to run qualification test. Use configurations in test_execution_config.h and test_param_config.h. + Disable to demo. Use configurations below (in sdkconfig). + config GRI_MQTT_ENDPOINT string "Endpoint for MQTT Broker to use" + depends on !GRI_RUN_QUALIFICATION_TEST default "" config GRI_MQTT_PORT int "Port for MQTT Broker to use" + depends on !GRI_RUN_QUALIFICATION_TEST default 8883 config GRI_THING_NAME string "Thing name" + depends on !GRI_RUN_QUALIFICATION_TEST default "" config GRI_OUTPUT_CERTS_KEYS @@ -40,6 +50,7 @@ menu "Featured FreeRTOS IoT Integration" config EXAMPLE_USE_DS_PERIPHERAL bool "Use DS peripheral" + depends on !GRI_RUN_QUALIFICATION_TEST default n select ESP_SECURE_CERT_DS_PERIPHERAL select ESP_TLS_USE_DS_PERIPHERAL @@ -98,6 +109,7 @@ menu "Featured FreeRTOS IoT Integration" config GRI_ENABLE_SUB_PUB_UNSUB_DEMO bool "Enable pub sub unsub demo" + depends on !GRI_RUN_QUALIFICATION_TEST default y menu "Sub pub unsub demo configurations" @@ -150,6 +162,7 @@ menu "Featured FreeRTOS IoT Integration" config GRI_ENABLE_TEMPERATURE_PUB_SUB_AND_LED_CONTROL_DEMO bool "Enable temperature sensor pub sub and LED control demo" + depends on !GRI_RUN_QUALIFICATION_TEST default y menu "Temperature pub sub and LED control demo configurations" @@ -196,6 +209,7 @@ menu "Featured FreeRTOS IoT Integration" config GRI_ENABLE_OTA_DEMO bool "Enable OTA demo" + depends on !GRI_RUN_QUALIFICATION_TEST default y menu "OTA demo configurations" 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 2e7b979..60be801 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 @@ -30,6 +30,9 @@ /* ESP-IDF sdkconfig include. */ #include +#if CONFIG_GRI_RUN_QUALIFICATION_TEST + #include "qualification_wrapper_config.h" +#endif /* CONFIG_GRI_RUN_QUALIFICATION_TEST */ /** * @brief The thing name of the device. */ diff --git a/main/demo_tasks/sub_pub_unsub_demo/sub_pub_unsub_demo_config.h b/main/demo_tasks/sub_pub_unsub_demo/sub_pub_unsub_demo_config.h index d8cc5fa..52cfd6b 100644 --- a/main/demo_tasks/sub_pub_unsub_demo/sub_pub_unsub_demo_config.h +++ b/main/demo_tasks/sub_pub_unsub_demo/sub_pub_unsub_demo_config.h @@ -30,6 +30,10 @@ /* ESP-IDF sdkconfig include. */ #include +#if CONFIG_GRI_RUN_QUALIFICATION_TEST + #include "qualification_wrapper_config.h" +#endif /* CONFIG_GRI_RUN_QUALIFICATION_TEST */ + /** * @brief Size of statically allocated buffers for holding topic names and * payloads. diff --git a/main/main.c b/main/main.c index 86ef059..127a9ba 100644 --- a/main/main.c +++ b/main/main.c @@ -66,6 +66,10 @@ #include "ota_over_mqtt_demo.h" #endif /* CONFIG_GRI_ENABLE_OTA_DEMO */ +#if CONFIG_GRI_RUN_QUALIFICATION_TEST + #include "qualification_wrapper_config.h" +#endif /* CONFIG_GRI_RUN_QUALIFICATION_TEST */ + /* Global variables ***********************************************************/ /** @@ -103,6 +107,10 @@ static BaseType_t prvInitializeNetworkContext( void ); */ static void prvStartEnabledDemos( void ); +#if CONFIG_GRI_RUN_QUALIFICATION_TEST + extern BaseType_t xQualificationStart( void ); +#endif /* CONFIG_GRI_RUN_QUALIFICATION_TEST */ + /* Static function definitions ************************************************/ static BaseType_t prvInitializeNetworkContext( void ) @@ -240,32 +248,59 @@ static BaseType_t prvInitializeNetworkContext( void ) static void prvStartEnabledDemos( void ) { - #if CONFIG_GRI_ENABLE_SUB_PUB_UNSUB_DEMO - vStartSubscribePublishUnsubscribeDemo(); - #endif /* CONFIG_GRI_ENABLE_SIMPLE_PUB_SUB_DEMO */ + BaseType_t xResult; - #if CONFIG_GRI_ENABLE_TEMPERATURE_PUB_SUB_AND_LED_CONTROL_DEMO - vStartTempSubPubAndLEDControlDemo(); - #endif /* CONFIG_GRI_ENABLE_TEMPERATURE_LED_PUB_SUB_DEMO */ + #if ( CONFIG_GRI_RUN_QUALIFICATION_TEST == 0 ) + #if CONFIG_GRI_ENABLE_SUB_PUB_UNSUB_DEMO + vStartSubscribePublishUnsubscribeDemo(); + #endif /* CONFIG_GRI_ENABLE_SIMPLE_PUB_SUB_DEMO */ - #if CONFIG_GRI_ENABLE_OTA_DEMO - #if CONFIG_GRI_OUTPUT_CERTS_KEYS - ESP_LOGI( TAG, "\nCS Cert: \nLength: %d\n%s", - strlen( pcAwsCodeSigningCertPem ), - pcAwsCodeSigningCertPem ); - #endif /* CONFIG_GRI_OUTPUT_CERTS_KEYS */ + #if CONFIG_GRI_ENABLE_TEMPERATURE_PUB_SUB_AND_LED_CONTROL_DEMO + vStartTempSubPubAndLEDControlDemo(); + #endif /* CONFIG_GRI_ENABLE_TEMPERATURE_LED_PUB_SUB_DEMO */ - if( otaPal_SetCodeSigningCertificate( pcAwsCodeSigningCertPem ) ) + #if CONFIG_GRI_ENABLE_OTA_DEMO + #if CONFIG_GRI_OUTPUT_CERTS_KEYS + ESP_LOGI( TAG, "\nCS Cert: \nLength: %d\n%s", + strlen( pcAwsCodeSigningCertPem ), + pcAwsCodeSigningCertPem ); + #endif /* CONFIG_GRI_OUTPUT_CERTS_KEYS */ + + if( otaPal_SetCodeSigningCertificate( pcAwsCodeSigningCertPem ) ) + { + vStartOTACodeSigningDemo(); + } + else + { + ESP_LOGE( TAG, + "Failed to set the code signing certificate for the AWS OTA " + "library. OTA demo will not be started." ); + } + #endif /* CONFIG_GRI_ENABLE_OTA_DEMO */ + + /* Initialize and start the coreMQTT-Agent network manager. This handles + * establishing a TLS connection and MQTT connection to the MQTT broker. + * This needs to be started before starting WiFi so it can handle WiFi + * connection events. */ + xResult = xCoreMqttAgentManagerStart( &xNetworkContext ); + + if( xResult != pdPASS ) { - vStartOTACodeSigningDemo(); + ESP_LOGE( TAG, "Failed to initialize and start coreMQTT-Agent network " + "manager." ); + + configASSERT( xResult == pdPASS ); } - else + #endif /* CONFIG_GRI_RUN_QUALIFICATION_TEST == 0 */ + + #if CONFIG_GRI_RUN_QUALIFICATION_TEST + if( ( xResult = xQualificationStart() ) != pdPASS ) { - ESP_LOGE( TAG, - "Failed to set the code signing certificate for the AWS OTA " - "library. OTA demo will not be started." ); + ESP_LOGE( TAG, "Failed to start Qualfication task: errno=%d", xResult ); } - #endif /* CONFIG_GRI_ENABLE_OTA_DEMO */ + + configASSERT( xResult == pdPASS ); + #endif /* CONFIG_GRI_RUN_QUALIFICATION_TEST */ } /* Main function definition ***************************************************/ @@ -315,19 +350,6 @@ void app_main( void ) * register their coreMQTT-Agent event handlers before events happen. */ prvStartEnabledDemos(); - /* Initialize and start the coreMQTT-Agent network manager. This handles - * establishing a TLS connection and MQTT connection to the MQTT broker. - * This needs to be started before starting WiFi so it can handle WiFi - * connection events. */ - xRet = xCoreMqttAgentManagerStart( &xNetworkContext ); - - if( xRet != pdPASS ) - { - ESP_LOGE( TAG, "Failed to initialize and start coreMQTT-Agent network " - "manager." ); - return; - } - /* Start WiFi. */ app_wifi_init(); app_wifi_start( POP_TYPE_MAC ); diff --git a/main/networking/mqtt/core_mqtt_agent_manager.c b/main/networking/mqtt/core_mqtt_agent_manager.c index 5e8288c..01bcdd4 100644 --- a/main/networking/mqtt/core_mqtt_agent_manager.c +++ b/main/networking/mqtt/core_mqtt_agent_manager.c @@ -62,17 +62,17 @@ /* Network transport include. */ #include "network_transport.h" -/* OTA demo include. */ -#if CONFIG_GRI_ENABLE_OTA_DEMO - #include "ota_over_mqtt_demo.h" -#endif - /* Public functions include. */ #include "core_mqtt_agent_manager.h" /* Configurations include. */ #include "core_mqtt_agent_manager_config.h" +/* OTA demo include. */ +#if CONFIG_GRI_ENABLE_OTA_DEMO + #include "ota_over_mqtt_demo.h" +#endif /* CONFIG_GRI_ENABLE_OTA_DEMO */ + /* Preprocessor definitions ***************************************************/ /* Network event group bit definitions */ @@ -87,6 +87,8 @@ ( MILLISECONDS_PER_SECOND / \ configTICK_RATE_HZ ) +#define MUTEX_IS_OWNED( xHandle ) ( xTaskGetCurrentTaskHandle() == xSemaphoreGetMutexHolder( xHandle ) ) + /* Global variables ***********************************************************/ /** @@ -128,6 +130,11 @@ MQTTAgentContext_t xGlobalMqttAgentContext; */ SubscriptionElement_t xGlobalSubscriptionList[ SUBSCRIPTION_MANAGER_MAX_SUBSCRIPTIONS ]; +/** + * @brief Lock to handle multi-tasks accessing xSubInfo in prvHandleResubscribe. + */ +SemaphoreHandle_t xSubListMutex; + /** * @brief Pointer to the network context passed in. */ @@ -269,6 +276,58 @@ static void prvCoreMqttAgentEventHandler( void * pvHandlerArg, /* Static function definitions ************************************************/ +static inline BaseType_t xLockSubList( void ) +{ + BaseType_t xResult = pdFALSE; + + configASSERT( xSubListMutex ); + + configASSERT( !MUTEX_IS_OWNED( xSubListMutex ) ); + + ESP_LOGD( TAG, + "Waiting for Mutex." ); + xResult = xSemaphoreTake( xSubListMutex, portMAX_DELAY ); + + if( xResult ) + { + ESP_LOGD( TAG, + ">>>> Mutex wait complete." ); + } + else + { + ESP_LOGE( TAG, + "**** Mutex request failed, xResult=%d.", xResult ); + } + + return xResult; +} + +/*-----------------------------------------------------------*/ + +static inline BaseType_t xUnlockSubList( void ) +{ + BaseType_t xResult = pdFALSE; + + configASSERT( xSubListMutex ); + + configASSERT( MUTEX_IS_OWNED( xSubListMutex ) ); + + xResult = xSemaphoreGive( xSubListMutex ); + + if( xResult ) + { + ESP_LOGD( TAG, + "<<<< Mutex Give." ); + } + else + { + ESP_LOGE( TAG, + "**** Mutex Give request failed, xResult=%d.", xResult ); + } + + return xResult; +} + static uint32_t prvGetTimeMs( void ) { TickType_t xTickCount = 0; @@ -309,7 +368,7 @@ static void prvIncomingPublishCallback( MQTTAgentContext_t * pMqttAgentContext, { xPublishHandled = vOTAProcessMessage( pMqttAgentContext->pIncomingCallbackContext, pxPublishInfo ); } - #endif + #endif /* CONFIG_GRI_ENABLE_OTA_DEMO */ /* If there are no callbacks to handle the incoming publishes, * handle it as an unsolicited publish. */ @@ -333,6 +392,8 @@ static void prvSubscriptionCommandCallback( MQTTAgentCommandContext_t * pxComman size_t lIndex = 0; MQTTAgentSubscribeArgs_t * pxSubscribeArgs = ( MQTTAgentSubscribeArgs_t * ) pxCommandContext; + xLockSubList(); + /* If the return code is success, no further action is required as all the topic filters * are already part of the subscription list. */ if( pxReturnInfo->returnCode != MQTTSuccess ) @@ -341,7 +402,7 @@ static void prvSubscriptionCommandCallback( MQTTAgentCommandContext_t * pxComman for( lIndex = 0; lIndex < pxSubscribeArgs->numSubscriptions; lIndex++ ) { /* This demo doesn't attempt to resubscribe in the event that a SUBACK failed. */ - if( pxReturnInfo->pSubackCodes[ lIndex ] == MQTTSubAckFailure ) + if( pxReturnInfo->pSubackCodes != NULL && pxReturnInfo->pSubackCodes[ lIndex ] == MQTTSubAckFailure ) { ESP_LOGE( TAG, "Failed to resubscribe to topic %.*s.", @@ -358,6 +419,8 @@ static void prvSubscriptionCommandCallback( MQTTAgentCommandContext_t * pxComman * the subscriptions. This logic will be updated with exponential backoff and retry. */ configASSERT( pdTRUE ); } + + xUnlockSubList(); } static MQTTStatus_t prvHandleResubscribe( void ) @@ -371,6 +434,8 @@ static MQTTStatus_t prvHandleResubscribe( void ) static MQTTSubscribeInfo_t xSubInfo[ SUBSCRIPTION_MANAGER_MAX_SUBSCRIPTIONS ]; static MQTTAgentCommandInfo_t xCommandParams = { 0 }; + xLockSubList(); + memset( &( xSubInfo[ 0 ] ), 0, SUBSCRIPTION_MANAGER_MAX_SUBSCRIPTIONS * sizeof( MQTTSubscribeInfo_t ) ); /* Loop through each subscription in the subscription list and add a subscribe @@ -423,6 +488,8 @@ static MQTTStatus_t prvHandleResubscribe( void ) MQTT_Status_strerror( xResult ) ); } + xUnlockSubList(); + return xResult; } @@ -906,6 +973,23 @@ BaseType_t xCoreMqttAgentManagerStart( NetworkContext_t * pxNetworkContextIn ) } } + if( xRet != pdFAIL ) + { + xSubListMutex = xSemaphoreCreateMutex(); + + if( xSubListMutex ) + { + ESP_LOGD( TAG, + "Creating MqttAgent manager Mutex." ); + } + else + { + ESP_LOGE( TAG, + "No memory to allocate mutex for MQTT agent manager." ); + xRet = pdFAIL; + } + } + if( xRet != pdFAIL ) { /* Start coreMQTT-Agent. */ diff --git a/main/networking/mqtt/core_mqtt_agent_manager_config.h b/main/networking/mqtt/core_mqtt_agent_manager_config.h index d7e8860..66c3eee 100644 --- a/main/networking/mqtt/core_mqtt_agent_manager_config.h +++ b/main/networking/mqtt/core_mqtt_agent_manager_config.h @@ -30,6 +30,10 @@ /* ESP-IDF sdkconfig include. */ #include +#if CONFIG_GRI_RUN_QUALIFICATION_TEST + #include "qualification_wrapper_config.h" +#endif /* CONFIG_GRI_RUN_QUALIFICATION_TEST */ + /** * @brief The thing name of the device. */ diff --git a/main/qualification_app_main.c b/main/qualification_app_main.c new file mode 100644 index 0000000..1da7919 --- /dev/null +++ b/main/qualification_app_main.c @@ -0,0 +1,590 @@ +/* + * ESP32-C3 FreeRTOS Reference Integration V202204.00 + * Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + +/* Includes *******************************************************************/ + +/* FreeRTOS includes. */ +#include +#include +#include + +/* ESP-IDF includes. */ +#include +#include +#include + +/* coreMQTT-Agent network manager include. */ +#include "core_mqtt_agent_manager.h" + +/* SubscribePublishUnsubscribeDemo demo includes. */ +#include "sub_pub_unsub_demo.h" + +/* OTACodeSigningDemo demo includes. */ +#include "ota_pal.h" +#include "ota_over_mqtt_demo.h" + +/* ESP Secure Certificate Manager include. */ +#include "esp_secure_cert_read.h" + +/* Network transport include. */ +#include "network_transport.h" + +/* Integration test includes */ +#include "test_param_config.h" +#include "test_execution_config.h" +#include "qualification_test.h" +#include "transport_interface_test.h" +#include "ota_pal_test.h" +#include "mqtt_test.h" + +#define keyCLIENT_CERTIFICATE_PEM NULL +#define keyCLIENT_PRIVATE_KEY_PEM NULL + +/* Global variables ***********************************************************/ + +/** + * @brief Logging tag for ESP-IDF logging functions. + */ +static const char * TAG = "qual_main"; + +/** + * @brief The AWS code signing certificate passed in from ./certs/aws_codesign.crt + */ +extern const char pcAwsCodeSigningCertPem[] asm ( "_binary_aws_codesign_crt_start" ); + +/** + * @brief The code signing certificate from + * components/FreeRTOS-Libraries-Integration-Tests/FreeRTOS-Libraries-Integration-Tests/src/ota/test_files/ecdsa-sha256-signer.crt.pem.test + */ +const char pcOtaPalTestCodeSigningCertPem[] = \ +"-----BEGIN CERTIFICATE-----\n"\ +"MIIBXDCCAQOgAwIBAgIJAPMhJT8l0C6AMAoGCCqGSM49BAMCMCExHzAdBgNVBAMM\n"\ +"FnRlc3Rfc2lnbmVyQGFtYXpvbi5jb20wHhcNMTgwNjI3MjAwNDQyWhcNMTkwNjI3\n"\ +"MjAwNDQyWjAhMR8wHQYDVQQDDBZ0ZXN0X3NpZ25lckBhbWF6b24uY29tMFkwEwYH\n"\ +"KoZIzj0CAQYIKoZIzj0DAQcDQgAEyza/tGLVbVxhL41iYtC8D6tGEvAHu498gNtq\n"\ +"DtPsKaoR3t5xQx+6zdWiCi32fgFT2vkeVAmX3pf/Gl8nIP48ZqMkMCIwCwYDVR0P\n"\ +"BAQDAgeAMBMGA1UdJQQMMAoGCCsGAQUFBwMDMAoGCCqGSM49BAMCA0cAMEQCIDkf\n"\ +"83Oq8sOXhSyJCWAN63gc4vp9//RFCXh/hUXPYcTWAiBgmQ5JV2MZH01Upi2lMflN\n"\ +"YLbC+lYscwcSlB2tECUbJA==\n"\ +"-----END CERTIFICATE-----\n"; + +/** + * @brief Socket send and receive timeouts to use. Specified in milliseconds. + */ +#define mqttexampleTRANSPORT_SEND_RECV_TIMEOUT_MS ( 750 ) + +/** + * @brief Used to convert times to/from ticks and milliseconds. + */ +#define mqttexampleMILLISECONDS_PER_SECOND ( 1000U ) +#define mqttexampleMILLISECONDS_PER_TICK ( mqttexampleMILLISECONDS_PER_SECOND / configTICK_RATE_HZ ) + +#if ( DEVICE_ADVISOR_TEST_ENABLED == 1 ) || ( OTA_E2E_TEST_ENABLED == 1 ) + static NetworkContext_t xNetworkContext = { 0 }; +#endif /* ( DEVICE_ADVISOR_TEST_ENABLED == 1 ) || ( OTA_E2E_TEST_ENABLED == 1 ) */ + +#if ( MQTT_TEST_ENABLED == 1 ) || ( TRANSPORT_INTERFACE_TEST_ENABLED == 1 ) + static TransportInterface_t xTransport = { 0 }; + static NetworkContext_t xNetworkContext = { 0 }; + static NetworkContext_t xSecondNetworkContext = { 0 }; +#endif /* ( MQTT_TEST_ENABLED == 1 ) || ( TRANSPORT_INTERFACE_TEST_ENABLED == 1 ) */ + +/** + * @brief Global entry time into the application to use as a reference timestamp + * in the #prvGetTimeMs function. #prvGetTimeMs will always return the difference + * between the current time and the global entry time. This will reduce the chances + * of overflow for the 32 bit unsigned integer used for holding the timestamp. + */ +static uint32_t ulGlobalEntryTimeMs; + +static BaseType_t prvInitializeNetworkContext( char * pcServerName, int xPort, char * pcCaCert, char * pcDeviceCert, char * pcDeviceKey ); +/*-----------------------------------------------------------*/ + + +#if ( MQTT_TEST_ENABLED == 1 ) || ( TRANSPORT_INTERFACE_TEST_ENABLED == 1 ) + static NetworkConnectStatus_t prvTransportNetworkConnect( void * pvNetworkContext, + TestHostInfo_t * pxHostInfo, + void * pvNetworkCredentials ) + { + ( void ) pvNetworkCredentials; + + ( ( NetworkContext_t * ) pvNetworkContext )->pcHostname = pxHostInfo->pHostName; + ( ( NetworkContext_t * ) pvNetworkContext )->xPort = pxHostInfo->port; + + if( xTlsConnect( pvNetworkContext ) != TLS_TRANSPORT_SUCCESS ) + { + return NETWORK_CONNECT_FAILURE; + } + + return NETWORK_CONNECT_SUCCESS; + } +#endif /* MQTT_TEST_ENABLED == 1 || TRANSPORT_INTERFACE_TEST_ENABLED == 1 */ + +#if ( MQTT_TEST_ENABLED == 1 ) || ( TRANSPORT_INTERFACE_TEST_ENABLED == 1 ) + static void prvTransportNetworkDisconnect( void * pNetworkContext ) + { + /* Disconnect the transport network. */ + xTlsDisconnect( pNetworkContext ); + } +#endif /* MQTT_TEST_ENABLED == 1 || TRANSPORT_INTERFACE_TEST_ENABLED == 1 */ +/*-----------------------------------------------------------*/ + +#if ( MQTT_TEST_ENABLED == 1 ) || ( TRANSPORT_INTERFACE_TEST_ENABLED == 1 ) || \ + ( DEVICE_ADVISOR_TEST_ENABLED == 1 ) || ( OTA_E2E_TEST_ENABLED == 1 ) + + static BaseType_t prvInitializeNetworkContext( char * pcServerName, int xPort, char * pcCaCert, char * pcDeviceCert, char * pcDeviceKey ) + { + /* This is returned by this function. */ + BaseType_t xRet = pdPASS; + + /* This is used to store the required buffer length when retrieving data + * from flash. */ + uint32_t ulBufferLen; + + /* This is used to store the error return of ESP-IDF functions. */ + esp_err_t xEspErrRet = ESP_OK; + + /* Verify that the MQTT endpoint and thing name have been configured by the + * user. */ + if( strlen( pcServerName ) == 0 ) + { + ESP_LOGE( TAG, "Empty endpoint for MQTT broker. Set endpoint by " + "running idf.py menuconfig, then Golden Reference Integration -> " + "Endpoint for MQTT Broker to use." ); + xRet = pdFAIL; + } + + /* Initialize first network context. */ + xNetworkContext.pcHostname = pcServerName; + xNetworkContext.xPort = xPort; + + /* Get the device certificate from esp_secure_crt_mgr and put into network + * context. */ + if( ( pcDeviceCert ) && ( strlen( pcDeviceCert ) > 0 ) ) + { + xNetworkContext.pcClientCertPem = pcDeviceCert; + ulBufferLen = strlen( pcDeviceCert ); + } + else + { + xEspErrRet = esp_secure_cert_get_dev_cert_addr( ( const void ** ) &xNetworkContext.pcClientCertPem, + &ulBufferLen ); + } + + + if( xEspErrRet == ESP_OK ) + { + #if CONFIG_GRI_OUTPUT_CERTS_KEYS + ESP_LOGI( TAG, "\Qualification device Cert: \nLength: %d\n%s", + strlen( xNetworkContext.pcClientCertPem ), + xNetworkContext.pcClientCertPem ); + #endif /* CONFIG_GRI_OUTPUT_CERTS_KEYS */ + } + else + { + ESP_LOGE( TAG, "Error in getting device certificate. Error: %s", + esp_err_to_name( xEspErrRet ) ); + + xRet = pdFAIL; + } + + /* Get the root CA certificate and put into network context. */ + if( ( pcCaCert ) && ( strlen( pcCaCert ) > 0 ) ) + { + xNetworkContext.pcServerRootCAPem = pcCaCert; + ulBufferLen = strlen( pcCaCert ); + } + else + { + xEspErrRet = esp_secure_cert_get_ca_cert_addr( ( const void ** ) &xNetworkContext.pcServerRootCAPem, + &ulBufferLen ); + } + + if( xEspErrRet == ESP_OK ) + { + #if CONFIG_GRI_OUTPUT_CERTS_KEYS + ESP_LOGI( TAG, "\nQualification CA Cert: \nLength: %d\n%s", + strlen( xNetworkContext.pcServerRootCAPem ), + xNetworkContext.pcServerRootCAPem ); + #endif /* CONFIG_GRI_OUTPUT_CERTS_KEYS */ + } + else + { + ESP_LOGE( TAG, "Error in getting CA certificate. Error: %s", + esp_err_to_name( xEspErrRet ) ); + + xRet = pdFAIL; + } + + #if CONFIG_EXAMPLE_USE_DS_PERIPHERAL + /* If the digital signature peripheral is being used, get the digital + * signature peripheral context from esp_secure_crt_mgr and put into + * network context. */ + + xNetworkContext.ds_data = esp_secure_cert_get_ds_ctx(); + + if( xNetworkContext.ds_data == NULL ) + { + ESP_LOGE( TAG, "Error in getting digital signature peripheral data." ); + xRet = pdFAIL; + } + #else + #if CONFIG_ESP_SECURE_CERT_DS_PERIPHERAL + #error Reference Integration -> Use DS peripheral set to false \ + but Component config -> Enable DS peripheral support set to \ + true. + #endif /* CONFIG_ESP_SECURE_CERT_DS_PERIPHERAL */ + + /* If the DS peripheral is not being used, get the device private key from + * esp_secure_crt_mgr and put into network context. */ + + if( ( pcDeviceKey ) && ( strlen( pcDeviceKey ) > 0 ) ) + { + xNetworkContext.pcClientKeyPem = pcDeviceKey; + ulBufferLen = strlen( pcDeviceKey ); + } + else + { + xEspErrRet = esp_secure_cert_get_priv_key_addr( ( const void ** ) &xNetworkContext.pcClientKeyPem, + &ulBufferLen ); + } + + if( xEspErrRet == ESP_OK ) + { + #if CONFIG_GRI_OUTPUT_CERTS_KEYS + ESP_LOGI( TAG, "\nQualification private Key: \nLength: %d\n%s", + strlen( xNetworkContext.pcClientKeyPem ), + xNetworkContext.pcClientKeyPem ); + #endif /* CONFIG_GRI_OUTPUT_CERTS_KEYS */ + } + else + { + ESP_LOGE( TAG, "Error in getting private key. Error: %s", + esp_err_to_name( xEspErrRet ) ); + + xRet = pdFAIL; + } + #endif /* CONFIG_EXAMPLE_USE_DS_PERIPHERAL */ + + xNetworkContext.pxTls = NULL; + xNetworkContext.xTlsContextSemaphore = xSemaphoreCreateMutex(); + + if( xNetworkContext.xTlsContextSemaphore == NULL ) + { + ESP_LOGE( TAG, "Not enough memory to create TLS semaphore for global " + "network context." ); + + xRet = pdFAIL; + } + + /* Initialize second network context. */ + #if ( MQTT_TEST_ENABLED == 1 ) || ( TRANSPORT_INTERFACE_TEST_ENABLED == 1 ) + xSecondNetworkContext.pcHostname = pcServerName; + xSecondNetworkContext.xPort = xPort; + + /* Get the device certificate and put into second network context. */ + if( ( pcDeviceCert ) && ( strlen( pcDeviceCert ) > 0 ) ) + { + xSecondNetworkContext.pcClientCertPem = pcDeviceCert; + ulBufferLen = strlen( pcDeviceCert ); + } + else + { + xEspErrRet = esp_secure_cert_get_dev_cert_addr( ( const void ** ) &xSecondNetworkContext.pcClientCertPem, + &ulBufferLen ); + } + + /* Get the root CA certificate and put into second network context. */ + if( ( pcCaCert ) && ( strlen( pcCaCert ) > 0 ) ) + { + xSecondNetworkContext.pcServerRootCAPem = pcCaCert; + ulBufferLen = strlen( pcCaCert ); + } + else + { + xEspErrRet = esp_secure_cert_get_ca_cert_addr( ( const void ** ) &xSecondNetworkContext.pcServerRootCAPem, + &ulBufferLen ); + } + + #if CONFIG_EXAMPLE_USE_DS_PERIPHERAL + /* If the digital signature peripheral is being used, get the digital + * signature peripheral context from esp_secure_crt_mgr and put into + * second network context. */ + + xSecondNetworkContext.ds_data = esp_secure_cert_get_ds_ctx(); + + if( xSecondNetworkContext.ds_data == NULL ) + { + ESP_LOGE( TAG, "Error in getting digital signature peripheral data." ); + xRet = pdFAIL; + } + #else + #if CONFIG_ESP_SECURE_CERT_DS_PERIPHERAL + #error Reference Integration -> Use DS peripheral set to false \ + but Component config -> Enable DS peripheral support set to \ + true. + #endif /* CONFIG_ESP_SECURE_CERT_DS_PERIPHERAL */ + + /* If the DS peripheral is not being used, get the device private key from + * esp_secure_crt_mgr and put into second network context. */ + + if( ( pcDeviceKey ) && ( strlen( pcDeviceKey ) > 0 ) ) + { + xSecondNetworkContext.pcClientKeyPem = pcDeviceKey; + ulBufferLen = strlen( pcDeviceKey ); + } + else + { + xEspErrRet = esp_secure_cert_get_priv_key_addr( ( const void ** ) &xSecondNetworkContext.pcClientKeyPem, + &ulBufferLen ); + } + + if( xEspErrRet == ESP_OK ) + { + /* Do nothing. Private key was printed at main.c. */ + } + else + { + ESP_LOGE( TAG, "Error in getting private key. Error: %s", + esp_err_to_name( xEspErrRet ) ); + + xRet = pdFAIL; + } + #endif /* CONFIG_EXAMPLE_USE_DS_PERIPHERAL */ + + xSecondNetworkContext.pxTls = NULL; + xSecondNetworkContext.xTlsContextSemaphore = xSemaphoreCreateMutex(); + + if( xSecondNetworkContext.xTlsContextSemaphore == NULL ) + { + ESP_LOGE( TAG, "Not enough memory to create TLS semaphore for global " + "second network context." ); + + xRet = pdFAIL; + } + #endif /* ( MQTT_TEST_ENABLED == 1 ) || ( TRANSPORT_INTERFACE_TEST_ENABLED == 1 ) */ + + return xRet; + } +#endif /* ( MQTT_TEST_ENABLED == 1 ) || ( TRANSPORT_INTERFACE_TEST_ENABLED == 1 ) || + ( DEVICE_ADVISOR_TEST_ENABLED == 1 ) || ( OTA_E2E_TEST_ENABLED == 1 ) */ +/*-----------------------------------------------------------*/ + +uint32_t MqttTestGetTimeMs( void ) +{ + TickType_t xTickCount = 0; + uint32_t ulTimeMs = 0UL; + + /* Get the current tick count. */ + xTickCount = xTaskGetTickCount(); + + /* Convert the ticks to milliseconds. */ + ulTimeMs = ( uint32_t ) xTickCount * mqttexampleMILLISECONDS_PER_TICK; + + /* Reduce ulGlobalEntryTimeMs from obtained time so as to always return the + * elapsed time in the application. */ + ulTimeMs = ( uint32_t ) ( ulTimeMs - ulGlobalEntryTimeMs ); + + return ulTimeMs; +} +/*-----------------------------------------------------------*/ + +#if ( MQTT_TEST_ENABLED == 1 ) + void SetupMqttTestParam( MqttTestParam_t * pTestParam ) + { + configASSERT( pTestParam != NULL ); + + /* Initialization of timestamp for MQTT. */ + ulGlobalEntryTimeMs = MqttTestGetTimeMs(); + + /* Setup the transport interface. */ + xTransport.send = espTlsTransportSend; + xTransport.recv = espTlsTransportRecv; + + pTestParam->pTransport = &xTransport; + pTestParam->pNetworkContext = &xNetworkContext; + pTestParam->pSecondNetworkContext = &xSecondNetworkContext; + pTestParam->pNetworkConnect = prvTransportNetworkConnect; + pTestParam->pNetworkDisconnect = prvTransportNetworkDisconnect; + pTestParam->pGetTimeMs = MqttTestGetTimeMs; + } +#endif /* TRANSPORT_INTERFACE_TEST_ENABLED == 1 */ +/*-----------------------------------------------------------*/ + +#if ( TRANSPORT_INTERFACE_TEST_ENABLED == 1 ) + void SetupTransportTestParam( TransportTestParam_t * pTestParam ) + { + configASSERT( pTestParam != NULL ); + + /* Setup the transport interface. */ + xTransport.send = espTlsTransportSend; + xTransport.recv = espTlsTransportRecv; + + pTestParam->pTransport = &xTransport; + pTestParam->pNetworkContext = &xNetworkContext; + pTestParam->pSecondNetworkContext = &xSecondNetworkContext; + pTestParam->pNetworkConnect = prvTransportNetworkConnect; + pTestParam->pNetworkDisconnect = prvTransportNetworkDisconnect; + } +#endif /* if ( TRANSPORT_INTERFACE_TEST_ENABLED == 1 ) */ + +#if ( OTA_PAL_TEST_ENABLED == 1 ) + void SetupOtaPalTestParam( OtaPalTestParam_t * pTestParam ) + { + pTestParam->pageSize = 1 << otaconfigLOG2_FILE_BLOCK_SIZE; + } +#endif /* if ( OTA_PAL_TEST_ENABLED == 1 ) */ +/*-----------------------------------------------------------*/ + +void runQualification( void * pvArgs ) +{ + (void) pvArgs; + + ESP_LOGI( TAG, "Run qualification test." ); + + RunQualificationTest(); + + ESP_LOGI( TAG, "End qualification test." ); + + for( ; ; ) + { + vTaskDelay( pdMS_TO_TICKS( 30000UL ) ); + } + + vTaskDelete( NULL ); +} +/*-----------------------------------------------------------*/ + +BaseType_t xQualificationStart( void ) +{ + BaseType_t xRet = pdPASS; + + ESP_LOGE( TAG, "Run xQualificationStart" ); + + #if ( MQTT_TEST_ENABLED == 1 ) || ( DEVICE_ADVISOR_TEST_ENABLED == 1 ) || ( OTA_E2E_TEST_ENABLED == 1 ) + prvInitializeNetworkContext( MQTT_SERVER_ENDPOINT, MQTT_SERVER_PORT, NULL, keyCLIENT_CERTIFICATE_PEM, keyCLIENT_PRIVATE_KEY_PEM ); + #endif /* */ + + #if ( TRANSPORT_INTERFACE_TEST_ENABLED == 1 ) + prvInitializeNetworkContext( ECHO_SERVER_ENDPOINT, ECHO_SERVER_PORT, ECHO_SERVER_ROOT_CA, TRANSPORT_CLIENT_CERTIFICATE, TRANSPORT_CLIENT_PRIVATE_KEY ); + #endif /* */ + + #if ( DEVICE_ADVISOR_TEST_ENABLED == 1 ) || ( OTA_E2E_TEST_ENABLED == 1 ) + if( xRet == pdPASS ) + { + xRet = xCoreMqttAgentManagerStart( &xNetworkContext ); + + if( xRet != pdPASS ) + { + ESP_LOGE( TAG, "Failed to initialize and start coreMQTT-Agent network " + "manager." ); + + configASSERT( xRet == pdPASS ); + } + } + #endif /* ( DEVICE_ADVISOR_TEST_ENABLED == 1 ) || ( OTA_E2E_TEST_ENABLED == 1 ) */ + + #if ( OTA_E2E_TEST_ENABLED == 1 ) + if( xRet == pdPASS ) + { + #if CONFIG_GRI_OUTPUT_CERTS_KEYS + ESP_LOGI( TAG, "\nCS Cert: \nLength: %d\n%s", + strlen( pcAwsCodeSigningCertPem ), + pcAwsCodeSigningCertPem ); + #endif /* CONFIG_GRI_OUTPUT_CERTS_KEYS */ + + if( otaPal_SetCodeSigningCertificate( pcAwsCodeSigningCertPem ) ) + { + vStartOTACodeSigningDemo(); + } + else + { + ESP_LOGE( TAG, + "Failed to set the code signing certificate for the AWS OTA " + "library. OTA demo will not be started." ); + + configASSERT( 0 ); + } + } + #endif /* OTA_E2E_TEST_ENABLED == 1 */ + + #if ( OTA_PAL_TEST_ENABLED == 1 ) + if( xRet == pdPASS ) + { + #if CONFIG_GRI_OUTPUT_CERTS_KEYS + ESP_LOGI( TAG, "\nCS Cert: \nLength: %d\n%s", + strlen( pcOtaPalTestCodeSigningCertPem ), + pcOtaPalTestCodeSigningCertPem ); + #endif /* CONFIG_GRI_OUTPUT_CERTS_KEYS */ + + if( otaPal_SetCodeSigningCertificate( pcOtaPalTestCodeSigningCertPem ) ) + { + /* No need to enable OTA task for OTA PAL test. */ + } + else + { + ESP_LOGE( TAG, + "Failed to set the code signing certificate for the AWS OTA " + "library. OTA demo will not be started." ); + + configASSERT( 0 ); + } + } + #endif /* OTA_E2E_TEST_ENABLED == 1 */ + + if( ( xRet = xTaskCreate( runQualification, + "QualTask", + 8192, + NULL, + 1, + NULL ) ) != pdPASS ) + { + ESP_LOGE( TAG, "Failed to start Qualfication task: errno=%d", xRet ); + + configASSERT( 0 ); + } + + return xRet; +} +/*-----------------------------------------------------------*/ + +#if ( DEVICE_ADVISOR_TEST_ENABLED == 1 ) + int RunDeviceAdvisorDemo( void ) + { + vStartSubscribePublishUnsubscribeDemo(); + + return 0; + } +#endif /* DEVICE_ADVISOR_TEST_ENABLED == 1 */ +/*-----------------------------------------------------------*/ + +#if ( OTA_E2E_TEST_ENABLED == 1 ) + int RunOtaE2eDemo( void ) + { + return 0; + } +#endif /* ( OTA_E2E_TEST_ENABLED == 1) */ +/*-----------------------------------------------------------*/ From 22c64965778a44b90a6ed66e8f06446deb3abcc2 Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Thu, 22 Sep 2022 17:05:08 +0800 Subject: [PATCH 06/32] Remove redundant integration submodule pointer --- .gitmodules | 3 --- 1 file changed, 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index 094f14f..a2f2ae3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,6 @@ [submodule "components/esp_secure_cert_mgr"] path = components/esp_secure_cert_mgr url = https://github.com/espressif/esp_secure_cert_mgr.git -[submodule "components/FreeRTOS-Libraries-Integration-Tests/FreeRTOS-Libraries-Integration-Tests"] - path = components/FreeRTOS-Libraries-Integration-Tests/FreeRTOS-Libraries-Integration-Tests - url = git@github.com:ActoryOu/FreeRTOS-Libraries-Integration-Tests.git [submodule "components/esp-aws-iot"] path = components/esp-aws-iot url = https://github.com/ActoryOu/esp-aws-iot/ From 83230e2adee635a5d2d6a5d9dfcda09ae7b0e708 Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Thu, 13 Oct 2022 17:04:31 +0800 Subject: [PATCH 07/32] Update coreMQTT/coreMQTT-Agent/FreeRTOS-Libraries-Integration-Tests. --- .../FreeRTOS-Libraries-Integration-Tests | 2 +- .../config/qualification_wrapper_config.h | 6 +- .../config/test_param_config.h | 3 + .../port/platform_function.c | 287 +++++++++--------- components/esp-aws-iot | 2 +- .../ota_over_mqtt_demo_config.h | 1 + .../networking/mqtt/core_mqtt_agent_manager.c | 2 +- 7 files changed, 159 insertions(+), 144 deletions(-) diff --git a/components/FreeRTOS-Libraries-Integration-Tests/FreeRTOS-Libraries-Integration-Tests b/components/FreeRTOS-Libraries-Integration-Tests/FreeRTOS-Libraries-Integration-Tests index e43aea7..be8ff56 160000 --- a/components/FreeRTOS-Libraries-Integration-Tests/FreeRTOS-Libraries-Integration-Tests +++ b/components/FreeRTOS-Libraries-Integration-Tests/FreeRTOS-Libraries-Integration-Tests @@ -1 +1 @@ -Subproject commit e43aea769347329ef717bd8f297c5f241b3d990b +Subproject commit be8ff56845a6dedd999dd4a1ad346d41bd371983 diff --git a/components/FreeRTOS-Libraries-Integration-Tests/config/qualification_wrapper_config.h b/components/FreeRTOS-Libraries-Integration-Tests/config/qualification_wrapper_config.h index fcde9cd..34e5175 100644 --- a/components/FreeRTOS-Libraries-Integration-Tests/config/qualification_wrapper_config.h +++ b/components/FreeRTOS-Libraries-Integration-Tests/config/qualification_wrapper_config.h @@ -35,7 +35,11 @@ #include "test_param_config.h" /* Common config */ - #define CONFIG_GRI_THING_NAME ( IOT_THING_NAME ) + #if ( MQTT_TEST_ENABLED == 1 ) + #define CONFIG_GRI_THING_NAME ( MQTT_TEST_CLIENT_IDENTIFIER ) + #else + #define CONFIG_GRI_THING_NAME ( IOT_THING_NAME ) + #endif #define CONFIG_GRI_MQTT_ENDPOINT ( MQTT_SERVER_ENDPOINT ) #define CONFIG_GRI_MQTT_PORT ( MQTT_SERVER_PORT ) diff --git a/components/FreeRTOS-Libraries-Integration-Tests/config/test_param_config.h b/components/FreeRTOS-Libraries-Integration-Tests/config/test_param_config.h index 080dd16..f0a83ed 100644 --- a/components/FreeRTOS-Libraries-Integration-Tests/config/test_param_config.h +++ b/components/FreeRTOS-Libraries-Integration-Tests/config/test_param_config.h @@ -182,4 +182,7 @@ */ #define OTA_APP_VERSION_BUILD 1 +#define OUTGOING_PUBLISH_RECORD_COUNT ( 10 ) +#define INCOMING_PUBLISH_RECORD_COUNT ( 10 ) + #endif /* TEST_PARAM_CONFIG_H */ diff --git a/components/FreeRTOS-Libraries-Integration-Tests/port/platform_function.c b/components/FreeRTOS-Libraries-Integration-Tests/port/platform_function.c index a1356ed..aec7191 100644 --- a/components/FreeRTOS-Libraries-Integration-Tests/port/platform_function.c +++ b/components/FreeRTOS-Libraries-Integration-Tests/port/platform_function.c @@ -1,140 +1,147 @@ -#include "platform_function.h" - -#include -#include -#include "freertos/FreeRTOS.h" -#include "freertos/FreeRTOSConfig.h" -#include "freertos/task.h" -#include "freertos/semphr.h" -#include "esp_log.h" -#include - -/* Random number generator include. */ -#include "esp_random.h" - -#define TEST_RESULT_BUFFER_CAPACITY 2048 - -static const char * TAG = "idt_platform_function"; - -typedef struct TaskParam -{ - StaticSemaphore_t joinMutexBuffer; - SemaphoreHandle_t joinMutexHandle; - FRTestThreadFunction_t threadFunc; - void * pParam; - TaskHandle_t taskHandle; -} TaskParam_t; - -/*----------------------- Log Helper -----------------------*/ - -/* The buffer to store test result. The content will be printed if an eol character - * is received */ -static char pcTestResultBuffer[ TEST_RESULT_BUFFER_CAPACITY ] = { 0 }; -static int16_t xBufferSize = 0; -/*-----------------------------------------------------------*/ - -int FRTest_GenerateRandInt() -{ - return (int) esp_random(); -} - -/*-----------------------------------------------------------*/ - -static void ThreadWrapper( void * pParam ) -{ - TaskParam_t * pTaskParam = pParam; - - if( ( pTaskParam != NULL ) && ( pTaskParam->threadFunc != NULL ) && ( pTaskParam->joinMutexHandle != NULL ) ) - { - pTaskParam->threadFunc( pTaskParam->pParam ); - - /* Give the mutex. */ - xSemaphoreGive( pTaskParam->joinMutexHandle ); - } - - vTaskDelete( NULL ); -} -/*-----------------------------------------------------------*/ - -FRTestThreadHandle_t FRTest_ThreadCreate( FRTestThreadFunction_t threadFunc, - void * pParam ) -{ - TaskParam_t * pTaskParam = NULL; - FRTestThreadHandle_t threadHandle = NULL; - BaseType_t xReturned; - - pTaskParam = malloc( sizeof( TaskParam_t ) ); - configASSERT( pTaskParam != NULL ); - - pTaskParam->joinMutexHandle = xSemaphoreCreateBinaryStatic( &pTaskParam->joinMutexBuffer ); - configASSERT( pTaskParam->joinMutexHandle != NULL ); - - pTaskParam->threadFunc = threadFunc; - pTaskParam->pParam = pParam; - - xReturned = xTaskCreate( ThreadWrapper, /* Task code. */ - "ThreadWrapper", /* All tasks have same name. */ - 8192, /* Task stack size. */ - pTaskParam, /* Where the task writes its result. */ - tskIDLE_PRIORITY, /* Task priority. */ - &pTaskParam->taskHandle ); - configASSERT( xReturned == pdPASS ); - - threadHandle = pTaskParam; - - return threadHandle; -} - -/*-----------------------------------------------------------*/ - -int FRTest_ThreadTimedJoin( FRTestThreadHandle_t threadHandle, - uint32_t timeoutMs ) -{ - TaskParam_t * pTaskParam = threadHandle; - BaseType_t xReturned; - int retValue = 0; - - /* Check the parameters. */ - configASSERT( pTaskParam != NULL ); - configASSERT( pTaskParam->joinMutexHandle != NULL ); - - /* Wait for the thread. */ - xReturned = xSemaphoreTake( pTaskParam->joinMutexHandle, pdMS_TO_TICKS( timeoutMs ) ); - - if( xReturned != pdTRUE ) - { - ESP_LOGW( TAG, "Waiting thread exist failed after %u %d. Task abort.", timeoutMs, xReturned ); - - /* Return negative value to indicate error. */ - retValue = -1; - - /* There may be used after free. Assert here to indicate error. */ - configASSERT( 0 ); - } - - free( pTaskParam ); - - return retValue; -} - -/*-----------------------------------------------------------*/ - -void FRTest_TimeDelay( uint32_t delayMs ) -{ - vTaskDelay( pdMS_TO_TICKS( delayMs ) ); -} - -/*-----------------------------------------------------------*/ - -void * FRTest_MemoryAlloc( size_t size ) -{ - return pvPortMalloc( size ); -} - -/*-----------------------------------------------------------*/ - -void FRTest_MemoryFree( void * ptr ) -{ - return vPortFree( ptr ); -} -/*-----------------------------------------------------------*/ +#include "platform_function.h" + +#include +#include +#include "freertos/FreeRTOS.h" +#include "freertos/FreeRTOSConfig.h" +#include "freertos/task.h" +#include "freertos/semphr.h" +#include "esp_log.h" +#include + +/* Random number generator include. */ +#include "esp_random.h" + +#define TEST_RESULT_BUFFER_CAPACITY 2048 + +static const char * TAG = "idt_platform_function"; + +typedef struct TaskParam +{ + StaticSemaphore_t joinMutexBuffer; + SemaphoreHandle_t joinMutexHandle; + FRTestThreadFunction_t threadFunc; + void * pParam; + TaskHandle_t taskHandle; +} TaskParam_t; + +extern uint32_t MqttTestGetTimeMs( void ); +/*----------------------- Log Helper -----------------------*/ + +/* The buffer to store test result. The content will be printed if an eol character + * is received */ +static char pcTestResultBuffer[ TEST_RESULT_BUFFER_CAPACITY ] = { 0 }; +static int16_t xBufferSize = 0; +/*-----------------------------------------------------------*/ + +int FRTest_GenerateRandInt() +{ + return (int) esp_random(); +} + +/*-----------------------------------------------------------*/ + +static void ThreadWrapper( void * pParam ) +{ + TaskParam_t * pTaskParam = pParam; + + if( ( pTaskParam != NULL ) && ( pTaskParam->threadFunc != NULL ) && ( pTaskParam->joinMutexHandle != NULL ) ) + { + pTaskParam->threadFunc( pTaskParam->pParam ); + + /* Give the mutex. */ + xSemaphoreGive( pTaskParam->joinMutexHandle ); + } + + vTaskDelete( NULL ); +} +/*-----------------------------------------------------------*/ + +FRTestThreadHandle_t FRTest_ThreadCreate( FRTestThreadFunction_t threadFunc, + void * pParam ) +{ + TaskParam_t * pTaskParam = NULL; + FRTestThreadHandle_t threadHandle = NULL; + BaseType_t xReturned; + + pTaskParam = malloc( sizeof( TaskParam_t ) ); + configASSERT( pTaskParam != NULL ); + + pTaskParam->joinMutexHandle = xSemaphoreCreateBinaryStatic( &pTaskParam->joinMutexBuffer ); + configASSERT( pTaskParam->joinMutexHandle != NULL ); + + pTaskParam->threadFunc = threadFunc; + pTaskParam->pParam = pParam; + + xReturned = xTaskCreate( ThreadWrapper, /* Task code. */ + "ThreadWrapper", /* All tasks have same name. */ + 8192, /* Task stack size. */ + pTaskParam, /* Where the task writes its result. */ + tskIDLE_PRIORITY, /* Task priority. */ + &pTaskParam->taskHandle ); + configASSERT( xReturned == pdPASS ); + + threadHandle = pTaskParam; + + return threadHandle; +} + +/*-----------------------------------------------------------*/ + +int FRTest_ThreadTimedJoin( FRTestThreadHandle_t threadHandle, + uint32_t timeoutMs ) +{ + TaskParam_t * pTaskParam = threadHandle; + BaseType_t xReturned; + int retValue = 0; + + /* Check the parameters. */ + configASSERT( pTaskParam != NULL ); + configASSERT( pTaskParam->joinMutexHandle != NULL ); + + /* Wait for the thread. */ + xReturned = xSemaphoreTake( pTaskParam->joinMutexHandle, pdMS_TO_TICKS( timeoutMs ) ); + + if( xReturned != pdTRUE ) + { + ESP_LOGW( TAG, "Waiting thread exist failed after %u %d. Task abort.", timeoutMs, xReturned ); + + /* Return negative value to indicate error. */ + retValue = -1; + + /* There may be used after free. Assert here to indicate error. */ + configASSERT( 0 ); + } + + free( pTaskParam ); + + return retValue; +} + +/*-----------------------------------------------------------*/ + +void FRTest_TimeDelay( uint32_t delayMs ) +{ + vTaskDelay( pdMS_TO_TICKS( delayMs ) ); +} + +/*-----------------------------------------------------------*/ + +void * FRTest_MemoryAlloc( size_t size ) +{ + return pvPortMalloc( size ); +} + +/*-----------------------------------------------------------*/ + +void FRTest_MemoryFree( void * ptr ) +{ + return vPortFree( ptr ); +} +/*-----------------------------------------------------------*/ + +uint32_t FRTest_GetTimeMs( void ) +{ + return MqttTestGetTimeMs(); +} +/*-----------------------------------------------------------*/ diff --git a/components/esp-aws-iot b/components/esp-aws-iot index 367b816..0bfdc65 160000 --- a/components/esp-aws-iot +++ b/components/esp-aws-iot @@ -1 +1 @@ -Subproject commit 367b8168d92509e4b1ed4fbe1193905a43935c15 +Subproject commit 0bfdc65d27f6ddf205212c5f23322d88a628ea33 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 60be801..9251842 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 @@ -33,6 +33,7 @@ #if CONFIG_GRI_RUN_QUALIFICATION_TEST #include "qualification_wrapper_config.h" #endif /* CONFIG_GRI_RUN_QUALIFICATION_TEST */ + /** * @brief The thing name of the device. */ diff --git a/main/networking/mqtt/core_mqtt_agent_manager.c b/main/networking/mqtt/core_mqtt_agent_manager.c index 01bcdd4..2cd96d4 100644 --- a/main/networking/mqtt/core_mqtt_agent_manager.c +++ b/main/networking/mqtt/core_mqtt_agent_manager.c @@ -550,7 +550,7 @@ static BaseType_t prvStartCoreMqttAgent( void ) static MQTTStatus_t prvCoreMqttAgentInit( NetworkContext_t * pxNetworkContext ) { - TransportInterface_t xTransport; + TransportInterface_t xTransport = { 0 }; MQTTStatus_t xReturn; MQTTFixedBuffer_t xFixedBuffer = { .pBuffer = ucNetworkBuffer, .size = configMQTT_AGENT_NETWORK_BUFFER_SIZE }; static uint8_t staticQueueStorageArea[ configMQTT_AGENT_COMMAND_QUEUE_LENGTH * sizeof( MQTTAgentCommand_t * ) ]; From 3da53bf684013842439293c21b2aa9f6fbfbc13c Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Mon, 17 Oct 2022 16:00:38 +0800 Subject: [PATCH 08/32] Update LTS2 libraries. --- components/esp-aws-iot | 2 +- manifest.yml | 71 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 manifest.yml diff --git a/components/esp-aws-iot b/components/esp-aws-iot index 0bfdc65..703216c 160000 --- a/components/esp-aws-iot +++ b/components/esp-aws-iot @@ -1 +1 @@ -Subproject commit 0bfdc65d27f6ddf205212c5f23322d88a628ea33 +Subproject commit 703216c8d4bd869d7aea02937459122836bfb71e diff --git a/manifest.yml b/manifest.yml new file mode 100644 index 0000000..c8ec3b5 --- /dev/null +++ b/manifest.yml @@ -0,0 +1,71 @@ +name : "FreeRTOS ESP32C3 Reference Integration" +version: "202210.00" +description: |- + "Reference IoT integration project using the Espressif ESP32C3 and FreeRTOS LTS libraries" +dependencies: + - name: "coreJSON" + version: "v3.2.0" + repository: + type: "git" + url: "https://github.com/FreeRTOS/coreJSON.git" + path: "components/esp-aws-iot/libraries/coreJSON/coreJSON" + - name: "coreHTTP" + version: "v3.0.0" + repository: + type: "git" + url: "https://github.com/FreeRTOS/coreHTTP.git" + path: "components/esp-aws-iot/libraries/coreHTTP/coreHTTP" + - name: "coreMQTT" + version: "v2.1.0" + repository: + type: "git" + url: "https://github.com/FreeRTOS/coreMQTT.git" + path: "components/esp-aws-iot/libraries/coreMQTT/coreMQTT" + - name: "coreMQTT-Agent" + version: "v1.2.0" + repository: + type: "git" + url: "https://github.com/FreeRTOS/coreMQTT-Agent.git" + path: "components/esp-aws-iot/libraries/coreMQTT-Agent/coreMQTT-Agent" + - name: "corePKCS11" + version: "v3.5.0" + repository: + type: "git" + url: "https://github.com/FreeRTOS/corePKCS11.git" + path: "components/esp-aws-iot/libraries/corePKCS11/corePKCS11" + - name: "device-shadow" + version: "v1.3.0" + repository: + type: "git" + url: "https://github.com/aws/Device-Shadow-for-AWS-IoT-embedded-sdk.git" + path: "components/esp-aws-iot/libraries/Device-Shadow-for-AWS-IoT-embedded-sdk/Device-Shadow-for-AWS-IoT-embedded-sdk" + - name: "backoffAlgorithm" + version: "v1.3.0" + repository: + type: "git" + url: "https://github.com/FreeRTOS/backoffAlgorithm.git" + path: "components/esp-aws-iot/libraries/backoffAlgorithm/backoffAlgorithm" + - name: "device-defender" + version: "v1.3.0" + repository: + type: "git" + url: "https://github.com/aws/Device-Defender-for-AWS-IoT-embedded-sdk.git" + path: "components/esp-aws-iot/libraries/Device-Defender-for-AWS-IoT-embedded-sdk/Device-Defender-for-AWS-IoT-embedded-sdk" + - name: "ota" + version: "v3.4.0" + repository: + type: "git" + url: "https://github.com/aws/ota-for-AWS-IoT-embedded-sdk.git" + path: "components/esp-aws-iot/libraries/ota-for-aws-iot-embedded-sdk/ota-for-aws-iot-embedded-sdk" + - name: "jobs" + version: "v1.3.0" + repository: + type: "git" + url: "https://github.com/aws/Jobs-for-AWS-IoT-embedded-sdk.git" + path: "components/esp-aws-iot/libraries/Jobs-for-AWS-IoT-embedded-sdk/Jobs-for-AWS-IoT-embedded-sdk" + - name: "FreeRTOS-Libraries-Integration-Tests" + version: "202210.00" + repository: + type: "git" + url: "https://github.com/FreeRTOS/FreeRTOS-Libraries-Integration-Tests" + path: "components/FreeRTOS-Libraries-Integration-Tests/FreeRTOS-Libraries-Integration-Tests" From be11beb5688c53f5df8ccea8cff25155351b7c3d Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Wed, 19 Oct 2022 16:37:29 +0800 Subject: [PATCH 09/32] Fix errors after updating LTS libraries. --- .../config/qualification_wrapper_config.h | 4 +++- .../config/test_param_config.h | 10 ++++++++-- .../port/platform_function.c | 6 ------ components/esp-aws-iot | 2 +- main/qualification_app_main.c | 10 +++++++--- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/components/FreeRTOS-Libraries-Integration-Tests/config/qualification_wrapper_config.h b/components/FreeRTOS-Libraries-Integration-Tests/config/qualification_wrapper_config.h index 34e5175..78be2e0 100644 --- a/components/FreeRTOS-Libraries-Integration-Tests/config/qualification_wrapper_config.h +++ b/components/FreeRTOS-Libraries-Integration-Tests/config/qualification_wrapper_config.h @@ -37,8 +37,10 @@ /* Common config */ #if ( MQTT_TEST_ENABLED == 1 ) #define CONFIG_GRI_THING_NAME ( MQTT_TEST_CLIENT_IDENTIFIER ) - #else + #elif ( OTA_E2E_TEST_ENABLED == 1 ) || ( DEVICE_ADVISOR_TEST_ENABLED == 1 ) #define CONFIG_GRI_THING_NAME ( IOT_THING_NAME ) + #else + #define CONFIG_GRI_THING_NAME "noUse" #endif #define CONFIG_GRI_MQTT_ENDPOINT ( MQTT_SERVER_ENDPOINT ) #define CONFIG_GRI_MQTT_PORT ( MQTT_SERVER_PORT ) diff --git a/components/FreeRTOS-Libraries-Integration-Tests/config/test_param_config.h b/components/FreeRTOS-Libraries-Integration-Tests/config/test_param_config.h index f0a83ed..9293685 100644 --- a/components/FreeRTOS-Libraries-Integration-Tests/config/test_param_config.h +++ b/components/FreeRTOS-Libraries-Integration-Tests/config/test_param_config.h @@ -52,9 +52,9 @@ */ /** - * @brief The IoT Thing name for the device for OTA test and MQTT test. + * @brief The client identifier for MQTT test. * - * #define IOT_THING_NAME "PLACE_HOLDER" + * #define MQTT_TEST_CLIENT_IDENTIFIER "PLACE_HOLDER" */ /** @@ -156,6 +156,12 @@ */ #define OTA_PAL_USE_FILE_SYSTEM 0 +/** + * @brief The IoT Thing name for the device for OTA test. + * + * #define IOT_THING_NAME "PLACE_HOLDER" + */ + /** * @brief 1 if using PKCS #11 to access the code sign certificate from NVM. */ diff --git a/components/FreeRTOS-Libraries-Integration-Tests/port/platform_function.c b/components/FreeRTOS-Libraries-Integration-Tests/port/platform_function.c index aec7191..3dc3b89 100644 --- a/components/FreeRTOS-Libraries-Integration-Tests/port/platform_function.c +++ b/components/FreeRTOS-Libraries-Integration-Tests/port/platform_function.c @@ -26,12 +26,6 @@ typedef struct TaskParam } TaskParam_t; extern uint32_t MqttTestGetTimeMs( void ); -/*----------------------- Log Helper -----------------------*/ - -/* The buffer to store test result. The content will be printed if an eol character - * is received */ -static char pcTestResultBuffer[ TEST_RESULT_BUFFER_CAPACITY ] = { 0 }; -static int16_t xBufferSize = 0; /*-----------------------------------------------------------*/ int FRTest_GenerateRandInt() diff --git a/components/esp-aws-iot b/components/esp-aws-iot index 703216c..9d7b36a 160000 --- a/components/esp-aws-iot +++ b/components/esp-aws-iot @@ -1 +1 @@ -Subproject commit 703216c8d4bd869d7aea02937459122836bfb71e +Subproject commit 9d7b36a9b3d0bd17b07421ee1e2252436013e71a diff --git a/main/qualification_app_main.c b/main/qualification_app_main.c index 1da7919..4a951ca 100644 --- a/main/qualification_app_main.c +++ b/main/qualification_app_main.c @@ -486,11 +486,15 @@ BaseType_t xQualificationStart( void ) #if ( MQTT_TEST_ENABLED == 1 ) || ( DEVICE_ADVISOR_TEST_ENABLED == 1 ) || ( OTA_E2E_TEST_ENABLED == 1 ) prvInitializeNetworkContext( MQTT_SERVER_ENDPOINT, MQTT_SERVER_PORT, NULL, keyCLIENT_CERTIFICATE_PEM, keyCLIENT_PRIVATE_KEY_PEM ); - #endif /* */ + #endif /* ( MQTT_TEST_ENABLED == 1 ) || ( DEVICE_ADVISOR_TEST_ENABLED == 1 ) || ( OTA_E2E_TEST_ENABLED == 1 ) */ #if ( TRANSPORT_INTERFACE_TEST_ENABLED == 1 ) - prvInitializeNetworkContext( ECHO_SERVER_ENDPOINT, ECHO_SERVER_PORT, ECHO_SERVER_ROOT_CA, TRANSPORT_CLIENT_CERTIFICATE, TRANSPORT_CLIENT_PRIVATE_KEY ); - #endif /* */ + #if defined( TRANSPORT_CLIENT_PRIVATE_KEY ) + prvInitializeNetworkContext( ECHO_SERVER_ENDPOINT, ECHO_SERVER_PORT, ECHO_SERVER_ROOT_CA, TRANSPORT_CLIENT_CERTIFICATE, TRANSPORT_CLIENT_PRIVATE_KEY ); + #else + prvInitializeNetworkContext( ECHO_SERVER_ENDPOINT, ECHO_SERVER_PORT, ECHO_SERVER_ROOT_CA, keyCLIENT_CERTIFICATE_PEM, keyCLIENT_PRIVATE_KEY_PEM ); + #endif /* defined( TRANSPORT_CLIENT_PRIVATE_KEY ) */ + #endif /* TRANSPORT_INTERFACE_TEST_ENABLED == 1 ) */ #if ( DEVICE_ADVISOR_TEST_ENABLED == 1 ) || ( OTA_E2E_TEST_ENABLED == 1 ) if( xRet == pdPASS ) From 2c4621722a57386900fda42cb45bd0257d6b106e Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Wed, 19 Oct 2022 16:38:20 +0800 Subject: [PATCH 10/32] Add IDT configurations. --- idt_config/windows/build.bat | 23 +++++++ idt_config/windows/config.json | 19 ++++++ idt_config/windows/device.json | 60 +++++++++++++++++++ idt_config/windows/dummyPublicKeyAsciiHex.txt | 6 ++ idt_config/windows/flash.bat | 11 ++++ idt_config/windows/userdata.json | 52 ++++++++++++++++ 6 files changed, 171 insertions(+) create mode 100644 idt_config/windows/build.bat create mode 100644 idt_config/windows/config.json create mode 100644 idt_config/windows/device.json create mode 100644 idt_config/windows/dummyPublicKeyAsciiHex.txt create mode 100644 idt_config/windows/flash.bat create mode 100644 idt_config/windows/userdata.json diff --git a/idt_config/windows/build.bat b/idt_config/windows/build.bat new file mode 100644 index 0000000..601425a --- /dev/null +++ b/idt_config/windows/build.bat @@ -0,0 +1,23 @@ +SET ESP_IDF_PATH= +SET ESP_IDF_FRAMEWORK_PATH= +SET SOURCE_PATH=%1% + +cd "%ESP_IDF_FRAMEWORK_PATH%" +call "%ESP_IDF_PATH%\idf_cmd_init.bat" +echo "esp-idf exported" +call rm "%SOURCE_PATH%\build\FeaturedFreeRTOSIoTIntegration.bin" +cd "%SOURCE_PATH%" +for /l %%a in (1 1 10) do ( + if exist "%SOURCE_PATH%\build\FeaturedFreeRTOSIoTIntegration.bin" ( + rem file exists + echo "file exists" + goto :break + ) else ( + rem file doesn't exist + echo "file doesn't exist" + call idf.py build + sleep 1 + ) +) + +:break diff --git a/idt_config/windows/config.json b/idt_config/windows/config.json new file mode 100644 index 0000000..625ba46 --- /dev/null +++ b/idt_config/windows/config.json @@ -0,0 +1,19 @@ +{ + "log": { + "location": "../logs/" + }, + "configFiles": { + "root": "../configs", + "device": "../configs/device.json" + }, + "testPath": "../tests/", + "reportPath": "../results/", + "certificatePath": "../certificates/", + "awsRegion": "", + "auth": { + "method": "file", + "credentials": { + "profile": "" + } + } + } \ No newline at end of file diff --git a/idt_config/windows/device.json b/idt_config/windows/device.json new file mode 100644 index 0000000..622ce74 --- /dev/null +++ b/idt_config/windows/device.json @@ -0,0 +1,60 @@ +[ + { + "id":"esp32c3-test", + "sku":"", + "features":[ + { + "name":"Wifi", + "value":"No" + }, + { + "name":"Cellular", + "value":"No" + }, + { + "name":"BLE", + "value":"No" + }, + { + "name":"PKCS11", + "value":"RSA" + }, + { + "name":"OTA", + "value":"Yes", + "configs":[ + { + "name":"OTADataPlaneProtocol", + "value":"MQTT" + } + ] + }, + { + "name":"KeyProvisioning", + "value":"No" + } + ], + "devices":[ + { + "id":"esp32c3", + "connectivity":{ + "protocol":"uart", + "serialPort":"" + }, + "secureElementConfig" : { + "publicKeyAsciiHexFilePath" : "", + "publicDeviceCertificateArn": "", + "secureElementSerialNumber": "", + "preProvisioned" : "Yes", + "pkcs11JITPCodeVerifyRootCertSupport": "No" + }, + "identifiers":[ + { + "name":"serialNo", + "value":"" + } + ] + } + ] + } + ] \ No newline at end of file diff --git a/idt_config/windows/dummyPublicKeyAsciiHex.txt b/idt_config/windows/dummyPublicKeyAsciiHex.txt new file mode 100644 index 0000000..97d054e --- /dev/null +++ b/idt_config/windows/dummyPublicKeyAsciiHex.txt @@ -0,0 +1,6 @@ +3059 3013 0607 2a86 48ce 3d02 0106 082a +8648 ce3d 0301 0703 4200 04cd 6569 ceb8 +1bb9 1e72 339f e8cf 60ef 0f9f b473 33ac +6f19 1813 6999 3fa0 c293 5fae 08f1 1ad0 +41b7 345c e746 1046 228e 5a5f d787 d571 +dcb2 4e8d 75b3 2586 e2cc 0c diff --git a/idt_config/windows/flash.bat b/idt_config/windows/flash.bat new file mode 100644 index 0000000..c9407f7 --- /dev/null +++ b/idt_config/windows/flash.bat @@ -0,0 +1,11 @@ +SET ESP_IDF_PATH= +SET ESP_IDF_FRAMEWORK_PATH= +SET SOURCE_PATH=%1% +SET NUM_COMPORT= + +cd "%ESP_IDF_FRAMEWORK_PATH%" +call "%ESP_IDF_PATH%\idf_cmd_init.bat" +echo "esp-idf exported" +cd "%SOURCE_PATH%" + +call idf.py -p "%NUM_COMPORT%" flash \ No newline at end of file diff --git a/idt_config/windows/userdata.json b/idt_config/windows/userdata.json new file mode 100644 index 0000000..50ac7f8 --- /dev/null +++ b/idt_config/windows/userdata.json @@ -0,0 +1,52 @@ +{ + "sourcePath": "", + "freeRTOSTestParamConfigPath": "{{testData.sourcePath}}/components/FreeRTOS-Libraries-Integration-Tests/config/test_param_config.h", + "freeRTOSTestExecutionConfigPath": "{{testData.sourcePath}}/components/FreeRTOS-Libraries-Integration-Tests/config/test_execution_config.h", + "freeRTOSVersion": "202012.04-LTS", + "buildTool": { + "name": "esp32c3-build", + "version": "1.0.0", + "command": [ + "{{config.idtRootPath}}/configs/build.bat {{testData.sourcePath}}" + ] + }, + "flashTool": { + "name": "esp32c3-flash", + "version": "1.0.0", + "command": [ + "{{config.idtRootPath}}/configs/flash.bat {{testData.sourcePath}}" + ] + }, + "testStartDelayms": 5000, + "echoServerCertificateConfiguration": { + "certificateGenerationMethod": "Automatic" + }, + "echoServerConfiguration": { + "keyGenerationMethod": "EC", + "serverPort": 9000 + }, + "otaConfiguration": { + "otaPALCertificateFile": "notUseInEsp32", + "otaPALFirmwareFileName": "/", + "otaPALUseFileSystem": "No", + "otaE2EDemoFilePath": "{{userData.sourcePath}}/examples/evkbmimxrt1060/test", + "otaE2EDemoConfigFilePath": "{{testData.sourcePath}}/components/FreeRTOS-Libraries-Integration-Tests/config/test_param_config.h", + "otaE2EFirmwareFilePath":"{{testData.sourcePath}}/build/FeaturedFreeRTOSIoTIntegration.bin", + "otaE2EDeviceFirmwareFileName":"NA", + "codeSigningConfiguration": { + "signingMethod": "AWS", + "signerHashingAlgorithm": "SHA256", + "signerSigningAlgorithm": "ECDSA", + "signerCertificate": "", + "untrustedSignerCertificate": "", + "signerCertificateFileName": "", + "compileSignerCertificate": false, + "signerPlatform": "AmazonFreeRTOS-Default" + } + }, + "pkcs11LabelConfiguration":{ + "pkcs11LabelPreProvisionedRSADevicePrivateKeyForTLS": "pkcs11configLABEL_DEVICE_PRIVATE_KEY_FOR_TLS", + "pkcs11LabelPreProvisionedRSADevicePublicKeyForTLS": "pkcs11configLABEL_DEVICE_PUBLIC_KEY_FOR_TLS", + "pkcs11LabelPreProvisionedRSADeviceCertificateForTLS": "pkcs11configLABEL_DEVICE_CERTIFICATE_FOR_TLS" + } +} From 5328c1effbe420b839ad90fe5dbba98ae338ded7 Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Wed, 19 Oct 2022 17:10:07 +0800 Subject: [PATCH 11/32] Update document to run IDT. --- GettingStartedGuide.md | 88 +++++++++++++++++-- .../{windows => }/dummyPublicKeyAsciiHex.txt | 0 idt_config/windows/userdata.json | 2 +- 3 files changed, 82 insertions(+), 8 deletions(-) rename idt_config/{windows => }/dummyPublicKeyAsciiHex.txt (100%) diff --git a/GettingStartedGuide.md b/GettingStartedGuide.md index fd6cc40..306c816 100644 --- a/GettingStartedGuide.md +++ b/GettingStartedGuide.md @@ -25,9 +25,14 @@ Once completed, one can progress to the [Use Security Features](UseSecurityFeatu     [5.5 Upload the binary with the higher version number (created in step 5.3) and create an OTA Update Job](#55-upload-the-binary-with-the-higher-version-number-created-in-step-53-and-create-an-ota-update-job)     [5.6 Monitor OTA](#56-monitor-ota) -[7 Run AWS IoT Qualification Test](#7-run-aws-iot-qualification-test) -    [7.1 Prerequisite](#71-prerequisite) -    [7.2 Steps for each test case](#72-steps-for-each-test-case) +[6 Run AWS IoT Qualification Test](#6-run-aws-iot-qualification-test) +    [6.1 Prerequisite](#61-prerequisite) +    [6.2 Steps for each test case](#62-steps-for-each-test-case) + +[7 Run AWS IoT Device Tester](#7-run-aws-iot-device-tester) +    [7.1 Download AWS IoT Device Tester](#71-download-aws-iot-device-tester) +    [7.2 Configure AWS IoT Device Tester](#72-configure-aws-iot-device-tester) +    [7.3 Running AWS IoT Device Tester](#73-running-aws-iot-device-tester) ## 1 Pre-requisites @@ -446,14 +451,14 @@ I (3444) coreMQTT: Packet received. ReceivedBytes=3. I (3444) ota_over_mqtt_demo: Subscribed to topic $aws/things/thing_esp32c3_nonOta/jobs/notify-next. ``` -## 7 Run AWS IoT Qualification Test +## 6 Run AWS IoT Qualification Test -### 7.1 Prerequisite +### 6.1 Prerequisite - Run [OTA](#5-perform-firmware-over-the-air-updates-with-aws-iot) once manually. - Enable "Run qualification test" by menuconfig (Featured FreeRTOS IoT Integration -> Run qualification test). - Enable Unity and Unity/Fixture by menuconfig. -### 7.2 Steps for each test case +### 6.2 Steps for each test case 1. DEVICE_ADVISOR_TEST_ENABLED - device advisor test - Set DEVICE_ADVISOR_TEST_ENABLED to 1 in [test_execution_config.h](./components/FreeRTOS-Libraries-Integration-Tests/config/test_execution_config.h). @@ -524,4 +529,73 @@ I (3444) ota_over_mqtt_demo: Subscribed to topic $aws/things/thing_esp32c3_nonOt - Disable all configurations in [test_execution_config.h](./components/FreeRTOS-Libraries-Integration-Tests/config/test_execution_config.h). - Follow [FreeRTOS IDT 2.0](https://docs.aws.amazon.com/freertos/latest/userguide/lts-idt-freertos-qualification.html) to set-up tool. - Run IDT OTA E2E test cases. - - See test result on tool output. \ No newline at end of file + - See test result on tool output. + +## 7 Run AWS IoT Device Tester + +The reference integration can be tested using [AWS IoT Device Tester for FreeRTOS (IDT)](https://aws.amazon.com/freertos/device-tester/). IDT is a downloadable tool that can be used to exercise a device integration with FreeRTOS to validate functionality and compatibility with Amazon IoT cloud. Passing the test suite provided by IDT is also required to qualify a device for the [Amazon Partner Device Catalogue](https://devices.amazonaws.com/). + +IDT runs a suite of tests that include testing the device's transport interface layer implementation, PKCS11 functionality, and OTA capabilities. In IDT test cases, the IDT binary will make a copy of the source code, update the header files in the project, then compile the project and flash the resulting image to your board. Finally, IDT will read serial output from the board and communicate with the AWS IoT cloud to ensure that test cases are passing. + +### 7.1 Download AWS IoT Device Tester + +The latest version of IDT can be downloaded from the [public documentation page](https://docs.aws.amazon.com/freertos/latest/userguide/dev-test-versions-afr.html). This reference implementation only supports test suites FRQ_2.2.0 or later. + +### 7.2 Configure AWS IoT Device Tester + +After downloading and unzipping IDT onto your file system, you should extract a file structure that includes the following directories: + +* The `bin` directory holds the devicetester binary, which is the entry point used to run IDT +* The `results` directory holds logs that are generated every time you run IDT. +* The `configs` directory holds configuration values that are needed to set up IDT + +Before we can run IDT, we have to update the files in `configs`. In this reference implementation, we have pre-defined configs available in the `idt_configs` directory. Copy these templates over into IDT, and the rest of this section will walk through the remaining values that need to be filled in. + +First, copy one of each file from `idt_configs` (based on host OS) in this reference repository to the `configs` directory inside the newly downloaded IDT project. This should provide you with the following files in `device_tester/configs` directory: + +``` +configs/dummyPublicKeyAsciiHex.txt +configs/flash.bat or flash.sh +configs/config.json +configs/userdata.json +configs/device.json +configs/build.bat or build.sh +``` + +Next, we need to update some configuration values in these files. + +* In `build.bat` / `build.sh`, update ESP_IDF_PATH, and ESP_IDF_FRAMEWORK_PATH +* In `flash.bat` / `flash.sh`, update ESP_IDF_PATH, ESP_IDF_FRAMEWORK_PATH, and NUM_COMPORT + +* In `config.json`, update the `profile` and `awsRegion` fields +* In `device.json`, update `serialPort` to the serial port of your board as from [PORT](https://github.com/FreeRTOS/iot-reference-esp32c3/blob/main/GettingStartedGuide.md#23-provision-the-esp32-c3-with-the-private-key-device-certificate-and-ca-certificate-in-development-mode). Update `publicKeyAsciiHexFilePath` to the absolute path to `dummyPublicKeyAsciiHex.txt`. Update `publicDeviceCertificateArn` to the ARN of the certificate uploaded when [Setup AWS IoT Core](https://github.com/FreeRTOS/iot-reference-esp32c3/blob/main/GettingStartedGuide.md#21-setup-aws-iot-core). +* In `userdata.json`, update `sourcePath` to the absolute path to the root of this reference implementation repository. +* In `userdata.json`, update `signerCertificate` with the ARN of the [Setup pre-requisites for OTA cloud resources +.](https://github.com/FreeRTOS/iot-reference-esp32c3/blob/main/GettingStartedGuide.md#51-setup-pre-requisites-for-ota-cloud-resources) +* Run all the steps to create a [second code signing certificate](https://github.com/FreeRTOS/iot-reference-esp32c3/blob/main/GettingStartedGuide.md#51-setup-pre-requisites-for-ota-cloud-resources) but do NOT provision the key onto your board. Copy the ARN for this certificate in `userdata.json` for the field `untrustedSignerCertificate`. + +### 7.3 Running AWS IoT Device Tester + +With all the configuration out of the way, we can run IDT either from an individual test group or test case, or the entire qualification suite. + +To list the available test groups, run: + +``` +.\devicetester_win_x86-64.exe list-groups +``` + +To run any one test group, run e.g.: + +``` +.\devicetester_win_x86-64.exe run-suite -g FullCloudIoT -g OTACore +``` + +To run the entire qualification suite, run: + +``` +.\devicetester_win_x86-64.exe run-suite --skip-group-id FullPKCS11_PreProvisioned_RSA +``` + +For more information, `.\devicetester_win_x86-64.exe help` will show all available commands. + +When you run IDT, a `results/uuid` directory is generated that will contain all the logs and other information associated with your test run. This allows you to debug any failures. \ No newline at end of file diff --git a/idt_config/windows/dummyPublicKeyAsciiHex.txt b/idt_config/dummyPublicKeyAsciiHex.txt similarity index 100% rename from idt_config/windows/dummyPublicKeyAsciiHex.txt rename to idt_config/dummyPublicKeyAsciiHex.txt diff --git a/idt_config/windows/userdata.json b/idt_config/windows/userdata.json index 50ac7f8..018cf27 100644 --- a/idt_config/windows/userdata.json +++ b/idt_config/windows/userdata.json @@ -39,7 +39,7 @@ "signerSigningAlgorithm": "ECDSA", "signerCertificate": "", "untrustedSignerCertificate": "", - "signerCertificateFileName": "", + "signerCertificateFileName": "/", "compileSignerCertificate": false, "signerPlatform": "AmazonFreeRTOS-Default" } From 20fd87817d712b2e99d9cf73b51f390f88b46fc6 Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Thu, 20 Oct 2022 14:08:28 +0800 Subject: [PATCH 12/32] Use pdMS_TO_TICKS in MqttTestGetTimeMs. --- main/qualification_app_main.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/main/qualification_app_main.c b/main/qualification_app_main.c index 4a951ca..11cb861 100644 --- a/main/qualification_app_main.c +++ b/main/qualification_app_main.c @@ -96,12 +96,6 @@ const char pcOtaPalTestCodeSigningCertPem[] = \ */ #define mqttexampleTRANSPORT_SEND_RECV_TIMEOUT_MS ( 750 ) -/** - * @brief Used to convert times to/from ticks and milliseconds. - */ -#define mqttexampleMILLISECONDS_PER_SECOND ( 1000U ) -#define mqttexampleMILLISECONDS_PER_TICK ( mqttexampleMILLISECONDS_PER_SECOND / configTICK_RATE_HZ ) - #if ( DEVICE_ADVISOR_TEST_ENABLED == 1 ) || ( OTA_E2E_TEST_ENABLED == 1 ) static NetworkContext_t xNetworkContext = { 0 }; #endif /* ( DEVICE_ADVISOR_TEST_ENABLED == 1 ) || ( OTA_E2E_TEST_ENABLED == 1 ) */ @@ -402,7 +396,7 @@ uint32_t MqttTestGetTimeMs( void ) xTickCount = xTaskGetTickCount(); /* Convert the ticks to milliseconds. */ - ulTimeMs = ( uint32_t ) xTickCount * mqttexampleMILLISECONDS_PER_TICK; + ulTimeMs = ( uint32_t ) pdMS_TO_TICKS( xTickCount ); /* Reduce ulGlobalEntryTimeMs from obtained time so as to always return the * elapsed time in the application. */ From 90711499359929290e2bddaf271e1141e46e5c56 Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Thu, 20 Oct 2022 15:47:44 +0800 Subject: [PATCH 13/32] Remove non-test logs for IDT parser. --- GettingStartedGuide.md | 1 + components/esp-aws-iot | 2 +- main/main.c | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/GettingStartedGuide.md b/GettingStartedGuide.md index 306c816..1198067 100644 --- a/GettingStartedGuide.md +++ b/GettingStartedGuide.md @@ -457,6 +457,7 @@ I (3444) ota_over_mqtt_demo: Subscribed to topic $aws/things/thing_esp32c3_nonOt - Run [OTA](#5-perform-firmware-over-the-air-updates-with-aws-iot) once manually. - Enable "Run qualification test" by menuconfig (Featured FreeRTOS IoT Integration -> Run qualification test). - Enable Unity and Unity/Fixture by menuconfig. +*Note: The log of module `esp_ota_ops` and `esp-tls-mbedtls` will be disabled when `Run qualification test` is on, you can enable them by comment out `esp_log_level_set` in [main.c](./main/main.c). ### 6.2 Steps for each test case diff --git a/components/esp-aws-iot b/components/esp-aws-iot index 9d7b36a..22a9c5c 160000 --- a/components/esp-aws-iot +++ b/components/esp-aws-iot @@ -1 +1 @@ -Subproject commit 9d7b36a9b3d0bd17b07421ee1e2252436013e71a +Subproject commit 22a9c5c51e55e0c77983079f212eaa1155510b89 diff --git a/main/main.c b/main/main.c index 127a9ba..968cf4c 100644 --- a/main/main.c +++ b/main/main.c @@ -294,6 +294,10 @@ static void prvStartEnabledDemos( void ) #endif /* CONFIG_GRI_RUN_QUALIFICATION_TEST == 0 */ #if CONFIG_GRI_RUN_QUALIFICATION_TEST + /* Disable some logs to avoid failure on IDT log parser. */ + esp_log_level_set("esp_ota_ops", ESP_LOG_NONE); + esp_log_level_set("esp-tls-mbedtls", ESP_LOG_NONE); + if( ( xResult = xQualificationStart() ) != pdPASS ) { ESP_LOGE( TAG, "Failed to start Qualfication task: errno=%d", xResult ); From ed2656aba6faa5d2d2e2ac4e1ec530c6c6c8a747 Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Thu, 20 Oct 2022 15:56:27 +0800 Subject: [PATCH 14/32] Update getting started guide document. --- GettingStartedGuide.md | 59 +++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/GettingStartedGuide.md b/GettingStartedGuide.md index 1198067..c9a5563 100644 --- a/GettingStartedGuide.md +++ b/GettingStartedGuide.md @@ -4,35 +4,36 @@ This guide contains instructions on how to setup, build and run the demo without Once completed, one can progress to the [Use Security Features](UseSecurityFeatures.md) guide. -[1 Pre-requisites](#1-pre-requisites) -    [1.1 Hardware Requirements](#11-hardware-requirements) -    [1.2 Software Requirements](#12-software-requirements) +[1 Pre-requisites](#1-pre-requisites)
+    [1.1 Hardware Requirements](#11-hardware-requirements)
+    [1.2 Software Requirements](#12-software-requirements)
-[2 Demo setup](#2-demo-setup) -    [2.1 Setup AWS IoT Core](#21-setup-aws-iot-core) -    [2.2 Configure the project with the AWS IoT Thing Name and AWS device Endpoint](#22-configure-the-project-with-the-aws-iot-thing-name-and-aws-device-endpoint) -    [2.3 Provision the ESP32-C3 with the private key, device certificate and CA certificate in Development Mode](#23-provision-the-esp32-c3-with-the-private-key-device-certificate-and-ca-certificate-in-development-mode) +[2 Demo setup](#2-demo-setup)
+    [2.1 Setup AWS IoT Core](#21-setup-aws-iot-core)
+    [2.2 Configure the project with the AWS IoT Thing Name and AWS device Endpoint](#22-configure-the-project-with-the-aws-iot-thing-name-and-aws-device-endpoint)
+    [2.3 Provision the ESP32-C3 with the private key, device certificate and CA certificate in Development Mode](#23-provision-the-esp32-c3-with-the-private-key-device-certificate-and-ca-certificate-in-development-mode)
-[3 Build and flash the demo project](#3-build-and-flash-the-demo-project) +[3 Build and flash the demo project](#3-build-and-flash-the-demo-project)
-[4 Monitoring the demo](#4-monitoring-the-demo) +[4 Monitoring the demo](#4-monitoring-the-demo)
-[5 Perform firmware Over-the-Air Updates with AWS IoT](#5-perform-firmware-over-the-air-updates-with-aws-iot) -    [5.1 Setup pre-requisites for OTA cloud resources](#51-setup-pre-requisites-for-ota-cloud-resources) -    [5.2 Provision the project with the code-signing public key certificate](#52-provision-the-project-with-the-code-signing-public-key-certificate) -    [5.3 Build an application binary with a higher version number, to be downloaded and activated on the device](#53-build-an-application-binary-with-a-higher-version-number-to-be-downloaded-and-activated-on-the-device) -    [5.4 Build and flash the device with a binary with a lower version number](#54-build-and-flash-the-device-with-a-binary-with-a-lower-version-number) -    [5.5 Upload the binary with the higher version number (created in step 5.3) and create an OTA Update Job](#55-upload-the-binary-with-the-higher-version-number-created-in-step-53-and-create-an-ota-update-job) -    [5.6 Monitor OTA](#56-monitor-ota) +[5 Perform firmware Over-the-Air Updates with AWS IoT](#5-perform-firmware-over-the-air-updates-with-aws-iot)
+    [5.1 Setup pre-requisites for OTA cloud resources](#51-setup-pre-requisites-for-ota-cloud-resources)
+    [5.2 Provision the project with the code-signing public key certificate](#52-provision-the-project-with-the-code-signing-public-key-certificate)
+    [5.3 Build an application binary with a higher version number, to be downloaded and activated on the device](#53-build-an-application-binary-with-a-higher-version-number-to-be-downloaded-and-activated-on-the-device)
+    [5.4 Build and flash the device with a binary with a lower version number](#54-build-and-flash-the-device-with-a-binary-with-a-lower-version-number)
+    [5.5 Upload the binary with the higher version number (created in step 5.3) and create an OTA Update Job](#55-upload-the-binary-with-the-higher-version-number-created-in-step-53-and-create-an-ota-update-job)
+    [5.6 Monitor OTA](#56-monitor-ota)
-[6 Run AWS IoT Qualification Test](#6-run-aws-iot-qualification-test) -    [6.1 Prerequisite](#61-prerequisite) -    [6.2 Steps for each test case](#62-steps-for-each-test-case) +[6 Run AWS IoT Qualification Test](#6-run-aws-iot-qualification-test)
+    [6.1 Prerequisite](#61-prerequisite)
+    [6.2 Steps for each test case](#62-steps-for-each-test-case)
-[7 Run AWS IoT Device Tester](#7-run-aws-iot-device-tester) -    [7.1 Download AWS IoT Device Tester](#71-download-aws-iot-device-tester) -    [7.2 Configure AWS IoT Device Tester](#72-configure-aws-iot-device-tester) -    [7.3 Running AWS IoT Device Tester](#73-running-aws-iot-device-tester) +[7 Run AWS IoT Device Tester](#7-run-aws-iot-device-tester)
+    [7.1 PrerequisiteDownload AWS IoT Device Tester](#71-prerequisite)
+    [7.2 Download AWS IoT Device Tester](#72-download-aws-iot-device-tester)
+    [7.3 Configure AWS IoT Device Tester](#73-configure-aws-iot-device-tester)
+    [7.4 Running AWS IoT Device Tester](#74-running-aws-iot-device-tester)
## 1 Pre-requisites @@ -538,11 +539,17 @@ The reference integration can be tested using [AWS IoT Device Tester for FreeRTO IDT runs a suite of tests that include testing the device's transport interface layer implementation, PKCS11 functionality, and OTA capabilities. In IDT test cases, the IDT binary will make a copy of the source code, update the header files in the project, then compile the project and flash the resulting image to your board. Finally, IDT will read serial output from the board and communicate with the AWS IoT cloud to ensure that test cases are passing. -### 7.1 Download AWS IoT Device Tester +### 7.1 Prerequisite +- Run [OTA](#5-perform-firmware-over-the-air-updates-with-aws-iot) once manually. +- Enable "Run qualification test" by menuconfig (Featured FreeRTOS IoT Integration -> Run qualification test). +- Enable Unity and Unity/Fixture by menuconfig. +*Note: The log of module `esp_ota_ops` and `esp-tls-mbedtls` will be disabled when `Run qualification test` is on, you can enable them by comment out `esp_log_level_set` in [main.c](./main/main.c). + +### 7.2 Download AWS IoT Device Tester The latest version of IDT can be downloaded from the [public documentation page](https://docs.aws.amazon.com/freertos/latest/userguide/dev-test-versions-afr.html). This reference implementation only supports test suites FRQ_2.2.0 or later. -### 7.2 Configure AWS IoT Device Tester +### 7.3 Configure AWS IoT Device Tester After downloading and unzipping IDT onto your file system, you should extract a file structure that includes the following directories: @@ -575,7 +582,7 @@ Next, we need to update some configuration values in these files. .](https://github.com/FreeRTOS/iot-reference-esp32c3/blob/main/GettingStartedGuide.md#51-setup-pre-requisites-for-ota-cloud-resources) * Run all the steps to create a [second code signing certificate](https://github.com/FreeRTOS/iot-reference-esp32c3/blob/main/GettingStartedGuide.md#51-setup-pre-requisites-for-ota-cloud-resources) but do NOT provision the key onto your board. Copy the ARN for this certificate in `userdata.json` for the field `untrustedSignerCertificate`. -### 7.3 Running AWS IoT Device Tester +### 7.4 Running AWS IoT Device Tester With all the configuration out of the way, we can run IDT either from an individual test group or test case, or the entire qualification suite. From b08c0973a6bde3e664398e0d5f2ee585f139c250 Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Thu, 20 Oct 2022 15:57:32 +0800 Subject: [PATCH 15/32] Update getting started guide document. --- GettingStartedGuide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GettingStartedGuide.md b/GettingStartedGuide.md index c9a5563..70ecaee 100644 --- a/GettingStartedGuide.md +++ b/GettingStartedGuide.md @@ -30,7 +30,7 @@ Once completed, one can progress to the [Use Security Features](UseSecurityFeatu     [6.2 Steps for each test case](#62-steps-for-each-test-case)
[7 Run AWS IoT Device Tester](#7-run-aws-iot-device-tester)
-    [7.1 PrerequisiteDownload AWS IoT Device Tester](#71-prerequisite)
+    [7.1 Prerequisite](#71-prerequisite)
    [7.2 Download AWS IoT Device Tester](#72-download-aws-iot-device-tester)
    [7.3 Configure AWS IoT Device Tester](#73-configure-aws-iot-device-tester)
    [7.4 Running AWS IoT Device Tester](#74-running-aws-iot-device-tester)
From 98a809e70e158dc3829a3987ec4c83c51ae9233b Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Thu, 20 Oct 2022 15:59:26 +0800 Subject: [PATCH 16/32] Update getting started guide document. --- GettingStartedGuide.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GettingStartedGuide.md b/GettingStartedGuide.md index 70ecaee..d8ea65f 100644 --- a/GettingStartedGuide.md +++ b/GettingStartedGuide.md @@ -458,7 +458,7 @@ I (3444) ota_over_mqtt_demo: Subscribed to topic $aws/things/thing_esp32c3_nonOt - Run [OTA](#5-perform-firmware-over-the-air-updates-with-aws-iot) once manually. - Enable "Run qualification test" by menuconfig (Featured FreeRTOS IoT Integration -> Run qualification test). - Enable Unity and Unity/Fixture by menuconfig. -*Note: The log of module `esp_ota_ops` and `esp-tls-mbedtls` will be disabled when `Run qualification test` is on, you can enable them by comment out `esp_log_level_set` in [main.c](./main/main.c). +*Note: The log of module `esp_ota_ops` and `esp-tls-mbedtls` will be disabled when `Run qualification test` is on. You can enable them back by commenting out `esp_log_level_set` in [main.c](./main/main.c). ### 6.2 Steps for each test case @@ -543,7 +543,7 @@ IDT runs a suite of tests that include testing the device's transport interface - Run [OTA](#5-perform-firmware-over-the-air-updates-with-aws-iot) once manually. - Enable "Run qualification test" by menuconfig (Featured FreeRTOS IoT Integration -> Run qualification test). - Enable Unity and Unity/Fixture by menuconfig. -*Note: The log of module `esp_ota_ops` and `esp-tls-mbedtls` will be disabled when `Run qualification test` is on, you can enable them by comment out `esp_log_level_set` in [main.c](./main/main.c). +*Note: The log of module `esp_ota_ops` and `esp-tls-mbedtls` will be disabled when `Run qualification test` is on. You can enable them back by commenting out `esp_log_level_set` in [main.c](./main/main.c). ### 7.2 Download AWS IoT Device Tester From db5f9e3bc50e94628b157dad46ea01e32b31f59b Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Thu, 20 Oct 2022 16:05:33 +0800 Subject: [PATCH 17/32] Update getting started guide document. --- GettingStartedGuide.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/GettingStartedGuide.md b/GettingStartedGuide.md index d8ea65f..726e6fc 100644 --- a/GettingStartedGuide.md +++ b/GettingStartedGuide.md @@ -576,11 +576,11 @@ Next, we need to update some configuration values in these files. * In `flash.bat` / `flash.sh`, update ESP_IDF_PATH, ESP_IDF_FRAMEWORK_PATH, and NUM_COMPORT * In `config.json`, update the `profile` and `awsRegion` fields -* In `device.json`, update `serialPort` to the serial port of your board as from [PORT](https://github.com/FreeRTOS/iot-reference-esp32c3/blob/main/GettingStartedGuide.md#23-provision-the-esp32-c3-with-the-private-key-device-certificate-and-ca-certificate-in-development-mode). Update `publicKeyAsciiHexFilePath` to the absolute path to `dummyPublicKeyAsciiHex.txt`. Update `publicDeviceCertificateArn` to the ARN of the certificate uploaded when [Setup AWS IoT Core](https://github.com/FreeRTOS/iot-reference-esp32c3/blob/main/GettingStartedGuide.md#21-setup-aws-iot-core). +* In `device.json`, update `serialPort` to the serial port of your board as from [PORT](./GettingStartedGuide.md#23-provision-the-esp32-c3-with-the-private-key-device-certificate-and-ca-certificate-in-development-mode). Update `publicKeyAsciiHexFilePath` to the absolute path to `dummyPublicKeyAsciiHex.txt`. Update `publicDeviceCertificateArn` to the ARN of the certificate uploaded when [Setup AWS IoT Core](./GettingStartedGuide.md#21-setup-aws-iot-core). * In `userdata.json`, update `sourcePath` to the absolute path to the root of this reference implementation repository. * In `userdata.json`, update `signerCertificate` with the ARN of the [Setup pre-requisites for OTA cloud resources -.](https://github.com/FreeRTOS/iot-reference-esp32c3/blob/main/GettingStartedGuide.md#51-setup-pre-requisites-for-ota-cloud-resources) -* Run all the steps to create a [second code signing certificate](https://github.com/FreeRTOS/iot-reference-esp32c3/blob/main/GettingStartedGuide.md#51-setup-pre-requisites-for-ota-cloud-resources) but do NOT provision the key onto your board. Copy the ARN for this certificate in `userdata.json` for the field `untrustedSignerCertificate`. +.](./GettingStartedGuide.md#51-setup-pre-requisites-for-ota-cloud-resources) +* Run all the steps to create a [second code signing certificate](./GettingStartedGuide.md#51-setup-pre-requisites-for-ota-cloud-resources) but do NOT provision the key onto your board. Copy the ARN for this certificate in `userdata.json` for the field `untrustedSignerCertificate`. ### 7.4 Running AWS IoT Device Tester From bbd015cd6587f4c18d93090621cbbb43b578b729 Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Fri, 21 Oct 2022 10:43:28 +0800 Subject: [PATCH 18/32] Update getting started guide document. --- GettingStartedGuide.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GettingStartedGuide.md b/GettingStartedGuide.md index 726e6fc..e4e37ea 100644 --- a/GettingStartedGuide.md +++ b/GettingStartedGuide.md @@ -458,7 +458,7 @@ I (3444) ota_over_mqtt_demo: Subscribed to topic $aws/things/thing_esp32c3_nonOt - Run [OTA](#5-perform-firmware-over-the-air-updates-with-aws-iot) once manually. - Enable "Run qualification test" by menuconfig (Featured FreeRTOS IoT Integration -> Run qualification test). - Enable Unity and Unity/Fixture by menuconfig. -*Note: The log of module `esp_ota_ops` and `esp-tls-mbedtls` will be disabled when `Run qualification test` is on. You can enable them back by commenting out `esp_log_level_set` in [main.c](./main/main.c). +*Note: The log of module `esp_ota_ops` and `esp-tls-mbedtls` will be disabled when `Run qualification test` is on. You can enable them back by commenting out `esp_log_level_set` in [main.c](./main/main.c).* ### 6.2 Steps for each test case @@ -543,7 +543,7 @@ IDT runs a suite of tests that include testing the device's transport interface - Run [OTA](#5-perform-firmware-over-the-air-updates-with-aws-iot) once manually. - Enable "Run qualification test" by menuconfig (Featured FreeRTOS IoT Integration -> Run qualification test). - Enable Unity and Unity/Fixture by menuconfig. -*Note: The log of module `esp_ota_ops` and `esp-tls-mbedtls` will be disabled when `Run qualification test` is on. You can enable them back by commenting out `esp_log_level_set` in [main.c](./main/main.c). +*Note: The log of module `esp_ota_ops` and `esp-tls-mbedtls` will be disabled when `Run qualification test` is on. You can enable them back by commenting out `esp_log_level_set` in [main.c](./main/main.c).* ### 7.2 Download AWS IoT Device Tester From 493f28368e480e862ca339424e30a85a155c560f Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Fri, 21 Oct 2022 10:45:15 +0800 Subject: [PATCH 19/32] Update getting started guide document. --- GettingStartedGuide.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/GettingStartedGuide.md b/GettingStartedGuide.md index e4e37ea..d79dddd 100644 --- a/GettingStartedGuide.md +++ b/GettingStartedGuide.md @@ -458,6 +458,7 @@ I (3444) ota_over_mqtt_demo: Subscribed to topic $aws/things/thing_esp32c3_nonOt - Run [OTA](#5-perform-firmware-over-the-air-updates-with-aws-iot) once manually. - Enable "Run qualification test" by menuconfig (Featured FreeRTOS IoT Integration -> Run qualification test). - Enable Unity and Unity/Fixture by menuconfig. + *Note: The log of module `esp_ota_ops` and `esp-tls-mbedtls` will be disabled when `Run qualification test` is on. You can enable them back by commenting out `esp_log_level_set` in [main.c](./main/main.c).* ### 6.2 Steps for each test case @@ -543,6 +544,7 @@ IDT runs a suite of tests that include testing the device's transport interface - Run [OTA](#5-perform-firmware-over-the-air-updates-with-aws-iot) once manually. - Enable "Run qualification test" by menuconfig (Featured FreeRTOS IoT Integration -> Run qualification test). - Enable Unity and Unity/Fixture by menuconfig. + *Note: The log of module `esp_ota_ops` and `esp-tls-mbedtls` will be disabled when `Run qualification test` is on. You can enable them back by commenting out `esp_log_level_set` in [main.c](./main/main.c).* ### 7.2 Download AWS IoT Device Tester From bd9ee0d73fc6f61349ce7db72df537052fb0e23f Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Mon, 24 Oct 2022 15:28:53 +0800 Subject: [PATCH 20/32] Add qualification configurations into kconfig. --- GettingStartedGuide.md | 42 ++-- .../config/qualification_wrapper_config.h | 32 ++-- .../config/test_execution_config.h | 52 ++++- .../config/test_param_config.h | 37 +++- main/Kconfig.projbuild | 181 ++++++++++++++++++ 5 files changed, 288 insertions(+), 56 deletions(-) diff --git a/GettingStartedGuide.md b/GettingStartedGuide.md index d79dddd..ce863d3 100644 --- a/GettingStartedGuide.md +++ b/GettingStartedGuide.md @@ -463,18 +463,17 @@ I (3444) ota_over_mqtt_demo: Subscribed to topic $aws/things/thing_esp32c3_nonOt ### 6.2 Steps for each test case -1. DEVICE_ADVISOR_TEST_ENABLED - device advisor test - - Set DEVICE_ADVISOR_TEST_ENABLED to 1 in [test_execution_config.h](./components/FreeRTOS-Libraries-Integration-Tests/config/test_execution_config.h). +1. Device Advisor Test + - Enable "Device Advisor Test" in Freatured FreeRTOS IoT Integration -> Qualification Test Configurations -> Qualification Execution Test Configurations by menuconfig. - Create a device advisor test on website. ( Iot Console -> Test -> Device Advisor ) - Create test suite. - - Run test suite and set the device advisor endpoint to MQTT_SERVER_ENDPOINT in [test_param_config.h](./components/FreeRTOS-Libraries-Integration-Tests/config/test_param_config.h). - - Set MQTT_SERVER_PORT and IOT_THING_NAME (Same as provisioned one) in [test_param_config.h](./components/FreeRTOS-Libraries-Integration-Tests/config/test_param_config.h). + - Run test suite and record device advisor endpoint. + - Set "Endpoint for MQTT Broker to use" (from previous step) and "Thing Name for Device Advisor Test/OTA end-to-end Test" in Freatured FreeRTOS IoT Integration -> Qualification Test Configurations -> Qualification Parameter Configurations by menuconfig. - Build and run. - See device advisor test result on website. -1. MQTT_TEST_ENABLED - MQTT test - - Set MQTT_TEST_ENABLED to 1 in [test_execution_config.h](./components/FreeRTOS-Libraries-Integration-Tests/config/test_execution_config.h). - - Set the MQTT endpoint to MQTT_SERVER_ENDPOINT in [test_param_config.h](./components/FreeRTOS-Libraries-Integration-Tests/config/test_param_config.h). - - Set MQTT_SERVER_PORT and IOT_THING_NAME (Same as provisioned one) in [test_param_config.h](./components/FreeRTOS-Libraries-Integration-Tests/config/test_param_config.h). +1. MQTT Test + - Enable "MQTT Test" in Freatured FreeRTOS IoT Integration -> Qualification Test Configurations -> Qualification Execution Test Configurations by menuconfig. + - Set "Endpoint for MQTT Broker to use" and "Client Identifier for MQTT Test" in Freatured FreeRTOS IoT Integration -> Qualification Test Configurations -> Qualification Parameter Configurations by menuconfig. - Build and run. - See test result on target output. - Example output @@ -486,10 +485,11 @@ I (3444) ota_over_mqtt_demo: Subscribed to topic $aws/things/thing_esp32c3_nonOt OK I (84381) qual_main: End qualification test. ``` -1. TRANSPORT_INTERFACE_TEST_ENABLED - Transport layer test - - Set TRANSPORT_INTERFACE_TEST_ENABLED to 1 [test_execution_config.h](./components/FreeRTOS-Libraries-Integration-Tests/config/test_execution_config.h). +1. Transport Interface Test + - Enable "Transport Interface Test" in Freatured FreeRTOS IoT Integration -> Qualification Test Configurations -> Qualification Execution Test Configurations by menuconfig. - Follow [Run The Transport Interface Test](https://github.com/FreeRTOS/FreeRTOS-Libraries-Integration-Tests/tree/main/src/transport_interface#6-run-the-transport-interface-test) to start a echo server. - - Set ECHO_SERVER_ENDPOINT / ECHO_SERVER_PORT / ECHO_SERVER_ROOT_CA / TRANSPORT_CLIENT_CERTIFICATE and TRANSPORT_CLIENT_PRIVATE_KEY in [test_param_config.h](./components/FreeRTOS-Libraries-Integration-Tests/config/test_param_config.h). + - Set "Echo Server Domain Name/IP for Transport Interface Test" and "Port for Echo Server to use" in Freatured FreeRTOS IoT Integration -> Qualification Test Configurations -> Qualification Parameter Configurations by menuconfig. + - Set ECHO_SERVER_ROOT_CA / TRANSPORT_CLIENT_CERTIFICATE and TRANSPORT_CLIENT_PRIVATE_KEY in [test_param_config.h](./components/FreeRTOS-Libraries-Integration-Tests/config/test_param_config.h). - Build and run. - See test result on target output. - Example output @@ -501,9 +501,8 @@ I (3444) ota_over_mqtt_demo: Subscribed to topic $aws/things/thing_esp32c3_nonOt OK I (612755) qual_main: End qualification test. ``` -1. OTA_PAL_TEST_ENABLED - OTA PAL test - - Set OTA_PAL_TEST_ENABLED to 1 [test_execution_config.h](./components/FreeRTOS-Libraries-Integration-Tests/config/test_execution_config.h). - - Set OTA_PAL_FIRMWARE_FILE to "b_u585i_iot02a_ntz.bin" in [test_param_config.h](./components/FreeRTOS-Libraries-Integration-Tests/config/test_param_config.h). +1. OTA PAL Test + - Enable "OTA PAL Test" in Freatured FreeRTOS IoT Integration -> Qualification Test Configurations -> Qualification Execution Test Configurations by menuconfig. - Build and run. - See test result on target output. - Example output @@ -515,8 +514,8 @@ I (3444) ota_over_mqtt_demo: Subscribed to topic $aws/things/thing_esp32c3_nonOt OK I (113755) qual_main: End qualification test. ``` -1. CORE_PKCS11_TEST_ENABLED - Core PKCS11 test - - Set CORE_PKCS11_TEST_ENABLED to 1 [test_execution_config.h](./components/FreeRTOS-Libraries-Integration-Tests/config/test_execution_config.h). +1. Core PKCS11 Test + - Enable "CorePKCS#11 Test" in Freatured FreeRTOS IoT Integration -> Qualification Test Configurations -> Qualification Execution Test Configurations by menuconfig. - Build and run. - See test result on target output. - Example output @@ -528,11 +527,6 @@ I (3444) ota_over_mqtt_demo: Subscribed to topic $aws/things/thing_esp32c3_nonOt OK I (7518) qual_main: End qualification test. ``` -1. OTA_E2E_TEST_ENABLED - OTA E2E test - - Disable all configurations in [test_execution_config.h](./components/FreeRTOS-Libraries-Integration-Tests/config/test_execution_config.h). - - Follow [FreeRTOS IDT 2.0](https://docs.aws.amazon.com/freertos/latest/userguide/lts-idt-freertos-qualification.html) to set-up tool. - - Run IDT OTA E2E test cases. - - See test result on tool output. ## 7 Run AWS IoT Device Tester @@ -544,6 +538,8 @@ IDT runs a suite of tests that include testing the device's transport interface - Run [OTA](#5-perform-firmware-over-the-air-updates-with-aws-iot) once manually. - Enable "Run qualification test" by menuconfig (Featured FreeRTOS IoT Integration -> Run qualification test). - Enable Unity and Unity/Fixture by menuconfig. +- Disable all in Freatured FreeRTOS IoT Integration -> Qualification Test Configurations -> Qualification Execution Test Configurations by menuconfig. +- run "idf.py fullclean" to clear local CMAKE cache. *Note: The log of module `esp_ota_ops` and `esp-tls-mbedtls` will be disabled when `Run qualification test` is on. You can enable them back by commenting out `esp_log_level_set` in [main.c](./main/main.c).* @@ -586,7 +582,7 @@ Next, we need to update some configuration values in these files. ### 7.4 Running AWS IoT Device Tester -With all the configuration out of the way, we can run IDT either from an individual test group or test case, or the entire qualification suite. +With configuration complete, IDT can be run for an individual test group, a test case, or the entire qualification suite. To list the available test groups, run: @@ -608,4 +604,4 @@ To run the entire qualification suite, run: For more information, `.\devicetester_win_x86-64.exe help` will show all available commands. -When you run IDT, a `results/uuid` directory is generated that will contain all the logs and other information associated with your test run. This allows you to debug any failures. \ No newline at end of file +When IDT is run, it generates the `results/uuid` directory that contains the logs and other information associated with your test run, allowing failures to easily be debugged. \ No newline at end of file diff --git a/components/FreeRTOS-Libraries-Integration-Tests/config/qualification_wrapper_config.h b/components/FreeRTOS-Libraries-Integration-Tests/config/qualification_wrapper_config.h index 78be2e0..c596520 100644 --- a/components/FreeRTOS-Libraries-Integration-Tests/config/qualification_wrapper_config.h +++ b/components/FreeRTOS-Libraries-Integration-Tests/config/qualification_wrapper_config.h @@ -30,7 +30,7 @@ /* ESP-IDF sdkconfig include. */ #include -#if CONFIG_GRI_RUN_QUALIFICATION_TEST +#if ( CONFIG_GRI_RUN_QUALIFICATION_TEST == 1 ) #include "test_execution_config.h" #include "test_param_config.h" @@ -45,27 +45,17 @@ #define CONFIG_GRI_MQTT_ENDPOINT ( MQTT_SERVER_ENDPOINT ) #define CONFIG_GRI_MQTT_PORT ( MQTT_SERVER_PORT ) - /* OTA config */ - #define CONFIG_GRI_OTA_DEMO_MAX_FILE_PATH_SIZE ( 260 ) - #define CONFIG_GRI_OTA_DEMO_MAX_STREAM_NAME_SIZE ( 128 ) - #define CONFIG_GRI_OTA_DEMO_TASK_DELAY_MS ( 1000 ) - #define CONFIG_GRI_OTA_DEMO_MQTT_TIMEOUT_MS ( 5000 ) - #define CONFIG_GRI_OTA_DEMO_AGENT_TASK_PRIORITY ( 4 ) - #define CONFIG_GRI_OTA_DEMO_AGENT_TASK_STACK_SIZE ( 4096 ) - #define CONFIG_GRI_OTA_DEMO_DEMO_TASK_PRIORITY ( 1 ) - #define CONFIG_GRI_OTA_DEMO_DEMO_TASK_STACK_SIZE ( 3072 ) - #define CONFIG_GRI_OTA_DEMO_APP_VERSION_MAJOR ( OTA_APP_VERSION_MAJOR ) - #define CONFIG_GRI_OTA_DEMO_APP_VERSION_MINOR ( OTA_APP_VERSION_MINOR ) - #define CONFIG_GRI_OTA_DEMO_APP_VERSION_BUILD ( OTA_APP_VERSION_BUILD ) + #if !defined( CONFIG_GRI_OTA_DEMO_APP_VERSION_MAJOR ) + #define CONFIG_GRI_OTA_DEMO_APP_VERSION_MAJOR ( OTA_APP_VERSION_MAJOR ) + #endif /* CONFIG_GRI_OTA_DEMO_APP_VERSION_MAJOR */ - /* SubPubUnsub demo config */ - #define CONFIG_GRI_SUB_PUB_UNSUB_DEMO_STRING_BUFFER_LENGTH ( 100 ) - #define CONFIG_GRI_SUB_PUB_UNSUB_DEMO_DELAY_BETWEEN_SUB_PUB_UNSUB_LOOPS_MS ( 5000 ) - #define CONFIG_GRI_SUB_PUB_UNSUB_DEMO_MAX_COMMAND_SEND_BLOCK_TIME_MS ( 500 ) - #define CONFIG_GRI_SUB_PUB_UNSUB_DEMO_QOS_LEVEL ( 1 ) - #define CONFIG_GRI_SUB_PUB_UNSUB_DEMO_NUM_TASKS_TO_CREATE ( 1 ) - #define CONFIG_GRI_SUB_PUB_UNSUB_DEMO_TASK_PRIORITY ( 1 ) - #define CONFIG_GRI_SUB_PUB_UNSUB_DEMO_TASK_STACK_SIZE ( 3072 ) + #if !defined( CONFIG_GRI_OTA_DEMO_APP_VERSION_MINOR ) + #define CONFIG_GRI_OTA_DEMO_APP_VERSION_MINOR ( OTA_APP_VERSION_MINOR ) + #endif /* CONFIG_GRI_OTA_DEMO_APP_VERSION_MINOR */ + + #if !defined( CONFIG_GRI_OTA_DEMO_APP_VERSION_BUILD ) + #define CONFIG_GRI_OTA_DEMO_APP_VERSION_BUILD ( OTA_APP_VERSION_BUILD ) + #endif /* CONFIG_GRI_OTA_DEMO_APP_VERSION_BUILD */ #if ( OTA_E2E_TEST_ENABLED == 1 ) /* Enable OTA demo. */ diff --git a/components/FreeRTOS-Libraries-Integration-Tests/config/test_execution_config.h b/components/FreeRTOS-Libraries-Integration-Tests/config/test_execution_config.h index fa99b86..4e176b1 100644 --- a/components/FreeRTOS-Libraries-Integration-Tests/config/test_execution_config.h +++ b/components/FreeRTOS-Libraries-Integration-Tests/config/test_execution_config.h @@ -28,19 +28,59 @@ #ifndef TEST_EXECUTION_CONFIG_H #define TEST_EXECUTION_CONFIG_H +#include + +/* Configuration wrapper. */ +#if CONFIG_GRI_DEVICE_ADVISOR_TEST_ENABLED + #define DEVICE_ADVISOR_TEST_ENABLED_SETTING ( 1 ) +#else + #define DEVICE_ADVISOR_TEST_ENABLED_SETTING ( 0 ) +#endif /* CONFIG_GRI_DEVICE_ADVISOR_TEST_ENABLED */ + +#if CONFIG_GRI_MQTT_TEST_ENABLED + #define MQTT_TEST_ENABLED_SETTING ( 1 ) +#else + #define MQTT_TEST_ENABLED_SETTING ( 0 ) +#endif /* CONFIG_GRI_MQTT_TEST_ENABLED */ + +#if CONFIG_GRI_TRANSPORT_INTERFACE_TEST_ENABLED + #define TRANSPORT_INTERFACE_TEST_ENABLED_SETTING ( 1 ) +#else + #define TRANSPORT_INTERFACE_TEST_ENABLED_SETTING ( 0 ) +#endif /* CONFIG_GRI_TRANSPORT_INTERFACE_TEST_ENABLED */ + +#if CONFIG_GRI_OTA_PAL_TEST_ENABLED + #define OTA_PAL_TEST_ENABLED_SETTING ( 1 ) +#else + #define OTA_PAL_TEST_ENABLED_SETTING ( 0 ) +#endif /* CONFIG_GRI_OTA_PAL_TEST_ENABLED */ + +#if CONFIG_GRI_OTA_E2E_TEST_ENABLED + #define OTA_E2E_TEST_ENABLED_SETTING ( 1 ) +#else + #define OTA_E2E_TEST_ENABLED_SETTING ( 0 ) +#endif /* CONFIG_GRI_OTA_E2E_TEST_ENABLED */ + +#if CONFIG_GRI_CORE_PKCS11_TEST_ENABLED + #define CORE_PKCS11_TEST_ENABLED_SETTING ( 1 ) +#else + #define CORE_PKCS11_TEST_ENABLED_SETTING ( 0 ) +#endif /* CONFIG_GRI_CORE_PKCS11_TEST_ENABLED */ +/* Configuration wrapper. */ + /** * @brief Configuration to enable Device Advisor testing. * * #define DEVICE_ADVISOR_TEST_ENABLED (0) */ -#define DEVICE_ADVISOR_TEST_ENABLED ( 0 ) +#define DEVICE_ADVISOR_TEST_ENABLED ( DEVICE_ADVISOR_TEST_ENABLED_SETTING ) /** * @brief Configuration to enable the MQTT test. * * #define MQTT_TEST_ENABLED (0) */ -#define MQTT_TEST_ENABLED ( 0 ) +#define MQTT_TEST_ENABLED ( MQTT_TEST_ENABLED_SETTING ) /** * @brief Configuration to enable the transport interface test. @@ -48,27 +88,27 @@ * #define TRANSPORT_INTERFACE_TEST_ENABLED (0) */ -#define TRANSPORT_INTERFACE_TEST_ENABLED ( 0 ) +#define TRANSPORT_INTERFACE_TEST_ENABLED ( TRANSPORT_INTERFACE_TEST_ENABLED_SETTING ) /** * @brief Configuration to enable the OTA PAL test. * * #define OTA_PAL_TEST_ENABLED (0) */ -#define OTA_PAL_TEST_ENABLED ( 0 ) +#define OTA_PAL_TEST_ENABLED ( OTA_PAL_TEST_ENABLED_SETTING ) /** * @brief Configuration to enable the OTA End-to-end test. * * #define OTA_E2E_TEST_ENABLED (0) */ -#define OTA_E2E_TEST_ENABLED ( 0 ) +#define OTA_E2E_TEST_ENABLED ( OTA_E2E_TEST_ENABLED_SETTING ) /** * @brief Configuration to enable the corePKCS11 test. * * #define CORE_PKCS11_TEST_ENABLED (0) */ -#define CORE_PKCS11_TEST_ENABLED ( 0 ) +#define CORE_PKCS11_TEST_ENABLED ( CORE_PKCS11_TEST_ENABLED_SETTING ) #endif /* TEST_EXECUTION_CONFIG_H */ diff --git a/components/FreeRTOS-Libraries-Integration-Tests/config/test_param_config.h b/components/FreeRTOS-Libraries-Integration-Tests/config/test_param_config.h index 9293685..2704b91 100644 --- a/components/FreeRTOS-Libraries-Integration-Tests/config/test_param_config.h +++ b/components/FreeRTOS-Libraries-Integration-Tests/config/test_param_config.h @@ -28,6 +28,22 @@ #ifndef TEST_PARAM_CONFIG_H #define TEST_PARAM_CONFIG_H +#include + +/* Configuration wrapper. */ +#if GRI_QUALIFICATION_FORCE_GENERATE_NEW_KEY_PAIR + #define QUALIFICATION_FORCE_GENERATE_NEW_KEY_PAIR_SETTING ( 1 ) +#else + #define QUALIFICATION_FORCE_GENERATE_NEW_KEY_PAIR_SETTING ( 0 ) +#endif /* GRI_QUALIFICATION_FORCE_GENERATE_NEW_KEY_PAIR */ + +#if GRI_QUALIFICATION_OTA_PAL_USE_FILE_SYSTEM + #define QUALIFICATION_OTA_PAL_USE_FILE_SYSTEM_SETTING ( 1 ) +#else + #define QUALIFICATION_OTA_PAL_USE_FILE_SYSTEM_SETTING ( 0 ) +#endif /* GRI_QUALIFICATION_OTA_PAL_USE_FILE_SYSTEM */ +/* Configuration wrapper. */ + /** * @brief Configuration that indicates if the device should generate a key pair. * @@ -37,6 +53,7 @@ * * #define FORCE_GENERATE_NEW_KEY_PAIR 0 */ +#define FORCE_GENERATE_NEW_KEY_PAIR QUALIFICATION_FORCE_GENERATE_NEW_KEY_PAIR_SETTING /** @@ -44,18 +61,22 @@ * * #define MQTT_SERVER_ENDPOINT "PLACE_HOLDER" */ +#define MQTT_SERVER_ENDPOINT CONFIG_GRI_QUALIFICATION_MQTT_ENDPOINT + /** * @brief Port of the MQTT broker to connect to in mqtt test. * * #define MQTT_SERVER_PORT (8883) */ +#define MQTT_SERVER_PORT CONFIG_GRI_QUALIFICATION_MQTT_PORT /** * @brief The client identifier for MQTT test. * * #define MQTT_TEST_CLIENT_IDENTIFIER "PLACE_HOLDER" */ +#define MQTT_TEST_CLIENT_IDENTIFIER CONFIG_GRI_QUALIFICATION_CLIENT_IDENTIFIER /** * @brief Network buffer size specified in bytes. Must be large enough to hold the maximum @@ -63,18 +84,21 @@ * * #define MQTT_TEST_NETWORK_BUFFER_SIZE ( 5000 ) */ +#define MQTT_TEST_NETWORK_BUFFER_SIZE ( CONFIG_GRI_QUALIFICATION_NETWORK_BUFFER_SIZE ) /** * @brief Endpoint of the echo server to connect to in transport interface test. * * #define ECHO_SERVER_ENDPOINT "PLACE_HOLDER" */ +#define ECHO_SERVER_ENDPOINT CONFIG_GRI_QUALIFICATION_ECHO_SERVER /** * @brief Port of the echo server to connect to in transport interface test. * * #define ECHO_SERVER_PORT (9000) */ +#define ECHO_SERVER_PORT CONFIG_GRI_QUALIFICATION_ECHO_SERVER_PORT /** * @brief Root certificate of the echo server. @@ -142,25 +166,26 @@ * If applicable, the device must be pre-provisioned with this certificate. Please see * test/common/ota/test_files for the set of certificates. */ -#define OTA_PAL_CERTIFICATE_FILE "" +#define OTA_PAL_CERTIFICATE_FILE CONFIG_GRI_QUALIFICATION_OTA_PAL_CERTIFICATE_FILE /** * @brief Some devices have a hard-coded name for the firmware image to boot. */ -#define OTA_PAL_FIRMWARE_FILE "/" +#define OTA_PAL_FIRMWARE_FILE CONFIG_GRI_QUALIFICATION_OTA_PAL_FIRMWARE_FILE /** * @brief Some boards OTA PAL layers will use the file names passed into it for the * image and the certificates because their non-volatile memory is abstracted by a * file system. Set this to 1 if that is the case for your device. */ -#define OTA_PAL_USE_FILE_SYSTEM 0 +#define OTA_PAL_USE_FILE_SYSTEM QUALIFICATION_OTA_PAL_USE_FILE_SYSTEM_SETTING /** * @brief The IoT Thing name for the device for OTA test. * * #define IOT_THING_NAME "PLACE_HOLDER" */ +#define IOT_THING_NAME CONFIG_GRI_QUALIFICATION_THING_NAME /** * @brief 1 if using PKCS #11 to access the code sign certificate from NVM. @@ -172,21 +197,21 @@ * * #define OTA_APP_VERSION_MAJOR 0 */ -#define OTA_APP_VERSION_MAJOR 0 +#define OTA_APP_VERSION_MAJOR CONFIG_GRI_QUALIFICATION_OTA_APP_VERSION_MAJOR /** * @brief Major version for OTA E2E test. * * #define OTA_APP_VERSION_MINOR 9 */ -#define OTA_APP_VERSION_MINOR 9 +#define OTA_APP_VERSION_MINOR CONFIG_GRI_QUALIFICATION_OTA_APP_VERSION_MINOR /** * @brief Major version for OTA E2E test. * * #define OTA_APP_VERSION_BUILD 1 */ -#define OTA_APP_VERSION_BUILD 1 +#define OTA_APP_VERSION_BUILD CONFIG_GRI_QUALIFICATION_OTA_APP_VERSION_BUILD #define OUTGOING_PUBLISH_RECORD_COUNT ( 10 ) #define INCOMING_PUBLISH_RECORD_COUNT ( 10 ) diff --git a/main/Kconfig.projbuild b/main/Kconfig.projbuild index 97c7632..88e82e6 100644 --- a/main/Kconfig.projbuild +++ b/main/Kconfig.projbuild @@ -29,6 +29,187 @@ menu "Featured FreeRTOS IoT Integration" Enable to run qualification test. Use configurations in test_execution_config.h and test_param_config.h. Disable to demo. Use configurations below (in sdkconfig). + menu "Qualification Test Configurations" + + menu "Qualification Execution Test Configurations" + config GRI_DEVICE_ADVISOR_TEST_ENABLED + bool "Device Advisor Test." + default n + + config GRI_MQTT_TEST_ENABLED + bool "MQTT Test." + default n + + config GRI_TRANSPORT_INTERFACE_TEST_ENABLED + 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 + + endmenu # "Qualification Execution Test Configurations" + + menu "Qualification Parameter Configurations" + config GRI_QUALIFICATION_FORCE_GENERATE_NEW_KEY_PAIR + bool "Generate a key pair." + default n + + config GRI_QUALIFICATION_MQTT_ENDPOINT + string "Endpoint for MQTT Broker to use" + default "PLACE_HOLDER" + help + MQTT Broker for Device Advisor Test/MQTT Test/OTA end-to-end Test. + + config GRI_QUALIFICATION_MQTT_PORT + int "Port for MQTT Broker to use" + default 8883 + + config GRI_QUALIFICATION_CLIENT_IDENTIFIER + string "Client Identifier for MQTT Test" + default "PLACE_HOLDER" + + config GRI_QUALIFICATION_NETWORK_BUFFER_SIZE + int "Network Buffer Size for MQTT Test" + default 5000 + + config GRI_QUALIFICATION_ECHO_SERVER + string "Echo Server Domain Name/IP for Transport Interface Test" + default "PLACE_HOLDER" + help + Domain Name or IP address for Transport Interface Test. + + config GRI_QUALIFICATION_ECHO_SERVER_PORT + int "Port for Echo Server to use" + default 9000 + + config GRI_QUALIFICATION_OTA_PAL_CERTIFICATE_FILE + string "Path to cert for OTA PAL Test." + default "" + + config GRI_QUALIFICATION_OTA_PAL_FIRMWARE_FILE + string "Path to store firmware for OTA PAL Test." + default "/" + + config GRI_QUALIFICATION_OTA_PAL_USE_FILE_SYSTEM + bool "Use File System for OTA PAL Test." + default n + + config GRI_QUALIFICATION_THING_NAME + string "Thing Name for Device Advisor Test/OTA end-to-end Test" + default "PLACE_HOLDER" + + config GRI_QUALIFICATION_OTA_APP_VERSION_MAJOR + int "Application version major for OTA end-to-end Test." + default 0 + + config GRI_QUALIFICATION_OTA_APP_VERSION_MINOR + int "Application version minor for OTA end-to-end Test." + default 9 + + config GRI_QUALIFICATION_OTA_APP_VERSION_BUILD + int "Application version build for OTA end-to-end Test." + default 0 + endmenu # "Qualification Parameter Configurations" + + menu "Sub pub unsub demo configurations" + config GRI_SUB_PUB_UNSUB_DEMO_STRING_BUFFER_LENGTH + int "Topic name and payload buffer length" + default 100 + help + Size of statically allocated buffers for holding topic names and payloads. + + config GRI_SUB_PUB_UNSUB_DEMO_DELAY_BETWEEN_SUB_PUB_UNSUB_LOOPS_MS + int "Delay between sub pub unsub loops in milliseconds" + default 5000 + help + Delay for each task between subscription, publish, unsubscription loops. + + config GRI_SUB_PUB_UNSUB_DEMO_MAX_COMMAND_SEND_BLOCK_TIME_MS + int "coreMQTT-Agent command post block time in milliseconds." + default 500 + help + The maximum amount of time in milliseconds to wait for the commands to be posted to the MQTT agent should the MQTT agent's command queue be full. Tasks wait in the Blocked state, so don't use any CPU time. + + config GRI_SUB_PUB_UNSUB_DEMO_QOS_LEVEL + int "QoS level of MQTT operations" + default 1 + range 0 2 + help + The QoS level of MQTT messages sent by this demo. This must be 0 or 1 if using AWS as AWS only supports levels 0 or 1. If using another MQTT broker, that supports QoS level 2, this can be set to 2. + + config GRI_SUB_PUB_UNSUB_DEMO_NUM_TASKS_TO_CREATE + int "Number of SubPubUnsub tasks to create" + default 1 + help + The number of SubPubUnsub tasks to create for this demo. + + config GRI_SUB_PUB_UNSUB_DEMO_TASK_PRIORITY + int "SubPubUnsub task priority." + default 1 + help + The task priority of each of the SubPubUnsub tasks. + + config GRI_SUB_PUB_UNSUB_DEMO_TASK_STACK_SIZE + int "SubPubUnsub task stack size." + default 3072 + help + The task stack size for each of the SubPubUnsub tasks. + + endmenu # Sub pub unsub demo configurations + + menu "OTA demo configurations" + config GRI_OTA_DEMO_MAX_FILE_PATH_SIZE + int "Max file path size." + default 260 + help + The maximum size of the file paths used in the demo. + + config GRI_OTA_DEMO_MAX_STREAM_NAME_SIZE + int "Max stream name size." + default 128 + help + The maximum size of the stream name required for downloading update file from streaming service. + + config GRI_OTA_DEMO_TASK_DELAY_MS + int "OTA statistic output delay milliseconds." + default 1000 + help + 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. + + config GRI_OTA_DEMO_MQTT_TIMEOUT_MS + int "MQTT operation timeout milliseconds." + default 5000 + help + 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. + + config GRI_OTA_DEMO_AGENT_TASK_PRIORITY + int "OTA agent task priority." + default 4 + + config GRI_OTA_DEMO_AGENT_TASK_STACK_SIZE + int "OTA agent task stack size." + default 4096 + + config GRI_OTA_DEMO_DEMO_TASK_PRIORITY + int "OTA demo task priority." + default 1 + + config GRI_OTA_DEMO_DEMO_TASK_STACK_SIZE + int "OTA demo task stack size." + default 3072 + + endmenu # OTA demo configurations + endmenu # Qualification Test Configurations + config GRI_MQTT_ENDPOINT string "Endpoint for MQTT Broker to use" depends on !GRI_RUN_QUALIFICATION_TEST From 5587aeb511f7cc64e7833a3b6aaaa922e52ed489 Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Mon, 24 Oct 2022 16:02:53 +0800 Subject: [PATCH 21/32] Update getting started guide. --- GettingStartedGuide.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/GettingStartedGuide.md b/GettingStartedGuide.md index ce863d3..0e01d1c 100644 --- a/GettingStartedGuide.md +++ b/GettingStartedGuide.md @@ -465,7 +465,7 @@ I (3444) ota_over_mqtt_demo: Subscribed to topic $aws/things/thing_esp32c3_nonOt 1. Device Advisor Test - Enable "Device Advisor Test" in Freatured FreeRTOS IoT Integration -> Qualification Test Configurations -> Qualification Execution Test Configurations by menuconfig. - - Create a device advisor test on website. ( Iot Console -> Test -> Device Advisor ) + - Create a [device advisor test](https://docs.aws.amazon.com/iot/latest/developerguide/device-advisor.html) on website. ( Iot Console -> Test -> Device Advisor ) - Create test suite. - Run test suite and record device advisor endpoint. - Set "Endpoint for MQTT Broker to use" (from previous step) and "Thing Name for Device Advisor Test/OTA end-to-end Test" in Freatured FreeRTOS IoT Integration -> Qualification Test Configurations -> Qualification Parameter Configurations by menuconfig. @@ -530,7 +530,7 @@ I (3444) ota_over_mqtt_demo: Subscribed to topic $aws/things/thing_esp32c3_nonOt ## 7 Run AWS IoT Device Tester -The reference integration can be tested using [AWS IoT Device Tester for FreeRTOS (IDT)](https://aws.amazon.com/freertos/device-tester/). IDT is a downloadable tool that can be used to exercise a device integration with FreeRTOS to validate functionality and compatibility with Amazon IoT cloud. Passing the test suite provided by IDT is also required to qualify a device for the [Amazon Partner Device Catalogue](https://devices.amazonaws.com/). +This repository can be tested using [AWS IoT Device Tester for FreeRTOS (IDT)](https://aws.amazon.com/freertos/device-tester/). IDT is a downloadable tool that can be used to exercise a device integration with FreeRTOS to validate functionality and compatibility with Amazon IoT cloud. Passing the test suite provided by IDT is also required to qualify a device for the [Amazon Partner Device Catalogue](https://devices.amazonaws.com/). IDT runs a suite of tests that include testing the device's transport interface layer implementation, PKCS11 functionality, and OTA capabilities. In IDT test cases, the IDT binary will make a copy of the source code, update the header files in the project, then compile the project and flash the resulting image to your board. Finally, IDT will read serial output from the board and communicate with the AWS IoT cloud to ensure that test cases are passing. @@ -545,7 +545,7 @@ IDT runs a suite of tests that include testing the device's transport interface ### 7.2 Download AWS IoT Device Tester -The latest version of IDT can be downloaded from the [public documentation page](https://docs.aws.amazon.com/freertos/latest/userguide/dev-test-versions-afr.html). This reference implementation only supports test suites FRQ_2.2.0 or later. +The latest version of IDT can be downloaded from the [public documentation page](https://docs.aws.amazon.com/freertos/latest/userguide/dev-test-versions-afr.html). This repository only supports test suites FRQ_2.2.0 or later. ### 7.3 Configure AWS IoT Device Tester @@ -555,9 +555,9 @@ After downloading and unzipping IDT onto your file system, you should extract a * The `results` directory holds logs that are generated every time you run IDT. * The `configs` directory holds configuration values that are needed to set up IDT -Before we can run IDT, we have to update the files in `configs`. In this reference implementation, we have pre-defined configs available in the `idt_configs` directory. Copy these templates over into IDT, and the rest of this section will walk through the remaining values that need to be filled in. +Before running IDT, the files in `configs` need to be updated. In this repository, we have pre-defined configs available in the `idt_config` directory. Copy these templates over into IDT, and the rest of this section will walk through the remaining values that need to be filled in. -First, copy one of each file from `idt_configs` (based on host OS) in this reference repository to the `configs` directory inside the newly downloaded IDT project. This should provide you with the following files in `device_tester/configs` directory: +First, copy one of each file from `idt_config` (based on host OS) in this reference repository to the `configs` directory inside the newly downloaded IDT project. This should provide you with the following files in `device_tester/configs` directory: ``` configs/dummyPublicKeyAsciiHex.txt @@ -575,7 +575,7 @@ Next, we need to update some configuration values in these files. * In `config.json`, update the `profile` and `awsRegion` fields * In `device.json`, update `serialPort` to the serial port of your board as from [PORT](./GettingStartedGuide.md#23-provision-the-esp32-c3-with-the-private-key-device-certificate-and-ca-certificate-in-development-mode). Update `publicKeyAsciiHexFilePath` to the absolute path to `dummyPublicKeyAsciiHex.txt`. Update `publicDeviceCertificateArn` to the ARN of the certificate uploaded when [Setup AWS IoT Core](./GettingStartedGuide.md#21-setup-aws-iot-core). -* In `userdata.json`, update `sourcePath` to the absolute path to the root of this reference implementation repository. +* In `userdata.json`, update `sourcePath` to the absolute path to the root of this repository. * In `userdata.json`, update `signerCertificate` with the ARN of the [Setup pre-requisites for OTA cloud resources .](./GettingStartedGuide.md#51-setup-pre-requisites-for-ota-cloud-resources) * Run all the steps to create a [second code signing certificate](./GettingStartedGuide.md#51-setup-pre-requisites-for-ota-cloud-resources) but do NOT provision the key onto your board. Copy the ARN for this certificate in `userdata.json` for the field `untrustedSignerCertificate`. @@ -599,7 +599,7 @@ To run any one test group, run e.g.: To run the entire qualification suite, run: ``` -.\devicetester_win_x86-64.exe run-suite --skip-group-id FullPKCS11_PreProvisioned_RSA +.\devicetester_win_x86-64.exe run-suite --skip-group-id FullPKCS11_PreProvisioned_RSA --skip-group-id FullPKCS11_Import_RSA --skip-group-id FullPKCS11_Core --skip-group-id FullTransportInterfacePlainText ``` For more information, `.\devicetester_win_x86-64.exe help` will show all available commands. From e756d35945b1c7b21c66a0e42ae66da654f5fa9e Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Fri, 11 Nov 2022 10:33:05 +0800 Subject: [PATCH 22/32] Fix get time function, run vStartSubscribePublishUnsubscribeDemo before coreMQTT agent task. --- main/qualification_app_main.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/main/qualification_app_main.c b/main/qualification_app_main.c index 11cb861..a728967 100644 --- a/main/qualification_app_main.c +++ b/main/qualification_app_main.c @@ -396,7 +396,7 @@ uint32_t MqttTestGetTimeMs( void ) xTickCount = xTaskGetTickCount(); /* Convert the ticks to milliseconds. */ - ulTimeMs = ( uint32_t ) pdMS_TO_TICKS( xTickCount ); + ulTimeMs = ( uint32_t ) ( xTickCount * 1000 / configTICK_RATE_HZ ) ; /* Reduce ulGlobalEntryTimeMs from obtained time so as to always return the * elapsed time in the application. */ @@ -489,6 +489,13 @@ BaseType_t xQualificationStart( void ) prvInitializeNetworkContext( ECHO_SERVER_ENDPOINT, ECHO_SERVER_PORT, ECHO_SERVER_ROOT_CA, keyCLIENT_CERTIFICATE_PEM, keyCLIENT_PRIVATE_KEY_PEM ); #endif /* defined( TRANSPORT_CLIENT_PRIVATE_KEY ) */ #endif /* TRANSPORT_INTERFACE_TEST_ENABLED == 1 ) */ + + #if ( DEVICE_ADVISOR_TEST_ENABLED == 1 ) + if( xRet == pdPASS ) + { + vStartSubscribePublishUnsubscribeDemo(); + } + #endif /* ( DEVICE_ADVISOR_TEST_ENABLED == 1 ) */ #if ( DEVICE_ADVISOR_TEST_ENABLED == 1 ) || ( OTA_E2E_TEST_ENABLED == 1 ) if( xRet == pdPASS ) @@ -572,8 +579,6 @@ BaseType_t xQualificationStart( void ) #if ( DEVICE_ADVISOR_TEST_ENABLED == 1 ) int RunDeviceAdvisorDemo( void ) { - vStartSubscribePublishUnsubscribeDemo(); - return 0; } #endif /* DEVICE_ADVISOR_TEST_ENABLED == 1 */ From fdd48a778193cf6b9ed6b5831847647d6ed926ce Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Tue, 15 Nov 2022 17:35:29 +0800 Subject: [PATCH 23/32] Disable ota_pal log while testing with IDT --- GettingStartedGuide.md | 4 ++-- main/main.c | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/GettingStartedGuide.md b/GettingStartedGuide.md index 0e01d1c..cdda0e6 100644 --- a/GettingStartedGuide.md +++ b/GettingStartedGuide.md @@ -538,10 +538,10 @@ IDT runs a suite of tests that include testing the device's transport interface - Run [OTA](#5-perform-firmware-over-the-air-updates-with-aws-iot) once manually. - Enable "Run qualification test" by menuconfig (Featured FreeRTOS IoT Integration -> Run qualification test). - Enable Unity and Unity/Fixture by menuconfig. -- Disable all in Freatured FreeRTOS IoT Integration -> Qualification Test Configurations -> Qualification Execution Test Configurations by menuconfig. +- Disable all test cases in Freatured FreeRTOS IoT Integration -> Qualification Test Configurations -> Qualification Execution Test Configurations by menuconfig. - run "idf.py fullclean" to clear local CMAKE cache. -*Note: The log of module `esp_ota_ops` and `esp-tls-mbedtls` will be disabled when `Run qualification test` is on. You can enable them back by commenting out `esp_log_level_set` in [main.c](./main/main.c).* +*Note: The log of module `esp_ota_ops`, `ota_pal` and `esp-tls-mbedtls` will be disabled when `Run qualification test` is on. You can enable them back by commenting out `esp_log_level_set` in [main.c](./main/main.c).* ### 7.2 Download AWS IoT Device Tester diff --git a/main/main.c b/main/main.c index 968cf4c..ddf8103 100644 --- a/main/main.c +++ b/main/main.c @@ -297,6 +297,7 @@ static void prvStartEnabledDemos( void ) /* Disable some logs to avoid failure on IDT log parser. */ esp_log_level_set("esp_ota_ops", ESP_LOG_NONE); esp_log_level_set("esp-tls-mbedtls", ESP_LOG_NONE); + esp_log_level_set("ota_pal", ESP_LOG_NONE); if( ( xResult = xQualificationStart() ) != pdPASS ) { From fb15b31907298a458f49c7869632d50f3d8ad49d Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Thu, 17 Nov 2022 15:36:45 +0800 Subject: [PATCH 24/32] Update userdata.json. --- idt_config/windows/userdata.json | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/idt_config/windows/userdata.json b/idt_config/windows/userdata.json index 018cf27..6888376 100644 --- a/idt_config/windows/userdata.json +++ b/idt_config/windows/userdata.json @@ -2,7 +2,7 @@ "sourcePath": "", "freeRTOSTestParamConfigPath": "{{testData.sourcePath}}/components/FreeRTOS-Libraries-Integration-Tests/config/test_param_config.h", "freeRTOSTestExecutionConfigPath": "{{testData.sourcePath}}/components/FreeRTOS-Libraries-Integration-Tests/config/test_execution_config.h", - "freeRTOSVersion": "202012.04-LTS", + "freeRTOSVersion": "202210.00-LTS", "buildTool": { "name": "esp32c3-build", "version": "1.0.0", @@ -26,19 +26,15 @@ "serverPort": 9000 }, "otaConfiguration": { - "otaPALCertificateFile": "notUseInEsp32", - "otaPALFirmwareFileName": "/", - "otaPALUseFileSystem": "No", - "otaE2EDemoFilePath": "{{userData.sourcePath}}/examples/evkbmimxrt1060/test", - "otaE2EDemoConfigFilePath": "{{testData.sourcePath}}/components/FreeRTOS-Libraries-Integration-Tests/config/test_param_config.h", - "otaE2EFirmwareFilePath":"{{testData.sourcePath}}/build/FeaturedFreeRTOSIoTIntegration.bin", - "otaE2EDeviceFirmwareFileName":"NA", + "otaPALCertificatePath": "notUseInEsp32", + "otaE2EFirmwarePath":"{{testData.sourcePath}}/build/FeaturedFreeRTOSIoTIntegration.bin", + "deviceFirmwarePath":"NA", "codeSigningConfiguration": { "signingMethod": "AWS", "signerHashingAlgorithm": "SHA256", "signerSigningAlgorithm": "ECDSA", - "signerCertificate": "", - "untrustedSignerCertificate": "", + "signerCertificate": "arn:aws:acm:ap-northeast-1:767859759493:certificate/f762caec-2237-4cea-ac5d-844e7bb585a5", + "untrustedSignerCertificate": "arn:aws:acm:ap-northeast-1:767859759493:certificate/e7eec463-6f1d-4bfd-a34b-b596bf681907", "signerCertificateFileName": "/", "compileSignerCertificate": false, "signerPlatform": "AmazonFreeRTOS-Default" From 11b21423971b92c8d4fd9809781cc854e72481dd Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Thu, 17 Nov 2022 16:48:02 +0800 Subject: [PATCH 25/32] Disable AWS_OTA logs while running IDT. --- GettingStartedGuide.md | 2 +- main/main.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/GettingStartedGuide.md b/GettingStartedGuide.md index cdda0e6..d5f9b25 100644 --- a/GettingStartedGuide.md +++ b/GettingStartedGuide.md @@ -541,7 +541,7 @@ IDT runs a suite of tests that include testing the device's transport interface - Disable all test cases in Freatured FreeRTOS IoT Integration -> Qualification Test Configurations -> Qualification Execution Test Configurations by menuconfig. - run "idf.py fullclean" to clear local CMAKE cache. -*Note: The log of module `esp_ota_ops`, `ota_pal` and `esp-tls-mbedtls` will be disabled when `Run qualification test` is on. You can enable them back by commenting out `esp_log_level_set` in [main.c](./main/main.c).* +*Note: The log of module `esp_ota_ops`, `AWS_OTA` and `esp-tls-mbedtls` will be disabled when `Run qualification test` is on. You can enable them back by commenting out `esp_log_level_set` in [main.c](./main/main.c).* ### 7.2 Download AWS IoT Device Tester diff --git a/main/main.c b/main/main.c index ddf8103..1798a11 100644 --- a/main/main.c +++ b/main/main.c @@ -297,7 +297,7 @@ static void prvStartEnabledDemos( void ) /* Disable some logs to avoid failure on IDT log parser. */ esp_log_level_set("esp_ota_ops", ESP_LOG_NONE); esp_log_level_set("esp-tls-mbedtls", ESP_LOG_NONE); - esp_log_level_set("ota_pal", ESP_LOG_NONE); + esp_log_level_set("AWS_OTA", ESP_LOG_NONE); if( ( xResult = xQualificationStart() ) != pdPASS ) { From fb43ddc6ca40c06c5c50c74294e0ee9731099978 Mon Sep 17 00:00:00 2001 From: Lai Date: Thu, 17 Nov 2022 17:28:13 +0800 Subject: [PATCH 26/32] update submodule pointer --- .../FreeRTOS-Libraries-Integration-Tests | 2 +- components/esp-aws-iot | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/FreeRTOS-Libraries-Integration-Tests/FreeRTOS-Libraries-Integration-Tests b/components/FreeRTOS-Libraries-Integration-Tests/FreeRTOS-Libraries-Integration-Tests index be8ff56..3b2ac89 160000 --- a/components/FreeRTOS-Libraries-Integration-Tests/FreeRTOS-Libraries-Integration-Tests +++ b/components/FreeRTOS-Libraries-Integration-Tests/FreeRTOS-Libraries-Integration-Tests @@ -1 +1 @@ -Subproject commit be8ff56845a6dedd999dd4a1ad346d41bd371983 +Subproject commit 3b2ac896b1dbae290d868e61f9e5576efa3fd021 diff --git a/components/esp-aws-iot b/components/esp-aws-iot index 22a9c5c..e64c227 160000 --- a/components/esp-aws-iot +++ b/components/esp-aws-iot @@ -1 +1 @@ -Subproject commit 22a9c5c51e55e0c77983079f212eaa1155510b89 +Subproject commit e64c227a903835f0347bdc55e5fa1c73a5737191 From 06699fb4fa06cbfd59d3d6f2f23a6516b735a0c4 Mon Sep 17 00:00:00 2001 From: Lai Date: Thu, 17 Nov 2022 18:38:46 +0800 Subject: [PATCH 27/32] update submodule pointer --- components/esp-aws-iot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/esp-aws-iot b/components/esp-aws-iot index e64c227..b1ca821 160000 --- a/components/esp-aws-iot +++ b/components/esp-aws-iot @@ -1 +1 @@ -Subproject commit e64c227a903835f0347bdc55e5fa1c73a5737191 +Subproject commit b1ca82190d2219a0f31e3704f3d84ac057231df4 From fe7b864084e1f76c47cf3b394f5a7f1382502162 Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Fri, 18 Nov 2022 16:37:21 +0800 Subject: [PATCH 28/32] Update to 202210.01-LTS version. --- .gitmodules | 2 +- .../FreeRTOS-Libraries-Integration-Tests | 2 +- .../config/test_param_config.h | 10 ++++++++++ components/esp-aws-iot | 2 +- idt_config/windows/userdata.json | 2 +- main/Kconfig.projbuild | 4 ++++ manifest.yml | 6 +++--- 7 files changed, 21 insertions(+), 7 deletions(-) diff --git a/.gitmodules b/.gitmodules index a2f2ae3..f1bd8b6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,4 +7,4 @@ [submodule "components/FreeRTOS-Libraries-Integration-Tests/FreeRTOS-Libraries-Integration-Tests"] path = components/FreeRTOS-Libraries-Integration-Tests/FreeRTOS-Libraries-Integration-Tests url = https://github.com/ActoryOu/FreeRTOS-Libraries-Integration-Tests - branch = lts-2.0 + branch = lts2-patch2 diff --git a/components/FreeRTOS-Libraries-Integration-Tests/FreeRTOS-Libraries-Integration-Tests b/components/FreeRTOS-Libraries-Integration-Tests/FreeRTOS-Libraries-Integration-Tests index be8ff56..4ec8241 160000 --- a/components/FreeRTOS-Libraries-Integration-Tests/FreeRTOS-Libraries-Integration-Tests +++ b/components/FreeRTOS-Libraries-Integration-Tests/FreeRTOS-Libraries-Integration-Tests @@ -1 +1 @@ -Subproject commit be8ff56845a6dedd999dd4a1ad346d41bd371983 +Subproject commit 4ec8241acf2beede601d230f9bd51636df60e240 diff --git a/components/FreeRTOS-Libraries-Integration-Tests/config/test_param_config.h b/components/FreeRTOS-Libraries-Integration-Tests/config/test_param_config.h index 2704b91..14d8741 100644 --- a/components/FreeRTOS-Libraries-Integration-Tests/config/test_param_config.h +++ b/components/FreeRTOS-Libraries-Integration-Tests/config/test_param_config.h @@ -78,6 +78,16 @@ */ #define MQTT_TEST_CLIENT_IDENTIFIER CONFIG_GRI_QUALIFICATION_CLIENT_IDENTIFIER + /** + * @brief Timeout for MQTT_ProcessLoop() function in milliseconds. + * The timeout value is appropriately chosen for receiving an incoming + * PUBLISH message and ack responses for QoS 1 and QoS 2 communications + * with the broker. + * + * #define MQTT_TEST_PROCESS_LOOP_TIMEOUT_MS ( 700 ) + */ +#define MQTT_TEST_PROCESS_LOOP_TIMEOUT_MS GRI_QUALIFICATION_PROCESS_LOOP_TIMEOUT_MS + /** * @brief Network buffer size specified in bytes. Must be large enough to hold the maximum * anticipated MQTT payload. diff --git a/components/esp-aws-iot b/components/esp-aws-iot index 22a9c5c..5463d5e 160000 --- a/components/esp-aws-iot +++ b/components/esp-aws-iot @@ -1 +1 @@ -Subproject commit 22a9c5c51e55e0c77983079f212eaa1155510b89 +Subproject commit 5463d5e0dcde2bfbb6921a49d1fbdf94f1d446b7 diff --git a/idt_config/windows/userdata.json b/idt_config/windows/userdata.json index 6888376..b55d93b 100644 --- a/idt_config/windows/userdata.json +++ b/idt_config/windows/userdata.json @@ -2,7 +2,7 @@ "sourcePath": "", "freeRTOSTestParamConfigPath": "{{testData.sourcePath}}/components/FreeRTOS-Libraries-Integration-Tests/config/test_param_config.h", "freeRTOSTestExecutionConfigPath": "{{testData.sourcePath}}/components/FreeRTOS-Libraries-Integration-Tests/config/test_execution_config.h", - "freeRTOSVersion": "202210.00-LTS", + "freeRTOSVersion": "202210.01-LTS", "buildTool": { "name": "esp32c3-build", "version": "1.0.0", diff --git a/main/Kconfig.projbuild b/main/Kconfig.projbuild index 88e82e6..7083b50 100644 --- a/main/Kconfig.projbuild +++ b/main/Kconfig.projbuild @@ -81,6 +81,10 @@ menu "Featured FreeRTOS IoT Integration" int "Network Buffer Size for MQTT Test" default 5000 + config GRI_QUALIFICATION_PROCESS_LOOP_TIMEOUT_MS + int "Timeout to run MQTT process loop for MQTT Test" + default 700 + config GRI_QUALIFICATION_ECHO_SERVER string "Echo Server Domain Name/IP for Transport Interface Test" default "PLACE_HOLDER" diff --git a/manifest.yml b/manifest.yml index c8ec3b5..fdf0597 100644 --- a/manifest.yml +++ b/manifest.yml @@ -1,5 +1,5 @@ name : "FreeRTOS ESP32C3 Reference Integration" -version: "202210.00" +version: "202210.01" description: |- "Reference IoT integration project using the Espressif ESP32C3 and FreeRTOS LTS libraries" dependencies: @@ -16,7 +16,7 @@ dependencies: url: "https://github.com/FreeRTOS/coreHTTP.git" path: "components/esp-aws-iot/libraries/coreHTTP/coreHTTP" - name: "coreMQTT" - version: "v2.1.0" + version: "v2.1.1" repository: type: "git" url: "https://github.com/FreeRTOS/coreMQTT.git" @@ -64,7 +64,7 @@ dependencies: url: "https://github.com/aws/Jobs-for-AWS-IoT-embedded-sdk.git" path: "components/esp-aws-iot/libraries/Jobs-for-AWS-IoT-embedded-sdk/Jobs-for-AWS-IoT-embedded-sdk" - name: "FreeRTOS-Libraries-Integration-Tests" - version: "202210.00" + version: "202210.01" repository: type: "git" url: "https://github.com/FreeRTOS/FreeRTOS-Libraries-Integration-Tests" From cf6ac3356a1bcf930fe08591ba622efa387f4d58 Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Tue, 22 Nov 2022 18:23:55 +0800 Subject: [PATCH 29/32] Update changelog. --- CHANGELOG.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2602abc..16f5663 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,18 @@ +## v202211.00 (November 2022) +Support IDT qualification test. + +Update Long Term Support (LTS) libraries to 202210.01-LTS: + +* coreMQTT v2.1.1 +* coreHTTP v3.0.0 +* corePKCS11 v3.5.0 +* coreJSON v3.2.0 +* backoffAlgorithm v1.3.0 +* AWS IoT Device Shadow v1.3.0 +* AWS IoT Device Defender v1.3.0 +* AWS IoT Jobs v1.3.0 +* AWS IoT Over-the-air Update v3.4.0 + ## v202204.00 ( April 2022 ) This is the first release for the repository. From aff9dae73604988da630525aaeb1b1d30217114c Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Wed, 23 Nov 2022 08:14:41 +0800 Subject: [PATCH 30/32] Update submodule pointer to Espressif/esp-aws-iot and FreeRTOS/FreeRTOS-Libraries-Integration-Tests --- .gitmodules | 5 ++--- components/esp-aws-iot | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.gitmodules b/.gitmodules index f1bd8b6..9bad026 100644 --- a/.gitmodules +++ b/.gitmodules @@ -3,8 +3,7 @@ url = https://github.com/espressif/esp_secure_cert_mgr.git [submodule "components/esp-aws-iot"] path = components/esp-aws-iot - url = https://github.com/ActoryOu/esp-aws-iot/ + url = https://github.com/espressif/esp-aws-iot [submodule "components/FreeRTOS-Libraries-Integration-Tests/FreeRTOS-Libraries-Integration-Tests"] path = components/FreeRTOS-Libraries-Integration-Tests/FreeRTOS-Libraries-Integration-Tests - url = https://github.com/ActoryOu/FreeRTOS-Libraries-Integration-Tests - branch = lts2-patch2 + url = https://github.com/FreeRTOS/FreeRTOS-Libraries-Integration-Tests diff --git a/components/esp-aws-iot b/components/esp-aws-iot index 5463d5e..bbaf03d 160000 --- a/components/esp-aws-iot +++ b/components/esp-aws-iot @@ -1 +1 @@ -Subproject commit 5463d5e0dcde2bfbb6921a49d1fbdf94f1d446b7 +Subproject commit bbaf03d7d1fbf8a3f91dc18489d7bd27d5b9e9df From ad940c3a220d50406d5bb888c6bb50efcab3553a Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Thu, 8 Dec 2022 12:13:14 +0800 Subject: [PATCH 31/32] Update MQTT_TEST_PROCESS_LOOP_TIMEOUT_MS definition. --- .../config/test_param_config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/FreeRTOS-Libraries-Integration-Tests/config/test_param_config.h b/components/FreeRTOS-Libraries-Integration-Tests/config/test_param_config.h index 14d8741..d226019 100644 --- a/components/FreeRTOS-Libraries-Integration-Tests/config/test_param_config.h +++ b/components/FreeRTOS-Libraries-Integration-Tests/config/test_param_config.h @@ -86,7 +86,7 @@ * * #define MQTT_TEST_PROCESS_LOOP_TIMEOUT_MS ( 700 ) */ -#define MQTT_TEST_PROCESS_LOOP_TIMEOUT_MS GRI_QUALIFICATION_PROCESS_LOOP_TIMEOUT_MS +#define MQTT_TEST_PROCESS_LOOP_TIMEOUT_MS CONFIG_GRI_QUALIFICATION_PROCESS_LOOP_TIMEOUT_MS /** * @brief Network buffer size specified in bytes. Must be large enough to hold the maximum From 991e86317b4b5b32c27f299cef701f44e658c3d9 Mon Sep 17 00:00:00 2001 From: Blake Lai Date: Mon, 12 Dec 2022 06:23:21 +0000 Subject: [PATCH 32/32] Update changelog for 202212.00 release --- CHANGELOG.md | 25 ++++----- GettingStartedGuide.md | 114 ++++++++++++++++++++++------------------- 2 files changed, 73 insertions(+), 66 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 16f5663..71c9f9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,17 +1,18 @@ -## v202211.00 (November 2022) -Support IDT qualification test. +# Changelog for ESP32-C3 MCU Featured FreeRTOS IoT Integration -Update Long Term Support (LTS) libraries to 202210.01-LTS: +## v202212.00 ( December 2022 ) +- [#12](https://github.com/FreeRTOS/iot-reference-esp32c3/pull/12) Update Long Term Support (LTS) libraries to 202210.01-LTS: + * [coreMQTT v2.1.1](https://github.com/FreeRTOS/coreMQTT/blob/v2.1.1/CHANGELOG.md) + * [coreHTTP v3.0.0](https://github.com/FreeRTOS/coreHTTP/tree/v3.0.0) + * [corePKCS11 v3.5.0](https://github.com/FreeRTOS/corePKCS11/tree/v3.5.0) + * [coreJSON v3.2.0](https://github.com/FreeRTOS/coreJSON/tree/v3.2.0) + * [backoffAlgorithm v1.3.0](https://github.com/FreeRTOS/backoffAlgorithm/tree/v1.3.0) + * [AWS IoT Device Shadow v1.3.0](https://github.com/aws/Device-Shadow-for-AWS-IoT-embedded-sdk/tree/v1.3.0) + * [AWS IoT Device Defender v1.3.0](https://github.com/aws/Device-Defender-for-AWS-IoT-embedded-sdk/tree/v1.3.0) + * [AWS IoT Jobs v1.3.0](https://github.com/aws/Jobs-for-AWS-IoT-embedded-sdk/tree/v1.3.0) + * [AWS IoT Over-the-air Update v3.4.0](https://github.com/aws/ota-for-aws-iot-embedded-sdk/tree/v3.4.0) -* coreMQTT v2.1.1 -* coreHTTP v3.0.0 -* corePKCS11 v3.5.0 -* coreJSON v3.2.0 -* backoffAlgorithm v1.3.0 -* AWS IoT Device Shadow v1.3.0 -* AWS IoT Device Defender v1.3.0 -* AWS IoT Jobs v1.3.0 -* AWS IoT Over-the-air Update v3.4.0 +- [#5](https://github.com/FreeRTOS/iot-reference-esp32c3/pull/5) and [#10](https://github.com/FreeRTOS/iot-reference-esp32c3/pull/10) Documentation updates ## v202204.00 ( April 2022 ) diff --git a/GettingStartedGuide.md b/GettingStartedGuide.md index d5f9b25..03db442 100644 --- a/GettingStartedGuide.md +++ b/GettingStartedGuide.md @@ -46,7 +46,7 @@ Once completed, one can progress to the [Use Security Features](UseSecurityFeatu ### 1.2 Software Requirements -* ESP-IDF 4.4.2 or higher to configure, build, and flash the project. To setup for the ESP32-C3, follow Espressif's [Getting Started Guide for the ESP32-C3](https://docs.espressif.com/projects/esp-idf/en/latest/esp32c3/get-started/index.html). +* ESP-IDF 4.4.3 or higher to configure, build, and flash the project. To setup for the ESP32-C3, follow Espressif's [Getting Started Guide for the ESP32-C3](https://docs.espressif.com/projects/esp-idf/en/latest/esp32c3/get-started/index.html). * [Python3](https://www.python.org/downloads/) and the Package Installer for Python [pip](https://pip.pypa.io/en/stable/installation/) to use the AWS CLI to import certificates and perform OTA Job set up. Pip is included when you install from Python 3.10. @@ -452,28 +452,32 @@ I (3444) coreMQTT: Packet received. ReceivedBytes=3. I (3444) ota_over_mqtt_demo: Subscribed to topic $aws/things/thing_esp32c3_nonOta/jobs/notify-next. ``` -## 6 Run AWS IoT Qualification Test +## 6 Run FreeRTOS Integration Test ### 6.1 Prerequisite -- Run [OTA](#5-perform-firmware-over-the-air-updates-with-aws-iot) once manually. -- Enable "Run qualification test" by menuconfig (Featured FreeRTOS IoT Integration -> Run qualification test). -- Enable Unity and Unity/Fixture by menuconfig. +- Follow the [OTA update with AWS IoT Guide](#5-perform-firmware-over-the-air-updates-with-aws-iot) to create an OTA update and verify the digital signature, checksum and version number of the new image. If firmware update is verified, you can run the tests on your device. +- Run `idf.py menuconfig`. +- Under `Featured FreeRTOS IoT Integration`, choose `Run qualification test`. +- Under `Component config -> Unity unit testing library`, choose `Include Unity test fixture`. -*Note: The log of module `esp_ota_ops` and `esp-tls-mbedtls` will be disabled when `Run qualification test` is on. You can enable them back by commenting out `esp_log_level_set` in [main.c](./main/main.c).* +*Note: The log of module `esp_ota_ops`, `AWS_OTA` and `esp-tls-mbedtls` will be disabled when running the qualification test. You can change the log level by `esp_log_level_set` in [main.c](./main/main.c).* ### 6.2 Steps for each test case 1. Device Advisor Test - - Enable "Device Advisor Test" in Freatured FreeRTOS IoT Integration -> Qualification Test Configurations -> Qualification Execution Test Configurations by menuconfig. - - Create a [device advisor test](https://docs.aws.amazon.com/iot/latest/developerguide/device-advisor.html) on website. ( Iot Console -> Test -> Device Advisor ) - - Create test suite. - - Run test suite and record device advisor endpoint. - - Set "Endpoint for MQTT Broker to use" (from previous step) and "Thing Name for Device Advisor Test/OTA end-to-end Test" in Freatured FreeRTOS IoT Integration -> Qualification Test Configurations -> Qualification Parameter Configurations by menuconfig. + - Create a [Device Advisor test suite](https://docs.aws.amazon.com/iot/latest/developerguide/device-advisor.html) in the console. + - Find the Device Advisor test endpoint for your account + - Under `Freatured FreeRTOS IoT Integration -> Qualification Test Configurations -> Qualification Execution Test Configurations`, choose `Device Advisor Test`. + - Under `FreeRTOS IoT Integration -> Qualification Test Configurations -> Qualification Parameter Configurations` + - Set `Endpoint for MQTT Broker to use` to Device Avdisor test endpoint + - Set `Thing Name for Device Advisor Test/OTA end-to-end Test` to AWS IoT Thing under test. - Build and run. - - See device advisor test result on website. -1. MQTT Test - - Enable "MQTT Test" in Freatured FreeRTOS IoT Integration -> Qualification Test Configurations -> Qualification Execution Test Configurations by menuconfig. - - Set "Endpoint for MQTT Broker to use" and "Client Identifier for MQTT Test" in Freatured FreeRTOS IoT Integration -> Qualification Test Configurations -> Qualification Parameter Configurations by menuconfig. + - See Device Advisor test result in the console. +2. MQTT Test + - Under `Freatured FreeRTOS IoT Integration -> Qualification Test Configurations -> Qualification Execution Test Configurations`, choose `MQTT Test`. + - Under `FreeRTOS IoT Integration -> Qualification Test Configurations -> Qualification Parameter Configurations` + - Set `Endpoint for MQTT Broker to use` to your AWS IoT endpoint + - Set `Client Identifier for MQTT Test` - Build and run. - See test result on target output. - Example output @@ -481,14 +485,16 @@ I (3444) ota_over_mqtt_demo: Subscribed to topic $aws/things/thing_esp32c3_nonOt I (821) qual_main: Run qualification test. ... ----------------------- - 7 Tests 0 Failures 0 Ignored + 8 Tests 0 Failures 0 Ignored OK I (84381) qual_main: End qualification test. ``` -1. Transport Interface Test - - Enable "Transport Interface Test" in Freatured FreeRTOS IoT Integration -> Qualification Test Configurations -> Qualification Execution Test Configurations by menuconfig. - - Follow [Run The Transport Interface Test](https://github.com/FreeRTOS/FreeRTOS-Libraries-Integration-Tests/tree/main/src/transport_interface#6-run-the-transport-interface-test) to start a echo server. - - Set "Echo Server Domain Name/IP for Transport Interface Test" and "Port for Echo Server to use" in Freatured FreeRTOS IoT Integration -> Qualification Test Configurations -> Qualification Parameter Configurations by menuconfig. +3. Transport Interface Test + - Follow [Run The Transport Interface Test](https://github.com/FreeRTOS/FreeRTOS-Libraries-Integration-Tests/tree/main/src/transport_interface#6-run-the-transport-interface-test) to start an echo server. + - Under `Freatured FreeRTOS IoT Integration -> Qualification Test Configurations -> Qualification Execution Test Configurations`, choose `Transport Interface Test`. + - Under `FreeRTOS IoT Integration -> Qualification Test Configurations -> Qualification Parameter Configurations` + - Set `Echo Server Domain Name/IP for Transport Interface Test` + - Set `Port for Echo Server to use` - Set ECHO_SERVER_ROOT_CA / TRANSPORT_CLIENT_CERTIFICATE and TRANSPORT_CLIENT_PRIVATE_KEY in [test_param_config.h](./components/FreeRTOS-Libraries-Integration-Tests/config/test_param_config.h). - Build and run. - See test result on target output. @@ -501,8 +507,8 @@ I (3444) ota_over_mqtt_demo: Subscribed to topic $aws/things/thing_esp32c3_nonOt OK I (612755) qual_main: End qualification test. ``` -1. OTA PAL Test - - Enable "OTA PAL Test" in Freatured FreeRTOS IoT Integration -> Qualification Test Configurations -> Qualification Execution Test Configurations by menuconfig. +4. OTA PAL Test + - Under `Freatured FreeRTOS IoT Integration -> Qualification Test Configurations -> Qualification Execution Test Configurations`, choose `OTA PAL Test`. - Build and run. - See test result on target output. - Example output @@ -514,8 +520,8 @@ I (3444) ota_over_mqtt_demo: Subscribed to topic $aws/things/thing_esp32c3_nonOt OK I (113755) qual_main: End qualification test. ``` -1. Core PKCS11 Test - - Enable "CorePKCS#11 Test" in Freatured FreeRTOS IoT Integration -> Qualification Test Configurations -> Qualification Execution Test Configurations by menuconfig. +5. Core PKCS11 Test + - Under `Freatured FreeRTOS IoT Integration -> Qualification Test Configurations -> Qualification Execution Test Configurations`, choose `CorePKCS#11 Test`. - Build and run. - See test result on target output. - Example output @@ -535,65 +541,65 @@ This repository can be tested using [AWS IoT Device Tester for FreeRTOS (IDT)](h IDT runs a suite of tests that include testing the device's transport interface layer implementation, PKCS11 functionality, and OTA capabilities. In IDT test cases, the IDT binary will make a copy of the source code, update the header files in the project, then compile the project and flash the resulting image to your board. Finally, IDT will read serial output from the board and communicate with the AWS IoT cloud to ensure that test cases are passing. ### 7.1 Prerequisite -- Run [OTA](#5-perform-firmware-over-the-air-updates-with-aws-iot) once manually. -- Enable "Run qualification test" by menuconfig (Featured FreeRTOS IoT Integration -> Run qualification test). -- Enable Unity and Unity/Fixture by menuconfig. -- Disable all test cases in Freatured FreeRTOS IoT Integration -> Qualification Test Configurations -> Qualification Execution Test Configurations by menuconfig. -- run "idf.py fullclean" to clear local CMAKE cache. +- Follow the [OTA update with AWS IoT Guide](#5-perform-firmware-over-the-air-updates-with-aws-iot) to create an OTA update and verify the digital signature, checksum and version number of the new image. If firmware update is verified, you can run the tests on your device. +- Run `idf.py menuconfig`. +- Under `Featured FreeRTOS IoT Integration`, choose `Run qualification test`. +- Under `Component config -> Unity unit testing library`, choose `Include Unity test fixture`. +- Under `Freatured FreeRTOS IoT Integration -> Qualification Test Configurations -> Qualification Execution Test Configurations`, **DISABLE** all the tests. +- Run `idf.py fullclean` to clear local CMAKE cache. -*Note: The log of module `esp_ota_ops`, `AWS_OTA` and `esp-tls-mbedtls` will be disabled when `Run qualification test` is on. You can enable them back by commenting out `esp_log_level_set` in [main.c](./main/main.c).* +*Note: The log of module `esp_ota_ops`, `AWS_OTA` and `esp-tls-mbedtls` will be disabled when running the qualification test. You can change the log level by `esp_log_level_set` in [main.c](./main/main.c).* ### 7.2 Download AWS IoT Device Tester -The latest version of IDT can be downloaded from the [public documentation page](https://docs.aws.amazon.com/freertos/latest/userguide/dev-test-versions-afr.html). This repository only supports test suites FRQ_2.2.0 or later. +The latest version of IDT can be downloaded from the [here](https://docs.aws.amazon.com/freertos/latest/userguide/dev-test-versions-afr.html). This repository has been qualified by IDT v4.6.0 and test suite version 2.3.0 for FreeRTOS 202210-LTS. ### 7.3 Configure AWS IoT Device Tester -After downloading and unzipping IDT onto your file system, you should extract a file structure that includes the following directories: +Follow [the instructions to setup your AWS account](https://docs.aws.amazon.com/freertos/latest/userguide/lts-idt-dev-tester-prereqs.html#lts-config-aws-account). -* The `bin` directory holds the devicetester binary, which is the entry point used to run IDT -* The `results` directory holds logs that are generated every time you run IDT. -* The `configs` directory holds configuration values that are needed to set up IDT +Extract IDT for FreeRTOS to a location on the file system -Before running IDT, the files in `configs` need to be updated. In this repository, we have pre-defined configs available in the `idt_config` directory. Copy these templates over into IDT, and the rest of this section will walk through the remaining values that need to be filled in. +* The `devicetester-extract-location/bin` directory holds the IDT binary, which is the entry point used to run IDT +* The `devicetester-extract-location/results` directory holds logs that are generated every time you run IDT. +* The `devicetester-extract-location/configs` directory holds configuration files that are required to setup IDT -First, copy one of each file from `idt_config` (based on host OS) in this reference repository to the `configs` directory inside the newly downloaded IDT project. This should provide you with the following files in `device_tester/configs` directory: +Before running IDT, the files in `devicetester-extract-location/configs` need to be updated. We have pre-defined configures available in the [idt_config](https://github.com/FreeRTOS/iot-reference-esp32c3/tree/main/idt_config). Copy these templates to `devicetester-extract-location/configs`, and the rest of this section will walk through the remaining values that need to be filled in. -``` -configs/dummyPublicKeyAsciiHex.txt -configs/flash.bat or flash.sh -configs/config.json -configs/userdata.json -configs/device.json -configs/build.bat or build.sh -``` +You need to configure your AWS credentials for IDT. +* In `config.json`, update the `profile` and `awsRegion` fields -Next, we need to update some configuration values in these files. +You need to specify the device details for IDT. +* In `device.json`, update `serialPort` to the serial port of your board as from [PORT](./GettingStartedGuide.md#23-provision-the-esp32-c3-with-the-private-key-device-certificate-and-ca-certificate-in-development-mode). Update `publicKeyAsciiHexFilePath` to the absolute path to `dummyPublicKeyAsciiHex.txt`. Update `publicDeviceCertificateArn` to the ARN of the certificate uploaded when [Setup AWS IoT Core](./GettingStartedGuide.md#21-setup-aws-iot-core). +You need to configure IDT the build, flash and test settings. * In `build.bat` / `build.sh`, update ESP_IDF_PATH, and ESP_IDF_FRAMEWORK_PATH * In `flash.bat` / `flash.sh`, update ESP_IDF_PATH, ESP_IDF_FRAMEWORK_PATH, and NUM_COMPORT - -* In `config.json`, update the `profile` and `awsRegion` fields -* In `device.json`, update `serialPort` to the serial port of your board as from [PORT](./GettingStartedGuide.md#23-provision-the-esp32-c3-with-the-private-key-device-certificate-and-ca-certificate-in-development-mode). Update `publicKeyAsciiHexFilePath` to the absolute path to `dummyPublicKeyAsciiHex.txt`. Update `publicDeviceCertificateArn` to the ARN of the certificate uploaded when [Setup AWS IoT Core](./GettingStartedGuide.md#21-setup-aws-iot-core). * In `userdata.json`, update `sourcePath` to the absolute path to the root of this repository. * In `userdata.json`, update `signerCertificate` with the ARN of the [Setup pre-requisites for OTA cloud resources .](./GettingStartedGuide.md#51-setup-pre-requisites-for-ota-cloud-resources) * Run all the steps to create a [second code signing certificate](./GettingStartedGuide.md#51-setup-pre-requisites-for-ota-cloud-resources) but do NOT provision the key onto your board. Copy the ARN for this certificate in `userdata.json` for the field `untrustedSignerCertificate`. -### 7.4 Running AWS IoT Device Tester +### 7.4 Running the FreeRTOS qualification 2.0 suite With configuration complete, IDT can be run for an individual test group, a test case, or the entire qualification suite. -To list the available test groups, run: +List all the available test groups, run: ``` .\devicetester_win_x86-64.exe list-groups ``` -To run any one test group, run e.g.: +Run one or more specified test group, run e.g.: + +``` +.\devicetester_win_x86-64.exe run-suite --group-id FullCloudIoT --group-id OTACore +``` + +Run one or more specified tests, run e.g.: ``` -.\devicetester_win_x86-64.exe run-suite -g FullCloudIoT -g OTACore +.\devicetester_win_x86-64.exe run-suite --group-id OTADataplaneMQTT --test-id OTAE2EGreaterVersion ``` To run the entire qualification suite, run: @@ -604,4 +610,4 @@ To run the entire qualification suite, run: For more information, `.\devicetester_win_x86-64.exe help` will show all available commands. -When IDT is run, it generates the `results/uuid` directory that contains the logs and other information associated with your test run, allowing failures to easily be debugged. \ No newline at end of file +When IDT is run, it generates the `results/uuid` directory that contains the logs and other information associated with your test run. See [Understanding results and logs](https://docs.aws.amazon.com/freertos/latest/userguide/lts-results-logs.html) for more details. \ No newline at end of file