diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml old mode 100755 new mode 100644 index 5d9bcc61..3590f039 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -22,12 +22,12 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout project - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: path: ${{ github.workspace }} submodules: 'recursive' - name: Install python 3 - uses: actions/setup-python@v2 + uses: actions/setup-python@v3 with: architecture: x64 env: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml old mode 100755 new mode 100644 index b1c7cba8..ad72bda3 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,39 +22,45 @@ jobs: runs-on: ubuntu-latest steps: - name: Clone This Repo - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Run spellings check uses: FreeRTOS/CI-CD-Github-Actions/spellings@main - with: - path: ./ formatting: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v3 + - name: Check formatting + uses: FreeRTOS/CI-CD-Github-Actions/formatting@main + + link-verifier: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Install Uncrustify - run: sudo apt-get install uncrustify - - name: Run Uncrustify - run: | - uncrustify --version - find Projects Config -iname "*.[hc]" -exec uncrustify --check -c Tools/uncrustify.cfg {} + - - name: Check For Trailing Whitespace - run: | - set +e - grep --exclude="README.md" --exclude-dir=Bsp --exclude-dir=Docs --exclude-dir=Middleware -rnI -e "[[:blank:]]$" . - if [ "$?" = "0" ]; then - echo "Files have trailing whitespace." - exit 1 - else - exit 0 - fi + - uses: actions/checkout@v3 + - name: Check Links + uses: FreeRTOS/CI-CD-Github-Actions/link-verifier@main + with: + exclude-urls: 'https://developer.arm.com/-/media/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-\`uname' + + verify-manifest: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + submodules: true + fetch-depth: 0 + + - name: Run manifest verifier + uses: FreeRTOS/CI-CD-GitHub-Actions/manifest-verifier@main + with: + fail-on-incorrect-version: true git-secrets: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Checkout awslabs/git-secrets - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: repository: awslabs/git-secrets ref: master diff --git a/.github/workflows/formatting.yml b/.github/workflows/formatting.yml new file mode 100644 index 00000000..04786bad --- /dev/null +++ b/.github/workflows/formatting.yml @@ -0,0 +1,23 @@ +name: Format Pull Request Files + +on: + issue_comment: + types: [created] + +env: + bashPass: \033[32;1mPASSED - + bashInfo: \033[33;1mINFO - + bashFail: \033[31;1mFAILED - + bashEnd: \033[0m + +jobs: + Formatting: + name: Run Formatting Check + if: ${{ github.event.issue.pull_request && + ( ( github.event.comment.body == '/bot run uncrustify' ) || + ( github.event.comment.body == '/bot run formatting' ) ) }} + runs-on: ubuntu-20.04 + steps: + - name: Apply Formatting Fix + uses: FreeRTOS/CI-CD-Github-Actions/formatting-bot@main + id: check-formatting diff --git a/Bsp/common/bsp_serial.c b/Bsp/common/bsp_serial.c index e9bbd012..990a5a9b 100644 --- a/Bsp/common/bsp_serial.c +++ b/Bsp/common/bsp_serial.c @@ -11,114 +11,134 @@ extern ARM_DRIVER_USART Driver_USART0; -void bsp_serial_init(void) +void bsp_serial_init( void ) { - Driver_USART0.Initialize(NULL); - Driver_USART0.Control(ARM_USART_MODE_ASYNCHRONOUS, DEFAULT_UART_BAUDRATE); + Driver_USART0.Initialize( NULL ); + Driver_USART0.Control( ARM_USART_MODE_ASYNCHRONOUS, DEFAULT_UART_BAUDRATE ); } -void bsp_serial_print(char *str) +void bsp_serial_print( char * str ) { - (void)Driver_USART0.Send(str, strlen(str)); + ( void ) Driver_USART0.Send( str, strlen( str ) ); } -#if defined(__ARMCOMPILER_VERSION) +#if defined( __ARMCOMPILER_VERSION ) /* Retarget armclang, which requires all IO system calls to be overridden together. */ -#include + #include -#define STDIN_FILENO 0 -#define STDOUT_FILENO 1 -#define STDERR_FILENO 2 + #define STDIN_FILENO 0 + #define STDOUT_FILENO 1 + #define STDERR_FILENO 2 -FILEHANDLE _sys_open(const char *name, int openmode) -{ - if (name == NULL) { - return -1; - } - - // By default, the Arm Compiler uses the special file path ":tt" for stdin, - // stdout and stderr and distinguishes between them using openmode. For details, - // see https://github.com/ARM-software/abi-aa/blob/2022Q1/semihosting/semihosting.rst#sys-open-0x01 - if (strcmp(name, ":tt") == 0) { - if (openmode & OPEN_W) { - return STDOUT_FILENO; - } - if (openmode & OPEN_A) { - return STDERR_FILENO; + FILEHANDLE _sys_open( const char * name, + int openmode ) + { + if( name == NULL ) + { + return -1; } - return STDIN_FILENO; - } - - return -1; -} -int _sys_close(FILEHANDLE fh) -{ - /* Not implemented */ - (void)fh; - return -1; -} - -int _sys_write(FILEHANDLE fd, const unsigned char *str, unsigned int len, int mode) -{ - /* From : `mode' exists for historical reasons and must be ignored. */ - (void)mode; + /* By default, the Arm Compiler uses the special file path ":tt" for stdin, */ + /* stdout and stderr and distinguishes between them using openmode. For details, */ + /* see https://github.com/ARM-software/abi-aa/blob/2022Q1/semihosting/semihosting.rst#sys-open-0x01 */ + if( strcmp( name, ":tt" ) == 0 ) + { + if( openmode & OPEN_W ) + { + return STDOUT_FILENO; + } + + if( openmode & OPEN_A ) + { + return STDERR_FILENO; + } + + return STDIN_FILENO; + } - if (fd != STDOUT_FILENO && fd != STDERR_FILENO) { return -1; } - if (Driver_USART0.Send(str, len) != ARM_DRIVER_OK) { + int _sys_close( FILEHANDLE fh ) + { + /* Not implemented */ + ( void ) fh; return -1; } - return 0; -} + int _sys_write( FILEHANDLE fd, + const unsigned char * str, + unsigned int len, + int mode ) + { + /* From : `mode' exists for historical reasons and must be ignored. */ + ( void ) mode; + + if( ( fd != STDOUT_FILENO ) && ( fd != STDERR_FILENO ) ) + { + return -1; + } -int _sys_read(FILEHANDLE fd, unsigned char *str, unsigned int len, int mode) -{ - // From : `mode' exists for historical reasons and must be ignored. - (void)mode; + if( Driver_USART0.Send( str, len ) != ARM_DRIVER_OK ) + { + return -1; + } - /* Not implemented */ - (void)str; - (void)len; - return -1; -} + return 0; + } -int _sys_istty(FILEHANDLE fh) -{ - /* Not implemented */ - (void)fh; - return 0; -} + int _sys_read( FILEHANDLE fd, + unsigned char * str, + unsigned int len, + int mode ) + { + /* From : `mode' exists for historical reasons and must be ignored. */ + ( void ) mode; + + /* Not implemented */ + ( void ) str; + ( void ) len; + return -1; + } -long _sys_flen(FILEHANDLE fh) -{ - /* Not implemented */ - (void)fh; - return -1; -} + int _sys_istty( FILEHANDLE fh ) + { + /* Not implemented */ + ( void ) fh; + return 0; + } -int _sys_seek(FILEHANDLE fh, long offset) -{ - /* Not implemented */ - (void)fh; - (void)offset; - return -1; -} + long _sys_flen( FILEHANDLE fh ) + { + /* Not implemented */ + ( void ) fh; + return -1; + } + + int _sys_seek( FILEHANDLE fh, + long offset ) + { + /* Not implemented */ + ( void ) fh; + ( void ) offset; + return -1; + } #else /* !defined(__ARMCOMPILER_VERSION) */ /* Redirects gcc printf to UART0 */ -int _write(int fd, char *str, int len) -{ - if (Driver_USART0.Send(str, len) == ARM_DRIVER_OK) { - return len; + int _write( int fd, + char * str, + int len ) + { + if( Driver_USART0.Send( str, len ) == ARM_DRIVER_OK ) + { + return len; + } + + return 0; } - return 0; -} -#endif +#endif /* if defined( __ARMCOMPILER_VERSION ) */ diff --git a/Bsp/common/bsp_serial.h b/Bsp/common/bsp_serial.h index 1714c9e7..f01b3ef2 100644 --- a/Bsp/common/bsp_serial.h +++ b/Bsp/common/bsp_serial.h @@ -12,11 +12,11 @@ /** * \brief Initializes default UART device */ -void bsp_serial_init(void); +void bsp_serial_init( void ); /** * \brief Prints a string through the default UART device */ -void bsp_serial_print(char *str); +void bsp_serial_print( char * str ); #endif /* __SERIAL_H__ */ diff --git a/Config/freertos-config/FreeRTOSConfig.h b/Config/freertos-config/FreeRTOSConfig.h index 9ba2f722..286d098a 100644 --- a/Config/freertos-config/FreeRTOSConfig.h +++ b/Config/freertos-config/FreeRTOSConfig.h @@ -183,8 +183,8 @@ void vLoggingPrintf( const char * pcFormat, /* 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. */ + * 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 diff --git a/Docs/aws-iot-example.md b/Docs/aws-iot-example.md index 82764127..f7203240 100644 --- a/Docs/aws-iot-example.md +++ b/Docs/aws-iot-example.md @@ -518,7 +518,7 @@ Follow the instructions described in the sections listed below to create an IoT thing for your device and attaching a policy to it. * [IoT thing](#creating-an-iot-thing-for-your-device) -* [IoT policy](#creating-a-policy-and-attach-it-to-your-thing) +* [IoT policy](#creating-a-policy-and-attach-it-to-your-certificate) ### Creating roles and policies diff --git a/Middleware/ARM/IoT_VSocket-lib/transport_tls_iot_socket.c b/Middleware/ARM/IoT_VSocket-lib/transport_tls_iot_socket.c index 90fcc915..98b34f1f 100644 --- a/Middleware/ARM/IoT_VSocket-lib/transport_tls_iot_socket.c +++ b/Middleware/ARM/IoT_VSocket-lib/transport_tls_iot_socket.c @@ -23,11 +23,11 @@ static int Recv_Cb( void * pvCallerContext, - unsigned char * pucReceiveBuffer, - size_t xReceiveLength ); + unsigned char * pucReceiveBuffer, + size_t xReceiveLength ); static int Send_Cb( void * pvCallerContext, - const unsigned char * pucData, - size_t xDataLength ); + const unsigned char * pucData, + size_t xDataLength ); TransportStatus_t Transport_Connect( NetworkContext_t * pNetworkContext, @@ -199,8 +199,8 @@ int32_t Transport_Send( NetworkContext_t * pNetworkContext, * @return The number of bytes actually read or appropriate error code. */ static int Recv_Cb( void * pvCallerContext, - unsigned char * pucReceiveBuffer, - size_t xReceiveLength ) + unsigned char * pucReceiveBuffer, + size_t xReceiveLength ) { int rc; NetworkContext_t * pNetworkContext = ( NetworkContext_t * ) ( pvCallerContext ); @@ -236,8 +236,8 @@ static int Recv_Cb( void * pvCallerContext, * @return The number of bytes actually sent. */ static int Send_Cb( void * pvCallerContext, - const unsigned char * pucData, - size_t xDataLength ) + const unsigned char * pucData, + size_t xDataLength ) { NetworkContext_t * pNetworkContext = ( NetworkContext_t * ) ( pvCallerContext ); int rc; @@ -265,6 +265,7 @@ TransportStatus_t Transport_Disconnect( NetworkContext_t * pNetworkContext ) else { int32_t socketStatus; + do { socketStatus = iotSocketClose( pNetworkContext->socket ); diff --git a/Middleware/ARM/freertos-ota-pal-psa-lib/src/ota_provision.c b/Middleware/ARM/freertos-ota-pal-psa-lib/src/ota_provision.c index c9bfe5e0..08d5a8d1 100644 --- a/Middleware/ARM/freertos-ota-pal-psa-lib/src/ota_provision.c +++ b/Middleware/ARM/freertos-ota-pal-psa-lib/src/ota_provision.c @@ -29,9 +29,9 @@ extern int convert_pem_to_der( const unsigned char * pucInput, unsigned char * pucOutput, size_t * pxOlen ); -int ota_privision_code_signing_key(psa_key_handle_t * key_handle) +int ota_privision_code_signing_key( psa_key_handle_t * key_handle ) { - uint8_t public_key_der[512]; + uint8_t public_key_der[ 512 ]; size_t xLength = 512; int result; psa_key_handle_t key_handle_tmp = 0; @@ -39,9 +39,10 @@ int ota_privision_code_signing_key(psa_key_handle_t * key_handle) psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; result = convert_pem_to_der( ( const unsigned char * ) cOTARSAPublicKey, - sizeof( cOTARSAPublicKey ), - public_key_der, - &xLength ); + sizeof( cOTARSAPublicKey ), + public_key_der, + &xLength ); + if( result != 0 ) { return result; @@ -50,11 +51,13 @@ int ota_privision_code_signing_key(psa_key_handle_t * key_handle) psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_VERIFY_HASH ); psa_set_key_algorithm( &attributes, PSA_ALG_RSA_PSS_ANY_SALT( PSA_ALG_SHA_256 ) ); psa_set_key_type( &attributes, PSA_KEY_TYPE_RSA_PUBLIC_KEY ); - psa_set_key_bits(&attributes, 3072); - status = psa_import_key(&attributes, ( const uint8_t *)public_key_der, xLength, &key_handle_tmp ); + psa_set_key_bits( &attributes, 3072 ); + status = psa_import_key( &attributes, ( const uint8_t * ) public_key_der, xLength, &key_handle_tmp ); + if( status == PSA_SUCCESS ) { *key_handle = key_handle_tmp; } + return status; } diff --git a/Middleware/ARM/freertos-ota-pal-psa-lib/src/ota_provision.h b/Middleware/ARM/freertos-ota-pal-psa-lib/src/ota_provision.h index c40d0ca4..d5d01bdc 100644 --- a/Middleware/ARM/freertos-ota-pal-psa-lib/src/ota_provision.h +++ b/Middleware/ARM/freertos-ota-pal-psa-lib/src/ota_provision.h @@ -4,15 +4,15 @@ */ #ifndef _OTA_PROVISION_ -#define _OTA_PROVISION_ -#include "psa/crypto.h" -#ifdef __cplusplus -extern "C" { -#endif + #define _OTA_PROVISION_ + #include "psa/crypto.h" + #ifdef __cplusplus + extern "C" { + #endif -int ota_privision_code_signing_key(psa_key_handle_t * key_handle); + int ota_privision_code_signing_key( psa_key_handle_t * key_handle ); -#ifdef __cplusplus + #ifdef __cplusplus } -#endif -#endif + #endif +#endif /* ifndef _OTA_PROVISION_ */ diff --git a/Middleware/ARM/mbedtls-lib/src/tls_helper.h b/Middleware/ARM/mbedtls-lib/src/tls_helper.h index c4c88099..f5361e4d 100644 --- a/Middleware/ARM/mbedtls-lib/src/tls_helper.h +++ b/Middleware/ARM/mbedtls-lib/src/tls_helper.h @@ -63,8 +63,8 @@ typedef struct TLSContext * @return The number of bytes actually read. */ typedef int ( * NetworkRecv_t )( void * pvCallerContext, - unsigned char * pucReceiveBuffer, - size_t xReceiveLength ); + unsigned char * pucReceiveBuffer, + size_t xReceiveLength ); /** * @brief Defines callback type for sending bytes to the network. @@ -76,8 +76,8 @@ typedef int ( * NetworkRecv_t )( void * pvCallerContext, * @return The number of bytes actually sent. */ typedef int ( * NetworkSend_t )( void * pvCallerContext, - const unsigned char * pucData, - size_t xDataLength ); + const unsigned char * pucData, + size_t xDataLength ); /** * @brief Defines parameter structure for initializing the TLS interface. @@ -103,9 +103,9 @@ typedef struct TLSHelperParams const char * pcServerCertificate; uint32_t ulServerCertificateLength; - const char * pClientCertLabel; /**< @brief String representing the PKCS #11 label for the client certificate. */ - const char * pPrivateKeyLabel; /**< @brief String representing the PKCS #11 label for the private key. */ - const char * pcLoginPIN; /**< @brief A login Password used to retrive the credentials */ + const char * pClientCertLabel; /**< @brief String representing the PKCS #11 label for the client certificate. */ + const char * pPrivateKeyLabel; /**< @brief String representing the PKCS #11 label for the private key. */ + const char * pcLoginPIN; /**< @brief A login Password used to retrive the credentials */ } TLSHelperParams_t; /** @@ -116,7 +116,8 @@ typedef struct TLSHelperParams * * @return Zero on success. Error return codes have the high bit set. */ -BaseType_t TLS_Init( TLSHelperParams_t * pxParams, TLSContext_t * pxContext ); +BaseType_t TLS_Init( TLSHelperParams_t * pxParams, + TLSContext_t * pxContext ); /** * @brief Perform TLS handshake with the given TLS context. @@ -136,12 +137,12 @@ void TLS_Cleanup( TLSContext_t * pxContext ); int32_t TLS_Recv( TLSContext_t * pxContext, - unsigned char * pucReadBuffer, - size_t xReadLength ); + unsigned char * pucReadBuffer, + size_t xReadLength ); int32_t TLS_Send( TLSContext_t * pxContext, - const unsigned char * pucMsg, - size_t xMsgLength ); + const unsigned char * pucMsg, + size_t xMsgLength ); #endif /* ifndef TLS_HELPER_H */ diff --git a/Projects/aws-iot-example/dev_mode_key_provisioning.c b/Projects/aws-iot-example/dev_mode_key_provisioning.c index dcde9abe..5ffad940 100644 --- a/Projects/aws-iot-example/dev_mode_key_provisioning.c +++ b/Projects/aws-iot-example/dev_mode_key_provisioning.c @@ -1074,6 +1074,7 @@ CK_RV xProvisionDevice( CK_SESSION_HANDLE xSession, xResult = C_GetFunctionList( &pxFunctionList ); #if ( pkcs11configIMPORT_PRIVATE_KEYS_SUPPORTED == 1 ) + /* Attempt to clean-up old crypto objects, but only if private key import is * supported by this application, and only if the caller has provided new * objects to use instead. */ @@ -1107,6 +1108,7 @@ CK_RV xProvisionDevice( CK_SESSION_HANDLE xSession, } #if ( pkcs11configIMPORT_PRIVATE_KEYS_SUPPORTED == 1 ) + /* If this application supports importing private keys, and if a private * key has been provided by the caller, attempt to import it. */ if( ( xResult == CKR_OK ) && ( NULL != pxParams->pucClientPrivateKey ) ) diff --git a/Projects/aws-iot-example/mqtt-agent-wrapper/mqtt_agent_task.c b/Projects/aws-iot-example/mqtt-agent-wrapper/mqtt_agent_task.c index b239dc9f..c77db1b7 100644 --- a/Projects/aws-iot-example/mqtt-agent-wrapper/mqtt_agent_task.c +++ b/Projects/aws-iot-example/mqtt-agent-wrapper/mqtt_agent_task.c @@ -287,6 +287,7 @@ static BaseType_t prvSocketConnect( NetworkContext_t * pxNetworkContext ) ServerInfo_t xServerInfo = { 0 }; #ifdef democonfigUSE_AWS_IOT_CORE_BROKER + /* ALPN protocols must be a NULL-terminated list of strings. Therefore, * the first entry will contain the actual ALPN protocol string while the * second entry must remain NULL. */ diff --git a/manifest.yml b/manifest.yml index ecefb1fc..13c7d6e3 100644 --- a/manifest.yml +++ b/manifest.yml @@ -17,13 +17,6 @@ dependencies: type: "git" url: "https://git.gitlab.arm.com/iot/open-iot-sdk/arm-corstone-platform-bsp.git" path: "Bsp/arm-corstone-platform-bsp" - - name: "CMSIS_5" - license: "Apache-2.0" - version: "5.9.0" - repository: - type: "git" - url: "https://github.com/ARM-software/CMSIS_5.git" - path: "Bsp/arm-corstone-platform-bsp/CMSIS/CMSIS_5" - name: "trusted-firmware-m" license: "BSD-3-Clause" version: "e435409343c074ba8f00349c459a3066cf6dece1"