diff --git a/.gitmodules b/.gitmodules index 74cb8c3..8ac0b83 100644 --- a/.gitmodules +++ b/.gitmodules @@ -48,4 +48,4 @@ url = https://github.com/ThrowTheSwitch/Unity.git [submodule "Middleware/FreeRTOS/tests"] path = Middleware/FreeRTOS/tests - url = https://github.com/FreeRTOS/Labs-FreeRTOS-Libraries-Integration-Tests.git + url = https://github.com/FreeRTOS/FreeRTOS-Libraries-Integration-Tests.git diff --git a/GSG.md b/GSG.md index 9e22f98..ba101d4 100644 --- a/GSG.md +++ b/GSG.md @@ -41,7 +41,12 @@ Many of these steps are automated in production environments. [7 Run the Shadow Demo](#7-run-the-shadow-demo)
[8 Run the Defender Demo](#8-run-the-defender-demo)
-[9 Troubleshooting Guide](#9-troubleshooting-guide) +[9 Troubleshooting Guide](#9-troubleshooting-guide)
+[10 Run AWS IoT Device Tester](#10-run-aws-iot-device-tester)
+    [10.1 Download AWS IoT Device Tester](#101-download-aws-iot-device-tester)
+    [10.2 Configure AWS IoT Device Tester](#102-configure-aws-iot-device-tester)
+    [10.3 Configure Divice](#103-configure-device)
+    [10.4 Running AWS IoT Device Tester](#104-running-aws-iot-device-tester)
## 1 Prerequisites @@ -764,11 +769,11 @@ 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 `examples/evkbmimxrt1060/test` 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. -### Download AWS IoT Device Tester +### 10.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 of version 2.0 or later. -### Configure AWS IoT Device Tester +### 10.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: @@ -781,7 +786,6 @@ Before we can run IDT, we have to update the files in `configs`. In this referen 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 @@ -797,14 +801,47 @@ Next, we need to update some configuration values in these files. A few notes on the provided build and flash scripts: First, if you run into issues with the provided scripts, you can copy commands provided by the MCUXpresso IDE during a GUI build and flash to create your own build and flash scripts. Second, these scripts only work if your `test` and `bootloader` project have been built once using the MCUXpresso GUI (this creates a required files `MIMXRT1062xxxxA.xml` and `MIMXRT1062xxxxA_part.xml` at `iot-reference-nxp-rt1060/projects/evkmimxrt1060/$PROJECT/Debug`) * In `config.json`, update the `profile` and `awsRegion` fields -* In `device.json`, update `serialPort` to the serial port of your board as from [section 2.1](https://github.com/FreeRTOS/iot-reference-nxp-rt1060/blob/main/GSG.md#21-setting-up-device). Update `publicKeyAsciiHexFilePath` to the absolute path to `dummyPublicKeyAsciiHex.txt`. Update `publicDeviceCertificateArn` to the ARN of the certificate uploaded when [provisioning the device](https://github.com/FreeRTOS/iot-reference-nxp-rt1060/blob/main/GSG.md#41-provisioning-the-device). +* In `device.json`, update `serialPort` to the serial port of your board as from [section 2.1](https://github.com/FreeRTOS/iot-reference-nxp-rt1060/blob/main/GSG.md#21-setting-up-device). Update `publicDeviceCertificateArn` to the ARN of the certificate uploaded when [provisioning the device](https://github.com/FreeRTOS/iot-reference-nxp-rt1060/blob/main/GSG.md#41-provisioning-the-device). * 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 [application code signing certificate you created.](https://github.com/FreeRTOS/iot-reference-nxp-rt1060/blob/main/GSG.md#62-creating-an-application-code-signing-certificate) * Run all the steps to create a [second code signing certificate](https://github.com/FreeRTOS/iot-reference-nxp-rt1060/blob/main/GSG.md#62-creating-an-application-code-signing-certificate) but do NOT provision the key onto your board. Copy the ARN for this certificate in `userdata.json` for the field `untrustedSignerCertificate`. -### 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. +### 10.3 Configure Device + +To run test cases "OTADataplaneMQTT" / OTACore / FullPKCS11_PreProvisioned_ECC successfully, we need to set our public keys manually once. + +- OTADataplaneMQTT + - Follow [6.2 Creating an Application Code Signing Certificate](#62-creating-an-application-code-signing-certificate) to set code signing certificate. +- OTACore + - Set appmainPROVISIONING_MODE to 1 and appmainRUN_QUALIFICATIOn_TEST_SUITE to 0 in app_main.c + - Build and flash + - In TeraTerm or putty, `pki set pub_key sss:00223346` + - Copy and paste below content to the serial port + ``` + -----BEGIN PUBLIC KEY----- + MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEyza/tGLVbVxhL41iYtC8D6tGEvAH + u498gNtqDtPsKaoR3t5xQx+6zdWiCi32fgFT2vkeVAmX3pf/Gl8nIP48Zg== + -----END PUBLIC KEY----- + ``` + - Should print “OK” +- FullPKCS11_PreProvisioned_ECC + - Set appmainPROVISIONING_MODE to 1 and appmainRUN_QUALIFICATION_TEST_SUITE to 0 in app_main.c + - Build and flash + - Get the cert at the label in Teraterm + ``` + pki get cert sss:F0000001 + ``` + - Paste that cert into a file cert.pem + - Run command `openssl x509 -pubkey -noout -in cert.pem > pubkey.pem` + - In TeraTerm or putty, `pki set pub_key sss:00223345` + - Paste the content of pubkey.pem to TeraTerm or putty + - Should print “OK” + +*Note: If you fail at setting public key, try sss:00223343 and remember to change the config.* + +### 10.4 Running AWS IoT Device Tester + +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: @@ -826,4 +863,6 @@ 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 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. + +*Note: Please run qualification test without provision mode (set appmainPROVISIONING_MODE to 0 in [app_main.c](./examples/evkbmimxrt1060/test/app_main.c)).* \ No newline at end of file diff --git a/Middleware/AWS/device-defender b/Middleware/AWS/device-defender index a12bbaf..9896700 160000 --- a/Middleware/AWS/device-defender +++ b/Middleware/AWS/device-defender @@ -1 +1 @@ -Subproject commit a12bbaf13920e83a4252b1cf992e1d6a5b0c9939 +Subproject commit 989670043d46dc104477957cdc0ce263218dae0a diff --git a/Middleware/AWS/device-shadow b/Middleware/AWS/device-shadow index 92327cd..250821f 160000 --- a/Middleware/AWS/device-shadow +++ b/Middleware/AWS/device-shadow @@ -1 +1 @@ -Subproject commit 92327cd715ddbab04f1d88837f7bc66010b2dfa5 +Subproject commit 250821f043d2d080547270b43f01d53c7d52640a diff --git a/Middleware/AWS/ota b/Middleware/AWS/ota index 1f2362f..f976089 160000 --- a/Middleware/AWS/ota +++ b/Middleware/AWS/ota @@ -1 +1 @@ -Subproject commit 1f2362f005f39a1847d645660ecaff93890cfcd7 +Subproject commit f9760892ba152f2c9104d08192ea5ffbbf9fa8ea diff --git a/Middleware/FreeRTOS/backoffAlgorithm b/Middleware/FreeRTOS/backoffAlgorithm index 6343da9..8818bed 160000 --- a/Middleware/FreeRTOS/backoffAlgorithm +++ b/Middleware/FreeRTOS/backoffAlgorithm @@ -1 +1 @@ -Subproject commit 6343da924adee67b315ce7f8ace2fb2ff5f05a29 +Subproject commit 8818bed40e57215fda8efa4b7fd33f7ae2c80d65 diff --git a/Middleware/FreeRTOS/coreJSON b/Middleware/FreeRTOS/coreJSON index caf540c..5b31f4c 160000 --- a/Middleware/FreeRTOS/coreJSON +++ b/Middleware/FreeRTOS/coreJSON @@ -1 +1 @@ -Subproject commit caf540ccdb98e8f96a6f557075cb607288384938 +Subproject commit 5b31f4c37a034911a4992fd415f8177a75014946 diff --git a/Middleware/FreeRTOS/coreMQTT b/Middleware/FreeRTOS/coreMQTT index 51c8067..5cfd781 160000 --- a/Middleware/FreeRTOS/coreMQTT +++ b/Middleware/FreeRTOS/coreMQTT @@ -1 +1 @@ -Subproject commit 51c8067bffbe73eaff2b666104293e46bdb103e6 +Subproject commit 5cfd781f94ed4d34a5d533abbff952fc23b86db5 diff --git a/Middleware/FreeRTOS/coreMQTT-Agent b/Middleware/FreeRTOS/coreMQTT-Agent index 0185515..86c51db 160000 --- a/Middleware/FreeRTOS/coreMQTT-Agent +++ b/Middleware/FreeRTOS/coreMQTT-Agent @@ -1 +1 @@ -Subproject commit 0185515bafd3002df9e9b8cf0b211baaae69f20b +Subproject commit 86c51db1a7d060744a06fa3619bd3ba86a938a94 diff --git a/Middleware/FreeRTOS/corePKCS11 b/Middleware/FreeRTOS/corePKCS11 index d6a5191..781f577 160000 --- a/Middleware/FreeRTOS/corePKCS11 +++ b/Middleware/FreeRTOS/corePKCS11 @@ -1 +1 @@ -Subproject commit d6a519146598ec2ccd6f0230a01fca876767a8fe +Subproject commit 781f5774948fa8e6427be544b1bf1ad512ae9e90 diff --git a/Middleware/FreeRTOS/kernel b/Middleware/FreeRTOS/kernel index 1e08439..6f63da2 160000 --- a/Middleware/FreeRTOS/kernel +++ b/Middleware/FreeRTOS/kernel @@ -1 +1 @@ -Subproject commit 1e0843929477c8f2e2679b70d18341ee312a5fce +Subproject commit 6f63da20b3c9e1408e7c8007d3427b75878cbd64 diff --git a/Middleware/FreeRTOS/tests b/Middleware/FreeRTOS/tests index 7b531a2..b5f0df5 160000 --- a/Middleware/FreeRTOS/tests +++ b/Middleware/FreeRTOS/tests @@ -1 +1 @@ -Subproject commit 7b531a24eb3d1f5e9fdd23ca0f3c57d7f24c875f +Subproject commit b5f0df5544bd36e49a4630466039777a61538656 diff --git a/examples/common/mqtt_agent/mqtt_agent_task.c b/examples/common/mqtt_agent/mqtt_agent_task.c index 196b61e..2bb409e 100644 --- a/examples/common/mqtt_agent/mqtt_agent_task.c +++ b/examples/common/mqtt_agent/mqtt_agent_task.c @@ -83,7 +83,7 @@ #include "using_mbedtls.h" /* Keystore APIs to fetch configuration data. */ -#include "kvStore.h" +#include "kvstore.h" /* Includes MQTT Agent Task management APIs. */ #include "mqtt_agent_task.h" @@ -373,7 +373,7 @@ static char * pcDeviceCertID = NULL; static MQTTStatus_t prvMQTTInit( void ) { - TransportInterface_t xTransport; + TransportInterface_t xTransport = { 0 }; MQTTStatus_t xReturn; MQTTFixedBuffer_t xFixedBuffer = { .pBuffer = xNetworkBuffer, .size = MQTT_AGENT_NETWORK_BUFFER_SIZE }; static uint8_t staticQueueStorageArea[ MQTT_AGENT_COMMAND_QUEUE_LENGTH * sizeof( MQTTAgentCommand_t * ) ]; diff --git a/examples/evkbmimxrt1060/defender/include/FreeRTOSConfig.h b/examples/evkbmimxrt1060/defender/include/FreeRTOSConfig.h index 71309bb..2629dd3 100644 --- a/examples/evkbmimxrt1060/defender/include/FreeRTOSConfig.h +++ b/examples/evkbmimxrt1060/defender/include/FreeRTOSConfig.h @@ -58,7 +58,7 @@ extern void vLoggingPrintf( const char * pcFormat, #define configUSE_DAEMON_TASK_STARTUP_HOOK 1 #define configCPU_CLOCK_HZ ( SystemCoreClock ) #define configTICK_RATE_HZ ( ( TickType_t ) 1000 ) -#define configMAX_PRIORITIES ( 7 ) +#define configMAX_PRIORITIES ( 9 ) #define configMINIMAL_STACK_SIZE ( ( uint16_t ) 90 ) #define configTOTAL_HEAP_SIZE ( ( size_t ) ( 160 * 1024 ) ) /* 160 Kbytes. */ #define configMAX_TASK_NAME_LEN ( 16 ) diff --git a/examples/evkbmimxrt1060/defender/include/core_mqtt_agent_config.h b/examples/evkbmimxrt1060/defender/include/core_mqtt_agent_config.h new file mode 100644 index 0000000..01d6f84 --- /dev/null +++ b/examples/evkbmimxrt1060/defender/include/core_mqtt_agent_config.h @@ -0,0 +1,2 @@ +/* An empty config file for the CBMC proofs to compile with the default + * definitions of configuration macros. */ diff --git a/examples/evkbmimxrt1060/defender/main.c b/examples/evkbmimxrt1060/defender/main.c index cbf30cd..09c0024 100644 --- a/examples/evkbmimxrt1060/defender/main.c +++ b/examples/evkbmimxrt1060/defender/main.c @@ -51,7 +51,7 @@ #include "ksdk_mbedtls.h" -#include "nxlog_App.h" +#include "nxLog_App.h" #include "mflash_drv.h" #include "ex_sss_boot.h" diff --git a/examples/evkbmimxrt1060/pubsub/include/FreeRTOSConfig.h b/examples/evkbmimxrt1060/pubsub/include/FreeRTOSConfig.h index 71309bb..2629dd3 100644 --- a/examples/evkbmimxrt1060/pubsub/include/FreeRTOSConfig.h +++ b/examples/evkbmimxrt1060/pubsub/include/FreeRTOSConfig.h @@ -58,7 +58,7 @@ extern void vLoggingPrintf( const char * pcFormat, #define configUSE_DAEMON_TASK_STARTUP_HOOK 1 #define configCPU_CLOCK_HZ ( SystemCoreClock ) #define configTICK_RATE_HZ ( ( TickType_t ) 1000 ) -#define configMAX_PRIORITIES ( 7 ) +#define configMAX_PRIORITIES ( 9 ) #define configMINIMAL_STACK_SIZE ( ( uint16_t ) 90 ) #define configTOTAL_HEAP_SIZE ( ( size_t ) ( 160 * 1024 ) ) /* 160 Kbytes. */ #define configMAX_TASK_NAME_LEN ( 16 ) diff --git a/examples/evkbmimxrt1060/pubsub/include/core_mqtt_agent_config.h b/examples/evkbmimxrt1060/pubsub/include/core_mqtt_agent_config.h new file mode 100644 index 0000000..01d6f84 --- /dev/null +++ b/examples/evkbmimxrt1060/pubsub/include/core_mqtt_agent_config.h @@ -0,0 +1,2 @@ +/* An empty config file for the CBMC proofs to compile with the default + * definitions of configuration macros. */ diff --git a/examples/evkbmimxrt1060/pubsub/main.c b/examples/evkbmimxrt1060/pubsub/main.c index cbf30cd..eabd49f 100644 --- a/examples/evkbmimxrt1060/pubsub/main.c +++ b/examples/evkbmimxrt1060/pubsub/main.c @@ -51,7 +51,7 @@ #include "ksdk_mbedtls.h" -#include "nxlog_App.h" +#include "nxLog_App.h" #include "mflash_drv.h" #include "ex_sss_boot.h" @@ -70,7 +70,7 @@ /* MAC address configuration. */ #define configMAC_ADDR \ { \ - 0x02, 0x12, 0x13, 0x10, 0x15, 0x25 \ + 0x00, 0x11, 0x22, 0x33, 0x44, 0x41 \ } /* Address of PHY interface. */ diff --git a/examples/evkbmimxrt1060/shadow/include/FreeRTOSConfig.h b/examples/evkbmimxrt1060/shadow/include/FreeRTOSConfig.h index 71309bb..2629dd3 100644 --- a/examples/evkbmimxrt1060/shadow/include/FreeRTOSConfig.h +++ b/examples/evkbmimxrt1060/shadow/include/FreeRTOSConfig.h @@ -58,7 +58,7 @@ extern void vLoggingPrintf( const char * pcFormat, #define configUSE_DAEMON_TASK_STARTUP_HOOK 1 #define configCPU_CLOCK_HZ ( SystemCoreClock ) #define configTICK_RATE_HZ ( ( TickType_t ) 1000 ) -#define configMAX_PRIORITIES ( 7 ) +#define configMAX_PRIORITIES ( 9 ) #define configMINIMAL_STACK_SIZE ( ( uint16_t ) 90 ) #define configTOTAL_HEAP_SIZE ( ( size_t ) ( 160 * 1024 ) ) /* 160 Kbytes. */ #define configMAX_TASK_NAME_LEN ( 16 ) diff --git a/examples/evkbmimxrt1060/shadow/include/core_mqtt_agent_config.h b/examples/evkbmimxrt1060/shadow/include/core_mqtt_agent_config.h new file mode 100644 index 0000000..01d6f84 --- /dev/null +++ b/examples/evkbmimxrt1060/shadow/include/core_mqtt_agent_config.h @@ -0,0 +1,2 @@ +/* An empty config file for the CBMC proofs to compile with the default + * definitions of configuration macros. */ diff --git a/examples/evkbmimxrt1060/shadow/main.c b/examples/evkbmimxrt1060/shadow/main.c index cbf30cd..09c0024 100644 --- a/examples/evkbmimxrt1060/shadow/main.c +++ b/examples/evkbmimxrt1060/shadow/main.c @@ -51,7 +51,7 @@ #include "ksdk_mbedtls.h" -#include "nxlog_App.h" +#include "nxLog_App.h" #include "mflash_drv.h" #include "ex_sss_boot.h" diff --git a/examples/evkbmimxrt1060/shadow/shadow_device_task.c b/examples/evkbmimxrt1060/shadow/shadow_device_task.c index d18b04b..40e26b2 100644 --- a/examples/evkbmimxrt1060/shadow/shadow_device_task.c +++ b/examples/evkbmimxrt1060/shadow/shadow_device_task.c @@ -148,7 +148,7 @@ * functions. shadowexampleMS_TO_WAIT_FOR_NOTIFICATION defines the time, in ticks, * to wait for such a callback. */ -#define shadowexampleMS_TO_WAIT_FOR_NOTIFICATION ( 5000 ) +#define shadowexampleMS_TO_WAIT_FOR_NOTIFICATION ( 15000 ) /** * @brief The maximum amount of time in milliseconds to wait for the commands diff --git a/examples/evkbmimxrt1060/shadow/shadow_update_task.c b/examples/evkbmimxrt1060/shadow/shadow_update_task.c index 8497fa1..52cf158 100644 --- a/examples/evkbmimxrt1060/shadow/shadow_update_task.c +++ b/examples/evkbmimxrt1060/shadow/shadow_update_task.c @@ -147,7 +147,7 @@ * functions. shadowexampleMS_TO_WAIT_FOR_NOTIFICATION defines the time, in ticks, * to wait for such a callback. */ -#define shadowexampleMS_TO_WAIT_FOR_NOTIFICATION ( 5000 ) +#define shadowexampleMS_TO_WAIT_FOR_NOTIFICATION ( 15000 ) /** * @brief The maximum amount of time in milliseconds to wait for the commands diff --git a/examples/evkbmimxrt1060/test/app_main.c b/examples/evkbmimxrt1060/test/app_main.c index 9e9b4ef..6c3ddb7 100644 --- a/examples/evkbmimxrt1060/test/app_main.c +++ b/examples/evkbmimxrt1060/test/app_main.c @@ -94,6 +94,32 @@ int RunDeviceAdvisorDemo( void ) return ( xResult == pdPASS ) ? 0 : -1; } +int RunOtaE2eDemo( void ) +{ + BaseType_t xResult = pdFAIL; + + if( xGetMQTTAgentState() < MQTT_AGENT_STATE_INITIALIZED ) + { + xResult = xMQTTAgentInit( appmainMQTT_AGENT_TASK_STACK_SIZE, appmainMQTT_AGENT_TASK_PRIORITY ); + } + else + { + xResult = pdPASS; + } + + if( xResult == pdPASS ) + { + xResult = xTaskCreate( vOTAUpdateTask, + "OTA", + appmainMQTT_OTA_UPDATE_TASK_STACK_SIZE, + NULL, + appmainMQTT_OTA_UPDATE_TASK_PRIORITY, + NULL ); + } + + return ( xResult == pdPASS ) ? 0 : -1; +} + int app_main( void ) { BaseType_t xResult = pdFAIL; @@ -119,25 +145,6 @@ int app_main( void ) } #endif /* if ( appmainPROVISIONING_MODE == 1 ) */ -#if ( OTA_E2E_TEST_ENABLED == 1 ) - { - if( xResult == pdPASS ) - { - xResult = xMQTTAgentInit( appmainMQTT_AGENT_TASK_STACK_SIZE, appmainMQTT_AGENT_TASK_PRIORITY ); - } - - if( xResult == pdPASS ) - { - xResult = xTaskCreate( vOTAUpdateTask, - "OTA", - appmainMQTT_OTA_UPDATE_TASK_STACK_SIZE, - NULL, - appmainMQTT_OTA_UPDATE_TASK_PRIORITY, - NULL ); - } - } -#endif /* if ( OTA_E2E_TEST_ENABLED == 1 ) */ - { if( xResult == pdPASS ) { diff --git a/examples/evkbmimxrt1060/test/include/FreeRTOSConfig.h b/examples/evkbmimxrt1060/test/include/FreeRTOSConfig.h index 71309bb..2629dd3 100644 --- a/examples/evkbmimxrt1060/test/include/FreeRTOSConfig.h +++ b/examples/evkbmimxrt1060/test/include/FreeRTOSConfig.h @@ -58,7 +58,7 @@ extern void vLoggingPrintf( const char * pcFormat, #define configUSE_DAEMON_TASK_STARTUP_HOOK 1 #define configCPU_CLOCK_HZ ( SystemCoreClock ) #define configTICK_RATE_HZ ( ( TickType_t ) 1000 ) -#define configMAX_PRIORITIES ( 7 ) +#define configMAX_PRIORITIES ( 9 ) #define configMINIMAL_STACK_SIZE ( ( uint16_t ) 90 ) #define configTOTAL_HEAP_SIZE ( ( size_t ) ( 160 * 1024 ) ) /* 160 Kbytes. */ #define configMAX_TASK_NAME_LEN ( 16 ) diff --git a/examples/evkbmimxrt1060/test/include/core_mqtt_agent_config.h b/examples/evkbmimxrt1060/test/include/core_mqtt_agent_config.h new file mode 100644 index 0000000..01d6f84 --- /dev/null +++ b/examples/evkbmimxrt1060/test/include/core_mqtt_agent_config.h @@ -0,0 +1,2 @@ +/* An empty config file for the CBMC proofs to compile with the default + * definitions of configuration macros. */ diff --git a/examples/evkbmimxrt1060/test/include/test_execution_config.h b/examples/evkbmimxrt1060/test/include/test_execution_config.h index 9cbee8a..54550e7 100644 --- a/examples/evkbmimxrt1060/test/include/test_execution_config.h +++ b/examples/evkbmimxrt1060/test/include/test_execution_config.h @@ -40,6 +40,7 @@ * * #define MQTT_TEST_ENABLED (0) */ +#define MQTT_TEST_ENABLED ( 0 ) /** * @brief Configuration to enable the transport interface test. diff --git a/examples/evkbmimxrt1060/test/include/test_param_config.h b/examples/evkbmimxrt1060/test/include/test_param_config.h index 8d3d9db..ae0a8a3 100644 --- a/examples/evkbmimxrt1060/test/include/test_param_config.h +++ b/examples/evkbmimxrt1060/test/include/test_param_config.h @@ -52,12 +52,29 @@ */ #define MQTT_SERVER_PORT ( 8883 ) +/** + * @brief The MQTT client identifier used in MQTT test. Each client identifier + * must be unique; so edit as required to ensure that no two clients connecting to + * the same broker use the same client identifier. + * + * #define MQTT_TEST_CLIENT_IDENTIFIER "insert here." + */ + +/** + * @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 ) + */ +#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. * @@ -141,17 +158,25 @@ */ #define OTA_PAL_USE_FILE_SYSTEM 0 +/** + * @brief The IoT Thing name for the device for OTA test and MQTT test. + * + * #define IOT_THING_NAME "PLACE_HOLDER" + */ +#define IOT_THING_NAME "PLACE_HOLDER" + /** * @brief 1 if using PKCS #11 to access the code sign certificate from NVM. */ #define OTA_PAL_READ_CERTIFICATE_FROM_NVM_WITH_PKCS11 0 -#define IOT_THING_NAME "PLACE_HOLDER" - #define OTA_APP_VERSION_MAJOR 0 #define OTA_APP_VERSION_MINOR 9 #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/examples/evkbmimxrt1060/test/integration_test.c b/examples/evkbmimxrt1060/test/integration_test.c index 13593c4..c4658ef 100644 --- a/examples/evkbmimxrt1060/test/integration_test.c +++ b/examples/evkbmimxrt1060/test/integration_test.c @@ -33,12 +33,16 @@ #include "qualification_test.h" #include "transport_interface_test.h" #include "ota_pal_test.h" +#include "mqtt_test.h" +#include "demo_config.h" #include "using_mbedtls.h" #include "mflash_drv.h" /* FreeRTOS includes. */ #include "FreeRTOS.h" #include "task.h" #include "semphr.h" +#include "fsl_common.h" +#include "fsl_trng.h" /** @@ -46,12 +50,29 @@ */ #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 ) + static NetworkCredentials_t xNetworkCredentials = { 0 }; static TransportInterface_t xTransport = { 0 }; static NetworkContext_t xNetworkContext = { 0 }; static NetworkContext_t xSecondNetworkContext = { 0 }; +/** + * @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; + +/* Function declaration. */ +uint32_t MqttTestGetTimeMs( void ); + static NetworkConnectStatus_t prvTransportNetworkConnect( void * pvNetworkContext, TestHostInfo_t * pxHostInfo, void * pvNetworkCredentials ) @@ -98,6 +119,39 @@ static void ThreadWrapper( void * pParam ) vTaskDelete( NULL ); } +/*-----------------------------------------------------------*/ + +int FRTest_GenerateRandInt() +{ + static bool first = true; + trng_config_t trngConfig; + int ret = 0; + + if( first ) + { + if( TRNG_GetDefaultConfig( &trngConfig ) != kStatus_Success ) + { + PRINTF( "TRNG_GetDefaultConfig fail.\n" ); + return( 0 ); + } + + /* Initialize TRNG */ + if( TRNG_Init( TRNG, &trngConfig ) != kStatus_Success ) + { + PRINTF( "TRNG_Init fail.\n" ); + return( 0 ); + } + + first = false; + } + + if( TRNG_GetRandomData( TRNG, &ret, sizeof( ret ) ) != kStatus_Success ) + { + PRINTF( "TRNG_GetRandomData fail.\n" ); + } + + return ret; +} /*-----------------------------------------------------------*/ @@ -182,6 +236,61 @@ void FRTest_MemoryFree( void * ptr ) { return vPortFree( ptr ); } +/*-----------------------------------------------------------*/ + +uint32_t FRTest_GetTimeMs() +{ + return MqttTestGetTimeMs(); +} +/*-----------------------------------------------------------*/ + +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 = TLS_FreeRTOS_Send; + xTransport.recv = TLS_FreeRTOS_Recv; + + xNetworkCredentials.pRootCa = ( unsigned char * ) democonfigROOT_CA_PEM; + xNetworkCredentials.rootCaSize = sizeof( democonfigROOT_CA_PEM ); + xNetworkCredentials.pClientCertLabel = pkcs11configLABEL_DEVICE_CERTIFICATE_FOR_TLS; + xNetworkCredentials.pPrivateKeyLabel = pkcs11configLABEL_DEVICE_PRIVATE_KEY_FOR_TLS; + xNetworkCredentials.disableSni = pdFALSE; + + pTestParam->pTransport = &xTransport; + pTestParam->pNetworkContext = &xNetworkContext; + pTestParam->pSecondNetworkContext = &xSecondNetworkContext; + pTestParam->pNetworkConnect = prvTransportNetworkConnect; + pTestParam->pNetworkDisconnect = prvTransportNetworkDisconnect; + pTestParam->pNetworkCredentials = &xNetworkCredentials; + pTestParam->pGetTimeMs = MqttTestGetTimeMs; +} +#endif /* TRANSPORT_INTERFACE_TEST_ENABLED == 1 */ +/*-----------------------------------------------------------*/ #if ( TRANSPORT_INTERFACE_TEST_ENABLED == 1 ) void SetupTransportTestParam( TransportTestParam_t * pTestParam ) diff --git a/examples/evkbmimxrt1060/test/main.c b/examples/evkbmimxrt1060/test/main.c index cbf30cd..09c0024 100644 --- a/examples/evkbmimxrt1060/test/main.c +++ b/examples/evkbmimxrt1060/test/main.c @@ -51,7 +51,7 @@ #include "ksdk_mbedtls.h" -#include "nxlog_App.h" +#include "nxLog_App.h" #include "mflash_drv.h" #include "ex_sss_boot.h" diff --git a/idt_config/linux/device.json b/idt_config/linux/device.json index 157b9b5..4cbe017 100644 --- a/idt_config/linux/device.json +++ b/idt_config/linux/device.json @@ -57,4 +57,4 @@ } ] } -] \ No newline at end of file +] diff --git a/idt_config/linux/userdata.json b/idt_config/linux/userdata.json index 177ba8e..252cb92 100644 --- a/idt_config/linux/userdata.json +++ b/idt_config/linux/userdata.json @@ -2,7 +2,7 @@ "sourcePath": "", "freeRTOSTestParamConfigPath": "{{testData.sourcePath}}/examples/evkbmimxrt1060/test/include/test_param_config.h", "freeRTOSTestExecutionConfigPath": "{{testData.sourcePath}}/examples/evkbmimxrt1060/test/include/test_execution_config.h", - "freeRTOSVersion": "202012.04-LTS", + "freeRTOSVersion": "202210.00-LTS", "buildTool": { "name": "nxp-build", "version": "1.0.0", @@ -26,13 +26,9 @@ "serverPort": 9000 }, "otaConfiguration": { - "otaPALCertificateFile": "sss:00223346", - "otaPALFirmwareFileName": "dummy.bin", - "otaPALUseFileSystem": "No", - "otaE2EDemoFilePath": "{{userData.sourcePath}}/examples/evkbmimxrt1060/test", - "otaE2EDemoConfigFilePath": "{{testData.sourcePath}}/examples/evkbmimxrt1060/test/include/test_param_config.h", - "otaE2EFirmwareFilePath":"{{testData.sourcePath}}/projects/evkmimxrt1060/test/Debug/aws_iot_qual_test_signed_OTA.bin", - "otaE2EDeviceFirmwareFileName":"NA", + "otaPALCertificatePath": "sss:00223346", + "otaE2EFirmwarePath":"{{testData.sourcePath}}/projects/evkmimxrt1060/test/Debug/aws_iot_qual_test_signed_OTA.bin", + "deviceFirmwarePath":"NA", "codeSigningConfiguration": { "signingMethod": "AWS", "signerHashingAlgorithm": "SHA256", @@ -47,9 +43,6 @@ "pkcs11LabelConfiguration":{ "pkcs11LabelPreProvisionedECDevicePrivateKeyForTLS": "\"sss:F0000000\"", "pkcs11LabelPreProvisionedECDevicePublicKeyForTLS": "\"sss:00223345\"", - "pkcs11LabelPreProvisionedECDeviceCertificateForTLS": "\"sss:F0000001\"", - "pkcs11LabelCodeVerifyKey": "\"sss:00223344\"", - "pkcs11LabelJITPCertificate": "\"sss:20181004\"", - "pkcs11LabelRootCertificate": "\"sss:20181002\"" + "pkcs11LabelPreProvisionedECDeviceCertificateForTLS": "\"sss:F0000001\"" } } \ No newline at end of file diff --git a/idt_config/mac/device.json b/idt_config/mac/device.json index 157b9b5..4cbe017 100644 --- a/idt_config/mac/device.json +++ b/idt_config/mac/device.json @@ -57,4 +57,4 @@ } ] } -] \ No newline at end of file +] diff --git a/idt_config/mac/userdata.json b/idt_config/mac/userdata.json index 177ba8e..252cb92 100644 --- a/idt_config/mac/userdata.json +++ b/idt_config/mac/userdata.json @@ -2,7 +2,7 @@ "sourcePath": "", "freeRTOSTestParamConfigPath": "{{testData.sourcePath}}/examples/evkbmimxrt1060/test/include/test_param_config.h", "freeRTOSTestExecutionConfigPath": "{{testData.sourcePath}}/examples/evkbmimxrt1060/test/include/test_execution_config.h", - "freeRTOSVersion": "202012.04-LTS", + "freeRTOSVersion": "202210.00-LTS", "buildTool": { "name": "nxp-build", "version": "1.0.0", @@ -26,13 +26,9 @@ "serverPort": 9000 }, "otaConfiguration": { - "otaPALCertificateFile": "sss:00223346", - "otaPALFirmwareFileName": "dummy.bin", - "otaPALUseFileSystem": "No", - "otaE2EDemoFilePath": "{{userData.sourcePath}}/examples/evkbmimxrt1060/test", - "otaE2EDemoConfigFilePath": "{{testData.sourcePath}}/examples/evkbmimxrt1060/test/include/test_param_config.h", - "otaE2EFirmwareFilePath":"{{testData.sourcePath}}/projects/evkmimxrt1060/test/Debug/aws_iot_qual_test_signed_OTA.bin", - "otaE2EDeviceFirmwareFileName":"NA", + "otaPALCertificatePath": "sss:00223346", + "otaE2EFirmwarePath":"{{testData.sourcePath}}/projects/evkmimxrt1060/test/Debug/aws_iot_qual_test_signed_OTA.bin", + "deviceFirmwarePath":"NA", "codeSigningConfiguration": { "signingMethod": "AWS", "signerHashingAlgorithm": "SHA256", @@ -47,9 +43,6 @@ "pkcs11LabelConfiguration":{ "pkcs11LabelPreProvisionedECDevicePrivateKeyForTLS": "\"sss:F0000000\"", "pkcs11LabelPreProvisionedECDevicePublicKeyForTLS": "\"sss:00223345\"", - "pkcs11LabelPreProvisionedECDeviceCertificateForTLS": "\"sss:F0000001\"", - "pkcs11LabelCodeVerifyKey": "\"sss:00223344\"", - "pkcs11LabelJITPCertificate": "\"sss:20181004\"", - "pkcs11LabelRootCertificate": "\"sss:20181002\"" + "pkcs11LabelPreProvisionedECDeviceCertificateForTLS": "\"sss:F0000001\"" } } \ No newline at end of file diff --git a/idt_config/windows/device.json b/idt_config/windows/device.json index b3e5c97..8a8f819 100644 --- a/idt_config/windows/device.json +++ b/idt_config/windows/device.json @@ -57,4 +57,4 @@ } ] } - ] \ No newline at end of file + ] diff --git a/idt_config/windows/userdata.json b/idt_config/windows/userdata.json index 62a37be..f031dc2 100644 --- a/idt_config/windows/userdata.json +++ b/idt_config/windows/userdata.json @@ -2,7 +2,7 @@ "sourcePath": "", "freeRTOSTestParamConfigPath": "{{testData.sourcePath}}/examples/evkbmimxrt1060/test/include/test_param_config.h", "freeRTOSTestExecutionConfigPath": "{{testData.sourcePath}}/examples/evkbmimxrt1060/test/include/test_execution_config.h", - "freeRTOSVersion": "202012.04-LTS", + "freeRTOSVersion": "202210.00-LTS", "buildTool": { "name": "nxp-build", "version": "1.0.0", @@ -26,13 +26,9 @@ "serverPort": 9000 }, "otaConfiguration": { - "otaPALCertificateFile": "sss:00223346", - "otaPALFirmwareFileName": "dummy.bin", - "otaPALUseFileSystem": "No", - "otaE2EDemoFilePath": "{{userData.sourcePath}}/examples/evkbmimxrt1060/test", - "otaE2EDemoConfigFilePath": "{{testData.sourcePath}}/examples/evkbmimxrt1060/test/include/test_param_config.h", - "otaE2EFirmwareFilePath":"{{testData.sourcePath}}/projects/evkmimxrt1060/test/Debug/aws_iot_qual_test_signed_OTA.bin", - "otaE2EDeviceFirmwareFileName":"NA", + "otaPALCertificatePath": "sss:00223346", + "otaE2EFirmwarePath":"{{testData.sourcePath}}/projects/evkmimxrt1060/test/Debug/aws_iot_qual_test_signed_OTA.bin", + "deviceFirmwarePath":"NA", "codeSigningConfiguration": { "signingMethod": "AWS", "signerHashingAlgorithm": "SHA256", @@ -47,9 +43,6 @@ "pkcs11LabelConfiguration":{ "pkcs11LabelPreProvisionedECDevicePrivateKeyForTLS": "\"sss:F0000000\"", "pkcs11LabelPreProvisionedECDevicePublicKeyForTLS": "\"sss:00223345\"", - "pkcs11LabelPreProvisionedECDeviceCertificateForTLS": "\"sss:F0000001\"", - "pkcs11LabelCodeVerifyKey": "\"sss:00223344\"", - "pkcs11LabelJITPCertificate": "\"sss:20181004\"", - "pkcs11LabelRootCertificate": "\"sss:20181002\"" + "pkcs11LabelPreProvisionedECDeviceCertificateForTLS": "\"sss:F0000001\"" } -} +} \ No newline at end of file diff --git a/lexicon.txt b/lexicon.txt index 0ba6bed..3586d9f 100644 --- a/lexicon.txt +++ b/lexicon.txt @@ -84,6 +84,7 @@ calloc cas casper cbc +cbmc cbor ccm ccm @@ -817,6 +818,7 @@ topiclen topicname topicnamelength tpm +trng tx txd txt diff --git a/manifest.yml b/manifest.yml index 4da500a..36596e0 100644 --- a/manifest.yml +++ b/manifest.yml @@ -4,55 +4,55 @@ description: |- "Reference IoT integration project using NXP i.MX RT1060 with EdgeLock® SE050 secure element and FreeRTOS LTS libraries" dependencies: - name: "FreeRTOS-Kernel" - version: "V10.4.3-LTS-Patch-2" + version: "V10.5.0" repository: type: "git" url: "https://github.com/FreeRTOS/FreeRTOS-Kernel.git" path: "/Middleware/FreeRTOS/kernel" - name: "coreJSON" - version: "v3.0.2" + version: "v3.2.0" repository: type: "git" url: "https://github.com/FreeRTOS/coreJSON.git" path: "/Middleware/FreeRTOS/coreJSON" - name: "coreMQTT" - version: "v1.1.2" + version: "v2.1.0" repository: type: "git" url: "https://github.com/FreeRTOS/coreMQTT.git" path: "/Middleware/FreeRTOS/coreMQTT" - name: "corePKCS11" - version: "v3.1.0" + version: "v3.5.0" repository: type: "git" url: "https://github.com/FreeRTOS/corePKCS11.git" path: "/Middleware/FreeRTOS/corePKCS11" - name: "backoffAlgorithm" - version: "v1.1.0" + version: "v1.3.0" repository: type: "git" url: "https://github.com/FreeRTOS/backoffAlgorithm" path: "/Middleware/FreeRTOS/backoffAlgorithm" - name: "coreMQTT-Agent" - version: "v1.0.1" + version: "v1.2.0" repository: type: "git" url: "https://github.com/FreeRTOS/coreMQTT-Agent.git" path: "/Middleware/FreeRTOS/coreMQTT-Agent" - name: "device-defender" - version: "a12bbaf13920e83a4252b1cf992e1d6a5b0c9939" + version: "v1.3.0" repository: type: "git" url: "https://github.com/aws/Device-Defender-for-AWS-IoT-embedded-sdk.git" path: "/Middleware/AWS/device-defender" - name: "ota" - version: "v3.3.0" + version: "v3.4.0" repository: type: "git" url: "https://github.com/aws/ota-for-AWS-IoT-embedded-sdk.git" path: "/Middleware/AWS/ota" - name: "device-shadow" - version: "v1.2.0" + version: "v1.3.0" repository: type: "git" url: "https://github.com/aws/Device-Shadow-for-AWS-IoT-embedded-sdk.git" @@ -94,7 +94,7 @@ dependencies: url: "https://github.com/ThrowTheSwitch/Unity.git" path: "/Middleware/unity" - name: "FreeRTOS-Libraries-Integration-Tests" - version: "7b531a24eb3d1f5e9fdd23ca0f3c57d7f24c875f" + version: "202210.00" repository: type: "git" url: "https://github.com/FreeRTOS/FreeRTOS-Libraries-Integration-Tests" diff --git a/projects/evkmimxrt1060/test/.cproject b/projects/evkmimxrt1060/test/.cproject index b7363e5..9bf9959 100644 --- a/projects/evkmimxrt1060/test/.cproject +++ b/projects/evkmimxrt1060/test/.cproject @@ -144,6 +144,7 @@ +