Verified Commit 90d6f871 authored by Vincent Coubard's avatar Vincent Coubard
Browse files

Update SDK version to head

- The TF-M version used is set to TF-M 1.6.3.
- The PKCS11 library has been updated to https://github.com/Linaro/freertos-pkcs11-psa/commit/e137fb99e0980f4c35bbc6eff74e30505b3c08af .
- FreeRTOS pal OTA has been updated to https://github.com/Linaro/freertos-ota-pal-psa/commits/main

 .
Signed-off-by: Vincent Coubard's avatarVincent Coubard <vincent.coubard@arm.com>
parent cb775bbd
......@@ -14,11 +14,28 @@ set(PRJ_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
# to underscore
set(TFM_PLATFORM_LOCAL_PATH "bsp/tf_m_targets/arm/mps3/an547")
# Override TF-M version
FetchContent_Declare(
tf-m
GIT_REPOSITORY https://git.trustedfirmware.org/TF-M/trusted-firmware-m.git
# Note: AN552 currently requires an unreleased version of TF-M.
# To be able to checkout an untagged commit, a full git clone is
# needed and GIT_SHALLOW is disabled.
GIT_TAG TF-Mv1.6.0-RC3
GIT_PROGRESS ON
# Note: This prevents FetchContent_MakeAvailable() from calling
# add_subdirectory() on the fetched repository. TF-M needs a
# standalone build because it relies on functions defined in its
# own toolchain files and contains paths that reference the
# top-level project instead of its own project.
SOURCE_SUBDIR NONE
)
# Declare the Open IoT SDK
FetchContent_Declare(
open_iot_sdk
GIT_REPOSITORY https://git.gitlab.arm.com/iot/open-iot-sdk/sdk.git
GIT_TAG v2022.01
GIT_REPOSITORY https://git.gitlab.oss.arm.com/engineering/iot-m-sw/open-iot-sdk/sdk.git
GIT_TAG ed118fea4b03ffa339ad7a9a5ee7d476f6a5b2d5
)
# Declare the Open IoT SDK configuration flags
......@@ -31,9 +48,10 @@ set(FETCHCONTENT_QUIET OFF)
set(TFM_PLATFORM "${CMAKE_CURRENT_SOURCE_DIR}/${TFM_PLATFORM_LOCAL_PATH}")
set(TFM_PSA_API OFF)
set(TFM_PARTITION_FIRMWARE_UPDATE ON)
set(TFM_LIB_MODEL ON)
# Extra arguments for TF-M and ML
set(TFM_CMAKE_ARGS "-DNS=OFF;-DPLATFORM_DEFAULT_UART_STDOUT=ON;-DMCUBOOT_SIGNATURE_KEY_LEN=2048;-DTFM_SYSTEM_FP=2;-DTFM_SYSTEM_FP_NS=2;-DTFM_SYSTEM_FPU=2;-DTFM_PARTITION_AUDIT_LOG=ON;-DITS_MAX_ASSET_SIZE=1300;-DCRYPTO_ENGINE_BUF_SIZE=0x8000")
set(TFM_CMAKE_ARGS "-DNS=ON;-DPLATFORM_DEFAULT_UART_STDOUT=ON;-DMCUBOOT_SIGNATURE_KEY_LEN=2048;-DCONFIG_TFM_FP=hard;-DCONFIG_TFM_FP_ARCH=fpv5-sp-d16;TFM_SYSTEM_FP=ON;-DTFM_PARTITION_AUDIT_LOG=ON;-DITS_MAX_ASSET_SIZE=1300;-DCRYPTO_ENGINE_BUF_SIZE=0x8000;-DMCUBOOT_LOG_LEVEL=INFO;-DTFM_SPM_LOG_LEVEL=TFM_SPM_LOG_LEVEL_INFO")
set(ML_CMAKE_ARGS "-Dkws_LABELS_TXT_FILE=resources/kws/labels/ds_cnn_labels.txt;-Dkws_MODEL_TFLITE_PATH=resources_downloaded/kws/ds_cnn_clustered_int8_vela_H128.tflite;-DUSE_CASE_BUILD=kws;-Dkws_ACTIVATION_BUF_SZ=0x00400000")
# Set library to std
......@@ -42,6 +60,9 @@ set(MBED_C_LIB "std")
# Set FVP variant
set(VARIANT "FVP")
# Set platform
set(MDH_PLATFORM "ARM_AN547_MPS3")
# Apply TF-M patch
find_package(Git)
set(TFM_PATCH_COMMAND ${GIT_EXECUTABLE} apply "${PRJ_DIR}/patches/tf-m.patch" || true)
......@@ -90,6 +111,25 @@ target_include_directories(freertos-kernel
${PRJ_DIR}/kws/include
)
# Patch the MDH target to enable multicast
target_compile_definitions(mdh-arm-an547-mps3
INTERFACE
LAN91C111_RFS_MULTICAST_SUPPORT
)
# CMSIS 5 require projects to provide configuration macros via RTE_Components.h
# and CMSIS_device_header. The macro CMSIS_device_header is not automatically set
# based on CMAKE_SYSTEM_PROCESSOR in the place where cmsis-core is first defined,
# because a project may want to provide its own device header.
target_include_directories(cmsis-core
INTERFACE
bsp/cmsis-config
)
target_compile_definitions(cmsis-core
INTERFACE
$<$<STREQUAL:${CMAKE_SYSTEM_PROCESSOR},cortex-m55>:CMSIS_device_header="ARMCM55.h">
)
# Compilation Database
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
add_custom_target(database COMMAND ${CMAKE_COMMAND} -E copy_if_different "${INT_DIR}/compile_commands.json" "${CMAKE_BINARY_DIR}")
......@@ -113,8 +153,8 @@ add_subdirectory(kws)
add_subdirectory(blinky)
# Copy tf-m binaries at the root
ExternalProject_Get_Property(tf-m BINARY_DIR)
ExternalProject_Get_Property(tf-m SOURCE_DIR)
FetchContent_GetProperties(tf-m)
add_custom_target(tfm-binaries
BYPRODUCTS
${CMAKE_BINARY_DIR}/bootloader/bl2.axf
......@@ -123,21 +163,21 @@ add_custom_target(tfm-binaries
${CMAKE_BINARY_DIR}/secure_partition/tfm_s_signed.bin
COMMAND ${CMAKE_COMMAND} -E copy
${BINARY_DIR}/install/outputs/$<UPPER_CASE:"EXTERNAL/${TFM_PLATFORM_LOCAL_PATH}">/bl2.axf
"${CMAKE_CURRENT_BINARY_DIR}/bootloader/bl2.axf"
${tf-m_BINARY_DIR}/install/outputs/bl2.axf
"${CMAKE_CURRENT_BINARY_DIR}/bootloader/bl2${CMAKE_EXECUTABLE_SUFFIX}"
COMMAND ${CMAKE_COMMAND} -E copy
${BINARY_DIR}/install/outputs/$<UPPER_CASE:"EXTERNAL/${TFM_PLATFORM_LOCAL_PATH}">/tfm_s.axf
"${CMAKE_CURRENT_BINARY_DIR}/secure_partition/tfm_s.axf"
${tf-m_BINARY_DIR}/install/outputs/tfm_s.axf
"${CMAKE_CURRENT_BINARY_DIR}/secure_partition/tfm_s${CMAKE_EXECUTABLE_SUFFIX}"
COMMAND
${ARM_ELF2BIN} --bin --output ${CMAKE_BINARY_DIR}/secure_partition/tfm_s_unsigned.bin ${CMAKE_BINARY_DIR}/secure_partition/tfm_s.axf --bincombined
${ARM_ELF2BIN} --bin --output ${CMAKE_BINARY_DIR}/secure_partition/tfm_s_unsigned.bin ${CMAKE_BINARY_DIR}/secure_partition/tfm_s${CMAKE_EXECUTABLE_SUFFIX} --bincombined
COMMAND
python3 ${BINARY_DIR}/install/image_signing/scripts/wrapper/wrapper.py
-v 1.3.0
python3 ${tf-m_BINARY_DIR}/install/image_signing/scripts/wrapper/wrapper.py
-v 0.0.1
--layout ${PRJ_DIR}/bsp/signing_layout_s.c
-k ${SOURCE_DIR}/bl2/ext/mcuboot/root-RSA-2048.pem
-k ${tf-m_SOURCE_DIR}/bl2/ext/mcuboot/root-RSA-2048.pem
--public-key-format full
--align 1
--pad
......@@ -148,5 +188,5 @@ add_custom_target(tfm-binaries
${CMAKE_BINARY_DIR}/secure_partition/tfm_s_signed.bin
)
add_dependencies(tfm-binaries tf-m)
add_dependencies(tfm-binaries tf-m-build)
add_dependencies(tfm-ns-interface tfm-binaries)
# Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
# Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
cmake_minimum_required(VERSION 3.21)
......@@ -23,27 +23,27 @@ target_link_libraries(blinky
# Copy the result of TF-M build in the top level build directory
# Convert axf files into bin
# Sign binaries
ExternalProject_Get_Property(tf-m BINARY_DIR)
ExternalProject_Get_Property(tf-m SOURCE_DIR)
FetchContent_GetProperties(tf-m)
add_custom_command(
TARGET
blinky
POST_BUILD
DEPENDS
${CMAKE_CURRENT_BINARY_DIR}/blinky.axf
${CMAKE_CURRENT_BINARY_DIR}/blinky${CMAKE_EXECUTABLE_SUFFIX}
BYPRODUCTS
${CMAKE_CURRENT_BINARY_DIR}/blinky_unsigned.bin
${CMAKE_CURRENT_BINARY_DIR}/blinky_signed.bin
COMMAND
${ARM_ELF2BIN} --bin --output ${CMAKE_CURRENT_BINARY_DIR}/blinky_unsigned.bin ${CMAKE_CURRENT_BINARY_DIR}/blinky.axf --bincombined
${ARM_ELF2BIN} --bin --output ${CMAKE_CURRENT_BINARY_DIR}/blinky_unsigned.bin ${CMAKE_CURRENT_BINARY_DIR}/blinky${CMAKE_EXECUTABLE_SUFFIX} --bincombined
COMMAND
python3 ${BINARY_DIR}/install/image_signing/scripts/wrapper/wrapper.py
-v 1.0.0
python3 ${tf-m_BINARY_DIR}/install/image_signing/scripts/wrapper/wrapper.py
-v 0.0.1
--layout ${PRJ_DIR}/bsp/signing_layout_ns.c
-k ${BINARY_DIR}/install/image_signing/keys/root-RSA-2048_1.pem
-k ${tf-m_BINARY_DIR}/install/image_signing/keys/root-RSA-2048_1.pem
--public-key-format full
--align 1
--pad
......
......@@ -26,7 +26,7 @@ def test_blinky(fvp):
# Traces expected in the output
expectations = [
'Starting bootloader',
'Booting TFM v1.4.1',
'Booting TF-M v1.6.0-RC3',
'FreeRTOS blink task started',
'LED on',
'LED off',
......
......@@ -184,12 +184,14 @@ add_library(startup
"${TFM_PLATFORM}/device/source/startup_an547_ns.c"
)
mbed_set_linker_script(startup "${PRJ_DIR}/bsp/an547_ns.sct")
set(link_definitions_file ${CMAKE_CURRENT_BINARY_DIR}/link_definitions.txt)
mdh_generate_definitions_for_linker(mdh-arm-an547-mps3-startup ${link_definitions_file})
mdh_set_linker_script(startup "${PRJ_DIR}/bsp/an547_ns.sct" ${link_definitions_file})
ExternalProject_Get_Property(tf-m SOURCE_DIR)
FetchContent_GetProperties(tf-m)
target_include_directories(startup
PRIVATE
"${SOURCE_DIR}/platform/include"
"${tf-m_SOURCE_DIR}/platform/include"
)
target_link_libraries(startup
......
/*
* Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* Copyright (c) 2019-2020 Arm Limited. All Rights Reserved.
* Copyright (c) 2019-2022 Arm Limited. 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
......@@ -3502,7 +3502,7 @@ CK_DEFINE_FUNCTION( CK_RV, C_GenerateKeyPair )( CK_SESSION_HANDLE xSession,
if( xResult == CKR_OK )
{
uxAlgorithm = PSA_ALG_ECDSA( PSA_ALG_SHA_256 );
uxKeyType = PSA_KEY_TYPE_ECC_KEY_PAIR( PSA_ECC_FAMILY_SECP_R1 );
uxKeyType = PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_FAMILY_SECP_R1);
if( strcmp( pxPrivateLabel->pValue,
pkcs11configLABEL_DEVICE_PRIVATE_KEY_FOR_TLS ) == 0 )
{
......@@ -3539,7 +3539,7 @@ CK_DEFINE_FUNCTION( CK_RV, C_GenerateKeyPair )( CK_SESSION_HANDLE xSession,
}
if ( uxStatus == PSA_SUCCESS )
{
uxKeyType = PSA_KEY_TYPE_ECC_KEY_PAIR( PSA_ECC_FAMILY_SECP_R1 );
uxKeyType = PSA_KEY_TYPE_ECC_PUBLIC_KEY( PSA_ECC_FAMILY_SECP_R1 );
uxAlgorithm = PSA_ALG_ECDSA( PSA_ALG_SHA_256 );
if( strcmp( pxPublicLabel->pValue,
pkcs11configLABEL_DEVICE_PUBLIC_KEY_FOR_TLS ) == 0 )
......
/*
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* Copyright (c) 2019-2020 Arm Limited. All Rights Reserved.
* Copyright (c) 2019-2022 Arm Limited. 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
......@@ -45,45 +45,65 @@ extern int convert_pem_to_der( const unsigned char * pucInput, size_t xLen,
*/
P11KeyConfig_t P11KeyConfig __attribute__(( section( "tasks_share" ) ));
/**
* @brief Helper function to convert MBedtls ECP group to PSA ECC group ID
*
* @param[in] grpid MBedtls ECP group ID.
*
* @return PSA ECC group ID.
*/
static psa_ecc_family_t mbedtls_ecc_group_to_psa( mbedtls_ecp_group_id grpid )
/** Convert an ECC curve identifier from the Mbed TLS encoding to PSA.
*
* \note This function is provided solely for the convenience of
* Mbed TLS and may be removed at any time without notice.
*
* \param grpid An Mbed TLS elliptic curve identifier
* (`MBEDTLS_ECP_DP_xxx`).
* \param[out] bits On success, the bit size of the curve.
*
* \return The corresponding PSA elliptic curve identifier
* (`PSA_ECC_FAMILY_xxx`).
* \return \c 0 on failure (\p grpid is not recognized).
*/
static inline psa_ecc_family_t mbedtls_ecc_group_to_psa( mbedtls_ecp_group_id grpid,
size_t *bits )
{
switch( grpid )
{
case MBEDTLS_ECP_DP_SECP192R1:
*bits = 192;
return( PSA_ECC_FAMILY_SECP_R1 );
case MBEDTLS_ECP_DP_SECP224R1:
*bits = 224;
return( PSA_ECC_FAMILY_SECP_R1 );
case MBEDTLS_ECP_DP_SECP256R1:
*bits = 256;
return( PSA_ECC_FAMILY_SECP_R1 );
case MBEDTLS_ECP_DP_SECP384R1:
*bits = 384;
return( PSA_ECC_FAMILY_SECP_R1 );
case MBEDTLS_ECP_DP_SECP521R1:
*bits = 521;
return( PSA_ECC_FAMILY_SECP_R1 );
case MBEDTLS_ECP_DP_BP256R1:
*bits = 256;
return( PSA_ECC_FAMILY_BRAINPOOL_P_R1 );
case MBEDTLS_ECP_DP_BP384R1:
*bits = 384;
return( PSA_ECC_FAMILY_BRAINPOOL_P_R1 );
case MBEDTLS_ECP_DP_BP512R1:
*bits = 512;
return( PSA_ECC_FAMILY_BRAINPOOL_P_R1 );
case MBEDTLS_ECP_DP_CURVE25519:
*bits = 255;
return( PSA_ECC_FAMILY_MONTGOMERY );
case MBEDTLS_ECP_DP_SECP192K1:
*bits = 192;
return( PSA_ECC_FAMILY_SECP_K1 );
case MBEDTLS_ECP_DP_SECP224K1:
*bits = 224;
return( PSA_ECC_FAMILY_SECP_K1 );
case MBEDTLS_ECP_DP_SECP256K1:
*bits = 256;
return( PSA_ECC_FAMILY_SECP_K1 );
case MBEDTLS_ECP_DP_CURVE448:
*bits = 448;
return( PSA_ECC_FAMILY_MONTGOMERY );
default:
*bits = 0;
return( 0 );
}
}
......@@ -116,6 +136,7 @@ CK_OBJECT_HANDLE PKCS11PSASaveObject( CK_ATTRIBUTE_PTR pxClass,
CK_RV xReturn;
psa_status_t uxStatus = PSA_SUCCESS;
mbedtls_ecp_group_id curve_id;
size_t bits;
const mbedtls_ecp_keypair *ec;
unsigned char cPrivateKeyRaw[EC_PRIVATE_KEY_MAX_LENGTH];
size_t xPrivateKeyRawSize = 0;
......@@ -236,7 +257,7 @@ CK_OBJECT_HANDLE PKCS11PSASaveObject( CK_ATTRIBUTE_PTR pxClass,
case MBEDTLS_PK_ECDSA:
ec = (mbedtls_ecp_keypair *) (pvContext->pk_ctx );
curve_id = mbedtls_ecp_curve_info_from_grp_id( ec->grp.id )->grp_id;
uxKeyType = PSA_KEY_TYPE_ECC_KEY_PAIR(mbedtls_ecc_group_to_psa(curve_id));
uxKeyType = PSA_KEY_TYPE_ECC_KEY_PAIR(mbedtls_ecc_group_to_psa(curve_id, &bits));
uxAlgorithm = PSA_ALG_ECDSA( PSA_ALG_SHA_256 );
xPrivateKeyRawSize = ( ec->grp.nbits + 7 ) / 8;
if( 0 != mbedtls_mpi_write_binary( &ec->d,
......@@ -299,7 +320,7 @@ CK_OBJECT_HANDLE PKCS11PSASaveObject( CK_ATTRIBUTE_PTR pxClass,
case MBEDTLS_PK_ECDSA:
ec = (mbedtls_ecp_keypair *) (pvContext->pk_ctx );
curve_id = mbedtls_ecp_curve_info_from_grp_id( ec->grp.id )->grp_id;
uxKeyType = PSA_KEY_TYPE_ECC_PUBLIC_KEY(mbedtls_ecc_group_to_psa(curve_id));
uxKeyType = PSA_KEY_TYPE_ECC_PUBLIC_KEY(mbedtls_ecc_group_to_psa(curve_id, &bits));
uxAlgorithm = PSA_ALG_ECDSA( PSA_ALG_SHA_256 );
if( 0 !=get_public_key_ECPoint( pucData,
ulDataSize,
......@@ -355,7 +376,7 @@ CK_OBJECT_HANDLE PKCS11PSASaveObject( CK_ATTRIBUTE_PTR pxClass,
case MBEDTLS_PK_ECDSA:
ec = (mbedtls_ecp_keypair *) (pvContext->pk_ctx );
curve_id = mbedtls_ecp_curve_info_from_grp_id( ec->grp.id )->grp_id;
uxKeyType = PSA_KEY_TYPE_ECC_PUBLIC_KEY(mbedtls_ecc_group_to_psa(curve_id));
uxKeyType = PSA_KEY_TYPE_ECC_PUBLIC_KEY(mbedtls_ecc_group_to_psa(curve_id, &bits));
uxAlgorithm = PSA_ALG_ECDSA( PSA_ALG_SHA_256 );
if( 0 !=get_public_key_ECPoint( pucData,
ulDataSize,
......
/*
* FreeRTOS HTTPS Client 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
*/
/**
* @file iot_https_utils.c
* @brief Implements functions for HTTPS Client library utilities.
*/
/* The config header is always included first. */
#include "iot_config.h"
/* iot_https_includes */
#include "iot_https_utils.h"
#include "http_parser.h"
#include "private/iot_https_internal.h"
/*-----------------------------------------------------------*/
IotHttpsReturnCode_t IotHttpsClient_GetUrlPath( const char * pUrl,
size_t urlLen,
const char ** pPath,
size_t * pPathLen )
{
/* http-parser status. Initialized to 0 to signify success. */
int parserStatus = 0;
struct http_parser_url urlParser;
IotHttpsReturnCode_t returnStatus = IOT_HTTPS_OK;
/* Sets all members in urlParser to 0. */
http_parser_url_init( &urlParser );
if( ( pUrl == NULL ) || ( pPath == NULL ) || ( pPathLen == NULL ) )
{
IotLogError( "NULL parameter passed to IotHttpsClient_GetUrlPath()." );
returnStatus = IOT_HTTPS_INVALID_PARAMETER;
}
if( returnStatus == IOT_HTTPS_OK )
{
parserStatus = http_parser_parse_url( pUrl, urlLen, 0, &urlParser );
if( parserStatus != 0 )
{
IotLogError( "Error parsing the input URL %.*s. Error code: %d.", urlLen, pUrl, parserStatus );
returnStatus = IOT_HTTPS_PARSING_ERROR;
}
}
if( returnStatus == IOT_HTTPS_OK )
{
*pPathLen = ( size_t ) ( urlParser.field_data[ UF_PATH ].len );
if( *pPathLen == 0 )
{
returnStatus = IOT_HTTPS_NOT_FOUND;
*pPath = NULL;
}
else
{
*pPath = &pUrl[ urlParser.field_data[ UF_PATH ].off ];
}
}
return returnStatus;
}
/*-----------------------------------------------------------*/
IotHttpsReturnCode_t IotHttpsClient_GetUrlAddress( const char * pUrl,
size_t urlLen,
const char ** pAddress,
size_t * pAddressLen )
{
/* http-parser status. Initialized to 0 to signify success. */
int parserStatus = 0;
struct http_parser_url urlParser;
IotHttpsReturnCode_t returnStatus = IOT_HTTPS_OK;
/* Sets all members in urlParser to 0. */
http_parser_url_init( &urlParser );
if( ( pUrl == NULL ) || ( pAddress == NULL ) || ( pAddressLen == NULL ) )
{
IotLogError( "NULL parameter passed to IotHttpsClient_GetUrlAddress()." );
returnStatus = IOT_HTTPS_INVALID_PARAMETER;
}
if( returnStatus == IOT_HTTPS_OK )
{
parserStatus = http_parser_parse_url( pUrl, urlLen, 0, &urlParser );
if( parserStatus != 0 )
{
IotLogError( "Error parsing the input URL %.*s. Error code: %d.", urlLen, pUrl, parserStatus );
returnStatus = IOT_HTTPS_PARSING_ERROR;
}
}
if( returnStatus == IOT_HTTPS_OK )
{
*pAddressLen = ( size_t ) ( urlParser.field_data[ UF_HOST ].len );
if( *pAddressLen == 0 )
{
returnStatus = IOT_HTTPS_NOT_FOUND;
*pAddress = NULL;
}
else
{
*pAddress = &pUrl[ urlParser.field_data[ UF_HOST ].off ];
}
}
return returnStatus;
}
/*
* FreeRTOS V202012.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://aws.amazon.com/freertos
* http://www.FreeRTOS.org
*/
/**
* @file iot_demo.c
* @brief Demo
*/
/* The config header is always included first. */
#include "iot_config.h"
#include "FreeRTOS.h"
#include "aws_clientcredential.h"
/*-----------------------------------------------------------*/
/* configUSE_STATIC_ALLOCATION is set to 1, so the application must provide an
* implementation of vApplicationGetIdleTaskMemory() to provide the memory that is
* used by the Idle task. */
void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
StackType_t ** ppxIdleTaskStackBuffer,
uint32_t * pulIdleTaskStackSize )
{
/* If the buffers to be provided to the Idle task are declared inside this
* function then they must be declared static - otherwise they will be allocated on
* the stack and so not exists after this function exits. */
static StaticTask_t xIdleTaskTCB;
static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ];
/* Pass out a pointer to the StaticTask_t structure in which the Idle
* task's state will be stored. */
*ppxIdleTaskTCBBuffer = &xIdleTaskTCB;
/* Pass out the array that will be used as the Idle task's stack. */
*ppxIdleTaskStackBuffer = uxIdleTaskStack;
/* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer.
* Note that, as the array is necessarily of type StackType_t,
* configMINIMAL_STACK_SIZE is specified in words, not bytes. */
*pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
}
/*-----------------------------------------------------------*/
/**
* @brief This is to provide the memory that is used by the RTOS daemon/time task.
*
* If configUSE_STATIC_ALLOCATION is set to 1, so the application must provide an
* implementation of vApplicationGetTimerTaskMemory() to provide the memory that is
* used by the RTOS daemon/time task.
*/
void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer,
StackType_t ** ppxTimerTaskStackBuffer,
uint32_t * pulTimerTaskStackSize )
{
/* If the buffers to be provided to the Timer task are declared inside this
* function then they must be declared static - otherwise they will be allocated on
* the stack and so not exists after this function exits. */
static StaticTask_t xTimerTaskTCB;
static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ];
/* Pass out a pointer to the StaticTask_t structure in which the Idle
* task's state will be stored. */
*ppxTimerTaskTCBBuffer = &xTimerTaskTCB;
/* Pass out the array that will be used as the Timer task's stack. */
*ppxTimerTaskStackBuffer = uxTimerTaskStack;
/* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer.
* Note that, as the array is necessarily of type StackType_t,
* configMINIMAL_STACK_SIZE is specified in words, not bytes. */
*pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
}
/*-----------------------------------------------------------*/
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment