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 diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 3590f039..1101e005 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -49,20 +49,20 @@ 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 + ./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 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: | 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 2ddbeb61..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 @@ -72,20 +72,21 @@ build-applications: stage: build extends: .base_job script: - - ./ci/generate_credentials.sh -f -p Config/aws_configs + - export APP_UNDERSCORED=$(echo ${APP} | tr '-' '_') + - ./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 + - ./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 \ - build/Projects/${APP}/${APP}_merged.elf \ - build/Projects/${APP}/${APP}-update_signed.bin \ - build/Projects/${APP}/update-signature.txt \ - Config/aws_configs + build/${APP}_merged.elf \ + build/${APP}-update_signed.bin \ + build/update-signature.txt \ + applications/${APP_UNDERSCORED}/configs/aws_configs else tar -czf ${TARGET}_${APP}_${TOOLCHAIN}_build.tar.gz \ - build/Projects/${APP}/${APP}_merged.elf + build/${APP}_merged.elf fi parallel: matrix: @@ -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/Projects/${APP}" \ + 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 "Projects/${APP}/tests/pass_output.log" \ - --fail-output-file "Projects/${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/Projects/${APP}" \ + pytest -s tools/tests/test_ota.py \ + --build-artefacts-path "build" \ --fvp $FVP_BIN \ - --credentials-path "Config/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 "Projects/${APP}/tests/pass_output.log" \ - --fail-output-file "Projects/${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,19 +145,20 @@ integration-tests: rules: - if: ( $SCHEDULED_JOB_TO_RUN == "integration-tests" ) script: - - ./ci/generate_credentials.sh -f -p Config/aws_configs + - export APP_UNDERSCORED=$(echo ${APP} | tr '-' '_') + - ./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} - - pushd Middleware/FreeRTOS/FreeRTOS-Libraries-Integration-Tests/tools/echo_server + - ./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 \ - --build-artefacts-path "build/Projects/${APP}" \ + pytest -s tools/tests/test_integration.py \ + --build-artefacts-path "build" \ --fvp $FVP_BIN \ - --credentials-path "Config/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: @@ -172,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/.gitmodules b/.gitmodules index 2dfe7c5d..40018147 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..14d4fed8 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/| + applications/helpers/logging/| + components/freertos_kernel/| + components/connectivity/freertos_plus_tcp/| + components/tools/freertos_libraries_integration_tests/| + components/tools/unity/ ) repos: @@ -33,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: @@ -76,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: @@ -92,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/Bsp/CMakeLists.txt b/Bsp/CMakeLists.txt deleted file mode 100644 index fe536599..00000000 --- a/Bsp/CMakeLists.txt +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2023 Arm Limited and/or its affiliates -# -# SPDX-License-Identifier: Apache-2.0 - -add_subdirectory(arm-corstone-platform-bsp) - -# 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) -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) -endif() - -# BSP serial library - -add_library(fri-bsp STATIC) - -target_sources(fri-bsp - PRIVATE - common/bsp_serial.c -) - -target_include_directories(fri-bsp - PUBLIC - $<$:${CMAKE_CURRENT_LIST_DIR}/corstone300/include> - $<$:${CMAKE_CURRENT_LIST_DIR}/corstone310/include> - common -) - -target_link_libraries(fri-bsp - PUBLIC - arm-corstone-platform-bsp -) diff --git a/CMakeLists.txt b/CMakeLists.txt index 62ffc006..0069b70c 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/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/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/aws-iot-example/CMakeLists.txt b/Projects/aws-iot-example/CMakeLists.txt deleted file mode 100644 index 89bd4760..00000000 --- a/Projects/aws-iot-example/CMakeLists.txt +++ /dev/null @@ -1,278 +0,0 @@ -# Copyright 2023 Arm Limited and/or its affiliates -# -# SPDX-License-Identifier: MIT - -cmake_minimum_required(VERSION 3.21) - -# 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") - -# 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 -# { -# uint8_t major; /*!< @brief Major version number of the firmware (X in firmware version X.Y.Z). */ -# uint8_t minor; /*!< @brief Minor version number of the firmware (Y in firmware version X.Y.Z). */ -# -# 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. -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 - -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_FIRMWARE_UPDATE=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} - -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} -) - -# Configuration of executable -set(EXE_SUFFIX ".axf") -set(CMAKE_EXECUTABLE_SUFFIX ${EXE_SUFFIX}) - -# 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() - if(${CMAKE_C_COMPILER_ID} STREQUAL "GNU") - add_compile_options(-Og) - else() - 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_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 -) - -add_subdirectory(event-helper) -add_subdirectory(mqtt-agent-wrapper) -add_subdirectory(provisioning provisioning_data) - -# Declare the aws-iot-example executable -add_executable(aws-iot-example - main.c - mqtt_demo_pub_sub.c - dev_mode_key_provisioning.c - ${MIDDLEWARE_DIR}/AWS/corePKCS11/source/dependency/3rdparty/mbedtls_utils/mbedtls_utils.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(aws-iot-example tf-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 - - freertos-ota-pal-psa - - mbedtls - mbedtls-threading-freertos - - freertos_kernel - 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) - -# 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) - -# 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_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/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/provisioning/generate_credentials_header.py b/Projects/aws-iot-example/provisioning/generate_credentials_header.py deleted file mode 100644 index 43bec23e..00000000 --- a/Projects/aws-iot-example/provisioning/generate_credentials_header.py +++ /dev/null @@ -1,66 +0,0 @@ -#! /usr/bin/env python3 -# -# Copyright 2023 Arm Limited and/or its affiliates -# -# SPDX-License-Identifier: MIT - -import argparse - -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: - out_file.write( - CREDENTIALS_TEMPLATE.format( - client_certificate_pem=client_certificate_pem, - client_private_key_pem=client_private_key_pem, - code_signing_public_key_pem=code_signing_public_key_pem, - jitr_dev_cert_auth_pem='''""''', - ) - ) - - -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 - - -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, - ) - main(parser.parse_args()) diff --git a/README.md b/README.md index 143f8d64..bb326b36 100644 --- a/README.md +++ b/README.md @@ -22,13 +22,28 @@ 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: -* [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) @@ -120,7 +135,7 @@ See [CONTRIBUTING](CONTRIBUTING.md) for more information. ## License -Source code located in the *Projects*, *Middleware/FreeRTOS* 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/applications/aws_iot_example/CMakeLists.txt b/applications/aws_iot_example/CMakeLists.txt new file mode 100644 index 00000000..6856556c --- /dev/null +++ b/applications/aws_iot_example/CMakeLists.txt @@ -0,0 +1,280 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +cmake_minimum_required(VERSION 3.21.0 FATAL_ERROR) + +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Release" CACHE STRING "The build type" FORCE) +endif() + +if (${ARM_CORSTONE_BSP_TARGET_PLATFORM} STREQUAL "corstone300") + set(TFM_PLATFORM_LOCAL_PATH "arm/mps3/corstone300/fvp") +elseif(${ARM_CORSTONE_BSP_TARGET_PLATFORM} STREQUAL "corstone310") + set(TFM_PLATFORM_LOCAL_PATH "arm/mps3/corstone310/fvp") +else() + message(FATAL_ERROR "Invalid ARM_CORSTONE_BSP_TARGET_PLATFORM (${ARM_CORSTONE_BSP_TARGET_PLATFORM}) set. Supported are corstone300/corstone310") +endif() + +# From: ota-for-aws-iot-embedded-sdk/source/include/ota_appversion32.h +# struct version +# { +# uint8_t major; /*!< @brief Major version number of the firmware (X in firmware version X.Y.Z). */ +# uint8_t minor; /*!< @brief Minor version number of the firmware (Y in firmware version X.Y.Z). */ +# +# 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 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") + +set(TFM_CMAKE_ARGS + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCONFIG_TFM_ENABLE_CP10CP11=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 + -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 + -DTFM_DUMMY_PROVISIONING=OFF + -DTFM_EXCEPTION_INFO_DUMP=ON + -DTFM_PARTITION_CRYPTO=ON + -DTFM_PARTITION_FIRMWARE_UPDATE=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 +) + +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +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) + elseif(CMAKE_C_COMPILER_ID STREQUAL "ARMClang") + add_compile_options(-O1) + endif() +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}/components/aws_iot/cmake) +list(APPEND CMAKE_MODULE_PATH ${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/components/security/trusted_firmware-m/integration/cmake) +include(SetLinkerOptions) +include(GenerateAWSUpdateDigestAndSignature) +include(MergeTfmImages) +include(SignTfmImage) + +add_subdirectory(configs) +add_subdirectory(../helpers ${CMAKE_BINARY_DIR}/helpers) + +# Add main application executable +add_executable(aws-iot-example + 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 + PUBLIC + freertos_integration_tests + ../helpers/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 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_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 +) + +set_linker_script(aws-iot-example) + +# 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 +) + +# 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 +) + +# 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}/helpers/provisioning/provisioning_data.bin +) + +# 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 +) + +# --------------------------------------------------------------------------------------------------------- +# 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 + 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 + 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 +) + +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}/helpers/provisioning/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/Config/CMakeLists.txt b/applications/aws_iot_example/configs/CMakeLists.txt similarity index 85% rename from Config/CMakeLists.txt rename to applications/aws_iot_example/configs/CMakeLists.txt index ff644a65..069f0910 100644 --- a/Config/CMakeLists.txt +++ b/applications/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/applications/aws_iot_example/configs/app_config/CMakeLists.txt similarity index 100% rename from Config/app_config/CMakeLists.txt rename to applications/aws_iot_example/configs/app_config/CMakeLists.txt diff --git a/Config/app_config/app_config.h b/applications/aws_iot_example/configs/app_config/app_config.h similarity index 100% rename from Config/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 new file mode 100644 index 00000000..c89696ee --- /dev/null +++ b/applications/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/applications/aws_iot_example/configs/aws_configs/aws_clientcredential.h similarity index 100% rename from Config/aws_configs/aws_clientcredential.h rename to applications/aws_iot_example/configs/aws_configs/aws_clientcredential.h diff --git a/Config/aws_configs/aws_mqtt_config.h b/applications/aws_iot_example/configs/aws_configs/aws_mqtt_config.h similarity index 100% rename from Config/aws_configs/aws_mqtt_config.h rename to applications/aws_iot_example/configs/aws_configs/aws_mqtt_config.h diff --git a/Config/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 Config/aws_configs/aws_secure_sockets_config.h rename to applications/aws_iot_example/configs/aws_configs/aws_secure_sockets_config.h diff --git a/Config/aws_configs/core_mqtt_config.h b/applications/aws_iot_example/configs/aws_configs/core_mqtt_config.h similarity index 100% rename from Config/aws_configs/core_mqtt_config.h rename to applications/aws_iot_example/configs/aws_configs/core_mqtt_config.h diff --git a/Config/aws_configs/core_pkcs11_config.h b/applications/aws_iot_example/configs/aws_configs/core_pkcs11_config.h similarity index 100% rename from Config/aws_configs/core_pkcs11_config.h rename to applications/aws_iot_example/configs/aws_configs/core_pkcs11_config.h diff --git a/Config/aws_configs/demo_config.h b/applications/aws_iot_example/configs/aws_configs/demo_config.h similarity index 100% rename from Config/aws_configs/demo_config.h rename to applications/aws_iot_example/configs/aws_configs/demo_config.h diff --git a/Config/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 Config/aws_configs/iot_default_root_certificates.h rename to applications/aws_iot_example/configs/aws_configs/iot_default_root_certificates.h diff --git a/Config/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 Config/aws_configs/mqtt_agent_demo_config.h rename to applications/aws_iot_example/configs/aws_configs/mqtt_agent_demo_config.h diff --git a/Config/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 Config/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/Config/aws_configs/ota_config.h b/applications/aws_iot_example/configs/aws_configs/ota_config.h similarity index 100% rename from Config/aws_configs/ota_config.h rename to applications/aws_iot_example/configs/aws_configs/ota_config.h diff --git a/Config/aws_configs/ota_demo_config.h b/applications/aws_iot_example/configs/aws_configs/ota_demo_config.h similarity index 100% rename from Config/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 new file mode 100644 index 00000000..088f7199 --- /dev/null +++ b/applications/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/applications/aws_iot_example/configs/freertos_config/FreeRTOSConfig.h similarity index 100% rename from Config/freertos-config/FreeRTOSConfig.h rename to applications/aws_iot_example/configs/freertos_config/FreeRTOSConfig.h diff --git a/Config/freertos-config/FreeRTOSIPConfig.h b/applications/aws_iot_example/configs/freertos_config/FreeRTOSIPConfig.h similarity index 100% rename from Config/freertos-config/FreeRTOSIPConfig.h rename to applications/aws_iot_example/configs/freertos_config/FreeRTOSIPConfig.h diff --git a/Config/mbedtls_config/CMakeLists.txt b/applications/aws_iot_example/configs/mbedtls_config/CMakeLists.txt similarity index 100% rename from Config/mbedtls_config/CMakeLists.txt rename to applications/aws_iot_example/configs/mbedtls_config/CMakeLists.txt diff --git a/Config/mbedtls_config/aws_mbedtls_config.h b/applications/aws_iot_example/configs/mbedtls_config/aws_mbedtls_config.h similarity index 100% rename from Config/mbedtls_config/aws_mbedtls_config.h rename to applications/aws_iot_example/configs/mbedtls_config/aws_mbedtls_config.h diff --git a/Config/mbedtls_config/threading_alt.h b/applications/aws_iot_example/configs/mbedtls_config/threading_alt.h similarity index 100% rename from Config/mbedtls_config/threading_alt.h rename to applications/aws_iot_example/configs/mbedtls_config/threading_alt.h diff --git a/Config/tfm-config/project_config.h b/applications/aws_iot_example/configs/tfm_config/project_config.h similarity index 100% rename from Config/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/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 Projects/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/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/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 Projects/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/Projects/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 Projects/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/Projects/aws-iot-example/freertos-integration-tests/include/unistd.h b/applications/aws_iot_example/freertos_integration_tests/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/unistd.h diff --git a/Projects/aws-iot-example/main.c b/applications/aws_iot_example/main.c similarity index 99% rename from Projects/aws-iot-example/main.c rename to applications/aws_iot_example/main.c index 02f762f5..803a14a9 100644 --- a/Projects/aws-iot-example/main.c +++ b/applications/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_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/fail_output.log b/applications/aws_iot_example/tests/fail_output.log similarity index 100% rename from Projects/aws-iot-example/tests/fail_output.log rename to applications/aws_iot_example/tests/fail_output.log diff --git a/Projects/aws-iot-example/tests/pass_output.log b/applications/aws_iot_example/tests/pass_output.log similarity index 100% rename from Projects/aws-iot-example/tests/pass_output.log rename to applications/aws_iot_example/tests/pass_output.log diff --git a/Projects/blinky/CMakeLists.txt b/applications/blinky/CMakeLists.txt similarity index 57% rename from Projects/blinky/CMakeLists.txt rename to applications/blinky/CMakeLists.txt index bcf18384..4c749df2 100644 --- a/Projects/blinky/CMakeLists.txt +++ b/applications/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}/applications/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(SetLinkerOptions) +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} +) diff --git a/applications/blinky/configs/CMakeLists.txt b/applications/blinky/configs/CMakeLists.txt new file mode 100644 index 00000000..da3043a1 --- /dev/null +++ b/applications/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/applications/blinky/configs/app_config/CMakeLists.txt similarity index 65% rename from Config/aws_configs/CMakeLists.txt rename to applications/blinky/configs/app_config/CMakeLists.txt index c88cab87..8127eb9f 100644 --- a/Config/aws_configs/CMakeLists.txt +++ b/applications/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/applications/blinky/configs/app_config/app_config.h b/applications/blinky/configs/app_config/app_config.h new file mode 100644 index 00000000..d57061b9 --- /dev/null +++ b/applications/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/applications/blinky/configs/freertos_config/CMakeLists.txt b/applications/blinky/configs/freertos_config/CMakeLists.txt new file mode 100644 index 00000000..088f7199 --- /dev/null +++ b/applications/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/applications/blinky/configs/freertos_config/FreeRTOSConfig.h b/applications/blinky/configs/freertos_config/FreeRTOSConfig.h new file mode 100644 index 00000000..9ba2f722 --- /dev/null +++ b/applications/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/applications/blinky/configs/tfm_config/project_config.h b/applications/blinky/configs/tfm_config/project_config.h new file mode 100644 index 00000000..fcb4598e --- /dev/null +++ b/applications/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 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/applications/helpers/CMakeLists.txt b/applications/helpers/CMakeLists.txt new file mode 100644 index 00000000..0f29ef20 --- /dev/null +++ b/applications/helpers/CMakeLists.txt @@ -0,0 +1,7 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +add_subdirectory(events) +add_subdirectory(logging) +add_subdirectory(provisioning) diff --git a/applications/helpers/events/CMakeLists.txt b/applications/helpers/events/CMakeLists.txt new file mode 100644 index 00000000..e2bcc490 --- /dev/null +++ b/applications/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/applications/helpers/events/inc/events.h similarity index 93% rename from Projects/aws-iot-example/event-helper/event_helper.h rename to applications/helpers/events/inc/events.h index e4ed2965..6d665641 100644 --- a/Projects/aws-iot-example/event-helper/event_helper.h +++ b/applications/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/applications/helpers/events/src/events.c similarity index 95% rename from Projects/aws-iot-example/event-helper/event_helper.c rename to applications/helpers/events/src/events.c index 4286b825..07a1a4a9 100644 --- a/Projects/aws-iot-example/event-helper/event_helper.c +++ b/applications/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/applications/helpers/logging/CMakeLists.txt b/applications/helpers/logging/CMakeLists.txt new file mode 100644 index 00000000..a55668b5 --- /dev/null +++ b/applications/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/applications/helpers/logging/inc/iot_logging_task.h similarity index 100% rename from Middleware/AWS/logging/include/iot_logging_task.h rename to applications/helpers/logging/inc/iot_logging_task.h diff --git a/Middleware/AWS/logging/include/logging_levels.h b/applications/helpers/logging/inc/logging_levels.h similarity index 100% rename from Middleware/AWS/logging/include/logging_levels.h rename to applications/helpers/logging/inc/logging_levels.h diff --git a/Middleware/AWS/logging/include/logging_stack.h b/applications/helpers/logging/inc/logging_stack.h similarity index 100% rename from Middleware/AWS/logging/include/logging_stack.h rename to applications/helpers/logging/inc/logging_stack.h diff --git a/Middleware/AWS/logging/iot_logging_task_dynamic_buffers.c b/applications/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 applications/helpers/logging/src/iot_logging_task_dynamic_buffers.c diff --git a/Projects/aws-iot-example/provisioning/CMakeLists.txt b/applications/helpers/provisioning/CMakeLists.txt similarity index 52% rename from Projects/aws-iot-example/provisioning/CMakeLists.txt rename to applications/helpers/provisioning/CMakeLists.txt index b9ea1269..674aebbc 100644 --- a/Projects/aws-iot-example/provisioning/CMakeLists.txt +++ b/applications/helpers/provisioning/CMakeLists.txt @@ -10,28 +10,33 @@ 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(SetProvisioningLinkOptions) + +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 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} ${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} + --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 +44,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") @@ -48,12 +53,12 @@ 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 ${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/aws-iot-example/provisioning/linkerscript_preprocess.cmake b/applications/helpers/provisioning/cmake/SetProvisioningLinkOptions.cmake similarity index 100% rename from Projects/aws-iot-example/provisioning/linkerscript_preprocess.cmake rename to applications/helpers/provisioning/cmake/SetProvisioningLinkOptions.cmake diff --git a/Projects/aws-iot-example/provisioning/provisioning_config.h b/applications/helpers/provisioning/provisioning_config.h similarity index 100% rename from Projects/aws-iot-example/provisioning/provisioning_config.h rename to applications/helpers/provisioning/provisioning_config.h diff --git a/Projects/aws-iot-example/provisioning/provisioning_data.c b/applications/helpers/provisioning/provisioning_data.c similarity index 100% rename from Projects/aws-iot-example/provisioning/provisioning_data.c rename to applications/helpers/provisioning/provisioning_data.c diff --git a/Projects/aws-iot-example/provisioning/provisioning_data.h b/applications/helpers/provisioning/provisioning_data.h similarity index 100% rename from Projects/aws-iot-example/provisioning/provisioning_data.h rename to applications/helpers/provisioning/provisioning_data.h diff --git a/Projects/aws-iot-example/provisioning/provisioning_data.ld b/applications/helpers/provisioning/provisioning_data.ld similarity index 100% rename from Projects/aws-iot-example/provisioning/provisioning_data.ld rename to applications/helpers/provisioning/provisioning_data.ld diff --git a/Projects/aws-iot-example/provisioning/provisioning_data.sct b/applications/helpers/provisioning/provisioning_data.sct similarity index 100% rename from Projects/aws-iot-example/provisioning/provisioning_data.sct rename to applications/helpers/provisioning/provisioning_data.sct diff --git a/bsp/CMakeLists.txt b/bsp/CMakeLists.txt new file mode 100644 index 00000000..d5057a9b --- /dev/null +++ b/bsp/CMakeLists.txt @@ -0,0 +1,53 @@ +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: Apache-2.0 + +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 +) + +if(ARM_CORSTONE_BSP_TARGET_PLATFORM STREQUAL "corstone300") + 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 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 + +add_library(fri-bsp STATIC) + +target_sources(fri-bsp + PRIVATE + common/bsp_serial.c +) + +target_include_directories(fri-bsp + PUBLIC + $<$:${CMAKE_CURRENT_LIST_DIR}/corstone300/include> + $<$:${CMAKE_CURRENT_LIST_DIR}/corstone310/include> + common +) + +target_link_libraries(fri-bsp + PUBLIC + arm-corstone-platform-bsp +) diff --git a/Bsp/cmake/BspUtilities.cmake b/bsp/cmake/SetLinkerOptions.cmake similarity index 66% rename from Bsp/cmake/BspUtilities.cmake rename to bsp/cmake/SetLinkerOptions.cmake index b1610b82..f88c9e41 100644 --- a/Bsp/cmake/BspUtilities.cmake +++ b/bsp/cmake/SetLinkerOptions.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/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/arm-corstone-platform-bsp b/bsp/library similarity index 100% rename from Bsp/arm-corstone-platform-bsp rename to bsp/library 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/Projects/aws-iot-example/mqtt-agent-wrapper/freertos_agent_message.h b/components/aws_iot/coremqtt_agent/integration/inc/freertos_agent_message.h similarity index 100% rename from Projects/aws-iot-example/mqtt-agent-wrapper/freertos_agent_message.h rename to components/aws_iot/coremqtt_agent/integration/inc/freertos_agent_message.h index 0051aaaf..c5eb4a79 100644 --- a/Projects/aws-iot-example/mqtt-agent-wrapper/freertos_agent_message.h +++ b/components/aws_iot/coremqtt_agent/integration/inc/freertos_agent_message.h @@ -31,9 +31,9 @@ #ifndef FREERTOS_AGENT_MESSAGE_H #define FREERTOS_AGENT_MESSAGE_H +#include #include #include -#include /* FreeRTOS includes. */ #include "FreeRTOS.h" diff --git a/Projects/aws-iot-example/mqtt-agent-wrapper/freertos_command_pool.h b/components/aws_iot/coremqtt_agent/integration/inc/freertos_command_pool.h similarity index 100% rename from Projects/aws-iot-example/mqtt-agent-wrapper/freertos_command_pool.h rename to components/aws_iot/coremqtt_agent/integration/inc/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/Projects/aws-iot-example/mqtt-agent-wrapper/subscription_manager.h b/components/aws_iot/coremqtt_agent/integration/inc/subscription_manager.h similarity index 96% rename from Projects/aws-iot-example/mqtt-agent-wrapper/subscription_manager.h rename to components/aws_iot/coremqtt_agent/integration/inc/subscription_manager.h index 9d09e16c..5fd3d661 100644 --- a/Projects/aws-iot-example/mqtt-agent-wrapper/subscription_manager.h +++ b/components/aws_iot/coremqtt_agent/integration/inc/subscription_manager.h @@ -47,8 +47,8 @@ * @param[in] pvIncomingPublishCallbackContext The incoming publish callback context. * @param[in] pxPublishInfo Deserialized publish information. */ -typedef void (* IncomingPubCallback_t )( void * pvIncomingPublishCallbackContext, - MQTTPublishInfo_t * pxPublishInfo ); +typedef void (* IncomingPubCallback_t)( void * pvIncomingPublishCallbackContext, + MQTTPublishInfo_t * pxPublishInfo ); /** * @brief An element in the list of subscriptions. diff --git a/Projects/aws-iot-example/mqtt-agent-wrapper/freertos_agent_message.c b/components/aws_iot/coremqtt_agent/integration/src/freertos_agent_message.c similarity index 100% rename from Projects/aws-iot-example/mqtt-agent-wrapper/freertos_agent_message.c rename to components/aws_iot/coremqtt_agent/integration/src/freertos_agent_message.c index 7dc7157c..ff96e6de 100644 --- a/Projects/aws-iot-example/mqtt-agent-wrapper/freertos_agent_message.c +++ b/components/aws_iot/coremqtt_agent/integration/src/freertos_agent_message.c @@ -30,16 +30,16 @@ */ /* Standard includes. */ -#include #include +#include /* Kernel includes. */ #include "FreeRTOS.h" #include "semphr.h" /* Header include. */ -#include "freertos_agent_message.h" #include "core_mqtt_agent_message_interface.h" +#include "freertos_agent_message.h" /*-----------------------------------------------------------*/ diff --git a/Projects/aws-iot-example/mqtt-agent-wrapper/freertos_command_pool.c b/components/aws_iot/coremqtt_agent/integration/src/freertos_command_pool.c similarity index 100% rename from Projects/aws-iot-example/mqtt-agent-wrapper/freertos_command_pool.c rename to components/aws_iot/coremqtt_agent/integration/src/freertos_command_pool.c 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 99% 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 index c77db1b7..e2ed89d8 100644 --- a/Projects/aws-iot-example/mqtt-agent-wrapper/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/Projects/aws-iot-example/mqtt-agent-wrapper/subscription_manager.c b/components/aws_iot/coremqtt_agent/integration/src/subscription_manager.c similarity index 100% rename from Projects/aws-iot-example/mqtt-agent-wrapper/subscription_manager.c rename to components/aws_iot/coremqtt_agent/integration/src/subscription_manager.c 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..6e099e35 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/Docs/aws-iot-example.md b/docs/aws_iot_example.md similarity index 95% rename from Docs/aws-iot-example.md rename to docs/aws_iot_example.md index f7203240..0f750192 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 @@ -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 \ @@ -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` @@ -211,25 +211,25 @@ 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 -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. ## 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. @@ -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 @@ -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)` @@ -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) @@ -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` @@ -588,19 +588,19 @@ 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 -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 @@ -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 similarity index 87% rename from Docs/blinky.md rename to docs/blinky.md index 28f20a47..aca65106 100644 --- a/Docs/blinky.md +++ b/docs/blinky.md @@ -11,32 +11,32 @@ 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 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 -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 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 similarity index 97% rename from Docs/development-environment.md rename to docs/development_environment.md index 3517eca9..5faec255 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. @@ -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: @@ -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: @@ -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/Docs/Prerequisites.md b/docs/prerequisites.md similarity index 93% rename from Docs/Prerequisites.md rename to docs/prerequisites.md index bbd5e569..382f2368 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 @@ -39,11 +39,11 @@ 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. ## 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/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/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 diff --git a/manifest.yml b/manifest.yml index 8b8dfeaf..9bb95890 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/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/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 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 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 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 76% rename from Tools/scripts/build.sh rename to tools/scripts/build.sh index 13003476..e1c99590 100755 --- a/Tools/scripts/build.sh +++ b/tools/scripts/build.sh @@ -41,10 +41,23 @@ 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 - - if [[ $BUILD -ne 0 ]]; then - cmake --build $BUILD_PATH --target $EXAMPLE + cmake \ + -G Ninja --toolchain=$TOOLCHAIN_FILE \ + -B $BUILD_PATH \ + -S $PATH_TO_SOURCE \ + -DCMAKE_SYSTEM_PROCESSOR=$TARGET_PROCESSOR \ + -DARM_CORSTONE_BSP_TARGET_PLATFORM=$TARGET \ + -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 && $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 ) } @@ -130,9 +143,11 @@ done case "$1" in blinky) EXAMPLE="$1" + PATH_TO_SOURCE="$ROOT/applications/blinky" ;; aws-iot-example) EXAMPLE="$1" + PATH_TO_SOURCE="$ROOT/applications/aws_iot_example" ;; *) echo "Missing example " @@ -157,10 +172,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/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 new file mode 100644 index 00000000..de3505e7 --- /dev/null +++ b/tools/scripts/generate_credentials_header.py @@ -0,0 +1,125 @@ +#! /usr/bin/env python3 +# +# Copyright 2023 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +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 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, + client_private_key_pem=client_private_key_pem, + code_signing_public_key_pem=code_signing_public_key_pem, + jitr_dev_cert_auth_pem='''""''', + ) + ) + + +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' + + # 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, + ) + + +if __name__ == "__main__": + main() diff --git a/Tools/scripts/run.sh b/tools/scripts/run.sh similarity index 80% rename from Tools/scripts/run.sh rename to tools/scripts/run.sh index cf04a574..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" @@ -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 @@ -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 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/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. 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