From 902a31160cd770898dab1235aa4f01e6b8d04dad Mon Sep 17 00:00:00 2001 From: Hugues Kamba-Mpiana Date: Fri, 6 Oct 2023 17:56:45 +0100 Subject: [PATCH 01/22] middleware: Restructure external projects integration * External projects are referred to as `components` * The components are grouped per category within the `components` subdirectory. * Each component contain a `library` subdir (containing the external project) and an `integration` subdir (containing additional code to integrate the external project). * The external project used for the BSP is now also located in a `library` subdir within the `Bsp` subdir. Signed-off-by: Hugues Kamba-Mpiana --- .gitlab-ci.yml | 2 +- .gitmodules | 102 +++++------ .pre-commit-config.yaml | 26 +-- Bsp/CMakeLists.txt | 36 ++-- Bsp/cmake/BspUtilities.cmake | 9 +- Bsp/{arm-corstone-platform-bsp => library} | 0 Middleware/ARM/CMakeLists.txt | 14 -- Middleware/ARM/IoT_VSocket-lib/CMakeLists.txt | 34 ---- .../freertos-ota-pal-psa-lib/CMakeLists.txt | 27 --- .../freertos-pkcs11-psa-lib/CMakeLists.txt | 24 --- Middleware/ARM/mbedtls-lib/CMakeLists.txt | 147 --------------- Middleware/AWS/CMakeLists.txt | 172 ------------------ Middleware/AWS/logging/CMakeLists.txt | 16 -- Middleware/FreeRTOS/CMakeLists.txt | 11 -- .../FreeRTOS-Plus-TCP-lib/CMakeLists.txt | 38 ---- NOTICE.txt | 2 +- Projects/helpers/CMakeLists.txt | 5 + Projects/helpers/logging/CMakeLists.txt | 16 ++ .../helpers/logging/inc}/iot_logging_task.h | 0 .../helpers/logging/inc}/logging_levels.h | 0 .../helpers/logging/inc}/logging_stack.h | 0 .../src}/iot_logging_task_dynamic_buffers.c | 0 README.md | 2 +- components/CMakeLists.txt | 11 ++ components/README.md | 28 +++ components/aws_iot/CMakeLists.txt | 10 + .../GenerateAWSUpdateDigestAndSignature.cmake | 2 +- components/aws_iot/corejson/CMakeLists.txt | 11 ++ .../corejson/integration/CMakeLists.txt | 21 +++ .../aws_iot/corejson/library | 0 components/aws_iot/coremqtt/CMakeLists.txt | 11 ++ .../coremqtt/integration/CMakeLists.txt | 25 +++ .../aws_iot/coremqtt/library | 0 .../aws_iot/coremqtt_agent/CMakeLists.txt | 11 ++ .../coremqtt_agent/integration/CMakeLists.txt | 33 ++++ .../integration/inc/freertos_agent_message.h | 84 +++++++++ .../integration/inc/freertos_command_pool.h | 83 +++++++++ .../integration/inc}/mqtt_agent_task.h | 0 .../integration/inc/subscription_manager.h | 118 ++++++++++++ .../integration/src/freertos_agent_message.c | 74 ++++++++ .../integration/src/freertos_command_pool.c | 153 ++++++++++++++++ .../integration/src}/mqtt_agent_task.c | 0 .../integration/src/subscription_manager.c | 165 +++++++++++++++++ .../aws_iot/coremqtt_agent/library | 0 components/aws_iot/corepkcs11/CMakeLists.txt | 18 ++ .../corepkcs11/integration/CMakeLists.txt | 28 +++ ...efine-__PASTE-macro-for-Arm-compiler.patch | 8 +- .../aws_iot/corepkcs11/library | 0 .../CMakeLists.txt | 18 ++ .../integration/CMakeLists.txt | 32 ++++ .../0001-Replace-strnlen-with-strlen.patch | 0 .../integration/src}/ota_agent_task.c | 0 .../ota_for_aws_iot_embedded_sdk/library | 0 components/aws_iot/tinycbor/CMakeLists.txt | 11 ++ .../tinycbor/integration/CMakeLists.txt | 25 +++ .../aws_iot/tinycbor/library | 0 components/connectivity/CMakeLists.txt | 16 ++ .../backoff_algorithm/CMakeLists.txt | 11 ++ .../integration/CMakeLists.txt | 21 +++ .../connectivity/backoff_algorithm/library | 0 .../freertos_plus_tcp/CMakeLists.txt | 20 ++ .../integration/CMakeLists.txt | 23 +++ .../inc}/transport_interface_api.h | 0 .../integration}/src/network_startup.c | 2 +- .../integration}/src/transport_mbedtls.c | 2 +- .../connectivity/freertos_plus_tcp/library | 0 .../connectivity/iot_socket/CMakeLists.txt | 11 ++ .../iot_socket/integration}/CMakeLists.txt | 2 +- .../connectivity/iot_socket/library | 0 .../connectivity/iot_vsocket/CMakeLists.txt | 18 ++ .../iot_vsocket/integration/CMakeLists.txt | 26 +++ .../inc}/transport_interface_api.h | 0 ...ce-CMSIS-RTX-APIs-with-FreeRTOS-APIs.patch | 0 .../integration/src}/network_startup.c | 6 +- .../src}/transport_tls_iot_socket.c | 2 +- .../connectivity/iot_vsocket/library | 0 components/freertos_kernel/CMakeLists.txt | 21 +++ .../freertos_kernel/library | 0 components/security/CMakeLists.txt | 12 ++ .../freertos_ota_pal_psa/CMakeLists.txt | 11 ++ .../integration/CMakeLists.txt | 32 ++++ .../security/freertos_ota_pal_psa/library | 0 .../freertos_pkcs11_psa/CMakeLists.txt | 11 ++ .../integration/CMakeLists.txt | 30 +++ .../security/freertos_pkcs11_psa/library | 0 components/security/mbedtls/CMakeLists.txt | 21 +++ .../mbedtls/integration/CMakeLists.txt | 47 +++++ .../mbedtls/integration/inc/iot_tls.h | 6 +- .../mbedtls/integration/src/iot_tls.c | 2 +- .../integration}/src/mbedtls_freertos_port.c | 0 .../security/mbedtls/library | 0 .../trusted_firmware-m/CMakeLists.txt | 11 ++ .../integration}/CMakeLists.txt | 6 +- .../integration/cmake/BuildTfm.cmake | 8 +- .../integration}/cmake/MergeTfmImages.cmake | 5 +- .../integration}/cmake/SignTfmImage.cmake | 5 +- .../security/trusted_firmware-m/library | 0 components/tools/CMakeLists.txt | 7 + .../CMakeLists.txt | 11 ++ .../integration/CMakeLists.txt | 89 +++++++++ .../library | 0 .../open_iot_sdk_toolchain/CMakeLists.txt | 9 + .../tools/open_iot_sdk_toolchain/library | 0 components/tools/unity/CMakeLists.txt | 13 ++ .../Unity => components/tools/unity/library | 0 manifest.yml | 40 ++-- release_changes/202311141614.change | 1 + 107 files changed, 1607 insertions(+), 614 deletions(-) rename Bsp/{arm-corstone-platform-bsp => library} (100%) delete mode 100644 Middleware/ARM/CMakeLists.txt delete mode 100644 Middleware/ARM/IoT_VSocket-lib/CMakeLists.txt delete mode 100644 Middleware/ARM/freertos-ota-pal-psa-lib/CMakeLists.txt delete mode 100644 Middleware/ARM/freertos-pkcs11-psa-lib/CMakeLists.txt delete mode 100644 Middleware/ARM/mbedtls-lib/CMakeLists.txt delete mode 100644 Middleware/AWS/CMakeLists.txt delete mode 100644 Middleware/AWS/logging/CMakeLists.txt delete mode 100644 Middleware/FreeRTOS/CMakeLists.txt delete mode 100644 Middleware/FreeRTOS/FreeRTOS-Plus-TCP-lib/CMakeLists.txt create mode 100644 Projects/helpers/CMakeLists.txt create mode 100644 Projects/helpers/logging/CMakeLists.txt rename {Middleware/AWS/logging/include => Projects/helpers/logging/inc}/iot_logging_task.h (100%) rename {Middleware/AWS/logging/include => Projects/helpers/logging/inc}/logging_levels.h (100%) rename {Middleware/AWS/logging/include => Projects/helpers/logging/inc}/logging_stack.h (100%) rename {Middleware/AWS/logging => Projects/helpers/logging/src}/iot_logging_task_dynamic_buffers.c (100%) create mode 100644 components/CMakeLists.txt create mode 100644 components/README.md create mode 100644 components/aws_iot/CMakeLists.txt rename {Middleware/AWS => components/aws_iot}/cmake/GenerateAWSUpdateDigestAndSignature.cmake (96%) create mode 100644 components/aws_iot/corejson/CMakeLists.txt create mode 100644 components/aws_iot/corejson/integration/CMakeLists.txt rename Middleware/AWS/coreJSON => components/aws_iot/corejson/library (100%) create mode 100644 components/aws_iot/coremqtt/CMakeLists.txt create mode 100644 components/aws_iot/coremqtt/integration/CMakeLists.txt rename Middleware/AWS/coreMQTT => components/aws_iot/coremqtt/library (100%) create mode 100644 components/aws_iot/coremqtt_agent/CMakeLists.txt create mode 100644 components/aws_iot/coremqtt_agent/integration/CMakeLists.txt create mode 100644 components/aws_iot/coremqtt_agent/integration/inc/freertos_agent_message.h create mode 100644 components/aws_iot/coremqtt_agent/integration/inc/freertos_command_pool.h rename {Projects/aws-iot-example/mqtt-agent-wrapper => components/aws_iot/coremqtt_agent/integration/inc}/mqtt_agent_task.h (100%) create mode 100644 components/aws_iot/coremqtt_agent/integration/inc/subscription_manager.h create mode 100644 components/aws_iot/coremqtt_agent/integration/src/freertos_agent_message.c create mode 100644 components/aws_iot/coremqtt_agent/integration/src/freertos_command_pool.c rename {Projects/aws-iot-example/mqtt-agent-wrapper => components/aws_iot/coremqtt_agent/integration/src}/mqtt_agent_task.c (100%) create mode 100644 components/aws_iot/coremqtt_agent/integration/src/subscription_manager.c rename Middleware/AWS/coreMQTT-Agent => components/aws_iot/coremqtt_agent/library (100%) create mode 100644 components/aws_iot/corepkcs11/CMakeLists.txt create mode 100644 components/aws_iot/corepkcs11/integration/CMakeLists.txt rename {Middleware/AWS/patches/corePKCS11 => components/aws_iot/corepkcs11/integration/patches}/0001-Do-not-define-__PASTE-macro-for-Arm-compiler.patch (68%) rename Middleware/AWS/corePKCS11 => components/aws_iot/corepkcs11/library (100%) create mode 100644 components/aws_iot/ota_for_aws_iot_embedded_sdk/CMakeLists.txt create mode 100644 components/aws_iot/ota_for_aws_iot_embedded_sdk/integration/CMakeLists.txt rename {Middleware/AWS/patches/ota-for-aws-iot-embedded-sdk => components/aws_iot/ota_for_aws_iot_embedded_sdk/integration/patches}/0001-Replace-strnlen-with-strlen.patch (100%) rename {Projects/aws-iot-example/mqtt-agent-wrapper => components/aws_iot/ota_for_aws_iot_embedded_sdk/integration/src}/ota_agent_task.c (100%) rename Middleware/AWS/ota-for-aws-iot-embedded-sdk => components/aws_iot/ota_for_aws_iot_embedded_sdk/library (100%) create mode 100644 components/aws_iot/tinycbor/CMakeLists.txt create mode 100644 components/aws_iot/tinycbor/integration/CMakeLists.txt rename Middleware/AWS/tinycbor => components/aws_iot/tinycbor/library (100%) create mode 100644 components/connectivity/CMakeLists.txt create mode 100644 components/connectivity/backoff_algorithm/CMakeLists.txt create mode 100644 components/connectivity/backoff_algorithm/integration/CMakeLists.txt rename Middleware/AWS/backoffAlgorithm => components/connectivity/backoff_algorithm/library (100%) create mode 100644 components/connectivity/freertos_plus_tcp/CMakeLists.txt create mode 100644 components/connectivity/freertos_plus_tcp/integration/CMakeLists.txt rename {Middleware/FreeRTOS/FreeRTOS-Plus-TCP-lib/src => components/connectivity/freertos_plus_tcp/integration/inc}/transport_interface_api.h (100%) rename {Middleware/FreeRTOS/FreeRTOS-Plus-TCP-lib => components/connectivity/freertos_plus_tcp/integration}/src/network_startup.c (99%) rename {Middleware/FreeRTOS/FreeRTOS-Plus-TCP-lib => components/connectivity/freertos_plus_tcp/integration}/src/transport_mbedtls.c (99%) rename Middleware/FreeRTOS/FreeRTOS-Plus-TCP-lib/FreeRTOS-Plus-TCP => components/connectivity/freertos_plus_tcp/library (100%) create mode 100644 components/connectivity/iot_socket/CMakeLists.txt rename {Middleware/ARM/IoT_Socket-lib => components/connectivity/iot_socket/integration}/CMakeLists.txt (83%) rename Middleware/ARM/IoT_Socket-lib/IoT_Socket => components/connectivity/iot_socket/library (100%) create mode 100644 components/connectivity/iot_vsocket/CMakeLists.txt create mode 100644 components/connectivity/iot_vsocket/integration/CMakeLists.txt rename {Middleware/ARM/IoT_VSocket-lib => components/connectivity/iot_vsocket/integration/inc}/transport_interface_api.h (100%) rename {Middleware/ARM/IoT_VSocket-lib => components/connectivity/iot_vsocket/integration/patches}/0001-Replace-CMSIS-RTX-APIs-with-FreeRTOS-APIs.patch (100%) rename {Middleware/ARM/IoT_VSocket-lib => components/connectivity/iot_vsocket/integration/src}/network_startup.c (87%) rename {Middleware/ARM/IoT_VSocket-lib => components/connectivity/iot_vsocket/integration/src}/transport_tls_iot_socket.c (99%) rename Middleware/ARM/IoT_VSocket-lib/AVH => components/connectivity/iot_vsocket/library (100%) create mode 100644 components/freertos_kernel/CMakeLists.txt rename Middleware/FreeRTOS/kernel => components/freertos_kernel/library (100%) create mode 100644 components/security/CMakeLists.txt create mode 100644 components/security/freertos_ota_pal_psa/CMakeLists.txt create mode 100644 components/security/freertos_ota_pal_psa/integration/CMakeLists.txt rename Middleware/ARM/freertos-ota-pal-psa-lib/freertos-ota-pal-psa => components/security/freertos_ota_pal_psa/library (100%) create mode 100644 components/security/freertos_pkcs11_psa/CMakeLists.txt create mode 100644 components/security/freertos_pkcs11_psa/integration/CMakeLists.txt rename Middleware/ARM/freertos-pkcs11-psa-lib/freertos-pkcs11-psa => components/security/freertos_pkcs11_psa/library (100%) create mode 100644 components/security/mbedtls/CMakeLists.txt create mode 100644 components/security/mbedtls/integration/CMakeLists.txt rename Middleware/ARM/mbedtls-lib/src/tls_helper.h => components/security/mbedtls/integration/inc/iot_tls.h (98%) rename Middleware/ARM/mbedtls-lib/src/tls_helper.c => components/security/mbedtls/integration/src/iot_tls.c (99%) rename {Middleware/ARM/mbedtls-lib => components/security/mbedtls/integration}/src/mbedtls_freertos_port.c (100%) rename Middleware/ARM/mbedtls-lib/mbedtls => components/security/mbedtls/library (100%) create mode 100644 components/security/trusted_firmware-m/CMakeLists.txt rename {Middleware/ARM/TF-M => components/security/trusted_firmware-m/integration}/CMakeLists.txt (80%) rename Middleware/ARM/TF-M/cmake/TF-M-build.cmake => components/security/trusted_firmware-m/integration/cmake/BuildTfm.cmake (90%) rename {Middleware/ARM/TF-M => components/security/trusted_firmware-m/integration}/cmake/MergeTfmImages.cmake (90%) rename {Middleware/ARM/TF-M => components/security/trusted_firmware-m/integration}/cmake/SignTfmImage.cmake (90%) rename Middleware/ARM/TF-M/trusted-firmware-m => components/security/trusted_firmware-m/library (100%) create mode 100644 components/tools/CMakeLists.txt create mode 100644 components/tools/freertos_libraries_integration_tests/CMakeLists.txt create mode 100644 components/tools/freertos_libraries_integration_tests/integration/CMakeLists.txt rename Middleware/FreeRTOS/FreeRTOS-Libraries-Integration-Tests => components/tools/freertos_libraries_integration_tests/library (100%) create mode 100644 components/tools/open_iot_sdk_toolchain/CMakeLists.txt rename toolchains => components/tools/open_iot_sdk_toolchain/library (100%) create mode 100644 components/tools/unity/CMakeLists.txt rename Middleware/Unity => components/tools/unity/library (100%) create mode 100644 release_changes/202311141614.change diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2ddbeb61..2cbb5dcf 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -146,7 +146,7 @@ integration-tests: - git config --global user.email "ci@example.com" - git config --global user.name "ci" - ./Tools/scripts/build.sh -q ${APP} - - pushd Middleware/FreeRTOS/FreeRTOS-Libraries-Integration-Tests/tools/echo_server + - pushd components/tools/freertos_libraries_integration_tests/library/tools/echo_server - go run echo_server.go& - popd - sleep 1 diff --git a/.gitmodules b/.gitmodules index 2dfe7c5d..37fd64df 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,57 +1,57 @@ -[submodule "Middleware/FreeRTOS/kernel"] - path = Middleware/FreeRTOS/kernel - url = https://github.com/FreeRTOS/FreeRTOS-Kernel.git -[submodule "Middleware/FreeRTOS/FreeRTOS-Libraries-Integration-Tests"] - path = Middleware/FreeRTOS/FreeRTOS-Libraries-Integration-Tests - url = https://github.com/FreeRTOS/FreeRTOS-Libraries-Integration-Tests.git -[submodule "Middleware/ARM/TF-M/trusted-firmware-m"] - path = Middleware/ARM/TF-M/trusted-firmware-m - url = https://git.trustedfirmware.org/TF-M/trusted-firmware-m.git -[submodule "toolchains"] - path = toolchains - url = https://git.gitlab.arm.com/iot/open-iot-sdk/toolchain.git -[submodule "Bsp/arm-corstone-platform-bsp"] - path = Bsp/arm-corstone-platform-bsp +[submodule "arm_corstone_platform_bsp"] + path = Bsp/library url = https://git.gitlab.arm.com/iot/open-iot-sdk/arm-corstone-platform-bsp.git -[submodule "Middleware/ARM/mbedtls-lib/mbedtls"] - path = Middleware/ARM/mbedtls-lib/mbedtls - url = https://github.com/Mbed-TLS/mbedtls.git -[submodule "Middleware/ARM/IoT_Socket-lib/IoT_Socket"] - path = Middleware/ARM/IoT_Socket-lib/IoT_Socket +[submodule "backoff_algorithm"] + path = components/connectivity/backoff_algorithm/library + url = https://github.com/FreeRTOS/backoffAlgorithm.git +[submodule "corejson"] + path = components/aws_iot/corejson/library + url = https://github.com/FreeRTOS/coreJSON.git +[submodule "coremqtt"] + path = components/aws_iot/coremqtt/library + url = https://github.com/FreeRTOS/coreMQTT.git +[submodule "coremqtt_agent"] + path = components/aws_iot/coremqtt_agent/library + url = https://github.com/FreeRTOS/coreMQTT-Agent.git +[submodule "corepkcs11"] + path = components/aws_iot/corepkcs11/library + url = https://github.com/FreeRTOS/corePKCS11.git +[submodule "iot_socket"] + path = components/connectivity/iot_socket/library url = https://github.com/MDK-Packs/IoT_Socket.git -[submodule "Middleware/ARM/IoT_VSocket-lib/AVH"] - path = Middleware/ARM/IoT_VSocket-lib/AVH +[submodule "iot_vsocket"] + path = components/connectivity/iot_vsocket/library url = https://github.com/ARM-software/AVH.git -[submodule "Middleware/ARM/freertos-pkcs11-psa-lib/freertos-pkcs11-psa"] - path = Middleware/ARM/freertos-pkcs11-psa-lib/freertos-pkcs11-psa - url = https://github.com/Linaro/freertos-pkcs11-psa.git -[submodule "Middleware/ARM/freertos-ota-pal-psa-lib/freertos-ota-pal-psa"] - path = Middleware/ARM/freertos-ota-pal-psa-lib/freertos-ota-pal-psa +[submodule "freertos_kernel"] + path = components/freertos_kernel/library + url = https://github.com/FreeRTOS/FreeRTOS-Kernel.git +[submodule "freertos_libraries_integration_tests"] + path = components/tools/freertos_libraries_integration_tests/library + url = https://github.com/FreeRTOS/FreeRTOS-Libraries-Integration-Tests.git +[submodule "freertos_ota_pal_psa"] + path = components/security/freertos_ota_pal_psa/library url = https://github.com/Linaro/freertos-ota-pal-psa.git -[submodule "Middleware/AWS/coreMQTT-Agent"] - path = Middleware/AWS/coreMQTT-Agent - url = https://github.com/FreeRTOS/coreMQTT-Agent -[submodule "Middleware/AWS/coreMQTT"] - path = Middleware/AWS/coreMQTT - url = https://github.com/FreeRTOS/coreMQTT.git -[submodule "Middleware/AWS/coreJSON"] - path = Middleware/AWS/coreJSON - url = https://github.com/FreeRTOS/coreJSON.git -[submodule "Middleware/AWS/corePKCS11"] - path = Middleware/AWS/corePKCS11 - url = https://github.com/FreeRTOS/corePKCS11.git -[submodule "Middleware/AWS/backoffAlgorithm"] - path = Middleware/AWS/backoffAlgorithm - url = https://github.com/FreeRTOS/backoffAlgorithm.git -[submodule "Middleware/AWS/ota-for-aws-iot-embedded-sdk"] - path = Middleware/AWS/ota-for-aws-iot-embedded-sdk +[submodule "freertos_plus_tcp"] + path = components/connectivity/freertos_plus_tcp/library + url = https://github.com/FreeRTOS/FreeRTOS-Plus-TCP.git +[submodule "freertos_pkcs11_psa"] + path = components/security/freertos_pkcs11_psa/library + url = https://github.com/Linaro/freertos-pkcs11-psa.git +[submodule "mbedtls"] + path = components/security/mbedtls/library + url = https://github.com/Mbed-TLS/mbedtls.git +[submodule "open_iot_sdk_toolchain"] + path = components/tools/open_iot_sdk_toolchain/library + url = https://git.gitlab.arm.com/iot/open-iot-sdk/toolchain.git +[submodule "ota_for_aws_iot_embedded_sdk"] + path = components/aws_iot/ota_for_aws_iot_embedded_sdk/library url = https://github.com/aws/ota-for-aws-iot-embedded-sdk.git -[submodule "Middleware/AWS/tinycbor"] - path = Middleware/AWS/tinycbor - url = https://github.com/intel/tinycbor -[submodule "Middleware/Unity"] - path = Middleware/Unity +[submodule "tinycbor"] + path = components/aws_iot/tinycbor/library + url = https://github.com/intel/tinycbor.git +[submodule "trusted_firmware-m"] + path = components/security/trusted_firmware-m/library + url = https://git.trustedfirmware.org/TF-M/trusted-firmware-m.git +[submodule "unity"] + path = components/tools/unity/library url = https://github.com/ThrowTheSwitch/Unity.git -[submodule "Middleware/FreeRTOS/FreeRTOS-Plus-TCP-lib/FreeRTOS-Plus-TCP"] - path = Middleware/FreeRTOS/FreeRTOS-Plus-TCP-lib/FreeRTOS-Plus-TCP - url = https://github.com/FreeRTOS/FreeRTOS-Plus-TCP.git diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cb452c77..164dac3b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,17 +7,21 @@ exclude: > .patch| (?x)^( - Bsp/arm-corstone-platform-bsp/| - Middleware/ARM/freertos-ota-pal-psa-lib/freertos-ota-pal-psa/| - Middleware/ARM/freertos-pkcs11-psa-lib/freertos-pkcs11-psa/| - Middleware/ARM/IoT_Socket-lib/IoT_Socket/| - Middleware/ARM/IoT_VSocket-lib/AVH/| - Middleware/ARM/IoT_VSocket-lib/transport_interface_api.h| - Middleware/ARM/mbedtls-lib/| - Middleware/ARM/TF-M/trusted-firmware-m/| - Middleware/AWS/| - Middleware/FreeRTOS/| - Middleware/Unity/ + bsp/library/| + components/security/freertos_ota_pal_psa/library/| + components/security/freertos-pkcs11-psa/library/| + components/connectivity/iot_socket/library/| + components/connectivity/iot_vsocket/library/| + components/connectivity/iot_vsocket/integration/inc/transport_interface_api.h| + components/security/mbedtls/| + components/security/trusted_firmware-m/library/| + components/aws_iot/| + components/connectivity/backoff_algorithm/| + Projects/helpers/logging/| + components/freertos_kernel/| + components/connectivity/freertos_plus_tcp/| + components/tools/freertos_libraries_integration_tests/| + components/tools/unity/ ) repos: diff --git a/Bsp/CMakeLists.txt b/Bsp/CMakeLists.txt index fe536599..d5057a9b 100644 --- a/Bsp/CMakeLists.txt +++ b/Bsp/CMakeLists.txt @@ -2,21 +2,33 @@ # # SPDX-License-Identifier: Apache-2.0 -add_subdirectory(arm-corstone-platform-bsp) +set(ARM_CORSTONE_BSP_TARGET_PLATFORM "corstone310" CACHE STRING "Featured Reference Integration target") + +set(arm_corstone_platform_bsp_SOURCE_DIR + ${CMAKE_CURRENT_LIST_DIR}/library + CACHE INTERNAL + "Path to Arm Corstone-3xx Platform CMSIS-Driver Based Board Support Package source code" +) + +add_subdirectory(library) + +target_compile_definitions(arm-corstone-platform-bsp + INTERFACE + __DOMAIN_NS=1 +) -# Target specific image loading addresses if(ARM_CORSTONE_BSP_TARGET_PLATFORM STREQUAL "corstone300") - set(BL2_IMAGE_LOAD_ADDRESS 0x00000000 PARENT_SCOPE) - set(S_IMAGE_LOAD_ADDRESS 0x38000000 PARENT_SCOPE) - set(NS_IMAGE_LOAD_ADDRESS 0x28080000 PARENT_SCOPE) - set(S_PROVISIONING_BUNDLE_LOAD_ADDRESS 0x10022000 PARENT_SCOPE) - set(NS_PROVISIONING_BUNDLE_LOAD_ADDRESS 0x211FF000 PARENT_SCOPE) + set(BL2_IMAGE_LOAD_ADDRESS 0x00000000 CACHE STRING "Bootload image loading address") + set(S_IMAGE_LOAD_ADDRESS 0x38000000 CACHE STRING "Secure TF-M firmware loading address") + set(NS_IMAGE_LOAD_ADDRESS 0x28080000 CACHE STRING "Non-secure user application loading address") + set(S_PROVISIONING_BUNDLE_LOAD_ADDRESS 0x10022000 CACHE STRING "Secure provisioning bundle loading address") + set(NS_PROVISIONING_BUNDLE_LOAD_ADDRESS 0x211FF000 CACHE STRING "Non-Secure provisioning bundle loading address") elseif(ARM_CORSTONE_BSP_TARGET_PLATFORM STREQUAL "corstone310") - set(BL2_IMAGE_LOAD_ADDRESS 0x11000000 PARENT_SCOPE) - set(S_IMAGE_LOAD_ADDRESS 0x38000000 PARENT_SCOPE) - set(NS_IMAGE_LOAD_ADDRESS 0x28080000 PARENT_SCOPE) - set(S_PROVISIONING_BUNDLE_LOAD_ADDRESS 0x11022000 PARENT_SCOPE) - set(NS_PROVISIONING_BUNDLE_LOAD_ADDRESS 0x213FF000 PARENT_SCOPE) + set(BL2_IMAGE_LOAD_ADDRESS 0x11000000 CACHE STRING "Bootload image loading address") + set(S_IMAGE_LOAD_ADDRESS 0x38000000 CACHE STRING "Secure TF-M firmware loading address") + set(NS_IMAGE_LOAD_ADDRESS 0x28080000 CACHE STRING "Non-secure user application loading address") + set(S_PROVISIONING_BUNDLE_LOAD_ADDRESS 0x11022000 CACHE STRING "Secure provisioning bundle loading address") + set(NS_PROVISIONING_BUNDLE_LOAD_ADDRESS 0x213FF000 CACHE STRING "Non-Secure provisioning bundle loading address") endif() # BSP serial library diff --git a/Bsp/cmake/BspUtilities.cmake b/Bsp/cmake/BspUtilities.cmake index b1610b82..7316f291 100644 --- a/Bsp/cmake/BspUtilities.cmake +++ b/Bsp/cmake/BspUtilities.cmake @@ -7,15 +7,16 @@ macro(set_linker_script executable_target) if(${CMAKE_C_COMPILER_ID} STREQUAL "GNU") target_link_options(${executable_target} PRIVATE - $<$:-T ${PRJ_DIR}/Bsp/corstone300/an552_ns.ld> - $<$:-T ${PRJ_DIR}/Bsp/corstone310/an555_ns.ld> + $<$:-T ${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/Bsp/corstone300/an552_ns.ld> + $<$:-T ${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/Bsp/corstone310/an555_ns.ld> + -Wl,--gc-sections --specs=nosys.specs ) else() target_link_options(${executable_target} PRIVATE - $<$:--scatter=${PRJ_DIR}/Bsp/corstone300/an552_ns.sct> - $<$:--scatter=${PRJ_DIR}/Bsp/corstone310/an555_ns.sct> + $<$:--scatter=${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/Bsp/corstone300/an552_ns.sct> + $<$:--scatter=${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/Bsp/corstone310/an555_ns.sct> --map ) endif() diff --git a/Bsp/arm-corstone-platform-bsp b/Bsp/library similarity index 100% rename from Bsp/arm-corstone-platform-bsp rename to Bsp/library diff --git a/Middleware/ARM/CMakeLists.txt b/Middleware/ARM/CMakeLists.txt deleted file mode 100644 index 02ae458e..00000000 --- a/Middleware/ARM/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -# Copyright 2023 Arm Limited and/or its affiliates -# -# SPDX-License-Identifier: MIT - -add_subdirectory(TF-M) -add_subdirectory(mbedtls-lib) -if (DEFINED CONNECTIVITY_STACK) - if (${CONNECTIVITY_STACK} STREQUAL "IOT_VSOCKET") - add_subdirectory(IoT_Socket-lib) - add_subdirectory(IoT_VSocket-lib) - endif() -endif() -add_subdirectory(freertos-pkcs11-psa-lib) -add_subdirectory(freertos-ota-pal-psa-lib) diff --git a/Middleware/ARM/IoT_VSocket-lib/CMakeLists.txt b/Middleware/ARM/IoT_VSocket-lib/CMakeLists.txt deleted file mode 100644 index ad4485b2..00000000 --- a/Middleware/ARM/IoT_VSocket-lib/CMakeLists.txt +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright 2023 Arm Limited and/or its affiliates -# -# SPDX-License-Identifier: MIT - -execute_process(COMMAND git am --abort - COMMAND git am ${CMAKE_CURRENT_SOURCE_DIR}/0001-Replace-CMSIS-RTX-APIs-with-FreeRTOS-APIs.patch - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/AVH" - OUTPUT_QUIET - ERROR_QUIET -) - -add_library(iot-vsocket STATIC - AVH/interface/vsocket/iot_socket.c - network_startup.c - transport_tls_iot_socket.c -) - -add_library(connectivity-stack ALIAS iot-vsocket) - -target_include_directories(iot-vsocket - PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR} - AVH/interface/include -) - -target_link_libraries(iot-vsocket - PUBLIC - iot-socket-api - event-helper - freertos_kernel - fri-bsp - awsIoT - mbedtls-helpers -) diff --git a/Middleware/ARM/freertos-ota-pal-psa-lib/CMakeLists.txt b/Middleware/ARM/freertos-ota-pal-psa-lib/CMakeLists.txt deleted file mode 100644 index 3af1fb39..00000000 --- a/Middleware/ARM/freertos-ota-pal-psa-lib/CMakeLists.txt +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright 2023 Arm Limited and/or its affiliates -# -# SPDX-License-Identifier: MIT - -add_library(freertos-ota-pal-psa STATIC - freertos-ota-pal-psa/version/application_version.c - freertos-ota-pal-psa/ota_pal.c -) - -target_compile_definitions(freertos-ota-pal-psa - PRIVATE - # FreeRTOS OTA PSA PAL configuration - OTA_PAL_CODE_SIGNING_ALGO=OTA_PAL_CODE_SIGNING_RSA - OTA_PAL_SIGNATURE_FORMAT=OTA_PAL_SIGNATURE_RAW -) - -target_include_directories(freertos-ota-pal-psa - PUBLIC - freertos-ota-pal-psa -) - -target_link_libraries(freertos-ota-pal-psa - PUBLIC - aws-configs - tfm-ns-interface - awsIoT -) diff --git a/Middleware/ARM/freertos-pkcs11-psa-lib/CMakeLists.txt b/Middleware/ARM/freertos-pkcs11-psa-lib/CMakeLists.txt deleted file mode 100644 index c6ac7d37..00000000 --- a/Middleware/ARM/freertos-pkcs11-psa-lib/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright 2023 Arm Limited and/or its affiliates -# -# SPDX-License-Identifier: MIT - -add_library(freertos-pkcs11-psa STATIC - freertos-pkcs11-psa/iot_pkcs11_psa_input_format.c - freertos-pkcs11-psa/iot_pkcs11_psa_object_management.c - freertos-pkcs11-psa/iot_pkcs11_psa.c -) - -ExternalProject_Get_Property(tf-m-build BINARY_DIR) - -target_include_directories(freertos-pkcs11-psa - PUBLIC - freertos-pkcs11-psa - ${BINARY_DIR}/api_ns/interface/include -) - -target_link_libraries(freertos-pkcs11-psa - PUBLIC - mbedtls - aws-configs - awsIoT -) diff --git a/Middleware/ARM/mbedtls-lib/CMakeLists.txt b/Middleware/ARM/mbedtls-lib/CMakeLists.txt deleted file mode 100644 index 710e5ebe..00000000 --- a/Middleware/ARM/mbedtls-lib/CMakeLists.txt +++ /dev/null @@ -1,147 +0,0 @@ -# Copyright 2023 Arm Limited and/or its affiliates -# -# SPDX-License-Identifier: MIT - -set(MBEDTLS_SRC_FILES - mbedtls/library/aes.c - mbedtls/library/aesni.c - mbedtls/library/arc4.c - mbedtls/library/aria.c - mbedtls/library/asn1parse.c - mbedtls/library/asn1write.c - mbedtls/library/base64.c - mbedtls/library/bignum.c - mbedtls/library/blowfish.c - mbedtls/library/camellia.c - mbedtls/library/ccm.c - mbedtls/library/certs.c - mbedtls/library/chacha20.c - mbedtls/library/chachapoly.c - mbedtls/library/cipher.c - mbedtls/library/cipher_wrap.c - mbedtls/library/cmac.c - mbedtls/library/constant_time.c - mbedtls/library/ctr_drbg.c - mbedtls/library/debug.c - mbedtls/library/des.c - mbedtls/library/dhm.c - mbedtls/library/ecdh.c - mbedtls/library/ecdsa.c - mbedtls/library/ecjpake.c - mbedtls/library/ecp.c - mbedtls/library/ecp_curves.c - mbedtls/library/entropy.c - mbedtls/library/entropy_poll.c - mbedtls/library/error.c - mbedtls/library/gcm.c - mbedtls/library/havege.c - mbedtls/library/hkdf.c - mbedtls/library/hmac_drbg.c - mbedtls/library/md2.c - mbedtls/library/md4.c - mbedtls/library/md5.c - mbedtls/library/md.c - mbedtls/library/memory_buffer_alloc.c - mbedtls/library/mps_reader.c - mbedtls/library/mps_trace.c - mbedtls/library/net_sockets.c - mbedtls/library/nist_kw.c - mbedtls/library/oid.c - mbedtls/library/padlock.c - mbedtls/library/pem.c - mbedtls/library/pk.c - mbedtls/library/pkcs11.c - mbedtls/library/pkcs12.c - mbedtls/library/pkcs5.c - mbedtls/library/pkparse.c - mbedtls/library/pk_wrap.c - mbedtls/library/pkwrite.c - mbedtls/library/platform.c - mbedtls/library/platform_util.c - mbedtls/library/poly1305.c - mbedtls/library/psa_crypto_aead.c - mbedtls/library/psa_crypto.c - mbedtls/library/psa_crypto_cipher.c - mbedtls/library/psa_crypto_client.c - mbedtls/library/psa_crypto_driver_wrappers.c - mbedtls/library/psa_crypto_ecp.c - mbedtls/library/psa_crypto_hash.c - mbedtls/library/psa_crypto_mac.c - mbedtls/library/psa_crypto_rsa.c - mbedtls/library/psa_crypto_se.c - mbedtls/library/psa_crypto_slot_management.c - mbedtls/library/psa_crypto_storage.c - mbedtls/library/psa_its_file.c - mbedtls/library/ripemd160.c - mbedtls/library/rsa.c - mbedtls/library/rsa_internal.c - mbedtls/library/sha1.c - mbedtls/library/sha256.c - mbedtls/library/sha512.c - mbedtls/library/ssl_cache.c - mbedtls/library/ssl_ciphersuites.c - mbedtls/library/ssl_cli.c - mbedtls/library/ssl_cookie.c - mbedtls/library/ssl_msg.c - mbedtls/library/ssl_srv.c - mbedtls/library/ssl_ticket.c - mbedtls/library/ssl_tls13_keys.c - mbedtls/library/ssl_tls.c - mbedtls/library/threading.c - mbedtls/library/timing.c - mbedtls/library/version.c - mbedtls/library/version_features.c - mbedtls/library/x509.c - mbedtls/library/x509_create.c - mbedtls/library/x509_crl.c - mbedtls/library/x509_crt.c - mbedtls/library/x509_csr.c - mbedtls/library/x509write_crt.c - mbedtls/library/x509write_csr.c - mbedtls/library/xtea.c -) - -add_library(mbedtls ${MBEDTLS_SRC_FILES}) - -target_include_directories(mbedtls - PUBLIC - mbedtls/include - mbedtls/library -) - -# mbedtls-config library is used to supply configuration for MbedTLS -# IMPORTANT: user applications must provide a "mbedtls_config.h" file which can be an empty -# file or contain MbedTLS options the user wants to override. This can be done by adding -# an include directory to mbed-config that contains the file. -add_library(mbedtls-config INTERFACE) - -target_link_libraries(mbedtls - mbedtls-config -) - -add_library(mbedtls-threading-freertos - src/mbedtls_freertos_port.c -) - -target_link_libraries(mbedtls-threading-freertos - freertos_kernel - mbedtls-config - mbedtls -) - -add_library(mbedtls-helpers - src/tls_helper.c -) - -target_include_directories(mbedtls-helpers - PUBLIC - src -) - -target_link_libraries(mbedtls-helpers - freertos_kernel - mbedtls-config - mbedtls - aws-configs - awsIoT -) diff --git a/Middleware/AWS/CMakeLists.txt b/Middleware/AWS/CMakeLists.txt deleted file mode 100644 index fedb1dfd..00000000 --- a/Middleware/AWS/CMakeLists.txt +++ /dev/null @@ -1,172 +0,0 @@ -# Copyright 2023 Arm Limited and/or its affiliates -# -# SPDX-License-Identifier: MIT - -# Logging -add_subdirectory(logging) - -# coreMQTT-Agent -add_library(awsIoT STATIC) - -include(coreMQTT-Agent/mqttAgentFilePaths.cmake) - -target_include_directories(awsIoT - PUBLIC - ${MQTT_AGENT_INCLUDE_PUBLIC_DIRS} -) - -target_sources(awsIoT - PRIVATE - ${MQTT_AGENT_SOURCES} -) - -# coreMQTT -include(coreMQTT/mqttFilePaths.cmake) - -target_include_directories(awsIoT - PUBLIC - ${MQTT_INCLUDE_PUBLIC_DIRS} -) - -target_sources(awsIoT - PRIVATE - ${MQTT_SOURCES} - ${MQTT_SERIALIZER_SOURCES} -) - -target_compile_definitions(awsIoT - PUBLIC - MQTT_DO_NOT_USE_CUSTOM_CONFIG=1 - MQTT_AGENT_DO_NOT_USE_CUSTOM_CONFIG=1 -) - -# coreJSON -include(coreJSON/jsonFilePaths.cmake) - -target_include_directories(awsIoT - PUBLIC - ${JSON_INCLUDE_PUBLIC_DIRS} -) - -target_sources(awsIoT - PRIVATE - ${JSON_SOURCES} -) - -# corePKCS11 -execute_process(COMMAND git am --abort - COMMAND git am ${CMAKE_CURRENT_SOURCE_DIR}/patches/corePKCS11/0001-Do-not-define-__PASTE-macro-for-Arm-compiler.patch - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/corePKCS11/source/dependency/3rdparty/pkcs11" - OUTPUT_QUIET - ERROR_QUIET -) - -include(corePKCS11/pkcsFilePaths.cmake) - -target_include_directories(awsIoT - PUBLIC - ${PKCS_INCLUDE_PUBLIC_DIRS} -) - -target_sources(awsIoT - PRIVATE - corePKCS11/source/core_pkcs11.c - corePKCS11/source/core_pki_utils.c -) - -# backoff_algorithm -include(backoffAlgorithm/backoffAlgorithmFilePaths.cmake) - -target_include_directories(awsIoT - PUBLIC - ${BACKOFF_ALGORITHM_INCLUDE_PUBLIC_DIRS} -) - -target_sources(awsIoT - PRIVATE - ${BACKOFF_ALGORITHM_SOURCES} -) - -# OTA -execute_process(COMMAND git am --abort - COMMAND git am ${CMAKE_CURRENT_SOURCE_DIR}/patches/ota-for-aws-iot-embedded-sdk/0001-Replace-strnlen-with-strlen.patch - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/ota-for-aws-iot-embedded-sdk" - OUTPUT_QUIET - ERROR_QUIET -) - -set( TINYCBOR_SOURCES - tinycbor/src/cborpretty.c - tinycbor/src/cborpretty_stdio.c - tinycbor/src/cborencoder.c - tinycbor/src/cborencoder_close_container_checked.c - tinycbor/src/cborerrorstrings.c - tinycbor/src/cborparser.c - tinycbor/src/cborparser_dup_string.c -) -set(TINYCBOR_INCLUDE_DIRS - tinycbor/src -) - -# OTA library source files, including 3rdparties. -set( OTA_SOURCES - ota-for-aws-iot-embedded-sdk/source/include/ota.h - ota-for-aws-iot-embedded-sdk/source/include/ota_os_interface.h - ota-for-aws-iot-embedded-sdk/source/include/ota_platform_interface.h - ota-for-aws-iot-embedded-sdk/source/include/ota_private.h - ota-for-aws-iot-embedded-sdk/source/include/ota_interface_private.h - ota-for-aws-iot-embedded-sdk/source/include/ota_base64_private.h - ota-for-aws-iot-embedded-sdk/source/ota.c - ota-for-aws-iot-embedded-sdk/source/ota_interface.c - ota-for-aws-iot-embedded-sdk/source/ota_base64.c - ${JSON_SOURCES} - ${TINYCBOR_SOURCES} -) - -# OTA library public include directories. -set( OTA_INCLUDE_PUBLIC_DIRS - ota-for-aws-iot-embedded-sdk/source/include - ota-for-aws-iot-embedded-sdk/source/portable -) - -# OTA library FreeRTOS OS porting source files. -set( OTA_OS_FREERTOS_SOURCES - ota-for-aws-iot-embedded-sdk/source/portable/os/ota_os_freertos.c -) - -# OTA library FreeRTOS OS porting source files. -set( OTA_INCLUDE_OS_FREERTOS_DIRS - ota-for-aws-iot-embedded-sdk/source/portable/os -) - -# OTA library MQTT backend source files. -set( OTA_MQTT_SOURCES - ota-for-aws-iot-embedded-sdk/source/ota_mqtt.c - ota-for-aws-iot-embedded-sdk/source/ota_cbor.c - ota-for-aws-iot-embedded-sdk/source/include/ota_mqtt_private.h - ota-for-aws-iot-embedded-sdk/source/include/ota_cbor_private.h -) - -target_include_directories(awsIoT - PUBLIC - ${OTA_INCLUDE_PUBLIC_DIRS} - ${OTA_INCLUDE_OS_FREERTOS_DIRS} - ${TINYCBOR_INCLUDE_DIRS} - ${JSON_INCLUDE_PUBLIC_DIRS} -) - -target_sources(awsIoT - PRIVATE - ${OTA_SOURCES} - ${OTA_OS_FREERTOS_SOURCES} - ${OTA_MQTT_SOURCES} -) - -target_link_libraries(awsIoT - aws-configs - app-logging - freertos_kernel - mbedtls - freertos-pkcs11-psa -) - diff --git a/Middleware/AWS/logging/CMakeLists.txt b/Middleware/AWS/logging/CMakeLists.txt deleted file mode 100644 index 752ffc4d..00000000 --- a/Middleware/AWS/logging/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright 2023 Arm Limited and/or its affiliates -# -# SPDX-License-Identifier: MIT - -# MQTT agent task library - -add_library(app-logging STATIC iot_logging_task_dynamic_buffers.c) - -target_include_directories(app-logging - PUBLIC - include -) - -target_link_libraries(app-logging - freertos_kernel -) diff --git a/Middleware/FreeRTOS/CMakeLists.txt b/Middleware/FreeRTOS/CMakeLists.txt deleted file mode 100644 index 0488e22e..00000000 --- a/Middleware/FreeRTOS/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright 2023 Arm Limited and/or its affiliates -# -# SPDX-License-Identifier: MIT - -add_subdirectory(kernel) - -if (DEFINED CONNECTIVITY_STACK) - if (${CONNECTIVITY_STACK} STREQUAL "FREERTOS_TCP_IP") - add_subdirectory(FreeRTOS-Plus-TCP-lib) - endif() -endif() diff --git a/Middleware/FreeRTOS/FreeRTOS-Plus-TCP-lib/CMakeLists.txt b/Middleware/FreeRTOS/FreeRTOS-Plus-TCP-lib/CMakeLists.txt deleted file mode 100644 index 3f4fac7a..00000000 --- a/Middleware/FreeRTOS/FreeRTOS-Plus-TCP-lib/CMakeLists.txt +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright 2023 Arm Limited and/or its affiliates -# -# SPDX-License-Identifier: MIT - -# Currently, the network interface for LAN91C111 ethernet controller in -# FreeRTOS TCP/IP is named `MPS3_AN552` and is based on CMSIS ethernet driver. -# All the MPS3 FVPs emulate LAN91C111 for network connectivity. Therefore, -# `MPS3_AN552` network interface is used by both Corstone-300 and Corstone-310 -# FVP targets. -set(FREERTOS_PLUS_TCP_NETWORK_IF "MPS3_AN552" CACHE STRING "FreeRTOS Plus TCP Network Interface selection") - -set(FREERTOS_PLUS_TCP_BUFFER_ALLOCATION "2" CACHE STRING "FreeRTOS buffer allocation model number. 1 .. 2.") - -add_subdirectory(FreeRTOS-Plus-TCP/source) -add_subdirectory(FreeRTOS-Plus-TCP/tools) - -add_library(connectivity-stack ALIAS freertos_plus_tcp) - -target_sources( freertos_plus_tcp - PRIVATE - src/network_startup.c - src/transport_mbedtls.c -) - -target_include_directories( freertos_plus_tcp SYSTEM - PUBLIC - src -) - -target_link_libraries(freertos_plus_tcp - PRIVATE - app-logging - freertos_kernel - fri-bsp - awsIoT - mbedtls-helpers - event-helper -) diff --git a/NOTICE.txt b/NOTICE.txt index f64844b3..2f6c04ea 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -1,5 +1,5 @@ ** mbedTLS; version 2.28.3 -- https://github.com/Mbed-TLS/mbedtls.git -** IoT_VSocket-lib; version 6b1b5140242c01127f18f54aeab63c9c1cd59e03 -- https://github.com/FreeRTOS/iot-reference-arm-corstone3xx/tree/main/Middleware/ARM/IoT_VSocket-lib +** IoT_VSocket-lib; version 6b1b5140242c01127f18f54aeab63c9c1cd59e03 -- https://github.com/FreeRTOS/iot-reference-arm-corstone3xx/tree/main/components/connectivity/iot_vsocket ** AVH; version ab37f6126c94fee7bbd061f77716745dfbb77592 -- https://github.com/ARM-software/AVH.git ** IoT_Socket; version 1e15f55ae08c2169c0e4a59216e78a4906a66af8 -- https://github.com/MDK-Packs/IoT_Socket.git ** arm-corstone-platform-bsp; version v0.1.0 -- https://git.gitlab.arm.com/iot/open-iot-sdk/arm-corstone-platform-bsp.git diff --git a/Projects/helpers/CMakeLists.txt b/Projects/helpers/CMakeLists.txt new file mode 100644 index 00000000..3a0b4180 --- /dev/null +++ b/Projects/helpers/CMakeLists.txt @@ -0,0 +1,5 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +add_subdirectory(logging) diff --git a/Projects/helpers/logging/CMakeLists.txt b/Projects/helpers/logging/CMakeLists.txt new file mode 100644 index 00000000..a55668b5 --- /dev/null +++ b/Projects/helpers/logging/CMakeLists.txt @@ -0,0 +1,16 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +add_library(helpers-logging + src/iot_logging_task_dynamic_buffers.c +) + +target_include_directories(helpers-logging + PUBLIC + inc +) + +target_link_libraries(helpers-logging + freertos_kernel +) diff --git a/Middleware/AWS/logging/include/iot_logging_task.h b/Projects/helpers/logging/inc/iot_logging_task.h similarity index 100% rename from Middleware/AWS/logging/include/iot_logging_task.h rename to Projects/helpers/logging/inc/iot_logging_task.h diff --git a/Middleware/AWS/logging/include/logging_levels.h b/Projects/helpers/logging/inc/logging_levels.h similarity index 100% rename from Middleware/AWS/logging/include/logging_levels.h rename to Projects/helpers/logging/inc/logging_levels.h diff --git a/Middleware/AWS/logging/include/logging_stack.h b/Projects/helpers/logging/inc/logging_stack.h similarity index 100% rename from Middleware/AWS/logging/include/logging_stack.h rename to Projects/helpers/logging/inc/logging_stack.h diff --git a/Middleware/AWS/logging/iot_logging_task_dynamic_buffers.c b/Projects/helpers/logging/src/iot_logging_task_dynamic_buffers.c similarity index 100% rename from Middleware/AWS/logging/iot_logging_task_dynamic_buffers.c rename to Projects/helpers/logging/src/iot_logging_task_dynamic_buffers.c diff --git a/README.md b/README.md index 143f8d64..c77635a8 100644 --- a/README.md +++ b/README.md @@ -120,7 +120,7 @@ See [CONTRIBUTING](CONTRIBUTING.md) for more information. ## License -Source code located in the *Projects*, *Middleware/FreeRTOS* directory is +Source code located in the *Projects* directory is available under the terms of the MIT License. See the [LICENSE](./LICENSE) file for more details. diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt new file mode 100644 index 00000000..7406b332 --- /dev/null +++ b/components/CMakeLists.txt @@ -0,0 +1,11 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +# FreeRTOS must be first as other components depend on it +add_subdirectory(freertos_kernel) + +add_subdirectory(aws_iot EXCLUDE_FROM_ALL) +add_subdirectory(connectivity EXCLUDE_FROM_ALL) +add_subdirectory(security EXCLUDE_FROM_ALL) +add_subdirectory(tools EXCLUDE_FROM_ALL) diff --git a/components/README.md b/components/README.md new file mode 100644 index 00000000..d7aa4cd3 --- /dev/null +++ b/components/README.md @@ -0,0 +1,28 @@ +# Components + +The `components` subdirectory contains external libraries along with other libraries +that are developed as part of FRI. + +The libraries are grouped per category within the `components` subdirectory. + +`aws_iot`: Includes the components used to make a connection to AWS IoT Core. +`connectivity`: Includes the components used to establish networking. +`freertos_kernel`: Includes the FreeRTOS kernel. +`security`: Includes components that enhance security. +`tools`: Includes components providing tools used by applications. + + +Each comprise two parts: +* `library` - the external library source code. +* `integration` - additional integration code for the library to build application. + +The `integration` subdirectory contains distinct directories: +* `src` - contains integration source code files +* `inc` - contains integration header files +* `patches` - contains patch files to be applied to the library + +A modular approach is used to create the components. +Two CMake targets are created for each component: +* library target (if one is not already provided). +* library configuration target for applications to customise the target for + their use cases. diff --git a/components/aws_iot/CMakeLists.txt b/components/aws_iot/CMakeLists.txt new file mode 100644 index 00000000..9f8a28d4 --- /dev/null +++ b/components/aws_iot/CMakeLists.txt @@ -0,0 +1,10 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +add_subdirectory(corejson) +add_subdirectory(coremqtt) +add_subdirectory(coremqtt_agent) +add_subdirectory(corepkcs11) +add_subdirectory(ota_for_aws_iot_embedded_sdk) +add_subdirectory(tinycbor) diff --git a/Middleware/AWS/cmake/GenerateAWSUpdateDigestAndSignature.cmake b/components/aws_iot/cmake/GenerateAWSUpdateDigestAndSignature.cmake similarity index 96% rename from Middleware/AWS/cmake/GenerateAWSUpdateDigestAndSignature.cmake rename to components/aws_iot/cmake/GenerateAWSUpdateDigestAndSignature.cmake index 855c245f..8df6ad0f 100644 --- a/Middleware/AWS/cmake/GenerateAWSUpdateDigestAndSignature.cmake +++ b/components/aws_iot/cmake/GenerateAWSUpdateDigestAndSignature.cmake @@ -4,7 +4,7 @@ include(ExternalProject) -ExternalProject_Get_Property(tf-m-build BINARY_DIR) +ExternalProject_Get_Property(trusted_firmware-m-build BINARY_DIR) # This function is meant to generate the AWS update signature and digest # for the input parameter, the name of the signature diff --git a/components/aws_iot/corejson/CMakeLists.txt b/components/aws_iot/corejson/CMakeLists.txt new file mode 100644 index 00000000..550851d9 --- /dev/null +++ b/components/aws_iot/corejson/CMakeLists.txt @@ -0,0 +1,11 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +set(corejson_SOURCE_DIR + ${CMAKE_CURRENT_LIST_DIR}/library + CACHE INTERNAL + "Path to coreJSON source code" +) + +add_subdirectory(integration) diff --git a/components/aws_iot/corejson/integration/CMakeLists.txt b/components/aws_iot/corejson/integration/CMakeLists.txt new file mode 100644 index 00000000..21975a97 --- /dev/null +++ b/components/aws_iot/corejson/integration/CMakeLists.txt @@ -0,0 +1,21 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +include(${corejson_SOURCE_DIR}/jsonFilePaths.cmake) + +add_library(corejson + ${JSON_SOURCES} +) + +target_include_directories(corejson + PUBLIC + ${JSON_INCLUDE_PUBLIC_DIRS} +) + +add_library(corejson-config INTERFACE) + +target_link_libraries(corejson + PUBLIC + corejson-config +) diff --git a/Middleware/AWS/coreJSON b/components/aws_iot/corejson/library similarity index 100% rename from Middleware/AWS/coreJSON rename to components/aws_iot/corejson/library diff --git a/components/aws_iot/coremqtt/CMakeLists.txt b/components/aws_iot/coremqtt/CMakeLists.txt new file mode 100644 index 00000000..bcf9940b --- /dev/null +++ b/components/aws_iot/coremqtt/CMakeLists.txt @@ -0,0 +1,11 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +set(coremqtt_SOURCE_DIR + ${CMAKE_CURRENT_LIST_DIR}/library + CACHE INTERNAL + "Path to coreMQTT source code" +) + +add_subdirectory(integration) diff --git a/components/aws_iot/coremqtt/integration/CMakeLists.txt b/components/aws_iot/coremqtt/integration/CMakeLists.txt new file mode 100644 index 00000000..52bd3d82 --- /dev/null +++ b/components/aws_iot/coremqtt/integration/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +include(${coremqtt_SOURCE_DIR}/mqttFilePaths.cmake) + +add_library(coremqtt + ${MQTT_SOURCES} + ${MQTT_SERIALIZER_SOURCES} +) + +target_include_directories(coremqtt + PUBLIC + ${MQTT_INCLUDE_PUBLIC_DIRS} +) + +add_library(coremqtt-config INTERFACE) + +target_link_libraries(coremqtt + PUBLIC + coremqtt-config + PRIVATE + freertos_kernel + helpers-logging +) diff --git a/Middleware/AWS/coreMQTT b/components/aws_iot/coremqtt/library similarity index 100% rename from Middleware/AWS/coreMQTT rename to components/aws_iot/coremqtt/library diff --git a/components/aws_iot/coremqtt_agent/CMakeLists.txt b/components/aws_iot/coremqtt_agent/CMakeLists.txt new file mode 100644 index 00000000..8686b2d5 --- /dev/null +++ b/components/aws_iot/coremqtt_agent/CMakeLists.txt @@ -0,0 +1,11 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +set(coremqtt_agent_SOURCE_DIR + ${CMAKE_CURRENT_LIST_DIR}/library + CACHE INTERNAL + "Path to coreMQTT-Agent source code" +) + +add_subdirectory(integration) diff --git a/components/aws_iot/coremqtt_agent/integration/CMakeLists.txt b/components/aws_iot/coremqtt_agent/integration/CMakeLists.txt new file mode 100644 index 00000000..1ac80c8a --- /dev/null +++ b/components/aws_iot/coremqtt_agent/integration/CMakeLists.txt @@ -0,0 +1,33 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +include(${coremqtt_agent_SOURCE_DIR}/mqttAgentFilePaths.cmake) + +add_library(coremqtt-agent + ${MQTT_AGENT_SOURCES} + src/mqtt_agent_task.c + src/subscription_manager.c + src/freertos_command_pool.c + src/freertos_agent_message.c +) + +target_include_directories(coremqtt-agent + PUBLIC + ${MQTT_AGENT_INCLUDE_PUBLIC_DIRS} + inc +) + +add_library(coremqtt-agent-config INTERFACE) + +target_link_libraries(coremqtt-agent + PUBLIC + coremqtt-agent-config + PRIVATE + backoff-algorithm + connectivity-stack + coremqtt + freertos_kernel + helpers-events + helpers-logging +) diff --git a/components/aws_iot/coremqtt_agent/integration/inc/freertos_agent_message.h b/components/aws_iot/coremqtt_agent/integration/inc/freertos_agent_message.h new file mode 100644 index 00000000..c5eb4a79 --- /dev/null +++ b/components/aws_iot/coremqtt_agent/integration/inc/freertos_agent_message.h @@ -0,0 +1,84 @@ +/* + * FreeRTOS V202104.00 + * Copyright (C) 2020 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 + * + */ + +/** + * @file freertos_core_mqtt_agent_message_interface.h + * @brief Functions to interact with queues. + */ +#ifndef FREERTOS_AGENT_MESSAGE_H +#define FREERTOS_AGENT_MESSAGE_H + +#include +#include +#include + +/* FreeRTOS includes. */ +#include "FreeRTOS.h" +#include "queue.h" + +/* Include MQTT agent messaging interface. */ +#include "core_mqtt_agent_message_interface.h" + +/** + * @ingroup mqtt_agent_struct_types + * @brief Context with which tasks may deliver messages to the agent. + */ +struct MQTTAgentMessageContext +{ + QueueHandle_t queue; +}; + +/*-----------------------------------------------------------*/ + +/** + * @brief Send a message to the specified context. + * Must be thread safe. + * + * @param[in] pMsgCtx An #MQTTAgentMessageContext_t. + * @param[in] pCommandToSend Pointer to address to send to queue. + * @param[in] blockTimeMs Block time to wait for a send. + * + * @return `true` if send was successful, else `false`. + */ +bool Agent_MessageSend( MQTTAgentMessageContext_t * pMsgCtx, + MQTTAgentCommand_t * const * pCommandToSend, + uint32_t blockTimeMs ); + +/** + * @brief Receive a message from the specified context. + * Must be thread safe. + * + * @param[in] pMsgCtx An #MQTTAgentMessageContext_t. + * @param[in] pReceivedCommand Pointer to write address of received command. + * @param[in] blockTimeMs Block time to wait for a receive. + * + * @return `true` if receive was successful, else `false`. + */ +bool Agent_MessageReceive( MQTTAgentMessageContext_t * pMsgCtx, + MQTTAgentCommand_t ** pReceivedCommand, + uint32_t blockTimeMs ); + +#endif /* FREERTOS_AGENT_MESSAGE_H */ diff --git a/components/aws_iot/coremqtt_agent/integration/inc/freertos_command_pool.h b/components/aws_iot/coremqtt_agent/integration/inc/freertos_command_pool.h new file mode 100644 index 00000000..587cb426 --- /dev/null +++ b/components/aws_iot/coremqtt_agent/integration/inc/freertos_command_pool.h @@ -0,0 +1,83 @@ +/* + * FreeRTOS V202104.00 + * Copyright (C) 2020 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 + * + */ + +/** + * @file freertos_command_pool.h + * @brief Functions to obtain and release a command. + */ +#ifndef FREERTOS_COMMAND_POOL_H +#define FREERTOS_COMMAND_POOL_H + +/* MQTT agent includes. */ +#include "core_mqtt_agent.h" + +/** + * @brief Initialize the common task pool. Not thread safe. + */ +void Agent_InitializePool( void ); + +/** + * @brief Obtain a MQTTAgentCommand_t structure from the pool of structures managed by the agent. + * + * @note MQTTAgentCommand_t structures hold everything the MQTT agent needs to process a + * command that originates from application. Examples of commands are PUBLISH and + * SUBSCRIBE. The MQTTAgentCommand_t structure must persist for the duration of the command's + * operation so are obtained from a pool of statically allocated structures when a + * new command is created, and returned to the pool when the command is complete. + * The MQTT_COMMAND_CONTEXTS_POOL_SIZE configuration file constant defines how many + * structures the pool contains. + * + * @param[in] blockTimeMs The length of time the calling task should remain in the + * Blocked state (so not consuming any CPU time) to wait for a MQTTAgentCommand_t structure to + * become available should one not be immediately at the time of the call. + * + * @return A pointer to a MQTTAgentCommand_t structure if one becomes available before + * blockTimeMs time expired, otherwise NULL. + */ +MQTTAgentCommand_t * Agent_GetCommand( uint32_t blockTimeMs ); + +/** + * @brief Give a MQTTAgentCommand_t structure back to the the pool of structures managed by + * the agent. + * + * @note MQTTAgentCommand_t structures hold everything the MQTT agent needs to process a + * command that originates from application. Examples of commands are PUBLISH and + * SUBSCRIBE. The MQTTAgentCommand_t structure must persist for the duration of the command's + * operation so are obtained from a pool of statically allocated structures when a + * new command is created, and returned to the pool when the command is complete. + * The MQTT_COMMAND_CONTEXTS_POOL_SIZE configuration file constant defines how many + * structures the pool contains. + * + * @param[in] pCommandToRelease A pointer to the MQTTAgentCommand_t structure to return to + * the pool. The structure must first have been obtained by calling + * Agent_GetCommand(), otherwise Agent_ReleaseCommand() will + * have no effect. + * + * @return true if the MQTTAgentCommand_t structure was returned to the pool, otherwise false. + */ +bool Agent_ReleaseCommand( MQTTAgentCommand_t * pCommandToRelease ); + +#endif /* FREERTOS_COMMAND_POOL_H */ diff --git a/Projects/aws-iot-example/mqtt-agent-wrapper/mqtt_agent_task.h b/components/aws_iot/coremqtt_agent/integration/inc/mqtt_agent_task.h similarity index 100% rename from Projects/aws-iot-example/mqtt-agent-wrapper/mqtt_agent_task.h rename to components/aws_iot/coremqtt_agent/integration/inc/mqtt_agent_task.h diff --git a/components/aws_iot/coremqtt_agent/integration/inc/subscription_manager.h b/components/aws_iot/coremqtt_agent/integration/inc/subscription_manager.h new file mode 100644 index 00000000..5fd3d661 --- /dev/null +++ b/components/aws_iot/coremqtt_agent/integration/inc/subscription_manager.h @@ -0,0 +1,118 @@ +/* + * FreeRTOS V202011.00 + * Copyright (C) 2020 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://aws.amazon.com/freertos + * + */ + +/** + * @file subscription_manager.h + * @brief Functions for managing MQTT subscriptions. + */ +#ifndef SUBSCRIPTION_MANAGER_H +#define SUBSCRIPTION_MANAGER_H + +#include "core_mqtt.h" + +/** + * @brief Maximum number of subscriptions maintained by the subscription manager + * simultaneously in a list. + */ +#ifndef SUBSCRIPTION_MANAGER_MAX_SUBSCRIPTIONS + #define SUBSCRIPTION_MANAGER_MAX_SUBSCRIPTIONS 10U +#endif + +/** + * @brief Callback function called when receiving a publish. + * + * @param[in] pvIncomingPublishCallbackContext The incoming publish callback context. + * @param[in] pxPublishInfo Deserialized publish information. + */ +typedef void (* IncomingPubCallback_t)( void * pvIncomingPublishCallbackContext, + MQTTPublishInfo_t * pxPublishInfo ); + +/** + * @brief An element in the list of subscriptions. + * + * This subscription manager implementation expects that the array of the + * subscription elements used for storing subscriptions to be initialized to 0. + * + * @note This implementation allows multiple tasks to subscribe to the same topic. + * In this case, another element is added to the subscription list, differing + * in the intended publish callback. Also note that the topic filters are not + * copied in the subscription manager and hence the topic filter strings need to + * stay in scope until unsubscribed. + */ +typedef struct subscriptionElement +{ + IncomingPubCallback_t pxIncomingPublishCallback; + void * pvIncomingPublishCallbackContext; + uint16_t usFilterStringLength; + const char * pcSubscriptionFilterString; +} SubscriptionElement_t; + +/** + * @brief Add a subscription to the subscription list. + * + * @note Multiple tasks can be subscribed to the same topic with different + * context-callback pairs. However, a single context-callback pair may only be + * associated to the same topic filter once. + * + * @param[in] pxSubscriptionList The pointer to the subscription list array. + * @param[in] pcTopicFilterString Topic filter string of subscription. + * @param[in] usTopicFilterLength Length of topic filter string. + * @param[in] pxIncomingPublishCallback Callback function for the subscription. + * @param[in] pvIncomingPublishCallbackContext Context for the subscription callback. + * + * @return `true` if subscription added or exists, `false` if insufficient memory. + */ +bool addSubscription( const char * pcTopicFilterString, + uint16_t usTopicFilterLength, + IncomingPubCallback_t pxIncomingPublishCallback, + void * pvIncomingPublishCallbackContext ); + +/** + * @brief Remove a subscription from the subscription list. + * + * @note If the topic filter exists multiple times in the subscription list, + * then every instance of the subscription will be removed. + * + * @param[in] pxSubscriptionList The pointer to the subscription list array. + * @param[in] pcTopicFilterString Topic filter of subscription. + * @param[in] usTopicFilterLength Length of topic filter. + */ +void removeSubscription( const char * pcTopicFilterString, + uint16_t usTopicFilterLength ); + +/** + * @brief Handle incoming publishes by invoking the callbacks registered + * for the incoming publish's topic filter. + * + * @param[in] pxSubscriptionList The pointer to the subscription list array. + * @param[in] pxPublishInfo Info of incoming publish. + * + * @return `true` if an application callback could be invoked; + * `false` otherwise. + */ +bool handleIncomingPublishes( MQTTPublishInfo_t * pxPublishInfo ); + +#endif /* SUBSCRIPTION_MANAGER_H */ diff --git a/components/aws_iot/coremqtt_agent/integration/src/freertos_agent_message.c b/components/aws_iot/coremqtt_agent/integration/src/freertos_agent_message.c new file mode 100644 index 00000000..ff96e6de --- /dev/null +++ b/components/aws_iot/coremqtt_agent/integration/src/freertos_agent_message.c @@ -0,0 +1,74 @@ +/* + * FreeRTOS V202104.00 + * Copyright (C) 2020 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 + * + */ + +/** + * @file freertos_agent_message.c + * @brief Implements functions to interact with queues. + */ + +/* Standard includes. */ +#include +#include + +/* Kernel includes. */ +#include "FreeRTOS.h" +#include "semphr.h" + +/* Header include. */ +#include "core_mqtt_agent_message_interface.h" +#include "freertos_agent_message.h" + +/*-----------------------------------------------------------*/ + +bool Agent_MessageSend( MQTTAgentMessageContext_t * pMsgCtx, + MQTTAgentCommand_t * const * pCommandToSend, + uint32_t blockTimeMs ) +{ + BaseType_t queueStatus = pdFAIL; + + if( ( pMsgCtx != NULL ) && ( pCommandToSend != NULL ) ) + { + queueStatus = xQueueSendToBack( pMsgCtx->queue, pCommandToSend, pdMS_TO_TICKS( blockTimeMs ) ); + } + + return ( queueStatus == pdPASS ) ? true : false; +} + +/*-----------------------------------------------------------*/ + +bool Agent_MessageReceive( MQTTAgentMessageContext_t * pMsgCtx, + MQTTAgentCommand_t ** pReceivedCommand, + uint32_t blockTimeMs ) +{ + BaseType_t queueStatus = pdFAIL; + + if( ( pMsgCtx != NULL ) && ( pReceivedCommand != NULL ) ) + { + queueStatus = xQueueReceive( pMsgCtx->queue, pReceivedCommand, pdMS_TO_TICKS( blockTimeMs ) ); + } + + return ( queueStatus == pdPASS ) ? true : false; +} diff --git a/components/aws_iot/coremqtt_agent/integration/src/freertos_command_pool.c b/components/aws_iot/coremqtt_agent/integration/src/freertos_command_pool.c new file mode 100644 index 00000000..e275a5b6 --- /dev/null +++ b/components/aws_iot/coremqtt_agent/integration/src/freertos_command_pool.c @@ -0,0 +1,153 @@ +/* + * FreeRTOS V202104.00 + * Copyright (C) 2020 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 + * + */ + +/** + * @file freertos_command_pool.c + * @brief Implements functions to obtain and release commands. + */ + +/* Standard includes. */ +#include +#include + +/* Kernel includes. */ +#include "FreeRTOS.h" +#include "semphr.h" + +/* Header include. */ +#include "freertos_agent_message.h" +#include "freertos_command_pool.h" + +/* Include header that defines log levels. */ +#include "logging_levels.h" + +/* Configure name and log level. */ +#ifndef LIBRARY_LOG_NAME +#define LIBRARY_LOG_NAME "COMMAND POOL" +#endif +#ifndef LIBRARY_LOG_LEVEL +#define LIBRARY_LOG_LEVEL LOG_INFO +#endif +#include "core_mqtt_config.h" +#include "logging_stack.h" + +/*-----------------------------------------------------------*/ + +#define QUEUE_NOT_INITIALIZED (0U) +#define QUEUE_INITIALIZED (1U) + +/** + * @brief The pool of command structures used to hold information on commands (such + * as PUBLISH or SUBSCRIBE) between the command being created by an API call and + * completion of the command by the execution of the command's callback. + */ +static MQTTAgentCommand_t commandStructurePool[MQTT_COMMAND_CONTEXTS_POOL_SIZE]; + +/** + * @brief The message context used to guard the pool of MQTTAgentCommand_t structures. + * For FreeRTOS, this is implemented with a queue. Structures may be + * obtained by receiving a pointer from the queue, and returned by + * sending the pointer back into it. + */ +static MQTTAgentMessageContext_t commandStructMessageCtx; + +/** + * @brief Initialization status of the queue. + */ +static volatile uint8_t initStatus = QUEUE_NOT_INITIALIZED; + +/*-----------------------------------------------------------*/ + +void Agent_InitializePool(void) +{ + size_t i; + MQTTAgentCommand_t *pCommand; + static uint8_t staticQueueStorageArea[MQTT_COMMAND_CONTEXTS_POOL_SIZE * sizeof(MQTTAgentCommand_t *)]; + static StaticQueue_t staticQueueStructure; + bool commandAdded = false; + + if (initStatus == QUEUE_NOT_INITIALIZED) { + memset((void *)commandStructurePool, 0x00, sizeof(commandStructurePool)); + commandStructMessageCtx.queue = xQueueCreateStatic(MQTT_COMMAND_CONTEXTS_POOL_SIZE, + sizeof(MQTTAgentCommand_t *), + staticQueueStorageArea, + &staticQueueStructure); + configASSERT(commandStructMessageCtx.queue); + + /* Populate the queue. */ + for (i = 0; i < MQTT_COMMAND_CONTEXTS_POOL_SIZE; i++) { + /* Store the address as a variable. */ + pCommand = &commandStructurePool[i]; + /* Send the pointer to the queue. */ + commandAdded = Agent_MessageSend(&commandStructMessageCtx, &pCommand, 0U); + configASSERT(commandAdded); + } + + initStatus = QUEUE_INITIALIZED; + } +} + +/*-----------------------------------------------------------*/ + +MQTTAgentCommand_t *Agent_GetCommand(uint32_t blockTimeMs) +{ + MQTTAgentCommand_t *structToUse = NULL; + bool structRetrieved = false; + + /* Check queue has been created. */ + configASSERT(initStatus == QUEUE_INITIALIZED); + + /* Retrieve a struct from the queue. */ + structRetrieved = Agent_MessageReceive(&commandStructMessageCtx, &(structToUse), blockTimeMs); + + if (!structRetrieved) { + LogDebug(("No command structure available.\n")); + } + + return structToUse; +} + +/*-----------------------------------------------------------*/ + +bool Agent_ReleaseCommand(MQTTAgentCommand_t *pCommandToRelease) +{ + bool structReturned = false; + + configASSERT(initStatus == QUEUE_INITIALIZED); + + /* See if the structure being returned is actually from the pool. */ + if ((pCommandToRelease >= commandStructurePool) + && (pCommandToRelease < (commandStructurePool + MQTT_COMMAND_CONTEXTS_POOL_SIZE))) { + structReturned = Agent_MessageSend(&commandStructMessageCtx, &pCommandToRelease, 0U); + + /* The send should not fail as the queue was created to hold every command + * in the pool. */ + configASSERT(structReturned); + LogDebug(("Returned Command Context %d to pool\n", (int)(pCommandToRelease - commandStructurePool))); + } + + return structReturned; +} diff --git a/Projects/aws-iot-example/mqtt-agent-wrapper/mqtt_agent_task.c b/components/aws_iot/coremqtt_agent/integration/src/mqtt_agent_task.c similarity index 100% rename from Projects/aws-iot-example/mqtt-agent-wrapper/mqtt_agent_task.c rename to components/aws_iot/coremqtt_agent/integration/src/mqtt_agent_task.c diff --git a/components/aws_iot/coremqtt_agent/integration/src/subscription_manager.c b/components/aws_iot/coremqtt_agent/integration/src/subscription_manager.c new file mode 100644 index 00000000..49d2f1da --- /dev/null +++ b/components/aws_iot/coremqtt_agent/integration/src/subscription_manager.c @@ -0,0 +1,165 @@ +/* + * FreeRTOS V202212.00 + * Copyright (C) 2020 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 + * + */ + +/** + * @file subscription_manager.c + * @brief Functions for managing MQTT subscriptions. + */ + +/* Standard includes. */ +#include + +/* Include header that defines log levels. */ +#include "logging_levels.h" + +/* Configure name and log level. */ +#ifndef LIBRARY_LOG_NAME +#define LIBRARY_LOG_NAME "SUB MGR" +#endif +#ifndef LIBRARY_LOG_LEVEL +#define LIBRARY_LOG_LEVEL LOG_INFO +#endif +#include "logging_stack.h" + +/* Subscription manager header include. */ +#include "subscription_manager.h" + +/** + * @brief The global array of subscription elements. + * + * @note No thread safety is required to this array, since the updates the array + * elements are done only from one task at a time. The subscription manager + * implementation expects that the array of the subscription elements used for + * storing subscriptions to be initialized to 0. As this is a global array, it + * will be intialized to 0 by default. + */ +SubscriptionElement_t xGlobalSubscriptionList[SUBSCRIPTION_MANAGER_MAX_SUBSCRIPTIONS]; + +bool addSubscription(const char *pcTopicFilterString, + uint16_t usTopicFilterLength, + IncomingPubCallback_t pxIncomingPublishCallback, + void *pvIncomingPublishCallbackContext) +{ + int32_t lIndex = 0; + size_t xAvailableIndex = SUBSCRIPTION_MANAGER_MAX_SUBSCRIPTIONS; + bool xReturnStatus = false; + + if ((pcTopicFilterString == NULL) || (usTopicFilterLength == 0U) || (pxIncomingPublishCallback == NULL)) { + LogError(("Invalid parameter. spcTopicFilterString=%p," + " usTopicFilterLength=%u, pxIncomingPublishCallback=%p.", + pcTopicFilterString, + (unsigned int)usTopicFilterLength, + pxIncomingPublishCallback)); + } else { + /* Start at end of array, so that we will insert at the first available index. + * Scans backwards to find duplicates. */ + for (lIndex = (int32_t)SUBSCRIPTION_MANAGER_MAX_SUBSCRIPTIONS - 1; lIndex >= 0; lIndex--) { + if (xGlobalSubscriptionList[lIndex].usFilterStringLength == 0) { + xAvailableIndex = lIndex; + } else if ((xGlobalSubscriptionList[lIndex].usFilterStringLength == usTopicFilterLength) + && (strncmp(pcTopicFilterString, + xGlobalSubscriptionList[lIndex].pcSubscriptionFilterString, + (size_t)usTopicFilterLength) + == 0)) { + /* If a subscription already exists, don't do anything. */ + if ((xGlobalSubscriptionList[lIndex].pxIncomingPublishCallback == pxIncomingPublishCallback) + && (xGlobalSubscriptionList[lIndex].pvIncomingPublishCallbackContext + == pvIncomingPublishCallbackContext)) { + LogWarn(("Subscription already exists.\n")); + xAvailableIndex = SUBSCRIPTION_MANAGER_MAX_SUBSCRIPTIONS; + xReturnStatus = true; + break; + } + } + } + + if (xAvailableIndex < SUBSCRIPTION_MANAGER_MAX_SUBSCRIPTIONS) { + xGlobalSubscriptionList[xAvailableIndex].pcSubscriptionFilterString = pcTopicFilterString; + xGlobalSubscriptionList[xAvailableIndex].usFilterStringLength = usTopicFilterLength; + xGlobalSubscriptionList[xAvailableIndex].pxIncomingPublishCallback = pxIncomingPublishCallback; + xGlobalSubscriptionList[xAvailableIndex].pvIncomingPublishCallbackContext = + pvIncomingPublishCallbackContext; + xReturnStatus = true; + } + } + + return xReturnStatus; +} + +/*-----------------------------------------------------------*/ + +void removeSubscription(const char *pcTopicFilterString, uint16_t usTopicFilterLength) +{ + int32_t lIndex = 0; + + if ((pcTopicFilterString == NULL) || (usTopicFilterLength == 0U)) { + LogError(("Invalid parameter. pcTopicFilterString=%p," + " usTopicFilterLength=%u.", + pcTopicFilterString, + (unsigned int)usTopicFilterLength)); + } else { + for (lIndex = 0; lIndex < SUBSCRIPTION_MANAGER_MAX_SUBSCRIPTIONS; lIndex++) { + if (xGlobalSubscriptionList[lIndex].usFilterStringLength == usTopicFilterLength) { + if (strncmp(xGlobalSubscriptionList[lIndex].pcSubscriptionFilterString, + pcTopicFilterString, + usTopicFilterLength) + == 0) { + memset(&(xGlobalSubscriptionList[lIndex]), 0x00, sizeof(SubscriptionElement_t)); + } + } + } + } +} + +/*-----------------------------------------------------------*/ + +bool handleIncomingPublishes(MQTTPublishInfo_t *pxPublishInfo) +{ + int32_t lIndex = 0; + bool isMatched = false, publishHandled = false; + + if (pxPublishInfo == NULL) { + LogError(("Invalid parameter. pxPublishInfo=%p,", pxPublishInfo)); + } else { + for (lIndex = 0; lIndex < SUBSCRIPTION_MANAGER_MAX_SUBSCRIPTIONS; lIndex++) { + if (xGlobalSubscriptionList[lIndex].usFilterStringLength > 0) { + MQTT_MatchTopic(pxPublishInfo->pTopicName, + pxPublishInfo->topicNameLength, + xGlobalSubscriptionList[lIndex].pcSubscriptionFilterString, + xGlobalSubscriptionList[lIndex].usFilterStringLength, + &isMatched); + + if (isMatched == true) { + xGlobalSubscriptionList[lIndex].pxIncomingPublishCallback( + xGlobalSubscriptionList[lIndex].pvIncomingPublishCallbackContext, pxPublishInfo); + publishHandled = true; + } + } + } + } + + return publishHandled; +} diff --git a/Middleware/AWS/coreMQTT-Agent b/components/aws_iot/coremqtt_agent/library similarity index 100% rename from Middleware/AWS/coreMQTT-Agent rename to components/aws_iot/coremqtt_agent/library diff --git a/components/aws_iot/corepkcs11/CMakeLists.txt b/components/aws_iot/corepkcs11/CMakeLists.txt new file mode 100644 index 00000000..f8a02f51 --- /dev/null +++ b/components/aws_iot/corepkcs11/CMakeLists.txt @@ -0,0 +1,18 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +set(corepkcs11_SOURCE_DIR + ${CMAKE_CURRENT_LIST_DIR}/library + CACHE INTERNAL + "Path to corePKCS11 source code" +) + +execute_process(COMMAND git am --abort + COMMAND git am ${CMAKE_CURRENT_SOURCE_DIR}/integration/patches/0001-Do-not-define-__PASTE-macro-for-Arm-compiler.patch + WORKING_DIRECTORY ${corepkcs11_SOURCE_DIR} + OUTPUT_QUIET + ERROR_QUIET +) + +add_subdirectory(integration) diff --git a/components/aws_iot/corepkcs11/integration/CMakeLists.txt b/components/aws_iot/corepkcs11/integration/CMakeLists.txt new file mode 100644 index 00000000..c35b3dda --- /dev/null +++ b/components/aws_iot/corepkcs11/integration/CMakeLists.txt @@ -0,0 +1,28 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +include(${corepkcs11_SOURCE_DIR}/pkcsFilePaths.cmake) + +# Do not use ${PKCS_SOURCES} because we are using the +# PKCS11 to PSA Crypto wrappers from freertos-pkcs11-psa +add_library(corepkcs11 + ${corepkcs11_SOURCE_DIR}/source/core_pkcs11.c + ${corepkcs11_SOURCE_DIR}/source/core_pki_utils.c +) + +target_include_directories(corepkcs11 + PUBLIC + ${PKCS_INCLUDE_PUBLIC_DIRS} +) + +add_library(corepkcs11-config INTERFACE) + +target_link_libraries(corepkcs11 + PUBLIC + corepkcs11-config + PRIVATE + freertos_kernel + freertos-pkcs11-psa + mbedtls +) diff --git a/Middleware/AWS/patches/corePKCS11/0001-Do-not-define-__PASTE-macro-for-Arm-compiler.patch b/components/aws_iot/corepkcs11/integration/patches/0001-Do-not-define-__PASTE-macro-for-Arm-compiler.patch similarity index 68% rename from Middleware/AWS/patches/corePKCS11/0001-Do-not-define-__PASTE-macro-for-Arm-compiler.patch rename to components/aws_iot/corepkcs11/integration/patches/0001-Do-not-define-__PASTE-macro-for-Arm-compiler.patch index bf28c73f..7ee856d0 100644 --- a/Middleware/AWS/patches/corePKCS11/0001-Do-not-define-__PASTE-macro-for-Arm-compiler.patch +++ b/components/aws_iot/corepkcs11/integration/patches/0001-Do-not-define-__PASTE-macro-for-Arm-compiler.patch @@ -5,13 +5,13 @@ Subject: [PATCH] Do not define __PASTE macro for Arm compiler Signed-off-by: Devaraj Ranganna --- - pkcs11.h | 2 ++ + ./source/dependency/3rdparty/pkcs11/pkcs11.h | 2 ++ 1 file changed, 2 insertions(+) -diff --git a/pkcs11.h b/pkcs11.h +diff --git a/source/dependency/3rdparty/pkcs11/pkcs11.h b/source/dependency/3rdparty/pkcs11/pkcs11.h index 0d78dd7..ecead72 100644 ---- a/pkcs11.h -+++ b/pkcs11.h +--- a/source/dependency/3rdparty/pkcs11/pkcs11.h ++++ b/source/dependency/3rdparty/pkcs11/pkcs11.h @@ -187,7 +187,9 @@ extern "C" { */ #include "pkcs11t.h" diff --git a/Middleware/AWS/corePKCS11 b/components/aws_iot/corepkcs11/library similarity index 100% rename from Middleware/AWS/corePKCS11 rename to components/aws_iot/corepkcs11/library diff --git a/components/aws_iot/ota_for_aws_iot_embedded_sdk/CMakeLists.txt b/components/aws_iot/ota_for_aws_iot_embedded_sdk/CMakeLists.txt new file mode 100644 index 00000000..5bd50d00 --- /dev/null +++ b/components/aws_iot/ota_for_aws_iot_embedded_sdk/CMakeLists.txt @@ -0,0 +1,18 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +set(ota_for_aws_iot_embedded_sdk_SOURCE_DIR + ${CMAKE_CURRENT_LIST_DIR}/library + CACHE INTERNAL + "Path to AWS IoT Over-the-air Update source code" +) + +execute_process(COMMAND git am --abort + COMMAND git am ${CMAKE_CURRENT_SOURCE_DIR}/integration/patches/0001-Replace-strnlen-with-strlen.patch + WORKING_DIRECTORY ${ota_for_aws_iot_embedded_sdk_SOURCE_DIR} + OUTPUT_QUIET + ERROR_QUIET +) + +add_subdirectory(integration) diff --git a/components/aws_iot/ota_for_aws_iot_embedded_sdk/integration/CMakeLists.txt b/components/aws_iot/ota_for_aws_iot_embedded_sdk/integration/CMakeLists.txt new file mode 100644 index 00000000..7247b85b --- /dev/null +++ b/components/aws_iot/ota_for_aws_iot_embedded_sdk/integration/CMakeLists.txt @@ -0,0 +1,32 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +include(${ota_for_aws_iot_embedded_sdk_SOURCE_DIR}/otaFilePaths.cmake) + +add_library(ota-for-aws-iot-embedded-sdk + ${OTA_SOURCES} + ${OTA_MQTT_SOURCES} + ${OTA_OS_FREERTOS_SOURCES} + src/ota_agent_task.c +) + +target_include_directories(ota-for-aws-iot-embedded-sdk + PUBLIC + ${OTA_INCLUDE_PUBLIC_DIRS} + ${OTA_INCLUDE_OS_FREERTOS_DIRS} +) + +add_library(ota-for-aws-iot-embedded-sdk-config INTERFACE) + +target_link_libraries(ota-for-aws-iot-embedded-sdk + PUBLIC + ota-for-aws-iot-embedded-sdk-config + PRIVATE + corejson + coremqtt + coremqtt-agent + freertos-ota-pal-psa + helpers-logging + tinycbor +) diff --git a/Middleware/AWS/patches/ota-for-aws-iot-embedded-sdk/0001-Replace-strnlen-with-strlen.patch b/components/aws_iot/ota_for_aws_iot_embedded_sdk/integration/patches/0001-Replace-strnlen-with-strlen.patch similarity index 100% rename from Middleware/AWS/patches/ota-for-aws-iot-embedded-sdk/0001-Replace-strnlen-with-strlen.patch rename to components/aws_iot/ota_for_aws_iot_embedded_sdk/integration/patches/0001-Replace-strnlen-with-strlen.patch diff --git a/Projects/aws-iot-example/mqtt-agent-wrapper/ota_agent_task.c b/components/aws_iot/ota_for_aws_iot_embedded_sdk/integration/src/ota_agent_task.c similarity index 100% rename from Projects/aws-iot-example/mqtt-agent-wrapper/ota_agent_task.c rename to components/aws_iot/ota_for_aws_iot_embedded_sdk/integration/src/ota_agent_task.c diff --git a/Middleware/AWS/ota-for-aws-iot-embedded-sdk b/components/aws_iot/ota_for_aws_iot_embedded_sdk/library similarity index 100% rename from Middleware/AWS/ota-for-aws-iot-embedded-sdk rename to components/aws_iot/ota_for_aws_iot_embedded_sdk/library diff --git a/components/aws_iot/tinycbor/CMakeLists.txt b/components/aws_iot/tinycbor/CMakeLists.txt new file mode 100644 index 00000000..0e652acf --- /dev/null +++ b/components/aws_iot/tinycbor/CMakeLists.txt @@ -0,0 +1,11 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +set(tinycbor_SOURCE_DIR + ${CMAKE_CURRENT_LIST_DIR}/library + CACHE INTERNAL + "Path to TinyCBOR source code" +) + +add_subdirectory(integration) diff --git a/components/aws_iot/tinycbor/integration/CMakeLists.txt b/components/aws_iot/tinycbor/integration/CMakeLists.txt new file mode 100644 index 00000000..5825baf7 --- /dev/null +++ b/components/aws_iot/tinycbor/integration/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +add_library(tinycbor + ${tinycbor_SOURCE_DIR}/src/cborpretty.c + ${tinycbor_SOURCE_DIR}/src/cborpretty_stdio.c + ${tinycbor_SOURCE_DIR}/src/cborencoder.c + ${tinycbor_SOURCE_DIR}/src/cborencoder_close_container_checked.c + ${tinycbor_SOURCE_DIR}/src/cborerrorstrings.c + ${tinycbor_SOURCE_DIR}/src/cborparser.c + ${tinycbor_SOURCE_DIR}/src/cborparser_dup_string.c +) + +target_include_directories(tinycbor + PUBLIC + ${tinycbor_SOURCE_DIR}/src +) + +add_library(tinycbor-config INTERFACE) + +target_link_libraries(tinycbor + PUBLIC + tinycbor-config +) diff --git a/Middleware/AWS/tinycbor b/components/aws_iot/tinycbor/library similarity index 100% rename from Middleware/AWS/tinycbor rename to components/aws_iot/tinycbor/library diff --git a/components/connectivity/CMakeLists.txt b/components/connectivity/CMakeLists.txt new file mode 100644 index 00000000..3ac724ee --- /dev/null +++ b/components/connectivity/CMakeLists.txt @@ -0,0 +1,16 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +add_subdirectory(backoff_algorithm) + +set(CONNECTIVITY_STACK "FREERTOS_PLUS_TCP" CACHE STRING "Choose the connectivity stack (FREERTOS_PLUS_TCP|IOT_VSOCKET) to use ().") + +if(CONNECTIVITY_STACK STREQUAL "FREERTOS_PLUS_TCP") + add_subdirectory(freertos_plus_tcp) +elseif(CONNECTIVITY_STACK STREQUAL "IOT_VSOCKET") + add_subdirectory(iot_socket) + add_subdirectory(iot_vsocket) +else() + message(FATAL_ERROR "Invalid connectivity stack choice: ${CONNECTIVITY_STACK}") +endif() diff --git a/components/connectivity/backoff_algorithm/CMakeLists.txt b/components/connectivity/backoff_algorithm/CMakeLists.txt new file mode 100644 index 00000000..c162c045 --- /dev/null +++ b/components/connectivity/backoff_algorithm/CMakeLists.txt @@ -0,0 +1,11 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +set(backoff_algorithm_SOURCE_DIR + ${CMAKE_CURRENT_LIST_DIR}/library + CACHE INTERNAL + "Path to backoffAlgorithm source code" +) + +add_subdirectory(integration) diff --git a/components/connectivity/backoff_algorithm/integration/CMakeLists.txt b/components/connectivity/backoff_algorithm/integration/CMakeLists.txt new file mode 100644 index 00000000..1e064763 --- /dev/null +++ b/components/connectivity/backoff_algorithm/integration/CMakeLists.txt @@ -0,0 +1,21 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +include(${backoff_algorithm_SOURCE_DIR}/backoffAlgorithmFilePaths.cmake) + +add_library(backoff-algorithm + ${BACKOFF_ALGORITHM_SOURCES} +) + +target_include_directories(backoff-algorithm + PUBLIC + ${BACKOFF_ALGORITHM_INCLUDE_PUBLIC_DIRS} +) + +add_library(backoff-algorithm-config INTERFACE) + +target_link_libraries(backoff-algorithm + PUBLIC + backoff-algorithm-config +) diff --git a/Middleware/AWS/backoffAlgorithm b/components/connectivity/backoff_algorithm/library similarity index 100% rename from Middleware/AWS/backoffAlgorithm rename to components/connectivity/backoff_algorithm/library diff --git a/components/connectivity/freertos_plus_tcp/CMakeLists.txt b/components/connectivity/freertos_plus_tcp/CMakeLists.txt new file mode 100644 index 00000000..520468e1 --- /dev/null +++ b/components/connectivity/freertos_plus_tcp/CMakeLists.txt @@ -0,0 +1,20 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +set(freertos_plus_tcp_SOURCE_DIR + ${CMAKE_CURRENT_LIST_DIR}/library + CACHE INTERNAL + "Path to FreeRTOS-Plus-TCP source code" +) + +if (${ARM_CORSTONE_BSP_TARGET_PLATFORM} STREQUAL "corstone300" OR ${ARM_CORSTONE_BSP_TARGET_PLATFORM} STREQUAL "corstone310") + set(FREERTOS_PLUS_TCP_NETWORK_IF "MPS3_AN552" CACHE STRING "FreeRTOS Plus TCP Network Interface selection") +endif() + +set(FREERTOS_PLUS_TCP_BUFFER_ALLOCATION "2" CACHE STRING "FreeRTOS buffer allocation model number. 1 .. 2.") + +add_subdirectory(library/source) +add_subdirectory(library/tools) + +add_subdirectory(integration) diff --git a/components/connectivity/freertos_plus_tcp/integration/CMakeLists.txt b/components/connectivity/freertos_plus_tcp/integration/CMakeLists.txt new file mode 100644 index 00000000..9fe36144 --- /dev/null +++ b/components/connectivity/freertos_plus_tcp/integration/CMakeLists.txt @@ -0,0 +1,23 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +target_sources(freertos_plus_tcp + PRIVATE + src/network_startup.c + src/transport_mbedtls.c +) + +target_include_directories(freertos_plus_tcp SYSTEM + PUBLIC + inc +) + +target_link_libraries(freertos_plus_tcp + PRIVATE + coremqtt + helpers-events + iot-tls +) + +add_library(connectivity-stack ALIAS freertos_plus_tcp) diff --git a/Middleware/FreeRTOS/FreeRTOS-Plus-TCP-lib/src/transport_interface_api.h b/components/connectivity/freertos_plus_tcp/integration/inc/transport_interface_api.h similarity index 100% rename from Middleware/FreeRTOS/FreeRTOS-Plus-TCP-lib/src/transport_interface_api.h rename to components/connectivity/freertos_plus_tcp/integration/inc/transport_interface_api.h diff --git a/Middleware/FreeRTOS/FreeRTOS-Plus-TCP-lib/src/network_startup.c b/components/connectivity/freertos_plus_tcp/integration/src/network_startup.c similarity index 99% rename from Middleware/FreeRTOS/FreeRTOS-Plus-TCP-lib/src/network_startup.c rename to components/connectivity/freertos_plus_tcp/integration/src/network_startup.c index 081664c2..f1a3e1b1 100644 --- a/Middleware/FreeRTOS/FreeRTOS-Plus-TCP-lib/src/network_startup.c +++ b/components/connectivity/freertos_plus_tcp/integration/src/network_startup.c @@ -10,7 +10,7 @@ #include "FreeRTOS_IP.h" /* System events helper header. */ -#include "event_helper.h" +#include "events.h" /* Include header that defines log levels. */ #include "logging_levels.h" diff --git a/Middleware/FreeRTOS/FreeRTOS-Plus-TCP-lib/src/transport_mbedtls.c b/components/connectivity/freertos_plus_tcp/integration/src/transport_mbedtls.c similarity index 99% rename from Middleware/FreeRTOS/FreeRTOS-Plus-TCP-lib/src/transport_mbedtls.c rename to components/connectivity/freertos_plus_tcp/integration/src/transport_mbedtls.c index e7763135..4ade5077 100644 --- a/Middleware/FreeRTOS/FreeRTOS-Plus-TCP-lib/src/transport_mbedtls.c +++ b/components/connectivity/freertos_plus_tcp/integration/src/transport_mbedtls.c @@ -47,7 +47,7 @@ #include "transport_interface_api.h" /* TLS helper header. */ -#include "tls_helper.h" +#include "iot_tls.h" static int Recv_Cb( void * pvCallerContext, unsigned char * pucReceiveBuffer, diff --git a/Middleware/FreeRTOS/FreeRTOS-Plus-TCP-lib/FreeRTOS-Plus-TCP b/components/connectivity/freertos_plus_tcp/library similarity index 100% rename from Middleware/FreeRTOS/FreeRTOS-Plus-TCP-lib/FreeRTOS-Plus-TCP rename to components/connectivity/freertos_plus_tcp/library diff --git a/components/connectivity/iot_socket/CMakeLists.txt b/components/connectivity/iot_socket/CMakeLists.txt new file mode 100644 index 00000000..45a7a8fa --- /dev/null +++ b/components/connectivity/iot_socket/CMakeLists.txt @@ -0,0 +1,11 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +set(iot_socket_SOURCE_DIR + ${CMAKE_CURRENT_LIST_DIR}/library + CACHE INTERNAL + "Path to IoT Socket source code" +) + +add_subdirectory(integration) diff --git a/Middleware/ARM/IoT_Socket-lib/CMakeLists.txt b/components/connectivity/iot_socket/integration/CMakeLists.txt similarity index 83% rename from Middleware/ARM/IoT_Socket-lib/CMakeLists.txt rename to components/connectivity/iot_socket/integration/CMakeLists.txt index cf1e7961..2744a6c8 100644 --- a/Middleware/ARM/IoT_Socket-lib/CMakeLists.txt +++ b/components/connectivity/iot_socket/integration/CMakeLists.txt @@ -6,5 +6,5 @@ add_library(iot-socket-api INTERFACE) target_include_directories(iot-socket-api INTERFACE - IoT_Socket/include + ${iot_socket_SOURCE_DIR}/include ) diff --git a/Middleware/ARM/IoT_Socket-lib/IoT_Socket b/components/connectivity/iot_socket/library similarity index 100% rename from Middleware/ARM/IoT_Socket-lib/IoT_Socket rename to components/connectivity/iot_socket/library diff --git a/components/connectivity/iot_vsocket/CMakeLists.txt b/components/connectivity/iot_vsocket/CMakeLists.txt new file mode 100644 index 00000000..5f70bee2 --- /dev/null +++ b/components/connectivity/iot_vsocket/CMakeLists.txt @@ -0,0 +1,18 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +set(iot_vsocket_SOURCE_DIR + ${CMAKE_CURRENT_LIST_DIR}/library + CACHE INTERNAL + "Path to Arm Virtual Hardware - IoT Virtual Socket source code" +) + +execute_process(COMMAND git am --abort + COMMAND git am ${CMAKE_CURRENT_LIST_DIR}/integration/patches/0001-Replace-CMSIS-RTX-APIs-with-FreeRTOS-APIs.patch + WORKING_DIRECTORY ${iot_vsocket_SOURCE_DIR} + OUTPUT_QUIET + ERROR_QUIET +) + +add_subdirectory(integration) diff --git a/components/connectivity/iot_vsocket/integration/CMakeLists.txt b/components/connectivity/iot_vsocket/integration/CMakeLists.txt new file mode 100644 index 00000000..e01ec9ae --- /dev/null +++ b/components/connectivity/iot_vsocket/integration/CMakeLists.txt @@ -0,0 +1,26 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +add_library(iot-vsocket + ${iot_vsocket_SOURCE_DIR}/interface/vsocket/iot_socket.c + src/network_startup.c + src/transport_tls_iot_socket.c +) + +target_include_directories(iot-vsocket + PUBLIC + inc + ${iot_vsocket_SOURCE_DIR}/interface/include +) + +target_link_libraries(iot-vsocket + PRIVATE + coremqtt + helpers-events + fri-bsp + iot-socket-api + iot-tls +) + +add_library(connectivity-stack ALIAS iot-vsocket) diff --git a/Middleware/ARM/IoT_VSocket-lib/transport_interface_api.h b/components/connectivity/iot_vsocket/integration/inc/transport_interface_api.h similarity index 100% rename from Middleware/ARM/IoT_VSocket-lib/transport_interface_api.h rename to components/connectivity/iot_vsocket/integration/inc/transport_interface_api.h diff --git a/Middleware/ARM/IoT_VSocket-lib/0001-Replace-CMSIS-RTX-APIs-with-FreeRTOS-APIs.patch b/components/connectivity/iot_vsocket/integration/patches/0001-Replace-CMSIS-RTX-APIs-with-FreeRTOS-APIs.patch similarity index 100% rename from Middleware/ARM/IoT_VSocket-lib/0001-Replace-CMSIS-RTX-APIs-with-FreeRTOS-APIs.patch rename to components/connectivity/iot_vsocket/integration/patches/0001-Replace-CMSIS-RTX-APIs-with-FreeRTOS-APIs.patch diff --git a/Middleware/ARM/IoT_VSocket-lib/network_startup.c b/components/connectivity/iot_vsocket/integration/src/network_startup.c similarity index 87% rename from Middleware/ARM/IoT_VSocket-lib/network_startup.c rename to components/connectivity/iot_vsocket/integration/src/network_startup.c index 829c67d6..1bf02755 100644 --- a/Middleware/ARM/IoT_VSocket-lib/network_startup.c +++ b/components/connectivity/iot_vsocket/integration/src/network_startup.c @@ -6,16 +6,14 @@ #include #include "FreeRTOS.h" -#include "event_helper.h" +#include "events.h" int32_t network_startup( void ) { - EventBits_t uxBits; - /* The iot-vsocket implementation utilizes the underlying host network * stack for network operation. It is assumed that the host network is * already operational by the time the application runs. */ - uxBits = xEventGroupSetBits( xSystemEvents, EVENT_MASK_NETWORK_UP ); + EventBits_t uxBits = xEventGroupSetBits( xSystemEvents, EVENT_MASK_NETWORK_UP ); if( !( uxBits & EVENT_MASK_NETWORK_UP ) ) { diff --git a/Middleware/ARM/IoT_VSocket-lib/transport_tls_iot_socket.c b/components/connectivity/iot_vsocket/integration/src/transport_tls_iot_socket.c similarity index 99% rename from Middleware/ARM/IoT_VSocket-lib/transport_tls_iot_socket.c rename to components/connectivity/iot_vsocket/integration/src/transport_tls_iot_socket.c index 98b34f1f..1b5805e1 100644 --- a/Middleware/ARM/IoT_VSocket-lib/transport_tls_iot_socket.c +++ b/components/connectivity/iot_vsocket/integration/src/transport_tls_iot_socket.c @@ -7,7 +7,7 @@ #include #include "transport_interface_api.h" #include "iot_socket.h" -#include "tls_helper.h" +#include "iot_tls.h" /* Include header that defines log levels. */ #include "logging_levels.h" diff --git a/Middleware/ARM/IoT_VSocket-lib/AVH b/components/connectivity/iot_vsocket/library similarity index 100% rename from Middleware/ARM/IoT_VSocket-lib/AVH rename to components/connectivity/iot_vsocket/library diff --git a/components/freertos_kernel/CMakeLists.txt b/components/freertos_kernel/CMakeLists.txt new file mode 100644 index 00000000..c644bebf --- /dev/null +++ b/components/freertos_kernel/CMakeLists.txt @@ -0,0 +1,21 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +set(freertos_kernel_SOURCE_DIR + ${CMAKE_CURRENT_LIST_DIR}/library + CACHE INTERNAL + "Path to FreeRTOS-Kernel source code" +) + +set(FREERTOS_HEAP "4" CACHE STRING "" FORCE) + +if(ARM_CORSTONE_BSP_TARGET_PLATFORM STREQUAL "corstone300") + set(FREERTOS_PORT GCC_ARM_CM55_TFM) +elseif(ARM_CORSTONE_BSP_TARGET_PLATFORM STREQUAL "corstone310") + set(FREERTOS_PORT GCC_ARM_CM85_TFM) +endif() + +# FreeRTOS requires the freertos_config library to exist first +add_library(freertos_config INTERFACE) +add_subdirectory(library) diff --git a/Middleware/FreeRTOS/kernel b/components/freertos_kernel/library similarity index 100% rename from Middleware/FreeRTOS/kernel rename to components/freertos_kernel/library diff --git a/components/security/CMakeLists.txt b/components/security/CMakeLists.txt new file mode 100644 index 00000000..0fff8ac1 --- /dev/null +++ b/components/security/CMakeLists.txt @@ -0,0 +1,12 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +# Trusted Firmware-M needs to be added before +# the other security components as its build +# byproducts are listed in the others. +add_subdirectory(trusted_firmware-m) + +add_subdirectory(freertos_ota_pal_psa) +add_subdirectory(freertos_pkcs11_psa) +add_subdirectory(mbedtls) diff --git a/components/security/freertos_ota_pal_psa/CMakeLists.txt b/components/security/freertos_ota_pal_psa/CMakeLists.txt new file mode 100644 index 00000000..114260d4 --- /dev/null +++ b/components/security/freertos_ota_pal_psa/CMakeLists.txt @@ -0,0 +1,11 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +set(freertos_ota_pal_psa_SOURCE_DIR + ${CMAKE_CURRENT_LIST_DIR}/library + CACHE INTERNAL + "Path to FreeRTOS OTA PAL based on PSA API source code" +) + +add_subdirectory(integration) diff --git a/components/security/freertos_ota_pal_psa/integration/CMakeLists.txt b/components/security/freertos_ota_pal_psa/integration/CMakeLists.txt new file mode 100644 index 00000000..6ea6d5bc --- /dev/null +++ b/components/security/freertos_ota_pal_psa/integration/CMakeLists.txt @@ -0,0 +1,32 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +add_library(freertos-ota-pal-psa + ${freertos_ota_pal_psa_SOURCE_DIR}/version/application_version.c + ${freertos_ota_pal_psa_SOURCE_DIR}/ota_pal.c +) + +target_compile_definitions(freertos-ota-pal-psa + PRIVATE + OTA_PAL_CODE_SIGNING_ALGO=OTA_PAL_CODE_SIGNING_RSA + OTA_PAL_SIGNATURE_FORMAT=OTA_PAL_SIGNATURE_RAW +) + +target_include_directories(freertos-ota-pal-psa + PUBLIC + ${freertos_ota_pal_psa_SOURCE_DIR} +) + +add_library(freertos-ota-pal-psa-config INTERFACE) + +target_link_libraries(freertos-ota-pal-psa + PUBLIC + freertos-ota-pal-psa-config + PRIVATE + corepkcs11 + freertos_kernel + helpers-logging + mbedtls + ota-for-aws-iot-embedded-sdk +) diff --git a/Middleware/ARM/freertos-ota-pal-psa-lib/freertos-ota-pal-psa b/components/security/freertos_ota_pal_psa/library similarity index 100% rename from Middleware/ARM/freertos-ota-pal-psa-lib/freertos-ota-pal-psa rename to components/security/freertos_ota_pal_psa/library diff --git a/components/security/freertos_pkcs11_psa/CMakeLists.txt b/components/security/freertos_pkcs11_psa/CMakeLists.txt new file mode 100644 index 00000000..def400cf --- /dev/null +++ b/components/security/freertos_pkcs11_psa/CMakeLists.txt @@ -0,0 +1,11 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +set(freertos_pkcs11_psa_SOURCE_DIR + ${CMAKE_CURRENT_LIST_DIR}/library + CACHE INTERNAL + "Path to FreeRTOS PKCS#11 to PSA shim layer source code" +) + +add_subdirectory(integration) diff --git a/components/security/freertos_pkcs11_psa/integration/CMakeLists.txt b/components/security/freertos_pkcs11_psa/integration/CMakeLists.txt new file mode 100644 index 00000000..6e682998 --- /dev/null +++ b/components/security/freertos_pkcs11_psa/integration/CMakeLists.txt @@ -0,0 +1,30 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +include(ExternalProject) + +add_library(freertos-pkcs11-psa + ${freertos_pkcs11_psa_SOURCE_DIR}/iot_pkcs11_psa_input_format.c + ${freertos_pkcs11_psa_SOURCE_DIR}/iot_pkcs11_psa_object_management.c + ${freertos_pkcs11_psa_SOURCE_DIR}/iot_pkcs11_psa.c +) + +ExternalProject_Get_Property(trusted_firmware-m-build BINARY_DIR) + +target_include_directories(freertos-pkcs11-psa + PUBLIC + ${freertos_pkcs11_psa_SOURCE_DIR} + ${BINARY_DIR}/api_ns/interface/include +) + +add_library(freertos-pkcs11-psa-config INTERFACE) + +target_link_libraries(freertos-pkcs11-psa + PUBLIC + freertos-pkcs11-psa-config + PRIVATE + corepkcs11 + freertos_kernel + mbedtls +) diff --git a/Middleware/ARM/freertos-pkcs11-psa-lib/freertos-pkcs11-psa b/components/security/freertos_pkcs11_psa/library similarity index 100% rename from Middleware/ARM/freertos-pkcs11-psa-lib/freertos-pkcs11-psa rename to components/security/freertos_pkcs11_psa/library diff --git a/components/security/mbedtls/CMakeLists.txt b/components/security/mbedtls/CMakeLists.txt new file mode 100644 index 00000000..7294f149 --- /dev/null +++ b/components/security/mbedtls/CMakeLists.txt @@ -0,0 +1,21 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +set(mbedtls_SOURCE_DIR + ${CMAKE_CURRENT_LIST_DIR}/library + CACHE INTERNAL + "Path to Mbed TLS source code" +) + +# MbedTLS library configuration +# Programs and testing builds are not required +# Note: Mbed TLS specifies an old version of CMake which does not fully support +# overriding a CACHE variable with a regular one, so we need to use the CACHE +# keyword here. +set(ENABLE_PROGRAMS OFF CACHE BOOL "" FORCE) +set(ENABLE_TESTING OFF CACHE BOOL "" FORCE) + +add_subdirectory(library) + +add_subdirectory(integration) diff --git a/components/security/mbedtls/integration/CMakeLists.txt b/components/security/mbedtls/integration/CMakeLists.txt new file mode 100644 index 00000000..dcaca973 --- /dev/null +++ b/components/security/mbedtls/integration/CMakeLists.txt @@ -0,0 +1,47 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +# mbedtls-config library is used to supply configuration for MbedTLS +# IMPORTANT: user applications must provide a "mbedtls_config.h" file which can be an empty +# file or contain MbedTLS options the user wants to override. This can be done by adding +# an include directory to mbed-config that contains the file. +add_library(mbedtls-config INTERFACE) +target_link_libraries(mbedtls + PUBLIC + mbedtls-config +) + +add_library(mbedtls-threading-freertos + src/mbedtls_freertos_port.c +) +target_link_libraries(mbedtls-threading-freertos + PRIVATE + freertos_kernel + mbedtls +) + +target_link_libraries(mbedx509 + PUBLIC + mbedtls-config +) + +target_link_libraries(mbedcrypto + PUBLIC + mbedtls-config +) + +add_library(iot-tls + src/iot_tls.c +) +target_include_directories(iot-tls + PUBLIC + inc +) +target_link_libraries(iot-tls + PUBLIC + mbedtls + corepkcs11 + PRIVATE + helpers-logging +) diff --git a/Middleware/ARM/mbedtls-lib/src/tls_helper.h b/components/security/mbedtls/integration/inc/iot_tls.h similarity index 98% rename from Middleware/ARM/mbedtls-lib/src/tls_helper.h rename to components/security/mbedtls/integration/inc/iot_tls.h index f5361e4d..2dee7c02 100644 --- a/Middleware/ARM/mbedtls-lib/src/tls_helper.h +++ b/components/security/mbedtls/integration/inc/iot_tls.h @@ -23,8 +23,8 @@ * http://www.FreeRTOS.org */ -#ifndef TLS_HELPER_H -#define TLS_HELPER_H +#ifndef IOT_TLS_H +#define IOT_TLS_H #include "mbedtls/ctr_drbg.h" #include "mbedtls/entropy.h" @@ -145,4 +145,4 @@ int32_t TLS_Send( TLSContext_t * pxContext, size_t xMsgLength ); -#endif /* ifndef TLS_HELPER_H */ +#endif /* ifndef IOT_TLS_H */ diff --git a/Middleware/ARM/mbedtls-lib/src/tls_helper.c b/components/security/mbedtls/integration/src/iot_tls.c similarity index 99% rename from Middleware/ARM/mbedtls-lib/src/tls_helper.c rename to components/security/mbedtls/integration/src/iot_tls.c index f65370d3..e7b4d3e4 100644 --- a/Middleware/ARM/mbedtls-lib/src/tls_helper.c +++ b/components/security/mbedtls/integration/src/iot_tls.c @@ -39,7 +39,7 @@ #include #include -#include "tls_helper.h" +#include "iot_tls.h" /* FreeRTOS includes. */ #include "FreeRTOS.h" diff --git a/Middleware/ARM/mbedtls-lib/src/mbedtls_freertos_port.c b/components/security/mbedtls/integration/src/mbedtls_freertos_port.c similarity index 100% rename from Middleware/ARM/mbedtls-lib/src/mbedtls_freertos_port.c rename to components/security/mbedtls/integration/src/mbedtls_freertos_port.c diff --git a/Middleware/ARM/mbedtls-lib/mbedtls b/components/security/mbedtls/library similarity index 100% rename from Middleware/ARM/mbedtls-lib/mbedtls rename to components/security/mbedtls/library diff --git a/components/security/trusted_firmware-m/CMakeLists.txt b/components/security/trusted_firmware-m/CMakeLists.txt new file mode 100644 index 00000000..9ef71da0 --- /dev/null +++ b/components/security/trusted_firmware-m/CMakeLists.txt @@ -0,0 +1,11 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +set(trusted_firmware-m_SOURCE_DIR + ${CMAKE_CURRENT_LIST_DIR}/library + CACHE INTERNAL + "Path to Trusted Firmware-M source code" +) + +add_subdirectory(integration) diff --git a/Middleware/ARM/TF-M/CMakeLists.txt b/components/security/trusted_firmware-m/integration/CMakeLists.txt similarity index 80% rename from Middleware/ARM/TF-M/CMakeLists.txt rename to components/security/trusted_firmware-m/integration/CMakeLists.txt index 214f49b0..884b4196 100644 --- a/Middleware/ARM/TF-M/CMakeLists.txt +++ b/components/security/trusted_firmware-m/integration/CMakeLists.txt @@ -4,12 +4,14 @@ project(tfm-ns-interface) -include(cmake/TF-M-build.cmake) +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake) + +include(BuildTfm) # TF-M NS interface for the non-secure side add_library(tfm-ns-interface ${tfm_ns_interface_generated}) -add_dependencies(tfm-ns-interface tf-m-build) +add_dependencies(tfm-ns-interface trusted_firmware-m-build) target_include_directories(tfm-ns-interface PUBLIC diff --git a/Middleware/ARM/TF-M/cmake/TF-M-build.cmake b/components/security/trusted_firmware-m/integration/cmake/BuildTfm.cmake similarity index 90% rename from Middleware/ARM/TF-M/cmake/TF-M-build.cmake rename to components/security/trusted_firmware-m/integration/cmake/BuildTfm.cmake index 518b3d14..0d22a695 100644 --- a/Middleware/ARM/TF-M/cmake/TF-M-build.cmake +++ b/components/security/trusted_firmware-m/integration/cmake/BuildTfm.cmake @@ -37,11 +37,10 @@ else() endif() ExternalProject_Add( - tf-m-build + trusted_firmware-m-build - # Use code fetched by FetchContent DOWNLOAD_COMMAND "" - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/trusted-firmware-m + SOURCE_DIR ${trusted_firmware-m_SOURCE_DIR} USES_TERMINAL_CONFIGURE ON USES_TERMINAL_BUILD ON @@ -50,7 +49,6 @@ ExternalProject_Add( CMAKE_ARGS -D TFM_TOOLCHAIN_FILE=/${tfm_toolchain_file} - -D CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} ${TFM_CMAKE_ARGS} PATCH_COMMAND @@ -63,6 +61,6 @@ ExternalProject_Add( # The path ${BINARY_DIR} is available after ExternalProject_Add. # Convert to allow projects to use those files. -ExternalProject_Get_Property(tf-m-build BINARY_DIR) +ExternalProject_Get_Property(trusted_firmware-m-build BINARY_DIR) list(TRANSFORM tfm_ns_interface_generated REPLACE "" "${BINARY_DIR}") list(TRANSFORM s_veneers_generated REPLACE "" "${BINARY_DIR}") diff --git a/Middleware/ARM/TF-M/cmake/MergeTfmImages.cmake b/components/security/trusted_firmware-m/integration/cmake/MergeTfmImages.cmake similarity index 90% rename from Middleware/ARM/TF-M/cmake/MergeTfmImages.cmake rename to components/security/trusted_firmware-m/integration/cmake/MergeTfmImages.cmake index c344c96f..3ea21580 100644 --- a/Middleware/ARM/TF-M/cmake/MergeTfmImages.cmake +++ b/components/security/trusted_firmware-m/integration/cmake/MergeTfmImages.cmake @@ -2,10 +2,9 @@ # # SPDX-License-Identifier: MIT -include(ConvertElfToBin) include(ExternalProject) -ExternalProject_Get_Property(tf-m-build BINARY_DIR) +ExternalProject_Get_Property(trusted_firmware-m-build BINARY_DIR) # To merge the bootloader image, TF-M secure image, non-secure user application image, # secure and non-secure provsioning bundle images into one image, their addresses are @@ -37,7 +36,7 @@ function(iot_reference_arm_corstone3xx_tf_m_merge_images target bl2_address tfm_ ${BINARY_DIR}/api_ns/bin/tfm_s_signed.bin -Binary -offset ${tfm_s_address} $/${target}_signed.bin -Binary -offset ${ns_address} ${ns_provisioning_data_param} - ${CMAKE_BINARY_DIR}/Middleware/ARM/TF-M/tf-m-build-prefix/src/tf-m-build-build/api_ns/bin/encrypted_provisioning_bundle.bin -Binary -offset ${s_prov_bundle_address} + ${BINARY_DIR}/api_ns/bin/encrypted_provisioning_bundle.bin -Binary -offset ${s_prov_bundle_address} -o $/${target}_merged.hex COMMAND ${objcopy} -I ihex -O elf32-little diff --git a/Middleware/ARM/TF-M/cmake/SignTfmImage.cmake b/components/security/trusted_firmware-m/integration/cmake/SignTfmImage.cmake similarity index 90% rename from Middleware/ARM/TF-M/cmake/SignTfmImage.cmake rename to components/security/trusted_firmware-m/integration/cmake/SignTfmImage.cmake index 329a55aa..43eb70ff 100644 --- a/Middleware/ARM/TF-M/cmake/SignTfmImage.cmake +++ b/components/security/trusted_firmware-m/integration/cmake/SignTfmImage.cmake @@ -2,11 +2,11 @@ # # SPDX-License-Identifier: MIT -list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/Tools/cmake) +list(APPEND CMAKE_MODULE_PATH ${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/Tools/cmake) include(ConvertElfToBin) include(ExternalProject) -ExternalProject_Get_Property(tf-m-build BINARY_DIR) +ExternalProject_Get_Property(trusted_firmware-m-build BINARY_DIR) function(iot_reference_arm_corstone3xx_tf_m_sign_image target signed_target_name version pad) if(${pad}) @@ -33,7 +33,6 @@ function(iot_reference_arm_corstone3xx_tf_m_sign_image target signed_target_name --confirm $/${target}_unsigned.bin $/${signed_target_name}.bin - COMMAND ${CMAKE_COMMAND} -E echo "-- signed: $/${signed_target_name}.bin" VERBATIM diff --git a/Middleware/ARM/TF-M/trusted-firmware-m b/components/security/trusted_firmware-m/library similarity index 100% rename from Middleware/ARM/TF-M/trusted-firmware-m rename to components/security/trusted_firmware-m/library diff --git a/components/tools/CMakeLists.txt b/components/tools/CMakeLists.txt new file mode 100644 index 00000000..1e8b7080 --- /dev/null +++ b/components/tools/CMakeLists.txt @@ -0,0 +1,7 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +add_subdirectory(freertos_libraries_integration_tests) +add_subdirectory(open_iot_sdk_toolchain) +add_subdirectory(unity) diff --git a/components/tools/freertos_libraries_integration_tests/CMakeLists.txt b/components/tools/freertos_libraries_integration_tests/CMakeLists.txt new file mode 100644 index 00000000..5d451faf --- /dev/null +++ b/components/tools/freertos_libraries_integration_tests/CMakeLists.txt @@ -0,0 +1,11 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +set(freertos_libraries_integration_tests_SOURCE_DIR + ${CMAKE_CURRENT_LIST_DIR}/library + CACHE INTERNAL + "Path to FreeRTOS-Libraries-Integration-Tests source code" +) + +add_subdirectory(integration) diff --git a/components/tools/freertos_libraries_integration_tests/integration/CMakeLists.txt b/components/tools/freertos_libraries_integration_tests/integration/CMakeLists.txt new file mode 100644 index 00000000..61c2bd51 --- /dev/null +++ b/components/tools/freertos_libraries_integration_tests/integration/CMakeLists.txt @@ -0,0 +1,89 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +add_library(freertos-libraries-integration-tests-config INTERFACE) + +include(${freertos_libraries_integration_tests_SOURCE_DIR}/qualification_test.cmake) +include(${freertos_libraries_integration_tests_SOURCE_DIR}/src/mqtt_test.cmake) +include(${freertos_libraries_integration_tests_SOURCE_DIR}/src/pkcs11_test.cmake) +include(${freertos_libraries_integration_tests_SOURCE_DIR}/src/ota_pal_test.cmake) +include(${freertos_libraries_integration_tests_SOURCE_DIR}/src/transport_interface_test.cmake) + +add_library(freertos-libraries-integration-tests-mqtt + ${MQTT_TEST_SOURCES} +) +target_include_directories(freertos-libraries-integration-tests-mqtt + PUBLIC + ${MQTT_TEST_INCLUDE_DIRS} +) +target_link_libraries(freertos-libraries-integration-tests-mqtt + PRIVATE + coremqtt + freertos-libraries-integration-tests-config + unity +) + +add_library(freertos-libraries-integration-tests-ota-pal + ${OTA_PAL_TEST_SOURCES} +) +target_include_directories(freertos-libraries-integration-tests-ota-pal + PUBLIC + ${OTA_PAL_TEST_INCLUDE_DIRS} +) +target_link_libraries(freertos-libraries-integration-tests-ota-pal + PRIVATE + freertos-libraries-integration-tests-config + freertos-ota-pal-psa + ota-for-aws-iot-embedded-sdk + unity +) + +add_library(freertos-libraries-integration-tests-pkcs11 + ${PKCS11_TEST_SOURCES} +) +# Do not use ${PKCS11_TEST_INCLUDE_DIRS} so applications can provide provisioning +target_include_directories(freertos-libraries-integration-tests-pkcs11 + PUBLIC + ${freertos_libraries_integration_tests_SOURCE_DIR}/src/pkcs11 + ${freertos_libraries_integration_tests_SOURCE_DIR}/src/common +) +target_link_libraries(freertos-libraries-integration-tests-pkcs11 + PRIVATE + corepkcs11 + freertos-libraries-integration-tests-config + mbedtls + unity +) + +add_library(freertos-libraries-integration-tests-qualification + ${QUALIFICATION_TEST_SOURCES} +) +target_include_directories(freertos-libraries-integration-tests-qualification + PUBLIC + ${QUALIFICATION_TEST_INCLUDE_DIRS} + ${freertos_libraries_integration_tests_SOURCE_DIR}/src/common + ${TRANSPORT_TEST_INCLUDE_DIRS} +) +target_link_libraries(freertos-libraries-integration-tests-qualification + PRIVATE + coremqtt + freertos-libraries-integration-tests-config + freertos-libraries-integration-tests-mqtt + freertos-libraries-integration-tests-ota-pal + freertos-libraries-integration-tests-pkcs11 +) + +add_library(freertos-libraries-integration-tests-transport + ${TRANSPORT_TEST_SOURCES} +) +target_include_directories(freertos-libraries-integration-tests-transport + PUBLIC + ${TRANSPORT_TEST_INCLUDE_DIRS} +) +target_link_libraries(freertos-libraries-integration-tests-transport + PRIVATE + coremqtt + freertos-libraries-integration-tests-config + unity +) diff --git a/Middleware/FreeRTOS/FreeRTOS-Libraries-Integration-Tests b/components/tools/freertos_libraries_integration_tests/library similarity index 100% rename from Middleware/FreeRTOS/FreeRTOS-Libraries-Integration-Tests rename to components/tools/freertos_libraries_integration_tests/library diff --git a/components/tools/open_iot_sdk_toolchain/CMakeLists.txt b/components/tools/open_iot_sdk_toolchain/CMakeLists.txt new file mode 100644 index 00000000..5dfe775e --- /dev/null +++ b/components/tools/open_iot_sdk_toolchain/CMakeLists.txt @@ -0,0 +1,9 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +set(open_iot_sdk_toolchain_SOURCE_DIR + ${CMAKE_CURRENT_LIST_DIR}/library + CACHE INTERNAL + "Path to Open IoT SDK CMake Toolchain source code" +) diff --git a/toolchains b/components/tools/open_iot_sdk_toolchain/library similarity index 100% rename from toolchains rename to components/tools/open_iot_sdk_toolchain/library diff --git a/components/tools/unity/CMakeLists.txt b/components/tools/unity/CMakeLists.txt new file mode 100644 index 00000000..47064792 --- /dev/null +++ b/components/tools/unity/CMakeLists.txt @@ -0,0 +1,13 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +set(unity_SOURCE_DIR + ${CMAKE_CURRENT_LIST_DIR}/library + CACHE INTERNAL + "Path to Unity Test source code" +) + +set(UNITY_EXTENSION_FIXTURE ON CACHE BOOL "") + +add_subdirectory(library) diff --git a/Middleware/Unity b/components/tools/unity/library similarity index 100% rename from Middleware/Unity rename to components/tools/unity/library diff --git a/manifest.yml b/manifest.yml index 8b8dfeaf..e3821964 100644 --- a/manifest.yml +++ b/manifest.yml @@ -9,130 +9,130 @@ dependencies: repository: type: "git" url: "https://github.com/FreeRTOS/FreeRTOS-Kernel.git" - path: "Middleware/FreeRTOS/kernel" + path: "components/freertos_kernel/library" - name: "arm-corstone-platform-bsp" license: "Apache-2.0" version: "v0.2.0" repository: type: "git" url: "https://git.gitlab.arm.com/iot/open-iot-sdk/arm-corstone-platform-bsp.git" - path: "Bsp/arm-corstone-platform-bsp" + path: "Bsp/library" - name: "trusted-firmware-m" license: "BSD-3-Clause" version: "TF-Mv2.0.0" repository: type: "git" url: "https://git.trustedfirmware.org/TF-M/trusted-firmware-m.git" - path: "Middleware/ARM/TF-M/trusted-firmware-m" + path: "components/security/trusted_firmware-m/library" - name: "mbedtls" license: "Apache-2.0" version: "v2.28.3" repository: type: "git" url: "https://github.com/Mbed-TLS/mbedtls.git" - path: "Middleware/ARM/mbedtls-lib/mbedtls" + path: "components/security/mbedtls/library" - name: "IoT_Socket" license: "Apache-2.0" version: "1e15f55ae08c2169c0e4a59216e78a4906a66af8" repository: type: "git" url: "https://github.com/MDK-Packs/IoT_Socket.git" - path: "Middleware/ARM/IoT_Socket-lib/IoT_Socket" + path: "components/connectivity/iot_socket/library" - name: "AVH" license: "Apache-2.0" version: "ab37f6126c94fee7bbd061f77716745dfbb77592" repository: type: "git" url: "https://github.com/ARM-software/AVH.git" - path: "Middleware/ARM/IoT_VSocket-lib/AVH" + path: "components/connectivity/iot_vsocket/library" - name: "freertos-pkcs11-psa" license: "MIT" version: "40b4868b38720757f88615f0e705ad086956967a" repository: type: "git" url: "https://github.com/Linaro/freertos-pkcs11-psa.git" - path: "Middleware/ARM/freertos-pkcs11-psa-lib/freertos-pkcs11-psa" + path: "components/security/freertos_pkcs11_psa/library" - name: "freertos-ota-pal-psa" license: "MIT" version: "08e6c6eeb978f28d873f9a12c58882b88f1b7235" repository: type: "git" url: "https://github.com/Linaro/freertos-ota-pal-psa.git" - path: "Middleware/ARM/freertos-ota-pal-psa-lib/freertos-ota-pal-psa" + path: "components/security/freertos_ota_pal_psa/library" - name: "coreMQTT-Agent" license: "MIT" version: "v1.2.0" repository: type: "git" url: "https://github.com/FreeRTOS/coreMQTT-Agent.git" - path: "Middleware/AWS/coreMQTT-Agent" + path: "components/aws_iot/coremqtt_agent/library" - name: "coreMQTT" license: "MIT" version: "v2.1.1" repository: type: "git" url: "https://github.com/FreeRTOS/coreMQTT.git" - path: "Middleware/AWS/coreMQTT" + path: "components/aws_iot/coremqtt/library" - name: "coreJSON" license: "MIT" version: "a1c702e6d216222ef45a520d8ba2aba315a1ea78" repository: type: "git" url: "https://github.com/FreeRTOS/coreJSON.git" - path: "Middleware/AWS/coreJSON" + path: "components/aws_iot/corejson/library" - name: "corePKCS11" license: "MIT" version: "ccba578b731c5f7ce351704c0a1f49831f640718" repository: type: "git" url: "https://github.com/FreeRTOS/corePKCS11.git" - path: "Middleware/AWS/corePKCS11" + path: "components/aws_iot/corepkcs11/library" - name: "backoffAlgorithm" license: "MIT" version: "5db5777c8fa787f0b7851adc8a7e3e12985e7667" repository: type: "git" url: "https://github.com/FreeRTOS/backoffAlgorithm.git" - path: "Middleware/AWS/backoffAlgorithm" + path: "components/connectivity/backoff_algorithm/library" - name: "ota-for-aws-iot-embedded-sdk" license: "MIT" version: "406415ef38d9f0fbabd69735623008fd090043b3" repository: type: "git" url: "https://github.com/aws/ota-for-aws-iot-embedded-sdk.git" - path: "Middleware/AWS/ota-for-aws-iot-embedded-sdk" + path: "components/aws_iot/ota_for_aws_iot_embedded_sdk/library" - name: "tinycbor" license: "MIT" version: "9924cfed3b95ad6de299ae675064430fdb886216" repository: type: "git" url: "https://github.com/intel/tinycbor" - path: "Middleware/AWS/tinycbor" - - name: "toolchain" + path: "components/aws_iot/tinycbor/library" + - name: "toolchains" license: "Apache-2.0" version: "v2022.09" repository: type: "git" url: "https://git.gitlab.arm.com/iot/open-iot-sdk/toolchain.git" - path: "toolchains" + path: "components/tools/open_iot_sdk_toolchain/library" - name: "FreeRTOS-Libraries-Integration-Tests" license: "MIT" version: "202210.01" repository: type: "git" url: "https://github.com/FreeRTOS/FreeRTOS-Libraries-Integration-Tests" - path: "Middleware/FreeRTOS/FreeRTOS-Libraries-Integration-Tests" + path: "components/tools/freertos_libraries_integration_tests/library" - name: "Unity" license: "MIT" version: "v2.5.2" repository: type: "git" url: "https://github.com/ThrowTheSwitch/Unity.git" - path: "Middleware/Unity" + path: "components/tools/unity/library" - name: "FreeRTOS-Plus-TCP" license: "MIT" version: "3d5ee0e821cab38cb6e6265fcf1ce7552a54519d" repository: type: "git" url: "https://github.com/FreeRTOS/FreeRTOS-Plus-TCP.git" - path: "Middleware/FreeRTOS/FreeRTOS-Plus-TCP-lib/FreeRTOS-Plus-TCP" + path: "components/connectivity/freertos_plus_tcp/library" diff --git a/release_changes/202311141614.change b/release_changes/202311141614.change new file mode 100644 index 00000000..f57bcdc9 --- /dev/null +++ b/release_changes/202311141614.change @@ -0,0 +1 @@ +Re-structure the project to ease maintenance From 744be23940343cb7678d4c0a66d7982c1e4a19d5 Mon Sep 17 00:00:00 2001 From: Hugues Kamba-Mpiana Date: Mon, 9 Oct 2023 09:24:47 +0100 Subject: [PATCH 02/22] cmake: Provide components and BSP as part of the FRI Rather having applications include individual parts of the FRI, include all of its parts (BSP and components) in the root level CMakeLists.txt To build application, point CMake to each application's main CMakeLists.txt as application should be treated as the root level CMakeLists.txt. This approach also shows how users who may want to include the FRI as a dependency to their project can build applications by treating their applications as the root level project. Additionally: * Raise an error if the minimum CMake version requirement is not met. * Rename FRI CMake project to match FRI project name. * Expose Tools/cmake subdir to CMake to find additional modules Signed-off-by: Hugues Kamba-Mpiana --- .github/workflows/build.yaml | 6 +++--- .gitlab-ci.yml | 8 ++++---- CMakeLists.txt | 17 +++++------------ Tools/scripts/build.sh | 17 ++++++++++++++--- Tools/scripts/run.sh | 4 ++-- 5 files changed, 28 insertions(+), 24 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 3590f039..7ee3f9fa 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -60,9 +60,9 @@ jobs: shell: bash run: | tar -czf gnu_build.tar.gz \ - build/Projects/aws-iot-example/aws-iot-example_merged.elf \ - build/Projects/aws-iot-example/aws-iot-example-update_signed.bin \ - build/Projects/aws-iot-example/update-signature.txt + build/aws-iot-example_merged.elf \ + build/aws-iot-example-update_signed.bin \ + build/update-signature.txt - name: Upload Build Artifacts uses: actions/upload-artifact@v3 with: diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2cbb5dcf..f0a35f72 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -79,13 +79,13 @@ build-applications: - | if [ $APP == "aws-iot-example" ];then tar -czf ${TARGET}_${APP}_${TOOLCHAIN}_build.tar.gz \ - build/Projects/${APP}/${APP}_merged.elf \ - build/Projects/${APP}/${APP}-update_signed.bin \ - build/Projects/${APP}/update-signature.txt \ + build/${APP}_merged.elf \ + build/${APP}-update_signed.bin \ + build/update-signature.txt \ Config/aws_configs else tar -czf ${TARGET}_${APP}_${TOOLCHAIN}_build.tar.gz \ - build/Projects/${APP}/${APP}_merged.elf + build/${APP}_merged.elf fi parallel: matrix: diff --git a/CMakeLists.txt b/CMakeLists.txt index 62ffc006..e824438c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,18 +2,11 @@ # # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.21) +cmake_minimum_required(VERSION 3.21.0 FATAL_ERROR) -project(arm-featured-reference-integration) +project(iot-reference-arm-corstone3xx LANGUAGES C ASM) -# Declare root and other build paths -set(PRJ_DIR "${CMAKE_CURRENT_SOURCE_DIR}") +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/Tools/cmake) -# Add examples targets -if(EXAMPLE STREQUAL "blinky") - add_subdirectory(Projects/blinky) -endif() - -if(EXAMPLE STREQUAL "aws-iot-example") - add_subdirectory(Projects/aws-iot-example) -endif() +add_subdirectory(Bsp) +add_subdirectory(components EXCLUDE_FROM_ALL) diff --git a/Tools/scripts/build.sh b/Tools/scripts/build.sh index 13003476..0713f3d1 100755 --- a/Tools/scripts/build.sh +++ b/Tools/scripts/build.sh @@ -41,7 +41,16 @@ function build_with_cmake { set -ex # Note: A bug in CMake force us to set the toolchain here - cmake -G Ninja -S . -B $BUILD_PATH --toolchain=$TOOLCHAIN_FILE -DCMAKE_SYSTEM_PROCESSOR=$TARGET_PROCESSOR -DARM_CORSTONE_BSP_TARGET_PLATFORM=$TARGET -DEXAMPLE=$EXAMPLE -DINTEGRATION_TESTS=$INTEGRATION_TESTS -DAWS_CLIENT_PRIVATE_KEY_PEM_PATH=$PRIVATE_KEY_PATH -DAWS_CLIENT_CERTIFICATE_PEM_PATH=$CERTIFICATE_PATH + cmake \ + -G Ninja --toolchain=$TOOLCHAIN_FILE \ + -B $BUILD_PATH \ + -S $PATH_TO_SOURCE \ + -DCMAKE_SYSTEM_PROCESSOR=$TARGET_PROCESSOR \ + -DARM_CORSTONE_BSP_TARGET_PLATFORM=$TARGET \ + -DINTEGRATION_TESTS=$INTEGRATION_TESTS \ + -DAWS_CLIENT_PRIVATE_KEY_PEM_PATH=$PRIVATE_KEY_PATH \ + -DAWS_CLIENT_CERTIFICATE_PEM_PATH=$CERTIFICATE_PATH \ + -DIOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR=$ROOT if [[ $BUILD -ne 0 ]]; then cmake --build $BUILD_PATH --target $EXAMPLE @@ -130,9 +139,11 @@ done case "$1" in blinky) EXAMPLE="$1" + PATH_TO_SOURCE="$ROOT/Projects/blinky" ;; aws-iot-example) EXAMPLE="$1" + PATH_TO_SOURCE="$ROOT/Projects/aws-iot-example" ;; *) echo "Missing example " @@ -157,10 +168,10 @@ esac case "$TOOLCHAIN" in ARMCLANG ) - TOOLCHAIN_FILE="toolchains/toolchain-armclang.cmake" + TOOLCHAIN_FILE="$ROOT/components/tools/open_iot_sdk_toolchain/library/toolchain-armclang.cmake" ;; GNU ) - TOOLCHAIN_FILE="toolchains/toolchain-arm-none-eabi-gcc.cmake" + TOOLCHAIN_FILE="$ROOT/components/tools/open_iot_sdk_toolchain/library/toolchain-arm-none-eabi-gcc.cmake" ;; * ) echo "Invalid toolchain " diff --git a/Tools/scripts/run.sh b/Tools/scripts/run.sh index cf04a574..0c2bf396 100755 --- a/Tools/scripts/run.sh +++ b/Tools/scripts/run.sh @@ -97,11 +97,11 @@ esac case "$1" in blinky) EXAMPLE="$1" - MERGED_IMAGE_PATH="$BUILD_PATH/Projects/$EXAMPLE/blinky_merged.elf" + MERGED_IMAGE_PATH="$BUILD_PATH/blinky_merged.elf" ;; aws-iot-example) EXAMPLE="$1" - MERGED_IMAGE_PATH="$BUILD_PATH/Projects/$EXAMPLE/aws-iot-example_merged.elf" + MERGED_IMAGE_PATH="$BUILD_PATH/aws-iot-example_merged.elf" ;; *) echo "Usage: $0 " >&2 From 60ad761a356954f2abb25bda1180c90e46410b19 Mon Sep 17 00:00:00 2001 From: Hugues Kamba-Mpiana Date: Mon, 9 Oct 2023 09:26:04 +0100 Subject: [PATCH 03/22] apps: Do not share configuration files This allows each application to apply configurations it needs without changing the behaviour of other applications as was previously the case since they share configuration files. Signed-off-by: Hugues Kamba-Mpiana --- .github/workflows/build.yaml | 2 +- .gitlab-ci.yml | 16 +- Docs/aws-iot-example.md | 10 +- .../aws-iot-example/configs}/CMakeLists.txt | 1 + .../configs}/app_config/CMakeLists.txt | 0 .../configs}/app_config/app_config.h | 0 .../configs/aws_configs/CMakeLists.txt | 38 +++ .../aws_configs/aws_clientcredential.h | 0 .../configs}/aws_configs/aws_mqtt_config.h | 0 .../aws_configs/aws_secure_sockets_config.h | 0 .../configs}/aws_configs/core_mqtt_config.h | 0 .../configs}/aws_configs/core_pkcs11_config.h | 0 .../configs}/aws_configs/demo_config.h | 0 .../iot_default_root_certificates.h | 0 .../aws_configs/mqtt_agent_demo_config.h | 0 .../mqtt_demo_mutual_auth_config.h | 0 .../configs}/aws_configs/ota_config.h | 0 .../configs}/aws_configs/ota_demo_config.h | 0 .../configs/freertos-config/CMakeLists.txt | 20 ++ .../configs}/freertos-config/FreeRTOSConfig.h | 0 .../freertos-config/FreeRTOSIPConfig.h | 0 .../configs}/mbedtls_config/CMakeLists.txt | 0 .../mbedtls_config/aws_mbedtls_config.h | 0 .../configs}/mbedtls_config/threading_alt.h | 0 .../configs}/tfm-config/project_config.h | 0 Projects/blinky/configs/CMakeLists.txt | 6 + .../blinky/configs/app_config}/CMakeLists.txt | 4 +- .../blinky/configs/app_config/app_config.h | 45 ++++ .../configs/freertos-config/CMakeLists.txt | 20 ++ .../configs/freertos-config/FreeRTOSConfig.h | 237 ++++++++++++++++++ .../configs/tfm-config/project_config.h | 86 +++++++ 31 files changed, 469 insertions(+), 16 deletions(-) rename {Config => Projects/aws-iot-example/configs}/CMakeLists.txt (85%) rename {Config => Projects/aws-iot-example/configs}/app_config/CMakeLists.txt (100%) rename {Config => Projects/aws-iot-example/configs}/app_config/app_config.h (100%) create mode 100644 Projects/aws-iot-example/configs/aws_configs/CMakeLists.txt rename {Config => Projects/aws-iot-example/configs}/aws_configs/aws_clientcredential.h (100%) rename {Config => Projects/aws-iot-example/configs}/aws_configs/aws_mqtt_config.h (100%) rename {Config => Projects/aws-iot-example/configs}/aws_configs/aws_secure_sockets_config.h (100%) rename {Config => Projects/aws-iot-example/configs}/aws_configs/core_mqtt_config.h (100%) rename {Config => Projects/aws-iot-example/configs}/aws_configs/core_pkcs11_config.h (100%) rename {Config => Projects/aws-iot-example/configs}/aws_configs/demo_config.h (100%) rename {Config => Projects/aws-iot-example/configs}/aws_configs/iot_default_root_certificates.h (100%) rename {Config => Projects/aws-iot-example/configs}/aws_configs/mqtt_agent_demo_config.h (100%) rename {Config => Projects/aws-iot-example/configs}/aws_configs/mqtt_demo_mutual_auth_config.h (100%) rename {Config => Projects/aws-iot-example/configs}/aws_configs/ota_config.h (100%) rename {Config => Projects/aws-iot-example/configs}/aws_configs/ota_demo_config.h (100%) create mode 100644 Projects/aws-iot-example/configs/freertos-config/CMakeLists.txt rename {Config => Projects/aws-iot-example/configs}/freertos-config/FreeRTOSConfig.h (100%) rename {Config => Projects/aws-iot-example/configs}/freertos-config/FreeRTOSIPConfig.h (100%) rename {Config => Projects/aws-iot-example/configs}/mbedtls_config/CMakeLists.txt (100%) rename {Config => Projects/aws-iot-example/configs}/mbedtls_config/aws_mbedtls_config.h (100%) rename {Config => Projects/aws-iot-example/configs}/mbedtls_config/threading_alt.h (100%) rename {Config => Projects/aws-iot-example/configs}/tfm-config/project_config.h (100%) create mode 100644 Projects/blinky/configs/CMakeLists.txt rename {Config/aws_configs => Projects/blinky/configs/app_config}/CMakeLists.txt (65%) create mode 100644 Projects/blinky/configs/app_config/app_config.h create mode 100644 Projects/blinky/configs/freertos-config/CMakeLists.txt create mode 100644 Projects/blinky/configs/freertos-config/FreeRTOSConfig.h create mode 100644 Projects/blinky/configs/tfm-config/project_config.h diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 7ee3f9fa..d96634ae 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -49,7 +49,7 @@ jobs: export IOT_OTA_CLIENT_CERT="dummy_certificate" export IOT_OTA_CLIENT_PRIV="dummy_priv_key" export IOT_OTA_CLIENT_PUB="dummy_pub_key" - ./ci/generate_credentials.sh -f -p Config/aws_configs + ./ci/generate_credentials.sh -f -p Projects/aws-iot-example/configs/aws_configs git config --global user.email "ci@example.com" git config --global user.name "ci" - name: Build the project diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f0a35f72..7363857e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -72,7 +72,7 @@ build-applications: stage: build extends: .base_job script: - - ./ci/generate_credentials.sh -f -p Config/aws_configs + - ./ci/generate_credentials.sh -f -p Projects/${APP}/configs/aws_configs - git config --global user.email "ci@example.com" - git config --global user.name "ci" - ./Tools/scripts/build.sh ${APP} --target $TARGET --toolchain $TOOLCHAIN --certificate_path $PWD/certificate.pem --private_key_path $PWD/private_key.pem @@ -82,7 +82,7 @@ build-applications: build/${APP}_merged.elf \ build/${APP}-update_signed.bin \ build/update-signature.txt \ - Config/aws_configs + Projects/${APP}/configs/aws_configs else tar -czf ${TARGET}_${APP}_${TOOLCHAIN}_build.tar.gz \ build/${APP}_merged.elf @@ -103,7 +103,7 @@ test-applications-output: - tar xf ${TARGET}_${APP}_${TOOLCHAIN}_build.tar.gz - | pytest -s Tools/tests/test_application_output.py \ - --build-artefacts-path "build/Projects/${APP}" \ + --build-artefacts-path "build" \ --fvp $FVP_BIN \ --merged-elf-name "${APP}_merged.elf" \ --timeout-seconds 600 \ @@ -121,9 +121,9 @@ test-ota: - tar xf ${TARGET}_${APP}_${TOOLCHAIN}_build.tar.gz - | pytest -s Tools/tests/test_ota.py \ - --build-artefacts-path "build/Projects/${APP}" \ + --build-artefacts-path "build" \ --fvp $FVP_BIN \ - --credentials-path "Config/aws_configs" \ + --credentials-path "Projects/${APP}/configs/aws_configs" \ --merged-elf-name "${APP}_merged.elf" \ --signed-update-bin-name "${APP}-update_signed.bin" \ --timeout-seconds 900 \ @@ -142,7 +142,7 @@ integration-tests: rules: - if: ( $SCHEDULED_JOB_TO_RUN == "integration-tests" ) script: - - ./ci/generate_credentials.sh -f -p Config/aws_configs + - ./ci/generate_credentials.sh -f -p Projects/${APP}/configs/aws_configs - git config --global user.email "ci@example.com" - git config --global user.name "ci" - ./Tools/scripts/build.sh -q ${APP} @@ -152,9 +152,9 @@ integration-tests: - sleep 1 - | pytest -s Tools/tests/test_integration.py \ - --build-artefacts-path "build/Projects/${APP}" \ + --build-artefacts-path "build" \ --fvp $FVP_BIN \ - --credentials-path "Config/aws_configs" \ + --credentials-path "Projects/${APP}/configs/aws_configs" \ --merged-elf-name "${APP}-tests_merged.elf" \ --signed-update-bin-name "${APP}-tests-update_signed.bin" parallel: diff --git a/Docs/aws-iot-example.md b/Docs/aws-iot-example.md index f7203240..94afcdf7 100644 --- a/Docs/aws-iot-example.md +++ b/Docs/aws-iot-example.md @@ -184,7 +184,7 @@ policies to it, the representative values must be added to your application to ensure connectivity with your AWS account. Within the application directory that you are using, edit the -`Config/aws_configs/aws_clientcredential.h` file and set values for specified +`configs/aws_configs/aws_clientcredential.h` file and set values for specified user defines called out below. `clientcredentialMQTT_BROKER_ENDPOINT` @@ -336,7 +336,7 @@ To see messages being sent by the application: 1. In the **Subscription topic** field enter the topic name `pubsub//task_0` > `mqtt-client-identifier` value is defined in - `Config/aws_configs/aws_clientcredential.h` as + `configs/aws_configs/aws_clientcredential.h` as `clientcredentialIOT_THING_NAME`. 1. In the **MQTT payload display** combo box select `Display payloads as strings (more accurate)` @@ -540,10 +540,10 @@ policies to it, the representative values must be added to your application to ensure connectivity with AWS IoT Core Device Advisor. Set the macro `appCONFIG_DEVICE_ADVISOR_TEST_ACTIVE` in -`Config/app_config/app_config.h` to 1. +`configs/app_config/app_config.h` to 1. Within the application directory that you are using, edit the -`Config/aws_configs/aws_clientcredential.h` file and set values for specified +`configs/aws_configs/aws_clientcredential.h` file and set values for specified user defines called out below. `clientcredentialMQTT_BROKER_ENDPOINT` @@ -570,7 +570,7 @@ Save and close the file. Next insert the keys that are in the certificates you have downloaded when you created the thing. Edit the file -`Config/aws_configs/aws_clientcredential_keys.h` replacing the existing keys +`configs/aws_configs/aws_clientcredential_keys.h` replacing the existing keys with yours. `keyCLIENT_CERTIFICATE_PEM` diff --git a/Config/CMakeLists.txt b/Projects/aws-iot-example/configs/CMakeLists.txt similarity index 85% rename from Config/CMakeLists.txt rename to Projects/aws-iot-example/configs/CMakeLists.txt index ff644a65..8ba83506 100644 --- a/Config/CMakeLists.txt +++ b/Projects/aws-iot-example/configs/CMakeLists.txt @@ -4,4 +4,5 @@ add_subdirectory(app_config) add_subdirectory(aws_configs) +add_subdirectory(freertos-config) add_subdirectory(mbedtls_config) diff --git a/Config/app_config/CMakeLists.txt b/Projects/aws-iot-example/configs/app_config/CMakeLists.txt similarity index 100% rename from Config/app_config/CMakeLists.txt rename to Projects/aws-iot-example/configs/app_config/CMakeLists.txt diff --git a/Config/app_config/app_config.h b/Projects/aws-iot-example/configs/app_config/app_config.h similarity index 100% rename from Config/app_config/app_config.h rename to Projects/aws-iot-example/configs/app_config/app_config.h diff --git a/Projects/aws-iot-example/configs/aws_configs/CMakeLists.txt b/Projects/aws-iot-example/configs/aws_configs/CMakeLists.txt new file mode 100644 index 00000000..c89696ee --- /dev/null +++ b/Projects/aws-iot-example/configs/aws_configs/CMakeLists.txt @@ -0,0 +1,38 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +target_include_directories(coremqtt-config + INTERFACE + . +) + +target_link_libraries(coremqtt-config + INTERFACE + helpers-logging +) + +target_compile_definitions(coremqtt-agent-config + INTERFACE + MQTT_AGENT_DO_NOT_USE_CUSTOM_CONFIG +) + +target_include_directories(corepkcs11-config + INTERFACE + . +) + +target_include_directories(freertos-ota-pal-psa-config + INTERFACE + . +) + +target_include_directories(freertos-pkcs11-psa-config + INTERFACE + . +) + +target_include_directories(ota-for-aws-iot-embedded-sdk-config + INTERFACE + . +) diff --git a/Config/aws_configs/aws_clientcredential.h b/Projects/aws-iot-example/configs/aws_configs/aws_clientcredential.h similarity index 100% rename from Config/aws_configs/aws_clientcredential.h rename to Projects/aws-iot-example/configs/aws_configs/aws_clientcredential.h diff --git a/Config/aws_configs/aws_mqtt_config.h b/Projects/aws-iot-example/configs/aws_configs/aws_mqtt_config.h similarity index 100% rename from Config/aws_configs/aws_mqtt_config.h rename to Projects/aws-iot-example/configs/aws_configs/aws_mqtt_config.h diff --git a/Config/aws_configs/aws_secure_sockets_config.h b/Projects/aws-iot-example/configs/aws_configs/aws_secure_sockets_config.h similarity index 100% rename from Config/aws_configs/aws_secure_sockets_config.h rename to Projects/aws-iot-example/configs/aws_configs/aws_secure_sockets_config.h diff --git a/Config/aws_configs/core_mqtt_config.h b/Projects/aws-iot-example/configs/aws_configs/core_mqtt_config.h similarity index 100% rename from Config/aws_configs/core_mqtt_config.h rename to Projects/aws-iot-example/configs/aws_configs/core_mqtt_config.h diff --git a/Config/aws_configs/core_pkcs11_config.h b/Projects/aws-iot-example/configs/aws_configs/core_pkcs11_config.h similarity index 100% rename from Config/aws_configs/core_pkcs11_config.h rename to Projects/aws-iot-example/configs/aws_configs/core_pkcs11_config.h diff --git a/Config/aws_configs/demo_config.h b/Projects/aws-iot-example/configs/aws_configs/demo_config.h similarity index 100% rename from Config/aws_configs/demo_config.h rename to Projects/aws-iot-example/configs/aws_configs/demo_config.h diff --git a/Config/aws_configs/iot_default_root_certificates.h b/Projects/aws-iot-example/configs/aws_configs/iot_default_root_certificates.h similarity index 100% rename from Config/aws_configs/iot_default_root_certificates.h rename to Projects/aws-iot-example/configs/aws_configs/iot_default_root_certificates.h diff --git a/Config/aws_configs/mqtt_agent_demo_config.h b/Projects/aws-iot-example/configs/aws_configs/mqtt_agent_demo_config.h similarity index 100% rename from Config/aws_configs/mqtt_agent_demo_config.h rename to Projects/aws-iot-example/configs/aws_configs/mqtt_agent_demo_config.h diff --git a/Config/aws_configs/mqtt_demo_mutual_auth_config.h b/Projects/aws-iot-example/configs/aws_configs/mqtt_demo_mutual_auth_config.h similarity index 100% rename from Config/aws_configs/mqtt_demo_mutual_auth_config.h rename to Projects/aws-iot-example/configs/aws_configs/mqtt_demo_mutual_auth_config.h diff --git a/Config/aws_configs/ota_config.h b/Projects/aws-iot-example/configs/aws_configs/ota_config.h similarity index 100% rename from Config/aws_configs/ota_config.h rename to Projects/aws-iot-example/configs/aws_configs/ota_config.h diff --git a/Config/aws_configs/ota_demo_config.h b/Projects/aws-iot-example/configs/aws_configs/ota_demo_config.h similarity index 100% rename from Config/aws_configs/ota_demo_config.h rename to Projects/aws-iot-example/configs/aws_configs/ota_demo_config.h diff --git a/Projects/aws-iot-example/configs/freertos-config/CMakeLists.txt b/Projects/aws-iot-example/configs/freertos-config/CMakeLists.txt new file mode 100644 index 00000000..088f7199 --- /dev/null +++ b/Projects/aws-iot-example/configs/freertos-config/CMakeLists.txt @@ -0,0 +1,20 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +target_include_directories(freertos_config SYSTEM + INTERFACE + . +) + +target_compile_definitions(freertos_config + INTERFACE + projCOVERAGE_TEST=0 +) + +target_link_libraries(freertos_config + INTERFACE + tfm-ns-interface + app-config + fri-bsp +) diff --git a/Config/freertos-config/FreeRTOSConfig.h b/Projects/aws-iot-example/configs/freertos-config/FreeRTOSConfig.h similarity index 100% rename from Config/freertos-config/FreeRTOSConfig.h rename to Projects/aws-iot-example/configs/freertos-config/FreeRTOSConfig.h diff --git a/Config/freertos-config/FreeRTOSIPConfig.h b/Projects/aws-iot-example/configs/freertos-config/FreeRTOSIPConfig.h similarity index 100% rename from Config/freertos-config/FreeRTOSIPConfig.h rename to Projects/aws-iot-example/configs/freertos-config/FreeRTOSIPConfig.h diff --git a/Config/mbedtls_config/CMakeLists.txt b/Projects/aws-iot-example/configs/mbedtls_config/CMakeLists.txt similarity index 100% rename from Config/mbedtls_config/CMakeLists.txt rename to Projects/aws-iot-example/configs/mbedtls_config/CMakeLists.txt diff --git a/Config/mbedtls_config/aws_mbedtls_config.h b/Projects/aws-iot-example/configs/mbedtls_config/aws_mbedtls_config.h similarity index 100% rename from Config/mbedtls_config/aws_mbedtls_config.h rename to Projects/aws-iot-example/configs/mbedtls_config/aws_mbedtls_config.h diff --git a/Config/mbedtls_config/threading_alt.h b/Projects/aws-iot-example/configs/mbedtls_config/threading_alt.h similarity index 100% rename from Config/mbedtls_config/threading_alt.h rename to Projects/aws-iot-example/configs/mbedtls_config/threading_alt.h diff --git a/Config/tfm-config/project_config.h b/Projects/aws-iot-example/configs/tfm-config/project_config.h similarity index 100% rename from Config/tfm-config/project_config.h rename to Projects/aws-iot-example/configs/tfm-config/project_config.h diff --git a/Projects/blinky/configs/CMakeLists.txt b/Projects/blinky/configs/CMakeLists.txt new file mode 100644 index 00000000..9e9e6360 --- /dev/null +++ b/Projects/blinky/configs/CMakeLists.txt @@ -0,0 +1,6 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +add_subdirectory(app_config) +add_subdirectory(freertos-config) diff --git a/Config/aws_configs/CMakeLists.txt b/Projects/blinky/configs/app_config/CMakeLists.txt similarity index 65% rename from Config/aws_configs/CMakeLists.txt rename to Projects/blinky/configs/app_config/CMakeLists.txt index c88cab87..8127eb9f 100644 --- a/Config/aws_configs/CMakeLists.txt +++ b/Projects/blinky/configs/app_config/CMakeLists.txt @@ -2,9 +2,9 @@ # # SPDX-License-Identifier: MIT -add_library(aws-configs INTERFACE) +add_library(app-config INTERFACE) -target_include_directories(aws-configs +target_include_directories(app-config INTERFACE . ) diff --git a/Projects/blinky/configs/app_config/app_config.h b/Projects/blinky/configs/app_config/app_config.h new file mode 100644 index 00000000..d57061b9 --- /dev/null +++ b/Projects/blinky/configs/app_config/app_config.h @@ -0,0 +1,45 @@ +/* Copyright 2023 Arm Limited and/or its affiliates + * + * SPDX-License-Identifier: MIT + */ + +/** + * @brief Subscribe Publish demo tasks configuration. + * Subscribe publish demo task shows the basic functionality of connecting to an MQTT broker, subscribing + * to a topic, publishing messages to a topic and reporting the incoming messages on subscribed topic. + * Number of subscribe publish demo tasks to be spawned is configurable. + */ +#define appCONFIG_MQTT_NUM_PUBSUB_TASKS ( 1 ) +#define appCONFIG_MQTT_PUBSUB_TASK_STACK_SIZE ( 2048 ) +#define appCONFIG_MQTT_PUBSUB_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 ) + +/** + * @brief Stack size and priority for MQTT agent task. + * Stack size is capped to an adequate value based on requirements from MbedTLS stack + * for establishing a TLS connection. Task priority of MQTT agent is set to a priority + * higher than other MQTT application tasks, so that the agent can drain the queue + * as work is being produced. + */ +#define appCONFIG_MQTT_AGENT_TASK_STACK_SIZE ( 4096 ) +#define appCONFIG_MQTT_AGENT_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 ) + +/** + * @brief Stack size and priority for OTA MQTT agent task. + * Stack size is capped to an adequate value based on requirements from MbedTLS stack + * for establishing a TLS connection. Task priority of OTA MQTT agent is set to a priority + * higher than other MQTT application tasks, so that the agent can drain the queue + * as work is being produced. + */ +#define appCONFIG_OTA_MQTT_AGENT_TASK_STACK_SIZE ( 4096 ) +#define appCONFIG_OTA_MQTT_AGENT_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 ) + +/** @brief Set logging task as high priority task */ +#define appCONFIG_LOGGING_TASK_PRIORITY ( configMAX_PRIORITIES - 1 ) +#define appCONFIG_LOGGING_TASK_STACK_SIZE ( 2048 ) +#define appCONFIG_LOGGING_MESSAGE_QUEUE_LENGTH ( 32 ) + +/** @brief Increase backoff algorithm timeout by 8 seconds when device advisor + * test is active. + */ + +#define appCONFIG_DEVICE_ADVISOR_TEST_ACTIVE 0 diff --git a/Projects/blinky/configs/freertos-config/CMakeLists.txt b/Projects/blinky/configs/freertos-config/CMakeLists.txt new file mode 100644 index 00000000..088f7199 --- /dev/null +++ b/Projects/blinky/configs/freertos-config/CMakeLists.txt @@ -0,0 +1,20 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +target_include_directories(freertos_config SYSTEM + INTERFACE + . +) + +target_compile_definitions(freertos_config + INTERFACE + projCOVERAGE_TEST=0 +) + +target_link_libraries(freertos_config + INTERFACE + tfm-ns-interface + app-config + fri-bsp +) diff --git a/Projects/blinky/configs/freertos-config/FreeRTOSConfig.h b/Projects/blinky/configs/freertos-config/FreeRTOSConfig.h new file mode 100644 index 00000000..9ba2f722 --- /dev/null +++ b/Projects/blinky/configs/freertos-config/FreeRTOSConfig.h @@ -0,0 +1,237 @@ +/* + * FreeRTOS Kernel V10.4.1 + * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright (c) 2022, Arm Limited and Contributors. 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. + * + * http://aws.amazon.com/freertos + * http://www.FreeRTOS.org + */ + +#ifndef FREERTOS_CONFIG_H +#define FREERTOS_CONFIG_H + +/* Here is a good place to include header files that are required across + * your application. */ +/* #include */ +/* #include "aws_secure_sockets_config.h" */ +/* #include "RTOS_config.h" */ + +#include "app_config.h" + +#ifndef __USED + #define __USED __attribute__( ( used ) ) +#endif +#ifndef __WEAK + #define __WEAK __attribute__( ( weak ) ) +#endif + + +extern uint32_t SystemCoreClock; + +/* Memory allocation related definitions. */ +#define configSUPPORT_STATIC_ALLOCATION 1 +#define configSUPPORT_DYNAMIC_ALLOCATION 1 +#define configTOTAL_HEAP_SIZE 720896 +#define configAPPLICATION_ALLOCATED_HEAP 0 + +#define configENABLE_MVE 0 +#define configENABLE_FPU 1 +#define configENABLE_MPU 0 +#define configENABLE_TRUSTZONE 0 +#define configRUN_FREERTOS_SECURE_ONLY 0 + +/* The target specific macros `configTICK_RATE_HZ`, `pdMS_TO_TICKS` and + * `TICKS_TO_pdMS` are defined in `FreeRTOSConfig_target.h`. */ +#include "FreeRTOSConfig_target.h" + +#define configMINIMAL_STACK_SIZE 4096 +#define configUSE_16_BIT_TICKS 0 +#define portTICK_TYPE_IS_ATOMIC 1 + +#define configUSE_PREEMPTION 1 +#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0 +#define configUSE_TICKLESS_IDLE 0 +#define configCPU_CLOCK_HZ ( ( unsigned long ) SystemCoreClock ) +#define configMAX_PRIORITIES 56 +#define configMAX_TASK_NAME_LEN 16 +#define configIDLE_SHOULD_YIELD 1 +#define configUSE_TASK_NOTIFICATIONS 1 +#define configTASK_NOTIFICATION_ARRAY_ENTRIES 3 +#define configUSE_MUTEXES 1 +#define configUSE_RECURSIVE_MUTEXES 1 +#define configUSE_COUNTING_SEMAPHORES 1 +#define configUSE_ALTERNATIVE_API 0 /* Deprecated! */ +#define configQUEUE_REGISTRY_SIZE 10 +#define configUSE_QUEUE_SETS 0 +#define configUSE_TIME_SLICING 1 +#define configUSE_NEWLIB_REENTRANT 0 +#define configENABLE_BACKWARD_COMPATIBILITY 0 +#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 5 + +/* Hook function related definitions. */ +#define configUSE_IDLE_HOOK 0 +#define configUSE_TICK_HOOK 0 +#define configCHECK_FOR_STACK_OVERFLOW 1 /* This should only be set for development */ +#define configUSE_MALLOC_FAILED_HOOK 0 +#define configUSE_DAEMON_TASK_STARTUP_HOOK 0 + +/* Run time and task stats gathering related definitions. */ +#define configGENERATE_RUN_TIME_STATS 0 +#define configUSE_TRACE_FACILITY 1 +#define configUSE_STATS_FORMATTING_FUNCTIONS 0 + +/* Co-routine related definitions. */ +#define configUSE_CO_ROUTINES 0 +#define configMAX_CO_ROUTINE_PRIORITIES 1 + +/* Software timer related definitions. */ +#define configUSE_TIMERS 1 +#define configTIMER_TASK_PRIORITY 3 +#define configTIMER_QUEUE_LENGTH 10 +#define configTIMER_TASK_STACK_DEPTH configMINIMAL_STACK_SIZE + +/* Interrupt nesting behaviour configuration. */ +/* FIXME: these were taken from a cortex M4 example project */ +#define configKERNEL_INTERRUPT_PRIORITY 255 /* Should be set to the lowest interrupt priority */ + +/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!! + * See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */ +#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( 5 << ( 8U - 3U ) ) /* Platform implements 3 priority bits */ +#define configMAC_INTERRUPT_PRIORITY 7 /* Used at ethernet init and shifted by CMSIS call */ + +/* Define to trap errors during development. */ +void vAssertCalled( const char * pcFile, + unsigned long ulLine ); +#define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled( __FILE__, __LINE__ ); + +/* FreeRTOS MPU specific definitions. */ +#define configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS 0 +#define configTOTAL_MPU_REGIONS 8 /* Default value. */ +#define configTEX_S_C_B_FLASH 0x07UL /* Default value. */ +#define configTEX_S_C_B_SRAM 0x07UL /* Default value. */ +#define configENFORCE_SYSTEM_CALLS_FROM_KERNEL_ONLY 1 + +/* Optional functions - most linkers will remove unused functions anyway. */ +#define INCLUDE_vTaskPrioritySet 1 +#define INCLUDE_uxTaskPriorityGet 1 +#define INCLUDE_vTaskDelete 1 +#define INCLUDE_vTaskSuspend 1 +#define INCLUDE_xResumeFromISR 1 +#define INCLUDE_vTaskDelayUntil 1 +#define INCLUDE_vTaskDelay 1 +#define INCLUDE_xTaskGetSchedulerState 1 +#define INCLUDE_xTaskGetCurrentTaskHandle 1 +#define INCLUDE_uxTaskGetStackHighWaterMark 1 +#define INCLUDE_xTaskGetIdleTaskHandle 0 +#define INCLUDE_eTaskGetState 1 +#define INCLUDE_xEventGroupSetBitFromISR 1 +#define INCLUDE_xTimerPendFunctionCall 1 +#define INCLUDE_xTaskAbortDelay 1 +#define INCLUDE_xTaskGetHandle 0 +#define INCLUDE_xTaskResumeFromISR 1 +#define INCLUDE_xEventGroupSetBitsFromISR 1 +#define INCLUDE_xSemaphoreGetMutexHolder 1 + +/* Cortex-M specific definitions. */ +#ifdef __NVIC_PRIO_BITS + /* __NVIC_PRIO_BITS will be specified when CMSIS is being used. */ + #define configPRIO_BITS __NVIC_PRIO_BITS +#else + #define configPRIO_BITS 3 /* 8 priority levels. */ +#endif + +/* Logging task definitions. */ +void vLoggingPrintf( const char * pcFormat, + ... ); + +/* Map the FreeRTOS printf() to the logging task printf. */ +#define configPRINTF( x ) vLoggingPrintf x + +/* Map the logging task's printf to the board specific output function. */ +#define configPRINT_STRING( x ) printf( "%s", ( x ) ) + +/* Sets the length of the buffers into which logging messages are written - so + * also defines the maximum length of each log message. */ +#if ( appCONFIG_DEVICE_ADVISOR_TEST_ACTIVE == 1 ) + #define configLOGGING_MAX_MESSAGE_LENGTH 20480 +#else + #define configLOGGING_MAX_MESSAGE_LENGTH 1024 +#endif +/* Prepend each log message with a message number, the task name and a time stamp. */ +#define configLOGGING_INCLUDE_TIME_AND_TASK_NAME 1 + +/* A header file that defines trace macro can be included here. */ + +/* FIXME: this is just to build freeRTOS demo */ + +/* The address of an echo server that will be used by the two demo echo client + * tasks: + * http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_Echo_Clients.html, + * http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/UDP_Echo_Clients.html. */ +#define configECHO_SERVER_ADDR0 192 +#define configECHO_SERVER_ADDR1 168 +#define configECHO_SERVER_ADDR2 0 +#define configECHO_SERVER_ADDR3 105 +#define configTCP_ECHO_CLIENT_PORT 45000 + +/* Default MAC address configuration. The demo creates a virtual network + * connection that uses this MAC address by accessing the raw Ethernet/WiFi data + * to and from a real network connection on the host PC. See the + * configNETWORK_INTERFACE_TO_USE definition above for information on how to + * configure the real network connection to use. */ +#define configMAC_ADDR0 0x00 +#define configMAC_ADDR1 0x11 +#define configMAC_ADDR2 0x22 +#define configMAC_ADDR3 0x33 +#define configMAC_ADDR4 0x44 +#define configMAC_ADDR5 0x21 + +/* Default IP address configuration. Used in ipconfigUSE_DHCP is set to 0, or + * ipconfigUSE_DHCP is set to 1 but a DNS server cannot be contacted. */ +#define configIP_ADDR0 192 +#define configIP_ADDR1 168 +#define configIP_ADDR2 0 +#define configIP_ADDR3 105 + +/* Default gateway IP address configuration. Used in ipconfigUSE_DHCP is set to + * 0, or ipconfigUSE_DHCP is set to 1 but a DNS server cannot be contacted. */ +#define configGATEWAY_ADDR0 192 +#define configGATEWAY_ADDR1 168 +#define configGATEWAY_ADDR2 0 +#define configGATEWAY_ADDR3 1 + +/* Default DNS server configuration. OpenDNS addresses are 208.67.222.222 and + * 208.67.220.220. Used in ipconfigUSE_DHCP is set to 0, or ipconfigUSE_DHCP is + * set to 1 but a DNS server cannot be contacted.*/ +#define configDNS_SERVER_ADDR0 208 +#define configDNS_SERVER_ADDR1 67 +#define configDNS_SERVER_ADDR2 222 +#define configDNS_SERVER_ADDR3 222 + +/* Default netmask configuration. Used in ipconfigUSE_DHCP is set to 0, or + * ipconfigUSE_DHCP is set to 1 but a DNS server cannot be contacted. */ +#define configNET_MASK0 255 +#define configNET_MASK1 255 +#define configNET_MASK2 255 +#define configNET_MASK3 0 + +#define democonfigNETWORK_TYPES ( AWSIOT_NETWORK_TYPE_ETH ) + +#endif /* FREERTOS_CONFIG_H */ diff --git a/Projects/blinky/configs/tfm-config/project_config.h b/Projects/blinky/configs/tfm-config/project_config.h new file mode 100644 index 00000000..fcb4598e --- /dev/null +++ b/Projects/blinky/configs/tfm-config/project_config.h @@ -0,0 +1,86 @@ +/* Copyright 2023 Arm Limited and/or its affiliates + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#define PLATFORM_SERVICE_INPUT_BUFFER_SIZE 64 + +#define PLATFORM_SERVICE_OUTPUT_BUFFER_SIZE 64 + +#define PLATFORM_SP_STACK_SIZE 0x500 + +#define PLATFORM_NV_COUNTER_MODULE_DISABLED 0 + +#define CRYPTO_ENGINE_BUF_SIZE 0x8000 + +#define CRYPTO_CONC_OPER_NUM 8 + +#define CRYPTO_RNG_MODULE_ENABLED 1 + +#define CRYPTO_KEY_MODULE_ENABLED 1 + +#define CRYPTO_AEAD_MODULE_ENABLED 1 + +#define CRYPTO_MAC_MODULE_ENABLED 1 + +#define CRYPTO_HASH_MODULE_ENABLED 1 + +#define CRYPTO_CIPHER_MODULE_ENABLED 1 + +#define CRYPTO_ASYM_SIGN_MODULE_ENABLED 1 + +#define CRYPTO_ASYM_ENCRYPT_MODULE_ENABLED 1 + +#define CRYPTO_KEY_DERIVATION_MODULE_ENABLED 1 + +#define CRYPTO_IOVEC_BUFFER_SIZE 5120 + +#define CRYPTO_NV_SEED 1 + +#define CRYPTO_SINGLE_PART_FUNCS_DISABLED 0 + +#define CRYPTO_STACK_SIZE 0x1B00 + +#define TFM_FWU_BUF_SIZE PSA_FWU_MAX_WRITE_SIZE + +#define FWU_STACK_SIZE 0x600 + +#define ATTEST_INCLUDE_OPTIONAL_CLAIMS 1 + +#define ATTEST_INCLUDE_COSE_KEY_ID 0 + +#define ATTEST_STACK_SIZE 0x700 + +#define ATTEST_TOKEN_PROFILE_PSA_IOT_1 1 + +#define ITS_CREATE_FLASH_LAYOUT 1 + +#define ITS_RAM_FS 0 + +#define ITS_VALIDATE_METADATA_FROM_FLASH 1 + +#define ITS_MAX_ASSET_SIZE 1300 + +#define ITS_BUF_SIZE ITS_MAX_ASSET_SIZE + +#define ITS_NUM_ASSETS 10 + +#define ITS_STACK_SIZE 0x720 + +#define PS_CREATE_FLASH_LAYOUT 1 + +#define PS_RAM_FS 0 + +#define PS_ROLLBACK_PROTECTION 1 + +#define PS_VALIDATE_METADATA_FROM_FLASH 1 + +#define PS_MAX_ASSET_SIZE 2048 + +#define PS_NUM_ASSETS 10 + +#define PS_STACK_SIZE 0x700 + +#define CONFIG_TFM_CONN_HANDLE_MAX_NUM 8 + +#define CONFIG_TFM_DOORBELL_API 0 From 679d8e40365665320b59ab2e256287922b0b6901 Mon Sep 17 00:00:00 2001 From: Hugues Kamba-Mpiana Date: Mon, 9 Oct 2023 09:50:50 +0100 Subject: [PATCH 04/22] blinky: Improve CMake support * Define all CMake variables to be used by the project prior to creating the project * Sort list items alphabetically so they are easier to find * Add fatal error if minimum CMake version is not used * Remove unnecessary comments to declutter * Handle compiler specific configurations in one location * Move BSP configuration to BSP subdir * Include only the libraries used by the application Signed-off-by: Hugues Kamba-Mpiana --- Projects/blinky/CMakeLists.txt | 101 ++++++++++++--------------------- 1 file changed, 36 insertions(+), 65 deletions(-) diff --git a/Projects/blinky/CMakeLists.txt b/Projects/blinky/CMakeLists.txt index bcf18384..d9d7be7f 100644 --- a/Projects/blinky/CMakeLists.txt +++ b/Projects/blinky/CMakeLists.txt @@ -2,15 +2,12 @@ # # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.21) +cmake_minimum_required(VERSION 3.21.0 FATAL_ERROR) -# Start of the project -project(blinky-example LANGUAGES C CXX) - -# Declare the target of the total solution -set(ARM_CORSTONE_BSP_TARGET_PLATFORM "" CACHE STRING "Featured Reference Integration target") +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Release" CACHE STRING "The build type" FORCE) +endif() -# Configure target if (${ARM_CORSTONE_BSP_TARGET_PLATFORM} STREQUAL "corstone300") set(TFM_PLATFORM_LOCAL_PATH "arm/mps3/corstone300/fvp") set( FREERTOS_PORT "GCC_ARM_CM55_TFM" CACHE STRING "" FORCE) @@ -21,94 +18,63 @@ else() message(FATAL_ERROR "Invalid ARM_CORSTONE_BSP_TARGET_PLATFORM (${ARM_CORSTONE_BSP_TARGET_PLATFORM}) set. Supported are corstone300/corstone310") endif() -# Extra arguments for TF-M and ML set(TFM_CMAKE_ARGS - -DPROJECT_CONFIG_HEADER_FILE=${PRJ_DIR}/Config/tfm-config/project_config.h + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCONFIG_TFM_ENABLE_CP10CP11=ON + -DMCUBOOT_GENERATE_SIGNING_KEYPAIR=ON + -DMCUBOOT_LOG_LEVEL=INFO + -DMCUBOOT_SIGNATURE_KEY_LEN=3072 + -DNS=ON -DPLATFORM_DEFAULT_PROVISIONING=OFF + -DPLATFORM_DEFAULT_UART_STDOUT=ON + -DPROJECT_CONFIG_HEADER_FILE=${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/Projects/blinky/configs/tfm-config/project_config.h -DTFM_DUMMY_PROVISIONING=OFF - -DMCUBOOT_GENERATE_SIGNING_KEYPAIR=ON - -DCONFIG_TFM_ENABLE_CP10CP11=ON -DTFM_EXCEPTION_INFO_DUMP=ON - -DNS=ON; - -DPLATFORM_DEFAULT_UART_STDOUT=ON; - -DMCUBOOT_SIGNATURE_KEY_LEN=3072 - -DMCUBOOT_LOG_LEVEL=INFO - -DTFM_SPM_LOG_LEVEL=TFM_SPM_LOG_LEVEL_INFO -DTFM_PARTITION_CRYPTO=ON -DTFM_PARTITION_INITIAL_ATTESTATION=ON -DTFM_PARTITION_INTERNAL_TRUSTED_STORAGE=ON -DTFM_PARTITION_PLATFORM=ON -DTFM_PARTITION_PROTECTED_STORAGE=ON -DTFM_PLATFORM=${TFM_PLATFORM_LOCAL_PATH} + -DTFM_SPM_LOG_LEVEL=TFM_SPM_LOG_LEVEL_INFO ) -# Configuration of executable -set(EXE_SUFFIX ".axf") -set(CMAKE_EXECUTABLE_SUFFIX ${EXE_SUFFIX}) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +project(blinky-example LANGUAGES C) + +set(CMAKE_EXECUTABLE_SUFFIX ".axf") # Set global optimization level to reduce code size while keeping the debug experience. -# ARMClang does not have -Og but officially recommends -O1 for debug. if(${CMAKE_C_COMPILER_ID} STREQUAL "GNU") add_compile_options(-Og) -else() +elseif(CMAKE_C_COMPILER_ID STREQUAL "ARMClang") add_compile_options(-O1) endif() -add_subdirectory(../../Middleware/ARM ${CMAKE_BINARY_DIR}/Middleware/ARM) -add_subdirectory(../../Bsp ${CMAKE_BINARY_DIR}/Bsp) -add_subdirectory(../../Config ${CMAKE_BINARY_DIR}/Config) - -target_compile_definitions(arm-corstone-platform-bsp - INTERFACE - __DOMAIN_NS=1 -) - -# Compilation Database -set(CMAKE_EXPORT_COMPILE_COMMANDS ON) - -add_library(freertos_config INTERFACE) -target_include_directories(freertos_config SYSTEM - INTERFACE - ${PRJ_DIR}/Config/freertos-config -) - -target_compile_definitions(freertos_config - INTERFACE - projCOVERAGE_TEST=0 -) - -target_link_libraries(freertos_config - INTERFACE - tfm-ns-interface - app-config - fri-bsp -) +add_subdirectory(${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR} ${CMAKE_BINARY_DIR}/iot_reference_arm_corstone3xx) -set( FREERTOS_HEAP "3" CACHE STRING "" FORCE) +list(APPEND CMAKE_MODULE_PATH ${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/Bsp/cmake) +list(APPEND CMAKE_MODULE_PATH ${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/components/security/trusted_firmware-m/integration/cmake) +include(BspUtilities) +include(MergeTfmImages) +include(SignTfmImage) -add_subdirectory(../../Middleware/FreeRTOS ${CMAKE_BINARY_DIR}/Middleware/FreeRTOS) +add_subdirectory(configs) -# Declare the blinky executable add_executable(blinky main.c) - +# Trusted Firmware-M must be built before the application, because +# the application depends on the NS interface and the BL2 signing scripts, +# both of which are generated as parts of the Trusted Firmware-M build process. +add_dependencies(blinky trusted_firmware-m-build) target_link_libraries(blinky freertos_kernel tfm-ns-interface fri-bsp ) -# Trusted Firmware-M must be built before the application, because -# the application depends on the NS interface and the BL2 signing scripts, -# both of which are generated as parts of the Trusted Firmware-M build process. -add_dependencies(blinky tf-m-build) - -include(${PRJ_DIR}/Bsp/cmake/BspUtilities.cmake) set_linker_script(blinky) -list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/Middleware/ARM/TF-M/cmake) -include(SignTfmImage) -include(MergeTfmImages) - # The non-secure application image should be padded while being signed # Hence, passing "TRUE" as the input parameter to the pad option of sign function. iot_reference_arm_corstone3xx_tf_m_sign_image(blinky blinky_signed 0.0.1 TRUE) @@ -117,4 +83,9 @@ iot_reference_arm_corstone3xx_tf_m_sign_image(blinky blinky_signed 0.0.1 TRUE) # addresses in order to merge images for TF-M. The addresses cannot # be easily programmatically extracted as they are defined in the linker # scripts. -iot_reference_arm_corstone3xx_tf_m_merge_images(blinky ${BL2_IMAGE_LOAD_ADDRESS} ${S_IMAGE_LOAD_ADDRESS} ${NS_IMAGE_LOAD_ADDRESS} ${S_PROVISIONING_BUNDLE_LOAD_ADDRESS}) +iot_reference_arm_corstone3xx_tf_m_merge_images(blinky + ${BL2_IMAGE_LOAD_ADDRESS} + ${S_IMAGE_LOAD_ADDRESS} + ${NS_IMAGE_LOAD_ADDRESS} + ${S_PROVISIONING_BUNDLE_LOAD_ADDRESS} +) From 7a0a8a497ce17249da9a5eaa1ed88f93541eb7e0 Mon Sep 17 00:00:00 2001 From: Hugues Kamba-Mpiana Date: Fri, 27 Oct 2023 10:43:02 +0100 Subject: [PATCH 05/22] apps: Improve Provisioning Python script * Add type notation * Wrap long lines * Clarify variables and function names * Process CLI arguments with click Signed-off-by: Hugues Kamba-Mpiana --- .../generate_credentials_header.py | 129 +++++++++++++----- 1 file changed, 94 insertions(+), 35 deletions(-) diff --git a/Projects/aws-iot-example/provisioning/generate_credentials_header.py b/Projects/aws-iot-example/provisioning/generate_credentials_header.py index 43bec23e..de3505e7 100644 --- a/Projects/aws-iot-example/provisioning/generate_credentials_header.py +++ b/Projects/aws-iot-example/provisioning/generate_credentials_header.py @@ -4,28 +4,45 @@ # # SPDX-License-Identifier: MIT -import argparse +import os +import click CREDENTIALS_TEMPLATE = """#ifndef AWS_CLIENT_CREDENTIAL_KEYS_H #define AWS_CLIENT_CREDENTIAL_KEYS_H - #define keyCLIENT_CERTIFICATE_PEM {client_certificate_pem} - #define keyCLIENT_PRIVATE_KEY_PEM {client_private_key_pem} - #define keyJITR_DEVICE_CERTIFICATE_AUTHORITY_PEM {jitr_dev_cert_auth_pem} - #define keyCODE_SIGNING_PUBLIC_KEY_PEM {code_signing_public_key_pem} #endif /* AWS_CLIENT_CREDENTIAL_KEYS_H */ """ -def main(args): - client_private_key_pem = format_pem_to_c(args.client_private_key_pem) - client_certificate_pem = format_pem_to_c(args.client_certificate_pem) - code_signing_public_key_pem = format_pem_to_c(args.code_signing_public_key_pem) - with open("aws_clientcredential_keys.h", "w") as out_file: +def create_aws_clientcredential_keys_header( + path_to_credential_directory: str, + path_to_client_certificate_pem: str, + path_to_client_private_key_pem: str, + path_to_code_signing_public_key_pem: str, +) -> None: + """ + Create an AWS client credential keys header file. + Args: + path_to_credential_directory (str): Path to the credential directory. + path_to_client_certificate_pem (str): Path to the client certificate PEM file. + path_to_client_private_key_pem (str): Path to the client private key PEM file. + path_to_code_signing_public_key_pem (str): Path to the code signing public + key with pem extension. + Returns: + None + """ + client_private_key_pem = process_file(path_to_client_private_key_pem) + client_certificate_pem = process_file(path_to_client_certificate_pem) + code_signing_public_key_pem = process_file(path_to_code_signing_public_key_pem) + path_to_credential_key_header = os.path.join( + path_to_credential_directory, "aws_clientcredential_keys.h" + ) + + with open(path_to_credential_key_header, "w") as out_file: out_file.write( CREDENTIALS_TEMPLATE.format( client_certificate_pem=client_certificate_pem, @@ -36,31 +53,73 @@ def main(args): ) -def format_pem_to_c(file): - formatted = "" - with open(file, "r") as f: - lines = f.readlines() - for line in lines[0:-1]: - formatted += '"' + line.strip() + '\\n"\\\n' - formatted += '"' + lines[-1].strip() + '"' - return formatted +def process_file(input_file: str) -> str: + """ + Process a file and return its content as a formatted string. + Args: + input_file (str): Path to the input file. + Returns: + str: Processed content as a formatted string. + """ + processed_content = "" + try: + with open(input_file, "r") as in_file: + lines = in_file.readlines() + # Add '"' and '\n"\' and then '\n' + for line in lines[0:-1]: + processed_content += '"' + line.strip() + '\\n"\\\n' -if __name__ == "__main__": - parser = argparse.ArgumentParser() - parser.add_argument( - "--client_certificate_pem", - help="the path of client certificate with pem extension", - required=True, - ) - parser.add_argument( - "--client_private_key_pem", - help="the path of client private key with pem extension", - required=True, - ) - parser.add_argument( - "--code_signing_public_key_pem", - help="the path of code signing public key with pem extension", - required=True, + # For the last line, add '"' and '"' + processed_content += '"' + lines[-1].strip() + '"' + return processed_content + except FileNotFoundError: + print(f"File '{input_file}' not found.") + except Exception as e: + print(f"An error occurred: {e}") + + +@click.command() +@click.argument("path_to_credential_directory", type=str) +@click.option( + "--path-to-client-certificate-pem", + type=str, + help="Path of client certificate with *.pem extension", +) +@click.option( + "--path-to-client-private-key-pem", + type=str, + help="Path of client private key with *.pem extension", +) +@click.option( + "--path-to-code-signing-public-key-pem", + type=str, + help="Path of code signing public key with pem extension", +) +def main( + path_to_credential_directory: str, + path_to_client_certificate_pem: str, + path_to_client_private_key_pem: str, + path_to_code_signing_public_key_pem: str, +) -> None: + """ + Main CLI entry point for creating AWS client credential keys header. + Args: + path_to_credential_directory (str): Path to the credential directory. + path_to_client_certificate_pem (str): Path to the client certificate PEM file. + path_to_client_private_key_pem (str): Path to the client private key PEM file. + path_to_code_signing_public_key_pem (str): Path to the code signing public key + with pem extension. + Returns: + None + """ + create_aws_clientcredential_keys_header( + path_to_credential_directory, + path_to_client_certificate_pem, + path_to_client_private_key_pem, + path_to_code_signing_public_key_pem, ) - main(parser.parse_args()) + + +if __name__ == "__main__": + main() From d86d2ef06d5dc81bf107f1f6b428b1b13c7aa7b3 Mon Sep 17 00:00:00 2001 From: Hugues Kamba-Mpiana Date: Mon, 9 Oct 2023 10:04:13 +0100 Subject: [PATCH 06/22] aws-iot-example: Improve CMake support and organisation * Define all CMake variables to be used by the project prior to creating the project * Sort list items alphabetically so they are easier to find * Add fatal error if minimum CMake version is not used * Remove unnecessary comments to declutter * Handle compiler specific configurations in one location * Move BSP configuration to BSP subdir * Include only the libraries used by the application Signed-off-by: Hugues Kamba-Mpiana --- Projects/aws-iot-example/CMakeLists.txt | 280 ++++++------------ .../event-helper/CMakeLists.txt | 22 -- Projects/aws-iot-example/main.c | 2 +- .../mqtt-agent-wrapper/CMakeLists.txt | 32 -- .../freertos_agent_message.c | 74 ----- .../freertos_agent_message.h | 84 ------ .../freertos_command_pool.c | 160 ---------- .../freertos_command_pool.h | 83 ------ .../mqtt-agent-wrapper/subscription_manager.c | 188 ------------ .../mqtt-agent-wrapper/subscription_manager.h | 118 -------- .../provisioning/CMakeLists.txt | 16 +- Projects/helpers/CMakeLists.txt | 1 + Projects/helpers/events/CMakeLists.txt | 16 + .../events/inc/events.h} | 6 +- .../events/src/events.c} | 4 +- Tools/scripts/build.sh | 4 +- .../integration/src/freertos_command_pool.c | 81 ++--- .../integration/src/mqtt_agent_task.c | 2 +- .../integration/src/subscription_manager.c | 153 ++++++---- 19 files changed, 253 insertions(+), 1073 deletions(-) delete mode 100644 Projects/aws-iot-example/event-helper/CMakeLists.txt delete mode 100644 Projects/aws-iot-example/mqtt-agent-wrapper/CMakeLists.txt delete mode 100644 Projects/aws-iot-example/mqtt-agent-wrapper/freertos_agent_message.c delete mode 100644 Projects/aws-iot-example/mqtt-agent-wrapper/freertos_agent_message.h delete mode 100644 Projects/aws-iot-example/mqtt-agent-wrapper/freertos_command_pool.c delete mode 100644 Projects/aws-iot-example/mqtt-agent-wrapper/freertos_command_pool.h delete mode 100644 Projects/aws-iot-example/mqtt-agent-wrapper/subscription_manager.c delete mode 100644 Projects/aws-iot-example/mqtt-agent-wrapper/subscription_manager.h create mode 100644 Projects/helpers/events/CMakeLists.txt rename Projects/{aws-iot-example/event-helper/event_helper.h => helpers/events/inc/events.h} (93%) rename Projects/{aws-iot-example/event-helper/event_helper.c => helpers/events/src/events.c} (95%) diff --git a/Projects/aws-iot-example/CMakeLists.txt b/Projects/aws-iot-example/CMakeLists.txt index 89bd4760..c28e34b1 100644 --- a/Projects/aws-iot-example/CMakeLists.txt +++ b/Projects/aws-iot-example/CMakeLists.txt @@ -2,34 +2,20 @@ # # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.21) +cmake_minimum_required(VERSION 3.21.0 FATAL_ERROR) -# Start of the project -project(aws-iot-example-project LANGUAGES C CXX) - -# Declare the target of the total solution -set(ARM_CORSTONE_BSP_TARGET_PLATFORM "" CACHE STRING "Featured Reference Integration target") +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Release" CACHE STRING "The build type" FORCE) +endif() -# Configure target if (${ARM_CORSTONE_BSP_TARGET_PLATFORM} STREQUAL "corstone300") set(TFM_PLATFORM_LOCAL_PATH "arm/mps3/corstone300/fvp") - set( FREERTOS_PORT "GCC_ARM_CM55_TFM" CACHE STRING "" FORCE) elseif(${ARM_CORSTONE_BSP_TARGET_PLATFORM} STREQUAL "corstone310") set(TFM_PLATFORM_LOCAL_PATH "arm/mps3/corstone310/fvp") - set( FREERTOS_PORT "GCC_ARM_CM85_TFM" CACHE STRING "" FORCE) else() message(FATAL_ERROR "Invalid ARM_CORSTONE_BSP_TARGET_PLATFORM (${ARM_CORSTONE_BSP_TARGET_PLATFORM}) set. Supported are corstone300/corstone310") endif() -set(TFM_PLATFORM_UPGRADE_STRATEGY "SWAP_USING_SCRATCH") -set(TFM_PLATFORM_CONFIRM_IMAGE ON) - - -set(TFM_PLATFORM "${TFM_PLATFORM_LOCAL_PATH}") -set(TFM_PARTITION_FIRMWARE_UPDATE ON) -set(TFM_PSA_FIRMWARE_UPDATE ON) -set(CONFIG_TFM_ENABLE_CP10CP11 ON) - # From: ota-for-aws-iot-embedded-sdk/source/include/ota_appversion32.h # struct version # { @@ -39,24 +25,30 @@ set(CONFIG_TFM_ENABLE_CP10CP11 ON) # uint16_t build; /*!< @brief Build of the firmware (Z in firmware version X.Y.Z). */ # } x; /*!< @brief Version number of the firmware. */ -# AWS OTA client doesn't use the patch version. Therefore, build version from TF-M is used. Because of this, -# if only patch version is changed then the OTA will be rejected due to same firmware version. +# AWS OTA client does not use the SemVer PATCH version. +# Because of this, if only PATCH version is changed then the OTA will be rejected +# due to same firmware version. +# We will therefore change the build version from TF-M. set(MCUBOOT_IMAGE_VERSION_NS "0.0.1+10") set(MCUBOOT_IMAGE_VERSION_NS_UPDATE "0.0.1+20") -# Extra arguments for TF-M and ML set(TFM_CMAKE_ARGS - -DPROJECT_CONFIG_HEADER_FILE=${PRJ_DIR}/Config/tfm-config/project_config.h - -DPLATFORM_DEFAULT_PROVISIONING=OFF - -DTFM_DUMMY_PROVISIONING=OFF - -DMCUBOOT_GENERATE_SIGNING_KEYPAIR=ON + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCONFIG_TFM_ENABLE_CP10CP11=ON - -DTFM_EXCEPTION_INFO_DUMP=ON + -DMCUBOOT_CONFIRM_IMAGE=ON + -DMCUBOOT_DATA_SHARING=ON + -DMCUBOOT_IMAGE_VERSION_NS=${MCUBOOT_IMAGE_VERSION_NS} + -DMCUBOOT_GENERATE_SIGNING_KEYPAIR=ON + -DMCUBOOT_LOG_LEVEL=INFO + -DMCUBOOT_SIGNATURE_KEY_LEN=3072 + -DMCUBOOT_UPGRADE_STRATEGY=SWAP_USING_SCRATCH -DNS=ON + -DPLATFORM_DEFAULT_PROVISIONING=OFF -DPLATFORM_DEFAULT_UART_STDOUT=ON - -DMCUBOOT_SIGNATURE_KEY_LEN=3072 - -DMCUBOOT_LOG_LEVEL=INFO - -DTFM_SPM_LOG_LEVEL=TFM_SPM_LOG_LEVEL_INFO + -DPLATFORM_HAS_FIRMWARE_UPDATE_SUPPORT=ON + -DPROJECT_CONFIG_HEADER_FILE=${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/Projects/aws-iot-example/configs/tfm-config/project_config.h + -DTFM_DUMMY_PROVISIONING=OFF + -DTFM_EXCEPTION_INFO_DUMP=ON -DTFM_PARTITION_CRYPTO=ON -DTFM_PARTITION_FIRMWARE_UPDATE=ON -DTFM_PARTITION_INITIAL_ATTESTATION=ON @@ -64,215 +56,115 @@ set(TFM_CMAKE_ARGS -DTFM_PARTITION_PLATFORM=ON -DTFM_PARTITION_PROTECTED_STORAGE=ON -DTFM_PLATFORM=${TFM_PLATFORM_LOCAL_PATH} - -DPLATFORM_HAS_FIRMWARE_UPDATE_SUPPORT=ON - -DMCUBOOT_DATA_SHARING=ON - -DMCUBOOT_CONFIRM_IMAGE=${TFM_PLATFORM_CONFIRM_IMAGE} - -DMCUBOOT_UPGRADE_STRATEGY=${TFM_PLATFORM_UPGRADE_STRATEGY} - -DMCUBOOT_IMAGE_VERSION_NS=${MCUBOOT_IMAGE_VERSION_NS} + -DTFM_SPM_LOG_LEVEL=TFM_SPM_LOG_LEVEL_INFO ) -# Configuration of executable -set(EXE_SUFFIX ".axf") -set(CMAKE_EXECUTABLE_SUFFIX ${EXE_SUFFIX}) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -# Set global optimization level to reduce code size while keeping the debug experience. -# ARMClang does not have -Og but officially recommends -O1 for debug. -if (INTEGRATION_TESTS) -else() +project(aws-iot-example-project LANGUAGES C) + +set(CMAKE_EXECUTABLE_SUFFIX ".axf") + +if (INTEGRATION_TESTS EQUAL 0) + # Set global optimization level to reduce code size while keeping the debug experience. if(${CMAKE_C_COMPILER_ID} STREQUAL "GNU") add_compile_options(-Og) - else() + elseif(CMAKE_C_COMPILER_ID STREQUAL "ARMClang") add_compile_options(-O1) endif() endif() -# Select connectivity stack. -set(CONNECTIVITY_STACK "FREERTOS_TCP_IP" CACHE STRING "Choose the connectivity stack to use. Possible values are `FREERTOS_TCP_IP | IOT_VSOCKET`.") - -set(MIDDLEWARE_DIR "../../Middleware") - -add_subdirectory(${MIDDLEWARE_DIR}/ARM ${CMAKE_BINARY_DIR}/Middleware/ARM) -add_subdirectory(../../Config ${CMAKE_BINARY_DIR}/Config) -add_subdirectory(../../Bsp ${CMAKE_BINARY_DIR}/Bsp) - - -target_compile_definitions(arm-corstone-platform-bsp - INTERFACE - __DOMAIN_NS=1 -) - -# Compilation Database -set(CMAKE_EXPORT_COMPILE_COMMANDS ON) - -add_library(freertos_config INTERFACE) -target_include_directories(freertos_config SYSTEM - INTERFACE - ${PRJ_DIR}/Config/freertos-config -) - -target_compile_definitions(freertos_config - INTERFACE - projCOVERAGE_TEST=0 -) - -target_link_libraries(freertos_config - INTERFACE - tfm-ns-interface - app-config - fri-bsp -) - -set( FREERTOS_HEAP "4" CACHE STRING "" FORCE) - -add_subdirectory(${MIDDLEWARE_DIR}/FreeRTOS ${CMAKE_BINARY_DIR}/Middleware/FreeRTOS) -add_subdirectory(${MIDDLEWARE_DIR}/AWS ${CMAKE_BINARY_DIR}/Middleware/AWS) - -# integration tests -include(${MIDDLEWARE_DIR}/FreeRTOS/FreeRTOS-Libraries-Integration-Tests/qualification_test.cmake) -include(${MIDDLEWARE_DIR}/FreeRTOS/FreeRTOS-Libraries-Integration-Tests/src/transport_interface_test.cmake) -include(${MIDDLEWARE_DIR}/FreeRTOS/FreeRTOS-Libraries-Integration-Tests/src/ota_pal_test.cmake) -include(${MIDDLEWARE_DIR}/FreeRTOS/FreeRTOS-Libraries-Integration-Tests/src/mqtt_test.cmake) -# override provisioning in PKCS11 tests with our provisioning -set(PKCS11_TEST_SOURCES - "${MIDDLEWARE_DIR}/FreeRTOS/FreeRTOS-Libraries-Integration-Tests/src/pkcs11/core_pkcs11_test.c") -set(PKCS11_TEST_INCLUDE_DIRS - "${MIDDLEWARE_DIR}/FreeRTOS/FreeRTOS-Libraries-Integration-Tests/src/pkcs11" - "${MIDDLEWARE_DIR}/FreeRTOS/FreeRTOS-Libraries-Integration-Tests/src/common") +add_subdirectory(${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR} ${CMAKE_BINARY_DIR}/iot_reference_arm_corstone3xx) -add_library(unity STATIC) - -target_sources(unity - PRIVATE - ${MIDDLEWARE_DIR}/Unity/src/unity.c - ${MIDDLEWARE_DIR}/Unity/extras/fixture/src/unity_fixture.c - ${MIDDLEWARE_DIR}/Unity/extras/memory/src/unity_memory.c -) - -target_include_directories(unity - PUBLIC - ${MIDDLEWARE_DIR}/Unity/src - ${MIDDLEWARE_DIR}/Unity/extras/fixture/src - ${MIDDLEWARE_DIR}/Unity/extras/memory/src -) - -add_library(integration-test-task STATIC) - -target_sources(integration-test-task - PRIVATE - ${TRANSPORT_TEST_SOURCES} - ${PKCS11_TEST_SOURCES} - ${OTA_PAL_TEST_SOURCES} - ${MQTT_TEST_SOURCES} - ${QUALIFICATION_TEST_SOURCES} - freertos-integration-tests/integration_tests_platform_function.c -) - -target_include_directories(integration-test-task - PRIVATE - freertos-integration-tests/include - ${TRANSPORT_TEST_INCLUDE_DIRS} - ${PKCS11_TEST_INCLUDE_DIRS} - ${OTA_PAL_TEST_INCLUDE_DIRS} - ${MQTT_TEST_INCLUDE_DIRS} - ${QUALIFICATION_TEST_INCLUDE_DIRS} - ${MIDDLEWARE_DIR}/AWS/aws-iot-device-sdk-lib/corePKCS11/source/include - ${MIDDLEWARE_DIR}/AWS/aws-iot-device-sdk-lib/corePKCS11/source/dependency/3rdparty/pkcs11 - ${MIDDLEWARE_DIR}/ARM/mbedtls-lib/mbedtls/include - ${MIDDLEWARE_DIR}/AWS/aws-iot-device-sdk-lib/ota-for-aws-iot-embedded-sdk/source/include/ - ${MIDDLEWARE_DIR}/ARM/freertos-ota-pal-psa-lib/freertos-ota-pal-psa - ${MIDDLEWARE_DIR}/AWS/aws-iot-device-sdk-lib/corePKCS11/source/dependency/3rdparty/mbedtls_utils -) - -target_link_libraries(integration-test-task - PRIVATE - freertos_kernel - aws-configs - app-logging - unity - awsIoT - connectivity-stack - mbedtls - fri-bsp -) +list(APPEND CMAKE_MODULE_PATH ${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/Bsp/cmake) +list(APPEND CMAKE_MODULE_PATH ${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/components/aws_iot/cmake) +list(APPEND CMAKE_MODULE_PATH ${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/components/security/trusted_firmware-m/integration/cmake) +include(BspUtilities) +include(GenerateAWSUpdateDigestAndSignature) +include(MergeTfmImages) +include(SignTfmImage) -add_subdirectory(event-helper) -add_subdirectory(mqtt-agent-wrapper) +add_subdirectory(configs) +add_subdirectory(../helpers ${CMAKE_BINARY_DIR}/helpers) add_subdirectory(provisioning provisioning_data) -# Declare the aws-iot-example executable +# Add main application executable add_executable(aws-iot-example + dev_mode_key_provisioning.c main.c mqtt_demo_pub_sub.c - dev_mode_key_provisioning.c - ${MIDDLEWARE_DIR}/AWS/corePKCS11/source/dependency/3rdparty/mbedtls_utils/mbedtls_utils.c + ${corepkcs11_SOURCE_DIR}/source/dependency/3rdparty/mbedtls_utils/mbedtls_utils.c +) +target_include_directories(aws-iot-example + PUBLIC + freertos-integration-tests/include + provisioning ) # Trusted Firmware-M must be built before the application, because # the application depends on the NS interface and the BL2 signing scripts, # both of which are generated as parts of the Trusted Firmware-M build process. -add_dependencies(aws-iot-example tf-m-build) +add_dependencies(aws-iot-example trusted_firmware-m-build) # The provision data must be built before the application because # it provides credentials to connect to AWS add_dependencies(aws-iot-example provisioning_data_bin) - -target_include_directories(aws-iot-example - PRIVATE - . - freertos-integration-tests/include - provisioning -) - -if (INTEGRATION_TESTS) - target_compile_definitions(aws-iot-example - PRIVATE - INTEGRATION_TESTS=1 - ) -endif() - target_link_libraries(aws-iot-example PRIVATE - app-config - app-logging - awsIoT - mqtt-agent-task - - event-helper - + backoff-algorithm + connectivity-stack + coremqtt + coremqtt-agent + corepkcs11 + freertos_kernel freertos-ota-pal-psa - + fri-bsp + helpers-events mbedtls mbedtls-threading-freertos - - freertos_kernel + ota-for-aws-iot-embedded-sdk tfm-ns-interface - fri-bsp - $<$:integration-test-task> ) -include(${PRJ_DIR}/Bsp/cmake/BspUtilities.cmake) set_linker_script(aws-iot-example) -list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/Middleware/ARM/TF-M/cmake) -include(SignTfmImage) -include(MergeTfmImages) - # The non-secure application image should be padded while being signed # Hence, passing "TRUE" as the input parameter to the pad option of sign function. -iot_reference_arm_corstone3xx_tf_m_sign_image(aws-iot-example aws-iot-example_signed ${MCUBOOT_IMAGE_VERSION_NS} TRUE) +iot_reference_arm_corstone3xx_tf_m_sign_image( + aws-iot-example + aws-iot-example_signed + ${MCUBOOT_IMAGE_VERSION_NS} + TRUE +) # The update image is not padded to fill the whole slot (no --pad), because # 1) the image to download is smaller without padding # 2) the trailer that keeps track of boot and update statuses should not be overwritten # Hence, passing "FALSE" as the input parameter for the pad option to the sign function. -iot_reference_arm_corstone3xx_tf_m_sign_image(aws-iot-example aws-iot-example-update_signed ${MCUBOOT_IMAGE_VERSION_NS_UPDATE} FALSE) +iot_reference_arm_corstone3xx_tf_m_sign_image( + aws-iot-example + aws-iot-example-update_signed + ${MCUBOOT_IMAGE_VERSION_NS_UPDATE} + FALSE +) # A user project that consumes the ARM FRI needs to explicitly provide # addresses in order to merge images for TF-M. The addresses cannot # be easily programmatically extracted as they are defined in the linker # scripts. -iot_reference_arm_corstone3xx_tf_m_merge_images(aws-iot-example ${BL2_IMAGE_LOAD_ADDRESS} ${S_IMAGE_LOAD_ADDRESS} ${NS_IMAGE_LOAD_ADDRESS} ${S_PROVISIONING_BUNDLE_LOAD_ADDRESS} ${NS_PROVISIONING_BUNDLE_LOAD_ADDRESS} ${CMAKE_BINARY_DIR}/Projects/aws-iot-example/provisioning_data/provisioning_data.bin) - -list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/Middleware/AWS/cmake) -include(GenerateAWSUpdateDigestAndSignature) +iot_reference_arm_corstone3xx_tf_m_merge_images( + aws-iot-example + ${BL2_IMAGE_LOAD_ADDRESS} + ${S_IMAGE_LOAD_ADDRESS} + ${NS_IMAGE_LOAD_ADDRESS} + ${S_PROVISIONING_BUNDLE_LOAD_ADDRESS} + ${NS_PROVISIONING_BUNDLE_LOAD_ADDRESS} + ${CMAKE_BINARY_DIR}/provisioning_data/provisioning_data.bin +) -iot_reference_arm_corstone3xx_generate_aws_update_digest_and_signature(aws-iot-example aws-iot-example-update_signed update-digest update-signature) +# Generate the AWS OTA update digest and signature +iot_reference_arm_corstone3xx_generate_aws_update_digest_and_signature( + aws-iot-example + aws-iot-example-update_signed + update-digest + update-signature +) diff --git a/Projects/aws-iot-example/event-helper/CMakeLists.txt b/Projects/aws-iot-example/event-helper/CMakeLists.txt deleted file mode 100644 index f103fa34..00000000 --- a/Projects/aws-iot-example/event-helper/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright 2023 Arm Limited and/or its affiliates -# -# SPDX-License-Identifier: MIT - -# System event helper library - -add_library(event-helper STATIC) - -target_sources(event-helper - PRIVATE - event_helper.c -) - -target_include_directories(event-helper - PUBLIC - . -) - -target_link_libraries(event-helper - PRIVATE - freertos_kernel -) diff --git a/Projects/aws-iot-example/main.c b/Projects/aws-iot-example/main.c index 02f762f5..803a14a9 100644 --- a/Projects/aws-iot-example/main.c +++ b/Projects/aws-iot-example/main.c @@ -24,7 +24,7 @@ #include "mbedtls/platform.h" #include "threading_alt.h" -#include "event_helper.h" +#include "events.h" /* Include header that defines log levels. */ #include "logging_levels.h" diff --git a/Projects/aws-iot-example/mqtt-agent-wrapper/CMakeLists.txt b/Projects/aws-iot-example/mqtt-agent-wrapper/CMakeLists.txt deleted file mode 100644 index ebc400ee..00000000 --- a/Projects/aws-iot-example/mqtt-agent-wrapper/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright 2023 Arm Limited and/or its affiliates -# -# SPDX-License-Identifier: MIT - -# MQTT agent task library - -add_library(mqtt-agent-task STATIC) - -target_sources(mqtt-agent-task - PRIVATE - ota_agent_task.c - mqtt_agent_task.c - subscription_manager.c - freertos_command_pool.c - freertos_agent_message.c -) - -target_include_directories(mqtt-agent-task - PUBLIC - . -) - -target_link_libraries(mqtt-agent-task - PRIVATE - freertos_kernel - freertos-ota-pal-psa - awsIoT - app-config - app-logging - event-helper - connectivity-stack -) diff --git a/Projects/aws-iot-example/mqtt-agent-wrapper/freertos_agent_message.c b/Projects/aws-iot-example/mqtt-agent-wrapper/freertos_agent_message.c deleted file mode 100644 index 7dc7157c..00000000 --- a/Projects/aws-iot-example/mqtt-agent-wrapper/freertos_agent_message.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * FreeRTOS V202104.00 - * Copyright (C) 2020 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 - * - */ - -/** - * @file freertos_agent_message.c - * @brief Implements functions to interact with queues. - */ - -/* Standard includes. */ -#include -#include - -/* Kernel includes. */ -#include "FreeRTOS.h" -#include "semphr.h" - -/* Header include. */ -#include "freertos_agent_message.h" -#include "core_mqtt_agent_message_interface.h" - -/*-----------------------------------------------------------*/ - -bool Agent_MessageSend( MQTTAgentMessageContext_t * pMsgCtx, - MQTTAgentCommand_t * const * pCommandToSend, - uint32_t blockTimeMs ) -{ - BaseType_t queueStatus = pdFAIL; - - if( ( pMsgCtx != NULL ) && ( pCommandToSend != NULL ) ) - { - queueStatus = xQueueSendToBack( pMsgCtx->queue, pCommandToSend, pdMS_TO_TICKS( blockTimeMs ) ); - } - - return ( queueStatus == pdPASS ) ? true : false; -} - -/*-----------------------------------------------------------*/ - -bool Agent_MessageReceive( MQTTAgentMessageContext_t * pMsgCtx, - MQTTAgentCommand_t ** pReceivedCommand, - uint32_t blockTimeMs ) -{ - BaseType_t queueStatus = pdFAIL; - - if( ( pMsgCtx != NULL ) && ( pReceivedCommand != NULL ) ) - { - queueStatus = xQueueReceive( pMsgCtx->queue, pReceivedCommand, pdMS_TO_TICKS( blockTimeMs ) ); - } - - return ( queueStatus == pdPASS ) ? true : false; -} diff --git a/Projects/aws-iot-example/mqtt-agent-wrapper/freertos_agent_message.h b/Projects/aws-iot-example/mqtt-agent-wrapper/freertos_agent_message.h deleted file mode 100644 index 0051aaaf..00000000 --- a/Projects/aws-iot-example/mqtt-agent-wrapper/freertos_agent_message.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * FreeRTOS V202104.00 - * Copyright (C) 2020 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 - * - */ - -/** - * @file freertos_core_mqtt_agent_message_interface.h - * @brief Functions to interact with queues. - */ -#ifndef FREERTOS_AGENT_MESSAGE_H -#define FREERTOS_AGENT_MESSAGE_H - -#include -#include -#include - -/* FreeRTOS includes. */ -#include "FreeRTOS.h" -#include "queue.h" - -/* Include MQTT agent messaging interface. */ -#include "core_mqtt_agent_message_interface.h" - -/** - * @ingroup mqtt_agent_struct_types - * @brief Context with which tasks may deliver messages to the agent. - */ -struct MQTTAgentMessageContext -{ - QueueHandle_t queue; -}; - -/*-----------------------------------------------------------*/ - -/** - * @brief Send a message to the specified context. - * Must be thread safe. - * - * @param[in] pMsgCtx An #MQTTAgentMessageContext_t. - * @param[in] pCommandToSend Pointer to address to send to queue. - * @param[in] blockTimeMs Block time to wait for a send. - * - * @return `true` if send was successful, else `false`. - */ -bool Agent_MessageSend( MQTTAgentMessageContext_t * pMsgCtx, - MQTTAgentCommand_t * const * pCommandToSend, - uint32_t blockTimeMs ); - -/** - * @brief Receive a message from the specified context. - * Must be thread safe. - * - * @param[in] pMsgCtx An #MQTTAgentMessageContext_t. - * @param[in] pReceivedCommand Pointer to write address of received command. - * @param[in] blockTimeMs Block time to wait for a receive. - * - * @return `true` if receive was successful, else `false`. - */ -bool Agent_MessageReceive( MQTTAgentMessageContext_t * pMsgCtx, - MQTTAgentCommand_t ** pReceivedCommand, - uint32_t blockTimeMs ); - -#endif /* FREERTOS_AGENT_MESSAGE_H */ diff --git a/Projects/aws-iot-example/mqtt-agent-wrapper/freertos_command_pool.c b/Projects/aws-iot-example/mqtt-agent-wrapper/freertos_command_pool.c deleted file mode 100644 index c2fffcc1..00000000 --- a/Projects/aws-iot-example/mqtt-agent-wrapper/freertos_command_pool.c +++ /dev/null @@ -1,160 +0,0 @@ -/* - * FreeRTOS V202104.00 - * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * Copyright 2023 Arm Limited and/or its affiliates - * - * - * 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 - * - */ - -/** - * @file freertos_command_pool.c - * @brief Implements functions to obtain and release commands. - */ - -/* Standard includes. */ -#include -#include - -/* Kernel includes. */ -#include "FreeRTOS.h" -#include "semphr.h" - -/* Header include. */ -#include "freertos_command_pool.h" -#include "freertos_agent_message.h" - -/* Include header that defines log levels. */ -#include "logging_levels.h" - -/* Configure name and log level. */ -#ifndef LIBRARY_LOG_NAME - #define LIBRARY_LOG_NAME "COMMAND POOL" -#endif -#ifndef LIBRARY_LOG_LEVEL - #define LIBRARY_LOG_LEVEL LOG_INFO -#endif -#include "logging_stack.h" -#include "core_mqtt_config.h" - -/*-----------------------------------------------------------*/ - -#define QUEUE_NOT_INITIALIZED ( 0U ) -#define QUEUE_INITIALIZED ( 1U ) - -/** - * @brief The pool of command structures used to hold information on commands (such - * as PUBLISH or SUBSCRIBE) between the command being created by an API call and - * completion of the command by the execution of the command's callback. - */ -static MQTTAgentCommand_t commandStructurePool[ MQTT_COMMAND_CONTEXTS_POOL_SIZE ]; - -/** - * @brief The message context used to guard the pool of MQTTAgentCommand_t structures. - * For FreeRTOS, this is implemented with a queue. Structures may be - * obtained by receiving a pointer from the queue, and returned by - * sending the pointer back into it. - */ -static MQTTAgentMessageContext_t commandStructMessageCtx; - -/** - * @brief Initialization status of the queue. - */ -static volatile uint8_t initStatus = QUEUE_NOT_INITIALIZED; - -/*-----------------------------------------------------------*/ - -void Agent_InitializePool( void ) -{ - MQTTAgentCommand_t * pCommand; - static StaticQueue_t staticQueueStructure; - - if( initStatus == QUEUE_NOT_INITIALIZED ) - { - static uint8_t staticQueueStorageArea[ MQTT_COMMAND_CONTEXTS_POOL_SIZE * sizeof( MQTTAgentCommand_t * ) ]; - memset( ( void * ) commandStructurePool, 0x00, sizeof( commandStructurePool ) ); - commandStructMessageCtx.queue = xQueueCreateStatic( MQTT_COMMAND_CONTEXTS_POOL_SIZE, - sizeof( MQTTAgentCommand_t * ), - staticQueueStorageArea, - &staticQueueStructure ); - configASSERT( commandStructMessageCtx.queue ); - - size_t i; - - /* Populate the queue. */ - for( i = 0; i < MQTT_COMMAND_CONTEXTS_POOL_SIZE; i++ ) - { - /* Store the address as a variable. */ - pCommand = &commandStructurePool[ i ]; - /* Send the pointer to the queue. */ - bool commandAdded = Agent_MessageSend( &commandStructMessageCtx, &pCommand, 0U ); - configASSERT( commandAdded ); - } - - initStatus = QUEUE_INITIALIZED; - } -} - -/*-----------------------------------------------------------*/ - -MQTTAgentCommand_t * Agent_GetCommand( uint32_t blockTimeMs ) -{ - MQTTAgentCommand_t * structToUse = NULL; - bool structRetrieved = false; - - /* Check queue has been created. */ - configASSERT( initStatus == QUEUE_INITIALIZED ); - - /* Retrieve a struct from the queue. */ - structRetrieved = Agent_MessageReceive( &commandStructMessageCtx, &( structToUse ), blockTimeMs ); - - if( !structRetrieved ) - { - LogDebug( ( "No command structure available.\n" ) ); - } - - return structToUse; -} - -/*-----------------------------------------------------------*/ - -bool Agent_ReleaseCommand( MQTTAgentCommand_t * pCommandToRelease ) -{ - bool structReturned = false; - - configASSERT( initStatus == QUEUE_INITIALIZED ); - - /* See if the structure being returned is actually from the pool. */ - if( ( pCommandToRelease >= commandStructurePool ) && - ( pCommandToRelease < ( commandStructurePool + MQTT_COMMAND_CONTEXTS_POOL_SIZE ) ) ) - { - structReturned = Agent_MessageSend( &commandStructMessageCtx, &pCommandToRelease, 0U ); - - /* The send should not fail as the queue was created to hold every command - * in the pool. */ - configASSERT( structReturned ); - LogDebug( ( "Returned Command Context %d to pool\n", - ( int ) ( pCommandToRelease - commandStructurePool ) ) ); - } - - return structReturned; -} diff --git a/Projects/aws-iot-example/mqtt-agent-wrapper/freertos_command_pool.h b/Projects/aws-iot-example/mqtt-agent-wrapper/freertos_command_pool.h deleted file mode 100644 index 587cb426..00000000 --- a/Projects/aws-iot-example/mqtt-agent-wrapper/freertos_command_pool.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * FreeRTOS V202104.00 - * Copyright (C) 2020 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 - * - */ - -/** - * @file freertos_command_pool.h - * @brief Functions to obtain and release a command. - */ -#ifndef FREERTOS_COMMAND_POOL_H -#define FREERTOS_COMMAND_POOL_H - -/* MQTT agent includes. */ -#include "core_mqtt_agent.h" - -/** - * @brief Initialize the common task pool. Not thread safe. - */ -void Agent_InitializePool( void ); - -/** - * @brief Obtain a MQTTAgentCommand_t structure from the pool of structures managed by the agent. - * - * @note MQTTAgentCommand_t structures hold everything the MQTT agent needs to process a - * command that originates from application. Examples of commands are PUBLISH and - * SUBSCRIBE. The MQTTAgentCommand_t structure must persist for the duration of the command's - * operation so are obtained from a pool of statically allocated structures when a - * new command is created, and returned to the pool when the command is complete. - * The MQTT_COMMAND_CONTEXTS_POOL_SIZE configuration file constant defines how many - * structures the pool contains. - * - * @param[in] blockTimeMs The length of time the calling task should remain in the - * Blocked state (so not consuming any CPU time) to wait for a MQTTAgentCommand_t structure to - * become available should one not be immediately at the time of the call. - * - * @return A pointer to a MQTTAgentCommand_t structure if one becomes available before - * blockTimeMs time expired, otherwise NULL. - */ -MQTTAgentCommand_t * Agent_GetCommand( uint32_t blockTimeMs ); - -/** - * @brief Give a MQTTAgentCommand_t structure back to the the pool of structures managed by - * the agent. - * - * @note MQTTAgentCommand_t structures hold everything the MQTT agent needs to process a - * command that originates from application. Examples of commands are PUBLISH and - * SUBSCRIBE. The MQTTAgentCommand_t structure must persist for the duration of the command's - * operation so are obtained from a pool of statically allocated structures when a - * new command is created, and returned to the pool when the command is complete. - * The MQTT_COMMAND_CONTEXTS_POOL_SIZE configuration file constant defines how many - * structures the pool contains. - * - * @param[in] pCommandToRelease A pointer to the MQTTAgentCommand_t structure to return to - * the pool. The structure must first have been obtained by calling - * Agent_GetCommand(), otherwise Agent_ReleaseCommand() will - * have no effect. - * - * @return true if the MQTTAgentCommand_t structure was returned to the pool, otherwise false. - */ -bool Agent_ReleaseCommand( MQTTAgentCommand_t * pCommandToRelease ); - -#endif /* FREERTOS_COMMAND_POOL_H */ diff --git a/Projects/aws-iot-example/mqtt-agent-wrapper/subscription_manager.c b/Projects/aws-iot-example/mqtt-agent-wrapper/subscription_manager.c deleted file mode 100644 index 9daac2df..00000000 --- a/Projects/aws-iot-example/mqtt-agent-wrapper/subscription_manager.c +++ /dev/null @@ -1,188 +0,0 @@ -/* - * FreeRTOS V202212.00 - * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * Copyright 2023 Arm Limited and/or its affiliates - * - * - * 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 - * - */ - -/** - * @file subscription_manager.c - * @brief Functions for managing MQTT subscriptions. - */ - -/* Standard includes. */ -#include - -/* Include header that defines log levels. */ -#include "logging_levels.h" - -/* Configure name and log level. */ -#ifndef LIBRARY_LOG_NAME - #define LIBRARY_LOG_NAME "SUB MGR" -#endif -#ifndef LIBRARY_LOG_LEVEL - #define LIBRARY_LOG_LEVEL LOG_INFO -#endif -#include "logging_stack.h" - -/* Subscription manager header include. */ -#include "subscription_manager.h" - -/** - * @brief The global array of subscription elements. - * - * @note No thread safety is required to this array, since the updates the array - * elements are done only from one task at a time. The subscription manager - * implementation expects that the array of the subscription elements used for - * storing subscriptions to be initialized to 0. As this is a global array, it - * will be intialized to 0 by default. - */ -SubscriptionElement_t xGlobalSubscriptionList[ SUBSCRIPTION_MANAGER_MAX_SUBSCRIPTIONS ]; - - -bool addSubscription( const char * pcTopicFilterString, - uint16_t usTopicFilterLength, - IncomingPubCallback_t pxIncomingPublishCallback, - void * pvIncomingPublishCallbackContext ) -{ - bool xReturnStatus = false; - - if( ( pcTopicFilterString == NULL ) || - ( usTopicFilterLength == 0U ) || - ( pxIncomingPublishCallback == NULL ) ) - { - LogError( ( "Invalid parameter. spcTopicFilterString=%p," - " usTopicFilterLength=%u, pxIncomingPublishCallback=%p.", - pcTopicFilterString, - ( unsigned int ) usTopicFilterLength, - pxIncomingPublishCallback ) ); - } - else - { - int32_t lIndex; - size_t xAvailableIndex = SUBSCRIPTION_MANAGER_MAX_SUBSCRIPTIONS; - - /* Start at end of array, so that we will insert at the first available index. - * Scans backwards to find duplicates. */ - for( lIndex = ( int32_t ) SUBSCRIPTION_MANAGER_MAX_SUBSCRIPTIONS - 1; lIndex >= 0; lIndex-- ) - { - if( xGlobalSubscriptionList[ lIndex ].usFilterStringLength == 0 ) - { - xAvailableIndex = lIndex; - } - else if( ( xGlobalSubscriptionList[ lIndex ].usFilterStringLength == usTopicFilterLength ) && - ( strncmp( pcTopicFilterString, xGlobalSubscriptionList[ lIndex ].pcSubscriptionFilterString, ( size_t ) usTopicFilterLength ) == 0 ) ) - { - /* If a subscription already exists, don't do anything. */ - if( ( xGlobalSubscriptionList[ lIndex ].pxIncomingPublishCallback == pxIncomingPublishCallback ) && - ( xGlobalSubscriptionList[ lIndex ].pvIncomingPublishCallbackContext == pvIncomingPublishCallbackContext ) ) - { - LogWarn( ( "Subscription already exists.\n" ) ); - xAvailableIndex = SUBSCRIPTION_MANAGER_MAX_SUBSCRIPTIONS; - xReturnStatus = true; - break; - } - } - } - - if( xAvailableIndex < SUBSCRIPTION_MANAGER_MAX_SUBSCRIPTIONS ) - { - xGlobalSubscriptionList[ xAvailableIndex ].pcSubscriptionFilterString = pcTopicFilterString; - xGlobalSubscriptionList[ xAvailableIndex ].usFilterStringLength = usTopicFilterLength; - xGlobalSubscriptionList[ xAvailableIndex ].pxIncomingPublishCallback = pxIncomingPublishCallback; - xGlobalSubscriptionList[ xAvailableIndex ].pvIncomingPublishCallbackContext = pvIncomingPublishCallbackContext; - xReturnStatus = true; - } - } - - return xReturnStatus; -} - -/*-----------------------------------------------------------*/ - -void removeSubscription( const char * pcTopicFilterString, - uint16_t usTopicFilterLength ) -{ - if( ( pcTopicFilterString == NULL ) || - ( usTopicFilterLength == 0U ) ) - { - LogError( ( "Invalid parameter. pcTopicFilterString=%p," - " usTopicFilterLength=%u.", - pcTopicFilterString, - ( unsigned int ) usTopicFilterLength ) ); - } - else - { - int32_t lIndex; - - for( lIndex = 0; lIndex < SUBSCRIPTION_MANAGER_MAX_SUBSCRIPTIONS; lIndex++ ) - { - if( xGlobalSubscriptionList[ lIndex ].usFilterStringLength == usTopicFilterLength ) - { - if( strncmp( xGlobalSubscriptionList[ lIndex ].pcSubscriptionFilterString, pcTopicFilterString, usTopicFilterLength ) == 0 ) - { - memset( &( xGlobalSubscriptionList[ lIndex ] ), 0x00, sizeof( SubscriptionElement_t ) ); - } - } - } - } -} - -/*-----------------------------------------------------------*/ - -bool handleIncomingPublishes( MQTTPublishInfo_t * pxPublishInfo ) -{ - bool isMatched = false, publishHandled = false; - - if( pxPublishInfo == NULL ) - { - LogError( ( "Invalid parameter. pxPublishInfo=%p,", - pxPublishInfo ) ); - } - else - { - int32_t lIndex; - - for( lIndex = 0; lIndex < SUBSCRIPTION_MANAGER_MAX_SUBSCRIPTIONS; lIndex++ ) - { - if( xGlobalSubscriptionList[ lIndex ].usFilterStringLength > 0 ) - { - MQTT_MatchTopic( pxPublishInfo->pTopicName, - pxPublishInfo->topicNameLength, - xGlobalSubscriptionList[ lIndex ].pcSubscriptionFilterString, - xGlobalSubscriptionList[ lIndex ].usFilterStringLength, - &isMatched ); - - if( isMatched == true ) - { - xGlobalSubscriptionList[ lIndex ].pxIncomingPublishCallback( xGlobalSubscriptionList[ lIndex ].pvIncomingPublishCallbackContext, - pxPublishInfo ); - publishHandled = true; - } - } - } - } - - return publishHandled; -} diff --git a/Projects/aws-iot-example/mqtt-agent-wrapper/subscription_manager.h b/Projects/aws-iot-example/mqtt-agent-wrapper/subscription_manager.h deleted file mode 100644 index 9d09e16c..00000000 --- a/Projects/aws-iot-example/mqtt-agent-wrapper/subscription_manager.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * FreeRTOS V202011.00 - * Copyright (C) 2020 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://aws.amazon.com/freertos - * - */ - -/** - * @file subscription_manager.h - * @brief Functions for managing MQTT subscriptions. - */ -#ifndef SUBSCRIPTION_MANAGER_H -#define SUBSCRIPTION_MANAGER_H - -#include "core_mqtt.h" - -/** - * @brief Maximum number of subscriptions maintained by the subscription manager - * simultaneously in a list. - */ -#ifndef SUBSCRIPTION_MANAGER_MAX_SUBSCRIPTIONS - #define SUBSCRIPTION_MANAGER_MAX_SUBSCRIPTIONS 10U -#endif - -/** - * @brief Callback function called when receiving a publish. - * - * @param[in] pvIncomingPublishCallbackContext The incoming publish callback context. - * @param[in] pxPublishInfo Deserialized publish information. - */ -typedef void (* IncomingPubCallback_t )( void * pvIncomingPublishCallbackContext, - MQTTPublishInfo_t * pxPublishInfo ); - -/** - * @brief An element in the list of subscriptions. - * - * This subscription manager implementation expects that the array of the - * subscription elements used for storing subscriptions to be initialized to 0. - * - * @note This implementation allows multiple tasks to subscribe to the same topic. - * In this case, another element is added to the subscription list, differing - * in the intended publish callback. Also note that the topic filters are not - * copied in the subscription manager and hence the topic filter strings need to - * stay in scope until unsubscribed. - */ -typedef struct subscriptionElement -{ - IncomingPubCallback_t pxIncomingPublishCallback; - void * pvIncomingPublishCallbackContext; - uint16_t usFilterStringLength; - const char * pcSubscriptionFilterString; -} SubscriptionElement_t; - -/** - * @brief Add a subscription to the subscription list. - * - * @note Multiple tasks can be subscribed to the same topic with different - * context-callback pairs. However, a single context-callback pair may only be - * associated to the same topic filter once. - * - * @param[in] pxSubscriptionList The pointer to the subscription list array. - * @param[in] pcTopicFilterString Topic filter string of subscription. - * @param[in] usTopicFilterLength Length of topic filter string. - * @param[in] pxIncomingPublishCallback Callback function for the subscription. - * @param[in] pvIncomingPublishCallbackContext Context for the subscription callback. - * - * @return `true` if subscription added or exists, `false` if insufficient memory. - */ -bool addSubscription( const char * pcTopicFilterString, - uint16_t usTopicFilterLength, - IncomingPubCallback_t pxIncomingPublishCallback, - void * pvIncomingPublishCallbackContext ); - -/** - * @brief Remove a subscription from the subscription list. - * - * @note If the topic filter exists multiple times in the subscription list, - * then every instance of the subscription will be removed. - * - * @param[in] pxSubscriptionList The pointer to the subscription list array. - * @param[in] pcTopicFilterString Topic filter of subscription. - * @param[in] usTopicFilterLength Length of topic filter. - */ -void removeSubscription( const char * pcTopicFilterString, - uint16_t usTopicFilterLength ); - -/** - * @brief Handle incoming publishes by invoking the callbacks registered - * for the incoming publish's topic filter. - * - * @param[in] pxSubscriptionList The pointer to the subscription list array. - * @param[in] pxPublishInfo Info of incoming publish. - * - * @return `true` if an application callback could be invoked; - * `false` otherwise. - */ -bool handleIncomingPublishes( MQTTPublishInfo_t * pxPublishInfo ); - -#endif /* SUBSCRIPTION_MANAGER_H */ diff --git a/Projects/aws-iot-example/provisioning/CMakeLists.txt b/Projects/aws-iot-example/provisioning/CMakeLists.txt index b9ea1269..d61602e6 100644 --- a/Projects/aws-iot-example/provisioning/CMakeLists.txt +++ b/Projects/aws-iot-example/provisioning/CMakeLists.txt @@ -23,15 +23,17 @@ target_link_libraries(provisioning_data PRIVATE fri-bsp ) -ExternalProject_Get_Property(tf-m-build BINARY_DIR) +ExternalProject_Get_Property(trusted_firmware-m-build BINARY_DIR) add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/aws_clientcredential_keys.h DEPENDS ${AWS_CLIENT_PRIVATE_KEY_PEM_PATH} DEPENDS ${AWS_CLIENT_CERTIFICATE_PEM_PATH} - COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/generate_credentials_header.py - --client_private_key_pem ${AWS_CLIENT_PRIVATE_KEY_PEM_PATH} - --client_certificate_pem ${AWS_CLIENT_CERTIFICATE_PEM_PATH} - --code_signing_public_key_pem ${BINARY_DIR}/api_ns/image_signing/keys/image_ns_signing_public_key.pem + COMMAND + ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/generate_credentials_header.py + ${CMAKE_CURRENT_BINARY_DIR} + --path-to-client-private-key-pem ${AWS_CLIENT_PRIVATE_KEY_PEM_PATH} + --path-to-client-certificate-pem ${AWS_CLIENT_CERTIFICATE_PEM_PATH} + --path-to-code-signing-public-key-pem ${BINARY_DIR}/api_ns/image_signing/keys/image_ns_signing_public_key.pem ) add_custom_target(aws_clientcredential_keys_header @@ -39,7 +41,7 @@ add_custom_target(aws_clientcredential_keys_header ${CMAKE_CURRENT_BINARY_DIR}/aws_clientcredential_keys.h ) -add_dependencies(aws_clientcredential_keys_header tf-m-build) +add_dependencies(aws_clientcredential_keys_header trusted_firmware-m-build) add_dependencies(provisioning_data aws_clientcredential_keys_header) if(${CMAKE_C_COMPILER_ID} STREQUAL "GNU") @@ -53,7 +55,7 @@ else() target_add_scatter_file(provisioning_data ${CMAKE_CURRENT_SOURCE_DIR}/provisioning_data.sct) endif() -list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/Tools/cmake) +list(APPEND CMAKE_MODULE_PATH ${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/Tools/cmake) include(ConvertElfToBin) add_custom_command(OUTPUT provisioning_data.bin diff --git a/Projects/helpers/CMakeLists.txt b/Projects/helpers/CMakeLists.txt index 3a0b4180..a9d3c214 100644 --- a/Projects/helpers/CMakeLists.txt +++ b/Projects/helpers/CMakeLists.txt @@ -2,4 +2,5 @@ # # SPDX-License-Identifier: MIT +add_subdirectory(events) add_subdirectory(logging) diff --git a/Projects/helpers/events/CMakeLists.txt b/Projects/helpers/events/CMakeLists.txt new file mode 100644 index 00000000..e2bcc490 --- /dev/null +++ b/Projects/helpers/events/CMakeLists.txt @@ -0,0 +1,16 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +add_library(helpers-events + src/events.c +) + +target_include_directories(helpers-events + PUBLIC + inc +) + +target_link_libraries(helpers-events + freertos_kernel +) diff --git a/Projects/aws-iot-example/event-helper/event_helper.h b/Projects/helpers/events/inc/events.h similarity index 93% rename from Projects/aws-iot-example/event-helper/event_helper.h rename to Projects/helpers/events/inc/events.h index e4ed2965..6d665641 100644 --- a/Projects/aws-iot-example/event-helper/event_helper.h +++ b/Projects/helpers/events/inc/events.h @@ -3,8 +3,8 @@ * SPDX-License-Identifier: MIT */ -#ifndef EVENT_HELPER_H -#define EVENT_HELPER_H +#ifndef EVENT_H +#define EVENT_H #include @@ -45,4 +45,4 @@ void vWaitUntilMQTTAgentConnected( void ); */ bool xIsMqttAgentConnected( void ); -#endif /* EVENT_HELPER_H */ +#endif /* EVENT_H */ diff --git a/Projects/aws-iot-example/event-helper/event_helper.c b/Projects/helpers/events/src/events.c similarity index 95% rename from Projects/aws-iot-example/event-helper/event_helper.c rename to Projects/helpers/events/src/events.c index 4286b825..07a1a4a9 100644 --- a/Projects/aws-iot-example/event-helper/event_helper.c +++ b/Projects/helpers/events/src/events.c @@ -3,7 +3,7 @@ * SPDX-License-Identifier: MIT */ -#include "event_helper.h" +#include "events.h" /* System events group. */ EventGroupHandle_t xSystemEvents = NULL; @@ -58,5 +58,5 @@ bool xIsMqttAgentConnected( void ) { EventBits_t uxEvents = xEventGroupGetBits( xSystemEvents ); - return( ( uxEvents & EVENT_MASK_MQTT_CONNECTED ) == 0 ? false : true ); + return( ( bool ) ( uxEvents & EVENT_MASK_MQTT_CONNECTED ) ); } diff --git a/Tools/scripts/build.sh b/Tools/scripts/build.sh index 0713f3d1..c995ad38 100755 --- a/Tools/scripts/build.sh +++ b/Tools/scripts/build.sh @@ -47,13 +47,13 @@ function build_with_cmake { -S $PATH_TO_SOURCE \ -DCMAKE_SYSTEM_PROCESSOR=$TARGET_PROCESSOR \ -DARM_CORSTONE_BSP_TARGET_PLATFORM=$TARGET \ - -DINTEGRATION_TESTS=$INTEGRATION_TESTS \ -DAWS_CLIENT_PRIVATE_KEY_PEM_PATH=$PRIVATE_KEY_PATH \ -DAWS_CLIENT_CERTIFICATE_PEM_PATH=$CERTIFICATE_PATH \ -DIOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR=$ROOT + if [[ $BUILD -ne 0 ]]; then - cmake --build $BUILD_PATH --target $EXAMPLE + cmake --build $BUILD_PATH --target "$EXAMPLE" fi ) } diff --git a/components/aws_iot/coremqtt_agent/integration/src/freertos_command_pool.c b/components/aws_iot/coremqtt_agent/integration/src/freertos_command_pool.c index e275a5b6..c2fffcc1 100644 --- a/components/aws_iot/coremqtt_agent/integration/src/freertos_command_pool.c +++ b/components/aws_iot/coremqtt_agent/integration/src/freertos_command_pool.c @@ -1,6 +1,8 @@ /* * FreeRTOS V202104.00 * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2023 Arm Limited and/or its affiliates + * * * 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 @@ -30,41 +32,41 @@ */ /* Standard includes. */ -#include #include +#include /* Kernel includes. */ #include "FreeRTOS.h" #include "semphr.h" /* Header include. */ -#include "freertos_agent_message.h" #include "freertos_command_pool.h" +#include "freertos_agent_message.h" /* Include header that defines log levels. */ #include "logging_levels.h" /* Configure name and log level. */ #ifndef LIBRARY_LOG_NAME -#define LIBRARY_LOG_NAME "COMMAND POOL" + #define LIBRARY_LOG_NAME "COMMAND POOL" #endif #ifndef LIBRARY_LOG_LEVEL -#define LIBRARY_LOG_LEVEL LOG_INFO + #define LIBRARY_LOG_LEVEL LOG_INFO #endif -#include "core_mqtt_config.h" #include "logging_stack.h" +#include "core_mqtt_config.h" /*-----------------------------------------------------------*/ -#define QUEUE_NOT_INITIALIZED (0U) -#define QUEUE_INITIALIZED (1U) +#define QUEUE_NOT_INITIALIZED ( 0U ) +#define QUEUE_INITIALIZED ( 1U ) /** * @brief The pool of command structures used to hold information on commands (such * as PUBLISH or SUBSCRIBE) between the command being created by an API call and * completion of the command by the execution of the command's callback. */ -static MQTTAgentCommand_t commandStructurePool[MQTT_COMMAND_CONTEXTS_POOL_SIZE]; +static MQTTAgentCommand_t commandStructurePool[ MQTT_COMMAND_CONTEXTS_POOL_SIZE ]; /** * @brief The message context used to guard the pool of MQTTAgentCommand_t structures. @@ -81,29 +83,31 @@ static volatile uint8_t initStatus = QUEUE_NOT_INITIALIZED; /*-----------------------------------------------------------*/ -void Agent_InitializePool(void) +void Agent_InitializePool( void ) { - size_t i; - MQTTAgentCommand_t *pCommand; - static uint8_t staticQueueStorageArea[MQTT_COMMAND_CONTEXTS_POOL_SIZE * sizeof(MQTTAgentCommand_t *)]; + MQTTAgentCommand_t * pCommand; static StaticQueue_t staticQueueStructure; - bool commandAdded = false; - if (initStatus == QUEUE_NOT_INITIALIZED) { - memset((void *)commandStructurePool, 0x00, sizeof(commandStructurePool)); - commandStructMessageCtx.queue = xQueueCreateStatic(MQTT_COMMAND_CONTEXTS_POOL_SIZE, - sizeof(MQTTAgentCommand_t *), - staticQueueStorageArea, - &staticQueueStructure); - configASSERT(commandStructMessageCtx.queue); + if( initStatus == QUEUE_NOT_INITIALIZED ) + { + static uint8_t staticQueueStorageArea[ MQTT_COMMAND_CONTEXTS_POOL_SIZE * sizeof( MQTTAgentCommand_t * ) ]; + memset( ( void * ) commandStructurePool, 0x00, sizeof( commandStructurePool ) ); + commandStructMessageCtx.queue = xQueueCreateStatic( MQTT_COMMAND_CONTEXTS_POOL_SIZE, + sizeof( MQTTAgentCommand_t * ), + staticQueueStorageArea, + &staticQueueStructure ); + configASSERT( commandStructMessageCtx.queue ); + + size_t i; /* Populate the queue. */ - for (i = 0; i < MQTT_COMMAND_CONTEXTS_POOL_SIZE; i++) { + for( i = 0; i < MQTT_COMMAND_CONTEXTS_POOL_SIZE; i++ ) + { /* Store the address as a variable. */ - pCommand = &commandStructurePool[i]; + pCommand = &commandStructurePool[ i ]; /* Send the pointer to the queue. */ - commandAdded = Agent_MessageSend(&commandStructMessageCtx, &pCommand, 0U); - configASSERT(commandAdded); + bool commandAdded = Agent_MessageSend( &commandStructMessageCtx, &pCommand, 0U ); + configASSERT( commandAdded ); } initStatus = QUEUE_INITIALIZED; @@ -112,19 +116,20 @@ void Agent_InitializePool(void) /*-----------------------------------------------------------*/ -MQTTAgentCommand_t *Agent_GetCommand(uint32_t blockTimeMs) +MQTTAgentCommand_t * Agent_GetCommand( uint32_t blockTimeMs ) { - MQTTAgentCommand_t *structToUse = NULL; + MQTTAgentCommand_t * structToUse = NULL; bool structRetrieved = false; /* Check queue has been created. */ - configASSERT(initStatus == QUEUE_INITIALIZED); + configASSERT( initStatus == QUEUE_INITIALIZED ); /* Retrieve a struct from the queue. */ - structRetrieved = Agent_MessageReceive(&commandStructMessageCtx, &(structToUse), blockTimeMs); + structRetrieved = Agent_MessageReceive( &commandStructMessageCtx, &( structToUse ), blockTimeMs ); - if (!structRetrieved) { - LogDebug(("No command structure available.\n")); + if( !structRetrieved ) + { + LogDebug( ( "No command structure available.\n" ) ); } return structToUse; @@ -132,21 +137,23 @@ MQTTAgentCommand_t *Agent_GetCommand(uint32_t blockTimeMs) /*-----------------------------------------------------------*/ -bool Agent_ReleaseCommand(MQTTAgentCommand_t *pCommandToRelease) +bool Agent_ReleaseCommand( MQTTAgentCommand_t * pCommandToRelease ) { bool structReturned = false; - configASSERT(initStatus == QUEUE_INITIALIZED); + configASSERT( initStatus == QUEUE_INITIALIZED ); /* See if the structure being returned is actually from the pool. */ - if ((pCommandToRelease >= commandStructurePool) - && (pCommandToRelease < (commandStructurePool + MQTT_COMMAND_CONTEXTS_POOL_SIZE))) { - structReturned = Agent_MessageSend(&commandStructMessageCtx, &pCommandToRelease, 0U); + if( ( pCommandToRelease >= commandStructurePool ) && + ( pCommandToRelease < ( commandStructurePool + MQTT_COMMAND_CONTEXTS_POOL_SIZE ) ) ) + { + structReturned = Agent_MessageSend( &commandStructMessageCtx, &pCommandToRelease, 0U ); /* The send should not fail as the queue was created to hold every command * in the pool. */ - configASSERT(structReturned); - LogDebug(("Returned Command Context %d to pool\n", (int)(pCommandToRelease - commandStructurePool))); + configASSERT( structReturned ); + LogDebug( ( "Returned Command Context %d to pool\n", + ( int ) ( pCommandToRelease - commandStructurePool ) ) ); } return structReturned; diff --git a/components/aws_iot/coremqtt_agent/integration/src/mqtt_agent_task.c b/components/aws_iot/coremqtt_agent/integration/src/mqtt_agent_task.c index c77db1b7..e2ed89d8 100644 --- a/components/aws_iot/coremqtt_agent/integration/src/mqtt_agent_task.c +++ b/components/aws_iot/coremqtt_agent/integration/src/mqtt_agent_task.c @@ -63,7 +63,7 @@ #include "backoff_algorithm.h" /* System events header. */ -#include "event_helper.h" +#include "events.h" /* Configure name and log level. */ #ifndef LIBRARY_LOG_NAME diff --git a/components/aws_iot/coremqtt_agent/integration/src/subscription_manager.c b/components/aws_iot/coremqtt_agent/integration/src/subscription_manager.c index 49d2f1da..9daac2df 100644 --- a/components/aws_iot/coremqtt_agent/integration/src/subscription_manager.c +++ b/components/aws_iot/coremqtt_agent/integration/src/subscription_manager.c @@ -1,6 +1,8 @@ /* * FreeRTOS V202212.00 * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2023 Arm Limited and/or its affiliates + * * * 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 @@ -37,10 +39,10 @@ /* Configure name and log level. */ #ifndef LIBRARY_LOG_NAME -#define LIBRARY_LOG_NAME "SUB MGR" + #define LIBRARY_LOG_NAME "SUB MGR" #endif #ifndef LIBRARY_LOG_LEVEL -#define LIBRARY_LOG_LEVEL LOG_INFO + #define LIBRARY_LOG_LEVEL LOG_INFO #endif #include "logging_stack.h" @@ -56,39 +58,47 @@ * storing subscriptions to be initialized to 0. As this is a global array, it * will be intialized to 0 by default. */ -SubscriptionElement_t xGlobalSubscriptionList[SUBSCRIPTION_MANAGER_MAX_SUBSCRIPTIONS]; +SubscriptionElement_t xGlobalSubscriptionList[ SUBSCRIPTION_MANAGER_MAX_SUBSCRIPTIONS ]; -bool addSubscription(const char *pcTopicFilterString, - uint16_t usTopicFilterLength, - IncomingPubCallback_t pxIncomingPublishCallback, - void *pvIncomingPublishCallbackContext) + +bool addSubscription( const char * pcTopicFilterString, + uint16_t usTopicFilterLength, + IncomingPubCallback_t pxIncomingPublishCallback, + void * pvIncomingPublishCallbackContext ) { - int32_t lIndex = 0; - size_t xAvailableIndex = SUBSCRIPTION_MANAGER_MAX_SUBSCRIPTIONS; bool xReturnStatus = false; - if ((pcTopicFilterString == NULL) || (usTopicFilterLength == 0U) || (pxIncomingPublishCallback == NULL)) { - LogError(("Invalid parameter. spcTopicFilterString=%p," - " usTopicFilterLength=%u, pxIncomingPublishCallback=%p.", - pcTopicFilterString, - (unsigned int)usTopicFilterLength, - pxIncomingPublishCallback)); - } else { + if( ( pcTopicFilterString == NULL ) || + ( usTopicFilterLength == 0U ) || + ( pxIncomingPublishCallback == NULL ) ) + { + LogError( ( "Invalid parameter. spcTopicFilterString=%p," + " usTopicFilterLength=%u, pxIncomingPublishCallback=%p.", + pcTopicFilterString, + ( unsigned int ) usTopicFilterLength, + pxIncomingPublishCallback ) ); + } + else + { + int32_t lIndex; + size_t xAvailableIndex = SUBSCRIPTION_MANAGER_MAX_SUBSCRIPTIONS; + /* Start at end of array, so that we will insert at the first available index. * Scans backwards to find duplicates. */ - for (lIndex = (int32_t)SUBSCRIPTION_MANAGER_MAX_SUBSCRIPTIONS - 1; lIndex >= 0; lIndex--) { - if (xGlobalSubscriptionList[lIndex].usFilterStringLength == 0) { + for( lIndex = ( int32_t ) SUBSCRIPTION_MANAGER_MAX_SUBSCRIPTIONS - 1; lIndex >= 0; lIndex-- ) + { + if( xGlobalSubscriptionList[ lIndex ].usFilterStringLength == 0 ) + { xAvailableIndex = lIndex; - } else if ((xGlobalSubscriptionList[lIndex].usFilterStringLength == usTopicFilterLength) - && (strncmp(pcTopicFilterString, - xGlobalSubscriptionList[lIndex].pcSubscriptionFilterString, - (size_t)usTopicFilterLength) - == 0)) { + } + else if( ( xGlobalSubscriptionList[ lIndex ].usFilterStringLength == usTopicFilterLength ) && + ( strncmp( pcTopicFilterString, xGlobalSubscriptionList[ lIndex ].pcSubscriptionFilterString, ( size_t ) usTopicFilterLength ) == 0 ) ) + { /* If a subscription already exists, don't do anything. */ - if ((xGlobalSubscriptionList[lIndex].pxIncomingPublishCallback == pxIncomingPublishCallback) - && (xGlobalSubscriptionList[lIndex].pvIncomingPublishCallbackContext - == pvIncomingPublishCallbackContext)) { - LogWarn(("Subscription already exists.\n")); + if( ( xGlobalSubscriptionList[ lIndex ].pxIncomingPublishCallback == pxIncomingPublishCallback ) && + ( xGlobalSubscriptionList[ lIndex ].pvIncomingPublishCallbackContext == pvIncomingPublishCallbackContext ) ) + { + LogWarn( ( "Subscription already exists.\n" ) ); xAvailableIndex = SUBSCRIPTION_MANAGER_MAX_SUBSCRIPTIONS; xReturnStatus = true; break; @@ -96,12 +106,12 @@ bool addSubscription(const char *pcTopicFilterString, } } - if (xAvailableIndex < SUBSCRIPTION_MANAGER_MAX_SUBSCRIPTIONS) { - xGlobalSubscriptionList[xAvailableIndex].pcSubscriptionFilterString = pcTopicFilterString; - xGlobalSubscriptionList[xAvailableIndex].usFilterStringLength = usTopicFilterLength; - xGlobalSubscriptionList[xAvailableIndex].pxIncomingPublishCallback = pxIncomingPublishCallback; - xGlobalSubscriptionList[xAvailableIndex].pvIncomingPublishCallbackContext = - pvIncomingPublishCallbackContext; + if( xAvailableIndex < SUBSCRIPTION_MANAGER_MAX_SUBSCRIPTIONS ) + { + xGlobalSubscriptionList[ xAvailableIndex ].pcSubscriptionFilterString = pcTopicFilterString; + xGlobalSubscriptionList[ xAvailableIndex ].usFilterStringLength = usTopicFilterLength; + xGlobalSubscriptionList[ xAvailableIndex ].pxIncomingPublishCallback = pxIncomingPublishCallback; + xGlobalSubscriptionList[ xAvailableIndex ].pvIncomingPublishCallbackContext = pvIncomingPublishCallbackContext; xReturnStatus = true; } } @@ -111,23 +121,28 @@ bool addSubscription(const char *pcTopicFilterString, /*-----------------------------------------------------------*/ -void removeSubscription(const char *pcTopicFilterString, uint16_t usTopicFilterLength) +void removeSubscription( const char * pcTopicFilterString, + uint16_t usTopicFilterLength ) { - int32_t lIndex = 0; - - if ((pcTopicFilterString == NULL) || (usTopicFilterLength == 0U)) { - LogError(("Invalid parameter. pcTopicFilterString=%p," - " usTopicFilterLength=%u.", - pcTopicFilterString, - (unsigned int)usTopicFilterLength)); - } else { - for (lIndex = 0; lIndex < SUBSCRIPTION_MANAGER_MAX_SUBSCRIPTIONS; lIndex++) { - if (xGlobalSubscriptionList[lIndex].usFilterStringLength == usTopicFilterLength) { - if (strncmp(xGlobalSubscriptionList[lIndex].pcSubscriptionFilterString, - pcTopicFilterString, - usTopicFilterLength) - == 0) { - memset(&(xGlobalSubscriptionList[lIndex]), 0x00, sizeof(SubscriptionElement_t)); + if( ( pcTopicFilterString == NULL ) || + ( usTopicFilterLength == 0U ) ) + { + LogError( ( "Invalid parameter. pcTopicFilterString=%p," + " usTopicFilterLength=%u.", + pcTopicFilterString, + ( unsigned int ) usTopicFilterLength ) ); + } + else + { + int32_t lIndex; + + for( lIndex = 0; lIndex < SUBSCRIPTION_MANAGER_MAX_SUBSCRIPTIONS; lIndex++ ) + { + if( xGlobalSubscriptionList[ lIndex ].usFilterStringLength == usTopicFilterLength ) + { + if( strncmp( xGlobalSubscriptionList[ lIndex ].pcSubscriptionFilterString, pcTopicFilterString, usTopicFilterLength ) == 0 ) + { + memset( &( xGlobalSubscriptionList[ lIndex ] ), 0x00, sizeof( SubscriptionElement_t ) ); } } } @@ -136,25 +151,33 @@ void removeSubscription(const char *pcTopicFilterString, uint16_t usTopicFilterL /*-----------------------------------------------------------*/ -bool handleIncomingPublishes(MQTTPublishInfo_t *pxPublishInfo) +bool handleIncomingPublishes( MQTTPublishInfo_t * pxPublishInfo ) { - int32_t lIndex = 0; bool isMatched = false, publishHandled = false; - if (pxPublishInfo == NULL) { - LogError(("Invalid parameter. pxPublishInfo=%p,", pxPublishInfo)); - } else { - for (lIndex = 0; lIndex < SUBSCRIPTION_MANAGER_MAX_SUBSCRIPTIONS; lIndex++) { - if (xGlobalSubscriptionList[lIndex].usFilterStringLength > 0) { - MQTT_MatchTopic(pxPublishInfo->pTopicName, - pxPublishInfo->topicNameLength, - xGlobalSubscriptionList[lIndex].pcSubscriptionFilterString, - xGlobalSubscriptionList[lIndex].usFilterStringLength, - &isMatched); - - if (isMatched == true) { - xGlobalSubscriptionList[lIndex].pxIncomingPublishCallback( - xGlobalSubscriptionList[lIndex].pvIncomingPublishCallbackContext, pxPublishInfo); + if( pxPublishInfo == NULL ) + { + LogError( ( "Invalid parameter. pxPublishInfo=%p,", + pxPublishInfo ) ); + } + else + { + int32_t lIndex; + + for( lIndex = 0; lIndex < SUBSCRIPTION_MANAGER_MAX_SUBSCRIPTIONS; lIndex++ ) + { + if( xGlobalSubscriptionList[ lIndex ].usFilterStringLength > 0 ) + { + MQTT_MatchTopic( pxPublishInfo->pTopicName, + pxPublishInfo->topicNameLength, + xGlobalSubscriptionList[ lIndex ].pcSubscriptionFilterString, + xGlobalSubscriptionList[ lIndex ].usFilterStringLength, + &isMatched ); + + if( isMatched == true ) + { + xGlobalSubscriptionList[ lIndex ].pxIncomingPublishCallback( xGlobalSubscriptionList[ lIndex ].pvIncomingPublishCallbackContext, + pxPublishInfo ); publishHandled = true; } } From 184d4435f6edbe1131d67b1a96010d6fc281a282 Mon Sep 17 00:00:00 2001 From: Hugues Kamba-Mpiana Date: Tue, 10 Oct 2023 06:21:13 +0100 Subject: [PATCH 07/22] aws-iot-example: Add FreeRTOS libs integration test app Signed-off-by: Hugues Kamba-Mpiana --- Projects/aws-iot-example/CMakeLists.txt | 110 ++++++++++++++++++++++++ Tools/scripts/build.sh | 6 +- 2 files changed, 115 insertions(+), 1 deletion(-) diff --git a/Projects/aws-iot-example/CMakeLists.txt b/Projects/aws-iot-example/CMakeLists.txt index c28e34b1..4669605d 100644 --- a/Projects/aws-iot-example/CMakeLists.txt +++ b/Projects/aws-iot-example/CMakeLists.txt @@ -168,3 +168,113 @@ iot_reference_arm_corstone3xx_generate_aws_update_digest_and_signature( update-digest update-signature ) + +# --------------------------------------------------------------------------------------------------------- +# Configure FreeRTOS Libraries Integration Tests +add_dependencies(freertos-libraries-integration-tests-config provisioning_data_bin) +target_sources(freertos-libraries-integration-tests-config + INTERFACE + freertos-integration-tests/integration_tests_platform_function.c +) +target_include_directories(freertos-libraries-integration-tests-config + INTERFACE + freertos-integration-tests/include + provisioning + ${CMAKE_BINARY_DIR}/provisioning + ${CMAKE_BINARY_DIR}/provisioning_data +) +target_link_libraries(freertos-libraries-integration-tests-config + INTERFACE + connectivity-stack + coremqtt + helpers-logging + freertos-libraries-integration-tests-mqtt + freertos-libraries-integration-tests-ota-pal + freertos-libraries-integration-tests-qualification + freertos-libraries-integration-tests-transport + unity +) + +# Add FreeRTOS Libraries Integration Tests application executable +add_executable(aws-iot-example-tests + dev_mode_key_provisioning.c + main.c + mqtt_demo_pub_sub.c + ${corepkcs11_SOURCE_DIR}/source/dependency/3rdparty/mbedtls_utils/mbedtls_utils.c +) +target_include_directories(aws-iot-example-tests + PUBLIC + freertos-integration-tests + provisioning +) + +target_compile_definitions(aws-iot-example-tests + PRIVATE + INTEGRATION_TESTS=1 +) +# Trusted Firmware-M must be built before the application, because +# the application depends on the NS interface and the BL2 signing scripts, +# both of which are generated as parts of the Trusted Firmware-M build process. +add_dependencies(aws-iot-example-tests trusted_firmware-m-build) +# The provision data must be built before the application because +# it provides credentials to connect to AWS +add_dependencies(aws-iot-example-tests provisioning_data_bin) +target_link_libraries(aws-iot-example-tests + PRIVATE + backoff-algorithm + connectivity-stack + coremqtt + coremqtt-agent + corepkcs11 + freertos_kernel + freertos-libraries-integration-tests-config + freertos-ota-pal-psa + fri-bsp + helpers-events + ota-for-aws-iot-embedded-sdk + mbedtls + mbedtls-threading-freertos + tfm-ns-interface +) + +set_linker_script(aws-iot-example-tests) + +# The non-secure application image should be padded while being signed +iot_reference_arm_corstone3xx_tf_m_sign_image( + aws-iot-example-tests + aws-iot-example-tests_signed + ${MCUBOOT_IMAGE_VERSION_NS} + TRUE +) + +# The update image is not padded to fill the whole slot (no --pad), because +# 1) the image to download is smaller without padding +# 2) the trailer that keeps track of boot and update statuses should not be overwritten +iot_reference_arm_corstone3xx_tf_m_sign_image( + aws-iot-example-tests + aws-iot-example-tests-update_signed + ${MCUBOOT_IMAGE_VERSION_NS_UPDATE} + FALSE +) + +# A user project that consumes the ARM FRI needs to explicitly provide +# addresses in order to merge images for TF-M. The addresses cannot +# be easily programmatically extracted as they are defined in the linker +# scripts. +iot_reference_arm_corstone3xx_tf_m_merge_images( + aws-iot-example-tests + ${BL2_IMAGE_LOAD_ADDRESS} + ${S_IMAGE_LOAD_ADDRESS} + ${NS_IMAGE_LOAD_ADDRESS} + ${S_PROVISIONING_BUNDLE_LOAD_ADDRESS} + ${NS_PROVISIONING_BUNDLE_LOAD_ADDRESS} + ${CMAKE_BINARY_DIR}/provisioning_data/provisioning_data.bin +) + +# Generate the AWS OTA update digest and signature +iot_reference_arm_corstone3xx_generate_aws_update_digest_and_signature( + aws-iot-example-tests + aws-iot-example-tests-update_signed + update-digest + update-signature +) diff --git a/Tools/scripts/build.sh b/Tools/scripts/build.sh index c995ad38..3a3b22c7 100755 --- a/Tools/scripts/build.sh +++ b/Tools/scripts/build.sh @@ -52,8 +52,12 @@ function build_with_cmake { -DIOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR=$ROOT - if [[ $BUILD -ne 0 ]]; then + if [[ $BUILD -ne 0 && $INTEGRATION_TESTS -eq 0 ]]; then + echo "Building $EXAMPLE" >&2 cmake --build $BUILD_PATH --target "$EXAMPLE" + elif [[ $BUILD -ne 0 && $INTEGRATION_TESTS -eq 1 ]]; then + echo "Building $EXAMPLE-tests" >&2 + cmake --build $BUILD_PATH --target "$EXAMPLE-tests" fi ) } From 540554001363a07bcb462532e61c23b54704e8a5 Mon Sep 17 00:00:00 2001 From: Hugues Kamba-Mpiana Date: Mon, 9 Oct 2023 10:06:51 +0100 Subject: [PATCH 08/22] run-script: Fix root path and wrap long string Improve readability of the string by wrapping it. Signed-off-by: Hugues Kamba-Mpiana --- Tools/scripts/run.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Tools/scripts/run.sh b/Tools/scripts/run.sh index 0c2bf396..f3505140 100755 --- a/Tools/scripts/run.sh +++ b/Tools/scripts/run.sh @@ -5,7 +5,7 @@ # SPDX-License-Identifier: MIT HERE="$(dirname "$0")" -ROOT="$(realpath $HERE/..)" +ROOT="$(realpath $HERE/../..)" EXAMPLE="" BUILD_PATH="build" TARGET="corstone310" @@ -109,7 +109,14 @@ case "$1" in ;; esac -OPTIONS="-C mps3_board.visualisation.disable-visualisation=1 -C mps3_board.smsc_91c111.enabled=1 -C mps3_board.hostbridge.userNetworking=1 -C mps3_board.telnetterminal0.start_telnet=0 -C mps3_board.uart0.out_file="-" -C mps3_board.uart0.unbuffered_output=1 --stat -C mps3_board.DISABLE_GATING=1" +OPTIONS="-C mps3_board.visualisation.disable-visualisation=1 \ +-C mps3_board.smsc_91c111.enabled=1 \ +-C mps3_board.hostbridge.userNetworking=1 \ +-C mps3_board.telnetterminal0.start_telnet=0 \ +-C mps3_board.uart0.out_file="-" \ +-C mps3_board.uart0.unbuffered_output=1 \ +--stat \ +-C mps3_board.DISABLE_GATING=1" # Start the FVP $FVP_BIN $OPTIONS -a $MERGED_IMAGE_PATH From dcd67f8d78b72287a1e8aa8780d8875ae979f91b Mon Sep 17 00:00:00 2001 From: Hugues Kamba-Mpiana Date: Fri, 27 Oct 2023 11:59:29 +0100 Subject: [PATCH 09/22] provisioning: Make provisioning available to all apps that need it Move the provisioning source code and script to the helpers subdir Signed-off-by: Hugues Kamba-Mpiana --- Projects/aws-iot-example/CMakeLists.txt | 10 ++++----- Projects/helpers/CMakeLists.txt | 1 + .../provisioning/CMakeLists.txt | 21 +++++++++++-------- .../cmake}/linkerscript_preprocess.cmake | 0 .../provisioning/provisioning_config.h | 0 .../provisioning/provisioning_data.c | 0 .../provisioning/provisioning_data.h | 0 .../provisioning/provisioning_data.ld | 0 .../provisioning/provisioning_data.sct | 0 .../scripts}/generate_credentials_header.py | 0 10 files changed, 18 insertions(+), 14 deletions(-) rename Projects/{aws-iot-example => helpers}/provisioning/CMakeLists.txt (75%) rename Projects/{aws-iot-example/provisioning => helpers/provisioning/cmake}/linkerscript_preprocess.cmake (100%) rename Projects/{aws-iot-example => helpers}/provisioning/provisioning_config.h (100%) rename Projects/{aws-iot-example => helpers}/provisioning/provisioning_data.c (100%) rename Projects/{aws-iot-example => helpers}/provisioning/provisioning_data.h (100%) rename Projects/{aws-iot-example => helpers}/provisioning/provisioning_data.ld (100%) rename Projects/{aws-iot-example => helpers}/provisioning/provisioning_data.sct (100%) rename {Projects/aws-iot-example/provisioning => Tools/scripts}/generate_credentials_header.py (100%) diff --git a/Projects/aws-iot-example/CMakeLists.txt b/Projects/aws-iot-example/CMakeLists.txt index 4669605d..3d6fc6b9 100644 --- a/Projects/aws-iot-example/CMakeLists.txt +++ b/Projects/aws-iot-example/CMakeLists.txt @@ -86,7 +86,6 @@ include(SignTfmImage) add_subdirectory(configs) add_subdirectory(../helpers ${CMAKE_BINARY_DIR}/helpers) -add_subdirectory(provisioning provisioning_data) # Add main application executable add_executable(aws-iot-example @@ -98,7 +97,7 @@ add_executable(aws-iot-example target_include_directories(aws-iot-example PUBLIC freertos-integration-tests/include - provisioning + ../helpers/provisioning ) # Trusted Firmware-M must be built before the application, because @@ -158,7 +157,7 @@ iot_reference_arm_corstone3xx_tf_m_merge_images( ${NS_IMAGE_LOAD_ADDRESS} ${S_PROVISIONING_BUNDLE_LOAD_ADDRESS} ${NS_PROVISIONING_BUNDLE_LOAD_ADDRESS} - ${CMAKE_BINARY_DIR}/provisioning_data/provisioning_data.bin + ${CMAKE_BINARY_DIR}/helpers/provisioning/provisioning_data.bin ) # Generate the AWS OTA update digest and signature @@ -182,6 +181,8 @@ target_include_directories(freertos-libraries-integration-tests-config provisioning ${CMAKE_BINARY_DIR}/provisioning ${CMAKE_BINARY_DIR}/provisioning_data + ${CMAKE_BINARY_DIR}/helpers/provisioning + ../helpers/provisioning ) target_link_libraries(freertos-libraries-integration-tests-config INTERFACE @@ -205,7 +206,6 @@ add_executable(aws-iot-example-tests target_include_directories(aws-iot-example-tests PUBLIC freertos-integration-tests - provisioning ) target_compile_definitions(aws-iot-example-tests @@ -268,7 +268,7 @@ iot_reference_arm_corstone3xx_tf_m_merge_images( ${NS_IMAGE_LOAD_ADDRESS} ${S_PROVISIONING_BUNDLE_LOAD_ADDRESS} ${NS_PROVISIONING_BUNDLE_LOAD_ADDRESS} - ${CMAKE_BINARY_DIR}/provisioning_data/provisioning_data.bin + ${CMAKE_BINARY_DIR}/helpers/provisioning/provisioning_data.bin ) # Generate the AWS OTA update digest and signature diff --git a/Projects/helpers/CMakeLists.txt b/Projects/helpers/CMakeLists.txt index a9d3c214..0f29ef20 100644 --- a/Projects/helpers/CMakeLists.txt +++ b/Projects/helpers/CMakeLists.txt @@ -4,3 +4,4 @@ add_subdirectory(events) add_subdirectory(logging) +add_subdirectory(provisioning) diff --git a/Projects/aws-iot-example/provisioning/CMakeLists.txt b/Projects/helpers/provisioning/CMakeLists.txt similarity index 75% rename from Projects/aws-iot-example/provisioning/CMakeLists.txt rename to Projects/helpers/provisioning/CMakeLists.txt index d61602e6..58a75b28 100644 --- a/Projects/aws-iot-example/provisioning/CMakeLists.txt +++ b/Projects/helpers/provisioning/CMakeLists.txt @@ -10,13 +10,16 @@ if(${CMAKE_C_COMPILER_ID} STREQUAL "GNU") string(REPLACE "-g3" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS}) endif() -include(linkerscript_preprocess.cmake) +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake) -add_executable(provisioning_data - provisioning_data.c -) -target_include_directories(provisioning_data PUBLIC - ${CMAKE_CURRENT_BINARY_DIR} +include(linkerscript_preprocess) + +add_executable(provisioning_data provisioning_data.c) +target_include_directories(provisioning_data + PUBLIC + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_LIST_DIR} + ${CMAKE_CURRENT_LIST_DIR}/inc ) target_link_libraries(provisioning_data PRIVATE @@ -29,7 +32,7 @@ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/aws_clientcredential_keys. DEPENDS ${AWS_CLIENT_PRIVATE_KEY_PEM_PATH} DEPENDS ${AWS_CLIENT_CERTIFICATE_PEM_PATH} COMMAND - ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/generate_credentials_header.py + ${Python3_EXECUTABLE} ${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/Tools/scripts/generate_credentials_header.py ${CMAKE_CURRENT_BINARY_DIR} --path-to-client-private-key-pem ${AWS_CLIENT_PRIVATE_KEY_PEM_PATH} --path-to-client-certificate-pem ${AWS_CLIENT_CERTIFICATE_PEM_PATH} @@ -50,9 +53,9 @@ if(${CMAKE_C_COMPILER_ID} STREQUAL "GNU") "--specs=nosys.specs" "-nostartfiles" ) - target_add_scatter_file(provisioning_data ${CMAKE_CURRENT_SOURCE_DIR}/provisioning_data.ld) + target_add_scatter_file(provisioning_data ${CMAKE_CURRENT_LIST_DIR}/provisioning_data.ld) else() - target_add_scatter_file(provisioning_data ${CMAKE_CURRENT_SOURCE_DIR}/provisioning_data.sct) + target_add_scatter_file(provisioning_data ${CMAKE_CURRENT_LIST_DIR}/provisioning_data.sct) endif() list(APPEND CMAKE_MODULE_PATH ${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/Tools/cmake) diff --git a/Projects/aws-iot-example/provisioning/linkerscript_preprocess.cmake b/Projects/helpers/provisioning/cmake/linkerscript_preprocess.cmake similarity index 100% rename from Projects/aws-iot-example/provisioning/linkerscript_preprocess.cmake rename to Projects/helpers/provisioning/cmake/linkerscript_preprocess.cmake diff --git a/Projects/aws-iot-example/provisioning/provisioning_config.h b/Projects/helpers/provisioning/provisioning_config.h similarity index 100% rename from Projects/aws-iot-example/provisioning/provisioning_config.h rename to Projects/helpers/provisioning/provisioning_config.h diff --git a/Projects/aws-iot-example/provisioning/provisioning_data.c b/Projects/helpers/provisioning/provisioning_data.c similarity index 100% rename from Projects/aws-iot-example/provisioning/provisioning_data.c rename to Projects/helpers/provisioning/provisioning_data.c diff --git a/Projects/aws-iot-example/provisioning/provisioning_data.h b/Projects/helpers/provisioning/provisioning_data.h similarity index 100% rename from Projects/aws-iot-example/provisioning/provisioning_data.h rename to Projects/helpers/provisioning/provisioning_data.h diff --git a/Projects/aws-iot-example/provisioning/provisioning_data.ld b/Projects/helpers/provisioning/provisioning_data.ld similarity index 100% rename from Projects/aws-iot-example/provisioning/provisioning_data.ld rename to Projects/helpers/provisioning/provisioning_data.ld diff --git a/Projects/aws-iot-example/provisioning/provisioning_data.sct b/Projects/helpers/provisioning/provisioning_data.sct similarity index 100% rename from Projects/aws-iot-example/provisioning/provisioning_data.sct rename to Projects/helpers/provisioning/provisioning_data.sct diff --git a/Projects/aws-iot-example/provisioning/generate_credentials_header.py b/Tools/scripts/generate_credentials_header.py similarity index 100% rename from Projects/aws-iot-example/provisioning/generate_credentials_header.py rename to Tools/scripts/generate_credentials_header.py From 9b710c438f20286ffa649f9bd41235d0660dc046 Mon Sep 17 00:00:00 2001 From: Hugues Kamba-Mpiana Date: Fri, 3 Nov 2023 13:27:30 +0000 Subject: [PATCH 10/22] bsp: Rename `Bsp` subdir to `bsp` The project is adopting snake case for files and subdirectories names Signed-off-by: Hugues Kamba-Mpiana --- .gitmodules | 2 +- CMakeLists.txt | 2 +- Projects/aws-iot-example/CMakeLists.txt | 2 +- Projects/blinky/CMakeLists.txt | 2 +- {Bsp => bsp}/CMakeLists.txt | 0 {Bsp => bsp}/cmake/BspUtilities.cmake | 8 ++++---- {Bsp => bsp}/common/bsp_serial.c | 0 {Bsp => bsp}/common/bsp_serial.h | 0 {Bsp => bsp}/corstone300/an552_ns.ld | 0 {Bsp => bsp}/corstone300/an552_ns.sct | 0 {Bsp => bsp}/corstone300/include/FreeRTOSConfig_target.h | 0 .../corstone300/include/provisioning_config_target.h | 0 {Bsp => bsp}/corstone310/an555_ns.ld | 0 {Bsp => bsp}/corstone310/an555_ns.sct | 0 {Bsp => bsp}/corstone310/include/FreeRTOSConfig_target.h | 0 .../corstone310/include/provisioning_config_target.h | 0 {Bsp => bsp}/library | 0 manifest.yml | 2 +- 18 files changed, 9 insertions(+), 9 deletions(-) rename {Bsp => bsp}/CMakeLists.txt (100%) rename {Bsp => bsp}/cmake/BspUtilities.cmake (83%) rename {Bsp => bsp}/common/bsp_serial.c (100%) rename {Bsp => bsp}/common/bsp_serial.h (100%) rename {Bsp => bsp}/corstone300/an552_ns.ld (100%) rename {Bsp => bsp}/corstone300/an552_ns.sct (100%) rename {Bsp => bsp}/corstone300/include/FreeRTOSConfig_target.h (100%) rename {Bsp => bsp}/corstone300/include/provisioning_config_target.h (100%) rename {Bsp => bsp}/corstone310/an555_ns.ld (100%) rename {Bsp => bsp}/corstone310/an555_ns.sct (100%) rename {Bsp => bsp}/corstone310/include/FreeRTOSConfig_target.h (100%) rename {Bsp => bsp}/corstone310/include/provisioning_config_target.h (100%) rename {Bsp => bsp}/library (100%) diff --git a/.gitmodules b/.gitmodules index 37fd64df..40018147 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,5 +1,5 @@ [submodule "arm_corstone_platform_bsp"] - path = Bsp/library + path = bsp/library url = https://git.gitlab.arm.com/iot/open-iot-sdk/arm-corstone-platform-bsp.git [submodule "backoff_algorithm"] path = components/connectivity/backoff_algorithm/library diff --git a/CMakeLists.txt b/CMakeLists.txt index e824438c..3f9fd595 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,5 +8,5 @@ project(iot-reference-arm-corstone3xx LANGUAGES C ASM) list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/Tools/cmake) -add_subdirectory(Bsp) +add_subdirectory(bsp) add_subdirectory(components EXCLUDE_FROM_ALL) diff --git a/Projects/aws-iot-example/CMakeLists.txt b/Projects/aws-iot-example/CMakeLists.txt index 3d6fc6b9..b2696472 100644 --- a/Projects/aws-iot-example/CMakeLists.txt +++ b/Projects/aws-iot-example/CMakeLists.txt @@ -76,7 +76,7 @@ endif() add_subdirectory(${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR} ${CMAKE_BINARY_DIR}/iot_reference_arm_corstone3xx) -list(APPEND CMAKE_MODULE_PATH ${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/Bsp/cmake) +list(APPEND CMAKE_MODULE_PATH ${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/bsp/cmake) list(APPEND CMAKE_MODULE_PATH ${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/components/aws_iot/cmake) list(APPEND CMAKE_MODULE_PATH ${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/components/security/trusted_firmware-m/integration/cmake) include(BspUtilities) diff --git a/Projects/blinky/CMakeLists.txt b/Projects/blinky/CMakeLists.txt index d9d7be7f..9a7b4964 100644 --- a/Projects/blinky/CMakeLists.txt +++ b/Projects/blinky/CMakeLists.txt @@ -54,7 +54,7 @@ endif() add_subdirectory(${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR} ${CMAKE_BINARY_DIR}/iot_reference_arm_corstone3xx) -list(APPEND CMAKE_MODULE_PATH ${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/Bsp/cmake) +list(APPEND CMAKE_MODULE_PATH ${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/bsp/cmake) list(APPEND CMAKE_MODULE_PATH ${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/components/security/trusted_firmware-m/integration/cmake) include(BspUtilities) include(MergeTfmImages) diff --git a/Bsp/CMakeLists.txt b/bsp/CMakeLists.txt similarity index 100% rename from Bsp/CMakeLists.txt rename to bsp/CMakeLists.txt diff --git a/Bsp/cmake/BspUtilities.cmake b/bsp/cmake/BspUtilities.cmake similarity index 83% rename from Bsp/cmake/BspUtilities.cmake rename to bsp/cmake/BspUtilities.cmake index 7316f291..f88c9e41 100644 --- a/Bsp/cmake/BspUtilities.cmake +++ b/bsp/cmake/BspUtilities.cmake @@ -7,16 +7,16 @@ macro(set_linker_script executable_target) if(${CMAKE_C_COMPILER_ID} STREQUAL "GNU") target_link_options(${executable_target} PRIVATE - $<$:-T ${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/Bsp/corstone300/an552_ns.ld> - $<$:-T ${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/Bsp/corstone310/an555_ns.ld> + $<$:-T ${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/bsp/corstone300/an552_ns.ld> + $<$:-T ${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/bsp/corstone310/an555_ns.ld> -Wl,--gc-sections --specs=nosys.specs ) else() target_link_options(${executable_target} PRIVATE - $<$:--scatter=${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/Bsp/corstone300/an552_ns.sct> - $<$:--scatter=${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/Bsp/corstone310/an555_ns.sct> + $<$:--scatter=${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/bsp/corstone300/an552_ns.sct> + $<$:--scatter=${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/bsp/corstone310/an555_ns.sct> --map ) endif() diff --git a/Bsp/common/bsp_serial.c b/bsp/common/bsp_serial.c similarity index 100% rename from Bsp/common/bsp_serial.c rename to bsp/common/bsp_serial.c diff --git a/Bsp/common/bsp_serial.h b/bsp/common/bsp_serial.h similarity index 100% rename from Bsp/common/bsp_serial.h rename to bsp/common/bsp_serial.h diff --git a/Bsp/corstone300/an552_ns.ld b/bsp/corstone300/an552_ns.ld similarity index 100% rename from Bsp/corstone300/an552_ns.ld rename to bsp/corstone300/an552_ns.ld diff --git a/Bsp/corstone300/an552_ns.sct b/bsp/corstone300/an552_ns.sct similarity index 100% rename from Bsp/corstone300/an552_ns.sct rename to bsp/corstone300/an552_ns.sct diff --git a/Bsp/corstone300/include/FreeRTOSConfig_target.h b/bsp/corstone300/include/FreeRTOSConfig_target.h similarity index 100% rename from Bsp/corstone300/include/FreeRTOSConfig_target.h rename to bsp/corstone300/include/FreeRTOSConfig_target.h diff --git a/Bsp/corstone300/include/provisioning_config_target.h b/bsp/corstone300/include/provisioning_config_target.h similarity index 100% rename from Bsp/corstone300/include/provisioning_config_target.h rename to bsp/corstone300/include/provisioning_config_target.h diff --git a/Bsp/corstone310/an555_ns.ld b/bsp/corstone310/an555_ns.ld similarity index 100% rename from Bsp/corstone310/an555_ns.ld rename to bsp/corstone310/an555_ns.ld diff --git a/Bsp/corstone310/an555_ns.sct b/bsp/corstone310/an555_ns.sct similarity index 100% rename from Bsp/corstone310/an555_ns.sct rename to bsp/corstone310/an555_ns.sct diff --git a/Bsp/corstone310/include/FreeRTOSConfig_target.h b/bsp/corstone310/include/FreeRTOSConfig_target.h similarity index 100% rename from Bsp/corstone310/include/FreeRTOSConfig_target.h rename to bsp/corstone310/include/FreeRTOSConfig_target.h diff --git a/Bsp/corstone310/include/provisioning_config_target.h b/bsp/corstone310/include/provisioning_config_target.h similarity index 100% rename from Bsp/corstone310/include/provisioning_config_target.h rename to bsp/corstone310/include/provisioning_config_target.h diff --git a/Bsp/library b/bsp/library similarity index 100% rename from Bsp/library rename to bsp/library diff --git a/manifest.yml b/manifest.yml index e3821964..9bb95890 100644 --- a/manifest.yml +++ b/manifest.yml @@ -16,7 +16,7 @@ dependencies: repository: type: "git" url: "https://git.gitlab.arm.com/iot/open-iot-sdk/arm-corstone-platform-bsp.git" - path: "Bsp/library" + path: "bsp/library" - name: "trusted-firmware-m" license: "BSD-3-Clause" version: "TF-Mv2.0.0" From 0a20b2db67ab3c5cb80767c715006c0cc1ca5623 Mon Sep 17 00:00:00 2001 From: Hugues Kamba-Mpiana Date: Fri, 3 Nov 2023 13:30:38 +0000 Subject: [PATCH 11/22] bsp: Rename CMake script CMake modules follow the typical naming convention of VerbWithCamelCase. Signed-off-by: Hugues Kamba-Mpiana --- Projects/aws-iot-example/CMakeLists.txt | 2 +- Projects/blinky/CMakeLists.txt | 2 +- bsp/cmake/{BspUtilities.cmake => SetLinkerOptions.cmake} | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename bsp/cmake/{BspUtilities.cmake => SetLinkerOptions.cmake} (100%) diff --git a/Projects/aws-iot-example/CMakeLists.txt b/Projects/aws-iot-example/CMakeLists.txt index b2696472..6fb80ce1 100644 --- a/Projects/aws-iot-example/CMakeLists.txt +++ b/Projects/aws-iot-example/CMakeLists.txt @@ -79,7 +79,7 @@ add_subdirectory(${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR} ${CMAKE_BINARY_DIR} list(APPEND CMAKE_MODULE_PATH ${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/bsp/cmake) list(APPEND CMAKE_MODULE_PATH ${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/components/aws_iot/cmake) list(APPEND CMAKE_MODULE_PATH ${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/components/security/trusted_firmware-m/integration/cmake) -include(BspUtilities) +include(SetLinkerOptions) include(GenerateAWSUpdateDigestAndSignature) include(MergeTfmImages) include(SignTfmImage) diff --git a/Projects/blinky/CMakeLists.txt b/Projects/blinky/CMakeLists.txt index 9a7b4964..cc2c0e28 100644 --- a/Projects/blinky/CMakeLists.txt +++ b/Projects/blinky/CMakeLists.txt @@ -56,7 +56,7 @@ add_subdirectory(${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR} ${CMAKE_BINARY_DIR} list(APPEND CMAKE_MODULE_PATH ${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/bsp/cmake) list(APPEND CMAKE_MODULE_PATH ${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/components/security/trusted_firmware-m/integration/cmake) -include(BspUtilities) +include(SetLinkerOptions) include(MergeTfmImages) include(SignTfmImage) diff --git a/bsp/cmake/BspUtilities.cmake b/bsp/cmake/SetLinkerOptions.cmake similarity index 100% rename from bsp/cmake/BspUtilities.cmake rename to bsp/cmake/SetLinkerOptions.cmake From 21551c5f6e448278157f00829147534fcea2d636 Mon Sep 17 00:00:00 2001 From: Hugues Kamba-Mpiana Date: Fri, 3 Nov 2023 13:33:27 +0000 Subject: [PATCH 12/22] docs: Rename `Docs` subdir following snake_case The project is adopting snake case for files and subdirectories names Signed-off-by: Hugues Kamba-Mpiana --- README.md | 4 ++-- Docs/aws-iot-example.md => docs/aws_iot_example.md | 10 +++++----- {Docs => docs}/blinky.md | 6 +++--- .../development_environment.md | 2 +- Docs/Prerequisites.md => docs/prerequisites.md | 4 ++-- .../setting_up_arm_virtual_hardware.md | 0 6 files changed, 13 insertions(+), 13 deletions(-) rename Docs/aws-iot-example.md => docs/aws_iot_example.md (98%) rename {Docs => docs}/blinky.md (91%) rename Docs/development-environment.md => docs/development_environment.md (99%) rename Docs/Prerequisites.md => docs/prerequisites.md (96%) rename Docs/setting-up-arm-virtual-hardware.md => docs/setting_up_arm_virtual_hardware.md (100%) diff --git a/README.md b/README.md index c77635a8..5960da0b 100644 --- a/README.md +++ b/README.md @@ -26,9 +26,9 @@ porting of this integration across platforms easy. This reference integration contains following two examples: -* [Blinky example](Docs/blinky.md) +* [Blinky example](docs/blinky.md) * Demonstrates FreeRTOS kernel and TF-M integration -* [AWS IoT example](Docs/aws-iot-example.md) +* [AWS IoT example](docs/aws_iot_example.md) * Demonstrates [secure connectivity](#secure-tls-connection) to AWS IoT core using [Mbed TLS](#mbed-tls), [PKCS#11 PSA Shim](#pkcs11-psa-shim) and [coreMQTT-agent](https://docs.aws.amazon.com/freertos/latest/userguide/coremqtt-agent.html) library. In addition, [secure OTA](#secure-ota-updates) using [OTA agent](https://freertos.org/ota/index.html) diff --git a/Docs/aws-iot-example.md b/docs/aws_iot_example.md similarity index 98% rename from Docs/aws-iot-example.md rename to docs/aws_iot_example.md index 94afcdf7..ada714b0 100644 --- a/Docs/aws-iot-example.md +++ b/docs/aws_iot_example.md @@ -44,7 +44,7 @@ of the verification fails, then MCUBoot stops the booting process. ## Prerequisites -Follow the instructions described in [Prerequisites](Prerequisites.md) and +Follow the instructions described in [Prerequisites](prerequisites.md) and ensure that all the prerequisites are met before continuing. ## Setting up AWS connectivity @@ -222,9 +222,9 @@ Or, run the command below to perform a clean build: ``` This will build the example with the Arm Compiler (armclang) by default, which is -included in the [Arm Virtual Hardware instance](./setting-up-arm-virtual-hardware.md) +included in the [Arm Virtual Hardware instance](./setting_up_arm_virtual_hardware.md) on AWS. If you would like to build it with the Arm GNU Toolchain (arm-none-eabi-gcc) -[installed by yourself](./development-environment.md), append the extra option +[installed by yourself](./development_environment.md), append the extra option `--toolchain GNU` to the build command above. @@ -598,9 +598,9 @@ Or, run the command below to perform a clean build: ``` This will build the example with the Arm Compiler (armclang) by default, which is -included in the [Arm Virtual Hardware instance](./setting-up-arm-virtual-hardware.md) +included in the [Arm Virtual Hardware instance](./setting_up_arm_virtual_hardware.md) on AWS. If you would like to build it with the Arm GNU Toolchain (arm-none-eabi-gcc) -[installed by yourself](./development-environment.md), append the extra option +[installed by yourself](./development_environment.md), append the extra option `--toolchain GNU` to the build command above. ### Running the application diff --git a/Docs/blinky.md b/docs/blinky.md similarity index 91% rename from Docs/blinky.md rename to docs/blinky.md index 28f20a47..f3f47294 100644 --- a/Docs/blinky.md +++ b/docs/blinky.md @@ -11,7 +11,7 @@ intervals. ## Prerequisites -Follow the instructions described in [Prerequisites](Prerequisites.md) and +Follow the instructions described in [Prerequisites](prerequisites.md) and ensure that all the prerequisites are met before continuing. ## Building the application @@ -27,9 +27,9 @@ Run the command below to perform a clean build: ``` This will build the example with the Arm Compiler (armclang) by default, which is -included in the [Arm Virtual Hardware instance](./setting-up-arm-virtual-hardware.md) +included in the [Arm Virtual Hardware instance](./setting_up_arm_virtual_hardware.md) on AWS. If you would like to build it with the Arm GNU Toolchain (arm-none-eabi-gcc) -[installed by yourself](./development-environment.md), append the extra option +[installed by yourself](./development_environment.md), append the extra option `--toolchain GNU` to the build command above. ## Running the application diff --git a/Docs/development-environment.md b/docs/development_environment.md similarity index 99% rename from Docs/development-environment.md rename to docs/development_environment.md index 3517eca9..55ea6cc1 100644 --- a/Docs/development-environment.md +++ b/docs/development_environment.md @@ -64,7 +64,7 @@ git submodule update --init --recursive * Arm Compiler for Embedded - The [Arm Virtual Hardware instance](./setting-up-arm-virtual-hardware.md) + The [Arm Virtual Hardware instance](./setting_up_arm_virtual_hardware.md) comes with the Arm Compiler for Embedded in its environment which is ready for use. diff --git a/Docs/Prerequisites.md b/docs/prerequisites.md similarity index 96% rename from Docs/Prerequisites.md rename to docs/prerequisites.md index bbd5e569..e2e28964 100644 --- a/Docs/Prerequisites.md +++ b/docs/prerequisites.md @@ -29,7 +29,7 @@ more information. ### Setting up Arm Virtual Hardware using Amazon Machine Images -Follow the instructions described in [Launch Arm Virtual Hardware Instance](setting-up-arm-virtual-hardware.md) +Follow the instructions described in [Launch Arm Virtual Hardware Instance](setting_up_arm_virtual_hardware.md) to setup your development environment. If you have successfully followed the instructions, then you should have a @@ -45,5 +45,5 @@ additional argument `--fvp_type vht` must be passed to the run example script. ## Setting up development environment -Follow the instructions described in [Setting Up your Development Environment](development-environment.md) +Follow the instructions described in [Setting Up your Development Environment](development_environment.md) to setup your development environment. diff --git a/Docs/setting-up-arm-virtual-hardware.md b/docs/setting_up_arm_virtual_hardware.md similarity index 100% rename from Docs/setting-up-arm-virtual-hardware.md rename to docs/setting_up_arm_virtual_hardware.md From 3bb23edb9c46c49bcd5c4c97ad103ee98a7839fe Mon Sep 17 00:00:00 2001 From: Hugues Kamba-Mpiana Date: Fri, 3 Nov 2023 13:39:46 +0000 Subject: [PATCH 13/22] apps: Rename `Projects` subdir to `applications` Improves the description of the content of the subdir. Signed-off-by: Hugues Kamba-Mpiana --- .github/workflows/build.yaml | 2 +- .gitlab-ci.yml | 18 +++++++++--------- .pre-commit-config.yaml | 2 +- README.md | 2 +- Tools/scripts/build.sh | 4 ++-- .../aws-iot-example/CMakeLists.txt | 2 +- .../aws-iot-example/configs/CMakeLists.txt | 0 .../configs/app_config/CMakeLists.txt | 0 .../configs/app_config/app_config.h | 0 .../configs/aws_configs/CMakeLists.txt | 0 .../configs/aws_configs/aws_clientcredential.h | 0 .../configs/aws_configs/aws_mqtt_config.h | 0 .../aws_configs/aws_secure_sockets_config.h | 0 .../configs/aws_configs/core_mqtt_config.h | 0 .../configs/aws_configs/core_pkcs11_config.h | 0 .../configs/aws_configs/demo_config.h | 0 .../iot_default_root_certificates.h | 0 .../aws_configs/mqtt_agent_demo_config.h | 0 .../aws_configs/mqtt_demo_mutual_auth_config.h | 0 .../configs/aws_configs/ota_config.h | 0 .../configs/aws_configs/ota_demo_config.h | 0 .../configs/freertos-config/CMakeLists.txt | 0 .../configs/freertos-config/FreeRTOSConfig.h | 0 .../configs/freertos-config/FreeRTOSIPConfig.h | 0 .../configs/mbedtls_config/CMakeLists.txt | 0 .../mbedtls_config/aws_mbedtls_config.h | 0 .../configs/mbedtls_config/threading_alt.h | 0 .../configs/tfm-config/project_config.h | 0 .../dev_mode_key_provisioning.c | 0 .../aws-iot-example}/fail_output.log | 0 .../include/dev_mode_key_provisioning.h | 0 .../include/test_execution_config.h | 0 .../include/test_param_config.h | 0 .../include/unistd.h | 0 .../integration_tests_platform_function.c | 0 .../aws-iot-example/main.c | 0 .../aws-iot-example/mqtt_demo_pub_sub.c | 0 .../aws-iot-example}/pass_output.log | 0 .../blinky/CMakeLists.txt | 2 +- .../blinky/configs/CMakeLists.txt | 0 .../blinky/configs/app_config/CMakeLists.txt | 0 .../blinky/configs/app_config/app_config.h | 0 .../configs/freertos-config/CMakeLists.txt | 0 .../configs/freertos-config/FreeRTOSConfig.h | 0 .../blinky/configs/tfm-config/project_config.h | 0 {Projects => applications}/blinky/main.c | 0 .../blinky/tests/fail_output.log | 0 .../blinky/tests/pass_output.log | 0 .../helpers/CMakeLists.txt | 0 .../helpers/events/CMakeLists.txt | 0 .../helpers/events/inc/events.h | 0 .../helpers/events/src/events.c | 0 .../helpers/logging/CMakeLists.txt | 0 .../helpers/logging/inc/iot_logging_task.h | 0 .../helpers/logging/inc/logging_levels.h | 0 .../helpers/logging/inc/logging_stack.h | 0 .../src/iot_logging_task_dynamic_buffers.c | 0 .../helpers/provisioning/CMakeLists.txt | 0 .../cmake/linkerscript_preprocess.cmake | 0 .../helpers/provisioning/provisioning_config.h | 0 .../helpers/provisioning/provisioning_data.c | 0 .../helpers/provisioning/provisioning_data.h | 0 .../helpers/provisioning/provisioning_data.ld | 0 .../helpers/provisioning/provisioning_data.sct | 0 docs/aws_iot_example.md | 8 ++++---- 65 files changed, 20 insertions(+), 20 deletions(-) rename {Projects => applications}/aws-iot-example/CMakeLists.txt (99%) rename {Projects => applications}/aws-iot-example/configs/CMakeLists.txt (100%) rename {Projects => applications}/aws-iot-example/configs/app_config/CMakeLists.txt (100%) rename {Projects => applications}/aws-iot-example/configs/app_config/app_config.h (100%) rename {Projects => applications}/aws-iot-example/configs/aws_configs/CMakeLists.txt (100%) rename {Projects => applications}/aws-iot-example/configs/aws_configs/aws_clientcredential.h (100%) rename {Projects => applications}/aws-iot-example/configs/aws_configs/aws_mqtt_config.h (100%) rename {Projects => applications}/aws-iot-example/configs/aws_configs/aws_secure_sockets_config.h (100%) rename {Projects => applications}/aws-iot-example/configs/aws_configs/core_mqtt_config.h (100%) rename {Projects => applications}/aws-iot-example/configs/aws_configs/core_pkcs11_config.h (100%) rename {Projects => applications}/aws-iot-example/configs/aws_configs/demo_config.h (100%) rename {Projects => applications}/aws-iot-example/configs/aws_configs/iot_default_root_certificates.h (100%) rename {Projects => applications}/aws-iot-example/configs/aws_configs/mqtt_agent_demo_config.h (100%) rename {Projects => applications}/aws-iot-example/configs/aws_configs/mqtt_demo_mutual_auth_config.h (100%) rename {Projects => applications}/aws-iot-example/configs/aws_configs/ota_config.h (100%) rename {Projects => applications}/aws-iot-example/configs/aws_configs/ota_demo_config.h (100%) rename {Projects => applications}/aws-iot-example/configs/freertos-config/CMakeLists.txt (100%) rename {Projects => applications}/aws-iot-example/configs/freertos-config/FreeRTOSConfig.h (100%) rename {Projects => applications}/aws-iot-example/configs/freertos-config/FreeRTOSIPConfig.h (100%) rename {Projects => applications}/aws-iot-example/configs/mbedtls_config/CMakeLists.txt (100%) rename {Projects => applications}/aws-iot-example/configs/mbedtls_config/aws_mbedtls_config.h (100%) rename {Projects => applications}/aws-iot-example/configs/mbedtls_config/threading_alt.h (100%) rename {Projects => applications}/aws-iot-example/configs/tfm-config/project_config.h (100%) rename {Projects => applications}/aws-iot-example/dev_mode_key_provisioning.c (100%) rename {Projects/aws-iot-example/tests => applications/aws-iot-example}/fail_output.log (100%) rename {Projects => applications}/aws-iot-example/freertos-integration-tests/include/dev_mode_key_provisioning.h (100%) rename {Projects => applications}/aws-iot-example/freertos-integration-tests/include/test_execution_config.h (100%) rename {Projects => applications}/aws-iot-example/freertos-integration-tests/include/test_param_config.h (100%) rename {Projects => applications}/aws-iot-example/freertos-integration-tests/include/unistd.h (100%) rename {Projects => applications}/aws-iot-example/freertos-integration-tests/integration_tests_platform_function.c (100%) rename {Projects => applications}/aws-iot-example/main.c (100%) rename {Projects => applications}/aws-iot-example/mqtt_demo_pub_sub.c (100%) rename {Projects/aws-iot-example/tests => applications/aws-iot-example}/pass_output.log (100%) rename {Projects => applications}/blinky/CMakeLists.txt (97%) rename {Projects => applications}/blinky/configs/CMakeLists.txt (100%) rename {Projects => applications}/blinky/configs/app_config/CMakeLists.txt (100%) rename {Projects => applications}/blinky/configs/app_config/app_config.h (100%) rename {Projects => applications}/blinky/configs/freertos-config/CMakeLists.txt (100%) rename {Projects => applications}/blinky/configs/freertos-config/FreeRTOSConfig.h (100%) rename {Projects => applications}/blinky/configs/tfm-config/project_config.h (100%) rename {Projects => applications}/blinky/main.c (100%) rename {Projects => applications}/blinky/tests/fail_output.log (100%) rename {Projects => applications}/blinky/tests/pass_output.log (100%) rename {Projects => applications}/helpers/CMakeLists.txt (100%) rename {Projects => applications}/helpers/events/CMakeLists.txt (100%) rename {Projects => applications}/helpers/events/inc/events.h (100%) rename {Projects => applications}/helpers/events/src/events.c (100%) rename {Projects => applications}/helpers/logging/CMakeLists.txt (100%) rename {Projects => applications}/helpers/logging/inc/iot_logging_task.h (100%) rename {Projects => applications}/helpers/logging/inc/logging_levels.h (100%) rename {Projects => applications}/helpers/logging/inc/logging_stack.h (100%) rename {Projects => applications}/helpers/logging/src/iot_logging_task_dynamic_buffers.c (100%) rename {Projects => applications}/helpers/provisioning/CMakeLists.txt (100%) rename {Projects => applications}/helpers/provisioning/cmake/linkerscript_preprocess.cmake (100%) rename {Projects => applications}/helpers/provisioning/provisioning_config.h (100%) rename {Projects => applications}/helpers/provisioning/provisioning_data.c (100%) rename {Projects => applications}/helpers/provisioning/provisioning_data.h (100%) rename {Projects => applications}/helpers/provisioning/provisioning_data.ld (100%) rename {Projects => applications}/helpers/provisioning/provisioning_data.sct (100%) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index d96634ae..c93d015f 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -49,7 +49,7 @@ jobs: export IOT_OTA_CLIENT_CERT="dummy_certificate" export IOT_OTA_CLIENT_PRIV="dummy_priv_key" export IOT_OTA_CLIENT_PUB="dummy_pub_key" - ./ci/generate_credentials.sh -f -p Projects/aws-iot-example/configs/aws_configs + ./ci/generate_credentials.sh -f -p applications/aws-iot-example/configs/aws_configs git config --global user.email "ci@example.com" git config --global user.name "ci" - name: Build the project diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7363857e..9f1882eb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -72,7 +72,7 @@ build-applications: stage: build extends: .base_job script: - - ./ci/generate_credentials.sh -f -p Projects/${APP}/configs/aws_configs + - ./ci/generate_credentials.sh -f -p applications/${APP}/configs/aws_configs - git config --global user.email "ci@example.com" - git config --global user.name "ci" - ./Tools/scripts/build.sh ${APP} --target $TARGET --toolchain $TOOLCHAIN --certificate_path $PWD/certificate.pem --private_key_path $PWD/private_key.pem @@ -82,7 +82,7 @@ build-applications: build/${APP}_merged.elf \ build/${APP}-update_signed.bin \ build/update-signature.txt \ - Projects/${APP}/configs/aws_configs + applications/${APP}/configs/aws_configs else tar -czf ${TARGET}_${APP}_${TOOLCHAIN}_build.tar.gz \ build/${APP}_merged.elf @@ -107,8 +107,8 @@ test-applications-output: --fvp $FVP_BIN \ --merged-elf-name "${APP}_merged.elf" \ --timeout-seconds 600 \ - --pass-output-file "Projects/${APP}/tests/pass_output.log" \ - --fail-output-file "Projects/${APP}/tests/fail_output.log" + --pass-output-file "applications/${APP}/tests/pass_output.log" \ + --fail-output-file "applications/${APP}/tests/fail_output.log" parallel: matrix: - @@ -123,12 +123,12 @@ test-ota: pytest -s Tools/tests/test_ota.py \ --build-artefacts-path "build" \ --fvp $FVP_BIN \ - --credentials-path "Projects/${APP}/configs/aws_configs" \ + --credentials-path "applications/${APP}/configs/aws_configs" \ --merged-elf-name "${APP}_merged.elf" \ --signed-update-bin-name "${APP}-update_signed.bin" \ --timeout-seconds 900 \ - --pass-output-file "Projects/${APP}/tests/pass_output.log" \ - --fail-output-file "Projects/${APP}/tests/fail_output.log" + --pass-output-file "applications/${APP}/tests/pass_output.log" \ + --fail-output-file "applications/${APP}/tests/fail_output.log" parallel: matrix: - @@ -142,7 +142,7 @@ integration-tests: rules: - if: ( $SCHEDULED_JOB_TO_RUN == "integration-tests" ) script: - - ./ci/generate_credentials.sh -f -p Projects/${APP}/configs/aws_configs + - ./ci/generate_credentials.sh -f -p applications/${APP}/configs/aws_configs - git config --global user.email "ci@example.com" - git config --global user.name "ci" - ./Tools/scripts/build.sh -q ${APP} @@ -154,7 +154,7 @@ integration-tests: pytest -s Tools/tests/test_integration.py \ --build-artefacts-path "build" \ --fvp $FVP_BIN \ - --credentials-path "Projects/${APP}/configs/aws_configs" \ + --credentials-path "applications/${APP}/configs/aws_configs" \ --merged-elf-name "${APP}-tests_merged.elf" \ --signed-update-bin-name "${APP}-tests-update_signed.bin" parallel: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 164dac3b..874a9f44 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,7 +17,7 @@ exclude: > components/security/trusted_firmware-m/library/| components/aws_iot/| components/connectivity/backoff_algorithm/| - Projects/helpers/logging/| + applications/helpers/logging/| components/freertos_kernel/| components/connectivity/freertos_plus_tcp/| components/tools/freertos_libraries_integration_tests/| diff --git a/README.md b/README.md index 5960da0b..b7a05c2e 100644 --- a/README.md +++ b/README.md @@ -120,7 +120,7 @@ See [CONTRIBUTING](CONTRIBUTING.md) for more information. ## License -Source code located in the *Projects* directory is +Source code located in the *applications* directory is available under the terms of the MIT License. See the [LICENSE](./LICENSE) file for more details. diff --git a/Tools/scripts/build.sh b/Tools/scripts/build.sh index 3a3b22c7..ebfdbd54 100755 --- a/Tools/scripts/build.sh +++ b/Tools/scripts/build.sh @@ -143,11 +143,11 @@ done case "$1" in blinky) EXAMPLE="$1" - PATH_TO_SOURCE="$ROOT/Projects/blinky" + PATH_TO_SOURCE="$ROOT/applications/blinky" ;; aws-iot-example) EXAMPLE="$1" - PATH_TO_SOURCE="$ROOT/Projects/aws-iot-example" + PATH_TO_SOURCE="$ROOT/applications/aws-iot-example" ;; *) echo "Missing example " diff --git a/Projects/aws-iot-example/CMakeLists.txt b/applications/aws-iot-example/CMakeLists.txt similarity index 99% rename from Projects/aws-iot-example/CMakeLists.txt rename to applications/aws-iot-example/CMakeLists.txt index 6fb80ce1..b768948e 100644 --- a/Projects/aws-iot-example/CMakeLists.txt +++ b/applications/aws-iot-example/CMakeLists.txt @@ -46,7 +46,7 @@ set(TFM_CMAKE_ARGS -DPLATFORM_DEFAULT_PROVISIONING=OFF -DPLATFORM_DEFAULT_UART_STDOUT=ON -DPLATFORM_HAS_FIRMWARE_UPDATE_SUPPORT=ON - -DPROJECT_CONFIG_HEADER_FILE=${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/Projects/aws-iot-example/configs/tfm-config/project_config.h + -DPROJECT_CONFIG_HEADER_FILE=${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/applications/aws-iot-example/configs/tfm-config/project_config.h -DTFM_DUMMY_PROVISIONING=OFF -DTFM_EXCEPTION_INFO_DUMP=ON -DTFM_PARTITION_CRYPTO=ON diff --git a/Projects/aws-iot-example/configs/CMakeLists.txt b/applications/aws-iot-example/configs/CMakeLists.txt similarity index 100% rename from Projects/aws-iot-example/configs/CMakeLists.txt rename to applications/aws-iot-example/configs/CMakeLists.txt diff --git a/Projects/aws-iot-example/configs/app_config/CMakeLists.txt b/applications/aws-iot-example/configs/app_config/CMakeLists.txt similarity index 100% rename from Projects/aws-iot-example/configs/app_config/CMakeLists.txt rename to applications/aws-iot-example/configs/app_config/CMakeLists.txt diff --git a/Projects/aws-iot-example/configs/app_config/app_config.h b/applications/aws-iot-example/configs/app_config/app_config.h similarity index 100% rename from Projects/aws-iot-example/configs/app_config/app_config.h rename to applications/aws-iot-example/configs/app_config/app_config.h diff --git a/Projects/aws-iot-example/configs/aws_configs/CMakeLists.txt b/applications/aws-iot-example/configs/aws_configs/CMakeLists.txt similarity index 100% rename from Projects/aws-iot-example/configs/aws_configs/CMakeLists.txt rename to applications/aws-iot-example/configs/aws_configs/CMakeLists.txt diff --git a/Projects/aws-iot-example/configs/aws_configs/aws_clientcredential.h b/applications/aws-iot-example/configs/aws_configs/aws_clientcredential.h similarity index 100% rename from Projects/aws-iot-example/configs/aws_configs/aws_clientcredential.h rename to applications/aws-iot-example/configs/aws_configs/aws_clientcredential.h diff --git a/Projects/aws-iot-example/configs/aws_configs/aws_mqtt_config.h b/applications/aws-iot-example/configs/aws_configs/aws_mqtt_config.h similarity index 100% rename from Projects/aws-iot-example/configs/aws_configs/aws_mqtt_config.h rename to applications/aws-iot-example/configs/aws_configs/aws_mqtt_config.h diff --git a/Projects/aws-iot-example/configs/aws_configs/aws_secure_sockets_config.h b/applications/aws-iot-example/configs/aws_configs/aws_secure_sockets_config.h similarity index 100% rename from Projects/aws-iot-example/configs/aws_configs/aws_secure_sockets_config.h rename to applications/aws-iot-example/configs/aws_configs/aws_secure_sockets_config.h diff --git a/Projects/aws-iot-example/configs/aws_configs/core_mqtt_config.h b/applications/aws-iot-example/configs/aws_configs/core_mqtt_config.h similarity index 100% rename from Projects/aws-iot-example/configs/aws_configs/core_mqtt_config.h rename to applications/aws-iot-example/configs/aws_configs/core_mqtt_config.h diff --git a/Projects/aws-iot-example/configs/aws_configs/core_pkcs11_config.h b/applications/aws-iot-example/configs/aws_configs/core_pkcs11_config.h similarity index 100% rename from Projects/aws-iot-example/configs/aws_configs/core_pkcs11_config.h rename to applications/aws-iot-example/configs/aws_configs/core_pkcs11_config.h diff --git a/Projects/aws-iot-example/configs/aws_configs/demo_config.h b/applications/aws-iot-example/configs/aws_configs/demo_config.h similarity index 100% rename from Projects/aws-iot-example/configs/aws_configs/demo_config.h rename to applications/aws-iot-example/configs/aws_configs/demo_config.h diff --git a/Projects/aws-iot-example/configs/aws_configs/iot_default_root_certificates.h b/applications/aws-iot-example/configs/aws_configs/iot_default_root_certificates.h similarity index 100% rename from Projects/aws-iot-example/configs/aws_configs/iot_default_root_certificates.h rename to applications/aws-iot-example/configs/aws_configs/iot_default_root_certificates.h diff --git a/Projects/aws-iot-example/configs/aws_configs/mqtt_agent_demo_config.h b/applications/aws-iot-example/configs/aws_configs/mqtt_agent_demo_config.h similarity index 100% rename from Projects/aws-iot-example/configs/aws_configs/mqtt_agent_demo_config.h rename to applications/aws-iot-example/configs/aws_configs/mqtt_agent_demo_config.h diff --git a/Projects/aws-iot-example/configs/aws_configs/mqtt_demo_mutual_auth_config.h b/applications/aws-iot-example/configs/aws_configs/mqtt_demo_mutual_auth_config.h similarity index 100% rename from Projects/aws-iot-example/configs/aws_configs/mqtt_demo_mutual_auth_config.h rename to applications/aws-iot-example/configs/aws_configs/mqtt_demo_mutual_auth_config.h diff --git a/Projects/aws-iot-example/configs/aws_configs/ota_config.h b/applications/aws-iot-example/configs/aws_configs/ota_config.h similarity index 100% rename from Projects/aws-iot-example/configs/aws_configs/ota_config.h rename to applications/aws-iot-example/configs/aws_configs/ota_config.h diff --git a/Projects/aws-iot-example/configs/aws_configs/ota_demo_config.h b/applications/aws-iot-example/configs/aws_configs/ota_demo_config.h similarity index 100% rename from Projects/aws-iot-example/configs/aws_configs/ota_demo_config.h rename to applications/aws-iot-example/configs/aws_configs/ota_demo_config.h diff --git a/Projects/aws-iot-example/configs/freertos-config/CMakeLists.txt b/applications/aws-iot-example/configs/freertos-config/CMakeLists.txt similarity index 100% rename from Projects/aws-iot-example/configs/freertos-config/CMakeLists.txt rename to applications/aws-iot-example/configs/freertos-config/CMakeLists.txt diff --git a/Projects/aws-iot-example/configs/freertos-config/FreeRTOSConfig.h b/applications/aws-iot-example/configs/freertos-config/FreeRTOSConfig.h similarity index 100% rename from Projects/aws-iot-example/configs/freertos-config/FreeRTOSConfig.h rename to applications/aws-iot-example/configs/freertos-config/FreeRTOSConfig.h diff --git a/Projects/aws-iot-example/configs/freertos-config/FreeRTOSIPConfig.h b/applications/aws-iot-example/configs/freertos-config/FreeRTOSIPConfig.h similarity index 100% rename from Projects/aws-iot-example/configs/freertos-config/FreeRTOSIPConfig.h rename to applications/aws-iot-example/configs/freertos-config/FreeRTOSIPConfig.h diff --git a/Projects/aws-iot-example/configs/mbedtls_config/CMakeLists.txt b/applications/aws-iot-example/configs/mbedtls_config/CMakeLists.txt similarity index 100% rename from Projects/aws-iot-example/configs/mbedtls_config/CMakeLists.txt rename to applications/aws-iot-example/configs/mbedtls_config/CMakeLists.txt diff --git a/Projects/aws-iot-example/configs/mbedtls_config/aws_mbedtls_config.h b/applications/aws-iot-example/configs/mbedtls_config/aws_mbedtls_config.h similarity index 100% rename from Projects/aws-iot-example/configs/mbedtls_config/aws_mbedtls_config.h rename to applications/aws-iot-example/configs/mbedtls_config/aws_mbedtls_config.h diff --git a/Projects/aws-iot-example/configs/mbedtls_config/threading_alt.h b/applications/aws-iot-example/configs/mbedtls_config/threading_alt.h similarity index 100% rename from Projects/aws-iot-example/configs/mbedtls_config/threading_alt.h rename to applications/aws-iot-example/configs/mbedtls_config/threading_alt.h diff --git a/Projects/aws-iot-example/configs/tfm-config/project_config.h b/applications/aws-iot-example/configs/tfm-config/project_config.h similarity index 100% rename from Projects/aws-iot-example/configs/tfm-config/project_config.h rename to applications/aws-iot-example/configs/tfm-config/project_config.h diff --git a/Projects/aws-iot-example/dev_mode_key_provisioning.c b/applications/aws-iot-example/dev_mode_key_provisioning.c similarity index 100% rename from Projects/aws-iot-example/dev_mode_key_provisioning.c rename to applications/aws-iot-example/dev_mode_key_provisioning.c diff --git a/Projects/aws-iot-example/tests/fail_output.log b/applications/aws-iot-example/fail_output.log similarity index 100% rename from Projects/aws-iot-example/tests/fail_output.log rename to applications/aws-iot-example/fail_output.log diff --git a/Projects/aws-iot-example/freertos-integration-tests/include/dev_mode_key_provisioning.h b/applications/aws-iot-example/freertos-integration-tests/include/dev_mode_key_provisioning.h similarity index 100% rename from Projects/aws-iot-example/freertos-integration-tests/include/dev_mode_key_provisioning.h rename to applications/aws-iot-example/freertos-integration-tests/include/dev_mode_key_provisioning.h diff --git a/Projects/aws-iot-example/freertos-integration-tests/include/test_execution_config.h b/applications/aws-iot-example/freertos-integration-tests/include/test_execution_config.h similarity index 100% rename from Projects/aws-iot-example/freertos-integration-tests/include/test_execution_config.h rename to applications/aws-iot-example/freertos-integration-tests/include/test_execution_config.h diff --git a/Projects/aws-iot-example/freertos-integration-tests/include/test_param_config.h b/applications/aws-iot-example/freertos-integration-tests/include/test_param_config.h similarity index 100% rename from Projects/aws-iot-example/freertos-integration-tests/include/test_param_config.h rename to applications/aws-iot-example/freertos-integration-tests/include/test_param_config.h diff --git a/Projects/aws-iot-example/freertos-integration-tests/include/unistd.h b/applications/aws-iot-example/freertos-integration-tests/include/unistd.h similarity index 100% rename from Projects/aws-iot-example/freertos-integration-tests/include/unistd.h rename to applications/aws-iot-example/freertos-integration-tests/include/unistd.h diff --git a/Projects/aws-iot-example/freertos-integration-tests/integration_tests_platform_function.c b/applications/aws-iot-example/freertos-integration-tests/integration_tests_platform_function.c similarity index 100% rename from Projects/aws-iot-example/freertos-integration-tests/integration_tests_platform_function.c rename to applications/aws-iot-example/freertos-integration-tests/integration_tests_platform_function.c diff --git a/Projects/aws-iot-example/main.c b/applications/aws-iot-example/main.c similarity index 100% rename from Projects/aws-iot-example/main.c rename to applications/aws-iot-example/main.c diff --git a/Projects/aws-iot-example/mqtt_demo_pub_sub.c b/applications/aws-iot-example/mqtt_demo_pub_sub.c similarity index 100% rename from Projects/aws-iot-example/mqtt_demo_pub_sub.c rename to applications/aws-iot-example/mqtt_demo_pub_sub.c diff --git a/Projects/aws-iot-example/tests/pass_output.log b/applications/aws-iot-example/pass_output.log similarity index 100% rename from Projects/aws-iot-example/tests/pass_output.log rename to applications/aws-iot-example/pass_output.log diff --git a/Projects/blinky/CMakeLists.txt b/applications/blinky/CMakeLists.txt similarity index 97% rename from Projects/blinky/CMakeLists.txt rename to applications/blinky/CMakeLists.txt index cc2c0e28..3c187d42 100644 --- a/Projects/blinky/CMakeLists.txt +++ b/applications/blinky/CMakeLists.txt @@ -27,7 +27,7 @@ set(TFM_CMAKE_ARGS -DNS=ON -DPLATFORM_DEFAULT_PROVISIONING=OFF -DPLATFORM_DEFAULT_UART_STDOUT=ON - -DPROJECT_CONFIG_HEADER_FILE=${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/Projects/blinky/configs/tfm-config/project_config.h + -DPROJECT_CONFIG_HEADER_FILE=${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/applications/blinky/configs/tfm-config/project_config.h -DTFM_DUMMY_PROVISIONING=OFF -DTFM_EXCEPTION_INFO_DUMP=ON -DTFM_PARTITION_CRYPTO=ON diff --git a/Projects/blinky/configs/CMakeLists.txt b/applications/blinky/configs/CMakeLists.txt similarity index 100% rename from Projects/blinky/configs/CMakeLists.txt rename to applications/blinky/configs/CMakeLists.txt diff --git a/Projects/blinky/configs/app_config/CMakeLists.txt b/applications/blinky/configs/app_config/CMakeLists.txt similarity index 100% rename from Projects/blinky/configs/app_config/CMakeLists.txt rename to applications/blinky/configs/app_config/CMakeLists.txt diff --git a/Projects/blinky/configs/app_config/app_config.h b/applications/blinky/configs/app_config/app_config.h similarity index 100% rename from Projects/blinky/configs/app_config/app_config.h rename to applications/blinky/configs/app_config/app_config.h diff --git a/Projects/blinky/configs/freertos-config/CMakeLists.txt b/applications/blinky/configs/freertos-config/CMakeLists.txt similarity index 100% rename from Projects/blinky/configs/freertos-config/CMakeLists.txt rename to applications/blinky/configs/freertos-config/CMakeLists.txt diff --git a/Projects/blinky/configs/freertos-config/FreeRTOSConfig.h b/applications/blinky/configs/freertos-config/FreeRTOSConfig.h similarity index 100% rename from Projects/blinky/configs/freertos-config/FreeRTOSConfig.h rename to applications/blinky/configs/freertos-config/FreeRTOSConfig.h diff --git a/Projects/blinky/configs/tfm-config/project_config.h b/applications/blinky/configs/tfm-config/project_config.h similarity index 100% rename from Projects/blinky/configs/tfm-config/project_config.h rename to applications/blinky/configs/tfm-config/project_config.h diff --git a/Projects/blinky/main.c b/applications/blinky/main.c similarity index 100% rename from Projects/blinky/main.c rename to applications/blinky/main.c diff --git a/Projects/blinky/tests/fail_output.log b/applications/blinky/tests/fail_output.log similarity index 100% rename from Projects/blinky/tests/fail_output.log rename to applications/blinky/tests/fail_output.log diff --git a/Projects/blinky/tests/pass_output.log b/applications/blinky/tests/pass_output.log similarity index 100% rename from Projects/blinky/tests/pass_output.log rename to applications/blinky/tests/pass_output.log diff --git a/Projects/helpers/CMakeLists.txt b/applications/helpers/CMakeLists.txt similarity index 100% rename from Projects/helpers/CMakeLists.txt rename to applications/helpers/CMakeLists.txt diff --git a/Projects/helpers/events/CMakeLists.txt b/applications/helpers/events/CMakeLists.txt similarity index 100% rename from Projects/helpers/events/CMakeLists.txt rename to applications/helpers/events/CMakeLists.txt diff --git a/Projects/helpers/events/inc/events.h b/applications/helpers/events/inc/events.h similarity index 100% rename from Projects/helpers/events/inc/events.h rename to applications/helpers/events/inc/events.h diff --git a/Projects/helpers/events/src/events.c b/applications/helpers/events/src/events.c similarity index 100% rename from Projects/helpers/events/src/events.c rename to applications/helpers/events/src/events.c diff --git a/Projects/helpers/logging/CMakeLists.txt b/applications/helpers/logging/CMakeLists.txt similarity index 100% rename from Projects/helpers/logging/CMakeLists.txt rename to applications/helpers/logging/CMakeLists.txt diff --git a/Projects/helpers/logging/inc/iot_logging_task.h b/applications/helpers/logging/inc/iot_logging_task.h similarity index 100% rename from Projects/helpers/logging/inc/iot_logging_task.h rename to applications/helpers/logging/inc/iot_logging_task.h diff --git a/Projects/helpers/logging/inc/logging_levels.h b/applications/helpers/logging/inc/logging_levels.h similarity index 100% rename from Projects/helpers/logging/inc/logging_levels.h rename to applications/helpers/logging/inc/logging_levels.h diff --git a/Projects/helpers/logging/inc/logging_stack.h b/applications/helpers/logging/inc/logging_stack.h similarity index 100% rename from Projects/helpers/logging/inc/logging_stack.h rename to applications/helpers/logging/inc/logging_stack.h diff --git a/Projects/helpers/logging/src/iot_logging_task_dynamic_buffers.c b/applications/helpers/logging/src/iot_logging_task_dynamic_buffers.c similarity index 100% rename from Projects/helpers/logging/src/iot_logging_task_dynamic_buffers.c rename to applications/helpers/logging/src/iot_logging_task_dynamic_buffers.c diff --git a/Projects/helpers/provisioning/CMakeLists.txt b/applications/helpers/provisioning/CMakeLists.txt similarity index 100% rename from Projects/helpers/provisioning/CMakeLists.txt rename to applications/helpers/provisioning/CMakeLists.txt diff --git a/Projects/helpers/provisioning/cmake/linkerscript_preprocess.cmake b/applications/helpers/provisioning/cmake/linkerscript_preprocess.cmake similarity index 100% rename from Projects/helpers/provisioning/cmake/linkerscript_preprocess.cmake rename to applications/helpers/provisioning/cmake/linkerscript_preprocess.cmake diff --git a/Projects/helpers/provisioning/provisioning_config.h b/applications/helpers/provisioning/provisioning_config.h similarity index 100% rename from Projects/helpers/provisioning/provisioning_config.h rename to applications/helpers/provisioning/provisioning_config.h diff --git a/Projects/helpers/provisioning/provisioning_data.c b/applications/helpers/provisioning/provisioning_data.c similarity index 100% rename from Projects/helpers/provisioning/provisioning_data.c rename to applications/helpers/provisioning/provisioning_data.c diff --git a/Projects/helpers/provisioning/provisioning_data.h b/applications/helpers/provisioning/provisioning_data.h similarity index 100% rename from Projects/helpers/provisioning/provisioning_data.h rename to applications/helpers/provisioning/provisioning_data.h diff --git a/Projects/helpers/provisioning/provisioning_data.ld b/applications/helpers/provisioning/provisioning_data.ld similarity index 100% rename from Projects/helpers/provisioning/provisioning_data.ld rename to applications/helpers/provisioning/provisioning_data.ld diff --git a/Projects/helpers/provisioning/provisioning_data.sct b/applications/helpers/provisioning/provisioning_data.sct similarity index 100% rename from Projects/helpers/provisioning/provisioning_data.sct rename to applications/helpers/provisioning/provisioning_data.sct diff --git a/docs/aws_iot_example.md b/docs/aws_iot_example.md index ada714b0..e4ac2bb6 100644 --- a/docs/aws_iot_example.md +++ b/docs/aws_iot_example.md @@ -229,7 +229,7 @@ on AWS. If you would like to build it with the Arm GNU Toolchain (arm-none-eabi- ## Provisioning the device credentials into Protected Storage -During the build process a ```provisioning_data.bin``` is built into the ```build/Projects/aws-iot-example/provisioning_data``` directory. +During the build process a ```provisioning_data.bin``` is built into the ```build/applications/aws-iot-example/provisioning_data``` directory. This binary contains the device credentials (private key and certificate). If the content of the .pem files that were used during the build process (passed with ```--certificate_path``` and ```--private_key_path```) changed, then ```cmake --build build -j -- provisioning_data``` rebuilds this provisioning binary. @@ -363,7 +363,7 @@ is used for both. This is to ensure you have the original binary to compare against any new version you build. For example, the updated binary is placed in -`build/Projects/aws-iot-example/aws-iot-example-update_signed.bin` for the +`build/applications/aws-iot-example/aws-iot-example-update_signed.bin` for the aws-iot-example application. The updated binary is already signed and it is the file you will need to upload to the Amazon S3 bucket in the next section. @@ -387,11 +387,11 @@ in the next step. 1. Select `MQTT` transport only 1. Select **Use my custom signed file** 1. Select upload new file and select the signed update binary - (`build/Projects/aws-iot-example/aws-iot-example-update_signed.bin`) + (`build/applications/aws-iot-example/aws-iot-example-update_signed.bin`) 1. Select the S3 bucket you created in step 1. to upload the binary to 1. Paste the signature string that is echoed during the build of the example (it is also available in - `build/Projects/aws-iot-example/update-signature.txt`). + `build/applications/aws-iot-example/update-signature.txt`). 1. Select `SHA-256` and `RSA` algorithms. 1. For **Path name of code signing certificate on device** put in `0` (the path is not used) From 0c35e8f4f9c17514e17521757113f0ff9040b48c Mon Sep 17 00:00:00 2001 From: Hugues Kamba-Mpiana Date: Fri, 3 Nov 2023 13:46:03 +0000 Subject: [PATCH 14/22] tools: Rename `Tools` subdir following snake_case The project is adopting snake case for files and subdirectories names Signed-off-by: Hugues Kamba-Mpiana --- .github/workflows/build.yaml | 2 +- .gitlab-ci.yml | 10 +++++----- .pre-commit-config.yaml | 4 ++-- CMakeLists.txt | 2 +- .../helpers/provisioning/CMakeLists.txt | 4 ++-- .../integration/cmake/SignTfmImage.cmake | 2 +- docs/aws_iot_example.md | 18 +++++++++--------- docs/blinky.md | 6 +++--- docs/development_environment.md | 2 +- docs/prerequisites.md | 2 +- {Tools => tools}/cmake/ConvertElfToBin.cmake | 0 {Tools => tools}/scripts/build.sh | 0 .../scripts/check_listed_dependencies.py | 0 .../scripts/generate_credentials.py | 0 .../scripts/generate_credentials_header.py | 0 {Tools => tools}/scripts/run.sh | 0 .../scripts/run_dependencies_check.sh | 2 +- {Tools => tools}/scripts/run_uncrustify.sh | 2 +- {Tools => tools}/tests/aws_test_util.py | 0 .../tests/test_application_output.py | 0 {Tools => tools}/tests/test_integration.py | 0 {Tools => tools}/tests/test_ota.py | 0 {Tools => tools}/uncrustify.cfg | 0 23 files changed, 28 insertions(+), 28 deletions(-) rename {Tools => tools}/cmake/ConvertElfToBin.cmake (100%) rename {Tools => tools}/scripts/build.sh (100%) rename {Tools => tools}/scripts/check_listed_dependencies.py (100%) rename {Tools => tools}/scripts/generate_credentials.py (100%) rename {Tools => tools}/scripts/generate_credentials_header.py (100%) rename {Tools => tools}/scripts/run.sh (100%) rename {Tools => tools}/scripts/run_dependencies_check.sh (71%) rename {Tools => tools}/scripts/run_uncrustify.sh (92%) rename {Tools => tools}/tests/aws_test_util.py (100%) rename {Tools => tools}/tests/test_application_output.py (100%) rename {Tools => tools}/tests/test_integration.py (100%) rename {Tools => tools}/tests/test_ota.py (100%) rename {Tools => tools}/uncrustify.cfg (100%) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index c93d015f..4854a17c 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -55,7 +55,7 @@ jobs: - name: Build the project shell: bash run: | - ./Tools/scripts/build.sh aws-iot-example --toolchain GNU --certificate_path $PWD/certificate.pem --private_key_path $PWD/private_key.pem + ./tools/scripts/build.sh aws-iot-example --toolchain GNU --certificate_path $PWD/certificate.pem --private_key_path $PWD/private_key.pem - name: Copy artifacts shell: bash run: | diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9f1882eb..a21fad91 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -75,7 +75,7 @@ build-applications: - ./ci/generate_credentials.sh -f -p applications/${APP}/configs/aws_configs - git config --global user.email "ci@example.com" - git config --global user.name "ci" - - ./Tools/scripts/build.sh ${APP} --target $TARGET --toolchain $TOOLCHAIN --certificate_path $PWD/certificate.pem --private_key_path $PWD/private_key.pem + - ./tools/scripts/build.sh ${APP} --target $TARGET --toolchain $TOOLCHAIN --certificate_path $PWD/certificate.pem --private_key_path $PWD/private_key.pem - | if [ $APP == "aws-iot-example" ];then tar -czf ${TARGET}_${APP}_${TOOLCHAIN}_build.tar.gz \ @@ -102,7 +102,7 @@ test-applications-output: script: - tar xf ${TARGET}_${APP}_${TOOLCHAIN}_build.tar.gz - | - pytest -s Tools/tests/test_application_output.py \ + pytest -s tools/tests/test_application_output.py \ --build-artefacts-path "build" \ --fvp $FVP_BIN \ --merged-elf-name "${APP}_merged.elf" \ @@ -120,7 +120,7 @@ test-ota: script: - tar xf ${TARGET}_${APP}_${TOOLCHAIN}_build.tar.gz - | - pytest -s Tools/tests/test_ota.py \ + pytest -s tools/tests/test_ota.py \ --build-artefacts-path "build" \ --fvp $FVP_BIN \ --credentials-path "applications/${APP}/configs/aws_configs" \ @@ -145,13 +145,13 @@ integration-tests: - ./ci/generate_credentials.sh -f -p applications/${APP}/configs/aws_configs - git config --global user.email "ci@example.com" - git config --global user.name "ci" - - ./Tools/scripts/build.sh -q ${APP} + - ./tools/scripts/build.sh -q ${APP} - pushd components/tools/freertos_libraries_integration_tests/library/tools/echo_server - go run echo_server.go& - popd - sleep 1 - | - pytest -s Tools/tests/test_integration.py \ + pytest -s tools/tests/test_integration.py \ --build-artefacts-path "build" \ --fvp $FVP_BIN \ --credentials-path "applications/${APP}/configs/aws_configs" \ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 874a9f44..b527c864 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -80,7 +80,7 @@ repos: name: uncrustify description: Run 'uncrustify' C/C++ code formatter language: script - entry: Tools/scripts/run_uncrustify.sh + entry: tools/scripts/run_uncrustify.sh require_serial: true - repo: local hooks: @@ -96,5 +96,5 @@ repos: name: dependencies-check description: Checks listed dependencies in manifest.yml language: script - entry: Tools/scripts/run_dependencies_check.sh + entry: tools/scripts/run_dependencies_check.sh require_serial: true diff --git a/CMakeLists.txt b/CMakeLists.txt index 3f9fd595..0069b70c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 3.21.0 FATAL_ERROR) project(iot-reference-arm-corstone3xx LANGUAGES C ASM) -list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/Tools/cmake) +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/tools/cmake) add_subdirectory(bsp) add_subdirectory(components EXCLUDE_FROM_ALL) diff --git a/applications/helpers/provisioning/CMakeLists.txt b/applications/helpers/provisioning/CMakeLists.txt index 58a75b28..db6d745f 100644 --- a/applications/helpers/provisioning/CMakeLists.txt +++ b/applications/helpers/provisioning/CMakeLists.txt @@ -32,7 +32,7 @@ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/aws_clientcredential_keys. DEPENDS ${AWS_CLIENT_PRIVATE_KEY_PEM_PATH} DEPENDS ${AWS_CLIENT_CERTIFICATE_PEM_PATH} COMMAND - ${Python3_EXECUTABLE} ${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/Tools/scripts/generate_credentials_header.py + ${Python3_EXECUTABLE} ${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/tools/scripts/generate_credentials_header.py ${CMAKE_CURRENT_BINARY_DIR} --path-to-client-private-key-pem ${AWS_CLIENT_PRIVATE_KEY_PEM_PATH} --path-to-client-certificate-pem ${AWS_CLIENT_CERTIFICATE_PEM_PATH} @@ -58,7 +58,7 @@ else() target_add_scatter_file(provisioning_data ${CMAKE_CURRENT_LIST_DIR}/provisioning_data.sct) endif() -list(APPEND CMAKE_MODULE_PATH ${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/Tools/cmake) +list(APPEND CMAKE_MODULE_PATH ${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/tools/cmake) include(ConvertElfToBin) add_custom_command(OUTPUT provisioning_data.bin diff --git a/components/security/trusted_firmware-m/integration/cmake/SignTfmImage.cmake b/components/security/trusted_firmware-m/integration/cmake/SignTfmImage.cmake index 43eb70ff..6e099e35 100644 --- a/components/security/trusted_firmware-m/integration/cmake/SignTfmImage.cmake +++ b/components/security/trusted_firmware-m/integration/cmake/SignTfmImage.cmake @@ -2,7 +2,7 @@ # # SPDX-License-Identifier: MIT -list(APPEND CMAKE_MODULE_PATH ${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/Tools/cmake) +list(APPEND CMAKE_MODULE_PATH ${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/tools/cmake) include(ConvertElfToBin) include(ExternalProject) diff --git a/docs/aws_iot_example.md b/docs/aws_iot_example.md index e4ac2bb6..93163c3a 100644 --- a/docs/aws_iot_example.md +++ b/docs/aws_iot_example.md @@ -100,11 +100,11 @@ via MQTT as well as enable an over-the-air update. ### Generating and registering your own device certificate AWS IoT Core authenticates device connections with the help of X.509 certificates. The steps below describes how to generate self-signed device certificate and then register it with AWS IoT Core. -1. Run the ```./Tools/scripts/generate_credentials.py``` Python script, that's going to generate a private key +1. Run the ```./tools/scripts/generate_credentials.py``` Python script, that's going to generate a private key and a certificate that's signed with this key. * Optionally you can specify metadata for the certificate. Use the ```-h``` flag for the python script to see the available options. ```bash - python ./Tools/scripts/generate_credentials.py --certificate_valid_time \ + python ./tools/scripts/generate_credentials.py --certificate_valid_time \ --certificate_country_name \ --certificate_state_province_name \ --certificate_locality_name \ @@ -211,14 +211,14 @@ The device certificate PEM and private key PEM will be set during the build conf To build the AWS FreeRTOS MQTT example, run the following command: ```bash -./Tools/scripts/build.sh aws-iot-example --certificate_path --private_key_path +./tools/scripts/build.sh aws-iot-example --certificate_path --private_key_path ``` -* The `certificate pem's path` and `private key pem's path` should be the downloaded key's and certificate's path if you chose the **Auto-generate a new certificate** during the Thing creation. If you chose **Skip creating a certificate at this time** then these paths should locate the generated credential files that were created by the `./Tools/scripts/generate_credentials.py` script in the previous step. +* The `certificate pem's path` and `private key pem's path` should be the downloaded key's and certificate's path if you chose the **Auto-generate a new certificate** during the Thing creation. If you chose **Skip creating a certificate at this time** then these paths should locate the generated credential files that were created by the `./tools/scripts/generate_credentials.py` script in the previous step. Or, run the command below to perform a clean build: ```bash -./Tools/scripts/build.sh aws-iot-example -c +./tools/scripts/build.sh aws-iot-example -c ``` This will build the example with the Arm Compiler (armclang) by default, which is @@ -241,7 +241,7 @@ The binary has to be loaded to the ```0x210FF000``` address so the ```aws-iot-ex To run the AWS FreeRTOS MQTT example, run the following command: ```bash -./Tools/scripts/run.sh aws-iot-example +./tools/scripts/run.sh aws-iot-example ``` ### Expected output @@ -588,13 +588,13 @@ with yours. To build the application, run the following command: ```bash -./Tools/scripts/build.sh aws-iot-example +./tools/scripts/build.sh aws-iot-example ``` Or, run the command below to perform a clean build: ```bash -./Tools/scripts/build.sh aws-iot-example -c +./tools/scripts/build.sh aws-iot-example -c ``` This will build the example with the Arm Compiler (armclang) by default, which is @@ -614,7 +614,7 @@ to start the Creating AWS IoT Core Qualification test suite created in [section] Now run the application by running the following command: ```bash -./Tools/scripts/run.sh aws-iot-example +./tools/scripts/run.sh aws-iot-example ``` Once the device advisor has completed all the tests, you can download the AWS diff --git a/docs/blinky.md b/docs/blinky.md index f3f47294..aca65106 100644 --- a/docs/blinky.md +++ b/docs/blinky.md @@ -18,12 +18,12 @@ ensure that all the prerequisites are met before continuing. To build the blinky example, run the following command: ```bash -./Tools/scripts/build.sh blinky +./tools/scripts/build.sh blinky ``` Run the command below to perform a clean build: ```bash -./Tools/scripts/build.sh blinky -c +./tools/scripts/build.sh blinky -c ``` This will build the example with the Arm Compiler (armclang) by default, which is @@ -36,7 +36,7 @@ on AWS. If you would like to build it with the Arm GNU Toolchain (arm-none-eabi- To run the blinky example, run the following command: ```bash -./Tools/scripts/run.sh blinky +./tools/scripts/run.sh blinky ``` ### Expected output diff --git a/docs/development_environment.md b/docs/development_environment.md index 55ea6cc1..d073b5e9 100644 --- a/docs/development_environment.md +++ b/docs/development_environment.md @@ -169,7 +169,7 @@ repos: name: uncrustify description: Run 'uncrustify' C/C++ code formatter language: script - entry: Tools/run_uncrustify.sh + entry: tools/run_uncrustify.sh require_serial: true - repo: local hooks: diff --git a/docs/prerequisites.md b/docs/prerequisites.md index e2e28964..382f2368 100644 --- a/docs/prerequisites.md +++ b/docs/prerequisites.md @@ -39,7 +39,7 @@ must be run on the console connected to the Arm Virtual Hardware Instance. **Note** -The run example script `Tools/scripts/run.sh` assumes ecosystem FVP by default. +The run example script `tools/scripts/run.sh` assumes ecosystem FVP by default. If you are using Arm virtual hardware using Amazon machine images then an additional argument `--fvp_type vht` must be passed to the run example script. diff --git a/Tools/cmake/ConvertElfToBin.cmake b/tools/cmake/ConvertElfToBin.cmake similarity index 100% rename from Tools/cmake/ConvertElfToBin.cmake rename to tools/cmake/ConvertElfToBin.cmake diff --git a/Tools/scripts/build.sh b/tools/scripts/build.sh similarity index 100% rename from Tools/scripts/build.sh rename to tools/scripts/build.sh diff --git a/Tools/scripts/check_listed_dependencies.py b/tools/scripts/check_listed_dependencies.py similarity index 100% rename from Tools/scripts/check_listed_dependencies.py rename to tools/scripts/check_listed_dependencies.py diff --git a/Tools/scripts/generate_credentials.py b/tools/scripts/generate_credentials.py similarity index 100% rename from Tools/scripts/generate_credentials.py rename to tools/scripts/generate_credentials.py diff --git a/Tools/scripts/generate_credentials_header.py b/tools/scripts/generate_credentials_header.py similarity index 100% rename from Tools/scripts/generate_credentials_header.py rename to tools/scripts/generate_credentials_header.py diff --git a/Tools/scripts/run.sh b/tools/scripts/run.sh similarity index 100% rename from Tools/scripts/run.sh rename to tools/scripts/run.sh diff --git a/Tools/scripts/run_dependencies_check.sh b/tools/scripts/run_dependencies_check.sh similarity index 71% rename from Tools/scripts/run_dependencies_check.sh rename to tools/scripts/run_dependencies_check.sh index 00e9662b..550a4e49 100755 --- a/Tools/scripts/run_dependencies_check.sh +++ b/tools/scripts/run_dependencies_check.sh @@ -4,4 +4,4 @@ # # SPDX-License-Identifier: MIT -python3 Tools/scripts/check_listed_dependencies.py +python3 tools/scripts/check_listed_dependencies.py diff --git a/Tools/scripts/run_uncrustify.sh b/tools/scripts/run_uncrustify.sh similarity index 92% rename from Tools/scripts/run_uncrustify.sh rename to tools/scripts/run_uncrustify.sh index 856ea99d..19982823 100755 --- a/Tools/scripts/run_uncrustify.sh +++ b/tools/scripts/run_uncrustify.sh @@ -21,4 +21,4 @@ do done exclude_pattern+="./build" -fdfind -E $exclude_pattern -e c -e h --exec uncrustify --no-backup --replace --if-changed -c Tools/uncrustify.cfg -l C +fdfind -E $exclude_pattern -e c -e h --exec uncrustify --no-backup --replace --if-changed -c tools/uncrustify.cfg -l C diff --git a/Tools/tests/aws_test_util.py b/tools/tests/aws_test_util.py similarity index 100% rename from Tools/tests/aws_test_util.py rename to tools/tests/aws_test_util.py diff --git a/Tools/tests/test_application_output.py b/tools/tests/test_application_output.py similarity index 100% rename from Tools/tests/test_application_output.py rename to tools/tests/test_application_output.py diff --git a/Tools/tests/test_integration.py b/tools/tests/test_integration.py similarity index 100% rename from Tools/tests/test_integration.py rename to tools/tests/test_integration.py diff --git a/Tools/tests/test_ota.py b/tools/tests/test_ota.py similarity index 100% rename from Tools/tests/test_ota.py rename to tools/tests/test_ota.py diff --git a/Tools/uncrustify.cfg b/tools/uncrustify.cfg similarity index 100% rename from Tools/uncrustify.cfg rename to tools/uncrustify.cfg From 470fe5f5bd53e5200ebdde462a103f0f0736fbbb Mon Sep 17 00:00:00 2001 From: Hugues Kamba-Mpiana Date: Fri, 3 Nov 2023 14:09:37 +0000 Subject: [PATCH 15/22] provisioning: Rename CMake script CMake modules follow the typical naming convention of VerbWithCamelCase. Signed-off-by: Hugues Kamba-Mpiana --- applications/helpers/provisioning/CMakeLists.txt | 2 +- ...script_preprocess.cmake => SetProvisioningLinkOptions.cmake} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename applications/helpers/provisioning/cmake/{linkerscript_preprocess.cmake => SetProvisioningLinkOptions.cmake} (100%) diff --git a/applications/helpers/provisioning/CMakeLists.txt b/applications/helpers/provisioning/CMakeLists.txt index db6d745f..674aebbc 100644 --- a/applications/helpers/provisioning/CMakeLists.txt +++ b/applications/helpers/provisioning/CMakeLists.txt @@ -12,7 +12,7 @@ endif() list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake) -include(linkerscript_preprocess) +include(SetProvisioningLinkOptions) add_executable(provisioning_data provisioning_data.c) target_include_directories(provisioning_data diff --git a/applications/helpers/provisioning/cmake/linkerscript_preprocess.cmake b/applications/helpers/provisioning/cmake/SetProvisioningLinkOptions.cmake similarity index 100% rename from applications/helpers/provisioning/cmake/linkerscript_preprocess.cmake rename to applications/helpers/provisioning/cmake/SetProvisioningLinkOptions.cmake From aa281af5ef3cacb1189d67fa672d02046736073b Mon Sep 17 00:00:00 2001 From: Hugues Kamba-Mpiana Date: Fri, 3 Nov 2023 14:23:12 +0000 Subject: [PATCH 16/22] aws-iot-example: Rename files and subdirs following snake_case Signed-off-by: Hugues Kamba-Mpiana --- .github/workflows/build.yaml | 2 +- .gitlab-ci.yml | 22 +++++++++++-------- .../CMakeLists.txt | 10 ++++----- .../configs/CMakeLists.txt | 2 +- .../configs/app_config/CMakeLists.txt | 0 .../configs/app_config/app_config.h | 0 .../configs/aws_configs/CMakeLists.txt | 0 .../aws_configs/aws_clientcredential.h | 0 .../configs/aws_configs/aws_mqtt_config.h | 0 .../aws_configs/aws_secure_sockets_config.h | 0 .../configs/aws_configs/core_mqtt_config.h | 0 .../configs/aws_configs/core_pkcs11_config.h | 0 .../configs/aws_configs/demo_config.h | 0 .../iot_default_root_certificates.h | 0 .../aws_configs/mqtt_agent_demo_config.h | 0 .../mqtt_demo_mutual_auth_config.h | 0 .../configs/aws_configs/ota_config.h | 0 .../configs/aws_configs/ota_demo_config.h | 0 .../configs/freertos_config}/CMakeLists.txt | 0 .../configs/freertos_config}/FreeRTOSConfig.h | 0 .../freertos_config}/FreeRTOSIPConfig.h | 0 .../configs/mbedtls_config/CMakeLists.txt | 0 .../mbedtls_config/aws_mbedtls_config.h | 0 .../configs/mbedtls_config/threading_alt.h | 0 .../configs/tfm_config}/project_config.h | 0 .../dev_mode_key_provisioning.c | 0 .../dev_mode_key_provisioning.h | 0 .../integration_tests_platform_function.c | 0 .../test_execution_config.h | 0 .../test_param_config.h | 0 .../freertos_integration_tests}/unistd.h | 0 .../main.c | 0 .../mqtt_demo_pub_sub.c | 0 .../tests}/fail_output.log | 0 .../tests}/pass_output.log | 0 docs/aws_iot_example.md | 8 +++---- tools/scripts/build.sh | 2 +- 37 files changed, 25 insertions(+), 21 deletions(-) rename applications/{aws-iot-example => aws_iot_example}/CMakeLists.txt (97%) rename applications/{aws-iot-example => aws_iot_example}/configs/CMakeLists.txt (85%) rename applications/{aws-iot-example => aws_iot_example}/configs/app_config/CMakeLists.txt (100%) rename applications/{aws-iot-example => aws_iot_example}/configs/app_config/app_config.h (100%) rename applications/{aws-iot-example => aws_iot_example}/configs/aws_configs/CMakeLists.txt (100%) rename applications/{aws-iot-example => aws_iot_example}/configs/aws_configs/aws_clientcredential.h (100%) rename applications/{aws-iot-example => aws_iot_example}/configs/aws_configs/aws_mqtt_config.h (100%) rename applications/{aws-iot-example => aws_iot_example}/configs/aws_configs/aws_secure_sockets_config.h (100%) rename applications/{aws-iot-example => aws_iot_example}/configs/aws_configs/core_mqtt_config.h (100%) rename applications/{aws-iot-example => aws_iot_example}/configs/aws_configs/core_pkcs11_config.h (100%) rename applications/{aws-iot-example => aws_iot_example}/configs/aws_configs/demo_config.h (100%) rename applications/{aws-iot-example => aws_iot_example}/configs/aws_configs/iot_default_root_certificates.h (100%) rename applications/{aws-iot-example => aws_iot_example}/configs/aws_configs/mqtt_agent_demo_config.h (100%) rename applications/{aws-iot-example => aws_iot_example}/configs/aws_configs/mqtt_demo_mutual_auth_config.h (100%) rename applications/{aws-iot-example => aws_iot_example}/configs/aws_configs/ota_config.h (100%) rename applications/{aws-iot-example => aws_iot_example}/configs/aws_configs/ota_demo_config.h (100%) rename applications/{aws-iot-example/configs/freertos-config => aws_iot_example/configs/freertos_config}/CMakeLists.txt (100%) rename applications/{aws-iot-example/configs/freertos-config => aws_iot_example/configs/freertos_config}/FreeRTOSConfig.h (100%) rename applications/{aws-iot-example/configs/freertos-config => aws_iot_example/configs/freertos_config}/FreeRTOSIPConfig.h (100%) rename applications/{aws-iot-example => aws_iot_example}/configs/mbedtls_config/CMakeLists.txt (100%) rename applications/{aws-iot-example => aws_iot_example}/configs/mbedtls_config/aws_mbedtls_config.h (100%) rename applications/{aws-iot-example => aws_iot_example}/configs/mbedtls_config/threading_alt.h (100%) rename applications/{aws-iot-example/configs/tfm-config => aws_iot_example/configs/tfm_config}/project_config.h (100%) rename applications/{aws-iot-example => aws_iot_example}/dev_mode_key_provisioning.c (100%) rename applications/{aws-iot-example/freertos-integration-tests/include => aws_iot_example/freertos_integration_tests}/dev_mode_key_provisioning.h (100%) rename applications/{aws-iot-example/freertos-integration-tests => aws_iot_example/freertos_integration_tests}/integration_tests_platform_function.c (100%) rename applications/{aws-iot-example/freertos-integration-tests/include => aws_iot_example/freertos_integration_tests}/test_execution_config.h (100%) rename applications/{aws-iot-example/freertos-integration-tests/include => aws_iot_example/freertos_integration_tests}/test_param_config.h (100%) rename applications/{aws-iot-example/freertos-integration-tests/include => aws_iot_example/freertos_integration_tests}/unistd.h (100%) rename applications/{aws-iot-example => aws_iot_example}/main.c (100%) rename applications/{aws-iot-example => aws_iot_example}/mqtt_demo_pub_sub.c (100%) rename applications/{aws-iot-example => aws_iot_example/tests}/fail_output.log (100%) rename applications/{aws-iot-example => aws_iot_example/tests}/pass_output.log (100%) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 4854a17c..caef950e 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -49,7 +49,7 @@ jobs: export IOT_OTA_CLIENT_CERT="dummy_certificate" export IOT_OTA_CLIENT_PRIV="dummy_priv_key" export IOT_OTA_CLIENT_PUB="dummy_pub_key" - ./ci/generate_credentials.sh -f -p applications/aws-iot-example/configs/aws_configs + ./ci/generate_credentials.sh -f -p applications/aws_iot_example/configs/aws_configs git config --global user.email "ci@example.com" git config --global user.name "ci" - name: Build the project diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a21fad91..0a737984 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -72,7 +72,8 @@ build-applications: stage: build extends: .base_job script: - - ./ci/generate_credentials.sh -f -p applications/${APP}/configs/aws_configs + - export APP_UNDERSCORED=$(echo ${APP} | tr '-' '_') + - ./ci/generate_credentials.sh -f -p applications/${APP_UNDERSCORED}/configs/aws_configs - git config --global user.email "ci@example.com" - git config --global user.name "ci" - ./tools/scripts/build.sh ${APP} --target $TARGET --toolchain $TOOLCHAIN --certificate_path $PWD/certificate.pem --private_key_path $PWD/private_key.pem @@ -82,7 +83,7 @@ build-applications: build/${APP}_merged.elf \ build/${APP}-update_signed.bin \ build/update-signature.txt \ - applications/${APP}/configs/aws_configs + applications/${APP_UNDERSCORED}/configs/aws_configs else tar -czf ${TARGET}_${APP}_${TOOLCHAIN}_build.tar.gz \ build/${APP}_merged.elf @@ -101,14 +102,15 @@ test-applications-output: extends: .test_job script: - tar xf ${TARGET}_${APP}_${TOOLCHAIN}_build.tar.gz + - export APP_UNDERSCORED=$(echo ${APP} | tr '-' '_') - | pytest -s tools/tests/test_application_output.py \ --build-artefacts-path "build" \ --fvp $FVP_BIN \ --merged-elf-name "${APP}_merged.elf" \ --timeout-seconds 600 \ - --pass-output-file "applications/${APP}/tests/pass_output.log" \ - --fail-output-file "applications/${APP}/tests/fail_output.log" + --pass-output-file "applications/${APP_UNDERSCORED}/tests/pass_output.log" \ + --fail-output-file "applications/${APP_UNDERSCORED}/tests/fail_output.log" parallel: matrix: - @@ -119,16 +121,17 @@ test-ota: extends: .test_job script: - tar xf ${TARGET}_${APP}_${TOOLCHAIN}_build.tar.gz + - export APP_UNDERSCORED=$(echo ${APP} | tr '-' '_') - | pytest -s tools/tests/test_ota.py \ --build-artefacts-path "build" \ --fvp $FVP_BIN \ - --credentials-path "applications/${APP}/configs/aws_configs" \ + --credentials-path "applications/${APP_UNDERSCORED}/configs/aws_configs" \ --merged-elf-name "${APP}_merged.elf" \ --signed-update-bin-name "${APP}-update_signed.bin" \ --timeout-seconds 900 \ - --pass-output-file "applications/${APP}/tests/pass_output.log" \ - --fail-output-file "applications/${APP}/tests/fail_output.log" + --pass-output-file "applications/${APP_UNDERSCORED}/tests/pass_output.log" \ + --fail-output-file "applications/${APP_UNDERSCORED}/tests/fail_output.log" parallel: matrix: - @@ -142,7 +145,8 @@ integration-tests: rules: - if: ( $SCHEDULED_JOB_TO_RUN == "integration-tests" ) script: - - ./ci/generate_credentials.sh -f -p applications/${APP}/configs/aws_configs + - export APP_UNDERSCORED=$(echo ${APP} | tr '-' '_') + - ./ci/generate_credentials.sh -f -p applications/${APP_UNDERSCORED}/configs/aws_configs - git config --global user.email "ci@example.com" - git config --global user.name "ci" - ./tools/scripts/build.sh -q ${APP} @@ -154,7 +158,7 @@ integration-tests: pytest -s tools/tests/test_integration.py \ --build-artefacts-path "build" \ --fvp $FVP_BIN \ - --credentials-path "applications/${APP}/configs/aws_configs" \ + --credentials-path "applications/${APP_UNDERSCORED}/configs/aws_configs" \ --merged-elf-name "${APP}-tests_merged.elf" \ --signed-update-bin-name "${APP}-tests-update_signed.bin" parallel: diff --git a/applications/aws-iot-example/CMakeLists.txt b/applications/aws_iot_example/CMakeLists.txt similarity index 97% rename from applications/aws-iot-example/CMakeLists.txt rename to applications/aws_iot_example/CMakeLists.txt index b768948e..6856556c 100644 --- a/applications/aws-iot-example/CMakeLists.txt +++ b/applications/aws_iot_example/CMakeLists.txt @@ -46,7 +46,7 @@ set(TFM_CMAKE_ARGS -DPLATFORM_DEFAULT_PROVISIONING=OFF -DPLATFORM_DEFAULT_UART_STDOUT=ON -DPLATFORM_HAS_FIRMWARE_UPDATE_SUPPORT=ON - -DPROJECT_CONFIG_HEADER_FILE=${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/applications/aws-iot-example/configs/tfm-config/project_config.h + -DPROJECT_CONFIG_HEADER_FILE=${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/applications/aws_iot_example/configs/tfm_config/project_config.h -DTFM_DUMMY_PROVISIONING=OFF -DTFM_EXCEPTION_INFO_DUMP=ON -DTFM_PARTITION_CRYPTO=ON @@ -96,7 +96,7 @@ add_executable(aws-iot-example ) target_include_directories(aws-iot-example PUBLIC - freertos-integration-tests/include + freertos_integration_tests ../helpers/provisioning ) @@ -173,11 +173,11 @@ iot_reference_arm_corstone3xx_generate_aws_update_digest_and_signature( add_dependencies(freertos-libraries-integration-tests-config provisioning_data_bin) target_sources(freertos-libraries-integration-tests-config INTERFACE - freertos-integration-tests/integration_tests_platform_function.c + freertos_integration_tests/integration_tests_platform_function.c ) target_include_directories(freertos-libraries-integration-tests-config INTERFACE - freertos-integration-tests/include + freertos_integration_tests provisioning ${CMAKE_BINARY_DIR}/provisioning ${CMAKE_BINARY_DIR}/provisioning_data @@ -205,7 +205,7 @@ add_executable(aws-iot-example-tests ) target_include_directories(aws-iot-example-tests PUBLIC - freertos-integration-tests + freertos_integration_tests ) target_compile_definitions(aws-iot-example-tests diff --git a/applications/aws-iot-example/configs/CMakeLists.txt b/applications/aws_iot_example/configs/CMakeLists.txt similarity index 85% rename from applications/aws-iot-example/configs/CMakeLists.txt rename to applications/aws_iot_example/configs/CMakeLists.txt index 8ba83506..069f0910 100644 --- a/applications/aws-iot-example/configs/CMakeLists.txt +++ b/applications/aws_iot_example/configs/CMakeLists.txt @@ -4,5 +4,5 @@ add_subdirectory(app_config) add_subdirectory(aws_configs) -add_subdirectory(freertos-config) +add_subdirectory(freertos_config) add_subdirectory(mbedtls_config) diff --git a/applications/aws-iot-example/configs/app_config/CMakeLists.txt b/applications/aws_iot_example/configs/app_config/CMakeLists.txt similarity index 100% rename from applications/aws-iot-example/configs/app_config/CMakeLists.txt rename to applications/aws_iot_example/configs/app_config/CMakeLists.txt diff --git a/applications/aws-iot-example/configs/app_config/app_config.h b/applications/aws_iot_example/configs/app_config/app_config.h similarity index 100% rename from applications/aws-iot-example/configs/app_config/app_config.h rename to applications/aws_iot_example/configs/app_config/app_config.h diff --git a/applications/aws-iot-example/configs/aws_configs/CMakeLists.txt b/applications/aws_iot_example/configs/aws_configs/CMakeLists.txt similarity index 100% rename from applications/aws-iot-example/configs/aws_configs/CMakeLists.txt rename to applications/aws_iot_example/configs/aws_configs/CMakeLists.txt diff --git a/applications/aws-iot-example/configs/aws_configs/aws_clientcredential.h b/applications/aws_iot_example/configs/aws_configs/aws_clientcredential.h similarity index 100% rename from applications/aws-iot-example/configs/aws_configs/aws_clientcredential.h rename to applications/aws_iot_example/configs/aws_configs/aws_clientcredential.h diff --git a/applications/aws-iot-example/configs/aws_configs/aws_mqtt_config.h b/applications/aws_iot_example/configs/aws_configs/aws_mqtt_config.h similarity index 100% rename from applications/aws-iot-example/configs/aws_configs/aws_mqtt_config.h rename to applications/aws_iot_example/configs/aws_configs/aws_mqtt_config.h diff --git a/applications/aws-iot-example/configs/aws_configs/aws_secure_sockets_config.h b/applications/aws_iot_example/configs/aws_configs/aws_secure_sockets_config.h similarity index 100% rename from applications/aws-iot-example/configs/aws_configs/aws_secure_sockets_config.h rename to applications/aws_iot_example/configs/aws_configs/aws_secure_sockets_config.h diff --git a/applications/aws-iot-example/configs/aws_configs/core_mqtt_config.h b/applications/aws_iot_example/configs/aws_configs/core_mqtt_config.h similarity index 100% rename from applications/aws-iot-example/configs/aws_configs/core_mqtt_config.h rename to applications/aws_iot_example/configs/aws_configs/core_mqtt_config.h diff --git a/applications/aws-iot-example/configs/aws_configs/core_pkcs11_config.h b/applications/aws_iot_example/configs/aws_configs/core_pkcs11_config.h similarity index 100% rename from applications/aws-iot-example/configs/aws_configs/core_pkcs11_config.h rename to applications/aws_iot_example/configs/aws_configs/core_pkcs11_config.h diff --git a/applications/aws-iot-example/configs/aws_configs/demo_config.h b/applications/aws_iot_example/configs/aws_configs/demo_config.h similarity index 100% rename from applications/aws-iot-example/configs/aws_configs/demo_config.h rename to applications/aws_iot_example/configs/aws_configs/demo_config.h diff --git a/applications/aws-iot-example/configs/aws_configs/iot_default_root_certificates.h b/applications/aws_iot_example/configs/aws_configs/iot_default_root_certificates.h similarity index 100% rename from applications/aws-iot-example/configs/aws_configs/iot_default_root_certificates.h rename to applications/aws_iot_example/configs/aws_configs/iot_default_root_certificates.h diff --git a/applications/aws-iot-example/configs/aws_configs/mqtt_agent_demo_config.h b/applications/aws_iot_example/configs/aws_configs/mqtt_agent_demo_config.h similarity index 100% rename from applications/aws-iot-example/configs/aws_configs/mqtt_agent_demo_config.h rename to applications/aws_iot_example/configs/aws_configs/mqtt_agent_demo_config.h diff --git a/applications/aws-iot-example/configs/aws_configs/mqtt_demo_mutual_auth_config.h b/applications/aws_iot_example/configs/aws_configs/mqtt_demo_mutual_auth_config.h similarity index 100% rename from applications/aws-iot-example/configs/aws_configs/mqtt_demo_mutual_auth_config.h rename to applications/aws_iot_example/configs/aws_configs/mqtt_demo_mutual_auth_config.h diff --git a/applications/aws-iot-example/configs/aws_configs/ota_config.h b/applications/aws_iot_example/configs/aws_configs/ota_config.h similarity index 100% rename from applications/aws-iot-example/configs/aws_configs/ota_config.h rename to applications/aws_iot_example/configs/aws_configs/ota_config.h diff --git a/applications/aws-iot-example/configs/aws_configs/ota_demo_config.h b/applications/aws_iot_example/configs/aws_configs/ota_demo_config.h similarity index 100% rename from applications/aws-iot-example/configs/aws_configs/ota_demo_config.h rename to applications/aws_iot_example/configs/aws_configs/ota_demo_config.h diff --git a/applications/aws-iot-example/configs/freertos-config/CMakeLists.txt b/applications/aws_iot_example/configs/freertos_config/CMakeLists.txt similarity index 100% rename from applications/aws-iot-example/configs/freertos-config/CMakeLists.txt rename to applications/aws_iot_example/configs/freertos_config/CMakeLists.txt diff --git a/applications/aws-iot-example/configs/freertos-config/FreeRTOSConfig.h b/applications/aws_iot_example/configs/freertos_config/FreeRTOSConfig.h similarity index 100% rename from applications/aws-iot-example/configs/freertos-config/FreeRTOSConfig.h rename to applications/aws_iot_example/configs/freertos_config/FreeRTOSConfig.h diff --git a/applications/aws-iot-example/configs/freertos-config/FreeRTOSIPConfig.h b/applications/aws_iot_example/configs/freertos_config/FreeRTOSIPConfig.h similarity index 100% rename from applications/aws-iot-example/configs/freertos-config/FreeRTOSIPConfig.h rename to applications/aws_iot_example/configs/freertos_config/FreeRTOSIPConfig.h diff --git a/applications/aws-iot-example/configs/mbedtls_config/CMakeLists.txt b/applications/aws_iot_example/configs/mbedtls_config/CMakeLists.txt similarity index 100% rename from applications/aws-iot-example/configs/mbedtls_config/CMakeLists.txt rename to applications/aws_iot_example/configs/mbedtls_config/CMakeLists.txt diff --git a/applications/aws-iot-example/configs/mbedtls_config/aws_mbedtls_config.h b/applications/aws_iot_example/configs/mbedtls_config/aws_mbedtls_config.h similarity index 100% rename from applications/aws-iot-example/configs/mbedtls_config/aws_mbedtls_config.h rename to applications/aws_iot_example/configs/mbedtls_config/aws_mbedtls_config.h diff --git a/applications/aws-iot-example/configs/mbedtls_config/threading_alt.h b/applications/aws_iot_example/configs/mbedtls_config/threading_alt.h similarity index 100% rename from applications/aws-iot-example/configs/mbedtls_config/threading_alt.h rename to applications/aws_iot_example/configs/mbedtls_config/threading_alt.h diff --git a/applications/aws-iot-example/configs/tfm-config/project_config.h b/applications/aws_iot_example/configs/tfm_config/project_config.h similarity index 100% rename from applications/aws-iot-example/configs/tfm-config/project_config.h rename to applications/aws_iot_example/configs/tfm_config/project_config.h diff --git a/applications/aws-iot-example/dev_mode_key_provisioning.c b/applications/aws_iot_example/dev_mode_key_provisioning.c similarity index 100% rename from applications/aws-iot-example/dev_mode_key_provisioning.c rename to applications/aws_iot_example/dev_mode_key_provisioning.c diff --git a/applications/aws-iot-example/freertos-integration-tests/include/dev_mode_key_provisioning.h b/applications/aws_iot_example/freertos_integration_tests/dev_mode_key_provisioning.h similarity index 100% rename from applications/aws-iot-example/freertos-integration-tests/include/dev_mode_key_provisioning.h rename to applications/aws_iot_example/freertos_integration_tests/dev_mode_key_provisioning.h diff --git a/applications/aws-iot-example/freertos-integration-tests/integration_tests_platform_function.c b/applications/aws_iot_example/freertos_integration_tests/integration_tests_platform_function.c similarity index 100% rename from applications/aws-iot-example/freertos-integration-tests/integration_tests_platform_function.c rename to applications/aws_iot_example/freertos_integration_tests/integration_tests_platform_function.c diff --git a/applications/aws-iot-example/freertos-integration-tests/include/test_execution_config.h b/applications/aws_iot_example/freertos_integration_tests/test_execution_config.h similarity index 100% rename from applications/aws-iot-example/freertos-integration-tests/include/test_execution_config.h rename to applications/aws_iot_example/freertos_integration_tests/test_execution_config.h diff --git a/applications/aws-iot-example/freertos-integration-tests/include/test_param_config.h b/applications/aws_iot_example/freertos_integration_tests/test_param_config.h similarity index 100% rename from applications/aws-iot-example/freertos-integration-tests/include/test_param_config.h rename to applications/aws_iot_example/freertos_integration_tests/test_param_config.h diff --git a/applications/aws-iot-example/freertos-integration-tests/include/unistd.h b/applications/aws_iot_example/freertos_integration_tests/unistd.h similarity index 100% rename from applications/aws-iot-example/freertos-integration-tests/include/unistd.h rename to applications/aws_iot_example/freertos_integration_tests/unistd.h diff --git a/applications/aws-iot-example/main.c b/applications/aws_iot_example/main.c similarity index 100% rename from applications/aws-iot-example/main.c rename to applications/aws_iot_example/main.c diff --git a/applications/aws-iot-example/mqtt_demo_pub_sub.c b/applications/aws_iot_example/mqtt_demo_pub_sub.c similarity index 100% rename from applications/aws-iot-example/mqtt_demo_pub_sub.c rename to applications/aws_iot_example/mqtt_demo_pub_sub.c diff --git a/applications/aws-iot-example/fail_output.log b/applications/aws_iot_example/tests/fail_output.log similarity index 100% rename from applications/aws-iot-example/fail_output.log rename to applications/aws_iot_example/tests/fail_output.log diff --git a/applications/aws-iot-example/pass_output.log b/applications/aws_iot_example/tests/pass_output.log similarity index 100% rename from applications/aws-iot-example/pass_output.log rename to applications/aws_iot_example/tests/pass_output.log diff --git a/docs/aws_iot_example.md b/docs/aws_iot_example.md index 93163c3a..0f750192 100644 --- a/docs/aws_iot_example.md +++ b/docs/aws_iot_example.md @@ -229,7 +229,7 @@ on AWS. If you would like to build it with the Arm GNU Toolchain (arm-none-eabi- ## Provisioning the device credentials into Protected Storage -During the build process a ```provisioning_data.bin``` is built into the ```build/applications/aws-iot-example/provisioning_data``` directory. +During the build process a ```provisioning_data.bin``` is built into the ```build/applications/aws_iot_example/provisioning_data``` directory. This binary contains the device credentials (private key and certificate). If the content of the .pem files that were used during the build process (passed with ```--certificate_path``` and ```--private_key_path```) changed, then ```cmake --build build -j -- provisioning_data``` rebuilds this provisioning binary. @@ -363,7 +363,7 @@ is used for both. This is to ensure you have the original binary to compare against any new version you build. For example, the updated binary is placed in -`build/applications/aws-iot-example/aws-iot-example-update_signed.bin` for the +`build/applications/aws_iot_example/aws-iot-example-update_signed.bin` for the aws-iot-example application. The updated binary is already signed and it is the file you will need to upload to the Amazon S3 bucket in the next section. @@ -387,11 +387,11 @@ in the next step. 1. Select `MQTT` transport only 1. Select **Use my custom signed file** 1. Select upload new file and select the signed update binary - (`build/applications/aws-iot-example/aws-iot-example-update_signed.bin`) + (`build/applications/aws_iot_example/aws-iot-example-update_signed.bin`) 1. Select the S3 bucket you created in step 1. to upload the binary to 1. Paste the signature string that is echoed during the build of the example (it is also available in - `build/applications/aws-iot-example/update-signature.txt`). + `build/applications/aws_iot_example/update-signature.txt`). 1. Select `SHA-256` and `RSA` algorithms. 1. For **Path name of code signing certificate on device** put in `0` (the path is not used) diff --git a/tools/scripts/build.sh b/tools/scripts/build.sh index ebfdbd54..e1c99590 100755 --- a/tools/scripts/build.sh +++ b/tools/scripts/build.sh @@ -147,7 +147,7 @@ case "$1" in ;; aws-iot-example) EXAMPLE="$1" - PATH_TO_SOURCE="$ROOT/applications/aws-iot-example" + PATH_TO_SOURCE="$ROOT/applications/aws_iot_example" ;; *) echo "Missing example " From cb3753cfa377d69b8e262dffa050be09da385273 Mon Sep 17 00:00:00 2001 From: Hugues Kamba-Mpiana Date: Fri, 3 Nov 2023 15:19:29 +0000 Subject: [PATCH 17/22] blinky: Rename files and subdirs following snake_case Signed-off-by: Hugues Kamba-Mpiana --- applications/blinky/CMakeLists.txt | 2 +- applications/blinky/configs/CMakeLists.txt | 2 +- .../configs/{freertos-config => freertos_config}/CMakeLists.txt | 0 .../{freertos-config => freertos_config}/FreeRTOSConfig.h | 0 .../blinky/configs/{tfm-config => tfm_config}/project_config.h | 0 5 files changed, 2 insertions(+), 2 deletions(-) rename applications/blinky/configs/{freertos-config => freertos_config}/CMakeLists.txt (100%) rename applications/blinky/configs/{freertos-config => freertos_config}/FreeRTOSConfig.h (100%) rename applications/blinky/configs/{tfm-config => tfm_config}/project_config.h (100%) diff --git a/applications/blinky/CMakeLists.txt b/applications/blinky/CMakeLists.txt index 3c187d42..4c749df2 100644 --- a/applications/blinky/CMakeLists.txt +++ b/applications/blinky/CMakeLists.txt @@ -27,7 +27,7 @@ set(TFM_CMAKE_ARGS -DNS=ON -DPLATFORM_DEFAULT_PROVISIONING=OFF -DPLATFORM_DEFAULT_UART_STDOUT=ON - -DPROJECT_CONFIG_HEADER_FILE=${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/applications/blinky/configs/tfm-config/project_config.h + -DPROJECT_CONFIG_HEADER_FILE=${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/applications/blinky/configs/tfm_config/project_config.h -DTFM_DUMMY_PROVISIONING=OFF -DTFM_EXCEPTION_INFO_DUMP=ON -DTFM_PARTITION_CRYPTO=ON diff --git a/applications/blinky/configs/CMakeLists.txt b/applications/blinky/configs/CMakeLists.txt index 9e9e6360..da3043a1 100644 --- a/applications/blinky/configs/CMakeLists.txt +++ b/applications/blinky/configs/CMakeLists.txt @@ -3,4 +3,4 @@ # SPDX-License-Identifier: MIT add_subdirectory(app_config) -add_subdirectory(freertos-config) +add_subdirectory(freertos_config) diff --git a/applications/blinky/configs/freertos-config/CMakeLists.txt b/applications/blinky/configs/freertos_config/CMakeLists.txt similarity index 100% rename from applications/blinky/configs/freertos-config/CMakeLists.txt rename to applications/blinky/configs/freertos_config/CMakeLists.txt diff --git a/applications/blinky/configs/freertos-config/FreeRTOSConfig.h b/applications/blinky/configs/freertos_config/FreeRTOSConfig.h similarity index 100% rename from applications/blinky/configs/freertos-config/FreeRTOSConfig.h rename to applications/blinky/configs/freertos_config/FreeRTOSConfig.h diff --git a/applications/blinky/configs/tfm-config/project_config.h b/applications/blinky/configs/tfm_config/project_config.h similarity index 100% rename from applications/blinky/configs/tfm-config/project_config.h rename to applications/blinky/configs/tfm_config/project_config.h From a09931e896d5fc499dc357b4f471fd9b987eb4d5 Mon Sep 17 00:00:00 2001 From: Hugues Kamba-Mpiana Date: Fri, 3 Nov 2023 15:41:11 +0000 Subject: [PATCH 18/22] docs: Add subdirectory description to README Signed-off-by: Hugues Kamba-Mpiana --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index b7a05c2e..bb326b36 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,21 @@ porting of this integration across platforms easy. * [Corstone-300](https://developer.arm.com/Processors/Corstone-300) * [Corstone-310](https://developer.arm.com/Processors/Corstone-310) + +## Directory structure + +The project contains the following subdirectories: + +| Subdirectory | Description | +| --- | --- | +|[applications](./applications/)| Contains applications that consume the components integrated in this reference integration. The applications can be built for all supported boards mentioned above.| +|[bsp](./bsp/)| Contains dependencies for the board support package (BSP) utilized in device drivers, firmware booting, and other functionalities that enable an embedded operating system to operate within a specific hardware environment.| +|[components](./components/)| Contains dependencies employed in the development of complete IoT applications fetched via Git Submodules. Read [this](./components/README.md) for more info.| +|[docs](./docs/)| Contains various documentation to work with this project.| +|[release_changes](./release_changes)| Contains the release changes to be compiled to generate a release note.| +|[tools](./tools/)| Contains all the tools created by this projects that are not imported from any components.| + + ## Examples This reference integration contains following two examples: From c506f6b281fc8175b285e68693a7d5f6ad19d46d Mon Sep 17 00:00:00 2001 From: Hugues Kamba-Mpiana Date: Mon, 6 Nov 2023 10:12:45 +0000 Subject: [PATCH 19/22] ci: Move tools to `tools` subdir Signed-off-by: Hugues Kamba-Mpiana --- .github/workflows/build.yaml | 2 +- .gitlab-ci.yml | 8 ++++---- .pre-commit-config.yaml | 2 +- docs/development_environment.md | 4 ++-- pyproject.toml | 2 +- setup.cfg | 2 +- {ci => tools/ci}/aws_cleanup.py | 0 {ci => tools/ci}/generate_credentials.sh | 2 +- {ci => tools/ci}/gitlint/.gitlint | 0 {ci => tools/ci}/gitlint/gitlint-user-rules.py | 0 {ci => tools/ci}/hooks/banned_api.py | 0 {ci => tools/ci}/hooks/banned_api_list.txt | 0 {ci => tools/ci}/license/license.schema | 0 {ci => tools/ci}/pipeline-baseline-fri.yml | 8 ++++---- {ci => tools/ci}/towncrier/template.rst | 0 {ci => tools/ci}/tpip-checker/tpip_checker.md | 0 {ci => tools/ci}/tpip-checker/tpip_checker.py | 0 17 files changed, 15 insertions(+), 15 deletions(-) rename {ci => tools/ci}/aws_cleanup.py (100%) rename {ci => tools/ci}/generate_credentials.sh (98%) rename {ci => tools/ci}/gitlint/.gitlint (100%) rename {ci => tools/ci}/gitlint/gitlint-user-rules.py (100%) rename {ci => tools/ci}/hooks/banned_api.py (100%) rename {ci => tools/ci}/hooks/banned_api_list.txt (100%) rename {ci => tools/ci}/license/license.schema (100%) rename {ci => tools/ci}/pipeline-baseline-fri.yml (91%) rename {ci => tools/ci}/towncrier/template.rst (100%) rename {ci => tools/ci}/tpip-checker/tpip_checker.md (100%) rename {ci => tools/ci}/tpip-checker/tpip_checker.py (100%) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index caef950e..1101e005 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -49,7 +49,7 @@ jobs: export IOT_OTA_CLIENT_CERT="dummy_certificate" export IOT_OTA_CLIENT_PRIV="dummy_priv_key" export IOT_OTA_CLIENT_PUB="dummy_pub_key" - ./ci/generate_credentials.sh -f -p applications/aws_iot_example/configs/aws_configs + ./tools/ci/generate_credentials.sh -f -p applications/aws_iot_example/configs/aws_configs git config --global user.email "ci@example.com" git config --global user.name "ci" - name: Build the project diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0a737984..75db4842 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,7 +8,7 @@ default: image: ${OPEN_IOT_SDK_DOCKER_REGISTRY}/open-iot-sdk:${OPEN_IOT_SDK_DOCKER_VERSION} include: - local: '$PWD/ci/pipeline-baseline-fri.yml' + local: '$PWD/tools/ci/pipeline-baseline-fri.yml' variables: OPEN_IOT_SDK_DOCKER_VERSION: v1 @@ -73,7 +73,7 @@ build-applications: extends: .base_job script: - export APP_UNDERSCORED=$(echo ${APP} | tr '-' '_') - - ./ci/generate_credentials.sh -f -p applications/${APP_UNDERSCORED}/configs/aws_configs + - ./tools/ci/generate_credentials.sh -f -p applications/${APP_UNDERSCORED}/configs/aws_configs - git config --global user.email "ci@example.com" - git config --global user.name "ci" - ./tools/scripts/build.sh ${APP} --target $TARGET --toolchain $TOOLCHAIN --certificate_path $PWD/certificate.pem --private_key_path $PWD/private_key.pem @@ -146,7 +146,7 @@ integration-tests: - if: ( $SCHEDULED_JOB_TO_RUN == "integration-tests" ) script: - export APP_UNDERSCORED=$(echo ${APP} | tr '-' '_') - - ./ci/generate_credentials.sh -f -p applications/${APP_UNDERSCORED}/configs/aws_configs + - ./tools/ci/generate_credentials.sh -f -p applications/${APP_UNDERSCORED}/configs/aws_configs - git config --global user.email "ci@example.com" - git config --global user.name "ci" - ./tools/scripts/build.sh -q ${APP} @@ -176,4 +176,4 @@ aws-cleanup: rules: - if: $SCHEDULED_JOB_TO_RUN == "cleanup" script: - - python -u ./ci/aws_cleanup.py + - python -u ./tools/ci/aws_cleanup.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b527c864..14d4fed8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -37,7 +37,7 @@ repos: hooks: - id: gitlint args: - - "--config ci/gitlint/.gitlint" + - "--config tools/ci/gitlint/.gitlint" - repo: https://github.com/psf/black rev: 23.10.1 hooks: diff --git a/docs/development_environment.md b/docs/development_environment.md index d073b5e9..5faec255 100644 --- a/docs/development_environment.md +++ b/docs/development_environment.md @@ -123,7 +123,7 @@ repos: hooks: - id: gitlint args: - - "--config ci/gitlint/.gitlint" + - "--config tools/ci/gitlint/.gitlint" - repo: https://github.com/psf/black rev: 23.10.1 hooks: @@ -194,7 +194,7 @@ Refer to the [.pre-commit-config.yaml](../.pre-commit-config.yaml) for the defau #### Banned-api -This pre-commit hook is used to check if certain unsafe C/C++ APIs are used in your code. By default, `banned-api` checks the [complete list](../ci/hooks/banned_api_list.txt) present in the repository. +This pre-commit hook is used to check if certain unsafe C/C++ APIs are used in your code. By default, `banned-api` checks the [complete list](../tools/ci/hooks/banned_api_list.txt) present in the repository. #### Trims trailing whitespace Check and trim any trailing whitespace. diff --git a/pyproject.toml b/pyproject.toml index 460c098b..03b0ccf6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ local_scheme = "no-local-version" [tool.towncrier] directory = "release_changes" filename = "CHANGELOG.md" -template = "ci/towncrier/template.rst" +template = "tools/ci/towncrier/template.rst" [[tool.towncrier.type]] directory = "change" diff --git a/setup.cfg b/setup.cfg index 4a0c3054..65066672 100644 --- a/setup.cfg +++ b/setup.cfg @@ -15,7 +15,7 @@ packages = find: [options.entry_points] console_scripts = - banned-api-hook = ci.hooks.banned_api:main + banned-api-hook = tools.ci.hooks.banned_api:main [options.package_data] * = *.txt diff --git a/ci/aws_cleanup.py b/tools/ci/aws_cleanup.py similarity index 100% rename from ci/aws_cleanup.py rename to tools/ci/aws_cleanup.py diff --git a/ci/generate_credentials.sh b/tools/ci/generate_credentials.sh similarity index 98% rename from ci/generate_credentials.sh rename to tools/ci/generate_credentials.sh index 597650ef..22e831ab 100755 --- a/ci/generate_credentials.sh +++ b/tools/ci/generate_credentials.sh @@ -6,7 +6,7 @@ NAME="$(basename "$0")" HERE="$(dirname "$0")" -ROOT="$(realpath $HERE/..)" +ROOT="$(realpath $HERE/../..)" FORCE=0 OUTPUT_PATH="$ROOT/credentials" diff --git a/ci/gitlint/.gitlint b/tools/ci/gitlint/.gitlint similarity index 100% rename from ci/gitlint/.gitlint rename to tools/ci/gitlint/.gitlint diff --git a/ci/gitlint/gitlint-user-rules.py b/tools/ci/gitlint/gitlint-user-rules.py similarity index 100% rename from ci/gitlint/gitlint-user-rules.py rename to tools/ci/gitlint/gitlint-user-rules.py diff --git a/ci/hooks/banned_api.py b/tools/ci/hooks/banned_api.py similarity index 100% rename from ci/hooks/banned_api.py rename to tools/ci/hooks/banned_api.py diff --git a/ci/hooks/banned_api_list.txt b/tools/ci/hooks/banned_api_list.txt similarity index 100% rename from ci/hooks/banned_api_list.txt rename to tools/ci/hooks/banned_api_list.txt diff --git a/ci/license/license.schema b/tools/ci/license/license.schema similarity index 100% rename from ci/license/license.schema rename to tools/ci/license/license.schema diff --git a/ci/pipeline-baseline-fri.yml b/tools/ci/pipeline-baseline-fri.yml similarity index 91% rename from ci/pipeline-baseline-fri.yml rename to tools/ci/pipeline-baseline-fri.yml index dc42b672..bbc17d16 100644 --- a/ci/pipeline-baseline-fri.yml +++ b/tools/ci/pipeline-baseline-fri.yml @@ -31,7 +31,7 @@ license: script: - scancode -l --json-pp scancode_report.json $PWD/.. - - jsonschema -i scancode_report.json $PWD/ci/license/license.schema + - jsonschema -i scancode_report.json $PWD/tools/ci/license/license.schema artifacts: paths: - scancode_report.json @@ -67,9 +67,9 @@ gitlint: - git fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME - > gitlint --commits "origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME..$CI_COMMIT_SHA" - --extra-path ${PWD}/ci/gitlint/gitlint-user-rules.py + --extra-path ${PWD}/tools/ci/gitlint/gitlint-user-rules.py -c body-invalid-words.invalid-words=${PROTECTED_WORDS_LIST} - --config ${PWD}/ci/gitlint/.gitlint + --config ${PWD}/tools/ci/gitlint/.gitlint ######################## # TownCrier Jobs # @@ -101,7 +101,7 @@ tpip-check: - env - set -x - > - python ${PWD}/ci/tpip-checker/tpip_checker.py + python ${PWD}/tools/ci/tpip-checker/tpip_checker.py --server-url "${CI_SERVER_URL}" --private-token "${AUTOBOT_GITLAB_TOKEN}" --project-id "${CI_PROJECT_ID}" diff --git a/ci/towncrier/template.rst b/tools/ci/towncrier/template.rst similarity index 100% rename from ci/towncrier/template.rst rename to tools/ci/towncrier/template.rst diff --git a/ci/tpip-checker/tpip_checker.md b/tools/ci/tpip-checker/tpip_checker.md similarity index 100% rename from ci/tpip-checker/tpip_checker.md rename to tools/ci/tpip-checker/tpip_checker.md diff --git a/ci/tpip-checker/tpip_checker.py b/tools/ci/tpip-checker/tpip_checker.py similarity index 100% rename from ci/tpip-checker/tpip_checker.py rename to tools/ci/tpip-checker/tpip_checker.py From 18764e9d8b13f4efb9a30faf221839936f10b020 Mon Sep 17 00:00:00 2001 From: Hugues Kamba-Mpiana Date: Mon, 6 Nov 2023 10:19:02 +0000 Subject: [PATCH 20/22] tests: Move conftest.py to `tools/tests/` Signed-off-by: Hugues Kamba-Mpiana --- conftest.py => tools/tests/conftest.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) rename conftest.py => tools/tests/conftest.py (84%) diff --git a/conftest.py b/tools/tests/conftest.py similarity index 84% rename from conftest.py rename to tools/tests/conftest.py index 6213e8a0..402346a6 100644 --- a/conftest.py +++ b/tools/tests/conftest.py @@ -8,6 +8,13 @@ from functools import reduce +def get_absolute_path(filename) -> str: + """ + Get the absolute path of the file + """ + return Path(__file__).parent.parent.parent / filename + + def pytest_addoption(parser): parser.addoption("--build-artefacts-path", action="store", default="") parser.addoption("--credentials-path", action="store", default="credentials") @@ -22,12 +29,12 @@ def pytest_addoption(parser): @pytest.fixture() def build_artefacts_path(pytestconfig): - yield Path(__file__).parent / pytestconfig.getoption("--build-artefacts-path") + yield get_absolute_path(pytestconfig.getoption("--build-artefacts-path")) @pytest.fixture def credentials_path(pytestconfig): - yield Path(__file__).parent / pytestconfig.getoption("--credentials-path") + yield get_absolute_path(pytestconfig.getoption("--credentials-path")) @pytest.fixture @@ -35,11 +42,6 @@ def fvp_path(pytestconfig): yield pytestconfig.getoption("--fvp") -@pytest.fixture -def vsi_script_path(): - yield Path(__file__) / "lib/AVH/audio" - - @pytest.fixture def fvp_options(pytestconfig): raw_options = pytestconfig.getoption("--fvp-options") @@ -60,7 +62,7 @@ def options_builder(options, opt): @pytest.fixture def merged_elf_name(pytestconfig): yield ( - Path(__file__).parent + Path(__file__).parent.parent.parent / pytestconfig.getoption("--build-artefacts-path") / pytestconfig.getoption("--merged-elf-name") ) @@ -78,17 +80,16 @@ def timeout_seconds(pytestconfig): @pytest.fixture def pass_output_file(pytestconfig): - print(Path(__file__).parent / pytestconfig.getoption("--pass-output-file")) - yield Path(__file__).parent / pytestconfig.getoption("--pass-output-file") + yield get_absolute_path(pytestconfig.getoption("--pass-output-file")) @pytest.fixture def fail_output_file(pytestconfig): - yield Path(__file__).parent / pytestconfig.getoption("--fail-output-file") + yield get_absolute_path(pytestconfig.getoption("--fail-output-file")) @pytest.fixture(scope="function") -def fvp_process(fvp_path, merged_elf_name, vsi_script_path, fvp_options): +def fvp_process(fvp_path, merged_elf_name, fvp_options): # Fixture of the FVP, when it returns, the FVP is started and # traces are accessible through the .stdout of the object returned. # When the test is terminated, the FVP subprocess is closed. From 4856cbf054215703e943edeef9156faf056dbf62 Mon Sep 17 00:00:00 2001 From: Hugues Kamba-Mpiana Date: Mon, 11 Dec 2023 13:04:23 +0000 Subject: [PATCH 21/22] docs: Add project organisation document The document describes the various subdirectories and conventions used througout this project. Signed-off-by: Hugues Kamba-Mpiana --- CONTRIBUTING.md | 4 +- docs/project_organisation.md | 267 ++++++++++++++++++++++++++++ release_changes/202312111335.change | 1 + 3 files changed, 271 insertions(+), 1 deletion(-) create mode 100644 docs/project_organisation.md create mode 100644 release_changes/202312111335.change diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c4b6a1c5..11b9f641 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,4 +1,4 @@ -# Contributing Guidelines +# Contributing to IoT Reference Integration for Arm Corstone-3xx Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional documentation, we greatly value feedback and contributions from our community. @@ -6,6 +6,8 @@ documentation, we greatly value feedback and contributions from our community. Please read through this document before submitting any issues or pull requests to ensure we have all the necessary information to effectively respond to your bug report or contribution. +For conventions and organisation of the project please read through [this](./docs/project_organisation.md). + ## Reporting Bugs/Feature Requests diff --git a/docs/project_organisation.md b/docs/project_organisation.md new file mode 100644 index 00000000..c9bdaa42 --- /dev/null +++ b/docs/project_organisation.md @@ -0,0 +1,267 @@ +# Project Organisation + +## Naming conventions +* Files and subdirectories are consistently named using `snake_case` (except for those files expected to have different cases such as `README.md`, `CONTRIBUTING.md`, `CMakeLists.txt`, etc), with underscores replacing spaces. +When names contain underscores, such as 'Trusted Firmware-M', the resultant subdirectory retains them, like `trusted_firmware-m`. +* CMake targets created by this project follow a consistent naming convention using `kebab-case`. +* CMake modules follow the typical naming convention of `VerbWithCamelCase`. + +## Root directory and files organisation + +```sh +├── applications/ +├── bsp/ +├── components/ +├── docs/ +├── release_changes/ +├── tools/ +├── CHANGELOG.md +├── CMakeLists.txt +├── CODE_OF_CONDUCT.md +├── CONTRIBUTING.md +├── cspell.config.yaml +├── DCO.txt +├── LICENSE +├── manifest.yml +├── NOTICE.txt +├── pyproject.toml +├── README.md +└── setup.cfg +``` +*Figure 1: Root directory and files organisation* + +* `applications`: Contains all application specific files including helper libraries and components configuration files. +* `bsp`:  Contains the integrations for the component that provide hardware platform supports. It is designed to be interchangeable and easily modifiable by silicon partners if they choose to utilize ARM FRI as a foundation for rapidly creating their own solution. +* `components`: Contains external libraries fetched with Git Submodules along with other libraries that are developed as part of FRI. +* `docs`: Design documents, guides and other documentation specific applications. +* `release_changes`: Automatically generated directory housing changelogs for each merged pull request. +* `tools`: Comprises all the tools developed by this project for accomplishing various tasks. +* `CHANGELOG.md`: An automatically generated changelog created using external tools and scripts within `tools` subdirectory. +* `CMakeLists.txt`: Determines the minimum CMake version, the project name (which matches the repository name), augments the CMake module paths to include CMake modules in the tools  subdirectory, and adds the bsp  and components subdirectories to the iot-reference-arm-corstone3xx CMake project. +* `CODE_OF_CONDUCT.md`: Code of conduct for the project. +* `CONTRIBUTING.md`: Guidelines for contributing. +* `cspell.config.yaml`: Code spell checker configuration file. +* `DCO.txt`: Developer Certificate of Origin +* `LICENSE`: Type of open-source license for the iot-reference-arm-corstone3xx project is under. +* `manifest.yml`: Record of all external project dependencies fetched by this project.  +* `NOTICE.txt`: Project notice. +* `pyproject.toml`: Configuration files for the build requirement of Python projects used with the iot-reference-arm-corstone3xx project. +* `README.md`: Project README including an additional section for subdirectories content. +* `setup.cfg`: Configuration file for packaging Python scripts created by the iot-reference-arm-corstone3xx project. + +### Components subdirectory organisation + +The components subdirectory contains external libraries along with other libraries that are developed as part of FRI. + + +```sh +components/ +├── aws_iot/ +│ ├── corejson/ +│ ├── coremqtt/ +│ ├── coremqtt_agent/ +│ ├── corepkcs11/ +│ ├── ota_for_aws_iot_embedded_sdk/ +│ └── tinycbor/ +├── connectivity/ +│ ├── backoff_algorithm/ +│ ├── freertos_plus_tcp/ +│ ├── iot_socket/ +│ └── iot_vsocket/ +├── freertos_kernel/ +├── security/ +│ ├── freertos_ota_pal_psa/ +│ ├── freertos_pkcs11_psa/ +│ ├── mbedtls/ +│ └── trusted_firmware-m/ +└── tools/ + ├── freertos_libraries_integration_tests/ + ├── open_iot_sdk_toolchain/ + └── unity/ +``` +*Figure 2: Libraries grouping per category within the components subdirectory.* + +* `aws`: Includes the integrations for components used to make a connection to AWS IoT Core. +* `connectivity`: Includes the integrations for components used to establish networking. +* `freertos_kernel`: Includes the FreeRTOS kernel. +* `security`: Includes integrations that enhance security. +* `tools`: Includes integrations for components providing tools used by applications. + +Each component comprise two parts: + +* `library` - the external library source code. +* `integration` - additional integration code for the library to build applications. + +If the component requires additional work before its code can be either consumed using CMake or requires addition source code for integration then an integration subdirectory is added. + +The integration subdirectory contains distinct directories: + +* `src`  - contains integration source code files +* `inc`  - contains integration header files +* `patches`  - contains patch files to be applied to the library + +```sh +components/aws_iot/coremqtt_agent/ +├── CMakeLists.txt +├── integration/ +│ ├── CMakeLists.txt +│ ├── inc/ +│ │ ├── freertos_agent_message.h +│ │ ├── freertos_command_pool.h +│ │ ├── mqtt_agent_task.h +│ │ └── subscription_manager.h +│   ├── patches/ +│ │   └── 0001-This-patch-is-to-be-applied-to-the-library.patch +│ └── src/ +│ ├── freertos_agent_message.c +│ ├── freertos_command_pool.c +│ ├── mqtt_agent_task.c +│ └── subscription_manager.c +└── library/ +``` +*Figure 3: Example of component organisation* + + +## CMake targets creation + +A modular approach is used to create the components. + +There is a subdirectory for each component and each contains a CMakeLists.txt that creates a CMake CACHE INTERNAL variable pointing to the path to the library code and adds the integration library (if additional integration is needed for the component). + +💡 This file is also where patches to the library are to be applied from. + +```cmake +set(coremqtt_agent_SOURCE_DIR + ${CMAKE_CURRENT_LIST_DIR}/library + CACHE INTERNAL + "Path to coreMQTT-Agent source code" +) + +execute_process(COMMAND git am --abort + COMMAND git am ${CMAKE_CURRENT_SOURCE_DIR}/integration/patches/0001-This-patch-is-to-be-applied-to-the-library.patch + WORKING_DIRECTORY ${coremqtt_agent_SOURCE_DIR} + OUTPUT_QUIET + ERROR_QUIET +) + +add_subdirectory(integration) +``` +*Figure 4: Component main CMakeLists.txt example* + + +Two CMake targets are created for each component integration: + +* library target (if one is not already provided). +* library configuration target for applications to customize the target for +  their use cases. +```cmake +include(${coremqtt_agent_SOURCE_DIR}/mqttAgentFilePaths.cmake) + +add_library(coremqtt-agent + ${MQTT_AGENT_SOURCES} + src/mqtt_agent_task.c + src/subscription_manager.c + src/freertos_command_pool.c + src/freertos_agent_message.c +) + +target_include_directories(coremqtt-agent + PUBLIC + ${MQTT_AGENT_INCLUDE_PUBLIC_DIRS} + inc +) + +add_library(coremqtt-agent-config INTERFACE) + +target_link_libraries(coremqtt-agent + PUBLIC + coremqtt-agent-config + PRIVATE + backoff-algorithm + connectivity-stack + coremqtt + freertos_kernel + helpers-events + helpers-logging +) +``` +*Figure 5: Component integration CMakeLists.txt example* + +## Applications subdirectory organisation + +Applications are located within their respective subdirectories within the top level applications subdirectory. + +Anything specific to an application should live in its respective subdirectory (component configuration files, cloud credential files, etc). + +Each applications has its own configs subdirectory as it is expected that the configurations will differ from an application to another. + +```sh +applications/aws_iot_example/ +├── CMakeLists.txt +├── configs +│ ├── app_config +│ │ ├── app_config.h +│ │ └── CMakeLists.txt +│ ├── aws_configs +│ │ ├── aws_clientcredential.h +│ │ ├── ... +│ │ └── ota_demo_config.h +│ ├── CMakeLists.txt +│ ├── freertos_config +│ │ ├── CMakeLists.txt +│ │ ├── FreeRTOSConfig.h +│ │ └── FreeRTOSIPConfig.h +│ ├── mbedtls_config +│ │ ├── aws_mbedtls_config.h +│ │ ├── CMakeLists.txt +│ │ └── threading_alt.h +│ └── tfm_config +│ └── project_config.h +├── freertos_integration_tests +│ ├── dev_mode_key_provisioning.h +│ ├── integration_tests_platform_function.c +│ ├── test_execution_config.h +│ ├── test_param_config.h +│ └── unistd.h +├── main.c +└── tests + ├── fail_ota_output.log + └── pass_ota_output.log +``` +*Figure 6: Content of aws-iot-example application* + +Each application executable link only with the component target library it needs: +```cmake +target_link_libraries(aws-iot-example + PRIVATE + backoff-algorithm + connectivity-stack + coremqtt + coremqtt-agent + corepkcs11 + freertos_kernel + freertos-ota-pal-psa + fri-bsp + helpers-events + mbedtls + mbedtls-threading-freertos + ota-for-aws-iot-embedded-sdk + tfm-ns-interface +) +``` +*Figure 7: aws-iot-example application linked library alphabetically ordered* + + +### Application helper libraries + +It is expected that applications share some common code, these are organised as libraries and made available in a helpers subdirectory within the root applications subdirectory so they can be used by any application. + +```sh +applications/helpers/ +├── CMakeLists.txt +├── events/ +├── logging/ +├── mqtt/ +└── provisioning/ +``` +*Figure 8: Application helper libraries organisation* diff --git a/release_changes/202312111335.change b/release_changes/202312111335.change new file mode 100644 index 00000000..ca9dd593 --- /dev/null +++ b/release_changes/202312111335.change @@ -0,0 +1 @@ +docs: Add project organisation document From ec6bdd7195be1678d221b2efc1480a5dbdf4af68 Mon Sep 17 00:00:00 2001 From: Hugues Kamba-Mpiana Date: Mon, 11 Dec 2023 17:04:14 +0000 Subject: [PATCH 22/22] ci: Add known words to spellchecker The added words are valid and therefore added to the spellchecker dictionary. Signed-off-by: Hugues Kamba-Mpiana --- .github/.cSpellWords.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/.cSpellWords.txt b/.github/.cSpellWords.txt index e66de761..4654fc91 100644 --- a/.github/.cSpellWords.txt +++ b/.github/.cSpellWords.txt @@ -17,9 +17,11 @@ CMAC cmsis CMSIS CMSIS's +coremqtt COSE CSRS Customisation +DCMAKE DCONFIG demultiplexing dgst @@ -58,7 +60,9 @@ mcuboot MCUBOOT mbed Mbed +mbedcrypto MBEDTLSSL +mbedx509 Merkle MFLN mqtt