diff --git a/README.md b/README.md index ce6b8c10..149e3e3c 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,9 @@ CPU and Ethos NPU, alongside a range of other components in a scalable and flexible reference package. This enables designers to build secure, AI-capable SoCs faster. +* [Corstone-315](https://developer.arm.com/Processors/Corstone-315) + * Arm Cortex-M85 CPU, Ethos-U65 NPU and Mali-C55 ISP + * Supported versions: 11.24.13 and above * [Corstone-310](https://developer.arm.com/Processors/Corstone-310) * Arm Cortex-M85 CPU and Ethos-U55 NPU * Supported versions: 11.24.13 and above @@ -65,6 +68,8 @@ This reference integration contains following two examples: * Demonstrates detecting keywords from an audio source using Machine Learning. * [Speech Recognition](docs/speech_recognition.md) * Demonstrates detecting sentences from an audio source using Machine Learning. +* [Object Detection](docs/object_detection.md) + * Demonstrates detection of faces from image source using Machine Learning. The Keyword-Detection and Speech-Recognition applications demonstrate [secure connectivity](#secure-tls-connection) to AWS IoT core using [Mbed TLS](#mbed-tls), [PKCS#11 PSA Shim](#pkcs11-psa-shim) and @@ -152,6 +157,11 @@ This implementation maps the AWS OTA PAL APIs to the PSA Firmware Update and PSA Cryptography APIs. The writing, verification and activation of the update image are protected by the PSA secure services. +### Mali-C55 Versatile Image Signal Processor for Computer Vision and Smart Display Systems + +Implementation of [Arm® Mali™-C55 bare-metal driver](https://gitlab.arm.com/iot/m-class/drivers/isp_mali-c55), +that demonstrates the usage of the Mali-C55 ISP with the Corstone M85 processor. + ## Contributing See [CONTRIBUTING](CONTRIBUTING.md) for more information. diff --git a/applications/object_detection/CMakeLists.txt b/applications/object_detection/CMakeLists.txt new file mode 100644 index 00000000..9e64e9d9 --- /dev/null +++ b/applications/object_detection/CMakeLists.txt @@ -0,0 +1,177 @@ +# Copyright 2023-2024 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +cmake_minimum_required(VERSION 3.21.0 FATAL_ERROR) + +set(ML_INFERENCE_ENGINE "ETHOS" CACHE STRING "Machine Learning inference engine (ETHOS)") + +set(AUDIO_SOURCE "ROM" CACHE STRING "Source of audio data (ROM | VSI)") + +# 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") + +if (${ML_INFERENCE_ENGINE} STREQUAL "ETHOS") + set(ETHOS_U_NPU_ENABLED ON) + set(ETHOS_U_NPU_TIMING_ADAPTER_ENABLED OFF) +else() + set(ETHOS_U_NPU_ENABLED OFF) +endif() +set(ML_USE_CASE "object_detection") +set(ML_MODEL "GenerateObjectDetectionModel") +set(ML_USE_CASE_RESOURCES_FILE "${CMAKE_CURRENT_LIST_DIR}/resources/use_case_resources.json") +set(TFM_PLATFORM_UPGRADE_STRATEGY "SWAP_USING_SCRATCH") +set(TFM_PLATFORM_CONFIRM_IMAGE ON) + +# Trusted Firmware-M setup +set(TFM_CMAKE_APP_ARGS + -DPROJECT_CONFIG_HEADER_FILE=${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/applications/object_detection/configs/tfm_config/project_config.h + -DMCUBOOT_CONFIRM_IMAGE=${TFM_PLATFORM_CONFIRM_IMAGE} + -DMCUBOOT_UPGRADE_STRATEGY=${TFM_PLATFORM_UPGRADE_STRATEGY} + -DMCUBOOT_IMAGE_VERSION_NS=${MCUBOOT_IMAGE_VERSION_NS} + -DCONFIG_TFM_HALT_ON_CORE_PANIC=ON + -DMCUBOOT_DATA_SHARING=ON + -DPLATFORM_HAS_FIRMWARE_UPDATE_SUPPORT=ON + -DTFM_PARTITION_FIRMWARE_UPDATE=ON + -DTFM_PARTITION_LOG_LEVEL=TFM_PARTITION_LOG_LEVEL_INFO +) + +project(object-detection LANGUAGES C CXX) + +# 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() + + +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}/components/aws_iot/cmake) +list(APPEND CMAKE_MODULE_PATH ${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/components/ai/ml_embedded_evaluation_kit/integration/cmake) +list(APPEND CMAKE_MODULE_PATH ${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/components/security/trusted_firmware-m/integration/cmake) +include(SetupMlEmbeddedEvaluationKitLibraries) +include(GenerateAWSUpdateDigestAndSignature) +include(MergeTfmImages) +include(SignTfmImage) + +add_subdirectory(configs ${CMAKE_BINARY_DIR}/Config) +add_subdirectory(isp) +add_subdirectory(../helpers helpers) + +add_executable(object-detection + blink_task.c + main.c + ml_interface.cc +) + +target_include_directories(object-detection + PUBLIC + ../helpers/provisioning + ${CMAKE_CURRENT_LIST_DIR} +) + +if (${ML_INFERENCE_ENGINE} STREQUAL "ETHOS") + target_compile_definitions(object-detection PRIVATE USE_ETHOS) + target_sources(object-detection PRIVATE ../helpers/ethosu/src/ethosu_platform_adaptation.c) +endif() + +target_compile_options(object-detection + PRIVATE + $<$:-std=c++14> + $<$:-std=c99> +) + +#FIXME USE RTE_USART2 for control tool +target_compile_definitions(arm-corstone-platform-bsp + PUBLIC + RTE_USART1=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(object-detection trusted_firmware-m-build) +# The provision data must be built before the application because +# it provides credentials to connect to AWS. +add_dependencies(object-detection provisioning_data_bin) + +target_link_libraries(object-detection + PRIVATE + arm-2d + backoff-algorithm + connectivity-stack + coremqtt + coremqtt-agent + corepkcs11 + freertos_kernel + freertos-ota-pal-psa + fri-bsp + helpers-events + helpers-hdlcd + isp-config + isp_platform_driver + mbedtls + mbedtls-threading-freertos + ota-for-aws-iot-embedded-sdk + provisioning-lib + tfm-ns-interface + toolchain-override + object_detection_api + object_detection_model +) + +include(${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR}/bsp/cmake/SetLinkerOptions.cmake) +set_linker_script(object-detection) + +# 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( + object-detection + object-detection_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( + object-detection + object-detection-update_signed + ${MCUBOOT_IMAGE_VERSION_NS_UPDATE} + FALSE +) + + +# A user project that consumes the ARM FIR 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( + object-detection + ${NS_PROVISIONING_BUNDLE_LOAD_ADDRESS} + ${CMAKE_BINARY_DIR}/helpers/provisioning/provisioning_data.bin +) + +iot_reference_arm_corstone3xx_generate_aws_update_digest_and_signature( + object-detection + object-detection-update_signed + update-digest + update-signature +) diff --git a/applications/object_detection/blink_task.c b/applications/object_detection/blink_task.c new file mode 100644 index 00000000..313b9361 --- /dev/null +++ b/applications/object_detection/blink_task.c @@ -0,0 +1,93 @@ +/* Copyright 2021-2024, Arm Limited and/or its affiliates + * + * SPDX-License-Identifier: MIT + */ + +#include "FreeRTOS.h" +#include "blink_task.h" +#include "mps3_leds.h" +#include "task.h" + +#include +#include + +/* Include header that defines log levels. */ +#include "logging_levels.h" + +/* Configure name and log level. */ +#ifndef LIBRARY_LOG_NAME + #define LIBRARY_LOG_NAME "Blink" +#endif +#ifndef LIBRARY_LOG_LEVEL + #define LIBRARY_LOG_LEVEL LOG_INFO +#endif +#include "logging_stack.h" + +#define blinky_taskBLINK_TIMER_PERIOD_MS 250 + +enum +{ + LED1 = 1 << 0, + LED2 = 1 << 1, + LED3 = 1 << 2, + LED4 = 1 << 3, + LED5 = 1 << 4, + LED6 = 1 << 5, + LED_ALIVE = LED6, + LED7 = 1 << 6, + LED8 = 1 << 7, + LED9 = 1 << 8, + LED10 = 1 << 9, + LED_ALL = 0xFF +}; + + +void vStartBlinkTask( void ) +{ + if( + xTaskCreate( + vBlinkTask, + "BLINK_TASK ", + appCONFIG_BLINK_TASK_STACK_SIZE, + NULL, + appCONFIG_BLINK_TASK_PRIORITY, + NULL + ) != pdPASS + ) + { + LogError( ( "Failed to create Blink Task\r\n" ) ); + } +} + +void vBlinkTask( void * pvParameters ) +{ + ( void ) pvParameters; + + LogInfo( ( "Blink task started\r\n" ) ); + + mps3_leds_init(); + + if( mps3_leds_turn_off( LED_ALL ) != true ) + { + LogError( ( "Failed to turn all LEDs off\r\n" ) ); + return; + } + + const uint32_t ulTicksInterval = blinky_taskBLINK_TIMER_PERIOD_MS * configTICK_RATE_HZ / 1000; + + while( 1 ) + { + if( ulTicksInterval == 0U ) + { + return; + } + + vTaskDelay( ulTicksInterval ); + + if( mps3_leds_toggle( LED_ALIVE ) != true ) + { + LogError( ( "Failed to toggle LED_ALIVE\r\n" ) ); + return; + } + } +} diff --git a/applications/object_detection/blink_task.h b/applications/object_detection/blink_task.h new file mode 100644 index 00000000..7c76d002 --- /dev/null +++ b/applications/object_detection/blink_task.h @@ -0,0 +1,32 @@ +/* Copyright 2021-2024, Arm Limited and/or its affiliates + * + * SPDX-License-Identifier: MIT + */ + +#ifndef BLINK_TASK_H + #define BLINK_TASK_H + + #ifdef __cplusplus + extern "C" { + #endif + +/** + * @brief Create blink task. + */ + void vStartBlinkTask( void ); + +/** + * @brief Blinks LEDs according to ML processing. + * + * LED1 ON and LED2 OFF => heard YES + * LED1 OFF and LED2 OFF => heard NO + * LED1 OFF and LED2 blinking => no/unknown input + * @param pvParameters Contextual data for the task. + */ + void vBlinkTask( void * pvParameters ); + + #ifdef __cplusplus + } + #endif + +#endif /* ! BLINK_TASK_H*/ diff --git a/applications/object_detection/configs/CMakeLists.txt b/applications/object_detection/configs/CMakeLists.txt new file mode 100644 index 00000000..0a308861 --- /dev/null +++ b/applications/object_detection/configs/CMakeLists.txt @@ -0,0 +1,10 @@ +# Copyright 2023-2024, Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +add_subdirectory(app_config) +add_subdirectory(arm_2d_config) +add_subdirectory(aws_configs) +add_subdirectory(isp_config) +add_subdirectory(freertos_config) +add_subdirectory(mbedtls_config) diff --git a/applications/object_detection/configs/app_config/CMakeLists.txt b/applications/object_detection/configs/app_config/CMakeLists.txt new file mode 100644 index 00000000..24bd2482 --- /dev/null +++ b/applications/object_detection/configs/app_config/CMakeLists.txt @@ -0,0 +1,10 @@ +# Copyright 2023-2024, Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +add_library(app-config INTERFACE) + +target_include_directories(app-config + INTERFACE + . +) diff --git a/applications/object_detection/configs/app_config/app_config.h b/applications/object_detection/configs/app_config/app_config.h new file mode 100644 index 00000000..ef917056 --- /dev/null +++ b/applications/object_detection/configs/app_config/app_config.h @@ -0,0 +1,59 @@ +/* Copyright 2023-2024, Arm Limited and/or its affiliates + * + * SPDX-License-Identifier: MIT + */ + +/** @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 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 + 3 ) + +/** + * @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 ) + + +#define appCONFIG_ML_TASK_STACK_SIZE ( 8192 ) +#define appCONFIG_ML_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 ) + +#define appCONFIG_DSP_TASK_STACK_SIZE ( 8192 ) +#define appCONFIG_DSP_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 ) + + +#define appCONFIG_ML_MQTT_TASK_STACK_SIZE ( configMINIMAL_STACK_SIZE ) +#define appCONFIG_ML_MQTT_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 ) + +/** + * @brief Stack size and priority for Blink task. + * Stack size is capped to an minimal value. Task priority of Blink is set to a priority + * lower than other ML task. + */ +#define appCONFIG_BLINK_TASK_STACK_SIZE ( configMINIMAL_STACK_SIZE ) +#define appCONFIG_BLINK_TASK_PRIORITY ( tskIDLE_PRIORITY ) + +#define appCONFIG_VSI_CALLBACK_TASK_STACK_SIZE ( configMINIMAL_STACK_SIZE ) +#define appCONFIG_VSI_CALLBACK_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 ) + + +/** @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/object_detection/configs/arm_2d_config/CMakeLists.txt b/applications/object_detection/configs/arm_2d_config/CMakeLists.txt new file mode 100644 index 00000000..6fd33498 --- /dev/null +++ b/applications/object_detection/configs/arm_2d_config/CMakeLists.txt @@ -0,0 +1,10 @@ +# Copyright 2024 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +add_library(arm_2d-config INTERFACE) + +target_include_directories(arm_2d-config + INTERFACE + . +) diff --git a/applications/object_detection/configs/arm_2d_config/arm_2d_cfg.h b/applications/object_detection/configs/arm_2d_config/arm_2d_cfg.h new file mode 100644 index 00000000..892a6ace --- /dev/null +++ b/applications/object_detection/configs/arm_2d_config/arm_2d_cfg.h @@ -0,0 +1,225 @@ +/* + * Copyright (c) 2009-2024, Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __ARM_2D_USER_CFG_H__ + #define __ARM_2D_USER_CFG_H__ + +/*============================ INCLUDES ======================================*/ + +/*#include "RTE_Components.h" */ + + #ifdef __cplusplus + extern "C" { + #endif + +/*============================ MACROS ========================================*/ +/*============================ MACROFIED FUNCTIONS ===========================*/ + +/*-------- <<< Use Configuration Wizard in Context Menu >>> ----------------- */ +/* */ +/* Arm-2D General Configurations */ +/* ======================= */ +/* */ +/* Enable Asynchronous Programmers' model support */ +/* Note that if you don't have any hardware accelerator, disable this feature can reduce code size and gain a small */ +/* performance uplift. This feature is enabled by default. */ + #ifndef __ARM_2D_HAS_ASYNC__ + #define __ARM_2D_HAS_ASYNC__ 0 + #endif + +/* Enable anti-alias support for all tranform operations. */ +/* Note that enabling this feature suffers a non-negligible performance drop. */ +/* This feature is disabled by default. */ + #ifndef __ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__ + #define __ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__ 0 + #endif + +/* Enable support for accessing individual colour channels */ +/* Note that enabling this feature will add the support for a special colour type: ARM_2D_CHANNEL_8in32 */ +/* This feature is disabled by default to save code size */ + #ifndef __ARM_2D_CFG_SUPPORT_COLOUR_CHANNEL_ACCESS__ + #define __ARM_2D_CFG_SUPPORT_COLOUR_CHANNEL_ACCESS__ 1 + #endif +/* */ + +/* Patches for improving performance */ +/* ======================= */ +/* */ +/* Do NOT treat alpha value 255 as completely opaque in mask related operations */ +/* When define this macro, alpha value 0xFF will not be treated as opaque in mask related operations and you can */ +/* barely see the background. Defining this macro improves performance. */ +/*#define __ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__ */ +/* */ + +/* Ignore calibration for small angles in transform operations */ +/* This option is used to speed up M-cores without DSP support. It skips saturation in the QADD/QDADD/QDSUB involved */ +/* in the rotation. The chances of overflow remain low as elements involved are using non-accumulating Q15.16 format and */ +/* integer parts are in the range of the screen size providing enough margin. */ +/*#define __ARM_2D_CFG_UNSAFE_IGNORE_CALIB_IN_TRANSFORM__ */ +/* */ + +/* Ignore saturation protection in fixed-point operations */ +/* This option is used to remove calibration in angle computations to gain a better performance, small error might */ +/* be noticeable for angles like 90, 180, 270 etc. */ +/*#define __ARM_2D_CFG_UNSAFE_NO_SATURATION_IN_FIXED_POINT__ */ +/* */ + +/* Optimize the scaler version of transform operations for pointer-like resources */ +/* This feature is enabled by default. There is no guarantee that the performance will increase or decrease. It is */ +/* all depends your applications. In most of the case, enabling it helps. This feature has no meaning when the */ +/* anti-alias transform is disabled or the helium acceleration is available. */ + #ifndef __ARM_2D_CFG_OPTIMIZE_FOR_POINTER_LIKE_SHAPES_IN_TRANSFORM__ + #define __ARM_2D_CFG_OPTIMIZE_FOR_POINTER_LIKE_SHAPES_IN_TRANSFORM__ 1 + #endif +/* */ + +/* Extra Components */ +/* ======================= */ +/* */ + #ifndef __GLCD_CFG_COLOUR_DEPTH__ +/* Select the screen colour depth */ +/* <8=> 8 Bits */ +/* <16=> 16Bits */ +/* <32=> 32Bits */ +/* The colour depth of your LCD */ +/* Default: 16 */ + #define __GLCD_CFG_COLOUR_DEPTH__ 16 + #endif + +/* Width of the screen <8-32767> */ +/* The width of your screen */ +/* Default: 320 */ + #ifndef __GLCD_CFG_SCREEN_WIDTH__ + #define __GLCD_CFG_SCREEN_WIDTH__ 320 + #endif + +/* Height of the screen <8-32767> */ +/* The height of your screen */ +/* Default: 240 */ + #ifndef __GLCD_CFG_SCREEN_HEIGHT__ + #define __GLCD_CFG_SCREEN_HEIGHT__ 240 + #endif + +/* The size of the LCD printf text buffer <16-65535> */ +/* The text buffer size for the lcd printf service. It determins how many character you can use in one printf */ +/* string. */ + #ifndef __LCD_PRINTF_CFG_TEXT_BUFFER_SIZE__ + #define __LCD_PRINTF_CFG_TEXT_BUFFER_SIZE__ 64 + #endif + +/* Benchmark */ +/* Width of the PFB block <8-32767> */ +/* The width of your PFB block size used in arm-2d benchmark */ + #ifndef BENCHMARK_PFB_BLOCK_WIDTH + #define BENCHMARK_PFB_BLOCK_WIDTH 320 + #endif + +/* Height of the PFB block <8-32767> */ +/* The height of your PFB block size used in arm-2d benchmark */ + #ifndef BENCHMARK_PFB_BLOCK_HEIGHT + #define BENCHMARK_PFB_BLOCK_HEIGHT 240 + #endif + +/* PFB Block Count <1-65535> */ +/* The number of blocks in the PFB pool. */ + #ifndef BENCHMARK_PFB_HEAP_SIZE + #define BENCHMARK_PFB_HEAP_SIZE 1 + #endif + +/* Width Alignment of generated PFBs */ +/* <0=> 1 pixel */ +/* <1=> 2 pixel */ +/* <2=> 4 pixel */ +/* <3=> 8 pixel */ +/* <4=> 16 pixel */ +/* <5=> 32 pixel */ +/* <6=> 64 pixel */ +/* <7=> 128 pixel */ +/* Make sure the x and width of the PFB is always aligned to 2^n pixels */ + #ifndef __BENCHMARK_PFB_PIXEL_ALIGN_WIDTH__ + #define __BENCHMARK_PFB_PIXEL_ALIGN_WIDTH__ 0 + #endif + +/* Height Alignment of generated PFBs */ +/* <0=> 1 pixel */ +/* <1=> 2 pixel */ +/* <2=> 4 pixel */ +/* <3=> 8 pixel */ +/* <4=> 16 pixel */ +/* <5=> 32 pixel */ +/* <6=> 64 pixel */ +/* <7=> 128 pixel */ +/* Make sure the y and height of the PFB is always aligned to 2^n pixels */ + #ifndef __BENCHMARK_PFB_PIXEL_ALIGN_HEIGHT__ + #define __BENCHMARK_PFB_PIXEL_ALIGN_HEIGHT__ 0 + #endif + +/* Swap the high and low bytes */ +/* Swap the high and low bytes of the 16bit-pixels */ + #ifndef __ARM_2D_CFG_BENCHMARK_SWAP_RGB16_HIGH_AND_LOW_BYTES__ + #define __ARM_2D_CFG_BENCHMARK_SWAP_RGB16_HIGH_AND_LOW_BYTES__ 0 + #endif + +/* Enable the helper service for Asynchronous Flushing */ +/* Please select this option when using asynchronous flushing, e.g. DMA + ISR */ + #ifndef __ARM_2D_CFG_BENCHMARK_ENABLE_ASYNC_FLUSHING__ + #define __ARM_2D_CFG_BENCHMARK_ENABLE_ASYNC_FLUSHING__ 0 + #endif + +/* Number of iterations <1-2000> */ +/* run number of iterations in arm-2d benchmark before calculating the result. */ + #ifndef ITERATION_CNT + #define ITERATION_CNT 1000 + #endif + +/* Use Tiny mode to run benchmark */ +/* Enable this mode to reduce the benchmark memory footprint (removing background picture etc.) */ +/* This feature is disabled by default. */ + #ifndef __ARM_2D_CFG_BENCHMARK_TINY_MODE__ + #define __ARM_2D_CFG_BENCHMARK_TINY_MODE__ 0 + #endif + +/* Enable Stopwatch mode in the Benchmark:Watch-panel */ +/* Only update the second-hand (i.e. red pointer) every second in the watch-panel demo */ +/* This feature is disabled by default. */ + #ifndef __ARM_2D_CFG_WATCH_PANEL_STOPWATCH_MODE__ + #define __ARM_2D_CFG_WATCH_PANEL_STOPWATCH_MODE__ 0 + #endif + +/* Exit benchmark when finished */ +/* Exit the arm_2d_run_benchmark() after running specified iterations */ +/* This feature is disabled by default. */ + #ifndef __ARM_2D_CFG_BENCHMARK_EXIT_WHEN_FINISH__ + #define __ARM_2D_CFG_BENCHMARK_EXIT_WHEN_FINISH__ 0 + #endif + +/* */ +/* */ + +/* <<< end of configuration section >>> */ + +/*============================ TYPES =========================================*/ +/*============================ GLOBAL VARIABLES ==============================*/ +/*============================ LOCAL VARIABLES ===============================*/ +/*============================ PROTOTYPES ====================================*/ + + #ifdef __cplusplus + } + #endif + +#endif /* ifndef __ARM_2D_USER_CFG_H__ */ diff --git a/applications/object_detection/configs/aws_configs/CMakeLists.txt b/applications/object_detection/configs/aws_configs/CMakeLists.txt new file mode 100644 index 00000000..d8c60fcf --- /dev/null +++ b/applications/object_detection/configs/aws_configs/CMakeLists.txt @@ -0,0 +1,38 @@ +# Copyright 2023-2024, 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/applications/object_detection/configs/aws_configs/aws_clientcredential.h b/applications/object_detection/configs/aws_configs/aws_clientcredential.h new file mode 100644 index 00000000..df1dd08a --- /dev/null +++ b/applications/object_detection/configs/aws_configs/aws_clientcredential.h @@ -0,0 +1,51 @@ +/* Copyright 2023-2024, Arm Limited and/or its affiliates + * + * SPDX-License-Identifier: MIT + */ + +#ifndef __AWS_CLIENTCREDENTIAL__H__ +#define __AWS_CLIENTCREDENTIAL__H__ + +/** + * @brief Endpoint of the MQTT broker to connect to. + * + * This demo application can be run with any MQTT broker, that supports mutual + * authentication. + * + * For AWS IoT MQTT broker, this is the Thing's REST API Endpoint. + * + * @note Replace the used dummy value "dummy.endpointid.amazonaws.com" by your + * AWS IoT Core endpoint which can be found in the AWS IoT console under + * Settings/Custom Endpoint, or using the describe-endpoint REST API (with + * AWS CLI command line tool). + * + */ + +#define clientcredentialMQTT_BROKER_ENDPOINT "dummy.endpointid.amazonaws.com" + +/** + * @brief The MQTT client identifier used in this example. Each client identifier + * must be unique; so replace the used dummy value "dummy_thingname" as required to + * ensure that no two clients connecting to the same broker use the same client identifier. + * + * Value is defined in "aws_clientcredential.h". + */ + +#define clientcredentialIOT_THING_NAME "dummy_thingname" + +/** + * @brief The port to use for the demo. + * + * In general, port 8883 is for secured MQTT connections. + * + * @note Port 443 requires use of the ALPN TLS extension with the ALPN protocol + * name. When using port 8883, ALPN is not required. + * + */ +#define clientcredentialMQTT_BROKER_PORT 8883 + +#define clientcredentialGREENGRASS_DISCOVERY_PORT 8443 +#define clientcredentialWIFI_SSID "" +#define clientcredentialWIFI_PASSWORD "" +#define clientcredentialWIFI_SECURITY eWiFiSecurityWPA2 +#endif /* ifndef __AWS_CLIENTCREDENTIAL__H__ */ diff --git a/applications/object_detection/configs/aws_configs/aws_mqtt_config.h b/applications/object_detection/configs/aws_configs/aws_mqtt_config.h new file mode 100644 index 00000000..efef52a5 --- /dev/null +++ b/applications/object_detection/configs/aws_configs/aws_mqtt_config.h @@ -0,0 +1,69 @@ +/* + * Amazon FreeRTOS V1.1.4 + * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://aws.amazon.com/freertos + * http://www.FreeRTOS.org + */ + +/** + * @file aws_mqtt_config.h + * @brief MQTT config options. + */ + +#ifndef _AWS_MQTT_CONFIG_H_ +#define _AWS_MQTT_CONFIG_H_ + +/** + * @brief Define assert for test project. + */ +#define mqttconfigASSERT( x ) if( ( x ) == 0 ) __asm( "b . " ); + +/** + * @brief Enable subscription management. + * + * This gives the user flexibility of registering a callback per subscription. + */ +#define mqttconfigENABLE_SUBSCRIPTION_MANAGEMENT ( 1 ) + +/** + * @brief Maximum length of the topic which can be stored in subscription + * manager. + */ +#define mqttconfigSUBSCRIPTION_MANAGER_MAX_TOPIC_LENGTH ( 128 ) + +/** + * @brief Maximum number of subscriptions which can be stored in subscription + * manager. + */ +#define mqttconfigSUBSCRIPTION_MANAGER_MAX_SUBSCRIPTIONS ( 8 ) + +/* + * Uncomment the following two lines to enable asserts. + */ +/* extern void vAssertCalled( const char *pcFile, uint32_t ulLine ); */ +/* #define mqttconfigASSERT( x ) if( ( x ) == 0 ) vAssertCalled( __FILE__, __LINE__ ) */ + +/** + * @brief Set this macro to 1 for enabling debug logs. + */ +#define mqttconfigENABLE_DEBUG_LOGS ( 0 ) + +#endif /* _AWS_MQTT_CONFIG_H_ */ diff --git a/applications/object_detection/configs/aws_configs/aws_secure_sockets_config.h b/applications/object_detection/configs/aws_configs/aws_secure_sockets_config.h new file mode 100644 index 00000000..a3924669 --- /dev/null +++ b/applications/object_detection/configs/aws_configs/aws_secure_sockets_config.h @@ -0,0 +1,57 @@ +/* + * FreeRTOS V202107.00 + * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright (c) 2022-2024, 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 IOT_SECURE_SOCKETS_CONFIG_H +#define IOT_SECURE_SOCKETS_CONFIG_H + +#include "RTOS_config.h" + +/** + * @brief Byte order of the target MCU. + * + * Valid values are pdLITTLE_ENDIAN and pdBIG_ENDIAN. + */ +#define socketsconfigBYTE_ORDER pdLITTLE_ENDIAN + +/** + * @brief Default socket send timeout. + */ +#define socketsconfigDEFAULT_SEND_TIMEOUT ( 10000 ) + +/** + * @brief Default socket receive timeout. + */ +#define socketsconfigDEFAULT_RECV_TIMEOUT ( 10000 ) + +/** + * @brief Enable metrics of secure socket. + */ +#define AWS_IOT_SECURE_SOCKETS_METRICS_ENABLED ( 0 ) + +#define socketsconfigDEFAULT_MAX_NUM_SECURE_SOCKETS 4 +#define socketsconfigRECEIVE_CALLBACK_TASK_STACK_DEPTH 512 + +#endif /*IOT_SECURE_SOCKETS_CONFIG_H*/ diff --git a/applications/object_detection/configs/aws_configs/core_mqtt_config.h b/applications/object_detection/configs/aws_configs/core_mqtt_config.h new file mode 100644 index 00000000..8ea1f7bc --- /dev/null +++ b/applications/object_detection/configs/aws_configs/core_mqtt_config.h @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + */ +#ifndef CORE_MQTT_CONFIG_H +#define CORE_MQTT_CONFIG_H + +#include "logging_levels.h" + +/* Logging configuration for the MQTT library. */ +#ifndef LIBRARY_LOG_NAME + #define LIBRARY_LOG_NAME "MQTT" +#endif + +#ifndef LIBRARY_LOG_LEVEL + #define LIBRARY_LOG_LEVEL LOG_INFO +#endif + +#include "logging_stack.h" + +/** + * @brief The maximum number of MQTT PUBLISH messages that may be pending + * acknowledgment at any time. + * + * QoS 1 and 2 MQTT PUBLISHes require acknowledgment from the server before + * they can be completed. While they are awaiting the acknowledgment, the + * client must maintain information about their state. The value of this + * macro sets the limit on how many simultaneous PUBLISH states an MQTT + * context maintains. + */ +#define MQTT_STATE_ARRAY_MAX_COUNT ( 20U ) +/* #define MQTT_RECV_POLLING_TIMEOUT_MS ( 250 ) */ + +/*_RB_ To document and add to the mqtt config defaults header file. */ +#define MQTT_AGENT_COMMAND_QUEUE_LENGTH ( 32 ) +#define MQTT_COMMAND_CONTEXTS_POOL_SIZE ( 32 ) + +/** + * @brief The maximum number of subscriptions to track for a single connection. + * + * @note The MQTT agent keeps a record of all existing MQTT subscriptions. + * MQTT_AGENT_MAX_SIMULTANEOUS_SUBSCRIPTIONS sets the maximum number of + * subscriptions records that can be maintained at one time. The higher this + * number is the greater the agent's RAM consumption will be. + */ +#define MQTT_AGENT_MAX_SIMULTANEOUS_SUBSCRIPTIONS ( 10 ) + +/** + * @brief Size of statically allocated buffers for holding subscription filters. + * + * @note Subscription filters are strings such as "/my/topicname/#". These + * strings are limited to a maximum of MQTT_AGENT_MAX_SUBSCRIPTION_FILTER_LENGTH + * characters. The higher this number is the greater the agent's RAM consumption + * will be. + */ +#define MQTT_AGENT_MAX_SUBSCRIPTION_FILTER_LENGTH ( 100 ) + +#endif /* ifndef CORE_MQTT_CONFIG_H */ diff --git a/applications/object_detection/configs/aws_configs/core_pkcs11_config.h b/applications/object_detection/configs/aws_configs/core_pkcs11_config.h new file mode 100644 index 00000000..9cdf1322 --- /dev/null +++ b/applications/object_detection/configs/aws_configs/core_pkcs11_config.h @@ -0,0 +1,160 @@ +/* + * Amazon FreeRTOS V1.1.4 + * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright (c) 2022-2024, 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 + */ + +/** + * @file aws_pkcs11_config.h + * @brief PCKS#11 config options. + */ + + +#ifndef _AWS_PKCS11_CONFIG_H_ +#define _AWS_PKCS11_CONFIG_H_ + +#include + +/** + * @brief Malloc API used by core_pkcs11.h + */ +extern void * pvPortMalloc( size_t xWantedSize ); +#define PKCS11_MALLOC pvPortMalloc + +/** + * @brief Free API used by core_pkcs11.h + */ +extern void vPortFree( void * pv ); +#define PKCS11_FREE vPortFree + +/* A non-standard version of C_INITIALIZE should be used by this port. */ +/* #define pkcs11configC_INITIALIZE_ALT */ + +/** + * @brief PKCS #11 default user PIN. + * + * The PKCS #11 standard specifies the presence of a user PIN. That feature is + * sensible for applications that have an interactive user interface and memory + * protections. However, since typical microcontroller applications lack one or + * both of those, the user PIN is assumed to be used herein for interoperability + * purposes only, and not as a security feature. + */ +#define configPKCS11_DEFAULT_USER_PIN "0000" + +/** + * @brief Maximum length (in characters) for a PKCS #11 CKA_LABEL + * attribute. + */ +#define pkcs11configMAX_LABEL_LENGTH 32 + +/** + * @brief Maximum number of token objects that can be stored + * by the PKCS #11 module. + */ +#define pkcs11configMAX_NUM_OBJECTS 6 + +/** + * @brief Set to 1 if a PAL destroy object is implemented. + * + * If set to 0, no PAL destroy object is implemented, and this functionality + * is implemented in the common PKCS #11 layer. + */ +#define pkcs11configPAL_DESTROY_SUPPORTED 0 + +/** + * @brief Set to 1 if OTA image verification via PKCS #11 module is supported. + * + * If set to 0, OTA code signing certificate is built in via + * aws_ota_codesigner_certificate.h. + */ +#define pkcs11configOTA_SUPPORTED 0 + +/** + * @brief Set to 1 if PAL supports storage for JITP certificate, + * code verify certificate, and trusted server root certificate. + * + * If set to 0, PAL does not support storage mechanism for these, and + * they are accessed via headers compiled into the code. + */ +#define pkcs11configJITP_CODEVERIFY_ROOT_CERT_SUPPORTED 0 + +/** + * @brief The PKCS #11 label for device private key. + * + * Private key for connection to AWS IoT endpoint. The corresponding + * public key should be registered with the AWS IoT endpoint. + */ +#define pkcs11configLABEL_DEVICE_PRIVATE_KEY_FOR_TLS "Device Priv TLS Key" + +/** + * @brief The PKCS #11 label for device public key. + * + * The public key corresponding to pkcs11configLABEL_DEVICE_PRIVATE_KEY_FOR_TLS. + */ +#define pkcs11configLABEL_DEVICE_PUBLIC_KEY_FOR_TLS "Device Pub TLS Key" + +/** + * @brief The PKCS #11 label for the device certificate. + * + * Device certificate corresponding to pkcs11configLABEL_DEVICE_PRIVATE_KEY_FOR_TLS. + */ +#define pkcs11configLABEL_DEVICE_CERTIFICATE_FOR_TLS "Device Cert" + +/** + * @brief The PKCS #11 label for the object to be used for code verification. + * + * Used by over-the-air update code to verify an incoming signed image. + */ +#define pkcs11configLABEL_CODE_VERIFICATION_KEY "Code Verify Key" + +/** + * @brief The PKCS #11 label for Just-In-Time-Provisioning. + * + * The certificate corresponding to the issuer of the device certificate + * (pkcs11configLABEL_DEVICE_CERTIFICATE_FOR_TLS) when using the JITR or + * JITP flow. + */ +#define pkcs11configLABEL_JITP_CERTIFICATE "JITP Cert" + +/** + * @brief The PKCS #11 label for the AWS Trusted Root Certificate. + * + * @see aws_default_root_certificates.h + */ +#define pkcs11configLABEL_ROOT_CERTIFICATE "Root Cert" + +/* + * Define the key ID of the device keys which will be saved as + * persistent keys in TF-M. The key ID servers as the a name. + */ +#define PSA_DEVICE_PRIVATE_KEY_ID 0x01 +#define PSA_DEVICE_PUBLIC_KEY_ID 0x10 + +/* */ +/* FIXME: are these needed? */ +/* extern void *MPU_pvPortMalloc( size_t xSize ); */ +/* extern void MPU_vPortFree( void *pv ); */ + +/* #define pvPortMalloc MPU_pvPortMalloc */ +/* #define vPortFree MPU_vPortFree */ +#endif /* _AWS_PKCS11_CONFIG_H_ include guard. */ diff --git a/applications/object_detection/configs/aws_configs/demo_config.h b/applications/object_detection/configs/aws_configs/demo_config.h new file mode 100644 index 00000000..e38a35d8 --- /dev/null +++ b/applications/object_detection/configs/aws_configs/demo_config.h @@ -0,0 +1,82 @@ +/* + * FreeRTOS V202010.00 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + */ + +#ifndef DEMO_CONFIG_H +#define DEMO_CONFIG_H + +#include "core_mqtt.h" +#include "aws_clientcredential.h" +#include "iot_default_root_certificates.h" + +/** + * To use this demo, please configure the client's certificate and private key + * in aws_configs/aws_clientcredential_keys.h + * and credentials in aws_configs/aws_clientcredential.h. + * + * For the AWS IoT MQTT broker, refer to the AWS documentation below for details + * regarding client authentication. + * https://docs.aws.amazon.com/iot/latest/developerguide/client-authentication.html + */ + +/** + * @brief The name of the operating system that the application is running on. + * The current value is given as an example. Please update for your specific + * operating system. + */ +#define democonfigOS_NAME "FreeRTOS" + +/** + * @brief The version of the operating system that the application is running + * on. The current value is given as an example. Please update for your specific + * operating system version. + */ +#define democonfigOS_VERSION "V10.4.3" + +/** + * @brief The name of the MQTT library used and its version, following an "@" + * symbol. + */ +#define democonfigMQTT_LIB "core-mqtt@" MQTT_LIBRARY_VERSION + +/** + * @brief The MQTT metrics string expected by AWS IoT. + */ +#define democonfigMQTT_USERNAME \ + "?SDK=" democonfigOS_NAME "&Version=" democonfigOS_VERSION \ + "&MQTTLib=" democonfigMQTT_LIB + +/** + * @brief The length of the MQTT metrics string expected by AWS IoT. + */ +#define democonfigMQTT_USERNAME_LENGTH ( ( uint16_t ) ( sizeof( democonfigMQTT_USERNAME ) - 1 ) ) + +/* these are set in "aws_clientcredential.h and iot_default_root_certificates.h" */ +#define democonfigCLIENT_IDENTIFIER clientcredentialIOT_THING_NAME +#define democonfigMQTT_BROKER_ENDPOINT clientcredentialMQTT_BROKER_ENDPOINT +#define democonfigMQTT_BROKER_PORT clientcredentialMQTT_BROKER_PORT +#define democonfigROOT_CA_PEM tlsATS1_ROOT_CERTIFICATE_PEM + +#endif /* DEMO_CONFIG_H */ diff --git a/applications/object_detection/configs/aws_configs/iot_default_root_certificates.h b/applications/object_detection/configs/aws_configs/iot_default_root_certificates.h new file mode 100644 index 00000000..f8243e7b --- /dev/null +++ b/applications/object_detection/configs/aws_configs/iot_default_root_certificates.h @@ -0,0 +1,197 @@ +/* + * FreeRTOS Common V1.2.0 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://aws.amazon.com/freertos + * http://www.FreeRTOS.org + */ + +#ifndef __DEFAULT__ROOT__CERTIFICATES__H__ +#define __DEFAULT__ROOT__CERTIFICATES__H__ + +/* + * https://www.amazontrust.com/repository/AmazonRootCA1.pem + * RSA 2048-bit + */ +static const char tlsATS1_ROOT_CERTIFICATE_PEM[] = + "-----BEGIN CERTIFICATE-----\n" + "MIIDQTCCAimgAwIBAgITBmyfz5m/jAo54vB4ikPmljZbyjANBgkqhkiG9w0BAQsF\n" + "ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6\n" + "b24gUm9vdCBDQSAxMB4XDTE1MDUyNjAwMDAwMFoXDTM4MDExNzAwMDAwMFowOTEL\n" + "MAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJv\n" + "b3QgQ0EgMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALJ4gHHKeNXj\n" + "ca9HgFB0fW7Y14h29Jlo91ghYPl0hAEvrAIthtOgQ3pOsqTQNroBvo3bSMgHFzZM\n" + "9O6II8c+6zf1tRn4SWiw3te5djgdYZ6k/oI2peVKVuRF4fn9tBb6dNqcmzU5L/qw\n" + "IFAGbHrQgLKm+a/sRxmPUDgH3KKHOVj4utWp+UhnMJbulHheb4mjUcAwhmahRWa6\n" + "VOujw5H5SNz/0egwLX0tdHA114gk957EWW67c4cX8jJGKLhD+rcdqsq08p8kDi1L\n" + "93FcXmn/6pUCyziKrlA4b9v7LWIbxcceVOF34GfID5yHI9Y/QCB/IIDEgEw+OyQm\n" + "jgSubJrIqg0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC\n" + "AYYwHQYDVR0OBBYEFIQYzIU07LwMlJQuCFmcx7IQTgoIMA0GCSqGSIb3DQEBCwUA\n" + "A4IBAQCY8jdaQZChGsV2USggNiMOruYou6r4lK5IpDB/G/wkjUu0yKGX9rbxenDI\n" + "U5PMCCjjmCXPI6T53iHTfIUJrU6adTrCC2qJeHZERxhlbI1Bjjt/msv0tadQ1wUs\n" + "N+gDS63pYaACbvXy8MWy7Vu33PqUXHeeE6V/Uq2V8viTO96LXFvKWlJbYK8U90vv\n" + "o/ufQJVtMVT8QtPHRh8jrdkPSHCa2XV4cdFyQzR1bldZwgJcJmApzyMZFo6IQ6XU\n" + "5MsI+yMRQ+hDKXJioaldXgjUkK642M4UwtBV8ob2xJNDd2ZhwLnoQdeXeGADbkpy\n" + "rqXRfboQnoZsG4q5WTP468SQvvG5\n" + "-----END CERTIFICATE-----\n"; +static const uint32_t tlsATS1_ROOT_CERTIFICATE_LENGTH = sizeof( tlsATS1_ROOT_CERTIFICATE_PEM ); + +/* + * https://www.amazontrust.com/repository/AmazonRootCA2.pem + * RSA 4096-bit + */ +static const char tlsATS2_ROOT_CERTIFICATE_PEM[] = + "-----BEGIN CERTIFICATE-----\n" + "MIIFQTCCAymgAwIBAgITBmyf0pY1hp8KD+WGePhbJruKNzANBgkqhkiG9w0BAQwF\n" + "ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6\n" + "b24gUm9vdCBDQSAyMB4XDTE1MDUyNjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTEL\n" + "MAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJv\n" + "b3QgQ0EgMjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK2Wny2cSkxK\n" + "gXlRmeyKy2tgURO8TW0G/LAIjd0ZEGrHJgw12MBvIITplLGbhQPDW9tK6Mj4kHbZ\n" + "W0/jTOgGNk3Mmqw9DJArktQGGWCsN0R5hYGCrVo34A3MnaZMUnbqQ523BNFQ9lXg\n" + "1dKmSYXpN+nKfq5clU1Imj+uIFptiJXZNLhSGkOQsL9sBbm2eLfq0OQ6PBJTYv9K\n" + "8nu+NQWpEjTj82R0Yiw9AElaKP4yRLuH3WUnAnE72kr3H9rN9yFVkE8P7K6C4Z9r\n" + "2UXTu/Bfh+08LDmG2j/e7HJV63mjrdvdfLC6HM783k81ds8P+HgfajZRRidhW+me\n" + "z/CiVX18JYpvL7TFz4QuK/0NURBs+18bvBt+xa47mAExkv8LV/SasrlX6avvDXbR\n" + "8O70zoan4G7ptGmh32n2M8ZpLpcTnqWHsFcQgTfJU7O7f/aS0ZzQGPSSbtqDT6Zj\n" + "mUyl+17vIWR6IF9sZIUVyzfpYgwLKhbcAS4y2j5L9Z469hdAlO+ekQiG+r5jqFoz\n" + "7Mt0Q5X5bGlSNscpb/xVA1wf+5+9R+vnSUeVC06JIglJ4PVhHvG/LopyboBZ/1c6\n" + "+XUyo05f7O0oYtlNc/LMgRdg7c3r3NunysV+Ar3yVAhU/bQtCSwXVEqY0VThUWcI\n" + "0u1ufm8/0i2BWSlmy5A5lREedCf+3euvAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMB\n" + "Af8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBSwDPBMMPQFWAJI/TPlUq9LhONm\n" + "UjANBgkqhkiG9w0BAQwFAAOCAgEAqqiAjw54o+Ci1M3m9Zh6O+oAA7CXDpO8Wqj2\n" + "LIxyh6mx/H9z/WNxeKWHWc8w4Q0QshNabYL1auaAn6AFC2jkR2vHat+2/XcycuUY\n" + "+gn0oJMsXdKMdYV2ZZAMA3m3MSNjrXiDCYZohMr/+c8mmpJ5581LxedhpxfL86kS\n" + "k5Nrp+gvU5LEYFiwzAJRGFuFjWJZY7attN6a+yb3ACfAXVU3dJnJUH/jWS5E4ywl\n" + "7uxMMne0nxrpS10gxdr9HIcWxkPo1LsmmkVwXqkLN1PiRnsn/eBG8om3zEK2yygm\n" + "btmlyTrIQRNg91CMFa6ybRoVGld45pIq2WWQgj9sAq+uEjonljYE1x2igGOpm/Hl\n" + "urR8FLBOybEfdF849lHqm/osohHUqS0nGkWxr7JOcQ3AWEbWaQbLU8uz/mtBzUF+\n" + "fUwPfHJ5elnNXkoOrJupmHN5fLT0zLm4BwyydFy4x2+IoZCn9Kr5v2c69BoVYh63\n" + "n749sSmvZ6ES8lgQGVMDMBu4Gon2nL2XA46jCfMdiyHxtN/kHNGfZQIG6lzWE7OE\n" + "76KlXIx3KadowGuuQNKotOrN8I1LOJwZmhsoVLiJkO/KdYE+HvJkJMcYr07/R54H\n" + "9jVlpNMKVv/1F2Rs76giJUmTtt8AF9pYfl3uxRuw0dFfIRDH+fO6AgonB8Xx1sfT\n" + "4PsJYGw=\n" + "-----END CERTIFICATE-----\n"; +static const uint32_t tlsATS2_ROOT_CERTIFICATE_LENGTH = sizeof( tlsATS2_ROOT_CERTIFICATE_PEM ); + +/* + * https://www.amazontrust.com/repository/AmazonRootCA3.pem + * EC 256-bit + */ +static const char tlsATS3_ROOT_CERTIFICATE_PEM[] = + "-----BEGIN CERTIFICATE-----\n" + "MIIBtjCCAVugAwIBAgITBmyf1XSXNmY/Owua2eiedgPySjAKBggqhkjOPQQDAjA5\n" + "MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24g\n" + "Um9vdCBDQSAzMB4XDTE1MDUyNjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkG\n" + "A1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJvb3Qg\n" + "Q0EgMzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABCmXp8ZBf8ANm+gBG1bG8lKl\n" + "ui2yEujSLtf6ycXYqm0fc4E7O5hrOXwzpcVOho6AF2hiRVd9RFgdszflZwjrZt6j\n" + "QjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBSr\n" + "ttvXBp43rDCGB5Fwx5zEGbF4wDAKBggqhkjOPQQDAgNJADBGAiEA4IWSoxe3jfkr\n" + "BqWTrBqYaGFy+uGh0PsceGCmQ5nFuMQCIQCcAu/xlJyzlvnrxir4tiz+OpAUFteM\n" + "YyRIHN8wfdVoOw==\n" + "-----END CERTIFICATE-----\n"; +static const uint32_t tlsATS3_ROOT_CERTIFICATE_LENGTH = sizeof( tlsATS3_ROOT_CERTIFICATE_PEM ); + +/* + * https://www.amazontrust.com/repository/AmazonRootCA4.pem + * EC 384-bit + */ +static const char tlsATS4_ROOT_CERTIFICATE_PEM[] = + "-----BEGIN CERTIFICATE-----\n" + "MIIB8jCCAXigAwIBAgITBmyf18G7EEwpQ+Vxe3ssyBrBDjAKBggqhkjOPQQDAzA5\n" + "MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24g\n" + "Um9vdCBDQSA0MB4XDTE1MDUyNjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkG\n" + "A1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJvb3Qg\n" + "Q0EgNDB2MBAGByqGSM49AgEGBSuBBAAiA2IABNKrijdPo1MN/sGKe0uoe0ZLY7Bi\n" + "9i0b2whxIdIA6GO9mif78DluXeo9pcmBqqNbIJhFXRbb/egQbeOc4OO9X4Ri83Bk\n" + "M6DLJC9wuoihKqB1+IGuYgbEgds5bimwHvouXKNCMEAwDwYDVR0TAQH/BAUwAwEB\n" + "/zAOBgNVHQ8BAf8EBAMCAYYwHQYDVR0OBBYEFNPsxzplbszh2naaVvuc84ZtV+WB\n" + "MAoGCCqGSM49BAMDA2gAMGUCMDqLIfG9fhGt0O9Yli/W651+kI0rz2ZVwyzjKKlw\n" + "CkcO8DdZEv8tmZQoTipPNU0zWgIxAOp1AE47xDqUEpHJWEadIRNyp4iciuRMStuW\n" + "1KyLa2tJElMzrdfkviT8tQp21KW8EA==\n" + "-----END CERTIFICATE-----\n"; +static const uint32_t tlsATS4_ROOT_CERTIFICATE_LENGTH = sizeof( tlsATS4_ROOT_CERTIFICATE_PEM ); + +/* + * Starfield Cross-signing CA + */ +static const char tlsSTARFIELD_ROOT_CERTIFICATE_PEM[] = + "-----BEGIN CERTIFICATE-----\n" + "MIIEDzCCAvegAwIBAgIBADANBgkqhkiG9w0BAQUFADBoMQswCQYDVQQGEwJVUzEl\n" + "MCMGA1UEChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMp\n" + "U3RhcmZpZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQw\n" + "NjI5MTczOTE2WhcNMzQwNjI5MTczOTE2WjBoMQswCQYDVQQGEwJVUzElMCMGA1UE\n" + "ChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMpU3RhcmZp\n" + "ZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEgMA0GCSqGSIb3\n" + "DQEBAQUAA4IBDQAwggEIAoIBAQC3Msj+6XGmBIWtDBFk385N78gDGIc/oav7PKaf\n" + "8MOh2tTYbitTkPskpD6E8J7oX+zlJ0T1KKY/e97gKvDIr1MvnsoFAZMej2YcOadN\n" + "+lq2cwQlZut3f+dZxkqZJRRU6ybH838Z1TBwj6+wRir/resp7defqgSHo9T5iaU0\n" + "X9tDkYI22WY8sbi5gv2cOj4QyDvvBmVmepsZGD3/cVE8MC5fvj13c7JdBmzDI1aa\n" + "K4UmkhynArPkPw2vCHmCuDY96pzTNbO8acr1zJ3o/WSNF4Azbl5KXZnJHoe0nRrA\n" + "1W4TNSNe35tfPe/W93bC6j67eA0cQmdrBNj41tpvi/JEoAGrAgEDo4HFMIHCMB0G\n" + "A1UdDgQWBBS/X7fRzt0fhvRbVazc1xDCDqmI5zCBkgYDVR0jBIGKMIGHgBS/X7fR\n" + "zt0fhvRbVazc1xDCDqmI56FspGowaDELMAkGA1UEBhMCVVMxJTAjBgNVBAoTHFN0\n" + "YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAwBgNVBAsTKVN0YXJmaWVsZCBD\n" + "bGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8w\n" + "DQYJKoZIhvcNAQEFBQADggEBAAWdP4id0ckaVaGsafPzWdqbAYcaT1epoXkJKtv3\n" + "L7IezMdeatiDh6GX70k1PncGQVhiv45YuApnP+yz3SFmH8lU+nLMPUxA2IGvd56D\n" + "eruix/U0F47ZEUD0/CwqTRV/p2JdLiXTAAsgGh1o+Re49L2L7ShZ3U0WixeDyLJl\n" + "xy16paq8U4Zt3VekyvggQQto8PT7dL5WXXp59fkdheMtlb71cZBDzI0fmgAKhynp\n" + "VSJYACPq4xJDKVtHCN2MQWplBqjlIapBtJUhlbl90TSrE9atvNziPTnNvT51cKEY\n" + "WQPJIrSPnNVeKtelttQKbfi3QBFGmh95DmK/D5fs4C8fF5Q=\n" + "-----END CERTIFICATE-----\n"; +static const uint32_t tlsSTARFIELD_ROOT_CERTIFICATE_LENGTH = sizeof( tlsSTARFIELD_ROOT_CERTIFICATE_PEM ); + +/* + * VeriSign-Class 3-Public-Primary-Certification-Authority-G5 + */ +static const char tlsVERISIGN_ROOT_CERTIFICATE_PEM[] = + "-----BEGIN CERTIFICATE-----\n" + "MIIE0zCCA7ugAwIBAgIQGNrRniZ96LtKIVjNzGs7SjANBgkqhkiG9w0BAQUFADCB\n" + "yjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL\n" + "ExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJp\n" + "U2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxW\n" + "ZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0\n" + "aG9yaXR5IC0gRzUwHhcNMDYxMTA4MDAwMDAwWhcNMzYwNzE2MjM1OTU5WjCByjEL\n" + "MAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZW\n" + "ZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJpU2ln\n" + "biwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJp\n" + "U2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9y\n" + "aXR5IC0gRzUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCvJAgIKXo1\n" + "nmAMqudLO07cfLw8RRy7K+D+KQL5VwijZIUVJ/XxrcgxiV0i6CqqpkKzj/i5Vbex\n" + "t0uz/o9+B1fs70PbZmIVYc9gDaTY3vjgw2IIPVQT60nKWVSFJuUrjxuf6/WhkcIz\n" + "SdhDY2pSS9KP6HBRTdGJaXvHcPaz3BJ023tdS1bTlr8Vd6Gw9KIl8q8ckmcY5fQG\n" + "BO+QueQA5N06tRn/Arr0PO7gi+s3i+z016zy9vA9r911kTMZHRxAy3QkGSGT2RT+\n" + "rCpSx4/VBEnkjWNHiDxpg8v+R70rfk/Fla4OndTRQ8Bnc+MUCH7lP59zuDMKz10/\n" + "NIeWiu5T6CUVAgMBAAGjgbIwga8wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8E\n" + "BAMCAQYwbQYIKwYBBQUHAQwEYTBfoV2gWzBZMFcwVRYJaW1hZ2UvZ2lmMCEwHzAH\n" + "BgUrDgMCGgQUj+XTGoasjY5rw8+AatRIGCx7GS4wJRYjaHR0cDovL2xvZ28udmVy\n" + "aXNpZ24uY29tL3ZzbG9nby5naWYwHQYDVR0OBBYEFH/TZafC3ey78DAJ80M5+gKv\n" + "MzEzMA0GCSqGSIb3DQEBBQUAA4IBAQCTJEowX2LP2BqYLz3q3JktvXf2pXkiOOzE\n" + "p6B4Eq1iDkVwZMXnl2YtmAl+X6/WzChl8gGqCBpH3vn5fJJaCGkgDdk+bW48DW7Y\n" + "5gaRQBi5+MHt39tBquCWIMnNZBU4gcmU7qKEKQsTb47bDN0lAtukixlE0kF6BWlK\n" + "WE9gyn6CagsCqiUXObXbf+eEZSqVir2G3l6BFoMtEMze/aiCKm0oHw0LxOXnGiYZ\n" + "4fQRbxC1lfznQgUy286dUV4otp6F01vvpX1FQHKOtw5rDgb7MzVIcbidJ4vEZV8N\n" + "hnacRHr2lVz2XTIIM6RUthg/aFzyQkqFOFSDX9HoLPKsEdao7WNq\n" + "-----END CERTIFICATE-----\n"; +static const uint32_t tlsVERISIGN_ROOT_CERTIFICATE_LENGTH = sizeof( tlsVERISIGN_ROOT_CERTIFICATE_PEM ); + +#endif /* ifndef __DEFAULT__ROOT__CERTIFICATES__H__ */ diff --git a/applications/object_detection/configs/aws_configs/mqtt_agent_demo_config.h b/applications/object_detection/configs/aws_configs/mqtt_agent_demo_config.h new file mode 100644 index 00000000..664d07f3 --- /dev/null +++ b/applications/object_detection/configs/aws_configs/mqtt_agent_demo_config.h @@ -0,0 +1,129 @@ +/* + * FreeRTOS V202010.00 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + */ + +#ifndef MQTT_DEMO_CONNECTION_SHARING_CONFIG_H +#define MQTT_DEMO_CONNECTION_SHARING_CONFIG_H + +/**************************************************/ +/******* DO NOT CHANGE the following order ********/ +/**************************************************/ + +/* Include logging header files and define logging macros in the following order: + * 1. Include the header file "logging_levels.h". + * 2. Define the LIBRARY_LOG_NAME and LIBRARY_LOG_LEVEL macros depending on + * the logging configuration for DEMO. + * 3. Include the header file "logging_stack.h", if logging is enabled for DEMO. + */ + +#include "logging_levels.h" + +/* Logging configuration for the Demo. */ +#ifndef LIBRARY_LOG_NAME + #define LIBRARY_LOG_NAME "MQTTDemo" +#endif + +#ifndef LIBRARY_LOG_LEVEL + #define LIBRARY_LOG_LEVEL LOG_INFO +#endif +#include "logging_stack.h" + +/************ End of logging configuration ****************/ + +/** + * @brief The MQTT client identifier used in this example. Each client identifier + * must be unique so edit as required to ensure no two clients connecting to the + * same broker use the same client identifier. + * + * #define democonfigCLIENT_IDENTIFIER "insert here." + */ + + +/** + * @brief Endpoint of the MQTT broker to connect to. + * + * This demo application can be run with any MQTT broker, although it is + * recommended to use one that supports mutual authentication. If mutual + * authentication is not used, then #democonfigUSE_TLS should be set to 0. + * + * For AWS IoT MQTT broker, this is the Thing's REST API Endpoint. + * + * @note Your AWS IoT Core endpoint can be found in the AWS IoT console under + * Settings/Custom Endpoint, or using the describe-endpoint REST API (with + * AWS CLI command line tool). + * + * #define democonfigMQTT_BROKER_ENDPOINT "insert here." + */ + + +/** + * @brief The port to use for the demo. + * + * In general, port 8883 is for secured MQTT connections, and port 1883 if not + * using TLS. + * + * @note Port 443 requires use of the ALPN TLS extension with the ALPN protocol + * name. Using ALPN with this demo would require additional changes, including + * setting the `pAlpnProtos` member of the `NetworkCredentials_t` struct before + * forming the TLS connection. When using port 8883, ALPN is not required. + * + * #define democonfigMQTT_BROKER_PORT ( insert here. ) + */ + +/** + * @brief Dimensions the buffer used to serialize and deserialize MQTT packets. + * + * @note Specified in bytes. Must be large enough to hold the maximum + * anticipated MQTT payload. + * + * #define MQTT_AGENT_NETWORK_BUFFER_SIZE ( insert here. ) + */ + +/** + * @brief The length of the queue used to hold commands for the agent. + * + * #define MQTT_AGENT_COMMAND_QUEUE_LENGTH ( insert here. ) + */ + +/** + * @brief Maximum number of subscriptions maintained by the subscription manager + * simultaneously in a list. + * + * #define SUBSCRIPTION_MANAGER_MAX_SUBSCRIPTIONS ( insert here. ) + */ + +/** + * @brief The number of simple subscribe-publish tasks to create for the demo + */ +#define democonfigNUM_SIMPLE_SUB_PUB_TASKS_TO_CREATE 1 +#define democonfigSIMPLE_SUB_PUB_TASK_STACK_SIZE ( configMINIMAL_STACK_SIZE * 4 ) + + +/** + * @brief The maximum number of times to run the demo's task creation loop. + */ +#define democonfigMQTT_MAX_DEMO_COUNT ( 3 ) + +#endif /* MQTT_DEMO_CONNECTION_SHARING_CONFIG_H */ diff --git a/applications/object_detection/configs/aws_configs/mqtt_demo_mutual_auth_config.h b/applications/object_detection/configs/aws_configs/mqtt_demo_mutual_auth_config.h new file mode 100644 index 00000000..6ac43b79 --- /dev/null +++ b/applications/object_detection/configs/aws_configs/mqtt_demo_mutual_auth_config.h @@ -0,0 +1,112 @@ +/* + * FreeRTOS V202010.00 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + */ + +#ifndef MQTT_DEMO_MUTUAL_AUTH_CONFIG_H +#define MQTT_DEMO_MUTUAL_AUTH_CONFIG_H + +/**************************************************/ +/******* DO NOT CHANGE the following order ********/ +/**************************************************/ + +/* Include logging header files and define logging macros in the following order: + * 1. Include the header file "logging_levels.h". + * 2. Define the LIBRARY_LOG_NAME and LIBRARY_LOG_LEVEL macros depending on + * the logging configuration for DEMO. + * 3. Include the header file "logging_stack.h", if logging is enabled for DEMO. + */ + +#include "logging_levels.h" + +/* Logging configuration for the Demo. */ +#ifndef LIBRARY_LOG_NAME + #define LIBRARY_LOG_NAME "MQTT_MutualAuth_Demo" +#endif + +#ifndef LIBRARY_LOG_LEVEL + #define LIBRARY_LOG_LEVEL LOG_INFO +#endif +#include "logging_stack.h" + +/************ End of logging configuration ****************/ + +/** + * To use this demo, please configure the client's certificate and private key + * in demos/include/aws_clientcredential_keys.h. + * + * For the AWS IoT MQTT broker, refer to the AWS documentation below for details + * regarding client authentication. + * https://docs.aws.amazon.com/iot/latest/developerguide/client-authentication.html + */ + +/** + * @brief The MQTT client identifier used in this example. Each client identifier + * must be unique; so edit as required to ensure that no two clients connecting to + * the same broker use the same client identifier. + * + * #define democonfigCLIENT_IDENTIFIER "insert here." + */ + +/** + * @brief Endpoint of the MQTT broker to connect to. + * + * This demo application can be run with any MQTT broker, that supports mutual + * authentication. + * + * For AWS IoT MQTT broker, this is the Thing's REST API Endpoint. + * + * @note Your AWS IoT Core endpoint can be found in the AWS IoT console under + * Settings/Custom Endpoint, or using the describe-endpoint REST API (with + * AWS CLI command line tool). + * + * #define democonfigMQTT_BROKER_ENDPOINT "...insert here..." + */ + +/** + * @brief The port to use for the demo. + * + * In general, port 8883 is for secured MQTT connections. + * + * @note Port 443 requires use of the ALPN TLS extension with the ALPN protocol + * name. When using port 8883, ALPN is not required. + * + * #define democonfigMQTT_BROKER_PORT "...insert here..." + */ +#define democonfigMQTT_BROKER_PORT 8883 + +/** + * @brief Size of the network buffer for MQTT packets. + */ +#define democonfigNETWORK_BUFFER_SIZE ( 1500 ) + +/** + * @brief The maximum number of times to run the subscribe publish loop in the + * demo. + * + * #define democonfigMQTT_MAX_DEMO_COUNT ( insert here ) + */ +#define democonfigMQTT_MAX_DEMO_COUNT ( 3 ) + +#endif /* MQTT_DEMO_MUTUAL_AUTH_CONFIG_H */ diff --git a/applications/object_detection/configs/aws_configs/ota_config.h b/applications/object_detection/configs/aws_configs/ota_config.h new file mode 100644 index 00000000..829b25f7 --- /dev/null +++ b/applications/object_detection/configs/aws_configs/ota_config.h @@ -0,0 +1,206 @@ +/* + * FreeRTOS V202104.00 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * @file ota_config.h + * @brief OTA user configurable settings. + */ + +#ifndef OTA_CONFIG_H_ +#define OTA_CONFIG_H_ + +/**************************************************/ +/******* DO NOT CHANGE the following order ********/ +/**************************************************/ + +/* Logging related header files are required to be included in the following order: + * 1. Include the header file "logging_levels.h". + * 2. Define LIBRARY_LOG_NAME and LIBRARY_LOG_LEVEL. + * 3. Include the header file "logging_stack.h". + */ + +/* Include header that defines log levels. */ +#include "logging_levels.h" + +/* Configure name and log level for the OTA library. */ +#ifndef LIBRARY_LOG_NAME + #define LIBRARY_LOG_NAME "OTA" +#endif +#ifndef LIBRARY_LOG_LEVEL + #define LIBRARY_LOG_LEVEL LOG_INFO +#endif +#include "logging_stack.h" + +/************ End of logging configuration ****************/ + +/* Include config file used for testing the OTA PAL. This config file defines + * the otapalconfigCODE_SIGNING_CERTIFICATE macro. */ +#include "ota_demo_config.h" + +/** + * @brief Log base 2 of the size of the file data block message (excluding the + * header). + * + * Possible values: Any unsigned 32 integer.
+ */ +#define otaconfigLOG2_FILE_BLOCK_SIZE 12UL /* TODO */ + +/** + * @brief Size of the file data block message (excluding the header). + */ +#define otaconfigFILE_BLOCK_SIZE ( 1UL << otaconfigLOG2_FILE_BLOCK_SIZE ) + +/** + * @brief Milliseconds to wait for the self test phase to succeed before we + * force reset. + * + * Possible values: Any unsigned 32 integer.
+ */ +#define otaconfigSELF_TEST_RESPONSE_WAIT_MS 16000U /* TODO */ + +/** + * @brief Milliseconds to wait before requesting data blocks from the OTA + * service if nothing is happening. + * + * @note The wait timer is reset whenever a data block is received from the OTA + * service so we will only send the request message after being idle for this + * amount of time. + * + * Possible values: Any unsigned 32 integer.
+ */ +#define otaconfigFILE_REQUEST_WAIT_MS 100000U /* TODO */ + +/** + * @brief The maximum allowed length of the thing name used by the OTA agent. + * + * @note AWS IoT requires Thing names to be unique for each device that + * connects to the broker. Likewise, the OTA agent requires the developer to + * construct and pass in the Thing name when initializing the OTA agent. The + * agent uses this size to allocate static storage for the Thing name used in + * all OTA base topics. Namely $aws/things/thingName + * + * Possible values: Any unsigned 32 integer.
+ */ +#define otaconfigMAX_THINGNAME_LEN 128U /* TODO */ + +/** + * @brief The maximum number of data blocks requested from OTA streaming + * service. + * + * @note This configuration parameter is sent with data requests and represents + * the maximum number of data blocks the service will send in response. The + * maximum limit for this must be calculated from the maximum data response + * limit (128 KB from service) divided by the block size. For example if block + * size is set as 1 KB then the maximum number of data blocks that we can + * request is 128/1 = 128 blocks. Configure this parameter to this maximum + * limit or lower based on how many data blocks response is expected for each + * data requests. + * + * Possible values: Any unsigned 32 integer value greater than 0.
+ */ +#define otaconfigMAX_NUM_BLOCKS_REQUEST 1U /* TODO */ + +/** + * @brief The maximum number of requests allowed to send without a response + * before we abort. + * + * @note This configuration parameter sets the maximum number of times the + * requests are made over the selected communication channel before aborting + * and returning error. + * + * Possible values: Any unsigned 32 integer.
+ */ +#define otaconfigMAX_NUM_REQUEST_MOMENTUM 32U /* TODO */ + +/** + * @brief How frequently the device will report its OTA progress to the cloud. + * + * @note Device will update the job status with the number of blocks it has + * received every certain number of blocks it receives. For example, 64 means + * device will update job status every 64 blocks it receives. + * + * Possible values: Any unsigned 32 integer.
+ */ +#define otaconfigOTA_UPDATE_STATUS_FREQUENCY 25U /* TODO */ + +/** + * @brief The number of data buffers reserved by the OTA agent. + * + * @note This configurations parameter sets the maximum number of static data + * buffers used by the OTA agent for job and file data blocks received. + * + * Possible values: Any unsigned 32 integer.
+ */ +#define otaconfigMAX_NUM_OTA_DATA_BUFFERS otaconfigMAX_NUM_BLOCKS_REQUEST + 1 /* TODO */ + +/** + * @brief Flag to enable booting into updates that have an identical or lower + * version than the current version. + * + * @note Set this configuration parameter to '1' to disable version checks. + * This allows updates to an identical or lower version. This is provided for + * testing purpose and it's recommended to always update to higher version and + * keep this configuration disabled. + * + * Possible values: Any unsigned 32 integer.
+ */ +#define otaconfigAllowDowngrade 0U /* TODO */ + +/** + * @brief The protocol selected for OTA control operations. + * + * @note This configurations parameter sets the default protocol for all the + * OTA control operations like requesting OTA job, updating the job status etc. + * + * @note Only MQTT is supported at this time for control operations. + * + * Possible values: OTA_CONTROL_OVER_MQTT
+ */ +#define configENABLED_CONTROL_PROTOCOL ( OTA_CONTROL_OVER_MQTT ) + +/** + * @brief The protocol selected for OTA data operations. + * + * @note This configurations parameter sets the protocols selected for the data + * operations like requesting file blocks from the service. + * + * Possible values:
+ * Enable data over MQTT - ( OTA_DATA_OVER_MQTT )
+ * Enable data over HTTP - ( OTA_DATA_OVER_HTTP )
+ * Enable data over both MQTT & HTTP - ( OTA_DATA_OVER_MQTT | OTA_DATA_OVER_HTTP )
+ */ +#define configENABLED_DATA_PROTOCOLS ( OTA_DATA_OVER_MQTT ) + +/** + * @brief The preferred protocol selected for OTA data operations. + * + * @note Primary data protocol will be the protocol used for downloading file + * if more than one protocol is selected while creating OTA job. + * + * Possible values:
+ * Data over MQTT - ( OTA_DATA_OVER_MQTT )
+ * Data over HTTP - ( OTA_DATA_OVER_HTTP )
+ */ + +#define configOTA_PRIMARY_DATA_PROTOCOL ( OTA_DATA_OVER_MQTT ) + +#endif /* OTA_CONFIG_H_ */ diff --git a/applications/object_detection/configs/aws_configs/ota_demo_config.h b/applications/object_detection/configs/aws_configs/ota_demo_config.h new file mode 100644 index 00000000..c6f3aa73 --- /dev/null +++ b/applications/object_detection/configs/aws_configs/ota_demo_config.h @@ -0,0 +1,103 @@ +/* + * FreeRTOS V202104.00 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * @file ota_demo_config.h + * @brief Configuration options for the OTA related demos. + */ + +#ifndef OTA_DEMO_CONFIG_H_ +#define OTA_DEMO_CONFIG_H_ + +/** + * @brief Certificate used for validating code signing signatures in the OTA PAL. + */ +#ifndef otapalconfigCODE_SIGNING_CERTIFICATE + #define otapalconfigCODE_SIGNING_CERTIFICATE "Insert code signing certificate..." /* TODO */ +#endif + +/** + * @brief Whether to use const qualifier for the appFirmwareVersion variable. + * + * @note In some cases the appFirmwareVersion variable cannot be declared as const + * because the version is read out during runtime. + * + * Possible values:
+ * appFirmwareVersion is const - ( 0 )
+ * appFirmwareVersion is non-const - ( 1 )
+ * Default value: '0' + */ +#ifndef OTA_USE_NONCONST_APPVERSION + #define OTA_USE_NONCONST_APPVERSION ( 1U ) +#endif + + +/** + * @brief Major version of the firmware. + * + * This is used in the OTA demo to set the appFirmwareVersion variable + * that is declared in the ota_appversion32.h file in the OTA library. + */ +#ifndef APP_VERSION_MAJOR + #define APP_VERSION_MAJOR 0 /* TODO */ +#endif + +/** + * @brief Minor version of the firmware. + * + * This is used in the OTA demo to set the appFirmwareVersion variable + * that is declared in the ota_appversion32.h file in the OTA library. + */ +#ifndef APP_VERSION_MINOR + #define APP_VERSION_MINOR 0 /* TODO */ +#endif + +/** + * @brief Build version of the firmware. + * + * This is used in the OTA demo to set the appFirmwareVersion variable + * that is declared in the ota_appversion32.h file in the OTA library. + */ +#ifndef APP_VERSION_BUILD + #define APP_VERSION_BUILD 0 /* TODO */ +#endif + +/** + * @brief Timeout for which MQTT library keeps polling the transport interface, + * when no byte is received. + * The timeout is honoured only after the first byte is read and while remaining + * bytes are read from network interface. Keeping this timeout to a sufficiently + * large value so as to account for delay of receipt of a large block of message. + */ +#undef MQTT_RECV_POLLING_TIMEOUT_MS /* Override the one from "core_mqtt_config_defaults.h" */ +#define MQTT_RECV_POLLING_TIMEOUT_MS ( 1000U ) /* TODO Set a timeout in msecs for data received from MQTT. Recommend values > 1 s. */ + +/** + * @brief Maximum time MQTT agent waits in the queue for any pending MQTT + * operations. The wait time is kept smallest possible to increase the + * responsiveness of MQTT agent while processing pending MQTT operations as + * well as receive packets from network. + */ +#undef MQTT_AGENT_MAX_EVENT_QUEUE_WAIT_TIME /* Override the one from "core_mqtt_config_defaults.h" */ +#define MQTT_AGENT_MAX_EVENT_QUEUE_WAIT_TIME ( 1U ) /* TODO */ + +#endif /* OTA_DEMO_CONFIG_H_ */ diff --git a/applications/object_detection/configs/freertos_config/CMakeLists.txt b/applications/object_detection/configs/freertos_config/CMakeLists.txt new file mode 100644 index 00000000..bf3ae06d --- /dev/null +++ b/applications/object_detection/configs/freertos_config/CMakeLists.txt @@ -0,0 +1,20 @@ +# Copyright 2023-2024, 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/object_detection/configs/freertos_config/FreeRTOSConfig.h b/applications/object_detection/configs/freertos_config/FreeRTOSConfig.h new file mode 100644 index 00000000..847bf7fb --- /dev/null +++ b/applications/object_detection/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-2024, 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 0 +#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/object_detection/configs/freertos_config/FreeRTOSIPConfig.h b/applications/object_detection/configs/freertos_config/FreeRTOSIPConfig.h new file mode 100644 index 00000000..4e1f9238 --- /dev/null +++ b/applications/object_detection/configs/freertos_config/FreeRTOSIPConfig.h @@ -0,0 +1,316 @@ +/* + * FreeRTOS V202212.00 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + + +/***************************************************************************** +* +* See the following URL for configuration information. +* https://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_IP_Configuration.html +* +*****************************************************************************/ + +#ifndef FREERTOS_IP_CONFIG_H +#define FREERTOS_IP_CONFIG_H + +/* Prototype for the function used to print out. In this case it prints to the + * console before the network is connected then a UDP port after the network has + * connected. */ +extern void vLoggingPrintf( const char * pcFormatString, + ... ); + +#ifdef HEAP3 + #define xPortGetMinimumEverFreeHeapSize( x ) 0 + #define xPortGetFreeHeapSize() 0 +#endif + +/* Set to 1 to print out debug messages. If ipconfigHAS_DEBUG_PRINTF is set to + * 1 then FreeRTOS_debug_printf should be defined to the function used to print + * out the debugging messages. */ +#define ipconfigHAS_DEBUG_PRINTF 0 +#if ( ipconfigHAS_DEBUG_PRINTF == 1 ) + #define FreeRTOS_debug_printf( X ) vLoggingPrintf X +#endif + +/* Set to 1 to print out non debugging messages, for example the output of the + * FreeRTOS_netstat() command, and ping replies. If ipconfigHAS_PRINTF is set to 1 + * then FreeRTOS_printf should be set to the function used to print out the + * messages. */ +#define ipconfigHAS_PRINTF 1 +#if ( ipconfigHAS_PRINTF == 1 ) + #define FreeRTOS_printf( X ) vLoggingPrintf X +#endif + +/* Define the byte order of the target MCU (the MCU FreeRTOS+TCP is executing + * on). Valid options are pdFREERTOS_BIG_ENDIAN and pdFREERTOS_LITTLE_ENDIAN. */ +#define ipconfigBYTE_ORDER pdFREERTOS_LITTLE_ENDIAN + +/* If the network card/driver includes checksum offloading (IP/TCP/UDP checksums) + * then set ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM to 1 to prevent the software + * stack repeating the checksum calculations. */ +#define ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM 1 + +/* Several API's will block until the result is known, or the action has been + * performed, for example FreeRTOS_send() and FreeRTOS_recv(). The timeouts can be + * set per socket, using setsockopt(). If not set, the times below will be + * used as defaults. */ +#define ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME ( 100 ) +#define ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME ( 100 ) + +/* Include support for LLMNR: Link-local Multicast Name Resolution + * (non-Microsoft) */ +#define ipconfigUSE_LLMNR ( 0 ) + +/* Include support for NBNS: NetBIOS Name Service (Microsoft) */ +#define ipconfigUSE_NBNS ( 0 ) + +/* Include support for DNS caching. For TCP, having a small DNS cache is very + * useful. When a cache is present, ipconfigDNS_REQUEST_ATTEMPTS can be kept low + * and also DNS may use small timeouts. If a DNS reply comes in after the DNS + * socket has been destroyed, the result will be stored into the cache. The next + * call to FreeRTOS_gethostbyname() will return immediately, without even creating + * a socket. */ +#define ipconfigUSE_DNS_CACHE ( 1 ) +#define ipconfigDNS_CACHE_NAME_LENGTH ( 254 ) +#define ipconfigDNS_CACHE_ENTRIES ( 4 ) +#define ipconfigDNS_REQUEST_ATTEMPTS ( 2 ) + +/* The IP stack executes it its own task (although any application task can make + * use of its services through the published sockets API). ipconfigUDP_TASK_PRIORITY + * sets the priority of the task that executes the IP stack. The priority is a + * standard FreeRTOS task priority so can take any value from 0 (the lowest + * priority) to (configMAX_PRIORITIES - 1) (the highest priority). + * configMAX_PRIORITIES is a standard FreeRTOS configuration parameter defined in + * FreeRTOSConfig.h, not FreeRTOSIPConfig.h. Consideration needs to be given as to + * the priority assigned to the task executing the IP stack relative to the + * priority assigned to tasks that use the IP stack. */ +#define ipconfigIP_TASK_PRIORITY ( configMAX_PRIORITIES - 1 ) + +/* The size, in words (not bytes), of the stack allocated to the FreeRTOS+TCP + * task. This setting is less important when the FreeRTOS Win32 simulator is used + * as the Win32 simulator only stores a fixed amount of information on the task + * stack. FreeRTOS includes optional stack overflow detection, see: + * http://www.freertos.org/Stacks-and-stack-overflow-checking.html */ +#define ipconfigIP_TASK_STACK_SIZE_WORDS ( configMINIMAL_STACK_SIZE * 5 ) + +/* ipconfigRAND32() is called by the IP stack to generate random numbers for + * things such as a DHCP transaction number or initial sequence number. Random + * number generation is performed via this macro to allow applications to use their + * own random number generation method. For example, it might be possible to + * generate a random number by sampling noise on an analogue input. */ +/* #define ipconfigRAND32() uxRand() */ + +/* If ipconfigUSE_NETWORK_EVENT_HOOK is set to 1 then FreeRTOS+TCP will call the + * network event hook at the appropriate times. If ipconfigUSE_NETWORK_EVENT_HOOK + * is not set to 1 then the network event hook will never be called. See + * http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/API/vApplicationIPNetworkEventHook.shtml + */ +#define ipconfigUSE_NETWORK_EVENT_HOOK 1 + +/* Sockets have a send block time attribute. If FreeRTOS_sendto() is called but + * a network buffer cannot be obtained then the calling task is held in the Blocked + * state (so other tasks can continue to executed) until either a network buffer + * becomes available or the send block time expires. If the send block time expires + * then the send operation is aborted. The maximum allowable send block time is + * capped to the value set by ipconfigMAX_SEND_BLOCK_TIME_TICKS. Capping the + * maximum allowable send block time prevents prevents a deadlock occurring when + * all the network buffers are in use and the tasks that process (and subsequently + * free) the network buffers are themselves blocked waiting for a network buffer. + * ipconfigMAX_SEND_BLOCK_TIME_TICKS is specified in RTOS ticks. A time in + * milliseconds can be converted to a time in ticks by dividing the time in + * milliseconds by portTICK_PERIOD_MS. */ +#define ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS ( 5000U ) + +/* If ipconfigUSE_DHCP is 1 then FreeRTOS+TCP will attempt to retrieve an IP + * address, netmask, DNS server address and gateway address from a DHCP server. If + * ipconfigUSE_DHCP is 0 then FreeRTOS+TCP will use a static IP address. The + * stack will revert to using the static IP address even when ipconfigUSE_DHCP is + * set to 1 if a valid configuration cannot be obtained from a DHCP server for any + * reason. The static configuration used is that passed into the stack by the + * FreeRTOS_IPInit() function call. */ +#define ipconfigUSE_DHCP 1 +#define ipconfigUSE_DHCP_HOOK 0 + +/* When ipconfigUSE_DHCP is set to 1, DHCP requests will be sent out at + * increasing time intervals until either a reply is received from a DHCP server + * and accepted, or the interval between transmissions reaches + * ipconfigMAXIMUM_DISCOVER_TX_PERIOD. The IP stack will revert to using the + * static IP address passed as a parameter to FreeRTOS_IPInit() if the + * re-transmission time interval reaches ipconfigMAXIMUM_DISCOVER_TX_PERIOD without + * a DHCP reply being received. */ +#define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( 120000U ) + +/* The ARP cache is a table that maps IP addresses to MAC addresses. The IP + * stack can only send a UDP message to a remove IP address if it knowns the MAC + * address associated with the IP address, or the MAC address of the router used to + * contact the remote IP address. When a UDP message is received from a remote IP + * address the MAC address and IP address are added to the ARP cache. When a UDP + * message is sent to a remote IP address that does not already appear in the ARP + * cache then the UDP message is replaced by a ARP message that solicits the + * required MAC address information. ipconfigARP_CACHE_ENTRIES defines the maximum + * number of entries that can exist in the ARP table at any one time. */ +#define ipconfigARP_CACHE_ENTRIES 6 + +/* ARP requests that do not result in an ARP response will be re-transmitted a + * maximum of ipconfigMAX_ARP_RETRANSMISSIONS times before the ARP request is + * aborted. */ +#define ipconfigMAX_ARP_RETRANSMISSIONS ( 5 ) + +/* ipconfigMAX_ARP_AGE defines the maximum time between an entry in the ARP + * table being created or refreshed and the entry being removed because it is stale. + * New ARP requests are sent for ARP cache entries that are nearing their maximum + * age. ipconfigMAX_ARP_AGE is specified in tens of seconds, so a value of 150 is + * equal to 1500 seconds (or 25 minutes). */ +#define ipconfigMAX_ARP_AGE 150 + +/* Implementing FreeRTOS_inet_addr() necessitates the use of string handling + * routines, which are relatively large. To save code space the full + * FreeRTOS_inet_addr() implementation is made optional, and a smaller and faster + * alternative called FreeRTOS_inet_addr_quick() is provided. FreeRTOS_inet_addr() + * takes an IP in decimal dot format (for example, "192.168.0.1") as its parameter. + * FreeRTOS_inet_addr_quick() takes an IP address as four separate numerical octets + * (for example, 192, 168, 0, 1) as its parameters. If + * ipconfigINCLUDE_FULL_INET_ADDR is set to 1 then both FreeRTOS_inet_addr() and + * FreeRTOS_indet_addr_quick() are available. If ipconfigINCLUDE_FULL_INET_ADDR is + * not set to 1 then only FreeRTOS_indet_addr_quick() is available. */ +#define ipconfigINCLUDE_FULL_INET_ADDR 1 + +/* ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS defines the total number of network buffer that + * are available to the IP stack. The total number of network buffers is limited + * to ensure the total amount of RAM that can be consumed by the IP stack is capped + * to a pre-determinable value. */ +#define ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS 60 + +/* A FreeRTOS queue is used to send events from application tasks to the IP + * stack. ipconfigEVENT_QUEUE_LENGTH sets the maximum number of events that can + * be queued for processing at any one time. The event queue must be a minimum of + * 5 greater than the total number of network buffers. */ +#define ipconfigEVENT_QUEUE_LENGTH ( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS + 5 ) + +/* The address of a socket is the combination of its IP address and its port + * number. FreeRTOS_bind() is used to manually allocate a port number to a socket + * (to 'bind' the socket to a port), but manual binding is not normally necessary + * for client sockets (those sockets that initiate outgoing connections rather than + * wait for incoming connections on a known port number). If + * ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 1 then calling + * FreeRTOS_sendto() on a socket that has not yet been bound will result in the IP + * stack automatically binding the socket to a port number from the range + * socketAUTO_PORT_ALLOCATION_START_NUMBER to 0xffff. If + * ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 0 then calling FreeRTOS_sendto() + * on a socket that has not yet been bound will result in the send operation being + * aborted. */ +#define ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND 1 + +/* Defines the Time To Live (TTL) values used in outgoing UDP packets. */ +#define ipconfigUDP_TIME_TO_LIVE 128 +#define ipconfigTCP_TIME_TO_LIVE 128 /* also defined in FreeRTOSIPConfigDefaults.h */ + +/* USE_TCP: Use TCP and all its features */ +#define ipconfigUSE_TCP ( 1 ) + +/* USE_WIN: Let TCP use windowing mechanism. */ +#define ipconfigUSE_TCP_WIN ( 1 ) + +/* The MTU is the maximum number of bytes the payload of a network frame can + * contain. For normal Ethernet V2 frames the maximum MTU is 1500. Setting a + * lower value can save RAM, depending on the buffer management scheme used. If + * ipconfigCAN_FRAGMENT_OUTGOING_PACKETS is 1 then (ipconfigNETWORK_MTU - 28) must + * be divisible by 8. */ +#define ipconfigNETWORK_MTU 1500U + +/* Set ipconfigUSE_DNS to 1 to include a basic DNS client/resolver. DNS is used + * through the FreeRTOS_gethostbyname() API function. */ +#define ipconfigUSE_DNS 1 + +/* If ipconfigREPLY_TO_INCOMING_PINGS is set to 1 then the IP stack will + * generate replies to incoming ICMP echo (ping) requests. */ +#define ipconfigREPLY_TO_INCOMING_PINGS 1 + +/* If ipconfigSUPPORT_OUTGOING_PINGS is set to 1 then the + * FreeRTOS_SendPingRequest() API function is available. */ +#define ipconfigSUPPORT_OUTGOING_PINGS 0 + +/* If ipconfigSUPPORT_SELECT_FUNCTION is set to 1 then the FreeRTOS_select() + * (and associated) API function is available. */ +#define ipconfigSUPPORT_SELECT_FUNCTION 0 + +/* If ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES is set to 1 then Ethernet frames + * that are not in Ethernet II format will be dropped. This option is included for + * potential future IP stack developments. */ +#define ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES 1 + +/* If ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES is set to 1 then it is the + * responsibility of the Ethernet interface to filter out packets that are of no + * interest. If the Ethernet interface does not implement this functionality, then + * set ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES to 0 to have the IP stack + * perform the filtering instead (it is much less efficient for the stack to do it + * because the packet will already have been passed into the stack). If the + * Ethernet driver does all the necessary filtering in hardware then software + * filtering can be removed by using a value other than 1 or 0. */ +#define ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES 1 + +/* Advanced only: in order to access 32-bit fields in the IP packets with + * 32-bit memory instructions, all packets will be stored 32-bit-aligned, plus 16-bits. + * This has to do with the contents of the IP-packets: all 32-bit fields are + * 32-bit-aligned, plus 16-bit(!) */ +#define ipconfigPACKET_FILLER_SIZE 2U + +/* Define the size of the pool of TCP window descriptors. On the average, each + * TCP socket will use up to 2 x 6 descriptors, meaning that it can have 2 x 6 + * outstanding packets (for Rx and Tx). When using up to 10 TP sockets + * simultaneously, one could define TCP_WIN_SEG_COUNT as 120. */ +#define ipconfigTCP_WIN_SEG_COUNT 240 + +/* Each TCP socket has a circular buffers for Rx and Tx, which have a fixed + * maximum size. Define the size of Rx buffer for TCP sockets. */ +#define ipconfigTCP_RX_BUFFER_LENGTH ( 10000 ) + +/* Define the size of Tx buffer for TCP sockets. */ +#define ipconfigTCP_TX_BUFFER_LENGTH ( 10000 ) + +/* When using call-back handlers, the driver may check if the handler points to + * real program memory (RAM or flash) or just has a random non-zero value. */ +#define ipconfigIS_VALID_PROG_ADDRESS( x ) ( ( x ) != NULL ) + +/* Include support for TCP hang protection. All sockets in a connecting or + * disconnecting stage will timeout after a period of non-activity. */ +#define ipconfigTCP_HANG_PROTECTION ( 1 ) +#define ipconfigTCP_HANG_PROTECTION_TIME ( 30 ) + +/* Include support for TCP keep-alive messages. */ +#define ipconfigTCP_KEEP_ALIVE ( 1 ) +#define ipconfigTCP_KEEP_ALIVE_INTERVAL ( 20 ) /* in seconds */ + +/* Include all API's and code that is needed for the IPv4 protocol. + * When defined as zero, the application should uses IPv6. */ +#define ipconfigUSE_IPv4 ( 1 ) + +/* + * If defined this macro enables the APIs that are backward compatible + * with single end point IPv4 version of the FreeRTOS+TCP library. + */ +#define ipconfigIPv4_BACKWARD_COMPATIBLE 0 + +#endif /* FREERTOS_IP_CONFIG_H */ diff --git a/applications/object_detection/configs/isp_config/CMakeLists.txt b/applications/object_detection/configs/isp_config/CMakeLists.txt new file mode 100644 index 00000000..f3e94e3e --- /dev/null +++ b/applications/object_detection/configs/isp_config/CMakeLists.txt @@ -0,0 +1,15 @@ +# Copyright 2023-2024 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +add_library(isp_firmware_config INTERFACE) + +target_include_directories(isp_firmware_config + INTERFACE + . +) + +target_link_libraries(isp_firmware_config + INTERFACE + arm-corstone-platform-bsp +) diff --git a/applications/object_detection/configs/isp_config/acamera_firmware_config.h b/applications/object_detection/configs/isp_config/acamera_firmware_config.h new file mode 100644 index 00000000..db616f84 --- /dev/null +++ b/applications/object_detection/configs/isp_config/acamera_firmware_config.h @@ -0,0 +1,238 @@ +/* + * + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright (c) 2024, Arm Limited. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * - Neither the name of ARM nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef __ACAMERA_FIRMWARE_CONFIG_H__ +#define __ACAMERA_FIRMWARE_CONFIG_H__ + +#include "platform_base_address.h" + +/* Autogenerated firmware settings. */ +#define ACAMERA_EVENT_QUEUE_SIZE 256 +#define ACAMERA_FW_SHP_DETECTED_MAXIMUM 1023 +#define ACAMERA_IRQ_AE_STATS 3 +#define ACAMERA_IRQ_AF2_STATS 1 +#define ACAMERA_IRQ_ANTIFOG_HIST 14 +#define ACAMERA_IRQ_AWB_STATS 4 +#define ACAMERA_IRQ_DFE_FRAME_END 17 +#define ACAMERA_IRQ_FRAME_END 0 +#define ACAMERA_IRQ_FRAME_START 7 +#define ACAMERA_IRQ_FRAME_WRITER_DS 6 +#define ACAMERA_IRQ_FRAME_WRITER_FR 5 +#define ACAMERA_ISP_PROFILING 0 +#define ACAMERA_ISP_PROFILING_INIT 0 +#define AE_CENTER_ZONES 65535 +#define AF_SPOT_COUNT_X 5 +#define AF_SPOT_COUNT_Y 5 +#define ANALOG_GAIN_ACCURACY ( 1 << ( LOG2_GAIN_SHIFT - 2 ) ) +#define AWB_BG_MAX_GAIN 0 +#define BLACK_LEVEL_SHIFT_DG 8 +#define BLACK_LEVEL_SHIFT_WB 8 +#define CALIBRATION_IRIDIX_AVG_COEF_INIT 0 +#define CM_SATURATION_TARGET 128 +#define CONNECTION_BUFFER_SIZE ( 26 * 1024 ) +#define CONNECTION_IN_THREAD 1 +#define DMA_WRITER_DEFAULT_BUFFER_NO 4 +#define EXPOSURE_DRIVES_LONG_INTEGRATION_TIME 0 +#define FILTER_LONG_INT_TIME 0 +#define FILTER_SHORT_INT_TIME 0 +#define FIRMWARE_CONTEXT_NUMBER 1 +#define FPGA_HAS_HDMI 0 +#define FSM_NAMES \ + { \ + "GENERIC", "SENSOR", "CMOS", "GENERAL", "AE_ACAMERA", "AWB_ACAMERA", "AF_ACAMERA", "COLOR_MATRIX", \ + "PURPLE_FRINGE", "IRIDIX_ACAMERA", "NOISE_REDUCTION", "CROP", "SHARPENING", "MATRIX_YUV", "GAMMA_ACAMERA", \ + "DMA_WRITER", "MONITOR" \ + } +#define FW_ALG_SUPPORT_SHARED_LIB 0 +#define FW_DO_INITIALIZATION 1 +#define FW_DS1_OUTPUT_FORMAT_PIPE PIPE_OUT_RGB +#define FW_EVT_QUEUE_TIMEOUT_MS 100 +#define FW_FR_OUTPUT_FORMAT_PIPE PIPE_OUT_RGB +#define FW_HAS_CONTROL_CHANNEL 0 +#define FW_HAS_CUSTOM_SETTINGS 1 +#define FW_INPUT_FORMAT DMA_FORMAT_RAW12 +#define FW_LOG_FROM_ISR 0 +#define FW_LOG_HAS_SRC 0 +#define FW_LOG_HAS_TIME 1 +#define FW_LOG_LEVEL LOG_NOTICE +#define FW_LOG_MASK 4294967295 +#define FW_LOG_REAL_TIME 0 +#define FW_OUTPUT_FORMAT DMA_FORMAT_A2R10G10B10 +#define FW_OUTPUT_FORMAT_SECONDARY DMA_FORMAT_DISABLE +#define FW_USE_SYSTEM_DMA 0 +#define FW_ZONE_AE 0 +#define HDMI_TDA19988 1 +#define IRIDIX_BYPASS_MAX_STR_CLIP 0 +#define IRIDIX_HAS_PRE_POST_GAMMA_LUT_LINEAR 0 +#define IRIDIX_STRENGTH_BY_EXP_RATIO 0 +#define IRIDIX_STRENGTH_TARGET 128 +#define ISP_BINARY_SEQUENCE 0 +#define ISP_CONTROLS_DMA_READER 1 +#define ISP_DEFAULT_AF_ZONES_HOR 15 +#define ISP_DEFAULT_AF_ZONES_VERT 15 +#define ISP_DISPLAY_MODE 1080 +#define ISP_DMA_RAW_CAPTURE 0 +#define ISP_FULL_HISTOGRAM_SIZE 1024 +#define ISP_FW_BUILD 1 +#define ISP_GAMMA_LUT_SIZE 129 +#define ISP_HAS_AE_ACAMERA_FSM 1 +#define ISP_HAS_AF 1 +#define ISP_HAS_AF_ACAMERA_FSM 1 +#define ISP_HAS_AWB_ACAMERA_FSM 1 +#define ISP_HAS_CMOS_FSM 1 +#define ISP_HAS_COLOR_MATRIX_FSM 1 +#define ISP_HAS_CONNECTION_BUFFER 0 +#define ISP_HAS_CONNECTION_CHARDEV 0 +#define ISP_HAS_CONNECTION_DEBUG 0 +#define ISP_HAS_CONNECTION_SOCKET 0 +#define ISP_HAS_CONNECTION_SOCKET_PORT 0 +#define ISP_HAS_CONNECTION_UART 1 +#define ISP_HAS_CROP_FSM 1 +#define ISP_HAS_DMA_WRITER_FSM 1 +#define ISP_HAS_DS1 1 +#define ISP_HAS_FPGA_WRAPPER 0 +#define ISP_HAS_GAMMA_ACAMERA_FSM 1 +#define ISP_HAS_GENERAL_FSM 1 +#define ISP_HAS_IRIDIX_ACAMERA_FSM 1 +#define ISP_HAS_MATRIX_YUV_FSM 1 +#define ISP_HAS_META_CB 0 +#define ISP_HAS_MONITOR_FSM 1 +#define ISP_HAS_NOISE_REDUCTION_FSM 1 +#define ISP_HAS_PURPLE_FRINGE_FSM 1 +#define ISP_HAS_RAW_CB 0 +#define ISP_HAS_SENSOR_FSM 1 +#define ISP_HAS_SHARPENING_FSM 1 +#define ISP_HAS_WDR_FRAME_BUFFER 0 +#define ISP_HW_IS_MALI_C32_C52 0 +#define ISP_INPUT_BITS 20 +#define ISP_IRQ_DISABLE_ALL_IRQ 4294967295 +#define ISP_IRQ_MASK_VECTOR 4289200114 +#define ISP_MAX_CALIBRATION_DATA_SIZE ( 128 * 1024 ) +#define ISP_MAX_SENSOR_MODES 16 +#define ISP_SENSOR_DRIVER_AD5821 0 +#define ISP_SENSOR_DRIVER_AN41908A 0 +#define ISP_SENSOR_DRIVER_BU64295 0 +#define ISP_SENSOR_DRIVER_BU64748 0 +#define ISP_SENSOR_DRIVER_DONGWOON 0 +#define ISP_SENSOR_DRIVER_DW9800 0 +#define ISP_SENSOR_DRIVER_FP5510A 0 +#define ISP_SENSOR_DRIVER_LC898201 0 +#define ISP_SENSOR_DRIVER_MODEL 0 +#define ISP_SENSOR_DRIVER_NULL 1 +#define ISP_SENSOR_DRIVER_ROHM 0 +#define ISP_SENSOR_DRIVER_V4L2 0 +#define ISP_SOC_DMA_BUS_OFFSET 0 +#define ISP_SOC_START_ADDR ISP_BASE_NS +#define ISP_VCLK_FREQ_MHZ 100 +#define ISP_WDR_DEFAULT_MODE WDR_MODE_LINEAR +#define ISP_WDR_SWITCH 1 +#define KERNEL_MODULE 0 +#define LOG2_GAIN_SHIFT 18 +#define LOG_MODULE_AE_ACAMERA 4 +#define LOG_MODULE_AE_ACAMERA_MASK 16 +#define LOG_MODULE_AF_ACAMERA 6 +#define LOG_MODULE_AF_ACAMERA_MASK 64 +#define LOG_MODULE_ALL 131071 +#define LOG_MODULE_AWB_ACAMERA 5 +#define LOG_MODULE_AWB_ACAMERA_MASK 32 +#define LOG_MODULE_CMOS 2 +#define LOG_MODULE_CMOS_MASK 4 +#define LOG_MODULE_COLOR_MATRIX 7 +#define LOG_MODULE_COLOR_MATRIX_MASK 128 +#define LOG_MODULE_CROP 11 +#define LOG_MODULE_CROP_MASK 2048 +#define LOG_MODULE_DMA_WRITER 15 +#define LOG_MODULE_DMA_WRITER_MASK 32768 +#define LOG_MODULE_GAMMA_ACAMERA 14 +#define LOG_MODULE_GAMMA_ACAMERA_MASK 16384 +#define LOG_MODULE_GENERAL 3 +#define LOG_MODULE_GENERAL_MASK 8 +#define LOG_MODULE_GENERIC 0 +#define LOG_MODULE_GENERIC_MASK 1 +#define LOG_MODULE_IRIDIX_ACAMERA 9 +#define LOG_MODULE_IRIDIX_ACAMERA_MASK 512 +#define LOG_MODULE_MATRIX_YUV 13 +#define LOG_MODULE_MATRIX_YUV_MASK 8192 +#define LOG_MODULE_MAX 17 +#define LOG_MODULE_MONITOR 16 +#define LOG_MODULE_MONITOR_MASK 65536 +#define LOG_MODULE_NOISE_REDUCTION 10 +#define LOG_MODULE_NOISE_REDUCTION_MASK 1024 +#define LOG_MODULE_PURPLE_FRINGE 8 +#define LOG_MODULE_PURPLE_FRINGE_MASK 256 +#define LOG_MODULE_SENSOR 1 +#define LOG_MODULE_SENSOR_MASK 2 +#define LOG_MODULE_SHARPENING 12 +#define LOG_MODULE_SHARPENING_MASK 4096 +#define MAX_REG_TRACK_ENTRIES 600 +#define OVEREXPOSE_TO_KEEP_ANTIFLICKER 0 +#define SENSOR_BINARY_SEQUENCE 0 +#define SENSOR_DEFAULT_EXP_NUM 1 +#define SENSOR_DEFAULT_PRESET_MODE 0 +#define SENSOR_HAS_FLASH 0 +#define SENSOR_HW_INTERFACE ACameraDefault +#define SENSOR_MASTER_CLOCK 27 +#define SENSOR_SUPPORT_OTP 0 +#define SYSTEM_AE_COMPENSATION_DEFAULT 128 +#define SYSTEM_ANTI_FLICKER_FREQUENCY_DEFAULT 50 +#define SYSTEM_EXPOSURE_PARTITION_VALUE_COUNT 10 +#define SYSTEM_EXPOSURE_RATIO_DEFAULT 8 +#define SYSTEM_MANUAL_EXPOSURE_RATIO_DEFAULT 0 +#define SYSTEM_MAXIMUM_IRIDIX_STRENGTH_DEFAULT 255 +#define SYSTEM_MINIMUM_IRIDIX_STRENGTH_DEFAULT 0 +#define USER_MODULE 0 +#define V4L2_INTERFACE_BUILD 0 +#define V4L2_SOC_SUBDEV_ENABLE 0 + +/* Autogenerated ISP core settings. DO NOT EDIT. */ +#define ISP_CORE_ID 0x58F8E91F +#define ISP_CONFIG_PING 1 +#define ISP_CONFIG_PONG 0 +#define ISP_CONFIG_LUT_OFFSET 0x054A8 +#define ISP_CONFIG_PING_OFFSET 0x18E88 +#define ISP_CONFIG_PING_SIZE 0x17FC0 +#define ISP_METERING_ZONES_MAX_V 15 +#define ISP_METERING_ZONES_MAX_H 15 +#define ISP_METERING_OFFSET_AWB 464 +#define ISP_METERING_OFFSET_AF 928 +#define ISP_INTERRUPT_EVENT_NONES_COUNT 16 +#define ISP_INTERRUPT_EVENT_ISP_START_FRAME_START 0 +#define ISP_INTERRUPT_EVENT_ISP_END_FRAME_END 1 +#define ISP_INTERRUPT_EVENT_METERING_AF 4 +#define ISP_INTERRUPT_EVENT_METERING_AEXP 5 +#define ISP_INTERRUPT_EVENT_METERING_AWB 6 +#define ISP_INTERRUPT_EVENT_ANTIFOG_HIST 8 +#define ISP_INTERRUPT_EVENT_BROKEN_FRAME 3 +#define ISP_INTERRUPT_EVENT_MULTICTX_ERROR 2 +#define ISP_INTERRUPT_EVENT_DMA_ERROR 22 +#define ISP_INTERRUPT_EVENT_WATCHDOG_EXP 19 +#define ISP_INTERRUPT_EVENT_FRAME_COLLISION 20 + +#endif /* __ACAMERA_FIRMWARE_CONFIG_H__*/ diff --git a/applications/object_detection/configs/isp_config/acamera_interface_config.h b/applications/object_detection/configs/isp_config/acamera_interface_config.h new file mode 100644 index 00000000..3934dea4 --- /dev/null +++ b/applications/object_detection/configs/isp_config/acamera_interface_config.h @@ -0,0 +1,49 @@ +/* + * + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright (c) 2024, Arm Limited. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * - Neither the name of ARM nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef __ACAMERA_INTERFACE_CONFIG_H__ +#define __ACAMERA_INTERFACE_CONFIG_H__ + +extern volatile uint32_t STREAM_ENABLED; + +#if 0 + #define FVP_SENSOR_WIDTH 1920 + #define FVP_SENSOR_HEIGHT 1080 +#else + #define FVP_SENSOR_WIDTH 576 + #define FVP_SENSOR_HEIGHT 576 +#endif +/* 0:RGGB 2:GBRG */ +#define FVP_SENSOR_RGGB_START 2 +#define FVP_SENSOR_DEPTH 12 +#define FVP_SENSOR_TWIDTH FVP_SENSOR_WIDTH +#define FVP_SENSOR_THEIGHT FVP_SENSOR_HEIGHT + +#endif /* ifndef __ACAMERA_INTERFACE_CONFIG_H__ */ diff --git a/applications/object_detection/configs/mbedtls_config/CMakeLists.txt b/applications/object_detection/configs/mbedtls_config/CMakeLists.txt new file mode 100644 index 00000000..a3d55dd6 --- /dev/null +++ b/applications/object_detection/configs/mbedtls_config/CMakeLists.txt @@ -0,0 +1,18 @@ +# Copyright 2023-2024, Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +target_include_directories(mbedtls-config + INTERFACE + . +) + +target_compile_definitions(mbedtls-config + INTERFACE + MBEDTLS_CONFIG_FILE="aws_mbedtls_config.h" +) + +target_link_libraries(mbedtls-config + INTERFACE + freertos_kernel +) diff --git a/applications/object_detection/configs/mbedtls_config/aws_mbedtls_config.h b/applications/object_detection/configs/mbedtls_config/aws_mbedtls_config.h new file mode 100644 index 00000000..d5be8045 --- /dev/null +++ b/applications/object_detection/configs/mbedtls_config/aws_mbedtls_config.h @@ -0,0 +1,3274 @@ +/** + * \file mbedtls_config.h + * + * \brief Configuration options (set of defines) + * + * This set of compile-time options may be used to enable + * or disable features selectively, and reduce the global + * memory footprint. + */ + +/* + * Copyright The Mbed TLS Contributors + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * This is an optional version symbol that enables compatibility handling of + * config files. + * + * It is equal to the #MBEDTLS_VERSION_NUMBER of the Mbed TLS version that + * introduced the config format we want to be compatible with. + */ +/*#define MBEDTLS_CONFIG_VERSION 0x03000000 */ + +/** + * \name SECTION: System support + * + * This section sets system specific settings. + * \{ + */ + +/** + * \def MBEDTLS_HAVE_ASM + * + * The compiler has support for asm(). + * + * Requires support for asm() in compiler. + * + * Used in: + * library/aria.c + * library/bn_mul.h + * + * Required by: + * MBEDTLS_AESNI_C + * MBEDTLS_PADLOCK_C + * + * Comment to disable the use of assembly code. + */ +#define MBEDTLS_HAVE_ASM + +/** + * \def MBEDTLS_NO_UDBL_DIVISION + * + * The platform lacks support for double-width integer division (64-bit + * division on a 32-bit platform, 128-bit division on a 64-bit platform). + * + * Used in: + * include/mbedtls/bignum.h + * library/bignum.c + * + * The bignum code uses double-width division to speed up some operations. + * Double-width division is often implemented in software that needs to + * be linked with the program. The presence of a double-width integer + * type is usually detected automatically through preprocessor macros, + * but the automatic detection cannot know whether the code needs to + * and can be linked with an implementation of division for that type. + * By default division is assumed to be usable if the type is present. + * Uncomment this option to prevent the use of double-width division. + * + * Note that division for the native integer type is always required. + * Furthermore, a 64-bit type is always required even on a 32-bit + * platform, but it need not support multiplication or division. In some + * cases it is also desirable to disable some double-width operations. For + * example, if double-width division is implemented in software, disabling + * it can reduce code size in some embedded targets. + */ +/*#define MBEDTLS_NO_UDBL_DIVISION */ + +/** + * \def MBEDTLS_NO_64BIT_MULTIPLICATION + * + * The platform lacks support for 32x32 -> 64-bit multiplication. + * + * Used in: + * library/poly1305.c + * + * Some parts of the library may use multiplication of two unsigned 32-bit + * operands with a 64-bit result in order to speed up computations. On some + * platforms, this is not available in hardware and has to be implemented in + * software, usually in a library provided by the toolchain. + * + * Sometimes it is not desirable to have to link to that library. This option + * removes the dependency of that library on platforms that lack a hardware + * 64-bit multiplier by embedding a software implementation in Mbed TLS. + * + * Note that depending on the compiler, this may decrease performance compared + * to using the library function provided by the toolchain. + */ +/*#define MBEDTLS_NO_64BIT_MULTIPLICATION */ + +/** + * \def MBEDTLS_HAVE_SSE2 + * + * CPU supports SSE2 instruction set. + * + * Uncomment if the CPU supports SSE2 (IA-32 specific). + */ +/*#define MBEDTLS_HAVE_SSE2 */ + +/** + * \def MBEDTLS_HAVE_TIME + * + * System has time.h and time(). + * The time does not need to be correct, only time differences are used, + * by contrast with MBEDTLS_HAVE_TIME_DATE + * + * Defining MBEDTLS_HAVE_TIME allows you to specify MBEDTLS_PLATFORM_TIME_ALT, + * MBEDTLS_PLATFORM_TIME_MACRO, MBEDTLS_PLATFORM_TIME_TYPE_MACRO and + * MBEDTLS_PLATFORM_STD_TIME. + * + * Comment if your system does not support time functions + */ +/*#define MBEDTLS_HAVE_TIME */ + +/** + * \def MBEDTLS_HAVE_TIME_DATE + * + * System has time.h, time(), and an implementation for + * mbedtls_platform_gmtime_r() (see below). + * The time needs to be correct (not necessarily very accurate, but at least + * the date should be correct). This is used to verify the validity period of + * X.509 certificates. + * + * Comment if your system does not have a correct clock. + * + * \note mbedtls_platform_gmtime_r() is an abstraction in platform_util.h that + * behaves similarly to the gmtime_r() function from the C standard. Refer to + * the documentation for mbedtls_platform_gmtime_r() for more information. + * + * \note It is possible to configure an implementation for + * mbedtls_platform_gmtime_r() at compile-time by using the macro + * MBEDTLS_PLATFORM_GMTIME_R_ALT. + */ +/*#define MBEDTLS_HAVE_TIME_DATE */ + +/** + * \def MBEDTLS_PLATFORM_MEMORY + * + * Enable the memory allocation layer. + * + * By default mbed TLS uses the system-provided calloc() and free(). + * This allows different allocators (self-implemented or provided) to be + * provided to the platform abstraction layer. + * + * Enabling MBEDTLS_PLATFORM_MEMORY without the + * MBEDTLS_PLATFORM_{FREE,CALLOC}_MACROs will provide + * "mbedtls_platform_set_calloc_free()" allowing you to set an alternative calloc() and + * free() function pointer at runtime. + * + * Enabling MBEDTLS_PLATFORM_MEMORY and specifying + * MBEDTLS_PLATFORM_{CALLOC,FREE}_MACROs will allow you to specify the + * alternate function at compile time. + * + * Requires: MBEDTLS_PLATFORM_C + * + * Enable this layer to allow use of alternative memory allocators. + */ +#define MBEDTLS_PLATFORM_MEMORY + +#include +void * mbedtls_platform_calloc( size_t nmemb, + size_t size ); +void mbedtls_platform_free( void * ptr ); + +/** + * \def MBEDTLS_PLATFORM_NO_STD_FUNCTIONS + * + * Do not assign standard functions in the platform layer (e.g. calloc() to + * MBEDTLS_PLATFORM_STD_CALLOC and printf() to MBEDTLS_PLATFORM_STD_PRINTF) + * + * This makes sure there are no linking errors on platforms that do not support + * these functions. You will HAVE to provide alternatives, either at runtime + * via the platform_set_xxx() functions or at compile time by setting + * the MBEDTLS_PLATFORM_STD_XXX defines, or enabling a + * MBEDTLS_PLATFORM_XXX_MACRO. + * + * Requires: MBEDTLS_PLATFORM_C + * + * Uncomment to prevent default assignment of standard functions in the + * platform layer. + */ +/*#define MBEDTLS_PLATFORM_NO_STD_FUNCTIONS */ + +/** + * \def MBEDTLS_PLATFORM_EXIT_ALT + * + * MBEDTLS_PLATFORM_XXX_ALT: Uncomment a macro to let mbed TLS support the + * function in the platform abstraction layer. + * + * Example: In case you uncomment MBEDTLS_PLATFORM_PRINTF_ALT, mbed TLS will + * provide a function "mbedtls_platform_set_printf()" that allows you to set an + * alternative printf function pointer. + * + * All these define require MBEDTLS_PLATFORM_C to be defined! + * + * \note MBEDTLS_PLATFORM_SNPRINTF_ALT is required on Windows; + * it will be enabled automatically by check_config.h + * + * \warning MBEDTLS_PLATFORM_XXX_ALT cannot be defined at the same time as + * MBEDTLS_PLATFORM_XXX_MACRO! + * + * Requires: MBEDTLS_PLATFORM_TIME_ALT requires MBEDTLS_HAVE_TIME + * + * Uncomment a macro to enable alternate implementation of specific base + * platform function + */ +/*#define MBEDTLS_PLATFORM_EXIT_ALT */ +/*#define MBEDTLS_PLATFORM_TIME_ALT */ +/*#define MBEDTLS_PLATFORM_FPRINTF_ALT */ +/*#define MBEDTLS_PLATFORM_PRINTF_ALT */ +/*#define MBEDTLS_PLATFORM_SNPRINTF_ALT */ +/*#define MBEDTLS_PLATFORM_VSNPRINTF_ALT */ +/*#define MBEDTLS_PLATFORM_NV_SEED_ALT */ +/*#define MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT */ + +/** + * \def MBEDTLS_DEPRECATED_WARNING + * + * Mark deprecated functions and features so that they generate a warning if + * used. Functionality deprecated in one version will usually be removed in the + * next version. You can enable this to help you prepare the transition to a + * new major version by making sure your code is not using this functionality. + * + * This only works with GCC and Clang. With other compilers, you may want to + * use MBEDTLS_DEPRECATED_REMOVED + * + * Uncomment to get warnings on using deprecated functions and features. + */ +#define MBEDTLS_DEPRECATED_WARNING + +/** + * \def MBEDTLS_DEPRECATED_REMOVED + * + * Remove deprecated functions and features so that they generate an error if + * used. Functionality deprecated in one version will usually be removed in the + * next version. You can enable this to help you prepare the transition to a + * new major version by making sure your code is not using this functionality. + * + * Uncomment to get errors on using deprecated functions and features. + */ +/*#define MBEDTLS_DEPRECATED_REMOVED */ + +/* \} name SECTION: System support */ + +/** + * \name SECTION: mbed TLS feature support + * + * This section sets support for features that are or are not needed + * within the modules that are enabled. + * \{ + */ + +/** + * \def MBEDTLS_TIMING_ALT + * + * Uncomment to provide your own alternate implementation for + * mbedtls_timing_get_timer(), mbedtls_set_alarm(), mbedtls_set/get_delay() + * + * Only works if you have MBEDTLS_TIMING_C enabled. + * + * You will need to provide a header "timing_alt.h" and an implementation at + * compile time. + */ +/*#define MBEDTLS_TIMING_ALT */ + +/** + * \def MBEDTLS_AES_ALT + * + * MBEDTLS__MODULE_NAME__ALT: Uncomment a macro to let mbed TLS use your + * alternate core implementation of a symmetric crypto, an arithmetic or hash + * module (e.g. platform specific assembly optimized implementations). Keep + * in mind that the function prototypes should remain the same. + * + * This replaces the whole module. If you only want to replace one of the + * functions, use one of the MBEDTLS__FUNCTION_NAME__ALT flags. + * + * Example: In case you uncomment MBEDTLS_AES_ALT, mbed TLS will no longer + * provide the "struct mbedtls_aes_context" definition and omit the base + * function declarations and implementations. "aes_alt.h" will be included from + * "aes.h" to include the new function definitions. + * + * Uncomment a macro to enable alternate implementation of the corresponding + * module. + * + * \warning MD5, DES and SHA-1 are considered weak and their + * use constitutes a security risk. If possible, we recommend + * avoiding dependencies on them, and considering stronger message + * digests and ciphers instead. + * + */ +/*#define MBEDTLS_AES_ALT */ +/*#define MBEDTLS_ARIA_ALT */ +/*#define MBEDTLS_CAMELLIA_ALT */ +/*#define MBEDTLS_CCM_ALT */ +/*#define MBEDTLS_CHACHA20_ALT */ +/*#define MBEDTLS_CHACHAPOLY_ALT */ +/*#define MBEDTLS_CMAC_ALT */ +/*#define MBEDTLS_DES_ALT */ +/*#define MBEDTLS_DHM_ALT */ +/*#define MBEDTLS_ECJPAKE_ALT */ +/*#define MBEDTLS_GCM_ALT */ +/*#define MBEDTLS_NIST_KW_ALT */ +/*#define MBEDTLS_MD5_ALT */ +/*#define MBEDTLS_POLY1305_ALT */ +/*#define MBEDTLS_RIPEMD160_ALT */ +/*#define MBEDTLS_RSA_ALT */ +/*#define MBEDTLS_SHA1_ALT */ +/*#define MBEDTLS_SHA256_ALT */ +/*#define MBEDTLS_SHA512_ALT */ + +/* + * When replacing the elliptic curve module, pleace consider, that it is + * implemented with two .c files: + * - ecp.c + * - ecp_curves.c + * You can replace them very much like all the other MBEDTLS__MODULE_NAME__ALT + * macros as described above. The only difference is that you have to make sure + * that you provide functionality for both .c files. + */ +/*#define MBEDTLS_ECP_ALT */ + +/** + * \def MBEDTLS_SHA256_PROCESS_ALT + * + * MBEDTLS__FUNCTION_NAME__ALT: Uncomment a macro to let mbed TLS use you + * alternate core implementation of symmetric crypto or hash function. Keep in + * mind that function prototypes should remain the same. + * + * This replaces only one function. The header file from mbed TLS is still + * used, in contrast to the MBEDTLS__MODULE_NAME__ALT flags. + * + * Example: In case you uncomment MBEDTLS_SHA256_PROCESS_ALT, mbed TLS will + * no longer provide the mbedtls_sha1_process() function, but it will still provide + * the other function (using your mbedtls_sha1_process() function) and the definition + * of mbedtls_sha1_context, so your implementation of mbedtls_sha1_process must be compatible + * with this definition. + * + * \note If you use the AES_xxx_ALT macros, then it is recommended to also set + * MBEDTLS_AES_ROM_TABLES in order to help the linker garbage-collect the AES + * tables. + * + * Uncomment a macro to enable alternate implementation of the corresponding + * function. + * + * \warning MD5, DES and SHA-1 are considered weak and their use + * constitutes a security risk. If possible, we recommend avoiding + * dependencies on them, and considering stronger message digests + * and ciphers instead. + * + * \warning If both MBEDTLS_ECDSA_SIGN_ALT and MBEDTLS_ECDSA_DETERMINISTIC are + * enabled, then the deterministic ECDH signature functions pass the + * the static HMAC-DRBG as RNG to mbedtls_ecdsa_sign(). Therefore + * alternative implementations should use the RNG only for generating + * the ephemeral key and nothing else. If this is not possible, then + * MBEDTLS_ECDSA_DETERMINISTIC should be disabled and an alternative + * implementation should be provided for mbedtls_ecdsa_sign_det_ext(). + * + */ +/*#define MBEDTLS_MD5_PROCESS_ALT */ +/*#define MBEDTLS_RIPEMD160_PROCESS_ALT */ +/*#define MBEDTLS_SHA1_PROCESS_ALT */ +/*#define MBEDTLS_SHA256_PROCESS_ALT */ +/*#define MBEDTLS_SHA512_PROCESS_ALT */ +/*#define MBEDTLS_DES_SETKEY_ALT */ +/*#define MBEDTLS_DES_CRYPT_ECB_ALT */ +/*#define MBEDTLS_DES3_CRYPT_ECB_ALT */ +/*#define MBEDTLS_AES_SETKEY_ENC_ALT */ +/*#define MBEDTLS_AES_SETKEY_DEC_ALT */ +/*#define MBEDTLS_AES_ENCRYPT_ALT */ +/*#define MBEDTLS_AES_DECRYPT_ALT */ +/*#define MBEDTLS_ECDH_GEN_PUBLIC_ALT */ +/*#define MBEDTLS_ECDH_COMPUTE_SHARED_ALT */ +/*#define MBEDTLS_ECDSA_VERIFY_ALT */ +/*#define MBEDTLS_ECDSA_SIGN_ALT */ +/*#define MBEDTLS_ECDSA_GENKEY_ALT */ + +/** + * \def MBEDTLS_ECP_INTERNAL_ALT + * + * Expose a part of the internal interface of the Elliptic Curve Point module. + * + * MBEDTLS_ECP__FUNCTION_NAME__ALT: Uncomment a macro to let mbed TLS use your + * alternative core implementation of elliptic curve arithmetic. Keep in mind + * that function prototypes should remain the same. + * + * This partially replaces one function. The header file from mbed TLS is still + * used, in contrast to the MBEDTLS_ECP_ALT flag. The original implementation + * is still present and it is used for group structures not supported by the + * alternative. + * + * The original implementation can in addition be removed by setting the + * MBEDTLS_ECP_NO_FALLBACK option, in which case any function for which the + * corresponding MBEDTLS_ECP__FUNCTION_NAME__ALT macro is defined will not be + * able to fallback to curves not supported by the alternative implementation. + * + * Any of these options become available by defining MBEDTLS_ECP_INTERNAL_ALT + * and implementing the following functions: + * unsigned char mbedtls_internal_ecp_grp_capable( + * const mbedtls_ecp_group *grp ) + * int mbedtls_internal_ecp_init( const mbedtls_ecp_group *grp ) + * void mbedtls_internal_ecp_free( const mbedtls_ecp_group *grp ) + * The mbedtls_internal_ecp_grp_capable function should return 1 if the + * replacement functions implement arithmetic for the given group and 0 + * otherwise. + * The functions mbedtls_internal_ecp_init and mbedtls_internal_ecp_free are + * called before and after each point operation and provide an opportunity to + * implement optimized set up and tear down instructions. + * + * Example: In case you set MBEDTLS_ECP_INTERNAL_ALT and + * MBEDTLS_ECP_DOUBLE_JAC_ALT, mbed TLS will still provide the ecp_double_jac() + * function, but will use your mbedtls_internal_ecp_double_jac() if the group + * for the operation is supported by your implementation (i.e. your + * mbedtls_internal_ecp_grp_capable() function returns 1 for this group). If the + * group is not supported by your implementation, then the original mbed TLS + * implementation of ecp_double_jac() is used instead, unless this fallback + * behaviour is disabled by setting MBEDTLS_ECP_NO_FALLBACK (in which case + * ecp_double_jac() will return MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE). + * + * The function prototypes and the definition of mbedtls_ecp_group and + * mbedtls_ecp_point will not change based on MBEDTLS_ECP_INTERNAL_ALT, so your + * implementation of mbedtls_internal_ecp__function_name__ must be compatible + * with their definitions. + * + * Uncomment a macro to enable alternate implementation of the corresponding + * function. + */ +/* Required for all the functions in this section */ +/*#define MBEDTLS_ECP_INTERNAL_ALT */ +/* Turn off software fallback for curves not supported in hardware */ +/*#define MBEDTLS_ECP_NO_FALLBACK */ +/* Support for Weierstrass curves with Jacobi representation */ +/*#define MBEDTLS_ECP_RANDOMIZE_JAC_ALT */ +/*#define MBEDTLS_ECP_ADD_MIXED_ALT */ +/*#define MBEDTLS_ECP_DOUBLE_JAC_ALT */ +/*#define MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT */ +/*#define MBEDTLS_ECP_NORMALIZE_JAC_ALT */ +/* Support for curves with Montgomery arithmetic */ +/*#define MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT */ +/*#define MBEDTLS_ECP_RANDOMIZE_MXZ_ALT */ +/*#define MBEDTLS_ECP_NORMALIZE_MXZ_ALT */ + +/** + * \def MBEDTLS_ENTROPY_HARDWARE_ALT + * + * Uncomment this macro to let mbed TLS use your own implementation of a + * hardware entropy collector. + * + * Your function must be called \c mbedtls_hardware_poll(), have the same + * prototype as declared in library/entropy_poll.h, and accept NULL as first + * argument. + * + * Uncomment to use your own hardware entropy collector. + */ +#define MBEDTLS_ENTROPY_HARDWARE_ALT + +/** + * \def MBEDTLS_AES_ROM_TABLES + * + * Use precomputed AES tables stored in ROM. + * + * Uncomment this macro to use precomputed AES tables stored in ROM. + * Comment this macro to generate AES tables in RAM at runtime. + * + * Tradeoff: Using precomputed ROM tables reduces RAM usage by ~8kb + * (or ~2kb if \c MBEDTLS_AES_FEWER_TABLES is used) and reduces the + * initialization time before the first AES operation can be performed. + * It comes at the cost of additional ~8kb ROM use (resp. ~2kb if \c + * MBEDTLS_AES_FEWER_TABLES below is used), and potentially degraded + * performance if ROM access is slower than RAM access. + * + * This option is independent of \c MBEDTLS_AES_FEWER_TABLES. + * + */ +#define MBEDTLS_AES_ROM_TABLES + +/** + * \def MBEDTLS_AES_FEWER_TABLES + * + * Use less ROM/RAM for AES tables. + * + * Uncommenting this macro omits 75% of the AES tables from + * ROM / RAM (depending on the value of \c MBEDTLS_AES_ROM_TABLES) + * by computing their values on the fly during operations + * (the tables are entry-wise rotations of one another). + * + * Tradeoff: Uncommenting this reduces the RAM / ROM footprint + * by ~6kb but at the cost of more arithmetic operations during + * runtime. Specifically, one has to compare 4 accesses within + * different tables to 4 accesses with additional arithmetic + * operations within the same table. The performance gain/loss + * depends on the system and memory details. + * + * This option is independent of \c MBEDTLS_AES_ROM_TABLES. + * + */ +#define MBEDTLS_AES_FEWER_TABLES + +/** + * \def MBEDTLS_CAMELLIA_SMALL_MEMORY + * + * Use less ROM for the Camellia implementation (saves about 768 bytes). + * + * Uncomment this macro to use less memory for Camellia. + */ +/*#define MBEDTLS_CAMELLIA_SMALL_MEMORY */ + +/** + * \def MBEDTLS_CIPHER_MODE_CBC + * + * Enable Cipher Block Chaining mode (CBC) for symmetric ciphers. + */ +#define MBEDTLS_CIPHER_MODE_CBC + +/** + * \def MBEDTLS_CIPHER_MODE_CFB + * + * Enable Cipher Feedback mode (CFB) for symmetric ciphers. + */ +#define MBEDTLS_CIPHER_MODE_CFB + +/** + * \def MBEDTLS_CIPHER_MODE_CTR + * + * Enable Counter Block Cipher mode (CTR) for symmetric ciphers. + */ +#define MBEDTLS_CIPHER_MODE_CTR + +/** + * \def MBEDTLS_CIPHER_MODE_OFB + * + * Enable Output Feedback mode (OFB) for symmetric ciphers. + */ +/*#define MBEDTLS_CIPHER_MODE_OFB */ + +/** + * \def MBEDTLS_CIPHER_MODE_XTS + * + * Enable Xor-encrypt-xor with ciphertext stealing mode (XTS) for AES. + */ +/*#define MBEDTLS_CIPHER_MODE_XTS */ + +/** + * \def MBEDTLS_CIPHER_NULL_CIPHER + * + * Enable NULL cipher. + * Warning: Only do so when you know what you are doing. This allows for + * encryption or channels without any security! + * + * To enable the following ciphersuites: + * MBEDTLS_TLS_ECDH_ECDSA_WITH_NULL_SHA + * MBEDTLS_TLS_ECDH_RSA_WITH_NULL_SHA + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_NULL_SHA + * MBEDTLS_TLS_ECDHE_RSA_WITH_NULL_SHA + * MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA384 + * MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA256 + * MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA256 + * MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA + * MBEDTLS_TLS_RSA_WITH_NULL_SHA256 + * MBEDTLS_TLS_RSA_WITH_NULL_SHA + * MBEDTLS_TLS_RSA_WITH_NULL_MD5 + * MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA256 + * MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA + * MBEDTLS_TLS_PSK_WITH_NULL_SHA384 + * MBEDTLS_TLS_PSK_WITH_NULL_SHA256 + * MBEDTLS_TLS_PSK_WITH_NULL_SHA + * + * Uncomment this macro to enable the NULL cipher and ciphersuites + */ +#define MBEDTLS_CIPHER_NULL_CIPHER + +/** + * \def MBEDTLS_CIPHER_PADDING_PKCS7 + * + * MBEDTLS_CIPHER_PADDING_XXX: Uncomment or comment macros to add support for + * specific padding modes in the cipher layer with cipher modes that support + * padding (e.g. CBC) + * + * If you disable all padding modes, only full blocks can be used with CBC. + * + * Enable padding modes in the cipher layer. + */ +#define MBEDTLS_CIPHER_PADDING_PKCS7 +#define MBEDTLS_CIPHER_PADDING_ONE_AND_ZEROS +#define MBEDTLS_CIPHER_PADDING_ZEROS_AND_LEN +#define MBEDTLS_CIPHER_PADDING_ZEROS + +/** \def MBEDTLS_CTR_DRBG_USE_128_BIT_KEY + * + * Uncomment this macro to use a 128-bit key in the CTR_DRBG module. + * By default, CTR_DRBG uses a 256-bit key. + */ +/*#define MBEDTLS_CTR_DRBG_USE_128_BIT_KEY */ + +/** + * \def MBEDTLS_ECP_DP_SECP192R1_ENABLED + * + * MBEDTLS_ECP_XXXX_ENABLED: Enables specific curves within the Elliptic Curve + * module. By default all supported curves are enabled. + * + * Comment macros to disable the curve and functions for it + */ +/* Short Weierstrass curves (supporting ECP, ECDH, ECDSA) */ +#define MBEDTLS_ECP_DP_SECP192R1_ENABLED +#define MBEDTLS_ECP_DP_SECP224R1_ENABLED +#define MBEDTLS_ECP_DP_SECP256R1_ENABLED +#define MBEDTLS_ECP_DP_SECP384R1_ENABLED +#define MBEDTLS_ECP_DP_SECP521R1_ENABLED +#define MBEDTLS_ECP_DP_SECP192K1_ENABLED +#define MBEDTLS_ECP_DP_SECP224K1_ENABLED +#define MBEDTLS_ECP_DP_SECP256K1_ENABLED +#define MBEDTLS_ECP_DP_BP256R1_ENABLED +#define MBEDTLS_ECP_DP_BP384R1_ENABLED +#define MBEDTLS_ECP_DP_BP512R1_ENABLED +/* Montgomery curves (supporting ECP) */ +#define MBEDTLS_ECP_DP_CURVE25519_ENABLED +#define MBEDTLS_ECP_DP_CURVE448_ENABLED + +/** + * \def MBEDTLS_ECP_NIST_OPTIM + * + * Enable specific 'modulo p' routines for each NIST prime. + * Depending on the prime and architecture, makes operations 4 to 8 times + * faster on the corresponding curve. + * + * Comment this macro to disable NIST curves optimisation. + */ +#define MBEDTLS_ECP_NIST_OPTIM + +/** + * \def MBEDTLS_ECP_RESTARTABLE + * + * Enable "non-blocking" ECC operations that can return early and be resumed. + * + * This allows various functions to pause by returning + * #MBEDTLS_ERR_ECP_IN_PROGRESS (or, for functions in the SSL module, + * #MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS) and then be called later again in + * order to further progress and eventually complete their operation. This is + * controlled through mbedtls_ecp_set_max_ops() which limits the maximum + * number of ECC operations a function may perform before pausing; see + * mbedtls_ecp_set_max_ops() for more information. + * + * This is useful in non-threaded environments if you want to avoid blocking + * for too long on ECC (and, hence, X.509 or SSL/TLS) operations. + * + * Uncomment this macro to enable restartable ECC computations. + * + * \note This option only works with the default software implementation of + * elliptic curve functionality. It is incompatible with + * MBEDTLS_ECP_ALT, MBEDTLS_ECDH_XXX_ALT, MBEDTLS_ECDSA_XXX_ALT. + */ +/*#define MBEDTLS_ECP_RESTARTABLE */ + +/** + * \def MBEDTLS_ECDSA_DETERMINISTIC + * + * Enable deterministic ECDSA (RFC 6979). + * Standard ECDSA is "fragile" in the sense that lack of entropy when signing + * may result in a compromise of the long-term signing key. This is avoided by + * the deterministic variant. + * + * Requires: MBEDTLS_HMAC_DRBG_C, MBEDTLS_ECDSA_C + * + * Comment this macro to disable deterministic ECDSA. + */ +/*#define MBEDTLS_ECDSA_DETERMINISTIC */ + +/** + * \def MBEDTLS_KEY_EXCHANGE_PSK_ENABLED + * + * Enable the PSK based ciphersuite modes in SSL / TLS. + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_PSK_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_PSK_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256 + */ +/*#define MBEDTLS_KEY_EXCHANGE_PSK_ENABLED */ + +/** + * \def MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED + * + * Enable the DHE-PSK based ciphersuite modes in SSL / TLS. + * + * Requires: MBEDTLS_DHM_C + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 + * + * \warning Using DHE constitutes a security risk as it + * is not possible to validate custom DH parameters. + * If possible, it is recommended users should consider + * preferring other methods of key exchange. + * See dhm.h for more details. + * + */ +/*#define MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED */ + +/** + * \def MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED + * + * Enable the ECDHE-PSK based ciphersuite modes in SSL / TLS. + * + * Requires: MBEDTLS_ECDH_C + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 + */ +/*#define MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED */ + +/** + * \def MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED + * + * Enable the RSA-PSK based ciphersuite modes in SSL / TLS. + * + * Requires: MBEDTLS_RSA_C, MBEDTLS_PKCS1_V15, + * MBEDTLS_X509_CRT_PARSE_C + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 + */ +/*#define MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED */ + +/** + * \def MBEDTLS_KEY_EXCHANGE_RSA_ENABLED + * + * Enable the RSA-only based ciphersuite modes in SSL / TLS. + * + * Requires: MBEDTLS_RSA_C, MBEDTLS_PKCS1_V15, + * MBEDTLS_X509_CRT_PARSE_C + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_RSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA + * MBEDTLS_TLS_RSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA + */ +/*#define MBEDTLS_KEY_EXCHANGE_RSA_ENABLED */ + +/** + * \def MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED + * + * Enable the DHE-RSA based ciphersuite modes in SSL / TLS. + * + * Requires: MBEDTLS_DHM_C, MBEDTLS_RSA_C, MBEDTLS_PKCS1_V15, + * MBEDTLS_X509_CRT_PARSE_C + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA + * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA + * + * \warning Using DHE constitutes a security risk as it + * is not possible to validate custom DH parameters. + * If possible, it is recommended users should consider + * preferring other methods of key exchange. + * See dhm.h for more details. + * + */ +/*#define MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED */ + +/** + * \def MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED + * + * Enable the ECDHE-RSA based ciphersuite modes in SSL / TLS. + * + * Requires: MBEDTLS_ECDH_C, MBEDTLS_RSA_C, MBEDTLS_PKCS1_V15, + * MBEDTLS_X509_CRT_PARSE_C + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 + */ +#define MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED + +/** + * \def MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED + * + * Enable the ECDHE-ECDSA based ciphersuite modes in SSL / TLS. + * + * Requires: MBEDTLS_ECDH_C, MBEDTLS_ECDSA_C, MBEDTLS_X509_CRT_PARSE_C, + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 + */ +#define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED + +/** + * \def MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED + * + * Enable the ECDH-ECDSA based ciphersuite modes in SSL / TLS. + * + * Requires: MBEDTLS_ECDH_C, MBEDTLS_ECDSA_C, MBEDTLS_X509_CRT_PARSE_C + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 + */ +/*#define MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED */ + +/** + * \def MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED + * + * Enable the ECDH-RSA based ciphersuite modes in SSL / TLS. + * + * Requires: MBEDTLS_ECDH_C, MBEDTLS_RSA_C, MBEDTLS_X509_CRT_PARSE_C + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384 + */ +/*#define MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED */ + +/** + * \def MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED + * + * Enable the ECJPAKE based ciphersuite modes in SSL / TLS. + * + * \warning This is currently experimental. EC J-PAKE support is based on the + * Thread v1.0.0 specification; incompatible changes to the specification + * might still happen. For this reason, this is disabled by default. + * + * Requires: MBEDTLS_ECJPAKE_C + * MBEDTLS_SHA256_C + * MBEDTLS_ECP_DP_SECP256R1_ENABLED + * + * This enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8 + */ +/*#define MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */ + +/** + * \def MBEDTLS_PK_PARSE_EC_EXTENDED + * + * Enhance support for reading EC keys using variants of SEC1 not allowed by + * RFC 5915 and RFC 5480. + * + * Currently this means parsing the SpecifiedECDomain choice of EC + * parameters (only known groups are supported, not arbitrary domains, to + * avoid validation issues). + * + * Disable if you only need to support RFC 5915 + 5480 key formats. + */ +/*#define MBEDTLS_PK_PARSE_EC_EXTENDED */ + +/** + * \def MBEDTLS_ERROR_STRERROR_DUMMY + * + * Enable a dummy error function to make use of mbedtls_strerror() in + * third party libraries easier when MBEDTLS_ERROR_C is disabled + * (no effect when MBEDTLS_ERROR_C is enabled). + * + * You can safely disable this if MBEDTLS_ERROR_C is enabled, or if you're + * not using mbedtls_strerror() or error_strerror() in your application. + * + * Disable if you run into name conflicts and want to really remove the + * mbedtls_strerror() + */ +#define MBEDTLS_ERROR_STRERROR_DUMMY + +/** + * \def MBEDTLS_GENPRIME + * + * Enable the prime-number generation code. + * + * Requires: MBEDTLS_BIGNUM_C + */ +#define MBEDTLS_GENPRIME + +/** + * \def MBEDTLS_FS_IO + * + * Enable functions that use the filesystem. + */ +/*#define MBEDTLS_FS_IO */ + +/** + * \def MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES + * + * Do not add default entropy sources in mbedtls_entropy_init(). + * + * This is useful to have more control over the added entropy sources in an + * application. + * + * Uncomment this macro to prevent loading of default entropy functions. + */ +/*#define MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES */ + +/** + * \def MBEDTLS_NO_PLATFORM_ENTROPY + * + * Do not use built-in platform entropy functions. + * This is useful if your platform does not support + * standards like the /dev/urandom or Windows CryptoAPI. + * + * Uncomment this macro to disable the built-in platform entropy functions. + */ +#define MBEDTLS_NO_PLATFORM_ENTROPY + +/** + * \def MBEDTLS_ENTROPY_FORCE_SHA256 + * + * Force the entropy accumulator to use a SHA-256 accumulator instead of the + * default SHA-512 based one (if both are available). + * + * Requires: MBEDTLS_SHA256_C + * + * On 32-bit systems SHA-256 can be much faster than SHA-512. Use this option + * if you have performance concerns. + * + * This option is only useful if both MBEDTLS_SHA256_C and + * MBEDTLS_SHA512_C are defined. Otherwise the available hash module is used. + */ +#define MBEDTLS_ENTROPY_FORCE_SHA256 + +/** + * \def MBEDTLS_ENTROPY_NV_SEED + * + * Enable the non-volatile (NV) seed file-based entropy source. + * (Also enables the NV seed read/write functions in the platform layer) + * + * This is crucial (if not required) on systems that do not have a + * cryptographic entropy source (in hardware or kernel) available. + * + * Requires: MBEDTLS_ENTROPY_C, MBEDTLS_PLATFORM_C + * + * \note The read/write functions that are used by the entropy source are + * determined in the platform layer, and can be modified at runtime and/or + * compile-time depending on the flags (MBEDTLS_PLATFORM_NV_SEED_*) used. + * + * \note If you use the default implementation functions that read a seedfile + * with regular fopen(), please make sure you make a seedfile with the + * proper name (defined in MBEDTLS_PLATFORM_STD_NV_SEED_FILE) and at + * least MBEDTLS_ENTROPY_BLOCK_SIZE bytes in size that can be read from + * and written to or you will get an entropy source error! The default + * implementation will only use the first MBEDTLS_ENTROPY_BLOCK_SIZE + * bytes from the file. + * + * \note The entropy collector will write to the seed file before entropy is + * given to an external source, to update it. + */ +/*#define MBEDTLS_ENTROPY_NV_SEED */ + +/* MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER + * + * Enable key identifiers that encode a key owner identifier. + * + * The owner of a key is identified by a value of type ::mbedtls_key_owner_id_t + * which is currently hard-coded to be int32_t. + * + * Note that this option is meant for internal use only and may be removed + * without notice. It is incompatible with MBEDTLS_USE_PSA_CRYPTO. + */ +/*#define MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER */ + +/** + * \def MBEDTLS_MEMORY_DEBUG + * + * Enable debugging of buffer allocator memory issues. Automatically prints + * (to stderr) all (fatal) messages on memory allocation issues. Enables + * function for 'debug output' of allocated memory. + * + * Requires: MBEDTLS_MEMORY_BUFFER_ALLOC_C + * + * Uncomment this macro to let the buffer allocator print out error messages. + */ +/*#define MBEDTLS_MEMORY_DEBUG */ + +/** + * \def MBEDTLS_MEMORY_BACKTRACE + * + * Include backtrace information with each allocated block. + * + * Requires: MBEDTLS_MEMORY_BUFFER_ALLOC_C + * GLIBC-compatible backtrace() an backtrace_symbols() support + * + * Uncomment this macro to include backtrace information + */ +/*#define MBEDTLS_MEMORY_BACKTRACE */ + +/** + * \def MBEDTLS_PK_RSA_ALT_SUPPORT + * + * Support external private RSA keys (eg from a HSM) in the PK layer. + * + * Comment this macro to disable support for external private RSA keys. + */ +#define MBEDTLS_PK_RSA_ALT_SUPPORT + +/** + * \def MBEDTLS_PKCS1_V15 + * + * Enable support for PKCS#1 v1.5 encoding. + * + * Requires: MBEDTLS_RSA_C + * + * This enables support for PKCS#1 v1.5 operations. + */ +#define MBEDTLS_PKCS1_V15 + +/** + * \def MBEDTLS_PKCS1_V21 + * + * Enable support for PKCS#1 v2.1 encoding. + * + * Requires: MBEDTLS_MD_C, MBEDTLS_RSA_C + * + * This enables support for RSAES-OAEP and RSASSA-PSS operations. + */ +/*#define MBEDTLS_PKCS1_V21 */ + +/** \def MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS + * + * Enable support for platform built-in keys. If you enable this feature, + * you must implement the function mbedtls_psa_platform_get_builtin_key(). + * See the documentation of that function for more information. + * + * Built-in keys are typically derived from a hardware unique key or + * stored in a secure element. + * + * Requires: MBEDTLS_PSA_CRYPTO_C. + * + * \warning This interface is experimental and may change or be removed + * without notice. + */ +/*#define MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS */ + +/** \def MBEDTLS_PSA_CRYPTO_CLIENT + * + * Enable support for PSA crypto client. + * + * \note This option allows to include the code necessary for a PSA + * crypto client when the PSA crypto implementation is not included in + * the library (MBEDTLS_PSA_CRYPTO_C disabled). The code included is the + * code to set and get PSA key attributes. + * The development of PSA drivers partially relying on the library to + * fulfill the hardware gaps is another possible usage of this option. + * + * \warning This interface is experimental and may change or be removed + * without notice. + */ +/* #define MBEDTLS_PSA_CRYPTO_CLIENT */ + +/** \def MBEDTLS_PSA_CRYPTO_DRIVERS + * + * Enable support for the experimental PSA crypto driver interface. + * + * Requires: MBEDTLS_PSA_CRYPTO_C + * + * \warning This interface is experimental and may change or be removed + * without notice. + */ +/*#define MBEDTLS_PSA_CRYPTO_DRIVERS */ + +/** \def MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG + * + * Make the PSA Crypto module use an external random generator provided + * by a driver, instead of Mbed TLS's entropy and DRBG modules. + * + * \note This random generator must deliver random numbers with cryptographic + * quality and high performance. It must supply unpredictable numbers + * with a uniform distribution. The implementation of this function + * is responsible for ensuring that the random generator is seeded + * with sufficient entropy. If you have a hardware TRNG which is slow + * or delivers non-uniform output, declare it as an entropy source + * with mbedtls_entropy_add_source() instead of enabling this option. + * + * If you enable this option, you must configure the type + * ::mbedtls_psa_external_random_context_t in psa/crypto_platform.h + * and define a function called mbedtls_psa_external_get_random() + * with the following prototype: + * ``` + * psa_status_t mbedtls_psa_external_get_random( + * mbedtls_psa_external_random_context_t *context, + * uint8_t *output, size_t output_size, size_t *output_length); + * ); + * ``` + * The \c context value is initialized to 0 before the first call. + * The function must fill the \c output buffer with \p output_size bytes + * of random data and set \c *output_length to \p output_size. + * + * Requires: MBEDTLS_PSA_CRYPTO_C + * + * \warning If you enable this option, code that uses the PSA cryptography + * interface will not use any of the entropy sources set up for + * the entropy module, nor the NV seed that MBEDTLS_ENTROPY_NV_SEED + * enables. + * + * \note This option is experimental and may be removed without notice. + */ +/*#define MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG */ + +/** + * \def MBEDTLS_PSA_CRYPTO_SPM + * + * When MBEDTLS_PSA_CRYPTO_SPM is defined, the code is built for SPM (Secure + * Partition Manager) integration which separates the code into two parts: a + * NSPE (Non-Secure Process Environment) and an SPE (Secure Process + * Environment). + * + * Module: library/psa_crypto.c + * Requires: MBEDTLS_PSA_CRYPTO_C + * + */ +/*#define MBEDTLS_PSA_CRYPTO_SPM */ + +/** + * \def MBEDTLS_PSA_INJECT_ENTROPY + * + * Enable support for entropy injection at first boot. This feature is + * required on systems that do not have a built-in entropy source (TRNG). + * This feature is currently not supported on systems that have a built-in + * entropy source. + * + * Requires: MBEDTLS_PSA_CRYPTO_STORAGE_C, MBEDTLS_ENTROPY_NV_SEED + * + */ +/*#define MBEDTLS_PSA_INJECT_ENTROPY */ + +/** + * \def MBEDTLS_RSA_NO_CRT + * + * Do not use the Chinese Remainder Theorem + * for the RSA private operation. + * + * Uncomment this macro to disable the use of CRT in RSA. + * + */ +/*#define MBEDTLS_RSA_NO_CRT */ + +/** + * \def MBEDTLS_SELF_TEST + * + * Enable the checkup functions (*_self_test). + */ +/*#define MBEDTLS_SELF_TEST */ + +/** + * \def MBEDTLS_SHA256_SMALLER + * + * Enable an implementation of SHA-256 that has lower ROM footprint but also + * lower performance. + * + * The default implementation is meant to be a reasonable compromise between + * performance and size. This version optimizes more aggressively for size at + * the expense of performance. Eg on Cortex-M4 it reduces the size of + * mbedtls_sha256_process() from ~2KB to ~0.5KB for a performance hit of about + * 30%. + * + * Uncomment to enable the smaller implementation of SHA256. + */ +/*#define MBEDTLS_SHA256_SMALLER */ + +/** + * \def MBEDTLS_SHA512_SMALLER + * + * Enable an implementation of SHA-512 that has lower ROM footprint but also + * lower performance. + * + * Uncomment to enable the smaller implementation of SHA512. + */ +/*#define MBEDTLS_SHA512_SMALLER */ + +/** + * \def MBEDTLS_SSL_ALL_ALERT_MESSAGES + * + * Enable sending of alert messages in case of encountered errors as per RFC. + * If you choose not to send the alert messages, mbed TLS can still communicate + * with other servers, only debugging of failures is harder. + * + * The advantage of not sending alert messages, is that no information is given + * about reasons for failures thus preventing adversaries of gaining intel. + * + * Enable sending of all alert messages + */ +/*#define MBEDTLS_SSL_ALL_ALERT_MESSAGES */ + +/** + * \def MBEDTLS_SSL_DTLS_CONNECTION_ID + * + * Enable support for the DTLS Connection ID extension + * (version draft-ietf-tls-dtls-connection-id-05, + * https://tools.ietf.org/html/draft-ietf-tls-dtls-connection-id-05) + * which allows to identify DTLS connections across changes + * in the underlying transport. + * + * Setting this option enables the SSL APIs `mbedtls_ssl_set_cid()`, + * `mbedtls_ssl_get_peer_cid()` and `mbedtls_ssl_conf_cid()`. + * See the corresponding documentation for more information. + * + * \warning The Connection ID extension is still in draft state. + * We make no stability promises for the availability + * or the shape of the API controlled by this option. + * + * The maximum lengths of outgoing and incoming CIDs can be configured + * through the options + * - MBEDTLS_SSL_CID_OUT_LEN_MAX + * - MBEDTLS_SSL_CID_IN_LEN_MAX. + * + * Requires: MBEDTLS_SSL_PROTO_DTLS + * + * Uncomment to enable the Connection ID extension. + */ +/*#define MBEDTLS_SSL_DTLS_CONNECTION_ID */ + +/** + * \def MBEDTLS_SSL_ASYNC_PRIVATE + * + * Enable asynchronous external private key operations in SSL. This allows + * you to configure an SSL connection to call an external cryptographic + * module to perform private key operations instead of performing the + * operation inside the library. + * + */ +/*#define MBEDTLS_SSL_ASYNC_PRIVATE */ + +/** + * \def MBEDTLS_SSL_CONTEXT_SERIALIZATION + * + * Enable serialization of the TLS context structures, through use of the + * functions mbedtls_ssl_context_save() and mbedtls_ssl_context_load(). + * + * This pair of functions allows one side of a connection to serialize the + * context associated with the connection, then free or re-use that context + * while the serialized state is persisted elsewhere, and finally deserialize + * that state to a live context for resuming read/write operations on the + * connection. From a protocol perspective, the state of the connection is + * unaffected, in particular this is entirely transparent to the peer. + * + * Note: this is distinct from TLS session resumption, which is part of the + * protocol and fully visible by the peer. TLS session resumption enables + * establishing new connections associated to a saved session with shorter, + * lighter handshakes, while context serialization is a local optimization in + * handling a single, potentially long-lived connection. + * + * Enabling these APIs makes some SSL structures larger, as 64 extra bytes are + * saved after the handshake to allow for more efficient serialization, so if + * you don't need this feature you'll save RAM by disabling it. + * + * Comment to disable the context serialization APIs. + */ +#define MBEDTLS_SSL_CONTEXT_SERIALIZATION + +/** + * \def MBEDTLS_SSL_DEBUG_ALL + * + * Enable the debug messages in SSL module for all issues. + * Debug messages have been disabled in some places to prevent timing + * attacks due to (unbalanced) debugging function calls. + * + * If you need all error reporting you should enable this during debugging, + * but remove this for production servers that should log as well. + * + * Uncomment this macro to report all debug messages on errors introducing + * a timing side-channel. + * + */ +/*#define MBEDTLS_SSL_DEBUG_ALL */ + +/** \def MBEDTLS_SSL_ENCRYPT_THEN_MAC + * + * Enable support for Encrypt-then-MAC, RFC 7366. + * + * This allows peers that both support it to use a more robust protection for + * ciphersuites using CBC, providing deep resistance against timing attacks + * on the padding or underlying cipher. + * + * This only affects CBC ciphersuites, and is useless if none is defined. + * + * Requires: MBEDTLS_SSL_PROTO_TLS1_2 + * + * Comment this macro to disable support for Encrypt-then-MAC + */ +#define MBEDTLS_SSL_ENCRYPT_THEN_MAC + +/** \def MBEDTLS_SSL_EXTENDED_MASTER_SECRET + * + * Enable support for RFC 7627: Session Hash and Extended Master Secret + * Extension. + * + * This was introduced as "the proper fix" to the Triple Handshake family of + * attacks, but it is recommended to always use it (even if you disable + * renegotiation), since it actually fixes a more fundamental issue in the + * original SSL/TLS design, and has implications beyond Triple Handshake. + * + * Requires: MBEDTLS_SSL_PROTO_TLS1_2 + * + * Comment this macro to disable support for Extended Master Secret. + */ +#define MBEDTLS_SSL_EXTENDED_MASTER_SECRET + +/** + * \def MBEDTLS_SSL_KEEP_PEER_CERTIFICATE + * + * This option controls the availability of the API mbedtls_ssl_get_peer_cert() + * giving access to the peer's certificate after completion of the handshake. + * + * Unless you need mbedtls_ssl_peer_cert() in your application, it is + * recommended to disable this option for reduced RAM usage. + * + * \note If this option is disabled, mbedtls_ssl_get_peer_cert() is still + * defined, but always returns \c NULL. + * + * \note This option has no influence on the protection against the + * triple handshake attack. Even if it is disabled, Mbed TLS will + * still ensure that certificates do not change during renegotiation, + * for example by keeping a hash of the peer's certificate. + * + * Comment this macro to disable storing the peer's certificate + * after the handshake. + */ +/*#define MBEDTLS_SSL_KEEP_PEER_CERTIFICATE */ + +/** + * \def MBEDTLS_SSL_RENEGOTIATION + * + * Enable support for TLS renegotiation. + * + * The two main uses of renegotiation are (1) refresh keys on long-lived + * connections and (2) client authentication after the initial handshake. + * If you don't need renegotiation, it's probably better to disable it, since + * it has been associated with security issues in the past and is easy to + * misuse/misunderstand. + * + * Comment this to disable support for renegotiation. + * + * \note Even if this option is disabled, both client and server are aware + * of the Renegotiation Indication Extension (RFC 5746) used to + * prevent the SSL renegotiation attack (see RFC 5746 Sect. 1). + * (See \c mbedtls_ssl_conf_legacy_renegotiation for the + * configuration of this extension). + * + */ +/*#define MBEDTLS_SSL_RENEGOTIATION */ + +/** + * \def MBEDTLS_SSL_MAX_FRAGMENT_LENGTH + * + * Enable support for RFC 6066 max_fragment_length extension in SSL. + * + * Comment this macro to disable support for the max_fragment_length extension + */ +#define MBEDTLS_SSL_MAX_FRAGMENT_LENGTH + +/** + * \def MBEDTLS_SSL_PROTO_TLS1_2 + * + * Enable support for TLS 1.2 (and DTLS 1.2 if DTLS is enabled). + * + * Requires: MBEDTLS_SHA1_C or MBEDTLS_SHA256_C or MBEDTLS_SHA512_C + * (Depends on ciphersuites) + * + * Comment this macro to disable support for TLS 1.2 / DTLS 1.2 + */ +#define MBEDTLS_SSL_PROTO_TLS1_2 + +/** + * \def MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL + * + * This macro is used to selectively enable experimental parts + * of the code that contribute to the ongoing development of + * the prototype TLS 1.3 and DTLS 1.3 implementation, and provide + * no other purpose. + * + * \warning TLS 1.3 and DTLS 1.3 aren't yet supported in Mbed TLS, + * and no feature exposed through this macro is part of the + * public API. In particular, features under the control + * of this macro are experimental and don't come with any + * stability guarantees. + * + * Uncomment this macro to enable experimental and partial + * functionality specific to TLS 1.3. + */ +/*#define MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */ + +/** + * \def MBEDTLS_SSL_PROTO_DTLS + * + * Enable support for DTLS (all available versions). + * + * Enable this and MBEDTLS_SSL_PROTO_TLS1_2 to enable DTLS 1.2. + * + * Requires: MBEDTLS_SSL_PROTO_TLS1_2 + * + * Comment this macro to disable support for DTLS + */ +/*#define MBEDTLS_SSL_PROTO_DTLS */ + +/** + * \def MBEDTLS_SSL_ALPN + * + * Enable support for RFC 7301 Application Layer Protocol Negotiation. + * + * Comment this macro to disable support for ALPN. + */ +#define MBEDTLS_SSL_ALPN + +/** + * \def MBEDTLS_SSL_DTLS_ANTI_REPLAY + * + * Enable support for the anti-replay mechanism in DTLS. + * + * Requires: MBEDTLS_SSL_TLS_C + * MBEDTLS_SSL_PROTO_DTLS + * + * \warning Disabling this is often a security risk! + * See mbedtls_ssl_conf_dtls_anti_replay() for details. + * + * Comment this to disable anti-replay in DTLS. + */ +/*#define MBEDTLS_SSL_DTLS_ANTI_REPLAY */ + +/** + * \def MBEDTLS_SSL_DTLS_HELLO_VERIFY + * + * Enable support for HelloVerifyRequest on DTLS servers. + * + * This feature is highly recommended to prevent DTLS servers being used as + * amplifiers in DoS attacks against other hosts. It should always be enabled + * unless you know for sure amplification cannot be a problem in the + * environment in which your server operates. + * + * \warning Disabling this can be a security risk! (see above) + * + * Requires: MBEDTLS_SSL_PROTO_DTLS + * + * Comment this to disable support for HelloVerifyRequest. + */ +/*#define MBEDTLS_SSL_DTLS_HELLO_VERIFY */ + +/** + * \def MBEDTLS_SSL_DTLS_SRTP + * + * Enable support for negotiation of DTLS-SRTP (RFC 5764) + * through the use_srtp extension. + * + * \note This feature provides the minimum functionality required + * to negotiate the use of DTLS-SRTP and to allow the derivation of + * the associated SRTP packet protection key material. + * In particular, the SRTP packet protection itself, as well as the + * demultiplexing of RTP and DTLS packets at the datagram layer + * (see Section 5 of RFC 5764), are not handled by this feature. + * Instead, after successful completion of a handshake negotiating + * the use of DTLS-SRTP, the extended key exporter API + * mbedtls_ssl_conf_export_keys_cb() should be used to implement + * the key exporter described in Section 4.2 of RFC 5764 and RFC 5705 + * (this is implemented in the SSL example programs). + * The resulting key should then be passed to an SRTP stack. + * + * Setting this option enables the runtime API + * mbedtls_ssl_conf_dtls_srtp_protection_profiles() + * through which the supported DTLS-SRTP protection + * profiles can be configured. You must call this API at + * runtime if you wish to negotiate the use of DTLS-SRTP. + * + * Requires: MBEDTLS_SSL_PROTO_DTLS + * + * Uncomment this to enable support for use_srtp extension. + */ +/*#define MBEDTLS_SSL_DTLS_SRTP */ + +/** + * \def MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE + * + * Enable server-side support for clients that reconnect from the same port. + * + * Some clients unexpectedly close the connection and try to reconnect using the + * same source port. This needs special support from the server to handle the + * new connection securely, as described in section 4.2.8 of RFC 6347. This + * flag enables that support. + * + * Requires: MBEDTLS_SSL_DTLS_HELLO_VERIFY + * + * Comment this to disable support for clients reusing the source port. + */ +/*#define MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE */ + +/** + * \def MBEDTLS_SSL_SESSION_TICKETS + * + * Enable support for RFC 5077 session tickets in SSL. + * Client-side, provides full support for session tickets (maintenance of a + * session store remains the responsibility of the application, though). + * Server-side, you also need to provide callbacks for writing and parsing + * tickets, including authenticated encryption and key management. Example + * callbacks are provided by MBEDTLS_SSL_TICKET_C. + * + * Comment this macro to disable support for SSL session tickets + */ +/*#define MBEDTLS_SSL_SESSION_TICKETS */ + +/** + * \def MBEDTLS_SSL_EXPORT_KEYS + * + * Enable support for exporting key block and master secret. + * This is required for certain users of TLS, e.g. EAP-TLS. + * + * Comment this macro to disable support for key export + */ +/*#define MBEDTLS_SSL_EXPORT_KEYS */ + +/** + * \def MBEDTLS_SSL_SERVER_NAME_INDICATION + * + * Enable support for RFC 6066 server name indication (SNI) in SSL. + * + * Requires: MBEDTLS_X509_CRT_PARSE_C + * + * Comment this macro to disable support for server name indication in SSL + */ +#define MBEDTLS_SSL_SERVER_NAME_INDICATION + +/** + * \def MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH + * + * When this option is enabled, the SSL buffer will be resized automatically + * based on the negotiated maximum fragment length in each direction. + * + * Requires: MBEDTLS_SSL_MAX_FRAGMENT_LENGTH + */ +/*#define MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH */ + +/** + * \def MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN + * + * Enable testing of the constant-flow nature of some sensitive functions with + * clang's MemorySanitizer. This causes some existing tests to also test + * this non-functional property of the code under test. + * + * This setting requires compiling with clang -fsanitize=memory. The test + * suites can then be run normally. + * + * \warning This macro is only used for extended testing; it is not considered + * part of the library's API, so it may change or disappear at any time. + * + * Uncomment to enable testing of the constant-flow nature of selected code. + */ +/*#define MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN */ + +/** + * \def MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND + * + * Enable testing of the constant-flow nature of some sensitive functions with + * valgrind's memcheck tool. This causes some existing tests to also test + * this non-functional property of the code under test. + * + * This setting requires valgrind headers for building, and is only useful for + * testing if the tests suites are run with valgrind's memcheck. This can be + * done for an individual test suite with 'valgrind ./test_suite_xxx', or when + * using CMake, this can be done for all test suites with 'make memcheck'. + * + * \warning This macro is only used for extended testing; it is not considered + * part of the library's API, so it may change or disappear at any time. + * + * Uncomment to enable testing of the constant-flow nature of selected code. + */ +/*#define MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND */ + +/** + * \def MBEDTLS_TEST_HOOKS + * + * Enable features for invasive testing such as introspection functions and + * hooks for fault injection. This enables additional unit tests. + * + * Merely enabling this feature should not change the behavior of the product. + * It only adds new code, and new branching points where the default behavior + * is the same as when this feature is disabled. + * However, this feature increases the attack surface: there is an added + * risk of vulnerabilities, and more gadgets that can make exploits easier. + * Therefore this feature must never be enabled in production. + * + * See `docs/architecture/testing/mbed-crypto-invasive-testing.md` for more + * information. + * + * Uncomment to enable invasive tests. + */ +/*#define MBEDTLS_TEST_HOOKS */ + +/** + * \def MBEDTLS_THREADING_ALT + * + * Provide your own alternate threading implementation. + * + * Requires: MBEDTLS_THREADING_C + * + * Uncomment this to allow your own alternate threading implementation. + */ +#define MBEDTLS_THREADING_ALT + +/** + * \def MBEDTLS_THREADING_PTHREAD + * + * Enable the pthread wrapper layer for the threading layer. + * + * Requires: MBEDTLS_THREADING_C + * + * Uncomment this to enable pthread mutexes. + */ +/*#define MBEDTLS_THREADING_PTHREAD */ + +/** + * \def MBEDTLS_USE_PSA_CRYPTO + * + * Make the X.509 and TLS library use PSA for cryptographic operations, and + * enable new APIs for using keys handled by PSA Crypto. + * + * \note Development of this option is currently in progress, and parts of Mbed + * TLS's X.509 and TLS modules are not ported to PSA yet. However, these parts + * will still continue to work as usual, so enabling this option should not + * break backwards compatibility. + * + * \warning The PSA Crypto API is in beta stage. While you're welcome to + * experiment using it, incompatible API changes are still possible, and some + * parts may not have reached the same quality as the rest of Mbed TLS yet. + * + * \warning This option enables new Mbed TLS APIs that are dependent on the + * PSA Crypto API, so can't come with the same stability guarantees as the + * rest of the Mbed TLS APIs. You're welcome to experiment with them, but for + * now, access to these APIs is opt-in (via enabling the present option), in + * order to clearly differentiate them from the stable Mbed TLS APIs. + * + * Requires: MBEDTLS_PSA_CRYPTO_C. + * + * Uncomment this to enable internal use of PSA Crypto and new associated APIs. + */ +/*#define MBEDTLS_USE_PSA_CRYPTO */ + +/** + * \def MBEDTLS_PSA_CRYPTO_CONFIG + * + * This setting allows support for cryptographic mechanisms through the PSA + * API to be configured separately from support through the mbedtls API. + * + * Uncomment this to enable use of PSA Crypto configuration settings which + * can be found in include/psa/crypto_config.h. + * + * This feature is still experimental and is not ready for production since + * it is not completed. + */ +/*#define MBEDTLS_PSA_CRYPTO_CONFIG */ + +/** + * \def MBEDTLS_VERSION_FEATURES + * + * Allow run-time checking of compile-time enabled features. Thus allowing users + * to check at run-time if the library is for instance compiled with threading + * support via mbedtls_version_check_feature(). + * + * Requires: MBEDTLS_VERSION_C + * + * Comment this to disable run-time checking and save ROM space + */ +/*#define MBEDTLS_VERSION_FEATURES */ + +/** + * \def MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK + * + * If set, this enables the X.509 API `mbedtls_x509_crt_verify_with_ca_cb()` + * and the SSL API `mbedtls_ssl_conf_ca_cb()` which allow users to configure + * the set of trusted certificates through a callback instead of a linked + * list. + * + * This is useful for example in environments where a large number of trusted + * certificates is present and storing them in a linked list isn't efficient + * enough, or when the set of trusted certificates changes frequently. + * + * See the documentation of `mbedtls_x509_crt_verify_with_ca_cb()` and + * `mbedtls_ssl_conf_ca_cb()` for more information. + * + * Uncomment to enable trusted certificate callbacks. + */ +#define MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK + +/** + * \def MBEDTLS_X509_REMOVE_INFO + * + * Disable mbedtls_x509_*_info() and related APIs. + * + * Uncomment to omit mbedtls_x509_*_info(), as well as mbedtls_debug_print_crt() + * and other functions/constants only used by these functions, thus reducing + * the code footprint by several KB. + */ +/*#define MBEDTLS_X509_REMOVE_INFO */ + +/** + * \def MBEDTLS_X509_RSASSA_PSS_SUPPORT + * + * Enable parsing and verification of X.509 certificates, CRLs and CSRS + * signed with RSASSA-PSS (aka PKCS#1 v2.1). + * + * Comment this macro to disallow using RSASSA-PSS in certificates. + */ +/*#define MBEDTLS_X509_RSASSA_PSS_SUPPORT */ +/* \} name SECTION: mbed TLS feature support */ + +/** + * \name SECTION: mbed TLS modules + * + * This section enables or disables entire modules in mbed TLS + * \{ + */ + +/** + * \def MBEDTLS_AESNI_C + * + * Enable AES-NI support on x86-64. + * + * Module: library/aesni.c + * Caller: library/aes.c + * + * Requires: MBEDTLS_HAVE_ASM + * + * This modules adds support for the AES-NI instructions on x86-64 + */ +/*#define MBEDTLS_AESNI_C */ + +/** + * \def MBEDTLS_AES_C + * + * Enable the AES block cipher. + * + * Module: library/aes.c + * Caller: library/cipher.c + * library/pem.c + * library/ctr_drbg.c + * + * This module enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_RSA_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_RSA_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA + * MBEDTLS_TLS_PSK_WITH_AES_256_GCM_SHA384 + * MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA384 + * MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA + * MBEDTLS_TLS_PSK_WITH_AES_128_GCM_SHA256 + * MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA256 + * MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA + * + * PEM_PARSE uses AES for decrypting encrypted keys. + */ +#define MBEDTLS_AES_C + +/** + * \def MBEDTLS_ASN1_PARSE_C + * + * Enable the generic ASN1 parser. + * + * Module: library/asn1.c + * Caller: library/x509.c + * library/dhm.c + * library/pkcs12.c + * library/pkcs5.c + * library/pkparse.c + */ +#define MBEDTLS_ASN1_PARSE_C + +/** + * \def MBEDTLS_ASN1_WRITE_C + * + * Enable the generic ASN1 writer. + * + * Module: library/asn1write.c + * Caller: library/ecdsa.c + * library/pkwrite.c + * library/x509_create.c + * library/x509write_crt.c + * library/x509write_csr.c + */ +#define MBEDTLS_ASN1_WRITE_C + +/** + * \def MBEDTLS_BASE64_C + * + * Enable the Base64 module. + * + * Module: library/base64.c + * Caller: library/pem.c + * + * This module is required for PEM support (required by X.509). + */ +#define MBEDTLS_BASE64_C + +/** + * \def MBEDTLS_BIGNUM_C + * + * Enable the multi-precision integer library. + * + * Module: library/bignum.c + * Caller: library/dhm.c + * library/ecp.c + * library/ecdsa.c + * library/rsa.c + * library/rsa_alt_helpers.c + * library/ssl_tls.c + * + * This module is required for RSA, DHM and ECC (ECDH, ECDSA) support. + */ +#define MBEDTLS_BIGNUM_C + +/** + * \def MBEDTLS_CAMELLIA_C + * + * Enable the Camellia block cipher. + * + * Module: library/camellia.c + * Caller: library/cipher.c + * + * This module enables the following ciphersuites (if other requisites are + * enabled as well): + * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA + * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA + * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 + * MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384 + * MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384 + * MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256 + * MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256 + */ +/*#define MBEDTLS_CAMELLIA_C */ + +/** + * \def MBEDTLS_ARIA_C + * + * Enable the ARIA block cipher. + * + * Module: library/aria.c + * Caller: library/cipher.c + * + * This module enables the following ciphersuites (if other requisites are + * enabled as well): + * + * MBEDTLS_TLS_RSA_WITH_ARIA_128_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_ARIA_256_CBC_SHA384 + * MBEDTLS_TLS_DHE_RSA_WITH_ARIA_128_CBC_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_ARIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_ARIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_ARIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_ARIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_ARIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_ARIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_RSA_WITH_ARIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_RSA_WITH_ARIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_ARIA_256_CBC_SHA384 + * MBEDTLS_TLS_RSA_WITH_ARIA_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_WITH_ARIA_256_GCM_SHA384 + * MBEDTLS_TLS_DHE_RSA_WITH_ARIA_128_GCM_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_ARIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDH_RSA_WITH_ARIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_ARIA_256_GCM_SHA384 + * MBEDTLS_TLS_PSK_WITH_ARIA_128_CBC_SHA256 + * MBEDTLS_TLS_PSK_WITH_ARIA_256_CBC_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_ARIA_128_CBC_SHA256 + * MBEDTLS_TLS_DHE_PSK_WITH_ARIA_256_CBC_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_ARIA_128_CBC_SHA256 + * MBEDTLS_TLS_RSA_PSK_WITH_ARIA_256_CBC_SHA384 + * MBEDTLS_TLS_PSK_WITH_ARIA_128_GCM_SHA256 + * MBEDTLS_TLS_PSK_WITH_ARIA_256_GCM_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_ARIA_128_GCM_SHA256 + * MBEDTLS_TLS_DHE_PSK_WITH_ARIA_256_GCM_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_ARIA_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_PSK_WITH_ARIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_PSK_WITH_ARIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_PSK_WITH_ARIA_256_CBC_SHA384 + */ +/*#define MBEDTLS_ARIA_C */ + +/** + * \def MBEDTLS_CCM_C + * + * Enable the Counter with CBC-MAC (CCM) mode for 128-bit block cipher. + * + * Module: library/ccm.c + * + * Requires: MBEDTLS_AES_C or MBEDTLS_CAMELLIA_C + * + * This module enables the AES-CCM ciphersuites, if other requisites are + * enabled as well. + */ +/*#define MBEDTLS_CCM_C */ + +/** + * \def MBEDTLS_CHACHA20_C + * + * Enable the ChaCha20 stream cipher. + * + * Module: library/chacha20.c + */ +/*#define MBEDTLS_CHACHA20_C */ + +/** + * \def MBEDTLS_CHACHAPOLY_C + * + * Enable the ChaCha20-Poly1305 AEAD algorithm. + * + * Module: library/chachapoly.c + * + * This module requires: MBEDTLS_CHACHA20_C, MBEDTLS_POLY1305_C + */ +/*#define MBEDTLS_CHACHAPOLY_C */ + +/** + * \def MBEDTLS_CIPHER_C + * + * Enable the generic cipher layer. + * + * Module: library/cipher.c + * Caller: library/ssl_tls.c + * + * Uncomment to enable generic cipher wrappers. + */ +#define MBEDTLS_CIPHER_C + +/** + * \def MBEDTLS_CMAC_C + * + * Enable the CMAC (Cipher-based Message Authentication Code) mode for block + * ciphers. + * + * \note When #MBEDTLS_CMAC_ALT is active, meaning that the underlying + * implementation of the CMAC algorithm is provided by an alternate + * implementation, that alternate implementation may opt to not support + * AES-192 or 3DES as underlying block ciphers for the CMAC operation. + * + * Module: library/cmac.c + * + * Requires: MBEDTLS_AES_C or MBEDTLS_DES_C + * + */ +#define MBEDTLS_CMAC_C + +/** + * \def MBEDTLS_CTR_DRBG_C + * + * Enable the CTR_DRBG AES-based random generator. + * The CTR_DRBG generator uses AES-256 by default. + * To use AES-128 instead, enable \c MBEDTLS_CTR_DRBG_USE_128_BIT_KEY above. + * + * \note To achieve a 256-bit security strength with CTR_DRBG, + * you must use AES-256 *and* use sufficient entropy. + * See ctr_drbg.h for more details. + * + * Module: library/ctr_drbg.c + * Caller: + * + * Requires: MBEDTLS_AES_C + * + * This module provides the CTR_DRBG AES random number generator. + */ +#define MBEDTLS_CTR_DRBG_C + +/** + * \def MBEDTLS_DEBUG_C + * + * Enable the debug functions. + * + * Module: library/debug.c + * Caller: library/ssl_cli.c + * library/ssl_srv.c + * library/ssl_tls.c + * + * This module provides debugging functions. + */ +/*#define MBEDTLS_DEBUG_C */ + +/** + * \def MBEDTLS_DES_C + * + * Enable the DES block cipher. + * + * Module: library/des.c + * Caller: library/pem.c + * library/cipher.c + * + * PEM_PARSE uses DES/3DES for decrypting encrypted keys. + * + * \warning DES is considered a weak cipher and its use constitutes a + * security risk. We recommend considering stronger ciphers instead. + */ +/*#define MBEDTLS_DES_C */ + +/** + * \def MBEDTLS_DHM_C + * + * Enable the Diffie-Hellman-Merkle module. + * + * Module: library/dhm.c + * Caller: library/ssl_cli.c + * library/ssl_srv.c + * + * This module is used by the following key exchanges: + * DHE-RSA, DHE-PSK + * + * \warning Using DHE constitutes a security risk as it + * is not possible to validate custom DH parameters. + * If possible, it is recommended users should consider + * preferring other methods of key exchange. + * See dhm.h for more details. + * + */ +/*#define MBEDTLS_DHM_C */ + +/** + * \def MBEDTLS_ECDH_C + * + * Enable the elliptic curve Diffie-Hellman library. + * + * Module: library/ecdh.c + * Caller: library/ssl_cli.c + * library/ssl_srv.c + * + * This module is used by the following key exchanges: + * ECDHE-ECDSA, ECDHE-RSA, DHE-PSK + * + * Requires: MBEDTLS_ECP_C + */ +#define MBEDTLS_ECDH_C + +/** + * \def MBEDTLS_ECDSA_C + * + * Enable the elliptic curve DSA library. + * + * Module: library/ecdsa.c + * Caller: + * + * This module is used by the following key exchanges: + * ECDHE-ECDSA + * + * Requires: MBEDTLS_ECP_C, MBEDTLS_ASN1_WRITE_C, MBEDTLS_ASN1_PARSE_C, + * and at least one MBEDTLS_ECP_DP_XXX_ENABLED for a + * short Weierstrass curve. + */ +#define MBEDTLS_ECDSA_C + +/** + * \def MBEDTLS_ECJPAKE_C + * + * Enable the elliptic curve J-PAKE library. + * + * \note EC J-PAKE support is based on the Thread v1.0.0 specification. + * It has not been reviewed for compliance with newer standards such as + * Thread v1.1 or RFC 8236. + * + * Module: library/ecjpake.c + * Caller: + * + * This module is used by the following key exchanges: + * ECJPAKE + * + * Requires: MBEDTLS_ECP_C, MBEDTLS_MD_C + */ +/*#define MBEDTLS_ECJPAKE_C */ + +/** + * \def MBEDTLS_ECP_C + * + * Enable the elliptic curve over GF(p) library. + * + * Module: library/ecp.c + * Caller: library/ecdh.c + * library/ecdsa.c + * library/ecjpake.c + * + * Requires: MBEDTLS_BIGNUM_C and at least one MBEDTLS_ECP_DP_XXX_ENABLED + */ +#define MBEDTLS_ECP_C + +/** + * \def MBEDTLS_ENTROPY_C + * + * Enable the platform-specific entropy code. + * + * Module: library/entropy.c + * Caller: + * + * Requires: MBEDTLS_SHA512_C or MBEDTLS_SHA256_C + * + * This module provides a generic entropy pool + */ +#define MBEDTLS_ENTROPY_C + +/** + * \def MBEDTLS_ERROR_C + * + * Enable error code to error string conversion. + * + * Module: library/error.c + * Caller: + * + * This module enables mbedtls_strerror(). + */ +/*#define MBEDTLS_ERROR_C */ + +/** + * \def MBEDTLS_GCM_C + * + * Enable the Galois/Counter Mode (GCM). + * + * Module: library/gcm.c + * + * Requires: MBEDTLS_AES_C or MBEDTLS_CAMELLIA_C or MBEDTLS_ARIA_C + * + * This module enables the AES-GCM and CAMELLIA-GCM ciphersuites, if other + * requisites are enabled as well. + */ +#define MBEDTLS_GCM_C + +/** + * \def MBEDTLS_HKDF_C + * + * Enable the HKDF algorithm (RFC 5869). + * + * Module: library/hkdf.c + * Caller: + * + * Requires: MBEDTLS_MD_C + * + * This module adds support for the Hashed Message Authentication Code + * (HMAC)-based key derivation function (HKDF). + */ +/*#define MBEDTLS_HKDF_C */ + +/** + * \def MBEDTLS_HMAC_DRBG_C + * + * Enable the HMAC_DRBG random generator. + * + * Module: library/hmac_drbg.c + * Caller: + * + * Requires: MBEDTLS_MD_C + * + * Uncomment to enable the HMAC_DRBG random number generator. + */ +/*#define MBEDTLS_HMAC_DRBG_C */ + +/** + * \def MBEDTLS_NIST_KW_C + * + * Enable the Key Wrapping mode for 128-bit block ciphers, + * as defined in NIST SP 800-38F. Only KW and KWP modes + * are supported. At the moment, only AES is approved by NIST. + * + * Module: library/nist_kw.c + * + * Requires: MBEDTLS_AES_C and MBEDTLS_CIPHER_C + */ +/*#define MBEDTLS_NIST_KW_C */ + +/** + * \def MBEDTLS_MD_C + * + * Enable the generic message digest layer. + * + * Module: library/md.c + * Caller: + * + * Uncomment to enable generic message digest wrappers. + */ +#define MBEDTLS_MD_C + +/** + * \def MBEDTLS_MD5_C + * + * Enable the MD5 hash algorithm. + * + * Module: library/md5.c + * Caller: library/md.c + * library/pem.c + * library/ssl_tls.c + * + * This module is required for TLS 1.2 depending on the handshake parameters. + * Further, it is used for checking MD5-signed certificates, and for PBKDF1 + * when decrypting PEM-encoded encrypted keys. + * + * \warning MD5 is considered a weak message digest and its use constitutes a + * security risk. If possible, we recommend avoiding dependencies on + * it, and considering stronger message digests instead. + * + */ +/*#define MBEDTLS_MD5_C */ + +/** + * \def MBEDTLS_MEMORY_BUFFER_ALLOC_C + * + * Enable the buffer allocator implementation that makes use of a (stack) + * based buffer to 'allocate' dynamic memory. (replaces calloc() and free() + * calls) + * + * Module: library/memory_buffer_alloc.c + * + * Requires: MBEDTLS_PLATFORM_C + * MBEDTLS_PLATFORM_MEMORY (to use it within mbed TLS) + * + * Enable this module to enable the buffer memory allocator. + */ +/*#define MBEDTLS_MEMORY_BUFFER_ALLOC_C */ + +/** + * \def MBEDTLS_NET_C + * + * Enable the TCP and UDP over IPv6/IPv4 networking routines. + * + * \note This module only works on POSIX/Unix (including Linux, BSD and OS X) + * and Windows. For other platforms, you'll want to disable it, and write your + * own networking callbacks to be passed to \c mbedtls_ssl_set_bio(). + * + * \note See also our Knowledge Base article about porting to a new + * environment: + * https://tls.mbed.org/kb/how-to/how-do-i-port-mbed-tls-to-a-new-environment-OS + * + * Module: library/net_sockets.c + * + * This module provides networking routines. + */ +/*#define MBEDTLS_NET_C */ + +/** + * \def MBEDTLS_OID_C + * + * Enable the OID database. + * + * Module: library/oid.c + * Caller: library/asn1write.c + * library/pkcs5.c + * library/pkparse.c + * library/pkwrite.c + * library/rsa.c + * library/x509.c + * library/x509_create.c + * library/x509_crl.c + * library/x509_crt.c + * library/x509_csr.c + * library/x509write_crt.c + * library/x509write_csr.c + * + * This modules translates between OIDs and internal values. + */ +#define MBEDTLS_OID_C + +/** + * \def MBEDTLS_PADLOCK_C + * + * Enable VIA Padlock support on x86. + * + * Module: library/padlock.c + * Caller: library/aes.c + * + * Requires: MBEDTLS_HAVE_ASM + * + * This modules adds support for the VIA PadLock on x86. + */ +/*#define MBEDTLS_PADLOCK_C */ + +/** + * \def MBEDTLS_PEM_PARSE_C + * + * Enable PEM decoding / parsing. + * + * Module: library/pem.c + * Caller: library/dhm.c + * library/pkparse.c + * library/x509_crl.c + * library/x509_crt.c + * library/x509_csr.c + * + * Requires: MBEDTLS_BASE64_C + * + * This modules adds support for decoding / parsing PEM files. + */ +#define MBEDTLS_PEM_PARSE_C + +/** + * \def MBEDTLS_PEM_WRITE_C + * + * Enable PEM encoding / writing. + * + * Module: library/pem.c + * Caller: library/pkwrite.c + * library/x509write_crt.c + * library/x509write_csr.c + * + * Requires: MBEDTLS_BASE64_C + * + * This modules adds support for encoding / writing PEM files. + */ +/*#define MBEDTLS_PEM_WRITE_C */ + +/** + * \def MBEDTLS_PK_C + * + * Enable the generic public (asymmetric) key layer. + * + * Module: library/pk.c + * Caller: library/ssl_tls.c + * library/ssl_cli.c + * library/ssl_srv.c + * + * Requires: MBEDTLS_RSA_C or MBEDTLS_ECP_C + * + * Uncomment to enable generic public key wrappers. + */ +#define MBEDTLS_PK_C + +/** + * \def MBEDTLS_PK_PARSE_C + * + * Enable the generic public (asymmetric) key parser. + * + * Module: library/pkparse.c + * Caller: library/x509_crt.c + * library/x509_csr.c + * + * Requires: MBEDTLS_PK_C + * + * Uncomment to enable generic public key parse functions. + */ +#define MBEDTLS_PK_PARSE_C + +/** + * \def MBEDTLS_PK_WRITE_C + * + * Enable the generic public (asymmetric) key writer. + * + * Module: library/pkwrite.c + * Caller: library/x509write.c + * + * Requires: MBEDTLS_PK_C + * + * Uncomment to enable generic public key write functions. + */ +#define MBEDTLS_PK_WRITE_C + +/** + * \def MBEDTLS_PKCS5_C + * + * Enable PKCS#5 functions. + * + * Module: library/pkcs5.c + * + * Requires: MBEDTLS_MD_C + * + * This module adds support for the PKCS#5 functions. + */ +/*#define MBEDTLS_PKCS5_C */ + +/** + * \def MBEDTLS_PKCS12_C + * + * Enable PKCS#12 PBE functions. + * Adds algorithms for parsing PKCS#8 encrypted private keys + * + * Module: library/pkcs12.c + * Caller: library/pkparse.c + * + * Requires: MBEDTLS_ASN1_PARSE_C, MBEDTLS_CIPHER_C, MBEDTLS_MD_C + * + * This module enables PKCS#12 functions. + */ +/*#define MBEDTLS_PKCS12_C */ + +/** + * \def MBEDTLS_PLATFORM_C + * + * Enable the platform abstraction layer that allows you to re-assign + * functions like calloc(), free(), snprintf(), printf(), fprintf(), exit(). + * + * Enabling MBEDTLS_PLATFORM_C enables to use of MBEDTLS_PLATFORM_XXX_ALT + * or MBEDTLS_PLATFORM_XXX_MACRO directives, allowing the functions mentioned + * above to be specified at runtime or compile time respectively. + * + * \note This abstraction layer must be enabled on Windows (including MSYS2) + * as other module rely on it for a fixed snprintf implementation. + * + * Module: library/platform.c + * Caller: Most other .c files + * + * This module enables abstraction of common (libc) functions. + */ +#define MBEDTLS_PLATFORM_C + +/** + * \def MBEDTLS_POLY1305_C + * + * Enable the Poly1305 MAC algorithm. + * + * Module: library/poly1305.c + * Caller: library/chachapoly.c + */ +/*#define MBEDTLS_POLY1305_C */ + +/** + * \def MBEDTLS_PSA_CRYPTO_C + * + * Enable the Platform Security Architecture cryptography API. + * + * \warning The PSA Crypto API is still beta status. While you're welcome to + * experiment using it, incompatible API changes are still possible, and some + * parts may not have reached the same quality as the rest of Mbed TLS yet. + * + * Module: library/psa_crypto.c + * + * Requires: either MBEDTLS_CTR_DRBG_C and MBEDTLS_ENTROPY_C, + * or MBEDTLS_HMAC_DRBG_C and MBEDTLS_ENTROPY_C, + * or MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG. + * + */ +/*#define MBEDTLS_PSA_CRYPTO_C */ + +/** + * \def MBEDTLS_PSA_CRYPTO_SE_C + * + * Enable secure element support in the Platform Security Architecture + * cryptography API. + * + * \warning This feature is not yet suitable for production. It is provided + * for API evaluation and testing purposes only. + * + * Module: library/psa_crypto_se.c + * + * Requires: MBEDTLS_PSA_CRYPTO_C, MBEDTLS_PSA_CRYPTO_STORAGE_C + * + */ +/*#define MBEDTLS_PSA_CRYPTO_SE_C */ + +/** + * \def MBEDTLS_PSA_CRYPTO_STORAGE_C + * + * Enable the Platform Security Architecture persistent key storage. + * + * Module: library/psa_crypto_storage.c + * + * Requires: MBEDTLS_PSA_CRYPTO_C, + * either MBEDTLS_PSA_ITS_FILE_C or a native implementation of + * the PSA ITS interface + */ +/*#define MBEDTLS_PSA_CRYPTO_STORAGE_C */ + +/** + * \def MBEDTLS_PSA_ITS_FILE_C + * + * Enable the emulation of the Platform Security Architecture + * Internal Trusted Storage (PSA ITS) over files. + * + * Module: library/psa_its_file.c + * + * Requires: MBEDTLS_FS_IO + */ +/*#define MBEDTLS_PSA_ITS_FILE_C */ + +/** + * \def MBEDTLS_RIPEMD160_C + * + * Enable the RIPEMD-160 hash algorithm. + * + * Module: library/ripemd160.c + * Caller: library/md.c + * + */ +/*#define MBEDTLS_RIPEMD160_C */ + +/** + * \def MBEDTLS_RSA_C + * + * Enable the RSA public-key cryptosystem. + * + * Module: library/rsa.c + * library/rsa_alt_helpers.c + * Caller: library/ssl_cli.c + * library/ssl_srv.c + * library/ssl_tls.c + * library/x509.c + * + * This module is used by the following key exchanges: + * RSA, DHE-RSA, ECDHE-RSA, RSA-PSK + * + * Requires: MBEDTLS_BIGNUM_C, MBEDTLS_OID_C + */ +#define MBEDTLS_RSA_C + +/** + * \def MBEDTLS_SHA1_C + * + * Enable the SHA1 cryptographic hash algorithm. + * + * Module: library/sha1.c + * Caller: library/md.c + * library/ssl_cli.c + * library/ssl_srv.c + * library/ssl_tls.c + * library/x509write_crt.c + * + * This module is required for TLS 1.2 depending on the handshake parameters, + * and for SHA1-signed certificates. + * + * \warning SHA-1 is considered a weak message digest and its use constitutes + * a security risk. If possible, we recommend avoiding dependencies + * on it, and considering stronger message digests instead. + * + */ +#define MBEDTLS_SHA1_C + +/** + * \def MBEDTLS_SHA224_C + * + * Enable the SHA-224 cryptographic hash algorithm. + * + * Requires: MBEDTLS_SHA256_C. The library does not currently support enabling + * SHA-224 without SHA-256. + * + * Module: library/sha256.c + * Caller: library/md.c + * library/ssl_cookie.c + * + * This module adds support for SHA-224. + */ +/*#define MBEDTLS_SHA224_C */ + +/** + * \def MBEDTLS_SHA256_C + * + * Enable the SHA-256 cryptographic hash algorithm. + * + * Requires: MBEDTLS_SHA224_C. The library does not currently support enabling + * SHA-256 without SHA-224. + * + * Module: library/sha256.c + * Caller: library/entropy.c + * library/md.c + * library/ssl_cli.c + * library/ssl_srv.c + * library/ssl_tls.c + * + * This module adds support for SHA-256. + * This module is required for the SSL/TLS 1.2 PRF function. + */ +#define MBEDTLS_SHA256_C + +/** + * \def MBEDTLS_SHA384_C + * + * Enable the SHA-384 cryptographic hash algorithm. + * + * Requires: MBEDTLS_SHA512_C + * + * Module: library/sha512.c + * Caller: library/md.c + * library/ssl_cli.c + * library/ssl_srv.c + * + * Comment to disable SHA-384 + */ +/*#define MBEDTLS_SHA384_C */ + +/** + * \def MBEDTLS_SHA512_C + * + * Enable SHA-512 cryptographic hash algorithms. + * + * Module: library/sha512.c + * Caller: library/entropy.c + * library/md.c + * library/ssl_tls.c + * library/ssl_cookie.c + * + * This module adds support for SHA-512. + */ +/*#define MBEDTLS_SHA512_C */ + +/** + * \def MBEDTLS_SSL_CACHE_C + * + * Enable simple SSL cache implementation. + * + * Module: library/ssl_cache.c + * Caller: + * + * Requires: MBEDTLS_SSL_CACHE_C + */ +/*#define MBEDTLS_SSL_CACHE_C */ + +/** + * \def MBEDTLS_SSL_COOKIE_C + * + * Enable basic implementation of DTLS cookies for hello verification. + * + * Module: library/ssl_cookie.c + * Caller: + */ +/*#define MBEDTLS_SSL_COOKIE_C */ + +/** + * \def MBEDTLS_SSL_TICKET_C + * + * Enable an implementation of TLS server-side callbacks for session tickets. + * + * Module: library/ssl_ticket.c + * Caller: + * + * Requires: MBEDTLS_CIPHER_C + */ +/*#define MBEDTLS_SSL_TICKET_C */ + +/** + * \def MBEDTLS_SSL_CLI_C + * + * Enable the SSL/TLS client code. + * + * Module: library/ssl_cli.c + * Caller: + * + * Requires: MBEDTLS_SSL_TLS_C + * + * This module is required for SSL/TLS client support. + */ +#define MBEDTLS_SSL_CLI_C + +/** + * \def MBEDTLS_SSL_SRV_C + * + * Enable the SSL/TLS server code. + * + * Module: library/ssl_srv.c + * Caller: + * + * Requires: MBEDTLS_SSL_TLS_C + * + * This module is required for SSL/TLS server support. + */ +/*#define MBEDTLS_SSL_SRV_C */ + +/** + * \def MBEDTLS_SSL_TLS_C + * + * Enable the generic SSL/TLS code. + * + * Module: library/ssl_tls.c + * Caller: library/ssl_cli.c + * library/ssl_srv.c + * + * Requires: MBEDTLS_CIPHER_C, MBEDTLS_MD_C + * and at least one of the MBEDTLS_SSL_PROTO_XXX defines + * + * This module is required for SSL/TLS. + */ +#define MBEDTLS_SSL_TLS_C + +/** + * \def MBEDTLS_THREADING_C + * + * Enable the threading abstraction layer. + * By default mbed TLS assumes it is used in a non-threaded environment or that + * contexts are not shared between threads. If you do intend to use contexts + * between threads, you will need to enable this layer to prevent race + * conditions. See also our Knowledge Base article about threading: + * https://tls.mbed.org/kb/development/thread-safety-and-multi-threading + * + * Module: library/threading.c + * + * This allows different threading implementations (self-implemented or + * provided). + * + * You will have to enable either MBEDTLS_THREADING_ALT or + * MBEDTLS_THREADING_PTHREAD. + * + * Enable this layer to allow use of mutexes within mbed TLS + */ +#define MBEDTLS_THREADING_C + +/** + * \def MBEDTLS_TIMING_C + * + * Enable the semi-portable timing interface. + * + * \note The provided implementation only works on POSIX/Unix (including Linux, + * BSD and OS X) and Windows. On other platforms, you can either disable that + * module and provide your own implementations of the callbacks needed by + * \c mbedtls_ssl_set_timer_cb() for DTLS, or leave it enabled and provide + * your own implementation of the whole module by setting + * \c MBEDTLS_TIMING_ALT in the current file. + * + * \note See also our Knowledge Base article about porting to a new + * environment: + * https://tls.mbed.org/kb/how-to/how-do-i-port-mbed-tls-to-a-new-environment-OS + * + * Module: library/timing.c + */ +/*#define MBEDTLS_TIMING_C */ + +/** + * \def MBEDTLS_VERSION_C + * + * Enable run-time version information. + * + * Module: library/version.c + * + * This module provides run-time version information. + */ +/*#define MBEDTLS_VERSION_C */ + +/** + * \def MBEDTLS_X509_USE_C + * + * Enable X.509 core for using certificates. + * + * Module: library/x509.c + * Caller: library/x509_crl.c + * library/x509_crt.c + * library/x509_csr.c + * + * Requires: MBEDTLS_ASN1_PARSE_C, MBEDTLS_BIGNUM_C, MBEDTLS_OID_C, + * MBEDTLS_PK_PARSE_C + * + * This module is required for the X.509 parsing modules. + */ +#define MBEDTLS_X509_USE_C + +/** + * \def MBEDTLS_X509_CRT_PARSE_C + * + * Enable X.509 certificate parsing. + * + * Module: library/x509_crt.c + * Caller: library/ssl_cli.c + * library/ssl_srv.c + * library/ssl_tls.c + * + * Requires: MBEDTLS_X509_USE_C + * + * This module is required for X.509 certificate parsing. + */ +#define MBEDTLS_X509_CRT_PARSE_C + +/** + * \def MBEDTLS_X509_CRL_PARSE_C + * + * Enable X.509 CRL parsing. + * + * Module: library/x509_crl.c + * Caller: library/x509_crt.c + * + * Requires: MBEDTLS_X509_USE_C + * + * This module is required for X.509 CRL parsing. + */ +/*#define MBEDTLS_X509_CRL_PARSE_C */ + +/** + * \def MBEDTLS_X509_CSR_PARSE_C + * + * Enable X.509 Certificate Signing Request (CSR) parsing. + * + * Module: library/x509_csr.c + * Caller: library/x509_crt_write.c + * + * Requires: MBEDTLS_X509_USE_C + * + * This module is used for reading X.509 certificate request. + */ +/*#define MBEDTLS_X509_CSR_PARSE_C */ + +/** + * \def MBEDTLS_X509_CREATE_C + * + * Enable X.509 core for creating certificates. + * + * Module: library/x509_create.c + * + * Requires: MBEDTLS_BIGNUM_C, MBEDTLS_OID_C, MBEDTLS_PK_WRITE_C + * + * This module is the basis for creating X.509 certificates and CSRs. + */ +/*#define MBEDTLS_X509_CREATE_C */ + +/** + * \def MBEDTLS_X509_CRT_WRITE_C + * + * Enable creating X.509 certificates. + * + * Module: library/x509_crt_write.c + * + * Requires: MBEDTLS_X509_CREATE_C + * + * This module is required for X.509 certificate creation. + */ +/*#define MBEDTLS_X509_CRT_WRITE_C */ + +/** + * \def MBEDTLS_X509_CSR_WRITE_C + * + * Enable creating X.509 Certificate Signing Requests (CSR). + * + * Module: library/x509_csr_write.c + * + * Requires: MBEDTLS_X509_CREATE_C + * + * This module is required for X.509 certificate request writing. + */ +/*#define MBEDTLS_X509_CSR_WRITE_C */ + +/* \} name SECTION: mbed TLS modules */ + +/** + * \name SECTION: Module configuration options + * + * This section allows for the setting of module specific sizes and + * configuration options. The default values are already present in the + * relevant header files and should suffice for the regular use cases. + * + * Our advice is to enable options and change their values here + * only if you have a good reason and know the consequences. + * + * Please check the respective header file for documentation on these + * parameters (to prevent duplicate documentation). + * \{ + */ + +/* MPI / BIGNUM options */ +/*#define MBEDTLS_MPI_WINDOW_SIZE 6 / **< Maximum window size used. * / */ +/*#define MBEDTLS_MPI_MAX_SIZE 1024 / **< Maximum number of bytes for usable MPIs. * / */ + +/* CTR_DRBG options */ +/*#define MBEDTLS_CTR_DRBG_ENTROPY_LEN 48 / **< Amount of entropy used per seed by default (48 with SHA-512, 32 with SHA-256) * / */ +/*#define MBEDTLS_CTR_DRBG_RESEED_INTERVAL 10000 / **< Interval before reseed is performed by default * / */ +/*#define MBEDTLS_CTR_DRBG_MAX_INPUT 256 / **< Maximum number of additional input bytes * / */ +/*#define MBEDTLS_CTR_DRBG_MAX_REQUEST 1024 / **< Maximum number of requested bytes per call * / */ +/*#define MBEDTLS_CTR_DRBG_MAX_SEED_INPUT 384 / **< Maximum size of (re)seed buffer * / */ + +/* HMAC_DRBG options */ +/*#define MBEDTLS_HMAC_DRBG_RESEED_INTERVAL 10000 / **< Interval before reseed is performed by default * / */ +/*#define MBEDTLS_HMAC_DRBG_MAX_INPUT 256 / **< Maximum number of additional input bytes * / */ +/*#define MBEDTLS_HMAC_DRBG_MAX_REQUEST 1024 / **< Maximum number of requested bytes per call * / */ +/*#define MBEDTLS_HMAC_DRBG_MAX_SEED_INPUT 384 / **< Maximum size of (re)seed buffer * / */ + +/* ECP options */ +/*#define MBEDTLS_ECP_WINDOW_SIZE 4 / **< Maximum window size used * / */ +/*#define MBEDTLS_ECP_FIXED_POINT_OPTIM 1 / **< Enable fixed-point speed-up * / */ + +/* Entropy options */ +/*#define MBEDTLS_ENTROPY_MAX_SOURCES 20 / **< Maximum number of sources supported * / */ +/*#define MBEDTLS_ENTROPY_MAX_GATHER 128 / **< Maximum amount requested from entropy sources * / */ +/*#define MBEDTLS_ENTROPY_MIN_HARDWARE 32 / **< Default minimum number of bytes required for the hardware entropy source mbedtls_hardware_poll() before entropy is released * / */ + +/* Memory buffer allocator options */ +/*#define MBEDTLS_MEMORY_ALIGN_MULTIPLE 4 / **< Align on multiples of this value * / */ + +/* Platform options */ +/*#define MBEDTLS_PLATFORM_STD_MEM_HDR / **< Header to include if MBEDTLS_PLATFORM_NO_STD_FUNCTIONS is defined. Don't define if no header is needed. * / */ +/*#define MBEDTLS_PLATFORM_STD_CALLOC calloc / **< Default allocator to use, can be undefined * / */ +/*#define MBEDTLS_PLATFORM_STD_FREE free / **< Default free to use, can be undefined * / */ +/*#define MBEDTLS_PLATFORM_STD_EXIT exit / **< Default exit to use, can be undefined * / */ +/*#define MBEDTLS_PLATFORM_STD_TIME time / **< Default time to use, can be undefined. MBEDTLS_HAVE_TIME must be enabled * / */ +/*#define MBEDTLS_PLATFORM_STD_FPRINTF fprintf / **< Default fprintf to use, can be undefined * / */ +/*#define MBEDTLS_PLATFORM_STD_PRINTF printf / **< Default printf to use, can be undefined * / */ +/* Note: your snprintf must correctly zero-terminate the buffer! */ +/*#define MBEDTLS_PLATFORM_STD_SNPRINTF snprintf / **< Default snprintf to use, can be undefined * / */ +/*#define MBEDTLS_PLATFORM_STD_EXIT_SUCCESS 0 / **< Default exit value to use, can be undefined * / */ +/*#define MBEDTLS_PLATFORM_STD_EXIT_FAILURE 1 / **< Default exit value to use, can be undefined * / */ +/*#define MBEDTLS_PLATFORM_STD_NV_SEED_READ mbedtls_platform_std_nv_seed_read / **< Default nv_seed_read function to use, can be undefined * / */ +/*#define MBEDTLS_PLATFORM_STD_NV_SEED_WRITE mbedtls_platform_std_nv_seed_write / **< Default nv_seed_write function to use, can be undefined * / */ +/*#define MBEDTLS_PLATFORM_STD_NV_SEED_FILE "seedfile" / **< Seed file to read/write with default implementation * / */ + +/* To Use Function Macros MBEDTLS_PLATFORM_C must be enabled */ +/* MBEDTLS_PLATFORM_XXX_MACRO and MBEDTLS_PLATFORM_XXX_ALT cannot both be defined */ +/*#define MBEDTLS_PLATFORM_CALLOC_MACRO mbedtls_platform_calloc / **< Default allocator macro to use, can be undefined */ +/*#define MBEDTLS_PLATFORM_FREE_MACRO mbedtls_platform_free / **< Default free macro to use, can be undefined */ +/*#define MBEDTLS_PLATFORM_EXIT_MACRO exit / **< Default exit macro to use, can be undefined * / */ +/*#define MBEDTLS_PLATFORM_TIME_MACRO time / **< Default time macro to use, can be undefined. MBEDTLS_HAVE_TIME must be enabled * / */ +/*#define MBEDTLS_PLATFORM_TIME_TYPE_MACRO time_t / **< Default time macro to use, can be undefined. MBEDTLS_HAVE_TIME must be enabled * / */ +/*#define MBEDTLS_PLATFORM_FPRINTF_MACRO fprintf / **< Default fprintf macro to use, can be undefined * / */ +/*#define MBEDTLS_PLATFORM_PRINTF_MACRO printf / **< Default printf macro to use, can be undefined * / */ +/* Note: your snprintf must correctly zero-terminate the buffer! */ +/*#define MBEDTLS_PLATFORM_SNPRINTF_MACRO snprintf / **< Default snprintf macro to use, can be undefined * / */ +/*#define MBEDTLS_PLATFORM_VSNPRINTF_MACRO vsnprintf / **< Default vsnprintf macro to use, can be undefined * / */ +/*#define MBEDTLS_PLATFORM_NV_SEED_READ_MACRO mbedtls_platform_std_nv_seed_read / **< Default nv_seed_read function to use, can be undefined * / */ +/*#define MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO mbedtls_platform_std_nv_seed_write / **< Default nv_seed_write function to use, can be undefined * / */ + +/* PSA options */ + +/** + * Use HMAC_DRBG with the specified hash algorithm for HMAC_DRBG for the + * PSA crypto subsystem. + * + * If this option is unset: + * - If CTR_DRBG is available, the PSA subsystem uses it rather than HMAC_DRBG. + * - Otherwise, the PSA subsystem uses HMAC_DRBG with either + * #MBEDTLS_MD_SHA512 or #MBEDTLS_MD_SHA256 based on availability and + * on unspecified heuristics. + */ +/*#define MBEDTLS_PSA_HMAC_DRBG_MD_TYPE MBEDTLS_MD_SHA256 */ + +/** \def MBEDTLS_PSA_KEY_SLOT_COUNT + * Restrict the PSA library to supporting a maximum amount of simultaneously + * loaded keys. A loaded key is a key stored by the PSA Crypto core as a + * volatile key, or a persistent key which is loaded temporarily by the + * library as part of a crypto operation in flight. + * + * If this option is unset, the library will fall back to a default value of + * 32 keys. + */ +/*#define MBEDTLS_PSA_KEY_SLOT_COUNT 16 */ + +/* SSL Cache options */ +/*#define MBEDTLS_SSL_CACHE_DEFAULT_TIMEOUT 86400 / **< 1 day * / */ +/*#define MBEDTLS_SSL_CACHE_DEFAULT_MAX_ENTRIES 50 / **< Maximum entries in cache * / */ + +/* SSL options */ + +/** \def MBEDTLS_SSL_IN_CONTENT_LEN + * + * Maximum length (in bytes) of incoming plaintext fragments. + * + * This determines the size of the incoming TLS I/O buffer in such a way + * that it is capable of holding the specified amount of plaintext data, + * regardless of the protection mechanism used. + * + * \note When using a value less than the default of 16KB on the client, it is + * recommended to use the Maximum Fragment Length (MFL) extension to + * inform the server about this limitation. On the server, there + * is no supported, standardized way of informing the client about + * restriction on the maximum size of incoming messages, and unless + * the limitation has been communicated by other means, it is recommended + * to only change the outgoing buffer size #MBEDTLS_SSL_OUT_CONTENT_LEN + * while keeping the default value of 16KB for the incoming buffer. + * + * Uncomment to set the maximum plaintext size of the incoming I/O buffer. + */ +/*#define MBEDTLS_SSL_IN_CONTENT_LEN 16384 */ + +/** \def MBEDTLS_SSL_CID_IN_LEN_MAX + * + * The maximum length of CIDs used for incoming DTLS messages. + * + */ +/*#define MBEDTLS_SSL_CID_IN_LEN_MAX 32 */ + +/** \def MBEDTLS_SSL_CID_OUT_LEN_MAX + * + * The maximum length of CIDs used for outgoing DTLS messages. + * + */ +/*#define MBEDTLS_SSL_CID_OUT_LEN_MAX 32 */ + +/** \def MBEDTLS_SSL_CID_TLS1_3_PADDING_GRANULARITY + * + * This option controls the use of record plaintext padding + * in TLS 1.3 and when using the Connection ID extension in DTLS 1.2. + * + * The padding will always be chosen so that the length of the + * padded plaintext is a multiple of the value of this option. + * + * Note: A value of \c 1 means that no padding will be used + * for outgoing records. + * + * Note: On systems lacking division instructions, + * a power of two should be preferred. + */ +/*#define MBEDTLS_SSL_CID_TLS1_3_PADDING_GRANULARITY 16 */ + +/** \def MBEDTLS_SSL_OUT_CONTENT_LEN + * + * Maximum length (in bytes) of outgoing plaintext fragments. + * + * This determines the size of the outgoing TLS I/O buffer in such a way + * that it is capable of holding the specified amount of plaintext data, + * regardless of the protection mechanism used. + * + * It is possible to save RAM by setting a smaller outward buffer, while keeping + * the default inward 16384 byte buffer to conform to the TLS specification. + * + * The minimum required outward buffer size is determined by the handshake + * protocol's usage. Handshaking will fail if the outward buffer is too small. + * The specific size requirement depends on the configured ciphers and any + * certificate data which is sent during the handshake. + * + * Uncomment to set the maximum plaintext size of the outgoing I/O buffer. + */ +/*#define MBEDTLS_SSL_OUT_CONTENT_LEN 16384 */ + +/** \def MBEDTLS_SSL_DTLS_MAX_BUFFERING + * + * Maximum number of heap-allocated bytes for the purpose of + * DTLS handshake message reassembly and future message buffering. + * + * This should be at least 9/8 * MBEDTLSSL_IN_CONTENT_LEN + * to account for a reassembled handshake message of maximum size, + * together with its reassembly bitmap. + * + * A value of 2 * MBEDTLS_SSL_IN_CONTENT_LEN (32768 by default) + * should be sufficient for all practical situations as it allows + * to reassembly a large handshake message (such as a certificate) + * while buffering multiple smaller handshake messages. + * + */ +/*#define MBEDTLS_SSL_DTLS_MAX_BUFFERING 32768 */ + +/*#define MBEDTLS_PSK_MAX_LEN 32 / **< Max size of TLS pre-shared keys, in bytes (default 256 bits) * / */ +/*#define MBEDTLS_SSL_COOKIE_TIMEOUT 60 / **< Default expiration delay of DTLS cookies, in seconds if HAVE_TIME, or in number of cookies issued * / */ + +/** + * Complete list of ciphersuites to use, in order of preference. + * + * \warning No dependency checking is done on that field! This option can only + * be used to restrict the set of available ciphersuites. It is your + * responsibility to make sure the needed modules are active. + * + * Use this to save a few hundred bytes of ROM (default ordering of all + * available ciphersuites) and a few to a few hundred bytes of RAM. + * + * The value below is only an example, not the default. + */ +/*#define MBEDTLS_SSL_CIPHERSUITES MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 */ + +/* X509 options */ +/*#define MBEDTLS_X509_MAX_INTERMEDIATE_CA 8 / **< Maximum number of intermediate CAs in a verification chain. * / */ +/*#define MBEDTLS_X509_MAX_FILE_PATH_LEN 512 / **< Maximum length of a path/filename string in bytes including the null terminator character ('\0'). * / */ + +/** + * Uncomment the macro to let mbed TLS use your alternate implementation of + * mbedtls_platform_zeroize(). This replaces the default implementation in + * platform_util.c. + * + * mbedtls_platform_zeroize() is a widely used function across the library to + * zero a block of memory. The implementation is expected to be secure in the + * sense that it has been written to prevent the compiler from removing calls + * to mbedtls_platform_zeroize() as part of redundant code elimination + * optimizations. However, it is difficult to guarantee that calls to + * mbedtls_platform_zeroize() will not be optimized by the compiler as older + * versions of the C language standards do not provide a secure implementation + * of memset(). Therefore, MBEDTLS_PLATFORM_ZEROIZE_ALT enables users to + * configure their own implementation of mbedtls_platform_zeroize(), for + * example by using directives specific to their compiler, features from newer + * C standards (e.g using memset_s() in C11) or calling a secure memset() from + * their system (e.g explicit_bzero() in BSD). + */ +/*#define MBEDTLS_PLATFORM_ZEROIZE_ALT */ + +/** + * Uncomment the macro to let Mbed TLS use your alternate implementation of + * mbedtls_platform_gmtime_r(). This replaces the default implementation in + * platform_util.c. + * + * gmtime() is not a thread-safe function as defined in the C standard. The + * library will try to use safer implementations of this function, such as + * gmtime_r() when available. However, if Mbed TLS cannot identify the target + * system, the implementation of mbedtls_platform_gmtime_r() will default to + * using the standard gmtime(). In this case, calls from the library to + * gmtime() will be guarded by the global mutex mbedtls_threading_gmtime_mutex + * if MBEDTLS_THREADING_C is enabled. We recommend that calls from outside the + * library are also guarded with this mutex to avoid race conditions. However, + * if the macro MBEDTLS_PLATFORM_GMTIME_R_ALT is defined, Mbed TLS will + * unconditionally use the implementation for mbedtls_platform_gmtime_r() + * supplied at compile time. + */ +/*#define MBEDTLS_PLATFORM_GMTIME_R_ALT */ + +/** + * Enable the verified implementations of ECDH primitives from Project Everest + * (currently only Curve25519). This feature changes the layout of ECDH + * contexts and therefore is a compatibility break for applications that access + * fields of a mbedtls_ecdh_context structure directly. See also + * MBEDTLS_ECDH_LEGACY_CONTEXT in include/mbedtls/ecdh.h. + */ +/*#define MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED */ + +/* \} name SECTION: Customisation configuration options */ + +/*#define MBEDTLS_PSA_CRYPTO_C */ + +/*#undef MBEDTLS_PSA_CRYPTO_C */ diff --git a/applications/object_detection/configs/mbedtls_config/threading_alt.h b/applications/object_detection/configs/mbedtls_config/threading_alt.h new file mode 100644 index 00000000..1b177933 --- /dev/null +++ b/applications/object_detection/configs/mbedtls_config/threading_alt.h @@ -0,0 +1,61 @@ +/* + * FreeRTOS V202112.00 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + +/** + * @file threading_alt.h + * @brief mbed TLS threading functions implemented for FreeRTOS. + */ + + +#ifndef MBEDTLS_THREADING_ALT_H_ +#define MBEDTLS_THREADING_ALT_H_ + +/* FreeRTOS includes. */ +#include "FreeRTOS.h" +#include "semphr.h" + +/** + * @brief mbed TLS mutex type. + * + * mbed TLS requires platform specific definition for the mutext type. Defining the type for + * FreeRTOS with FreeRTOS semaphore + * handle and semaphore storage as members. + */ +typedef struct mbedtls_threading_mutex +{ + SemaphoreHandle_t mutexHandle; + StaticSemaphore_t mutexStorage; +} mbedtls_threading_mutex_t; + +/* mbed TLS mutex functions. */ +void mbedtls_platform_mutex_init( mbedtls_threading_mutex_t * pMutex ); +void mbedtls_platform_mutex_free( mbedtls_threading_mutex_t * pMutex ); +int mbedtls_platform_mutex_lock( mbedtls_threading_mutex_t * pMutex ); +int mbedtls_platform_mutex_unlock( mbedtls_threading_mutex_t * pMutex ); + + + +#endif /* ifndef MBEDTLS_THREADING_ALT_H_ */ diff --git a/applications/object_detection/configs/tfm_config/project_config.h b/applications/object_detection/configs/tfm_config/project_config.h new file mode 100644 index 00000000..86414f75 --- /dev/null +++ b/applications/object_detection/configs/tfm_config/project_config.h @@ -0,0 +1,86 @@ +/* Copyright 2023-2024, 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/applications/object_detection/isp/CMakeLists.txt b/applications/object_detection/isp/CMakeLists.txt new file mode 100644 index 00000000..4188c5f3 --- /dev/null +++ b/applications/object_detection/isp/CMakeLists.txt @@ -0,0 +1,23 @@ +# Copyright 2023-2024 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: MIT + +add_library(isp-config INTERFACE) + +target_include_directories(isp-config + INTERFACE + . +) + +target_sources(isp-config + INTERFACE + acamera_callbacks.c + isp_app.c + isp_config.c +) + +target_link_libraries(isp-config + INTERFACE + isp_control + helpers-logging +) diff --git a/applications/object_detection/isp/acamera_callbacks.c b/applications/object_detection/isp/acamera_callbacks.c new file mode 100644 index 00000000..fd7aa5ec --- /dev/null +++ b/applications/object_detection/isp/acamera_callbacks.c @@ -0,0 +1,213 @@ +/* Copyright 2024, Arm Limited and/or its affiliates + * + * SPDX-License-Identifier: MIT + */ + +#include "acamera_logger.h" +#include "acamera_types.h" +#include "application_command_api.h" + +#include "isp_config.h" + +pvFrameReadyHandler_t pvDownscaledFrameReady = NULL; +pvFrameReadyHandler_t pvFullResolutionFrameReady = NULL; + +static uint32_t ulCoherentDmaAllocatedSize = 0; +typedef uint8_t ucFrameBuffer_t[ isp_configMAX_OUTPUT_FRAME_SIZE ]; +static ucFrameBuffer_t * xFullResolutionBuffer = ( ucFrameBuffer_t * ) isp_configFULL_RESOLUTION_BUFFER_BASE; +static ucFrameBuffer_t * xDownscaledBuffer = ( ucFrameBuffer_t * ) isp_configDOWNSCALED_BUFFER_BASE; + +/* This is for FVP stream optimisation */ +#include "FreeRTOS.h" +#include "semphr.h" +extern SemaphoreHandle_t xStreamSemaphore; + +/* Only 1 allocation is supported, it is for the Temper Frame */ +void * pvCallbackDmaAllocCoherent( uint32_t ulContextId, + uint64_t ullSize, + uint64_t * ullDmaAddress ) +{ + uint32_t ulAddress; + + if( ulCoherentDmaAllocatedSize + ullSize > isp_configCOHERENT_DMA_MEMORY_SIZE ) + { + LOG( LOG_ERR, "Not enough memory" ); + *ullDmaAddress = 0; + return NULL; + } + + ulAddress = isp_configCOHERENT_DMA_MEMORY_BASE + ulCoherentDmaAllocatedSize; + ulCoherentDmaAllocatedSize += ullSize; + + *ullDmaAddress = ulAddress; + + /* compute bus address */ + *ullDmaAddress -= ISP_SOC_DMA_BUS_OFFSET; + + LOG( LOG_DEBUG, + "DMA alloc: 0x%x, Memory left: 0x%x", + ( uint32_t ) ullSize, + isp_configCOHERENT_DMA_MEMORY_SIZE - ulCoherentDmaAllocatedSize ); + return ( void * ) ulAddress; +} + +/* Only 1 allocation is supported, it is for the Temper Frame */ +void vCallbackDmaFreeCoherent( uint32_t ulContextId, + uint64_t ullSize, + void * pvVirtualAddress, + uint64_t ullDmaAddress ) +{ + if( ( ( uint32_t ) pvVirtualAddress ) != isp_configCOHERENT_DMA_MEMORY_SIZE ) + { + LOG( LOG_ERR, "DMA free: Trying to fr ee unknown memory: 0x%x", ( uint32_t ) pvVirtualAddress ); + } + + ulCoherentDmaAllocatedSize = 0; +} + +int32_t lCallbackStreamGetFrame( uint32_t ulContextId, + acamera_stream_type_t xType, + aframe_t * pxAFrames, + uint64_t ullNumPlanes ) +{ + static uint32_t ulDownscaledFrameCounter = 0; + uint32_t ulAddress = 0; + + while( ullNumPlanes > 1 ) + { + ullNumPlanes--; + pxAFrames[ ullNumPlanes ].address = 0; + pxAFrames[ ullNumPlanes ].status = dma_buf_purge; + } + + if( xType == ACAMERA_STREAM_FR ) + { + static uint32_t ulFullResolutionFrameCounter = 0; + ulAddress = ( uint32_t ) xFullResolutionBuffer[ ulFullResolutionFrameCounter % isp_configMAX_BUFFERED_FRAMES ]; + ulFullResolutionFrameCounter++; + } + else if( xType == ACAMERA_STREAM_DS1 ) + { + ulAddress = ( uint32_t ) xDownscaledBuffer[ ulDownscaledFrameCounter % isp_configMAX_BUFFERED_FRAMES ]; + ulDownscaledFrameCounter++; + } + + pxAFrames[ 0 ].address = ulAddress; + + if( ulAddress == 0 ) + { + LOG( LOG_ERR, "No buffer available!" ); + pxAFrames[ 0 ].status = dma_buf_purge; + return -1; + } + + pxAFrames[ 0 ].status = dma_buf_empty; + return 0; +} + +/* Return pixel width in bits for format. */ +static inline uint32_t prvGetPixelWidth( uint32_t ulFormat ) +{ + uint32_t ulResult = 32; + + switch( ulFormat ) + { + case DMA_FORMAT_RGB24: + ulResult = 24; + break; + + case DMA_FORMAT_RGB565: + case DMA_FORMAT_RAW16: + case DMA_FORMAT_YUY2: + case DMA_FORMAT_UYVY: + ulResult = 16; + break; + + case DMA_FORMAT_RAW12: + ulResult = 12; + break; + + case DMA_FORMAT_NV12_Y: + case DMA_FORMAT_NV12_UV: + case DMA_FORMAT_NV12_VU: + case DMA_FORMAT_YV12_Y: + case DMA_FORMAT_YV12_U: + case DMA_FORMAT_YV12_V: + ulResult = 8; + break; + } + + return ulResult; +} + +int32_t lCallbackStreamPutFrame( uint32_t ulContextId, + acamera_stream_type_t xType, + aframe_t * pxAFrames, + uint64_t ullNumPlanes ) +{ + uint32_t ulAddress; + uint32_t ulWidth; + uint32_t ulHeight; + uint32_t ulBitsPerPixel; + uint32_t ulFormat; + uint32_t ulBitsPerPixelFormat; + + /* Note: We only care about the first plane */ + LOG( LOG_CRIT, "\033[1;33m-- aframes->frame_id = %d --\033[1;0m", pxAFrames->frame_id ); + + while( ullNumPlanes > 0 ) + { + ullNumPlanes--; + pxAFrames[ ullNumPlanes ].status = dma_buf_purge; + } + + if( pxAFrames->address ) + { + ulAddress = pxAFrames->address; + ulWidth = pxAFrames->width; + ulHeight = pxAFrames->height; + ulBitsPerPixel = pxAFrames->size / ulWidth / ulHeight; + + LOG( LOG_CRIT, "\033[1;33m-- %u X %u @ %u bytes per pixel --\033[1;0m", ulWidth, ulHeight, ulBitsPerPixel ); + } + + if( xType == ACAMERA_STREAM_DS1 ) + { + application_command( TIMAGE, DS1_FORMAT_BASE_PLANE_ID, 0, COMMAND_GET, &ulFormat ); + ulBitsPerPixelFormat = _get_pixel_width( ulFormat ) / 8; + + if( ulBitsPerPixel != ulBitsPerPixelFormat ) + { + /* Current frame and current format mismatch */ + /* Default to 2 bytes = RGB565, otherwise RGB32 */ + ulFormat = ( ulBitsPerPixel == 2 ) ? DMA_FORMAT_RGB565 : DMA_FORMAT_RGB32; + LOG( LOG_NOTICE, "Bits per pixel mismatch! Expected: %u. Using format: 0x%x", ulBitsPerPixelFormat * 8, ulFormat ); + } + + if( pvDownscaledFrameReady != NULL ) + { + pvDownscaledFrameReady( ulAddress, ulWidth, ulHeight, ulFormat, pxAFrames->frame_id ); + } + + /* Let stream thread start the next frame */ + xSemaphoreGive( xStreamSemaphore ); + } + else if( xType == ACAMERA_STREAM_FR ) + { + application_command( TIMAGE, FR_FORMAT_BASE_PLANE_ID, 0, COMMAND_GET, &ulFormat ); + ulBitsPerPixelFormat = _get_pixel_width( ulFormat ) / 8; + + if( ulBitsPerPixel != ulBitsPerPixelFormat ) + { + ulFormat = ( ulBitsPerPixel == 2 ) ? DMA_FORMAT_RGB565 : DMA_FORMAT_RGB32; + LOG( LOG_NOTICE, "Bits per pixel mismatch! Expected: %u. Using format: 0x%x", ulBitsPerPixelFormat * 8, ulFormat ); + } + + if( pvFullResolutionFrameReady != NULL ) + { + pvFullResolutionFrameReady( ulAddress, ulWidth, ulHeight, ulFormat, pxAFrames->frame_id ); + } + } + + return 0; +} diff --git a/applications/object_detection/isp/isp_app.c b/applications/object_detection/isp/isp_app.c new file mode 100644 index 00000000..2bb71f74 --- /dev/null +++ b/applications/object_detection/isp/isp_app.c @@ -0,0 +1,318 @@ +/* Copyright 2024, Arm Limited and/or its affiliates + * + * SPDX-License-Identifier: MIT + */ + +#include "acamera_command_api.h" +#include "acamera_control_config.h" +#include "acamera_firmware_api.h" +#include "acamera_firmware_config.h" +#include "acamera_interface_config.h" +#include "acamera_logger.h" + +#include "application_command_api.h" + +#include "system_cdma_platform.h" +#include "system_interrupts.h" + +#if ISP_HAS_STREAM_CONNECTION + #include "acamera_connection.h" +#endif + +#include "FreeRTOS.h" +#include "semphr.h" +#include "task.h" +#include "events.h" + +#include "isp_config.h" + +#define ENABLE_TPG_AT_START 0 + +static acamera_settings xACameraSettings[ FIRMWARE_CONTEXT_NUMBER ] = +{ + { + .sensor_init = fvp_sensor_init, + .sensor_deinit = fvp_sensor_deinit, + .get_calibrations = get_calibrations_dummy, + .lens_init = NULL, + .lens_deinit = NULL, + .isp_base = 0x0, + .hw_isp_addr = ISP_SOC_START_ADDR, + .callback_dma_alloc_coherent = pvCallbackDmaAllocCoherent, + .callback_dma_free_coherent = vCallbackDmaFreeCoherent, + .callback_stream_get_frame = lCallbackStreamGetFrame, + .callback_stream_put_frame = lCallbackStreamPutFrame, + }, +}; + +/* This example will run the infinite loop to process the firmware events. */ +/* This variable also can be changed outside to stop the processing. */ +volatile int32_t lACameraMainLoopActive = 1; + +/* Stream semaphore is used to block stream thread until previous frame is displayed */ +SemaphoreHandle_t xStreamSemaphore; +StaticSemaphore_t xStreamSemaphoreBuffer; + +#if ISP_HAS_STREAM_CONNECTION && CONNECTION_IN_THREAD + static void connection_thread( void * pvParameters ); +#endif +static void prvStreamControlThread( void * pvParameters ); +static void prvACameraThread( void * pvParameters ); + +/* this is a main application IRQ handler to drive the firmware */ +/* The main purpose is to redirect ISP irq event to the firmware core */ +/* Please see the ACamera Porting Guide for details. */ +static void prvInterruptHandler( void * pvPtr, + uint32_t ulMask ) +{ + /* the lower bits are for ISP interrupts on ACamera FPGA reference platform */ + uint32_t ulIspMask = ulMask & 0x0000FFFF; + + /* tell the firmware that isp interrupts happened */ + if( ulIspMask ) + { + /* the first irq pins are connected to ISP */ + acamera_interrupt_handler(); + } +} + +static void prvCreateTasks() +{ + /* ACamera provides a simple protocol to communicate with firmware */ + /* outside application. Several channels are supported depend on the */ + /* system requirements. */ + /* To start using ACamera Control Tool the connection must be initialised */ + /* before by calling acamera_connection_init */ + /* The connection module parses input commands from ACT and call the required */ + /* api command like acamera_command or acamera_calibrations. */ + /* Please see acamera_command_api.h for details. */ + #if ISP_HAS_STREAM_CONNECTION + #if !CONNECTION_IN_THREAD + acamera_connection_init(); + #else + + /*xTaskCreate(connection_thread, + * "connection", + * configMINIMAL_STACK_SIZE * 2, + * NULL, + * (configMAX_PRIORITIES - 1) | portPRIVILEGE_BIT, + * NULL);*/ + #endif + #endif + + xTaskCreate( prvACameraThread, + "acamera", + configMINIMAL_STACK_SIZE * 4, + NULL, + ( configMAX_PRIORITIES - 2 ) | portPRIVILEGE_BIT, + NULL ); + + xStreamSemaphore = xSemaphoreCreateBinaryStatic( &xStreamSemaphoreBuffer ); + xTaskCreate( prvStreamControlThread, + "stream", + configMINIMAL_STACK_SIZE, + NULL, + ( configMAX_PRIORITIES - 3 ) | portPRIVILEGE_BIT, + NULL ); +} + +static int prvIspInitialConfig() +{ + int32_t lResult; + uint32_t ulReturnCode; + uint32_t ulContextNumber; + uint32_t ulPreviousContextNumber = 0; + + /* The firmware supports multicontext. */ + /* It means that the customer can use the same firmware for controlling */ + /* several instances of different sensors/isp. To initialise a context */ + /* the structure acamera_settings must be filled properly. */ + /* the total number of initialized context must not exceed FIRMWARE_CONTEXT_NUMBER */ + /* all contexts are numerated from 0 till ctx_number - 1 */ + lResult = acamera_init( xACameraSettings, FIRMWARE_CONTEXT_NUMBER ); + + if( lResult != 0 ) + { + LOG( LOG_ERR, "Failed to start firmware processing thread. (0x%x)", lResult ); + return lResult; + } + + application_command( TGENERAL, ACTIVE_CONTEXT, 0, COMMAND_GET, &ulPreviousContextNumber ); + + system_interrupt_set_handler( prvInterruptHandler, NULL ); + + for( ulContextNumber = 0; ulContextNumber < FIRMWARE_CONTEXT_NUMBER; ulContextNumber++ ) + { + application_command( TGENERAL, ACTIVE_CONTEXT, ulContextNumber, COMMAND_SET, &ulReturnCode ); + + /* Disable most ISP calibrations. FVP sensor streams processed RGB images which does not need calibration */ + application_command( TALGORITHMS, AE_MODE_ID, AE_FULL_MANUAL, COMMAND_SET, &ulReturnCode ); + application_command( TALGORITHMS, AWB_MODE_ID, AWB_MANUAL, COMMAND_SET, &ulReturnCode ); + + application_command( TISP_MODULES, ISP_MODULES_MANUAL_TEMPER, ON, COMMAND_SET, &ulReturnCode ); + application_command( TISP_MODULES, ISP_MODULES_MANUAL_IRIDIX, ON, COMMAND_SET, &ulReturnCode ); + + application_command( TSYSTEM, SYSTEM_MANUAL_EXPOSURE, ON, COMMAND_SET, &ulReturnCode ); + application_command( TSYSTEM, SYSTEM_MANUAL_EXPOSURE_RATIO, ON, COMMAND_SET, &ulReturnCode ); + application_command( TSYSTEM, SYSTEM_MANUAL_ISP_DIGITAL_GAIN, ON, COMMAND_SET, &ulReturnCode ); + application_command( TSYSTEM, SYSTEM_MANUAL_AWB, ON, COMMAND_SET, &ulReturnCode ); + +#define AWB_GAIN 9 + application_command( TSYSTEM, SYSTEM_AWB_BLUE_GAIN, AWB_GAIN, COMMAND_SET, &ulReturnCode ); + application_command( TSYSTEM, SYSTEM_AWB_GREEN_EVEN_GAIN, AWB_GAIN, COMMAND_SET, &ulReturnCode ); + application_command( TSYSTEM, SYSTEM_AWB_GREEN_ODD_GAIN, AWB_GAIN, COMMAND_SET, &ulReturnCode ); + application_command( TSYSTEM, SYSTEM_AWB_RED_GAIN, AWB_GAIN, COMMAND_SET, &ulReturnCode ); +#define CCM_GAIN 4095 + application_command( TSYSTEM, SYSTEM_MANUAL_CCM, ON, COMMAND_SET, &ulReturnCode ); + application_command( TSYSTEM, SYSTEM_CCM_MATRIX_RR, CCM_GAIN, COMMAND_SET, &ulReturnCode ); + application_command( TSYSTEM, SYSTEM_CCM_MATRIX_GG, CCM_GAIN, COMMAND_SET, &ulReturnCode ); + application_command( TSYSTEM, SYSTEM_CCM_MATRIX_BB, CCM_GAIN, COMMAND_SET, &ulReturnCode ); + application_command( TSYSTEM, SYSTEM_CCM_MATRIX_RG, 0, COMMAND_SET, &ulReturnCode ); + application_command( TSYSTEM, SYSTEM_CCM_MATRIX_RB, 0, COMMAND_SET, &ulReturnCode ); + application_command( TSYSTEM, SYSTEM_CCM_MATRIX_GR, 0, COMMAND_SET, &ulReturnCode ); + application_command( TSYSTEM, SYSTEM_CCM_MATRIX_GB, 0, COMMAND_SET, &ulReturnCode ); + application_command( TSYSTEM, SYSTEM_CCM_MATRIX_BR, 0, COMMAND_SET, &ulReturnCode ); + application_command( TSYSTEM, SYSTEM_CCM_MATRIX_BG, 0, COMMAND_SET, &ulReturnCode ); + + application_command( TSYSTEM, TEST_PATTERN_MODE_ID, 5, COMMAND_SET, &ulReturnCode ); + + #if ENABLE_TPG_AT_START + application_command( TSYSTEM, TEST_PATTERN_ENABLE_ID, ON, COMMAND_SET, &ulReturnCode ); + #endif + + application_command( TSCENE_MODES, SHARPENING_STRENGTH_ID, 0, COMMAND_SET, &ulReturnCode ); + + application_command( TIMAGE, FR_FORMAT_BASE_PLANE_ID, DMA_FORMAT_RGB565, COMMAND_SET, &ulReturnCode ); + application_command( TIMAGE, DS1_FORMAT_BASE_PLANE_ID, DMA_FORMAT_RGB565, COMMAND_SET, &ulReturnCode ); + } + + application_command( TGENERAL, ACTIVE_CONTEXT, ulPreviousContextNumber, COMMAND_SET, &ulReturnCode ); + + return 0; +} + +int32_t lIspInit() +{ + system_cdma_setup(); + prvCreateTasks(); + return 0; +} + +/* On systems which support pthreads it is more efficient to run */ +/* control channel in a separate thread to let the firmware to communicate */ +/* with ACamera Control Tool (ACT) */ +/* ACT allows to change the firmware behaviour by calling API functions, change ISP registers and */ +/* update calibration LUTs. */ +/* Please read the ACamera Control Tool User Guide for details */ +#if ISP_HAS_STREAM_CONNECTION && CONNECTION_IN_THREAD + static void connection_thread( void * pvParameters ) + { + /* acamera_connection_init is used to initialize the */ + /* communication channel between the firmware application */ + /* and the firmware. It is used only together with ACT tool */ + /* and may be omitted on the customer discretion */ + /* if ACT is not required */ + acamera_connection_init(); + + for( ; ; ) + { + /* the function checks the incoming requests from */ + /* ACT tool and call the corresponding API command. */ + /* Please note that acamera_connection_process may be omitted */ + /* if ACT tool is not used for the firmware API. */ + acamera_connection_process(); + } + } +#endif /* if ISP_HAS_STREAM_CONNECTION && CONNECTION_IN_THREAD */ + +extern volatile uint32_t UART_PLEASE_HOLD_STREAM; +static void prvStreamControlThread( void * pvParameters ) +{ + uint32_t ulFrameCount = 0; + + while( 1 ) + { + EventBits_t xFlags = xEventGroupWaitBits( xSystemEvents, ( EventBits_t ) EVENT_MASK_ML_STOP, pdTRUE, pdFAIL, 10 ); + + if( xFlags & EVENT_MASK_ML_STOP ) + { + /* jump out to outer loop */ + LogInfo( ( "Stopping processing\r\n" ) ); + break; + } + + if( STREAM_ENABLED ) + { + if( !ulFrameCount || !UART_PLEASE_HOLD_STREAM ) + { + LOG( LOG_CRIT, "\033[1;34m-- CAMERA STREAM TRIGGER #%d --\033[1;0m", ulFrameCount ); + ulFrameCount++; + *( ( uint8_t * ) ( ISP_VIRTUAL_CAMERA_BASE_NS ) ) = 0x1; /* camera enable */ + } + + /* Displaying a frame gives the semaphore. If previous frame is not yet + * displayed, or no frames have been displayed, task waits 100 ticks. */ + xSemaphoreTake( xStreamSemaphore, 100 ); + } + + vTaskDelay( 5 ); + } +} + +static void prvACameraThread( void * pvParameters ) +{ + static uint32_t ulDoInitialSetup = 1; + uint32_t ulReturnCode = 0; + + if( prvIspInitialConfig() ) + { + lACameraMainLoopActive = 0; + } + + /* acamera_process function must be called on every incoming interrupt */ + /* to give the firmware the possibility to apply */ + /* all internal algorithms and change the ISP state. */ + /* The external application can be run in the same loop on bare metal systems. */ + while( lACameraMainLoopActive ) + { + /* acamera_process must be called for each initialised context */ + acamera_process(); + #if ISP_HAS_STREAM_CONNECTION && !CONNECTION_IN_THREAD + /* acamera_connection_process is used for communication between */ + /* firmware and ACT through different possible channels like */ + /* cmd_queue memory in ISP, socket, UART, chardev etc. */ + /* Different channels can be supported depending on the target */ + /* platform. The common case when cmd_queue buffer is used */ + /* ( see acamera_isp_config.h ) */ + /* The channels supported by this routine can be used not only on */ + /* NIOS2 platform but on the customer system as well. */ + acamera_connection_process(); + #endif + + /* This needs to be after first acamera_process(); because for the first time, it resets the FSMs and */ + /* Crop FSM resets the scaler width/height values */ + if( ulDoInitialSetup ) + { + ulDoInitialSetup = 0; + application_command( TIMAGE, IMAGE_RESIZE_TYPE_ID, SCALER_DS, COMMAND_SET, &ulReturnCode ); + application_command( TIMAGE, IMAGE_RESIZE_WIDTH_ID, 192, COMMAND_SET, &ulReturnCode ); + application_command( TIMAGE, IMAGE_RESIZE_HEIGHT_ID, 192, COMMAND_SET, &ulReturnCode ); + application_command( TIMAGE, IMAGE_RESIZE_ENABLE_ID, RUN, COMMAND_SET, &ulReturnCode ); + + application_command( TSENSOR, SENSOR_STREAMING, ON, COMMAND_SET, &ulReturnCode ); + } + + taskYIELD(); + } + + /* this api function will free */ + /* all resources allocated by the firmware */ + acamera_terminate(); + + LOG( LOG_CRIT, "Acamera terminated" ); + + for( ; ; ) + { + /* Task shouldn't exit */ + } +} diff --git a/applications/object_detection/isp/isp_config.c b/applications/object_detection/isp/isp_config.c new file mode 100644 index 00000000..8cf89e81 --- /dev/null +++ b/applications/object_detection/isp/isp_config.c @@ -0,0 +1,459 @@ +/* Copyright 2024, Arm Limited and/or its affiliates + * + * SPDX-License-Identifier: MIT + */ + +#include CMSIS_device_header + +#include "device_cfg.h" +#include "device_definition.h" +#include "hdlcd_drv.h" +#include "hdlcd_helper.h" +#include "stdint.h" +#include +#include + +#include "arm_2d.h" + +#include "isp_config.h" + +#include "ml_interface.h" + +/* + * Semihosting is a mechanism that enables code running on an ARM target + * to communicate and use the Input/Output facilities of a host computer + * that is running a debugger. + * There is an issue where if you use armclang at -O0 optimisation with + * no parameters specified in the main function, the initialisation code + * contains a breakpoint for semihosting by default. This will stop the + * code from running before main is reached. + * Semihosting can be disabled by defining __ARM_use_no_argv symbol + * (or using higher optimization level). + */ +#if defined( __ARMCC_VERSION ) && ( __ARMCC_VERSION >= 6010050 ) + __asm( " .global __ARM_use_no_argv\n" ); +#endif + +#define isp_configHIGHLIGHTED_FRAME_WIDTH 2 + +#define isp_configMAX_BORDER_WIDTH 320 +#define isp_configMAX_BORDER_HEIGHT 240 +#define isp_configMAX_BORDER_BYTES_PER_PIXEL 4 +#define isp_configBORDER_BUFFER_SIZE ( isp_configMAX_BORDER_WIDTH * isp_configMAX_BORDER_HEIGHT * isp_configMAX_BORDER_BYTES_PER_PIXEL ) + +#define isp_configMAX_DETECT_RESULTS 10 + +/* This buffer is used by FP unit, align it to prevent unaligned FP faults */ +static uint8_t ucBorderTileBuffer[ isp_configBORDER_BUFFER_SIZE ] __ALIGNED( 4 ); +static volatile uint8_t ucFlag = 0; + +static struct LastFrame xLastFrame = +{ + .ulDisplayed = 0, + .ulInferred = 0, + .xFullResolution = + { + .ulMode = HDLCD_PIXEL_FORMAT_NOT_SUPPORTED, + .ulWidth = 0, + .ulHeight = 0 + } +}; + +struct arm_2d_tile_t xRootTile = +{ + .tInfo = + { + .bIsRoot = true, + .bHasEnforcedColour = true, + }, +}; + +#define isp_configMAX_INFER_FRAME_WIDTH 192 +#define isp_configMAX_INFER_FRAME_HEIGHT 192 +#define isp_configMAX_INFER_FRAME_SIZE ( isp_configMAX_INFER_FRAME_WIDTH * isp_configMAX_INFER_FRAME_HEIGHT ) +uint8_t ucGrayBuffer[ isp_configMAX_INFER_FRAME_SIZE ] __attribute__( ( aligned( 32 ) ) ); +static void prvHdlcdShow( uint32_t address, + uint32_t width, + uint32_t height, + uint32_t mode ); +static void prvHandleFullResolutionFrame( uint32_t ulAddress, + uint32_t ulWidth, + uint32_t ulHeight, + uint32_t ulMode, + uint32_t ulFrameId ); +static void prvHandleDownscaledFrame( uint32_t ulAddress, + uint32_t ulWidth, + uint32_t ulHeight, + uint32_t ulMode, + uint32_t ulFrameId ); +static void prvDrawFrameOnTile( struct arm_2d_tile_t * pxDest, + struct arm_2d_region_t * pxFrame, + enum hdlcd_pixel_format eFormat ); +void vHDLCDHandler( void ); +void vEnableHdlcdIrq( void ); +void vDisableHdlcdIrq( void ); + +extern int32_t lIspInit(); +extern void arm_2d_init( void ); + +void vStartISPDemo() +{ + enum hdlcd_error_t eHdlcdErr; + + NVIC_SetPriority( ISP_IRQn, 7 ); + NVIC_SetPriority( HDLCD_IRQn, 7 ); + NVIC_SetPriority( NPU0_IRQn, 5 ); + NVIC_SetPriority( UARTTX0_IRQn, 4 ); + + LogInfo( ( "ISP init\r\n" ) ); + + arm_2d_init(); + + LogInfo( ( "Starting HDLCD config!\r\n" ) ); + + eHdlcdErr = hdlcd_init( &HDLCD_DEV ); + + if( eHdlcdErr != HDLCD_ERR_NONE ) + { + LogInfo( ( "HDLCD init error! \r\n" ) ); + + while( 1 ) + { + } + } + + eHdlcdErr = hdlcd_static_config( &HDLCD_DEV ); + + if( eHdlcdErr != HDLCD_ERR_NONE ) + { + LogInfo( ( "HDLCD static config error! \r\n" ) ); + + while( 1 ) + { + } + } + + LogInfo( ( "Starting ISP init!\r\n" ) ); + + lIspInit(); + + pvDownscaledFrameReady = prvHandleDownscaledFrame; + pvFullResolutionFrameReady = prvHandleFullResolutionFrame; +} + +static uint32_t ulHdlcdToArm2dColorScheme( enum hdlcd_pixel_format eFormat ) +{ + switch( eFormat ) + { + case HDLCD_PIXEL_FORMAT_RGB565: + return ARM_2D_COLOUR_RGB565; + + case HDLCD_PIXEL_FORMAT_RGB32: + return ARM_2D_COLOUR_RGB32; + + case HDLCD_PIXEL_FORMAT_A2R10G10B10: + return ARM_2D_COLOUR_32BIT; + + default: + return 0; + } +} + +void vRgbToGrayscale( const uint8_t * pucSrcImage, + uint8_t * pucDstImage, + const size_t xDstImageSize, + enum hdlcd_pixel_format eFormat ) +{ + const struct hdlcd_pixel_cfg_t * const pxPixelConfig = HDLCD_MODES[ eFormat ].pixel_cfg; + const uint32_t ulRedOffset = pxPixelConfig->red.offset; + const uint32_t ulGreenOffset = pxPixelConfig->green.offset; + const uint32_t ulBlueOffset = pxPixelConfig->blue.offset; + const uint32_t ulRedMask = ( 0x1UL << pxPixelConfig->red.bit_size ) - 1; + const uint32_t ulGreenMask = ( 0x1UL << pxPixelConfig->green.bit_size ) - 1; + const uint32_t ulBlueMask = ( 0x1UL << pxPixelConfig->blue.bit_size ) - 1; + const float xRed = 0.299 * ( 0x1UL << ( 8 - pxPixelConfig->red.bit_size ) ); + const float xGreen = 0.587 * ( 0x1UL << ( 8 - pxPixelConfig->green.bit_size ) ); + const float xBlue = 0.114 * ( 0x1UL << ( 8 - pxPixelConfig->blue.bit_size ) ); + + for( size_t i = 0; i < xDstImageSize; ++i, pucSrcImage += HDLCD_MODES[ eFormat ].bytes_per_pixel ) + { + uint32_t ulGrayIntensity = xRed * ( ( ( *( uint32_t * ) pucSrcImage ) >> ulRedOffset ) & ulRedMask ) + xGreen * ( ( ( *( uint32_t * ) pucSrcImage ) >> ulGreenOffset ) & ulGreenMask ) + + xBlue * ( ( ( *( uint32_t * ) pucSrcImage ) >> ulBlueOffset ) & ulBlueMask ); + *pucDstImage++ = ulGrayIntensity <= 0xff ? ulGrayIntensity : 0xff; + } +} + +void vGrayscaleToRgb( const uint8_t * pucSrcImage, + uint8_t * pucDstImage, + const size_t xSrcImageSize, + enum hdlcd_pixel_format eFormat ) +{ + const struct hdlcd_pixel_cfg_t * const pxPixelConfig = HDLCD_MODES[ eFormat ].pixel_cfg; + const uint32_t ulRedOffset = pxPixelConfig->red.offset; + const uint32_t ulGreenOffset = pxPixelConfig->green.offset; + const uint32_t ulBlueOffset = pxPixelConfig->blue.offset; + const uint32_t ulRedMask = ( 0x1UL << pxPixelConfig->red.bit_size ) - 1; + const uint32_t ulGreenMask = ( 0x1UL << pxPixelConfig->green.bit_size ) - 1; + const uint32_t ulBlueMask = ( 0x1UL << pxPixelConfig->blue.bit_size ) - 1; + uint32_t ulColor; + uint32_t ulGrayMinimum = 0xff; + uint32_t ulGrayMaximum = 0x00; + + for( size_t i = 0; i < xSrcImageSize; ++i, pucDstImage += HDLCD_MODES[ eFormat ].bytes_per_pixel ) + { + ulColor = ( ( ( ( ( uint32_t ) *pucSrcImage ) >> ( 8 - pxPixelConfig->red.bit_size ) ) & ulRedMask ) << ulRedOffset ) + | ( ( ( ( ( uint32_t ) *pucSrcImage ) >> ( 8 - pxPixelConfig->green.bit_size ) ) & ulGreenMask ) << ulGreenOffset ) + | ( ( ( ( ( uint32_t ) *pucSrcImage ) >> ( 8 - pxPixelConfig->blue.bit_size ) ) & ulBlueMask ) << ulBlueOffset ); + + if( ( uint32_t ) *pucSrcImage > ulGrayMaximum ) + { + ulGrayMaximum = ( uint32_t ) *pucSrcImage; + } + + if( ( uint32_t ) *pucSrcImage < ulGrayMinimum ) + { + ulGrayMinimum = ( uint32_t ) *pucSrcImage; + } + + for( size_t j = 0; j < HDLCD_MODES[ eFormat ].bytes_per_pixel; j++ ) + { + pucDstImage[ j ] = ( ( uint8_t * ) &ulColor )[ j ]; + } + + pucSrcImage++; + } + + LogInfo( ( "srcGray: %02u-%02u\r\n", ulGrayMinimum, ulGrayMaximum ) ); +} + +static void prvHandleFullResolutionFrame( uint32_t ulAddress, + uint32_t ulWidth, + uint32_t ulHeight, + uint32_t ulMode, + uint32_t ulFrameId ) +{ + /* If the previous full frame wasn't inferred yet, skip this frame */ + if( xLastFrame.ulDisplayed == xLastFrame.ulInferred ) + { + xLastFrame.ulDisplayed = ulFrameId; + xLastFrame.xFullResolution.ulMode = ulMode; + xLastFrame.xFullResolution.ulWidth = ulWidth; + xLastFrame.xFullResolution.ulHeight = ulHeight; + prvHdlcdShow( ulAddress, ulWidth, ulHeight, ulMode ); + } +} + +static void prvHandleDownscaledFrame( uint32_t ulAddress, + uint32_t ulWidth, + uint32_t ulHeight, + uint32_t ulMode, + uint32_t ulFrameId ) +{ + xLastFrame.ulInferred = ulFrameId; + uint32_t i = 0UL; + uint32_t ulResultsCount = 0UL; + struct DetectRegion_t xResults[ isp_configMAX_DETECT_RESULTS ]; + float xUpscaleWidth = xLastFrame.xFullResolution.ulWidth / ulWidth; + float xUpscaleHeight = xLastFrame.xFullResolution.ulHeight / ulHeight; + + static struct arm_2d_region_t xFrameRegion = { 0 }; + enum hdlcd_pixel_format ePixelFormat = HDLCD_PIXEL_FORMAT_RGB565; + + if( ePixelFormat == HDLCD_PIXEL_FORMAT_NOT_SUPPORTED ) + { + LogError( ( "Unsupported pixel format: 0x%x\r\n", xLastFrame.xFullResolution.ulMode ) ); + return; + } + + if( ulWidth * ulHeight > isp_configMAX_INFER_FRAME_SIZE ) + { + LogError( ( "Input frame too big for inference!\r\n" ) ); + return; + } + + /* Note: mode Vs xLastFrame.xFullResolution.ulMode */ + LogInfo( ( "Converting to Gray: 0x%x -> 0x%x\r\n", ulAddress, ( uint32_t ) ucGrayBuffer ) ); + vRgbToGrayscale( ( uint8_t * ) ulAddress, ucGrayBuffer, ulWidth * ulHeight, HDLCD_PIXEL_FORMAT_RGB565 ); + + /*taskENTER_CRITICAL(); */ + ulResultsCount = isp_configMAX_DETECT_RESULTS; + lMLRunInference( ucGrayBuffer, xResults, &ulResultsCount ); + /*taskEXIT_CRITICAL(); */ + + hdlcd_disable( &HDLCD_DEV ); + + /* Draw frame according to selected region in the secondary buffer */ + for( i = 0; i < ulResultsCount; i++ ) + { + xFrameRegion.tSize.iWidth = ( int ) xResults[ i ].ulW * xUpscaleWidth; + xFrameRegion.tSize.iHeight = ( int ) xResults[ i ].ulH * xUpscaleHeight; + xFrameRegion.tLocation.iX = ( int ) xResults[ i ].ulX * xUpscaleWidth; + xFrameRegion.tLocation.iY = ( int ) xResults[ i ].ulY * xUpscaleHeight; + + if( xFrameRegion.tSize.iWidth < isp_configHIGHLIGHTED_FRAME_WIDTH * 3 ) + { + xFrameRegion.tSize.iWidth = isp_configHIGHLIGHTED_FRAME_WIDTH * 3; + } + + if( xFrameRegion.tSize.iHeight < isp_configHIGHLIGHTED_FRAME_WIDTH * 3 ) + { + xFrameRegion.tSize.iHeight = isp_configHIGHLIGHTED_FRAME_WIDTH * 3; + } + + prvDrawFrameOnTile( &xRootTile, &xFrameRegion, ePixelFormat ); + } + + hdlcd_enable( &HDLCD_DEV ); + /* Wait until HDLCD is displayed at least once */ + ucFlag = 0; + vEnableHdlcdIrq(); + + while( ucFlag < 5 ) + { + } + + vDisableHdlcdIrq(); +} + +static void prvHdlcdShow( uint32_t ulAddress, + uint32_t ulWidth, + uint32_t ulHeight, + uint32_t ulMode ) +{ + struct hdlcd_resolution_cfg_t xCustomResolutionConfig = { 0 }; + + enum hdlcd_error_t eHdlcdErr = 0; + enum hdlcd_pixel_format ePixelFormat = HDLCD_PIXEL_FORMAT_RGB565; + + LogInfo( ( "Displaying image...\r\n" ) ); + + if( ePixelFormat == HDLCD_PIXEL_FORMAT_NOT_SUPPORTED ) + { + LogError( ( "Unsupported pixel format: 0x%x\r\n", ulMode ) ); + return; + } + + hdlcd_disable( &HDLCD_DEV ); + + /* Note: This only works, because FVP ignores all timing values */ + xCustomResolutionConfig.v_data = ulHeight; + xCustomResolutionConfig.h_data = ulWidth; + hdlcd_set_custom_resolution( &HDLCD_DEV, &xCustomResolutionConfig ); + + struct hdlcd_buffer_cfg_t xHdlcdBuffer = + { + .base_address = ulAddress, + .line_length = ulWidth * HDLCD_MODES[ ePixelFormat ].bytes_per_pixel, + .line_count = ulHeight - 1, + .line_pitch = ulWidth * HDLCD_MODES[ ePixelFormat ].bytes_per_pixel, + .pixel_format = HDLCD_MODES[ ePixelFormat ].pixel_format + }; + + eHdlcdErr = hdlcd_buffer_config( &HDLCD_DEV, &xHdlcdBuffer ); + + if( eHdlcdErr != HDLCD_ERR_NONE ) + { + LogError( ( "HDLCD buffer config error! \r\n" ) ); + + while( 1 ) + { + } + } + + eHdlcdErr = hdlcd_pixel_config( &HDLCD_DEV, HDLCD_MODES[ ePixelFormat ].pixel_cfg ); + + if( eHdlcdErr != HDLCD_ERR_NONE ) + { + LogError( ( "HDLCD pixel config error! \r\n" ) ); + + while( 1 ) + { + } + } + + xRootTile.pwBuffer = ( uint32_t * ) ulAddress; + xRootTile.tRegion.tSize.iWidth = ulWidth; + xRootTile.tRegion.tSize.iHeight = ulHeight; + xRootTile.tInfo.tColourInfo.chScheme = ulHdlcdToArm2dColorScheme( ePixelFormat ); + + hdlcd_enable( &HDLCD_DEV ); + + LogInfo( ( "Image displayed\r\n" ) ); +} + +static void prvDrawFrameOnTile( struct arm_2d_tile_t * pxDestination, + struct arm_2d_region_t * pxFrame, + enum hdlcd_pixel_format eFormat ) +{ + static struct arm_2d_region_t xBlendRegion = { 0 }; + static struct arm_2d_tile_t xBorderTile = { 0 }; + uint_fast8_t xOpacity = 0xFF; + + xBlendRegion.tSize.iWidth = ( pxFrame->tSize.iWidth - 2 * isp_configHIGHLIGHTED_FRAME_WIDTH ); + xBlendRegion.tSize.iHeight = ( pxFrame->tSize.iHeight - 2 * isp_configHIGHLIGHTED_FRAME_WIDTH ); + xBlendRegion.tLocation.iX = isp_configHIGHLIGHTED_FRAME_WIDTH; + xBlendRegion.tLocation.iY = isp_configHIGHLIGHTED_FRAME_WIDTH; + + xBorderTile.tRegion.tSize.iWidth = pxFrame->tSize.iWidth; + xBorderTile.tRegion.tSize.iHeight = pxFrame->tSize.iHeight; + xBorderTile.tInfo.bIsRoot = true; + xBorderTile.tInfo.bHasEnforcedColour = true; + xBorderTile.tInfo.tColourInfo.chScheme = ulHdlcdToArm2dColorScheme( eFormat ); + xBorderTile.pwBuffer = ( uint32_t * ) ucBorderTileBuffer; + + if( eFormat == HDLCD_PIXEL_FORMAT_RGB565 ) + { + arm_2dp_rgb16_fill_colour( + NULL, &xBorderTile, &xBorderTile.tRegion, ( uint16_t ) HDLCD_MODES[ eFormat ].default_highlight_color ); + arm_2dp_rgb16_fill_colour( NULL, &xBorderTile, &xBlendRegion, ( uint16_t ) HDLCD_MODES[ eFormat ].default_mask_color ); + arm_2dp_rgb565_tile_copy_with_colour_keying_and_opacity( + NULL, + &xBorderTile, + pxDestination, + pxFrame, + xOpacity, + ( arm_2d_color_rgb565_t ) { .tValue = ( uint16_t ) HDLCD_MODES[ eFormat ].default_mask_color } ); + } + else + { + arm_2dp_rgb32_fill_colour( + NULL, &xBorderTile, &xBorderTile.tRegion, HDLCD_MODES[ eFormat ].default_highlight_color ); + arm_2dp_rgb32_fill_colour( NULL, &xBorderTile, &xBlendRegion, HDLCD_MODES[ eFormat ].default_mask_color ); + arm_2dp_cccn888_tile_copy_with_colour_keying_and_opacity( + NULL, + &xBorderTile, + pxDestination, + pxFrame, + xOpacity, + ( arm_2d_color_cccn888_t ) { .tValue = HDLCD_MODES[ eFormat ].default_mask_color } ); + } +} + +void vHDLCDHandler( void ) +{ + /* Clear IRQ */ + uint32_t ulIrqState = hdlcd_get_irq_state( &HDLCD_DEV ); + + hdlcd_clear_irq( &HDLCD_DEV, ulIrqState ); + + if( ulIrqState & INT_DMA_END_Msk ) + { + ucFlag++; + } + + __NVIC_ClearPendingIRQ( HDLCD_IRQn ); +} + +void vEnableHdlcdIrq( void ) +{ + NVIC_ClearPendingIRQ( HDLCD_IRQn ); + NVIC_SetVector( HDLCD_IRQn, ( uint32_t ) vHDLCDHandler ); + NVIC_EnableIRQ( HDLCD_IRQn ); + hdlcd_enable_irq( &HDLCD_DEV, INT_DMA_END_Msk ); +} + +void vDisableHdlcdIrq( void ) +{ + NVIC_DisableIRQ( HDLCD_IRQn ); + hdlcd_disable_irq( &HDLCD_DEV, INT_DMA_END_Msk ); +} diff --git a/applications/object_detection/isp/isp_config.h b/applications/object_detection/isp/isp_config.h new file mode 100644 index 00000000..689f0ccf --- /dev/null +++ b/applications/object_detection/isp/isp_config.h @@ -0,0 +1,93 @@ +/* Copyright 2024, Arm Limited and/or its affiliates + * + * SPDX-License-Identifier: MIT + */ + +#include "acamera_firmware_api.h" +#include "acamera_sensor_api.h" +#include "acamera_types.h" + +#include "platform_base_address.h" + +#include "logging_levels.h" + +/* Logging configuration for the MQTT library. */ +#ifndef LIBRARY_LOG_NAME + #define LIBRARY_LOG_NAME "ISP" +#endif + +#ifndef LIBRARY_LOG_LEVEL + #define LIBRARY_LOG_LEVEL LOG_INFO +#endif + +#include "logging_stack.h" + +#define isp_configCOHERENT_DMA_MEMORY_BASE DDR4_BLK2_BASE_NS + +#define isp_configMAX_FRAME_WIDTH 2048 +#define isp_configMAX_FRAME_HEIGHT 1080 +#define isp_configMAX_BITS_PER_PIXEL 20 +#define isp_configMAX_BYTES_PER_PIXEL 4 +#define isp_configMAX_INPUT_FRAME_SIZE ( isp_configMAX_FRAME_WIDTH * isp_configMAX_FRAME_HEIGHT * isp_configMAX_BITS_PER_PIXEL / 8 ) +#define isp_configMAX_OUTPUT_FRAME_SIZE ( isp_configMAX_FRAME_WIDTH * isp_configMAX_FRAME_HEIGHT * isp_configMAX_BYTES_PER_PIXEL ) + +/* 5400KB */ +#define isp_configCOHERENT_DMA_MEMORY_SIZE isp_configMAX_INPUT_FRAME_SIZE + +#define isp_configMAX_BUFFERED_FRAMES 4 +#define isp_configFULL_RESOLUTION_BUFFER_BASE ( isp_configCOHERENT_DMA_MEMORY_BASE + isp_configCOHERENT_DMA_MEMORY_SIZE ) +#define isp_configDOWNSCALED_BUFFER_BASE ( isp_configFULL_RESOLUTION_BUFFER_BASE + ( isp_configMAX_OUTPUT_FRAME_SIZE * isp_configMAX_BUFFERED_FRAMES ) ) + +struct FullResolutionImage +{ + uint32_t ulMode; + uint32_t ulWidth; + uint32_t ulHeight; +}; + +struct LastFrame +{ + uint32_t ulDisplayed; + uint32_t ulInferred; + struct FullResolutionImage xFullResolution; +}; + +typedef void (* pvFrameReadyHandler_t)( uint32_t ulAddress, + uint32_t ulWidth, + uint32_t ulHeight, + uint32_t ulMode, + uint32_t ulFrameId ); + +extern pvFrameReadyHandler_t pvDownscaledFrameReady; +extern pvFrameReadyHandler_t pvFullResolutionFrameReady; + +extern void fvp_sensor_init( void ** ppvContext, + sensor_control_t * ); +extern void fvp_sensor_deinit( void * pvContext ); +extern uint32_t get_calibrations_dummy( uint32_t ulContextNumber, + void * pvSensorArg, + ACameraCalibrations * ); + +extern void * pvCallbackDmaAllocCoherent( uint32_t ulContextId, + uint64_t ullSize, + uint64_t * pullDmaAddress ); +extern void vCallbackDmaFreeCoherent( uint32_t ulContextId, + uint64_t ullSize, + void * pvVirtualAddress, + uint64_t ullDmaAddress ); + +/* The ISP pipeline can have several outputs such as Full Resolution, DownScaler1, DownScaler2 etc */ +/* It is possible to set up the firmware to return the metadata for each output frame from */ +/* the specific channel. This callbacks must be set in acamera_settings structure and passed to the firmware in */ +/* acamera_init api function */ +/* The context id can be used to differentiate contexts */ +extern int32_t lCallbackStreamGetFrame( uint32_t ulContextId, + acamera_stream_type_t xType, + aframe_t * pxAFrames, + uint64_t ullNumPlanes ); +extern int32_t lCallbackStreamPutFrame( uint32_t ulContextId, + acamera_stream_type_t xType, + aframe_t * pxAFrames, + uint64_t ullNumPlanes ); + +void vStartISPDemo(); diff --git a/applications/object_detection/main.c b/applications/object_detection/main.c new file mode 100644 index 00000000..128db86a --- /dev/null +++ b/applications/object_detection/main.c @@ -0,0 +1,324 @@ +/* Copyright 2023-2024, Arm Limited and/or its affiliates + * + * SPDX-License-Identifier: MIT + */ + +#include +#include +#include + +#include "FreeRTOS.h" +#include "task.h" + +#include "app_config.h" +#include "aws_clientcredential.h" +#include "blink_task.h" +#include "dev_mode_key_provisioning.h" +#include "events.h" +#include "mbedtls/platform.h" +#include "mbedtls/threading.h" +#include "ml_interface.h" +#include "mqtt_agent_task.h" +#include "tfm_ns_interface.h" +#include "bsp_serial.h" +#include "aws_mbedtls_config.h" +#include "threading_alt.h" +#include "psa/crypto.h" +#include "tfm_ns_interface.h" + +#include "FreeRTOSConfig.h" + +#ifdef AUDIO_VSI + #include "Driver_SAI.h" +#endif + +/* + * Semihosting is a mechanism that enables code running on an ARM target + * to communicate and use the Input/Output facilities of a host computer + * that is running a debugger. + * There is an issue where if you use armclang at -O0 optimisation with + * no parameters specified in the main function, the initialisation code + * contains a breakpoint for semihosting by default. This will stop the + * code from running before main is reached. + * Semihosting can be disabled by defining __ARM_use_no_argv symbol + * (or using higher optimization level). + */ +#if defined( __ARMCC_VERSION ) && ( __ARMCC_VERSION >= 6010050 ) + __asm( " .global __ARM_use_no_argv\n" ); +#endif + +extern void vStartOtaTask( void ); +extern int32_t network_startup( void ); + +#ifdef AUDIO_VSI + void vVsiCallbackTask( void * arg ); + static void prvStartVsiCallbackTask( void ); + extern uint32_t ulVsiEvent; + extern void (* pxOnVsiEvent)( void * ); + extern void * pvVsiContext; + TaskHandle_t xVsiTaskHandle = NULL; +#endif + +psa_key_handle_t xOTACodeVerifyKeyHandle = 0; +QueueHandle_t xMlMqttQueue = NULL; + +static bool prvAreAwsCredentialsValid( void ) +{ + if( ( strcmp( clientcredentialMQTT_BROKER_ENDPOINT, "dummy.endpointid.amazonaws.com" ) == 0 ) || + ( strcmp( clientcredentialIOT_THING_NAME, "dummy_thingname" ) == 0 ) ) + { + printf( "[ERR] INVALID BROKER ENDPOINT AND/OR THING NAME.\r\n" ); + printf( "[ERR] Set the right credentials in aws_clientcredential.h\r\n" ); + return false; + } + + return true; +} + +void vOtaActiveHook( void ) +{ + vMlTaskInferenceStop(); +} + +void vOtaNotActiveHook( void ) +{ + vMlTaskInferenceStart(); +} + +void vAssertCalled( const char * pcFile, + unsigned long ulLine ) +{ + printf( "ASSERT failed! file %s:%lu, \n", pcFile, ulLine ); + + taskENTER_CRITICAL(); + { + /* Use the debugger to set ul to a non-zero value in order to step out + * of this function to determine why it was called. */ + volatile uint32_t ulLooping = 0; + + while( ulLooping == 0LU ) + { + portNOP(); + } + } + taskEXIT_CRITICAL(); +} + +BaseType_t xApplicationGetRandomNumber( uint32_t * pulNumber ) +{ + return ( BaseType_t ) ( psa_generate_random( ( uint8_t * ) ( pulNumber ), sizeof( uint32_t ) ) == PSA_SUCCESS ); +} + +uint32_t ulApplicationGetNextSequenceNumber( uint32_t ulSourceAddress, + uint16_t usSourcePort, + uint32_t ulDestinationAddress, + uint16_t usDestinationPort ) +{ + ( void ) ulSourceAddress; + ( void ) usSourcePort; + ( void ) ulDestinationAddress; + ( void ) usDestinationPort; + + uint32_t uxRandomValue = 0U; + psa_status_t xPsaStatus = psa_generate_random( ( uint8_t * ) ( &uxRandomValue ), sizeof( uint32_t ) ); + + if( xPsaStatus != PSA_SUCCESS ) + { + LogError( ( "psa_generate_random failed with %d.", xPsaStatus ) ); + configASSERT( 0 ); + } + + return uxRandomValue; +} + +int main( void ) +{ + bsp_serial_init(); + + xLoggingTaskInitialize( appCONFIG_LOGGING_TASK_STACK_SIZE, + appCONFIG_LOGGING_TASK_PRIORITY, + appCONFIG_LOGGING_MESSAGE_QUEUE_LENGTH ); + + UBaseType_t uxStatus = tfm_ns_interface_init(); + + if( uxStatus != 0 ) + { + LogError( ( "TF-M non-secure interface init failed with [%d]. Exiting...\n", uxStatus ) ); + return EXIT_FAILURE; + } + + LogInfo( ( "PSA Framework version is: %d\n", psa_framework_version() ) ); + + if( xEventHelperInit() != 0 ) + { + LogError( ( "System events group was not initialised successfully" ) ); + return EXIT_FAILURE; + } + + ( void ) mbedtls_platform_set_calloc_free( mbedtls_platform_calloc, mbedtls_platform_free ); + + mbedtls_threading_set_alt( mbedtls_platform_mutex_init, + mbedtls_platform_mutex_free, + mbedtls_platform_mutex_lock, + mbedtls_platform_mutex_unlock ); + + UBaseType_t xReturnValue = vDevModeKeyProvisioning(); + + if( xReturnValue != CKR_OK ) + { + LogError( ( "Device key provisioning failed [%d]\n", xReturnValue ) ); + LogError( ( "Device cannot connect to IoT Core. Exiting...\n" ) ); + return EXIT_FAILURE; + } + + LogInfo( ( "Device key provisioning succeeded \n" ) ); + + /* FIXME: Magic value */ + uxStatus = xOtaProvisionCodeSigningKey( &xOTACodeVerifyKeyHandle, 3072 ); + + if( uxStatus != PSA_SUCCESS ) + { + LogError( ( "OTA signing key provision failed [%d]\n", uxStatus ) ); + } + + LogInfo( ( "OTA signing key provisioning succeeded \n" ) ); + + /* The next initializations are done as a part of the main */ + /* function as these resources are shared between tasks */ + /* and it is not guranteed that the task which initialise */ + /* these resources will start first before the tasks using them. */ + xMlMqttQueue = xQueueCreate( 20, sizeof( MLMqttMsg_t ) ); + + if( xMlMqttQueue == NULL ) + { + LogError( ( "Failed to create xMlMqttQueue\r\n" ) ); + return EXIT_FAILURE; + } + + vMlTaskInferenceStop(); + + if( prvAreAwsCredentialsValid() == true ) + { + if( network_startup() != 0 ) + { + return EXIT_FAILURE; + } + + vStartMqttAgentTask(); + + vStartOtaTask(); + + vStartMlMqttTask(); + } + else + { + vMlTaskInferenceStart(); + } + + vStartBlinkTask(); + + vStartMlTask( NULL ); + + vTaskStartScheduler(); + + /* If all is well, the scheduler will now be running, and the following + * line will never be reached. If the following line does execute, then + * there was insufficient FreeRTOS heap memory available for the idle and/or + * timer tasks to be created. See the memory management section on the + * FreeRTOS web site for more details. NOTE: This demo uses static allocation + * for the idle and timer tasks so this line should never execute. */ + while( 1 ) + { + } + + return EXIT_FAILURE; +} + +/** + * Dummy implementation of the callback function vApplicationStackOverflowHook(). + */ +#if ( configCHECK_FOR_STACK_OVERFLOW > 0 ) + __WEAK void vApplicationStackOverflowHook( TaskHandle_t xTask, + char * pcTaskName ) + { + ( void ) xTask; + ( void ) pcTaskName; + + /* Assert when stack overflow is enabled but no application defined function exists */ + configASSERT( 0 ); + } +#endif + +/*---------------------------------------------------------------------------*/ +#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) + +/* + * vApplicationGetIdleTaskMemory gets called when configSUPPORT_STATIC_ALLOCATION + * equals to 1 and is required for static memory allocation support. + */ + + __WEAK void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, + StackType_t ** ppxIdleTaskStackBuffer, + uint32_t * pulIdleTaskStackSize ) + { + /* Idle task control block and stack */ + static StaticTask_t xIdleTCB = { 0 }; + static StackType_t xIdleStack[ configMINIMAL_STACK_SIZE ] = { 0 }; + + *ppxIdleTaskTCBBuffer = &xIdleTCB; + *ppxIdleTaskStackBuffer = &xIdleStack[ 0 ]; + *pulIdleTaskStackSize = ( uint32_t ) configMINIMAL_STACK_SIZE; + } + +/* + * vApplicationGetTimerTaskMemory gets called when configSUPPORT_STATIC_ALLOCATION + * equals to 1 and is required for static memory allocation support. + */ + __WEAK void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer, + StackType_t ** ppxTimerTaskStackBuffer, + uint32_t * pulTimerTaskStackSize ) + { + /* Timer task control block and stack */ + static StaticTask_t xTimerTCB = { 0 }; + static StackType_t xTimerStack[ configTIMER_TASK_STACK_DEPTH ] = { 0 }; + + *ppxTimerTaskTCBBuffer = &xTimerTCB; + *ppxTimerTaskStackBuffer = &xTimerStack[ 0 ]; + *pulTimerTaskStackSize = ( uint32_t ) configTIMER_TASK_STACK_DEPTH; + } +#endif /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) */ + +#ifdef AUDIO_VSI + void vVsiCallbackTask( void * arg ) + { + ( void ) arg; + + while( 1 ) + { + ( void ) ulTaskNotifyTake( pdTRUE, portMAX_DELAY ); + + if( ( ulVsiEvent & ARM_SAI_EVENT_RECEIVE_COMPLETE ) && ( pxOnVsiEvent ) ) + { + pxOnVsiEvent( pvVsiContext ); + } + + if( ulVsiEvent & ARM_SAI_EVENT_RX_OVERFLOW ) + { + LogError( ( "VSI Receive Overflow Error \r\n" ) ); + } + } + } + + static void prvStartVsiCallbackTask( void ) + { + if( xTaskCreate( vVsiCallbackTask, + "VSI_CALLBACK_TASK", + appCONFIG_VSI_CALLBACK_TASK_STACK_SIZE, + NULL, + appCONFIG_VSI_CALLBACK_TASK_PRIORITY, + &xVsiTaskHandle ) != pdPASS ) + { + LogError( ( "Failed to create Vsi Callback Task\r\n" ) ); + } + } +#endif /* ifdef AUDIO_VSI */ diff --git a/applications/object_detection/ml_interface.cc b/applications/object_detection/ml_interface.cc new file mode 100755 index 00000000..c162300b --- /dev/null +++ b/applications/object_detection/ml_interface.cc @@ -0,0 +1,512 @@ +/* Copyright 2021-2024 Arm Limited and/or its affiliates + * + * SPDX-License-Identifier: MIT + */ + +#include "FreeRTOS.h" +#include "queue.h" +#include "task.h" + +#include "ml_interface.h" +#include "AppContext.hpp" +#include "BufAttributes.hpp" +#include "demo_config.h" +extern "C" { +#include "events.h" +#ifdef USE_ETHOS +#include "ethosu_driver.h" +#include "ethosu_npu_init.h" +#endif +} +#include "DetectorPostProcessing.hpp" +#include "DetectorPreProcessing.hpp" +#include "mqtt_agent_task.h" +#include "TensorFlowLiteMicro.hpp" +#include "YoloFastestModel.hpp" +#include CMSIS_device_header +#include "log_macros.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +/* Include header that defines log levels. */ +#include "logging_levels.h" +/* Configure name and log level. */ +#ifndef LIBRARY_LOG_NAME + #define LIBRARY_LOG_NAME "ML_IFC" +#endif +#ifndef LIBRARY_LOG_LEVEL + #define LIBRARY_LOG_LEVEL LOG_INFO +#endif +#include "logging_stack.h" + +#include "isp_config.h" +} + +#include "app_config.h" + +/** + * @brief The topic to subscribe and publish to in the example. + * + * The topic name starts with the client identifier to ensure that each demo + * interacts with a unique topic name. + */ +#define mqttexampleTOPIC democonfigCLIENT_IDENTIFIER "/ml/inference" + +/** + * @brief The MQTT agent manages the MQTT contexts. This set the handle to the + * context used by this demo. + */ +extern MQTTAgentContext_t xGlobalMqttAgentContext; + +/** + * @brief The maximum time for which application waits for an MQTT operation to be complete. + * This involves receiving an acknowledgment for broker for SUBSCRIBE, UNSUBSCRIBE and non + * QOS0 publishes. + */ +#define appMQTT_TIMEOUT_MS ( 5000U ) + +/** + * @brief Used to clear bits in a task's notification value. + */ +#define appMAX_UINT32 ( 0xffffffff ) + +extern EventGroupHandle_t xSystemEvents; +extern QueueHandle_t xMlMqttQueue; + +// Define tensor arena and declare functions required to access the model +namespace arm { + namespace app { + uint8_t ucTensorArena[ACTIVATION_BUF_SZ] ACTIVATION_BUF_ATTRIBUTE; + namespace object_detection { + extern uint8_t *GetModelPointer(); + extern size_t GetModelLen(); + } /* namespace object_detection */ + } /* namespace app */ +} /* namespace arm */ + +namespace { + +// Import +using namespace arm::app; + +// Model +arm::app::ApplicationContext xCaseContext; + +static int prvProcessImage(ApplicationContext &xApplicationContext, const uint8_t *pucImage, struct DetectRegion_t *pxCResults, uint32_t *pulResultsNum); + +extern "C" { + +static void prvAppPublishCommandCallback( MQTTAgentCommandContext_t * pxCommandContext, + MQTTAgentReturnInfo_t * pxReturnInfo ) +{ + pxCommandContext->xReturnStatus = pxReturnInfo->returnCode; + + if( pxCommandContext->xTaskToNotify != NULL ) + { + xTaskNotify( pxCommandContext->xTaskToNotify, ( uint32_t ) ( pxReturnInfo->returnCode ), eSetValueWithOverwrite ); + } +} + +static void prvMqttSendMessage( const char * pcMessage ) +{ + static MQTTPublishInfo_t xPublishInfo = { (MQTTQoS_t)0 }; + static MQTTAgentCommandInfo_t xCommandParams = { 0 }; + static MQTTAgentCommandContext_t xCommandContext = { (MQTTStatus_t)0 }; + MQTTStatus_t xMqttStatus = MQTTBadParameter; + + xPublishInfo.pTopicName = mqttexampleTOPIC; + xPublishInfo.topicNameLength = ( uint16_t ) strlen( mqttexampleTOPIC ); + xPublishInfo.qos = MQTTQoS1; + xPublishInfo.pPayload = pcMessage; + xPublishInfo.payloadLength = strlen( pcMessage ); + + xCommandContext.xTaskToNotify = xTaskGetCurrentTaskHandle(); + xTaskNotifyStateClear( NULL ); + + xCommandParams.blockTimeMs = appMQTT_TIMEOUT_MS; + xCommandParams.cmdCompleteCallback = prvAppPublishCommandCallback; + xCommandParams.pCmdCompleteCallbackContext = ( MQTTAgentCommandContext_t * ) &xCommandContext; + + LogInfo( ( "Attempting to publish (%s) to the MQTT topic %s.\r\n", pcMessage, mqttexampleTOPIC ) ); + xMqttStatus = MQTTAgent_Publish( &xGlobalMqttAgentContext, + &xPublishInfo, + &xCommandParams ); + + /* Wait for command to complete so MQTTSubscribeInfo_t remains in scope for the + * duration of the command. */ + if( xMqttStatus == MQTTSuccess ) + { + BaseType_t xResult = xTaskNotifyWait( 0, appMAX_UINT32, NULL, pdMS_TO_TICKS( appMQTT_TIMEOUT_MS ) ); + + if( xResult != pdTRUE ) + { + xMqttStatus = MQTTSendFailed; + } + else + { + xMqttStatus = xCommandContext.xReturnStatus; + } + } + + if( xMqttStatus != MQTTSuccess ) + { + LogError( ( "Failed to publish result over MQTT" ) ); + } + else + { + LogInfo( ( "Sent PUBLISH packet to broker %.*s to broker.\n", + strlen( mqttexampleTOPIC ), + mqttexampleTOPIC ) ); + } +} + +void vMlTaskInferenceStart(void) +{ + if(xSystemEvents == NULL) + { + LogError( ( "xSystemEvents is not initialised\r\n" ) ); + return; + } + + LogInfo( ( "Signal task inference start\r\n" ) ); + ( void )xEventGroupClearBits( xSystemEvents, (EventBits_t)EVENT_MASK_ML_STOP ); + ( void )xEventGroupSetBits( xSystemEvents, (EventBits_t)EVENT_MASK_ML_START ); + +} + +void vMlTaskInferenceStop(void) +{ + if(xSystemEvents == NULL) + { + LogError( ( "xSystemEvents is not initialised\r\n" ) ); + return; + } + + LogInfo( ( "Signal task inference stop\r\n" ) ); + ( void )xEventGroupClearBits( xSystemEvents, (EventBits_t)EVENT_MASK_ML_START ); + ( void )xEventGroupSetBits( xSystemEvents, (EventBits_t)EVENT_MASK_ML_STOP ); +} + +void vStartMlTask( void *pvParameters ) +{ + if ( + xTaskCreate( + vMlTask, + "ML_TASK", + appCONFIG_ML_TASK_STACK_SIZE, + pvParameters, + appCONFIG_ML_TASK_PRIORITY, + NULL + ) != pdPASS + ) { + LogError( ( "Failed to create ML Task\r\n" ) ); + } +} + +void vStartMlMqttTask( void ) +{ + if ( + xTaskCreate( + vMlMqttTask, + "ML_MQTT", + appCONFIG_ML_MQTT_TASK_STACK_SIZE, + NULL, + appCONFIG_ML_MQTT_TASK_PRIORITY, + NULL + ) != pdPASS + ) { + LogError( ( "Failed to create ML Mqtt Task\r\n" ) ); + } +} + +int32_t lMLRunInference(const uint8_t *pucImg, struct DetectRegion_t *pxResults, uint32_t *pulResultsNum) +{ + prvProcessImage(xCaseContext, pucImg, pxResults, pulResultsNum); + return 0; +} +} // extern "C" { + +static void prvSetMlProcessingstate(const char *pcInferenceResult) +{ + size_t xMsgLen = strlen(pcInferenceResult) + 1; + char *pcMsgResult = reinterpret_cast(malloc(xMsgLen)); + if (pcMsgResult) { + if(xMlMqttQueue == NULL) + { + LogError( ( "xMlMqttQueue is not initialised\r\n" ) ); + free(reinterpret_cast(pcMsgResult)); + return; + } + + memcpy(pcMsgResult, pcInferenceResult, xMsgLen); + const MLMqttMsg_t msg = {pcMsgResult}; + if (xQueueSendToBack(xMlMqttQueue, (void *)&msg, (TickType_t)0) != pdTRUE) { + LogError( ( "Failed to send message to xMlMqttQueue\r\n" ) ); + free(reinterpret_cast(pcMsgResult)); + } + } else { + LogWarn( ( "Failed to send ml processing inference_result (alloc failure)" ) ); + } +} + +/** + * @brief Presents inference results using the data presentation + * object. + * @param[in] platform Reference to the hal platform object. + * @param[in] results Vector of classification results to be displayed. + * @return true if successful, false otherwise. + **/ +static bool prvPresentInferenceResult(const std::vector &xResults); + +static int prvProcessImage(ApplicationContext &xApplicationContext, const uint8_t *pucImage, struct DetectRegion_t *pxCResults, uint32_t *pulResultsNum) +{ + // Get the global model + auto &xModel = xApplicationContext.Get("model"); + + if (!xModel.IsInited()) { + LogError( ("Model is not initialised! Terminating processing.\n") ); + return -1; + } + + TfLiteTensor *xInputTensor = xModel.GetInputTensor(0); + TfLiteTensor *xOutputTensor0 = xModel.GetOutputTensor(0); + TfLiteTensor *xOutputTensor1 = xModel.GetOutputTensor(1); + + if (!xInputTensor->dims) { + LogError( ("Invalid input tensor dims\n") ); + return -1; + } else if (xInputTensor->dims->size < 3) { + LogError( ("Input tensor dimension should be >= 3\n") ); + return -1; + } + + TfLiteIntArray *pxInputShape = xModel.GetInputShape(0); + + const int lInputImgCols = pxInputShape->data[YoloFastestModel::ms_inputColsIdx]; + const int lInputImgRows = pxInputShape->data[YoloFastestModel::ms_inputRowsIdx]; + + /* Set up pre and post-processing. */ + /* RGB to grayscale skipped, already done outside */ + DetectorPreProcess xPreProcess = DetectorPreProcess(xInputTensor, false, xModel.IsDataSigned()); + + std::vector xResults; + const object_detection::PostProcessParams xPostProcessParams{lInputImgRows, + lInputImgCols, + object_detection::originalImageSize, + object_detection::anchor1, + object_detection::anchor2}; + DetectorPostProcess xPostProcess = DetectorPostProcess(xOutputTensor0, xOutputTensor1, xResults, xPostProcessParams); + /* Ensure there are no results leftover from previous inference when running all. */ + xResults.clear(); + + /* Run the pre-processing, inference and post-processing. */ + if (!xPreProcess.DoPreProcess(pucImage, xInputTensor->bytes)) { + LogError( ("Pre-processing failed.") ); + return -1; + } + + /* Run inference over this image. */ + info("Running inference on image at addr 0x%x\n", (uint32_t)pucImage); + + if (!xModel.RunInference()) { + LogError( ("Inference failed.") ); + return -1; + } + + if (!xPostProcess.DoPostProcess()) { + LogError( ("Post-processing failed.") ); + return -1; + } + + for (uint32_t i = 0; i < xResults.size() && i < *pulResultsNum; ++i) { + pxCResults[i].ulX = xResults[i].m_x0; + pxCResults[i].ulY = xResults[i].m_y0; + pxCResults[i].ulW = xResults[i].m_w; + pxCResults[i].ulH = xResults[i].m_h; + } + if (!prvPresentInferenceResult(xResults)) { + return -1; + } + if (*pulResultsNum > xResults.size()) { + *pulResultsNum = xResults.size(); + } + + return 0; +} + +static bool prvPresentInferenceResult(const std::vector &xResults) +{ + /* If profiling is enabled, and the time is valid. */ + LogInfo( ("Final results:\n") ); + LogInfo( ("Total number of inferences: 1\n") ); + LogInfo( ("Detected faces: %d\n", xResults.size()) ); + + for (uint32_t i = 0; i < xResults.size(); ++i) { + LogInfo( ("%" PRIu32 ") (%f) -> %s {x=%d,y=%d,w=%d,h=%d}\n", + i, + xResults[i].m_normalisedVal, + "Detection box:", + xResults[i].m_x0, + xResults[i].m_y0, + xResults[i].m_w, + xResults[i].m_h) ); + } + + std::string xFinalResultStr = "Detected faces: "; + xFinalResultStr += std::to_string( xResults.size() ); + + LogInfo( ( "Complete recognition: %s\n", xFinalResultStr.c_str() ) ); + + // Send the inference result + prvSetMlProcessingstate(xFinalResultStr.c_str()); + + return true; +} + +} // anonymous namespace + +#ifdef USE_ETHOS +extern struct ethosu_driver ethosu_drv; /* Default Ethos-U55 device driver */ + +/** + * @brief Initialises the Arm Ethos-U55 NPU + * @return 0 if successful, error code otherwise + **/ +static int prvArmNpuInit(void); + +static int prvArmNpuInit(void) +{ + int lErr = 0; + + SCB_EnableICache(); + SCB_EnableDCache(); + +#if defined(ETHOS_U_NPU_TIMING_ADAPTER_ENABLED) + /* If the platform has timing adapter blocks along with Ethos-U core + * block, initialise them here. */ + if (0 != (err = arm_ethosu_timing_adapter_init())) { + LogError( ("Failed to init timing adapter\n") ); + return lErr; + } +#endif /* ETHOS_U_NPU_TIMING_ADAPTER_ENABLED */ + + // Initialize the ethos NPU + if (0 != (lErr = arm_ethosu_npu_init())) { + LogError( ("Failed to init arm npu\n") ); + return lErr; + } + + LogInfo( ( "Ethos-U55 device initialised\n" ) ); + + /* Get Ethos-U55 version */ + struct ethosu_driver_version xDriverVersion; + struct ethosu_hw_info xHwInfo; + + ethosu_get_driver_version(&xDriverVersion); + ethosu_get_hw_info(ðosu_drv, &xHwInfo); + + LogInfo( ( "Ethos-U version info:\n" ) ); + LogInfo( ( "\tArch: v%" PRIu32 ".%" PRIu32 ".%" PRIu32 "\n", + xHwInfo.version.arch_major_rev, + xHwInfo.version.arch_minor_rev, + xHwInfo.version.arch_patch_rev ) ); + LogInfo( ( "\tDriver: v%" PRIu8 ".%" PRIu8 ".%" PRIu8 "\n", + xDriverVersion.major, + xDriverVersion.minor, + xDriverVersion.patch ) ); + LogInfo( ( "\tMACs/cc: %" PRIu32 "\n", (uint32_t)(1 << xHwInfo.cfg.macs_per_cc) ) ); + LogInfo( ( "\tCmd stream: v%" PRIu32 "\n", xHwInfo.cfg.cmd_stream_version ) ); + + return 0; +} +#endif /* USE_ETHOS */ + +extern "C" { + +static int prvMlInterfaceInit(void) +{ + static arm::app::YoloFastestModel xModel; /* Model wrapper object. */ + +#ifdef USE_ETHOS + // Initialize the ethos U55 + if (prvArmNpuInit() != 0) { + LogError( ( "Failed to arm npu\n" ) ); + return -1; + } +#endif /* USE_ETHOS */ + + /* Load the model. */ + if (!xModel.Init(arm::app::ucTensorArena, + sizeof(arm::app::ucTensorArena), + arm::app::object_detection::GetModelPointer(), + arm::app::object_detection::GetModelLen())) { + LogError( ( "Failed to initialise model\n" ) ); + return -1; + } + + xModel.ShowModelInfoHandler(); + + /* Instantiate application context. */ + xCaseContext.Set("model", xModel); + + PrintTensorFlowVersion(); + LogInfo( ( "*** ML interface initialised\r\n" ) ); + return 0; +} + +void vMlTask(void *pvParameters) +{ + LogInfo( ( "ML Task start\r\n" ) ); + + EventBits_t xFlags = xEventGroupWaitBits( + xSystemEvents, (EventBits_t)EVENT_MASK_ML_START, pdTRUE, pdFAIL, portMAX_DELAY + ); + + if (xFlags & EVENT_MASK_ML_START) { + LogInfo( ( "Initial start of image processing\r\n" ) ); + } + + if (prvMlInterfaceInit() < 0) { + LogError( ( "prvMlInterfaceInit failed\r\n" ) ); + return; + } + + vStartISPDemo(); + + while (1) { + xFlags = xEventGroupWaitBits( + xSystemEvents, (EventBits_t)EVENT_MASK_ML_STOP, pdTRUE, pdFAIL, 300 + ); + + if (xFlags & EVENT_MASK_ML_STOP) { + LogInfo( ( "Stopping image processing\r\n" ) ); + break; + } + } +} + +void vMlMqttTask(void *pvParameters) +{ + (void)pvParameters; + + while (1) { + MLMqttMsg_t xMsg; + if (xQueueReceive (xMlMqttQueue, &xMsg, portMAX_DELAY) == pdTRUE) { + prvMqttSendMessage(xMsg.pcResult); + free(reinterpret_cast(xMsg.pcResult)); + } else { + LogError( ( "xQueueReceive ML MQTT msg queue failed\r\n" ) ); + } + } +} + +} // extern "C" diff --git a/applications/object_detection/ml_interface.h b/applications/object_detection/ml_interface.h new file mode 100644 index 00000000..c33559af --- /dev/null +++ b/applications/object_detection/ml_interface.h @@ -0,0 +1,71 @@ +/* Copyright 2021-2024, Arm Limited and/or its affiliates + * + * SPDX-License-Identifier: MIT + */ + +#ifndef ML_INTERFACE_H + #define ML_INTERFACE_H + + #include + + #ifdef __cplusplus + extern "C" { + #endif + + struct DetectRegion_t + { + uint32_t ulX; + uint32_t ulY; + uint32_t ulW; + uint32_t ulH; + }; + + typedef struct + { + char * pcResult; + } MLMqttMsg_t; + +/** + * @brief Start the inference task. + */ + void vMlTaskInferenceStart( void ); + +/** + * @brief Stop the inference task. + */ + void vMlTaskInferenceStop( void ); + +/** + * @brief Task to perform ML processing. + * It is gated by the net task which lets it run + * if no ota job is present. + * @param pvParameters Contextual data for the task. + */ + void vMlTask( void * pvParameters ); + +/** + * @brief Task to communicate ML results via MQTT. + * @param pvParameters Contextual data for the task. + */ + void vMlMqttTask( void * pvParameters ); + +/** + * @brief Create ML MQTT task. + */ + void vStartMlMqttTask( void ); + +/** + * @brief Create ML task. + * @param pvParameters Contextual data for the task. + */ + void vStartMlTask( void * pvParameters ); + + int32_t lMLRunInference( const uint8_t * pucImg, + struct DetectRegion_t * pxResults, + uint32_t * pulResultsNum ); + + #ifdef __cplusplus + } + #endif + +#endif /* ! ML_INTERFACE_H */ diff --git a/applications/object_detection/resources/test.frm b/applications/object_detection/resources/test.frm new file mode 100644 index 00000000..18ade61d Binary files /dev/null and b/applications/object_detection/resources/test.frm differ diff --git a/applications/object_detection/resources/use_case_resources.json b/applications/object_detection/resources/use_case_resources.json new file mode 100644 index 00000000..7a56dbcf --- /dev/null +++ b/applications/object_detection/resources/use_case_resources.json @@ -0,0 +1,14 @@ +[ + { + "name": "object_detection", + "url_prefix": [ + "https://github.com/emza-vs/ModelZoo/blob/v1.0/object_detection/" + ], + "resources": [ + { + "name": "yolo-fastest_192_face_v4.tflite", + "url": "{url_prefix:0}yolo-fastest_192_face_v4.tflite?raw=true" + } + ] + } +] diff --git a/applications/object_detection/tests/fail_output.log b/applications/object_detection/tests/fail_output.log new file mode 100644 index 00000000..e69de29b diff --git a/applications/object_detection/tests/pass_output.log b/applications/object_detection/tests/pass_output.log new file mode 100644 index 00000000..f36b4c12 --- /dev/null +++ b/applications/object_detection/tests/pass_output.log @@ -0,0 +1,10 @@ +Waiting for provisioning bundle +Running provisioning bundle +Application version from appFirmwareVersion 0.0.10 +Starting bootloader +Booting TF-M v2.0.0 +PSA Framework version is: 257 +Application version from appFirmwareVersion 0.0.20 +Complete recognition: Detected faces: 2 +Complete recognition: Detected faces: 2 +Complete recognition: Detected faces: 2 diff --git a/docs/object_detection.md b/docs/object_detection.md new file mode 100644 index 00000000..b0e6d54c --- /dev/null +++ b/docs/object_detection.md @@ -0,0 +1,488 @@ +# Object Detection with ISP and OTA support + +## Introduction + +The Object Detection application demonstrates face detection on a `.frm` input frames file by utilising ML accelerator [Ethos-U65](https://www.arm.com/products/silicon-ip-cpu/ethos/ethos-u65) and Versatile Image Signal Processor for Computer Vision [Mali-C55 ISP](https://www.arm.com/products/silicon-ip-multimedia/image-signal-processor/mali-c55). The application encompasses [TrustedFirmware-M](https://www.trustedfirmware.org/projects/tf-m/) running on the secure side, while the ML inference engine (tensorflow-lite) and the model running on the non-secure side of the Armv8-M processor. + +### The following inference configurations are supported: +- ETHOS (uses Ethos-U65) +- ISP (uses Mali-C55) + +### The following frame configurations are supported: +- FRM (From File) + +## Prerequisites + +Follow the instructions described in [Prerequisites](prerequisites.md) and +ensure that all the prerequisites are met before continuing. + +## Setting up AWS connectivity +Follow the instructions described in [Setting Up AWS Connectivity](./setting_up_aws_connectivity.md). + +## Building the application + +### To build the Object-Detection example, run the following command: +```bash +./tools/scripts/build.sh object-detection --certificate_path --private_key_path -t corstone315 --toolchain GNU +``` +- 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 `toolchain` is used to select the `GNU`, that supports the `Mali-C55`. + +### Or, run the command below to perform a clean build: +```bash +./tools/scripts/build.sh object-detection --certificate_path --private_key_path -t corstone315 --toolchain GNU -c +``` + +## Provisioning the device credentials into Protected Storage +Check [Device Provisioning](./device_provisioning.md) for detailed information. + +## Running the application + +```bash +./tools/scripts/run.sh object-detection -t corstone315 --frames applications/object_detection/resources/test.frm +``` +- The `frames` is used to select the input frames file. + +### Expected output + +```log +[INF] Starting bootloader +[INF] Primary image: magic=good, swap_type=0x1, copy_done=0x3, image_ok=0x1 +[INF] Scratch: magic=bad, swap_type=0x1, copy_done=0x2, image_ok=0x2 +[INF] Boot source: primary slot +[INF] Image index: 1, Swap type: test +[INF] Starting swap using scratch algorithm. +[INF] Primary image: magic=good, swap_type=0x1, copy_done=0x3, image_ok=0x1 +[INF] Scratch: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3 +[INF] Boot source: primary slot +[INF] Image index: 0, Swap type: none +[INF] Bootloader chainload address offset: 0x0 +[INF] Jumping to the first image slot +Booting TF-M v2.0.0 +[Sec Thread] Secure image initializing! +[INF][Crypto] Provisioning entropy seed... complete. +0 0 [None] [INFO] PSA Framework version is: 257 +1 0 [None] Write certificate... +2 0 [None] [INFO] Device key provisioning succeeded +3 0 [None] [INFO] OTA signing key provisioning succeeded +4 0 [None] [INFO] Signal task inference stop +5 0 [None] FreeRTOS_AddEndPoint: MAC: 44-21 IPv4: c0a80069ip +6 41 [OTA Task ] [INFO] OTA over MQTT, Application version from appFirmwareVersion 0.0.20 +7 54 [ML_TASK] [INFO] ML Task start +8 59 [BLINK_TASK ] [INFO] Blink task started +9 1000 [IP-Task] DHCP-socket[44-21]: DHCP Socket Create +10 1000 [IP-Task] prvCreateDHCPSocket[44-21]: open, user count 1 +11 1000 [IP-Task] vDHCP_RATimerReload: 250 +12 1250 [IP-Task] vDHCPProcess: offer ac143301ip for MAC address 44-21 +13 1260 [IP-Task] vDHCPProcess: offer ac143301ip for MAC address 44-21 +14 1260 [IP-Task] [INFO] Network is up +15 1260 [IP-Task] prvCloseDHCPSocket[44-21]: closed, user count 0 +16 1260 [IP-Task] vDHCP_RATimerReload: 8640000 +17 1291 [MQTT Agent Task] [INFO] Creating a TLS connection to a1nn4qspc1z547-ats.iot.eu-west-1.amazonaws.com:8883. +18 1307 [MQTT Agent Task] [INFO] Resolving host name: a1nn4qspc1z547-ats.iot.eu-west-1.amazonaws.com. +19 1322 [IP-Task] ipARP_REPLY from ac1433feip to ac143301ip end-point ac143301ip +20 6334 [MQTT Agent Task] DNS_ReadReply returns -11 +21 6341 [MQTT Agent Task] prvIncreaseDNS4Index: from 0 to 0 +22 6356 [MQTT Agent Task] DNS[0xE135]: The answer to 'a1nn4qspc1z547-ats.iot.eu-west-1.amazonaws.com' (99.81.255.142) will be stored +23 6374 [MQTT Agent Task] [INFO] Initiating TCP connection with host: a1nn4qspc1z547-ats.iot.eu-west-1.amazonaws.com:8883 +24 6392 [MQTT Agent Task] FreeRTOS_connect: 37762 to 6351ff8eip:8883 +25 6492 [MQTT Agent Task] [INFO] Initiating TLS handshake with host: a1nn4qspc1z547-ats.iot.eu-west-1.amazonaws.com:8883 +26 8622 [MQTT Agent Task] [INFO] Successfully created a TLS connection to a1nn4qspc1z547-ats.iot.eu-west-1.amazonaws.com:8883. +27 8640 [MQTT Agent Task] [INFO] Creating an MQTT connection to the broker. +28 8993 [MQTT Agent Task] [INFO] MQTT connection established with the broker. +29 9004 [MQTT Agent Task] [INFO] Successfully connected to the MQTT broker. +30 9014 [MQTT Agent Task] [INFO] Session present: 0 +31 9022 [MQTT Agent Task] [INFO] Starting a clean MQTT Session. +32 9031 [OTA Task ] [INFO] Received: 0 Queued: 0 Processed: 0 Dropped: 0 +33 9042 [OTA Agent Task] [INFO] Current State=[RequestingJob], Event=[Start], New state=[RequestingJob] +34 9413 [OTA Agent Task] [INFO] Subscribed to topic $aws/things/iotmsw-ci-test-thing-9ba0432f-e481-4fde-b3e5-a45bcf076e7a/jobs/notify-next. +35 9432 [OTA Agent Task] [INFO] Subscribed to MQTT topic: $aws/things/iotmsw-ci-test-thing-9ba0432f-e481-4fde-b3e5-a45bcf076e7a/jobs/notify-next +36 10163 [MQTT Agent Task] [INFO] Publishing message to $aws/things/iotmsw-ci-test-thing-9ba0432f-e481-4fde-b3e5-a45bcf076e7a/jobs/$next/get. +37 10484 [MQTT Agent Task] [INFO] Ack packet deserialized with result: MQTTSuccess. +38 10496 [MQTT Agent Task] [INFO] State record updated. New state=MQTTPublishDone. +39 10508 [OTA Agent Task] [INFO] Sent PUBLISH packet to broker $aws/things/iotmsw-ci-test-thing-9ba0432f-e481-4fde-b3e5-a45bcf076e7a/jobs/$next/get to broker. +40 10530 [OTA Agent Task] [WARN] OTA Timer handle NULL for Timerid=0, can't stop. +41 10542 [OTA Agent Task] [INFO] Current State=[WaitingForJob], Event=[RequestJobDocument], New state=[WaitingForJob] +42 11258 [MQTT Agent Task] [INFO] De-serialized incoming PUBLISH packet: DeserializerResult=MQTTSuccess. +43 11272 [MQTT Agent Task] [INFO] State record updated. New state=MQTTPublishDone. +44 11284 [MQTT Agent Task] [INFO] Received job message callback, size 1112. +45 11295 [OTA Agent Task] [INFO] Extracted parameter: [key: value]=[execution.jobId: AFR_OTA-ota-test-update-id-9ba0432f-e481-4fde-b3e5-a45bcf076e7a] +46 11318 [OTA Agent Task] [INFO] Extracted parameter: [key: value]=[execution.statusDetails.updatedBy: 10] +47 11335 [OTA Agent Task] [INFO] Extracted parameter: [key: value]=[execution.jobDocument.afr_ota.streamname: AFR_OTA-eac26517-1848-4705-8242-97bda52cab40] +48 11358 [OTA Agent Task] [INFO] Extracted parameter: [key: value]=[execution.jobDocument.afr_ota.protocols: ["MQTT"]] +49 11375 [OTA Agent Task] [INFO] Extracted parameter: [key: value]=[filepath: non_secure image] +50 11389 [OTA Agent Task] [INFO] Extracted parameter: [key: value]=[filesize: 1141641] +51 11402 [OTA Agent Task] [INFO] Extracted parameter: [key: value]=[fileid: 0] +52 11413 [OTA Agent Task] [INFO] Extracted parameter: [key: value]=[certfile: 0] +53 11426 [OTA Agent Task] [INFO] Extracted parameter [ sig-sha256-rsa: LUOGFk3dx7VoXvS7tJl5MJObgHtbCJgZ... ] +54 11442 [OTA Agent Task] [INFO] In self test mode. +55 11450 [OTA Agent Task] [INFO] New image has a higher version number than the current image: New image version=0.0.20, Previous image version=0.0.10 +56 11471 [OTA Agent Task] [INFO] Image version is valid: Begin testing file: File ID=0 +57 12044 [MQTT Agent Task] [INFO] Publishing message to $aws/things/iotmsw-ci-test-thing-9ba0432f-e481-4fde-b3e5-a45bcf076e7a/jobs/AFR_OTA-ota-test-update-id-9ba0432f-e481-4fde-b3e5-a45bcf076e7a/update. +58 12372 [MQTT Agent Task] [INFO] Ack packet deserialized with result: MQTTSuccess. +59 12383 [MQTT Agent Task] [INFO] State record updated. New state=MQTTPublishDone. +60 12395 [MQTT Agent Task] [INFO] De-serialized incoming PUBLISH packet: DeserializerResult=MQTTSuccess. +61 12410 [MQTT Agent Task] [INFO] State record updated. New state=MQTTPublishDone. +62 12421 [OTA Agent Task] [INFO] Sent PUBLISH packet to broker $aws/things/iotmsw-ci-test-thing-9ba0432f-e481-4fde-b3e5-a45bcf076e7a/jobs/AFR_OTA-ota-test-update-id-9ba0432f-e481-4fde-b3e5-a45bcf076e7a/update to broker. +63 12452 [OTA Agent Task] [INFO] Job parsing success: OtaJobParseErr_t=OtaJobParseErrNone, Job name=AFR_OTA-ota-test-update-id-9ba0432f-e481-4fde-b3e5-a45bcf076e7a +64 12475 [OTA Agent Task] [INFO] Signal task inference stop +65 12484 [OTA Agent Task] [INFO] Current State=[CreatingFile], Event=[ReceivedJobDocument], New state=[CreatingFile] +66 12500 [OTA Agent Task] [INFO] Beginning self-test. +67 12508 [OTA Agent Task] [INFO] Received OtaJobEventStartTest callback from OTA Agent. +68 13171 [MQTT Agent Task] [INFO] Publishing message to $aws/things/iotmsw-ci-test-thing-9ba0432f-e481-4fde-b3e5-a45bcf076e7a/jobs/AFR_OTA-ota-test-update-id-9ba0432f-e481-4fde-b3e5-a45bcf076e7a/update. +69 13498 [MQTT Agent Task] [INFO] Ack packet deserialized with result: MQTTSuccess. +70 13510 [MQTT Agent Task] [INFO] State record updated. New state=MQTTPublishDone. +71 13521 [MQTT Agent Task] [INFO] De-serialized incoming PUBLISH packet: DeserializerResult=MQTTSuccess. +72 13536 [MQTT Agent Task] [INFO] State record updated. New state=MQTTPublishDone. +73 13548 [OTA Agent Task] [INFO] Sent PUBLISH packet to broker $aws/things/iotmsw-ci-test-thing-9ba0432f-e481-4fde-b3e5-a45bcf076e7a/jobs/AFR_OTA-ota-test-update-id-9ba0432f-e481-4fde-b3e5-a45bcf076e7a/update to broker. +74 13579 [OTA Agent Task] [INFO] New image validation succeeded in self test mode. +75 13590 [OTA Agent Task] [INFO] OTA active state `4` from OTA Agent. +76 13600 [OTA Agent Task] [INFO] Signal task inference stop +77 13608 [OTA Agent Task] [WARN] OTA Timer handle NULL for Timerid=1, can't stop. +78 13620 [OTA Agent Task] [INFO] Current State=[WaitingForJob], Event=[StartSelfTest], New state=[WaitingForJob] +79 17048 [MQTT Agent Task] [INFO] De-serialized incoming PUBLISH packet: DeserializerResult=MQTTSuccess. +80 17062 [MQTT Agent Task] [INFO] State record updated. New state=MQTTPubAckSend. +81 17074 [MQTT Agent Task] [INFO] Received job message callback, size 24. +82 17085 [OTA Agent Task] [INFO] No active job available in received job document: OtaJobParseErr_t=OtaJobParseErrNoActiveJobs +83 17102 [OTA Agent Task] [INFO] Signal task inference start +84 17111 [OTA Agent Task] [INFO] Current State=[WaitingForJob], Event=[ReceivedJobDocument], New state=[CreatingFile] +85 17127 [ML_TASK] [INFO] Initial start of image processing +INFO - Ethos-U device initialised +INFO - Ethos-U version info: +INFO - Arch: v1.1.0 +INFO - Driver: v0.16.0 +INFO - MACs/cc: 256 +INFO - Cmd stream: v0 +86 17159 [ML_TASK] [INFO] Ethos-U65 device initialised +87 17167 [ML_TASK] [INFO] Ethos-U version info: +88 17173 [ML_TASK] [INFO] Arch: v1.1.0 +89 17180 [ML_TASK] [INFO] Driver: v0.16.0 +90 17187 [ML_TASK] [INFO] MACs/cc: 256 +91 17192 [ML_TASK] [INFO] Cmd stream: v0 +INFO - Added ethos-u support to op resolver +INFO - Creating allocator using tensor arena at 0x0x6006b440 +INFO - Allocating tensors +INFO - Model INPUT tensors: +INFO - tensor type is INT8 +INFO - tensor occupies 36864 bytes with dimensions +INFO - 0: 1 +INFO - 1: 192 +INFO - 2: 192 +INFO - 3: 1 +INFO - Quant dimension: 0 +INFO - Scale[0] = 0.003921 +INFO - ZeroPoint[0] = -128 +INFO - Model OUTPUT tensors: +INFO - tensor type is INT8 +INFO - tensor occupies 648 bytes with dimensions +INFO - 0: 1 +INFO - 1: 6 +INFO - 2: 6 +INFO - 3: 18 +INFO - Quant dimension: 0 +INFO - Scale[0] = 0.134084 +INFO - ZeroPoint[0] = 47 +INFO - tensor type is INT8 +INFO - tensor occupies 2592 bytes with dimensions +INFO - 0: 1 +INFO - 1: 12 +INFO - 2: 12 +INFO - 3: 18 +INFO - Quant dimension: 0 +INFO - Scale[0] = 0.185359 +INFO - ZeroPoint[0] = 10 +INFO - Activation buffer (a.k.a tensor arena) size used: 370024 +INFO - Number of operators: 1 +INFO - Operator 0: ethos-u +INFO - Model address: 0x0x60000000INFO - Model size: 439360 bytes.INFO - Model info: +INFO - Model INPUT tensors: +INFO - tensor type is INT8 +INFO - tensor occupies 36864 bytes with dimensions +INFO - 0: 1 +INFO - 1: 192 +INFO - 2: 192 +INFO - 3: 1 +INFO - Quant dimension: 0 +INFO - Scale[0] = 0.003921 +INFO - ZeroPoint[0] = -128 +INFO - Model OUTPUT tensors: +INFO - tensor type is INT8 +INFO - tensor occupies 648 bytes with dimensions +INFO - 0: 1 +INFO - 1: 6 +INFO - 2: 6 +INFO - 3: 18 +INFO - Quant dimension: 0 +INFO - Scale[0] = 0.134084 +INFO - ZeroPoint[0] = 47 +INFO - tensor type is INT8 +INFO - tensor occupies 2592 bytes with dimensions +INFO - 0: 1 +INFO - 1: 12 +INFO - 2: 12 +INFO - 3: 18 +INFO - Quant dimension: 0 +INFO - Scale[0] = 0.185359 +INFO - ZeroPoint[0] = 10 +INFO - Activation buffer (a.k.a tensor arena) size used: 370024 +INFO - Number of operators: 1 +INFO - Operator 0: ethos-u +INFO - The model is optimised for Ethos-U NPU: yes. +92 17474 [ML_TASK] [INFO] *** ML interface initialised +93 17481 [ML_TASK] [INFO] ISP init +94 17486 [ML_TASK] [INFO] Starting HDLCD config! +95 17493 [ML_TASK] [INFO] Starting ISP init! +00T00:00:17.500Z GENERIC(ERR) :PINGISP +1:4830ab6c(58140) <-> 0x212f6f7c(58140) +2:48318e88(16384) <-> 0x21305298(16384) +00T00:00:17.517Z GENERIC(ERR) :PoNGISP +1:48322b2c(58140) <-> 0x212f6f7c(58140) +2:48330e48(16384) <-> 0x21305298(16384) +00T00:00:17.534Z GENERIC(ERR) :PINGMET +1:483054a8(4096) <-> 0x212f18b8(4096) +2:483095ac(4672) <-> 0x212f59bc(4672) +00T00:00:17.550Z GENERIC(ERR) :PoNGMET +1:483054a8(4096) <-> 0x212f18b8(4096) +2:4832156c(4672) <-> 0x212f59bc(4672) +00T00:00:17.567Z SENSOR(NOTICE) :Sensor initialization is complete, ID 0xFFFF resolution 576x576 +00T00:00:17.581Z GENERIC(ERR) :DMA alloc: 0xca800, Memory left: 0x47b800 +00T00:00:17.596Z CROP(NOTICE) :FR update: Crop: e 0 x 0, y 0, w 576, h 576, Downscaler: e 0, w 576, h 576 +00T00:00:17.611Z CROP(NOTICE) :DS update: Crop: e 0 x 0, y 0, w 576, h 576, Downscaler: e 0, w 576, h 576 +00T00:00:17.636Z GENERIC(CRIT) :-- CAMERA STREAM TRIGGER #0 -- +abstract_port__vsync_s__setValue : (idx = 0) Frame #0 is ready. +abstract_port__vsync_s__setValue : (idx = 1) Frame #0 is ready. +abstract_port__vsync_s__setValue : (idx = 2) Frame #0 is ready. +abstract_port__vsync_s__setValue : (idx = 0) Frame #0 is ready. +abstract_port__vsync_s__setValue : (idx = 1) Frame #0 is ready. +abstract_port__vsync_s__setValue : (idx = 2) Frame #0 is ready. +00T00:00:17.646Z GENERIC(CRIT) :[KeyMsg]: FS interrupt: 0 +00T00:00:17.646Z GENERIC(ERR) :Attempt to start a new frame before processing is done for the previous one. Skip this frame. +00T00:00:17.762Z GENERIC(CRIT) :-- CAMERA STREAM TRIGGER #1 -- +abstract_port__vsync_s__setValue : (idx = 0) Frame #1 is ready. +abstract_port__vsync_s__setValue : (idx = 1) Frame #1 is ready. +abstract_port__vsync_s__setValue : (idx = 2) Frame #1 is ready. +abstract_port__vsync_s__setValue : (idx = 0) Frame #1 is ready. +abstract_port__vsync_s__setValue : (idx = 1) Frame #1 is ready. +abstract_port__vsync_s__setValue : (idx = 2) Frame #1 is ready. +00T00:00:17.772Z GENERIC(CRIT) :[KeyMsg]: FS interrupt: 1 +00T00:00:17.888Z GENERIC(CRIT) :-- CAMERA STREAM TRIGGER #2 -- +abstract_port__vsync_s__setValue : (idx = 0) Frame #2 is ready. +abstract_port__vsync_s__setValue : (idx = 1) Frame #2 is ready. +abstract_port__vsync_s__setValue : (idx = 2) Frame #2 is ready. +abstract_port__vsync_s__setValue : (idx = 0) Frame #2 is ready. +abstract_port__vsync_s__setValue : (idx = 1) Frame #2 is ready. +abstract_port__vsync_s__setValue : (idx = 2) Frame #2 is ready. +00T00:00:17.898Z GENERIC(CRIT) :[KeyMsg]: FS interrupt: 2 +00T00:00:18.014Z GENERIC(CRIT) :-- CAMERA STREAM TRIGGER #3 -- +abstract_port__vsync_s__setValue : (idx = 0) Frame #3 is ready. +abstract_port__vsync_s__setValue : (idx = 1) Frame #3 is ready. +abstract_port__vsync_s__setValue : (idx = 2) Frame #3 is ready. +abstract_port__vsync_s__setValue : (idx = 0) Frame #3 is ready. +abstract_port__vsync_s__setValue : (idx = 1) Frame #3 is ready. +abstract_port__vsync_s__setValue : (idx = 2) Frame #3 is ready. +00T00:00:18.024Z GENERIC(CRIT) :[KeyMsg]: FS interrupt: 3 +00T00:00:18.140Z GENERIC(CRIT) :-- CAMERA STREAM TRIGGER #4 -- +abstract_port__vsync_s__setValue : (idx = 0) Frame #4 is ready. +abstract_port__vsync_s__setValue : (idx = 1) Frame #4 is ready. +abstract_port__vsync_s__setValue : (idx = 2) Frame #4 is ready. +abstract_port__vsync_s__setValue : (idx = 0) Frame #4 is ready. +abstract_port__vsync_s__setValue : (idx = 1) Frame #4 is ready. +abstract_port__vsync_s__setValue : (idx = 2) Frame #4 is ready. +00T00:00:18.150Z GENERIC(CRIT) :[KeyMsg]: FS interrupt: 4 +00T00:00:18.155Z GENERIC(CRIT) :-- aframes->frame_id = 1 -- +00T00:00:18.165Z GENERIC(CRIT) :-- 576 X 576 @ 2 bytes per pixel -- +96 18177 [acamera] [INFO] Displaying image... +97 18183 [acamera] [INFO] Image displayed +00T00:00:18.189Z GENERIC(CRIT) :-- aframes->frame_id = 1 -- +00T00:00:18.199Z GENERIC(CRIT) :-- 576 X 576 @ 2 bytes per pixel -- +98 18211 [acamera] [ERROR] Input frame too big for inference! +00T00:00:18.235Z GENERIC(CRIT) :-- CAMERA STREAM TRIGGER #5 -- +abstract_port__vsync_s__setValue : (idx = 0) Frame #5 is ready. +abstract_port__vsync_s__setValue : (idx = 1) Frame #5 is ready. +abstract_port__vsync_s__setValue : (idx = 2) Frame #5 is ready. +abstract_port__vsync_s__setValue : (idx = 0) Frame #5 is ready. +abstract_port__vsync_s__setValue : (idx = 1) Frame #5 is ready. +abstract_port__vsync_s__setValue : (idx = 2) Frame #5 is ready. +00T00:00:18.245Z GENERIC(CRIT) :[KeyMsg]: FS interrupt: 5 +00T00:00:18.252Z GENERIC(CRIT) :-- aframes->frame_id = 2 -- +00T00:00:18.262Z GENERIC(CRIT) :-- 576 X 576 @ 2 bytes per pixel -- +99 18274 [acamera] [INFO] Displaying image... +100 18280 [acamera] [INFO] Image displayed +00T00:00:18.286Z GENERIC(CRIT) :-- aframes->frame_id = 2 -- +00T00:00:18.296Z GENERIC(CRIT) :-- 192 X 192 @ 2 bytes per pixel -- +101 18308 [acamera] [INFO] Converting to Gray: 0x82f76000 -> 0x21224300 +INFO - Running inference on image at addr 0x21224300 +102 18340 [acamera] [INFO] Final results: +103 18346 [acamera] [INFO] Total number of inferences: 1 +104 18354 [acamera] [INFO] Detected faces: 3 +105 18360 [acamera] [INFO] 0) (0.994434) -> Detection box: {x=6,y=71,w=33,h=44} +106 18371 [acamera] [INFO] 1) (0.950913) -> Detection box: {x=108,y=71,w=13,h=21} +107 18383 [acamera] [INFO] 2) (0.884787) -> Detection box: {x=47,y=78,w=20,h=31} +108 18394 [acamera] [INFO] Complete recognition: Detected faces: 3 +109 18534 [ML_MQTT] [INFO] Attempting to publish (Detected faces: 3) to the MQTT topic iotmsw-ci-test-thing-9ba0432f-e481-4fde-b3e5-a45bcf076e7a/ml/inference. +110 18557 [MQTT Agent Task] [INFO] Publishing message to iotmsw-ci-test-thing-9ba0432f-e481-4fde-b3e5-a45bcf076e7a/ml/inference. +00T00:00:18.575Z GENERIC(CRIT) :-- CAMERA STREAM TRIGGER #6 -- +abstract_port__vsync_s__setValue : (idx = 0) Frame #6 is ready. +abstract_port__vsync_s__setValue : (idx = 1) Frame #6 is ready. +abstract_port__vsync_s__setValue : (idx = 2) Frame #6 is ready. +abstract_port__vsync_s__setValue : (idx = 0) Frame #6 is ready. +abstract_port__vsync_s__setValue : (idx = 1) Frame #6 is ready. +abstract_port__vsync_s__setValue : (idx = 2) Frame #6 is ready. +00T00:00:18.585Z GENERIC(CRIT) :[KeyMsg]: FS interrupt: 6 +00T00:00:18.588Z GENERIC(CRIT) :-- aframes->frame_id = 3 -- +00T00:00:18.598Z GENERIC(CRIT) :-- 576 X 576 @ 2 bytes per pixel -- +111 18610 [acamera] [INFO] Displaying image... +112 18616 [acamera] [INFO] Image displayed +00T00:00:18.622Z GENERIC(CRIT) :-- aframes->frame_id = 3 -- +00T00:00:18.633Z GENERIC(CRIT) :-- 192 X 192 @ 2 bytes per pixel -- +113 18644 [acamera] [INFO] Converting to Gray: 0x837e6000 -> 0x21224300 +INFO - Running inference on image at addr 0x21224300 +114 18676 [acamera] [INFO] Final results: +115 18682 [acamera] [INFO] Total number of inferences: 1 +116 18690 [acamera] [INFO] Detected faces: 4 +117 18696 [acamera] [INFO] 0) (0.996794) -> Detection box: {x=6,y=71,w=33,h=44} +118 18707 [acamera] [INFO] 1) (0.986066) -> Detection box: {x=108,y=71,w=13,h=21} +119 18719 [acamera] [INFO] 2) (0.958923) -> Detection box: {x=47,y=78,w=20,h=31} +120 18730 [acamera] [INFO] 3) (0.546118) -> Detection box: {x=170,y=91,w=16,h=21} +121 18741 [acamera] [INFO] Complete recognition: Detected faces: 4 +. +OTA update status: DELETE_IN_PROGRESS +An error occurred (ResourceNotFoundException) when calling the GetOTAUpdate operation: Requested otaUpdateJob ota-test-update-id-9ba0432f-e481-4fde-b3e5-a45bcf076e7a does not exist +Deleted update ota-test-update-id-9ba0432f-e481-4fde-b3e5-a45bcf076e7a +Deleted thing arn:aws:iot:eu-west-1:965412032949:thing/iotmsw-ci-test-thing-9ba0432f-e481-4fde-b3e5-a45bcf076e7a +Deleted S3 object object-detection-update_signed.bin from iotmsw-ci-test-bucket-9ba0432f-e481-4fde-b3e5-a45bcf076e7a +Deleted S3 bucket iotmsw-ci-test-bucket-9ba0432f-e481-4fde-b3e5-a45bcf076e7a +``` + +## Observing MQTT connectivity +Follow the instructions described in the [Observing MQTT connectivity](./aws_iot_cloud_connection.md) section. + +## Firmware update with AWS +Follow the instructions described in the [Firmware update with AWS](./aws_iot_cloud_connection.md) section. + +### Expected output + +```log +[INF] Starting bootloader +[INF] Primary image: magic=good, swap_type=0x1, copy_done=0x3, image_ok=0x1 +[INF] Scratch: magic=bad, swap_type=0x1, copy_done=0x2, image_ok=0x2 +[INF] Boot source: primary slot +[INF] Image index: 1, Swap type: none +[INF] Primary image: magic=good, swap_type=0x1, copy_done=0x3, image_ok=0x1 +[INF] Scratch: magic=bad, swap_type=0x1, copy_done=0x2, image_ok=0x2 +[INF] Boot source: primary slot +[INF] Image index: 0, Swap type: none +[INF] Bootloader chainload address offset: 0x0 +[INF] Jumping to the first image slot +Booting TF-M v2.0.0 +[Sec Thread] Secure image initializing! +Creating an empty ITS flash layout. +Creating an empty PS flash layout. +[INF][Crypto] Provisioning entropy seed... complete. +0 0 [None] [INFO] PSA Framework version is: 257 +1 0 [None] Write certificate... +2 0 [None] [INFO] Device key provisioning succeeded +3 0 [None] [INFO] OTA signing key provisioning succeeded +4 0 [None] [INFO] Signal task inference stop +5 0 [None] FreeRTOS_AddEndPoint: MAC: 44-21 IPv4: c0a80069ip +6 41 [OTA Task ] [INFO] OTA over MQTT, Application version from appFirmwareVersion 0.0.10 +7 54 [ML_TASK] [INFO] ML Task start +8 59 [BLINK_TASK ] [INFO] Blink task started +9 1000 [IP-Task] DHCP-socket[44-21]: DHCP Socket Create +10 1000 [IP-Task] prvCreateDHCPSocket[44-21]: open, user count 1 +11 1000 [IP-Task] vDHCP_RATimerReload: 250 +12 1250 [IP-Task] vDHCPProcess: offer ac143301ip for MAC address 44-21 +13 1260 [IP-Task] vDHCPProcess: offer ac143301ip for MAC address 44-21 +14 1260 [IP-Task] [INFO] Network is up +15 1260 [IP-Task] prvCloseDHCPSocket[44-21]: closed, user count 0 +16 1260 [IP-Task] vDHCP_RATimerReload: 8640000 +17 1291 [MQTT Agent Task] [INFO] Creating a TLS connection to a1nn4qspc1z547-ats.iot.eu-west-1.amazonaws.com:8883. +18 1307 [MQTT Agent Task] [INFO] Resolving host name: a1nn4qspc1z547-ats.iot.eu-west-1.amazonaws.com. +19 1323 [IP-Task] ipARP_REPLY from ac1433feip to ac143301ip end-point ac143301ip +20 6334 [MQTT Agent Task] DNS_ReadReply returns -11 +21 6341 [MQTT Agent Task] prvIncreaseDNS4Index: from 0 to 0 +22 6352 [MQTT Agent Task] DNS[0xB324]: The answer to 'a1nn4qspc1z547-ats.iot.eu-west-1.amazonaws.com' (52.208.143.40) will be stored +23 6371 [MQTT Agent Task] [INFO] Initiating TCP connection with host: a1nn4qspc1z547-ats.iot.eu-west-1.amazonaws.com:8883 +24 6388 [MQTT Agent Task] FreeRTOS_connect: 25748 to 34d08f28ip:8883 +25 6482 [MQTT Agent Task] [INFO] Initiating TLS handshake with host: a1nn4qspc1z547-ats.iot.eu-west-1.amazonaws.com:8883 +26 8653 [MQTT Agent Task] [INFO] Successfully created a TLS connection to a1nn4qspc1z547-ats.iot.eu-west-1.amazonaws.com:8883. +27 8671 [MQTT Agent Task] [INFO] Creating an MQTT connection to the broker. +28 9099 [MQTT Agent Task] [INFO] MQTT connection established with the broker. +29 9110 [MQTT Agent Task] [INFO] Successfully connected to the MQTT broker. +30 9121 [MQTT Agent Task] [INFO] Session present: 0 +31 9128 [MQTT Agent Task] [INFO] Starting a clean MQTT Session. +32 9137 [OTA Task ] [INFO] Received: 0 Queued: 0 Processed: 0 Dropped: 0 +33 9149 [OTA Agent Task] [INFO] Current State=[RequestingJob], Event=[Start], New state=[RequestingJob] +34 9633 [OTA Agent Task] [INFO] Subscribed to topic $aws/things/iotmsw-ci-test-thing-9ba0432f-e481-4fde-b3e5-a45bcf076e7a/jobs/notify-next. +35 9653 [OTA Agent Task] [INFO] Subscribed to MQTT topic: $aws/things/iotmsw-ci-test-thing-9ba0432f-e481-4fde-b3e5-a45bcf076e7a/jobs/notify-next +36 10383 [MQTT Agent Task] [INFO] Publishing message to $aws/things/iotmsw-ci-test-thing-9ba0432f-e481-4fde-b3e5-a45bcf076e7a/jobs/$next/get. +37 10922 [MQTT Agent Task] [INFO] Ack packet deserialized with result: MQTTSuccess. +38 10934 [MQTT Agent Task] [INFO] State record updated. New state=MQTTPublishDone. +39 10946 [MQTT Agent Task] [INFO] De-serialized incoming PUBLISH packet: DeserializerResult=MQTTSuccess. +40 10961 [MQTT Agent Task] [INFO] State record updated. New state=MQTTPublishDone. +41 10973 [MQTT Agent Task] [INFO] Received job message callback, size 1020. +42 10983 [OTA Agent Task] [INFO] Sent PUBLISH packet to broker $aws/things/iotmsw-ci-test-thing-9ba0432f-e481-4fde-b3e5-a45bcf076e7a/jobs/$next/get to broker. +43 11006 [OTA Agent Task] [WARN] OTA Timer handle NULL for Timerid=0, can't stop. +44 11017 [OTA Agent Task] [INFO] Current State=[WaitingForJob], Event=[RequestJobDocument], New state=[WaitingForJob] +45 11035 [OTA Agent Task] [INFO] Extracted parameter: [key: value]=[execution.jobId: AFR_OTA-ota-test-update-id-9ba0432f-e481-4fde-b3e5-a45bcf076e7a] +46 11060 [OTA Agent Task] [INFO] Extracted parameter: [key: value]=[execution.jobDocument.afr_ota.streamname: AFR_OTA-eac26517-1848-4705-8242-97bda52cab40] +47 11082 [OTA Agent Task] [INFO] Extracted parameter: [key: value]=[execution.jobDocument.afr_ota.protocols: ["MQTT"]] +48 11100 [OTA Agent Task] [INFO] Extracted parameter: [key: value]=[filepath: non_secure image] +49 11114 [OTA Agent Task] [INFO] Extracted parameter: [key: value]=[filesize: 1141641] +50 11127 [OTA Agent Task] [INFO] Extracted parameter: [key: value]=[fileid: 0] +51 11138 [OTA Agent Task] [INFO] Extracted parameter: [key: value]=[certfile: 0] +52 11151 [OTA Agent Task] [INFO] Extracted parameter [ sig-sha256-rsa: LUOGFk3dx7VoXvS7tJl5MJObgHtbCJgZ... ] +53 11167 [OTA Agent Task] [INFO] Job document was accepted. Attempting to begin the update. +54 11180 [OTA Agent Task] [INFO] Job parsing success: OtaJobParseErr_t=OtaJobParseErrNone, Job name=AFR_OTA-ota-test-update-id-9ba0432f-e481-4fde-b3e5-a45bcf076e7a +55 11203 [OTA Agent Task] [INFO] Signal task inference stop +56 11253 [OTA Agent Task] [INFO] Setting OTA data interface. +57 11261 [OTA Agent Task] [INFO] Current State=[CreatingFile], Event=[ReceivedJobDocument], New state=[CreatingFile] +58 12464 [OTA Agent Task] [INFO] Subscribed to topic $aws/things/iotmsw-ci-test-thing-9ba0432f-e481-4fde-b3e5-a45bcf076e7a/streams/AFR_OTA-eac26517-1848-4705-8242-97bda52cab40/data/cbor. +59 12490 [OTA Agent Task] [INFO] Current State=[RequestingFileBlock], Event=[CreateFile], New state=[RequestingFileBlock] +60 13214 [MQTT Agent Task] [INFO] Publishing message to $aws/things/iotmsw-ci-test-thing-9ba0432f-e481-4fde-b3e5-a45bcf076e7a/streams/AFR_OTA-eac26517-1848-4705-8242-97bda52cab40/get/cbor. +61 13399 [OTA Agent Task] [INFO] Sent PUBLISH packet to broker $aws/things/iotmsw-ci-test-thing-9ba0432f-e481-4fde-b3e5-a45bcf076e7a/streams/AFR_OTA-eac26517-1848-4705-8242-97bda52cab40/get/cbor to broker. +62 13428 [OTA Agent Task] [INFO] Published to MQTT topic to request the next block: topic=$aws/things/iotmsw-ci-test-thing-9ba0432f-e481-4fde-b3e5-a45bcf076e7a/streams/AFR_OTA-eac26517-1848-4705-8242-97bda52cab40/get/cbor +63 13459 [OTA Agent Task] [INFO] Current State=[WaitingForFileBlock], Event=[RequestFileBlock], New state=[WaitingForFileBlock] +64 14010 [MQTT Agent Task] [INFO] De-serialized incoming PUBLISH packet: DeserializerResult=MQTTSuccess. +65 14024 [MQTT Agent Task] [INFO] State record updated. New state=MQTTPublishDone. +66 14036 [MQTT Agent Task] [INFO] Received data message callback, size 4120. +67 14047 [OTA Agent Task] [INFO] Received valid file block: Block index=0, Size=4096 +68 14059 [OTA Agent Task] [INFO] Number of blocks remaining: 278 + +... + +3487 567949 [MQTT Agent Task] [INFO] Publishing message to $aws/things/iotmsw-ci-test-thing-9ba0432f-e481-4fde-b3e5-a45bcf076e7a/streams/AFR_OTA-eac26517-1848-4705-8242-97bda52cab40/get/cbor. +3488 568137 [OTA Agent Task] [INFO] Sent PUBLISH packet to broker $aws/things/iotmsw-ci-test-thing-9ba0432f-e481-4fde-b3e5-a45bcf076e7a/streams/AFR_OTA-eac26517-1848-4705-8242-97bda52cab40/get/cbor to broker. +3489 568166 [OTA Agent Task] [INFO] Published to MQTT topic to request the next block: topic=$aws/things/iotmsw-ci-test-thing-9ba0432f-e481-4fde-b3e5-a45bcf076e7a/streams/AFR_OTA-eac26517-1848-4705-8242-97bda52cab40/get/cbor +3490 568198 [OTA Agent Task] [INFO] Current State=[WaitingForFileBlock], Event=[RequestFileBlock], New state=[WaitingForFileBlock] +3491 569141 [MQTT Agent Task] [INFO] De-serialized incoming PUBLISH packet: DeserializerResult=MQTTSuccess. +3492 569156 [MQTT Agent Task] [INFO] State record updated. New state=MQTTPublishDone. +3493 569168 [MQTT Agent Task] [INFO] Received data message callback, size 4122. +3494 569179 [OTA Agent Task] [INFO] Received valid file block: Block index=277, Size=4096 +3495 569192 [OTA Agent Task] [INFO] Number of blocks remaining: 1 +3496 569201 [OTA Agent Task] [INFO] OTA active state `6` from OTA Agent. +3497 569212 [OTA Agent Task] [INFO] Signal task inference stop +3498 569221 [OTA Agent Task] [INFO] Current State=[WaitingForFileBlock], Event=[ReceivedFileBlock], New state=[WaitingForFileBlock] +3499 569872 [OTA Task ] [INFO] Received: 278 Queued: 278 Processed: 278 Dropped: 0 +3500 569983 [MQTT Agent Task] [INFO] Publishing message to $aws/things/iotmsw-ci-test-thing-9ba0432f-e481-4fde-b3e5-a45bcf076e7a/streams/AFR_OTA-eac26517-1848-4705-8242-97bda52cab40/get/cbor. +3501 570169 [OTA Agent Task] [INFO] Sent PUBLISH packet to broker $aws/things/iotmsw-ci-test-thing-9ba0432f-e481-4fde-b3e5-a45bcf076e7a/streams/AFR_OTA-eac26517-1848-4705-8242-97bda52cab40/get/cbor to broker. +3502 570198 [OTA Agent Task] [INFO] Published to MQTT topic to request the next block: topic=$aws/things/iotmsw-ci-test-thing-9ba0432f-e481-4fde-b3e5-a45bcf076e7a/streams/AFR_OTA-eac26517-1848-4705-8242-97bda52cab40/get/cbor +3503 570230 [OTA Agent Task] [INFO] Current State=[WaitingForFileBlock], Event=[RequestFileBlock], New state=[WaitingForFileBlock] +3504 571172 [MQTT Agent Task] [INFO] De-serialized incoming PUBLISH packet: DeserializerResult=MQTTSuccess. +3505 571187 [MQTT Agent Task] [INFO] State record updated. New state=MQTTPublishDone. +3506 571199 [MQTT Agent Task] [INFO] Received data message callback, size 2979. +3507 571210 [OTA Agent Task] [INFO] Received valid file block: Block index=278, Size=2953 +3508 571223 [OTA Agent Task] [INFO] Received final block of the update. +3509 571894 [OTA Agent Task] [INFO] Received entire update and validated the signature. +3510 572014 [MQTT Agent Task] [INFO] Publishing message to $aws/things/iotmsw-ci-test-thing-9ba0432f-e481-4fde-b3e5-a45bcf076e7a/jobs/AFR_OTA-ota-test-update-id-9ba0432f-e481-4fde-b3e5-a45bcf076e7a/update. +3511 573260 [MQTT Agent Task] [INFO] Ack packet deserialized with result: MQTTSuccess. +3512 573272 [MQTT Agent Task] [INFO] State record updated. New state=MQTTPublishDone. +3513 573284 [MQTT Agent Task] [INFO] De-serialized incoming PUBLISH packet: DeserializerResult=MQTTSuccess. +3514 573299 [MQTT Agent Task] [INFO] State record updated. New state=MQTTPublishDone. +3515 573312 [OTA Agent Task] [INFO] Sent PUBLISH packet to broker $aws/things/iotmsw-ci-test-thing-9ba0432f-e481-4fde-b3e5-a45bcf076e7a/jobs/AFR_OTA-ota-test-update-id-9ba0432f-e481-4fde-b3e5-a45bcf076e7a/update to broker. +3516 573343 [OTA Agent Task] [INFO] Received OtaJobEventActivate callback from OTA Agent. +``` + +## Running AWS IoT Core Device Advisor tests +Follow the instructions described in [Running AWS IoT Core Device Advisor tests](./running_aws_iot_core_device_advisor_tests.md). diff --git a/tools/ci/license/license.schema b/tools/ci/license/license.schema index fb510f42..f9dde918 100644 --- a/tools/ci/license/license.schema +++ b/tools/ci/license/license.schema @@ -73,7 +73,7 @@ "properties": { "path": { "type": "string", - "pattern": "\\.(html|json|md|log|in|map|rst|patch|wav|release_ignore|ini|conf|options|toml|change|pylintrc)$" + "pattern": "\\.(html|json|md|log|in|map|rst|patch|wav|frm|release_ignore|ini|conf|options|toml|change|pylintrc)$" }, "type": { "type": "string", diff --git a/tools/scripts/build.sh b/tools/scripts/build.sh index 582aea77..41a37a2f 100755 --- a/tools/scripts/build.sh +++ b/tools/scripts/build.sh @@ -93,7 +93,7 @@ Options: --certificate_path Path to the AWS device certificate --private_key_path Path to the AWS device private key Examples: - blinky, freertos-iot-libraries-tests, keyword-detection, speech-recognition + blinky, freertos-iot-libraries-tests, keyword-detection, object-detection, speech-recognition EOF } @@ -188,8 +188,12 @@ case "$1" in EXAMPLE="$1" PATH_TO_SOURCE="$ROOT/applications/speech_recognition" ;; + object-detection) + EXAMPLE="$1" + PATH_TO_SOURCE="$ROOT/applications/object_detection" + ;; *) - echo "Missing example " + echo "Missing example " show_usage exit 2 ;; @@ -282,4 +286,9 @@ if [ "$EXAMPLE" == "speech-recognition" ] && [ "$ML_INFERENCE_ENGINE" == "SOFTWA exit 1 fi +if [ "$EXAMPLE" == "object-detection" ] && [ "$TARGET" != "corstone315" ]; then + echo "Error: Invalid combination of example and target. object-detection only supports corstone315" >&2 + exit 2 +fi + build_with_cmake diff --git a/tools/scripts/run.sh b/tools/scripts/run.sh index 60ced60d..67bc2481 100755 --- a/tools/scripts/run.sh +++ b/tools/scripts/run.sh @@ -28,14 +28,15 @@ Options: -t,--target Target to run -s, --audio Audio source (ROM, VSI) -n, --npu-id NPU ID to use (U55, U65) + --frames Path to camera frames for the ISP to stream Examples: - blinky, keyword-detection, speech-recognition + blinky, keyword-detection, speech-recognition, object-detection EOF } SHORT=t:,n:,s:,h,p: -LONG=target:,npu-id:,audio:,help,path: +LONG=target:,npu-id:,audio:,help,path:,frames: OPTS=$(getopt -n run --options $SHORT --longoptions $LONG -- "$@") eval set -- "$OPTS" @@ -63,6 +64,10 @@ do AUDIO_SOURCE=$2 shift 2 ;; + --frames ) + FRAMES=$2 + shift 2 + ;; --) shift; break @@ -121,8 +126,12 @@ case "$1" in EXAMPLE="$1" MERGED_IMAGE_PATH="$BUILD_PATH/speech-recognition_merged.elf" ;; + object-detection) + EXAMPLE="$1" + MERGED_IMAGE_PATH="$BUILD_PATH/object-detection_merged.elf" + ;; *) - echo "Usage: $0 " >&2 + echo "Usage: $0 " >&2 exit 1 ;; esac @@ -167,9 +176,17 @@ case "$TARGET" in -C mps4_board.uart0.out_file="-" \ -C mps4_board.uart0.unbuffered_output=1 \ -C mps4_board.subsystem.ethosu.extra_args="--fast" \ + -C mps4_board.isp_c55_capture_ds.do_capture=0 \ + -C mps4_board.isp_c55_capture_fr.do_capture=0 \ + -C mps4_board.isp_c55_camera.image_file=${FRAMES} \ --stat" ;; esac +if [ "$EXAMPLE" == "object-detection" ] && [ "$TARGET" != "corstone315" ]; then + echo "Error: Invalid combination of example and target. object-detection only supports corstone315" >&2 + exit 2 +fi + # Start the FVP $FVP_BIN -a $MERGED_IMAGE_PATH $OPTIONS $AVH_AUDIO_OPTIONS diff --git a/tools/tests/conftest.py b/tools/tests/conftest.py index e2e0bcc9..eaeaaa14 100644 --- a/tools/tests/conftest.py +++ b/tools/tests/conftest.py @@ -1,4 +1,4 @@ -# Copyright (c) 2023 Arm Limited. All rights reserved. +# Copyright (c) 2023-2024, Arm Limited. All rights reserved. # SPDX-License-Identifier: MIT import pytest @@ -22,6 +22,7 @@ def pytest_addoption(parser): default="", help="Path to the input audio file to be used by applications.", ) + parser.addoption("--frm-file-path", action="store", default="") parser.addoption("--build-artefacts-path", action="store", default="") parser.addoption("--credentials-path", action="store", default="credentials") parser.addoption("--fvp", action="store", default="FVP_Corstone_SSE-310") @@ -63,6 +64,11 @@ def audio_file_path(pytestconfig): yield pytestconfig.getoption("--audio-file-path") +@pytest.fixture +def frm_file_path(pytestconfig): + yield pytestconfig.getoption("--frm-file-path") + + @pytest.fixture def fvp_options(pytestconfig): raw_options = pytestconfig.getoption("--fvp-options") @@ -116,39 +122,93 @@ def pythonhome_path(pytestconfig): @pytest.fixture(scope="function") def fvp_process( - fvp_path, merged_elf_name, fvp_options, audio_file_path, pythonhome_path + fvp_path, + merged_elf_name, + fvp_options, + audio_file_path, + pythonhome_path, + frm_file_path, ): # 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. # Note: It can take few seconds to terminate the FVP - cmdline = [ - fvp_path, - "-a", - f"{merged_elf_name}", - "-C", - "core_clk.mul=200000000", - "-C", - "mps3_board.visualisation.disable-visualisation=1", - "-C", - "mps3_board.telnetterminal0.start_telnet=0", - "-C", - "mps3_board.uart0.out_file=-", - "-C", - "mps3_board.uart0.unbuffered_output=1", - "-C", - "mps3_board.uart0.shutdown_on_eot=1", - "-C", - "cpu0.semihosting-enable=1", - "-C", - "mps3_board.smsc_91c111.enabled=1", - "-C", - "mps3_board.hostbridge.userNetworking=1", - "-C", - "mps3_board.DISABLE_GATING=1", - "-C", - "ethosu.extra_args=--fast", - ] + + if "SSE-315" in fvp_path: + cmdline = [ + fvp_path, + "-a", + f"{merged_elf_name}", + "-C", + "core_clk.mul=200000000", + "-C", + "mps4_board.visualisation.disable-visualisation=1", + "-C", + "mps4_board.telnetterminal0.start_telnet=0", + "-C", + "mps4_board.uart0.out_file=-", + "-C", + "mps4_board.uart0.unbuffered_output=1", + "-C", + "mps4_board.uart0.shutdown_on_eot=1", + "-C", + "mps4_board.subsystem.cpu0.semihosting-enable=1", + "-C", + "mps4_board.smsc_91c111.enabled=1", + "-C", + "mps4_board.hostbridge.userNetworking=1", + "-C", + "mps4_board.subsystem.ethosu.extra_args=--fast", + ] + + vsi_options = [ + "-C", + f"mps4_board.v_path={Path(__file__).parent.parent / 'scripts'}", + ] + + frm_options = [ + "-C", + "mps4_board.isp_c55_capture_ds.do_capture=0", + "-C", + "mps4_board.isp_c55_capture_fr.do_capture=0", + "-C", + f"mps4_board.isp_c55_camera.image_file={frm_file_path}", + ] + else: + cmdline = [ + fvp_path, + "-a", + f"{merged_elf_name}", + "-C", + "core_clk.mul=200000000", + "-C", + "mps3_board.visualisation.disable-visualisation=1", + "-C", + "mps3_board.telnetterminal0.start_telnet=0", + "-C", + "mps3_board.uart0.out_file=-", + "-C", + "mps3_board.uart0.unbuffered_output=1", + "-C", + "mps3_board.uart0.shutdown_on_eot=1", + "-C", + "cpu0.semihosting-enable=1", + "-C", + "mps3_board.smsc_91c111.enabled=1", + "-C", + "mps3_board.hostbridge.userNetworking=1", + "-C", + "mps3_board.DISABLE_GATING=1", + "-C", + "ethosu.extra_args=--fast", + ] + + vsi_options = [ + "-C", + f"mps3_board.v_path={Path(__file__).parent.parent / 'scripts'}", + ] + + frm_options = [] cmdline.extend(fvp_options) @@ -159,11 +219,9 @@ def fvp_process( # If this option is used with ROM as audio source, it would break if PYTHONHOME # path is not set. if audio_file_path: - vsi_options = [ - "-C", - f"mps3_board.v_path={Path(__file__).parent.parent / 'scripts'}", - ] cmdline.extend(vsi_options) + if frm_file_path: + cmdline.extend(frm_options) if pythonhome_path != "": fvp_env["PYTHONHOME"] = pythonhome_path proc = subprocess.Popen(cmdline, stdout=subprocess.PIPE, env=fvp_env)