diff --git a/.github/workflows/freertos_plus_demos.yml b/.github/workflows/freertos_plus_demos.yml index 583b89193d0..684111dd038 100644 --- a/.github/workflows/freertos_plus_demos.yml +++ b/.github/workflows/freertos_plus_demos.yml @@ -956,7 +956,7 @@ jobs: - env: stepName: Build AWS IoT Fleet Provisioning Demo name: ${{ env.stepName }} - working-directory: FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo + working-directory: FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo run: | # ${{ env.stepName }} echo "::group::${{ env.stepName }}" diff --git a/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/DemoSetup/cloudformation_template.json b/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/DemoSetup/cloudformation_template.json similarity index 100% rename from FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/DemoSetup/cloudformation_template.json rename to FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/DemoSetup/cloudformation_template.json diff --git a/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/DemoSetup/convert_credentials_to_der.py b/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/DemoSetup/convert_credentials_to_der.py similarity index 100% rename from FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/DemoSetup/convert_credentials_to_der.py rename to FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/DemoSetup/convert_credentials_to_der.py diff --git a/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/DemoSetup/demo_cleanup.py b/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/DemoSetup/demo_cleanup.py similarity index 100% rename from FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/DemoSetup/demo_cleanup.py rename to FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/DemoSetup/demo_cleanup.py diff --git a/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/DemoSetup/demo_config.templ b/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/DemoSetup/demo_config.templ similarity index 100% rename from FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/DemoSetup/demo_config.templ rename to FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/DemoSetup/demo_config.templ diff --git a/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/DemoSetup/demo_config_empty.templ b/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/DemoSetup/demo_config_empty.templ similarity index 100% rename from FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/DemoSetup/demo_config_empty.templ rename to FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/DemoSetup/demo_config_empty.templ diff --git a/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/DemoSetup/demo_setup.py b/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/DemoSetup/demo_setup.py similarity index 100% rename from FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/DemoSetup/demo_setup.py rename to FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/DemoSetup/demo_setup.py diff --git a/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/DemoSetup/example_claim_policy.json b/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/DemoSetup/example_claim_policy.json similarity index 100% rename from FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/DemoSetup/example_claim_policy.json rename to FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/DemoSetup/example_claim_policy.json diff --git a/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/DemoSetup/example_fleet_provisioning_template.json b/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/DemoSetup/example_fleet_provisioning_template.json similarity index 100% rename from FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/DemoSetup/example_fleet_provisioning_template.json rename to FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/DemoSetup/example_fleet_provisioning_template.json diff --git a/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/DemoSetup/example_iot_thing_policy.json b/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/DemoSetup/example_iot_thing_policy.json similarity index 100% rename from FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/DemoSetup/example_iot_thing_policy.json rename to FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/DemoSetup/example_iot_thing_policy.json diff --git a/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/DemoSetup/generate_credentials.py b/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/DemoSetup/generate_credentials.py similarity index 100% rename from FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/DemoSetup/generate_credentials.py rename to FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/DemoSetup/generate_credentials.py diff --git a/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/FleetProvisioningDemoExample.c b/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/FleetProvisioningDemoExample.c similarity index 99% rename from FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/FleetProvisioningDemoExample.c rename to FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/FleetProvisioningDemoExample.c index 05ace5c7d8f..c8e75dd0a6c 100644 --- a/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/FleetProvisioningDemoExample.c +++ b/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/FleetProvisioningDemoExample.c @@ -291,6 +291,10 @@ static bool prvUnsubscribeFromRegisterThingResponseTopics( void ); static int prvFleetProvisioningTask( void * pvParameters ); +/*-----------------------------------------------------------*/ + +BaseType_t xPlatformIsNetworkUp( void ); + /*-----------------------------------------------------------*/ static void prvProvisioningPublishCallback( MQTTContext_t * pxMqttContext, diff --git a/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/core_mqtt_config.h b/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/core_mqtt_config.h similarity index 100% rename from FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/core_mqtt_config.h rename to FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/core_mqtt_config.h diff --git a/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/demo_config.h b/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/demo_config.h similarity index 100% rename from FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/demo_config.h rename to FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/demo_config.h diff --git a/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/fleet_provisioning_config.h b/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/fleet_provisioning_config.h similarity index 100% rename from FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/fleet_provisioning_config.h rename to FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/fleet_provisioning_config.h diff --git a/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/fleet_provisioning_demo.sln b/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/fleet_provisioning_demo.sln similarity index 100% rename from FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/fleet_provisioning_demo.sln rename to FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/fleet_provisioning_demo.sln diff --git a/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/fleet_provisioning_demo.vcxproj b/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/fleet_provisioning_demo.vcxproj similarity index 100% rename from FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/fleet_provisioning_demo.vcxproj rename to FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/fleet_provisioning_demo.vcxproj diff --git a/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/fleet_provisioning_demo.vcxproj.filters b/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/fleet_provisioning_demo.vcxproj.filters similarity index 100% rename from FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/fleet_provisioning_demo.vcxproj.filters rename to FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/fleet_provisioning_demo.vcxproj.filters diff --git a/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/main.c b/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/main.c similarity index 98% rename from FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/main.c rename to FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/main.c index ba12350ac9a..7fc4756d971 100644 --- a/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/main.c +++ b/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/main.c @@ -54,6 +54,7 @@ /*-----------------------------------------------------------*/ extern void vStartFleetProvisioningDemo( void ); +extern void vPlatformInitIpStack( void ); /*-----------------------------------------------------------*/ diff --git a/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/pkcs11_operations.c b/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/pkcs11_operations.c similarity index 99% rename from FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/pkcs11_operations.c rename to FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/pkcs11_operations.c index 9d7ee97f666..4cf1af25f49 100644 --- a/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/pkcs11_operations.c +++ b/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/pkcs11_operations.c @@ -214,7 +214,6 @@ bool xGenerateKeyAndCsr( CK_SESSION_HANDLE xP11Session, CK_OBJECT_HANDLE xPubKeyHandle; CK_RV xPkcs11Ret = CKR_OK; mbedtls_pk_context xPrivKey; - mbedtls_ecdsa_context xEcdsaContext; mbedtls_x509write_csr xReq; int32_t ulMbedtlsRet = -1; const mbedtls_pk_info_t * pxHeader = mbedtls_pk_info_from_type( MBEDTLS_PK_ECKEY ); diff --git a/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/pkcs11_operations.h b/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/pkcs11_operations.h similarity index 100% rename from FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/pkcs11_operations.h rename to FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/pkcs11_operations.h diff --git a/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/tinycbor_serializer.c b/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/tinycbor_serializer.c similarity index 100% rename from FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/tinycbor_serializer.c rename to FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/tinycbor_serializer.c diff --git a/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/tinycbor_serializer.h b/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/tinycbor_serializer.h similarity index 100% rename from FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/tinycbor_serializer.h rename to FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/CSR_Demo/tinycbor_serializer.h diff --git a/FreeRTOS-Plus/Demo/AWS/Mqtt_Demo_Helpers/mqtt_demo_helpers.c b/FreeRTOS-Plus/Demo/AWS/Mqtt_Demo_Helpers/mqtt_demo_helpers.c index 7e35306f4a1..77520b9c545 100644 --- a/FreeRTOS-Plus/Demo/AWS/Mqtt_Demo_Helpers/mqtt_demo_helpers.c +++ b/FreeRTOS-Plus/Demo/AWS/Mqtt_Demo_Helpers/mqtt_demo_helpers.c @@ -801,7 +801,7 @@ BaseType_t xEstablishMqttSession( MQTTContext_t * pxMqttContext, } } - if( xReturnStatus == pdFAIL ) + if( xReturnStatus != pdFAIL ) { /* Keep a flag for indicating if MQTT session is established. This * flag will mark that an MQTT DISCONNECT has to be sent at the end diff --git a/FreeRTOS-Plus/Demo/AWS/Mqtt_Demo_Helpers/mqtt_pkcs11_demo_helpers.c b/FreeRTOS-Plus/Demo/AWS/Mqtt_Demo_Helpers/mqtt_pkcs11_demo_helpers.c index 8d4d8b0a75f..e284a5df028 100644 --- a/FreeRTOS-Plus/Demo/AWS/Mqtt_Demo_Helpers/mqtt_pkcs11_demo_helpers.c +++ b/FreeRTOS-Plus/Demo/AWS/Mqtt_Demo_Helpers/mqtt_pkcs11_demo_helpers.c @@ -359,6 +359,10 @@ static MQTTStatus_t prvProcessLoopWithTimeout( MQTTContext_t * pMqttContext, /*-----------------------------------------------------------*/ +extern UBaseType_t uxRand( void ); + +/*-----------------------------------------------------------*/ + static int32_t prvGenerateRandomNumber() { return( uxRand() & INT32_MAX ); @@ -794,7 +798,7 @@ BaseType_t xEstablishMqttSession( MQTTContext_t * pxMqttContext, } } - if( xReturnStatus == pdFAIL ) + if( xReturnStatus != pdFAIL ) { /* Keep a flag for indicating if MQTT session is established. This * flag will mark that an MQTT DISCONNECT has to be sent at the end diff --git a/FreeRTOS-Plus/Demo/Common/Logging/windows/Logging_WinSim.c b/FreeRTOS-Plus/Demo/Common/Logging/windows/Logging_WinSim.c index 0313b1c0aee..c2e2881ccd1 100644 --- a/FreeRTOS-Plus/Demo/Common/Logging/windows/Logging_WinSim.c +++ b/FreeRTOS-Plus/Demo/Common/Logging/windows/Logging_WinSim.c @@ -397,7 +397,7 @@ void vLoggingPrintf( const char * pcFormat, pcTarget--; } - sscanf( pcTarget, "%8X", &ulIPAddress ); + ( void ) sscanf( pcTarget, "%8X", &ulIPAddress ); rc = sprintf( pcTarget, "%lu.%lu.%lu.%lu", ( unsigned long ) ( ulIPAddress >> 24UL ), ( unsigned long ) ( ( ulIPAddress >> 16UL ) & 0xffUL ), @@ -601,7 +601,7 @@ static void prvLogToFile( const char * pcMessage, remove( pcFullLogFileName ); } - rename( pcLogFileName, pcFullLogFileName ); + ( void ) rename( pcLogFileName, pcFullLogFileName ); ulSizeOfLoggingFile = 0; } } diff --git a/FreeRTOS-Plus/Demo/Common/coreMQTT_Agent_Interface/freertos_command_pool.c b/FreeRTOS-Plus/Demo/Common/coreMQTT_Agent_Interface/freertos_command_pool.c index 153a18c4db2..ea4a69c0fe7 100644 --- a/FreeRTOS-Plus/Demo/Common/coreMQTT_Agent_Interface/freertos_command_pool.c +++ b/FreeRTOS-Plus/Demo/Common/coreMQTT_Agent_Interface/freertos_command_pool.c @@ -41,6 +41,9 @@ #include "freertos_command_pool.h" #include "freertos_agent_message.h" +/* Demo config include. */ +#include "demo_config.h" + /*-----------------------------------------------------------*/ #define QUEUE_NOT_INITIALIZED ( 0U ) diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/Common/comm_if_windows.c b/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/Common/comm_if_windows.c index 4412df1d9d9..f3f6b691c5e 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/Common/comm_if_windows.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/Common/comm_if_windows.c @@ -48,37 +48,23 @@ #ifndef CELLULAR_COMM_INTERFACE_PORT #error "Define CELLULAR_COMM_INTERFACE_PORT in cellular_config.h" #endif -#define CELLULAR_COMM_PATH "\\\\.\\"CELLULAR_COMM_INTERFACE_PORT +#define CELLULAR_COMM_PATH "\\\\.\\"CELLULAR_COMM_INTERFACE_PORT /* Define the simulated UART interrupt number. */ -#define portINTERRUPT_UART ( 2UL ) +#define appINTERRUPT_UART portINTERRUPT_APPLICATION_DEFINED_START /* Define the read write buffer size. */ -#define COMM_TX_BUFFER_SIZE ( 8192 ) -#define COMM_RX_BUFFER_SIZE ( 8192 ) +#define COMM_TX_BUFFER_SIZE ( 8192 ) +#define COMM_RX_BUFFER_SIZE ( 8192 ) /* Receive thread timeout in ms. */ -#define COMM_RECV_THREAD_TIMEOUT ( 5000 ) +#define COMM_RECV_THREAD_TIMEOUT ( 5000 ) /* Write operation timeout in ms. */ -#define COMM_WRITE_OPERATION_TIMEOUT ( 500 ) +#define COMM_WRITE_OPERATION_TIMEOUT ( 500 ) /* Comm status. */ -#define CELLULAR_COMM_OPEN_BIT ( 0x01U ) - -/* Comm task event. */ -#define COMMTASK_EVT_MASK_STARTED ( 0x0001UL ) -#define COMMTASK_EVT_MASK_ABORT ( 0x0002UL ) -#define COMMTASK_EVT_MASK_ABORTED ( 0x0004UL ) -#define COMMTASK_EVT_MASK_ALL_EVENTS \ - ( COMMTASK_EVT_MASK_STARTED \ - | COMMTASK_EVT_MASK_ABORT \ - | COMMTASK_EVT_MASK_ABORTED ) -#define COMMTASK_POLLING_TIME_MS ( 1UL ) - -/* Platform thread stack size and priority. */ -#define COMM_IF_THREAD_DEFAULT_STACK_SIZE ( 2048U ) -#define COMM_IF_THREAD_DEFAULT_PRIORITY ( tskIDLE_PRIORITY + 5U ) +#define CELLULAR_COMM_OPEN_BIT ( 0x01U ) /*-----------------------------------------------------------*/ @@ -91,7 +77,6 @@ typedef struct cellularCommContext HANDLE commFileHandle; CellularCommInterface_t * pCommInterface; bool commTaskThreadStarted; - EventGroupHandle_t pCommTaskEvent; } cellularCommContext_t; /*-----------------------------------------------------------*/ @@ -126,14 +111,6 @@ static CellularCommInterfaceError_t prvCommIntfReceive( CellularCommInterfaceHan */ static CellularCommInterfaceError_t prvCommIntfClose( CellularCommInterfaceHandle_t commInterfaceHandle ); -/** - * @brief Get default comm interface context. - * - * @return On success, SOCKETS_ERROR_NONE is returned. If an error occurred, error code defined - * in sockets_wrapper.h is returned. - */ -static cellularCommContext_t * prvGetCellularCommContext( void ); - /** * @brief UART interrupt handler. * @@ -168,34 +145,7 @@ static CellularCommInterfaceError_t prvSetupCommTimeout( HANDLE hComm ); * @return On success, IOT_COMM_INTERFACE_SUCCESS is returned. If an error occurred, error code defined * in CellularCommInterfaceError_t is returned. */ -static CellularCommInterfaceError_t prvSetupCommSettings( HANDLE hComm ); - -/** - * @brief Thread routine to generate simulated interrupt. - * - * @param[in] pUserData Pointer to cellularCommContext_t allocated in comm interface open. - */ -static void prvCommTaskThread( void * pUserData ); - -/** - * @brief Helper function to setup and create commTaskThread. - * - * @param[in] pCellularCommContext Cellular comm interface context allocated in open. - * - * @return On success, IOT_COMM_INTERFACE_SUCCESS is returned. If an error occurred, error code defined - * in CellularCommInterfaceError_t is returned. - */ -static CellularCommInterfaceError_t prvSetupCommTaskThread( cellularCommContext_t * pCellularCommContext ); - -/** - * @brief Helper function to clean commTaskThread. - * - * @param[in] pCellularCommContext Cellular comm interface context allocated in open. - * - * @return On success, IOT_COMM_INTERFACE_SUCCESS is returned. If an error occurred, error code defined - * in CellularCommInterfaceError_t is returned. - */ -static CellularCommInterfaceError_t prvCleanCommTaskThread( cellularCommContext_t * pCellularCommContext ); +static CellularCommInterfaceError_t prvSetupCommState( HANDLE hComm ); /*-----------------------------------------------------------*/ @@ -215,28 +165,14 @@ static cellularCommContext_t uxCellularCommContext = .commFileHandle = NULL, .pUserData = NULL, .commStatus = 0U, - .commTaskThreadStarted = false, - .pCommTaskEvent = NULL + .commTaskThreadStarted = false }; -/* Mutex used to protect rxEvent variables that are accessed by multiple threads. */ -static void * pvRxEventMutex = NULL; - -/* Indicate RX event is received in comm driver. */ -static bool rxEvent = false; - -/*-----------------------------------------------------------*/ - -static cellularCommContext_t * prvGetCellularCommContext( void ) -{ - return &uxCellularCommContext; -} - /*-----------------------------------------------------------*/ static uint32_t prvProcessUartInt( void ) { - cellularCommContext_t * pCellularCommContext = prvGetCellularCommContext(); + cellularCommContext_t * pCellularCommContext = &uxCellularCommContext; CellularCommInterfaceError_t callbackRet = IOT_COMM_INTERFACE_FAILURE; uint32_t retUartInt = pdTRUE; @@ -271,35 +207,35 @@ static DWORD WINAPI prvCellularCommReceiveCBThreadFunc( LPVOID pArgument ) { retValue = ERROR_INVALID_HANDLE; } - - while( retValue == 0 ) + else { - retWait = WaitCommEvent( hComm, &dwCommStatus, NULL ); - - if( ( retWait != FALSE ) && ( ( dwCommStatus & EV_RXCHAR ) != 0 ) ) - { - if( ( dwCommStatus & EV_RXCHAR ) != 0 ) - { - WaitForSingleObject( pvRxEventMutex, INFINITE ); - rxEvent = true; - ReleaseMutex( pvRxEventMutex ); - } - } - else + for( ; ; ) { - if( ( GetLastError() == ERROR_INVALID_HANDLE ) || ( GetLastError() == ERROR_OPERATION_ABORTED ) ) + retWait = WaitCommEvent( hComm, &dwCommStatus, NULL ); + + if( ( retWait != FALSE ) && ( ( dwCommStatus & EV_RXCHAR ) != 0 ) ) { - /* COM port closed. */ - LogInfo( ( "Cellular COM port %p closed", hComm ) ); + /* Generate a simulated interrupt when data is received in the input buffer in driver. + * The interrupt handler prvProcessUartInt() will be called in prvProcessSimulatedInterrupts(). + * This ensures no other task or ISR is running. */ + vPortGenerateSimulatedInterruptFromWindowsThread( appINTERRUPT_UART ); } else { - LogInfo( ( "Cellular receiver thread wait comm error %p %d", hComm, GetLastError() ) ); - } + retValue = GetLastError(); - retValue = GetLastError(); + if( ( retValue == ERROR_INVALID_HANDLE ) || ( retValue == ERROR_OPERATION_ABORTED ) ) + { + /* COM port closed. */ + LogInfo( ( "Cellular COM port %p closed", hComm ) ); + } + else + { + LogInfo( ( "Cellular receiver thread wait comm error %p %d", hComm, retValue ) ); + } - break; + break; + } } } @@ -335,7 +271,7 @@ static CellularCommInterfaceError_t prvSetupCommTimeout( HANDLE hComm ) /*-----------------------------------------------------------*/ -static CellularCommInterfaceError_t prvSetupCommSettings( HANDLE hComm ) +static CellularCommInterfaceError_t prvSetupCommState( HANDLE hComm ) { CellularCommInterfaceError_t commIntRet = IOT_COMM_INTERFACE_SUCCESS; DCB dcbSerialParams = { 0 }; @@ -367,146 +303,6 @@ static CellularCommInterfaceError_t prvSetupCommSettings( HANDLE hComm ) /*-----------------------------------------------------------*/ -static void prvCommTaskThread( void * pUserData ) -{ - cellularCommContext_t * pCellularCommContext = ( cellularCommContext_t * ) pUserData; - EventBits_t uxBits = 0; - - /* Inform thread ready. */ - LogInfo( ( "Cellular commTaskThread started" ) ); - - if( pCellularCommContext != NULL ) - { - ( void ) xEventGroupSetBits( pCellularCommContext->pCommTaskEvent, - COMMTASK_EVT_MASK_STARTED ); - } - - while( true ) - { - /* Wait for notification from eventqueue. */ - uxBits = xEventGroupWaitBits( ( pCellularCommContext->pCommTaskEvent ), - ( ( EventBits_t ) COMMTASK_EVT_MASK_ABORT ), - pdTRUE, - pdFALSE, - pdMS_TO_TICKS( COMMTASK_POLLING_TIME_MS ) ); - - if( ( uxBits & ( EventBits_t ) COMMTASK_EVT_MASK_ABORT ) != 0U ) - { - LogDebug( ( "Abort received, cleaning up!" ) ); - break; - } - else - { - /* Polling the global share variable to trigger the interrupt. */ - if( rxEvent == true ) - { - WaitForSingleObject( pvRxEventMutex, INFINITE ); - rxEvent = false; - ReleaseMutex( pvRxEventMutex ); - - vPortGenerateSimulatedInterrupt( portINTERRUPT_UART ); - } - } - } - - /* Inform thread ready. */ - if( pCellularCommContext != NULL ) - { - ( void ) xEventGroupSetBits( pCellularCommContext->pCommTaskEvent, COMMTASK_EVT_MASK_ABORTED ); - } - - LogInfo( ( "Cellular commTaskThread exit" ) ); -} - -/*-----------------------------------------------------------*/ - -static CellularCommInterfaceError_t prvSetupCommTaskThread( cellularCommContext_t * pCellularCommContext ) -{ - BOOL Status = TRUE; - EventBits_t uxBits = 0; - CellularCommInterfaceError_t commIntRet = IOT_COMM_INTERFACE_SUCCESS; - - pCellularCommContext->pCommTaskEvent = xEventGroupCreate(); - - if( pCellularCommContext->pCommTaskEvent != NULL ) - { - /* Create the FreeRTOS thread to generate the simulated interrupt. */ - Status = Platform_CreateDetachedThread( prvCommTaskThread, - ( void * ) pCellularCommContext, - COMM_IF_THREAD_DEFAULT_PRIORITY, - COMM_IF_THREAD_DEFAULT_STACK_SIZE ); - - if( Status != true ) - { - commIntRet = IOT_COMM_INTERFACE_FAILURE; - } - } - else - { - commIntRet = IOT_COMM_INTERFACE_FAILURE; - } - - if( commIntRet == IOT_COMM_INTERFACE_SUCCESS ) - { - uxBits = xEventGroupWaitBits( ( pCellularCommContext->pCommTaskEvent ), - ( ( EventBits_t ) COMMTASK_EVT_MASK_STARTED | ( EventBits_t ) COMMTASK_EVT_MASK_ABORTED ), - pdTRUE, - pdFALSE, - portMAX_DELAY ); - - if( ( uxBits & ( EventBits_t ) COMMTASK_EVT_MASK_STARTED ) == COMMTASK_EVT_MASK_STARTED ) - { - pCellularCommContext->commTaskThreadStarted = true; - } - else - { - commIntRet = IOT_COMM_INTERFACE_FAILURE; - pCellularCommContext->commTaskThreadStarted = false; - } - } - - return commIntRet; -} - -/*-----------------------------------------------------------*/ - -static CellularCommInterfaceError_t prvCleanCommTaskThread( cellularCommContext_t * pCellularCommContext ) -{ - EventBits_t uxBits = 0; - CellularCommInterfaceError_t commIntRet = IOT_COMM_INTERFACE_SUCCESS; - - /* Wait for the commTaskThreadStarted exit. */ - if( ( pCellularCommContext->commTaskThreadStarted == true ) && ( pCellularCommContext->pCommTaskEvent != NULL ) ) - { - ( void ) xEventGroupSetBits( pCellularCommContext->pCommTaskEvent, - COMMTASK_EVT_MASK_ABORT ); - uxBits = xEventGroupWaitBits( ( pCellularCommContext->pCommTaskEvent ), - ( ( EventBits_t ) COMMTASK_EVT_MASK_ABORTED ), - pdTRUE, - pdFALSE, - portMAX_DELAY ); - - if( ( uxBits & ( EventBits_t ) COMMTASK_EVT_MASK_ABORTED ) != COMMTASK_EVT_MASK_ABORTED ) - { - LogDebug( ( "Cellular close wait commTaskThread fail" ) ); - commIntRet = IOT_COMM_INTERFACE_FAILURE; - } - - pCellularCommContext->commTaskThreadStarted = false; - } - - /* Clean the event group. */ - if( pCellularCommContext->pCommTaskEvent != NULL ) - { - vEventGroupDelete( pCellularCommContext->pCommTaskEvent ); - pCellularCommContext->pCommTaskEvent = NULL; - } - - return commIntRet; -} - -/*-----------------------------------------------------------*/ - static CellularCommInterfaceError_t prvCommIntfOpen( CellularCommInterfaceReceiveCallback_t receiveCallback, void * pUserData, CellularCommInterfaceHandle_t * pCommInterfaceHandle ) @@ -514,7 +310,7 @@ static CellularCommInterfaceError_t prvCommIntfOpen( CellularCommInterfaceReceiv CellularCommInterfaceError_t commIntRet = IOT_COMM_INTERFACE_SUCCESS; HANDLE hComm = ( HANDLE ) INVALID_HANDLE_VALUE; BOOL Status = TRUE; - cellularCommContext_t * pCellularCommContext = prvGetCellularCommContext(); + cellularCommContext_t * pCellularCommContext = &uxCellularCommContext; DWORD dwRes = 0; if( pCellularCommContext == NULL ) @@ -543,7 +339,7 @@ static CellularCommInterfaceError_t prvCommIntfOpen( CellularCommInterfaceReceiv } /* Comm port is just closed. Wait 1 second and retry. */ - if( ( hComm == ( HANDLE ) INVALID_HANDLE_VALUE ) && ( GetLastError() == 5 ) ) + if( ( hComm == ( HANDLE ) INVALID_HANDLE_VALUE ) && ( GetLastError() == ERROR_ACCESS_DENIED ) ) { vTaskDelay( pdMS_TO_TICKS( 1000UL ) ); hComm = CreateFile( TEXT( CELLULAR_COMM_PATH ), @@ -578,7 +374,7 @@ static CellularCommInterfaceError_t prvCommIntfOpen( CellularCommInterfaceReceiv if( commIntRet == IOT_COMM_INTERFACE_SUCCESS ) { - commIntRet = prvSetupCommSettings( hComm ); + commIntRet = prvSetupCommState( hComm ); } if( commIntRet == IOT_COMM_INTERFACE_SUCCESS ) @@ -592,26 +388,11 @@ static CellularCommInterfaceError_t prvCommIntfOpen( CellularCommInterfaceReceiv } } - /* Create RX event mutex to protect rxEvent. */ - if( commIntRet == IOT_COMM_INTERFACE_SUCCESS ) - { - pvRxEventMutex = CreateMutex( NULL, FALSE, NULL ); - - if( pvRxEventMutex == NULL ) - { - commIntRet = IOT_COMM_INTERFACE_FAILURE; - } - } - if( commIntRet == IOT_COMM_INTERFACE_SUCCESS ) { pCellularCommContext->commReceiveCallback = receiveCallback; - commIntRet = prvSetupCommTaskThread( pCellularCommContext ); - } - if( commIntRet == IOT_COMM_INTERFACE_SUCCESS ) - { - vPortSetInterruptHandler( portINTERRUPT_UART, prvProcessUartInt ); + vPortSetInterruptHandler( appINTERRUPT_UART, prvProcessUartInt ); pCellularCommContext->commReceiveCallbackThread = CreateThread( NULL, 0, prvCellularCommReceiveCBThreadFunc, hComm, 0, NULL ); @@ -653,16 +434,6 @@ static CellularCommInterfaceError_t prvCommIntfOpen( CellularCommInterfaceReceiv } pCellularCommContext->commReceiveCallbackThread = NULL; - - /* Wait for the commTaskThreadStarted exit. */ - ( void ) prvCleanCommTaskThread( pCellularCommContext ); - - /* Clean the rxEvent mutex. */ - if( pvRxEventMutex != NULL ) - { - CloseHandle( pvRxEventMutex ); - pvRxEventMutex = NULL; - } } return commIntRet; @@ -731,16 +502,6 @@ static CellularCommInterfaceError_t prvCommIntfClose( CellularCommInterfaceHandl pCellularCommContext->commReceiveCallbackThread = NULL; - /* Clean the commTaskThread. */ - ( void ) prvCleanCommTaskThread( pCellularCommContext ); - - /* Clean the rxEvent mutex. */ - if( pvRxEventMutex != NULL ) - { - CloseHandle( pvRxEventMutex ); - pvRxEventMutex = NULL; - } - /* clean the data structure. */ pCellularCommContext->commStatus &= ~( CELLULAR_COMM_OPEN_BIT ); } diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/FreeRTOSConfig.h b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/FreeRTOSConfig.h index 371b5f8dc1a..c30c781ffdc 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/FreeRTOSConfig.h +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/FreeRTOSConfig.h @@ -57,11 +57,8 @@ extern void vAssertCalled( void ); #define configUSE_16_BIT_TICKS 0 #define configIDLE_SHOULD_YIELD 0 #define configMAX_PRIORITIES ( 10 ) -#define configTIMER_QUEUE_LENGTH 20 -#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 3 ) #define configUSE_COUNTING_SEMAPHORES 1 #define configSUPPORT_DYNAMIC_ALLOCATION 1 -#define configNUM_TX_DESCRIPTORS 15 /* Set the following definitions to 1 to include the API function, or zero * to exclude the API function. */ @@ -74,7 +71,7 @@ extern void vAssertCalled( void ); #define INCLUDE_vTaskDelete 0 #define INCLUDE_vTaskCleanUpResources 0 #define INCLUDE_vTaskSuspend 0 -#define INCLUDE_vTaskDelayUntil 1 +#define INCLUDE_vTaskDelayUntil 0 #define INCLUDE_vTaskDelay 1 @@ -89,7 +86,6 @@ extern void vAssertCalled( void ); /* networking definitions */ #define configMAC_ISR_SIMULATOR_PRIORITY ( configMAX_PRIORITIES - 2 ) #define ipconfigUSE_NETWORK_EVENT_HOOK 1 -/*#define ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME pdMS_TO_TICKS(5000) */ #define configNETWORK_INTERFACE_TO_USE 1L /* The address of an echo server that will be used by the two demo echo client @@ -115,16 +111,16 @@ extern void vAssertCalled( void ); #define configMAC_ADDR4 0x34 #define configMAC_ADDR5 0xAD -/* Default IP address configuration. Used in ipconfigUSE_DNS is set to 0, or - * ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */ +/* Default IP address configuration. Used if ipconfigUSE_DHCP is set to 0, or + * ipconfigUSE_DHCP is set to 1 but a DHCP server cannot be contacted. */ #define configIP_ADDR0 10 #define configIP_ADDR1 211 #define configIP_ADDR2 55 #define configIP_ADDR3 5 -/* Default gateway IP address configuration. Used in ipconfigUSE_DNS is set to - * 0, or ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */ +/* Default gateway IP address configuration. Used if ipconfigUSE_DHCP is set to + * 0, or ipconfigUSE_DHCP is set to 1 but a DHCP server cannot be contacted. */ #define configGATEWAY_ADDR0 10 #define configGATEWAY_ADDR1 211 @@ -132,16 +128,16 @@ extern void vAssertCalled( void ); #define configGATEWAY_ADDR3 1 /* Default DNS server configuration. OpenDNS addresses are 208.67.222.222 and - * 208.67.220.220. Used in ipconfigUSE_DNS is set to 0, or ipconfigUSE_DNS is set - * to 1 but a DNS server cannot be contacted.*/ + * 208.67.220.220. Used if ipconfigUSE_DHCP is set to 0, or ipconfigUSE_DHCP is set + * to 1 but a DHCP server cannot be contacted.*/ #define configDNS_SERVER_ADDR0 127 #define configDNS_SERVER_ADDR1 0 #define configDNS_SERVER_ADDR2 0 #define configDNS_SERVER_ADDR3 53 -/* Default netmask configuration. Used in ipconfigUSE_DNS is set to 0, or - * ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */ +/* Default netmask configuration. Used if ipconfigUSE_DHCP is set to 0, or + * ipconfigUSE_DHCP is set to 1 but a DHCP server cannot be contacted. */ #define configNET_MASK0 255 #define configNET_MASK1 255 #define configNET_MASK2 255 diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/Makefile b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/Makefile index fdfe7c74103..eb248d9a51a 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/Makefile +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/Makefile @@ -1,4 +1,5 @@ CC = arm-none-eabi-gcc +SIZE = arm-none-eabi-size BIN := freertos_tcp_mps2_demo.axf BUILD_DIR := build @@ -29,7 +30,6 @@ INCLUDE_DIRS += -I$(KERNEL_DIR)/include SOURCE_FILES += $(KERNEL_DIR)/tasks.c SOURCE_FILES += $(KERNEL_DIR)/list.c SOURCE_FILES += $(KERNEL_DIR)/queue.c -SOURCE_FILES += $(KERNEL_DIR)/timers.c SOURCE_FILES += $(KERNEL_DIR)/event_groups.c # FreeRTOS Kernel ARM Cortex-M3 Port @@ -51,30 +51,33 @@ SOURCE_FILES += ${FREERTOS_TCP}/source/portable/BufferManagement/BufferAllocatio SOURCE_FILES += ${FREERTOS_TCP}/source/portable/NetworkInterface/MPS2_AN385/NetworkInterface.c SOURCE_FILES += ${FREERTOS_TCP}/source/portable/NetworkInterface/MPS2_AN385/ether_lan9118/smsc9220_eth_drv.c -DEFINES := -DQEMU_SOC_MPS2 -DHEAP3 - -LDFLAGS = -T mps2_m3.ld -specs=nano.specs --specs=rdimon.specs -lc -lrdimon -LDFLAGS += -Xlinker -Map=${BUILD_DIR}/output.map - -CFLAGS += -nostartfiles -mthumb -mcpu=cortex-m3 -Wno-error=implicit-function-declaration -CFLAGS += -Wno-builtin-declaration-mismatch -Werror +DEFINES := -DHEAP3 +CPPFLAGS += $(DEFINES) +CFLAGS += -mthumb -mcpu=cortex-m3 ifeq ($(DEBUG), 1) - CFLAGS += -ggdb3 -Og + CFLAGS += -g3 -Og -ffunction-sections -fdata-sections else - CFLAGS += -O3 + CFLAGS += -Os -ffunction-sections -fdata-sections endif - CFLAGS += -fstrict-aliasing -Wstrict-aliasing -Wno-error=address-of-packed-member +CFLAGS += -MMD +CFLAGS += -Wall -Wextra -Wshadow +#CFLAGS += -Wpedantic -fanalyzer +#CFLAGS += -flto +CFLAGS += $(INCLUDE_DIRS) -OBJ_FILES := $(SOURCE_FILES:%.c=$(BUILD_DIR)/%.o) +LDFLAGS = -T mps2_m3.ld +LDFLAGS += -Xlinker -Map=${BUILD_DIR}/output.map +LDFLAGS += -Xlinker --gc-sections +LDFLAGS += -nostartfiles -specs=nano.specs -specs=nosys.specs -specs=rdimon.specs -CPPFLAGS += $(DEFINES) -CFLAGS += $(INCLUDE_DIRS) +OBJ_FILES := $(SOURCE_FILES:%.c=$(BUILD_DIR)/%.o) .PHONY: clean $(BUILD_DIR)/$(BIN) : $(OBJ_FILES) - $(CC) -ffunction-sections -fdata-sections $(CFLAGS) $(LDFLAGS) $+ -o $(@) + $(CC) $(CFLAGS) $(LDFLAGS) $+ -o $(@) + $(SIZE) $(@) %.d: %.c @set -e; rm -f $@; \ @@ -87,7 +90,7 @@ INCLUDES := $(SOURCE_FILES:%.c=$(BUILD_DIR)/%.d) ${BUILD_DIR}/%.o : %.c Makefile -mkdir -p $(@D) - $(CC) $(CPPFLAGS) $(CFLAGS) -MMD -c $< -o $@ + $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ clean: -rm -rf build diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/TCPEchoClient_SingleTasks.c b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/TCPEchoClient_SingleTasks.c index 41b9ed09332..477ba4c1c07 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/TCPEchoClient_SingleTasks.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/TCPEchoClient_SingleTasks.c @@ -206,10 +206,10 @@ lStringLength = prvCreateTxData( pcTransmittedString, echoBUFFER_SIZES ); /* Add in some unique text at the front of the string. */ - sprintf( pcTransmittedString, "TxRx message number %u", ulTxCount ); + sprintf( pcTransmittedString, "TxRx message number %lu", ulTxCount ); ulTxCount++; - printf( "sending data to the echo server size %d original %d\n", + printf( "sending data to the echo server size %ld original %d\n", lStringLength, echoBUFFER_SIZES ); /* Send the string to the socket. */ @@ -217,7 +217,7 @@ ( void * ) pcTransmittedString, /* The data being sent. */ lStringLength, /* The length of the data being sent. */ 0 ); /* No flags. */ - printf( "FreeRTOS_send returned...transmitted %d\n", + printf( "FreeRTOS_send returned...transmitted %ld\n", lTransmitted ); if( lTransmitted < 0 ) @@ -398,15 +398,24 @@ #if ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 ) eDHCPCallbackAnswer_t xApplicationDHCPHook( eDHCPCallbackPhase_t eDHCPPhase, uint32_t ulIPAddress ) + { + ( void ) eDHCPPhase; + ( void ) ulIPAddress; + + return eDHCPContinue; + } #else /* ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 ) */ eDHCPCallbackAnswer_t xApplicationDHCPHook_Multi( eDHCPCallbackPhase_t eDHCPPhase, struct xNetworkEndPoint * pxEndPoint, IP_Address_t * pxIPAddress ) + { + ( void ) eDHCPPhase; + ( void ) pxEndPoint; + ( void ) pxIPAddress; + + return eDHCPContinue; + } #endif /* ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 ) */ - { - /* Provide a stub for this function. */ - return eDHCPContinue; - } #endif /* if ( ipconfigUSE_DHCP_HOOK != 0 )*/ diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/main.c b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/main.c index cb17a6bf47c..ec5f5650c85 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/main.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/main.c @@ -40,9 +40,7 @@ void main_tcp_echo_client_tasks( void ); void vApplicationIdleHook( void ); void vApplicationTickHook( void ); -extern void initialise_monitor_handles( void ); - -int main() +int main( void ) { main_tcp_echo_client_tasks(); return 0; @@ -84,8 +82,6 @@ void vApplicationStackOverflowHook( TaskHandle_t pxTask, void vApplicationIdleHook( void ) { - volatile size_t xFreeHeapSpace; - /* This is just a trivial example of an idle hook. It is called on each * cycle of the idle task. It must *NOT* attempt to block. In this case the * idle task just queries the amount of FreeRTOS heap that remains. See the diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/main_networking.c b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/main_networking.c index 5af2c81b20e..60e5ca36402 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/main_networking.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/main_networking.c @@ -180,8 +180,6 @@ void main_tcp_echo_client_tasks( void ) } #endif /* ( ipconfigUSE_DHCP != 0 ) */ - memcpy( ipLOCAL_MAC_ADDRESS, ucMACAddress, sizeof( ucMACAddress ) ); - FreeRTOS_IPInit_Multi(); #else /* if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 ) */ /* Using the old /single /IPv4 library, or using backward compatible mode of the new /multi library. */ @@ -224,6 +222,10 @@ BaseType_t xTasksAlreadyCreated = pdFALSE; uint32_t ulDNSServerAddress; char cBuffer[ 16 ]; + #if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 ) + ( void ) pxEndPoint; + #endif /* defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 ) */ + /* If the network has just come up...*/ if( eNetworkEvent == eNetworkUp ) { @@ -335,6 +337,10 @@ static void prvMiscInitialisation( void ) { BaseType_t xReturn; + #if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 ) + ( void ) pxEndPoint; + #endif /* defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 ) */ + /* Determine if a name lookup is for this node. Two names are given * to this node: that returned by pcApplicationHostnameHook() and that set * by mainDEVICE_NICK_NAME. */ diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/mps2_m3.ld b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/mps2_m3.ld index 13b1a3d79f0..97089f3c4aa 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/mps2_m3.ld +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/mps2_m3.ld @@ -128,7 +128,7 @@ SECTIONS _heap_top = .; . = . + _Min_Stack_Size; . = ALIGN(8); - } >RAM + } >RAM /* Set stack top to end of RAM, and stack limit move down by * size of stack_dummy section */ diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/startup.c b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/startup.c index 3dcec37f443..72a269c07eb 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/startup.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/startup.c @@ -28,15 +28,14 @@ #include #include #include -#include "CMSIS/CMSDK_CM3.h" -#include "CMSIS/core_cm3.h" extern void vPortSVCHandler( void ); extern void xPortPendSVHandler( void ); extern void xPortSysTickHandler( void ); -extern void uart_init(); -extern int main(); +extern void uart_init( void ); +extern int main( void ); +void _start( void ); void __attribute__( ( weak ) ) EthernetISR( void ); extern uint32_t _estack, _sidata, _sdata, _edata, _sbss, _ebss; @@ -63,7 +62,6 @@ void Reset_Handler( void ) } /* jump to board initialisation */ - void _start( void ); _start(); } @@ -96,6 +94,16 @@ void prvGetRegistersFromStack( uint32_t * pulFaultStackAddress ) for( ; ; ) { } + + /* Remove the warning about unused variables. */ + ( void ) r0; + ( void ) r1; + ( void ) r2; + ( void ) r3; + ( void ) r12; + ( void ) lr; + ( void ) pc; + ( void ) psr; } static void Default_Handler( void ) __attribute__( ( naked ) ); @@ -114,7 +122,8 @@ void Default_Handler( void ) "NVIC_INT_CTRL_CONST: .word 0xe000ed04\n" ); } -static void HardFault_Handler( void ) __attribute__( ( naked ) ); + +static void Default_Handler2( void ) __attribute__( ( naked ) ); void Default_Handler2( void ) { __asm volatile @@ -158,7 +167,7 @@ void Default_Handler6( void ) } } -const uint32_t * isr_vector[] __attribute__( ( section( ".isr_vector" ) ) ) = +const uint32_t * const isr_vector[] __attribute__( ( section( ".isr_vector" ) ) ) = { ( uint32_t * ) &_estack, ( uint32_t * ) &Reset_Handler, /* Reset -15 */ @@ -195,7 +204,7 @@ const uint32_t * isr_vector[] __attribute__( ( section( ".isr_vector" ) ) ) = void _start( void ) { uart_init(); - main( 0, 0 ); + main(); exit( 0 ); } @@ -212,4 +221,6 @@ __attribute__( ( naked ) ) void exit( int status ) "bkpt 0xab\n" "end: b end\n" ); + + ( void ) status; } diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/syscalls.c b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/syscalls.c index bfa97f3b8e8..6e5425db004 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/syscalls.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/syscalls.c @@ -38,24 +38,21 @@ typedef struct UART_t volatile uint32_t BAUDDIV; } UART_t; -#define UART0_ADDR ( ( UART_t * ) ( 0x40004000 ) ) +#define UART0_ADDR ( ( UART_t * ) ( 0x40004000 ) ) #define UART_DR( baseaddr ) ( *( unsigned int * ) ( baseaddr ) ) -#define UART_STATE_TXFULL ( 1 << 0 ) -#define UART_CTRL_TX_EN ( 1 << 0 ) -#define UART_CTRL_RX_EN ( 1 << 1 ) +#define UART_CTRL_TX_EN ( 1 << 0 ) extern unsigned long _heap_bottom; extern unsigned long _heap_top; -extern unsigned long g_ulBase; -static void * heap_end = 0; +static char * heap_end = ( char * ) &_heap_bottom; /** * @brief initializes the UART emulated hardware */ -void uart_init() +void uart_init( void ) { UART0_ADDR->BAUDDIV = 16; UART0_ADDR->CTRL = UART_CTRL_TX_EN; @@ -68,6 +65,7 @@ void uart_init() */ int _fstat( int file ) { + ( void ) file; return 0; } @@ -80,6 +78,9 @@ int _read( int file, char * buf, int len ) { + ( void ) file; + ( void ) buf; + ( void ) len; return -1; } @@ -97,6 +98,8 @@ int _write( int file, { int todo; + ( void ) file; + for( todo = 0; todo < len; todo++ ) { UART_DR( UART0_ADDR ) = *buf++; @@ -113,16 +116,9 @@ int _write( int file, */ void * _sbrk( int incr ) { - char * prev_heap_end; - - if( heap_end == 0 ) - { - heap_end = ( void * ) &_heap_bottom; - } - - prev_heap_end = heap_end; + void * prev_heap_end = heap_end; - if( ( heap_end + incr ) > ( void * ) &_heap_top ) + if( ( heap_end + incr ) > ( char * ) &_heap_top ) { return ( void * ) -1; } diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator/main.c b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator/main.c index 126e7477696..3d4e285f1d6 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator/main.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator/main.c @@ -145,6 +145,7 @@ static UBaseType_t ulNextRand; int main( void ) { + BaseType_t xResult; const uint32_t ulLongTime_ms = pdMS_TO_TICKS( 1000UL ); /* @@ -185,14 +186,14 @@ int main( void ) } #endif /* ( ipconfigUSE_DHCP != 0 ) */ - memcpy( ipLOCAL_MAC_ADDRESS, ucMACAddress, sizeof( ucMACAddress ) ); - - FreeRTOS_IPInit_Multi(); + xResult = FreeRTOS_IPInit_Multi(); #else /* if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 ) */ /* Using the old /single /IPv4 library, or using backward compatible mode of the new /multi library. */ - FreeRTOS_IPInit( ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress ); + xResult = FreeRTOS_IPInit( ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress ); #endif /* defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 ) */ + configASSERT( xResult == pdTRUE ); + /* Start the RTOS scheduler. */ FreeRTOS_debug_printf( ( "vTaskStartScheduler\r\n" ) ); vTaskStartScheduler(); diff --git a/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_Mutual_Auth/DemoTasks/MutualAuthHTTPExample.c b/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_Mutual_Auth/DemoTasks/MutualAuthHTTPExample.c index eb652c3b954..9bd1f33ae89 100644 --- a/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_Mutual_Auth/DemoTasks/MutualAuthHTTPExample.c +++ b/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_Mutual_Auth/DemoTasks/MutualAuthHTTPExample.c @@ -200,6 +200,10 @@ static BaseType_t prvSendHttpRequest( const TransportInterface_t * pxTransportIn /*-----------------------------------------------------------*/ +extern BaseType_t xPlatformIsNetworkUp( void ); + +/*-----------------------------------------------------------*/ + /* * @brief Create the task that demonstrates the HTTP API Demo over a * mutually-authenticated network connection with an HTTP server. diff --git a/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_Plaintext/DemoTasks/PlainTextHTTPExample.c b/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_Plaintext/DemoTasks/PlainTextHTTPExample.c index 52914bcd65a..039375be0fd 100644 --- a/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_Plaintext/DemoTasks/PlainTextHTTPExample.c +++ b/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_Plaintext/DemoTasks/PlainTextHTTPExample.c @@ -260,6 +260,10 @@ static BaseType_t prvSendHttpRequest( const TransportInterface_t * pxTransportIn /*-----------------------------------------------------------*/ +extern BaseType_t xPlatformIsNetworkUp( void ); + +/*-----------------------------------------------------------*/ + /* * @brief Create the task that demonstrates the HTTP API Demo over a * mutually-authenticated network connection with an HTTP server. diff --git a/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_S3_Download_Multithreaded/DemoTasks/S3DownloadMultithreadedHTTPExample.c b/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_S3_Download_Multithreaded/DemoTasks/S3DownloadMultithreadedHTTPExample.c index cd8359627bd..e28bcc8a893 100644 --- a/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_S3_Download_Multithreaded/DemoTasks/S3DownloadMultithreadedHTTPExample.c +++ b/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_S3_Download_Multithreaded/DemoTasks/S3DownloadMultithreadedHTTPExample.c @@ -429,6 +429,10 @@ static BaseType_t prvDownloadLoop( void ); /*-----------------------------------------------------------*/ +extern BaseType_t xPlatformIsNetworkUp( void ); + +/*-----------------------------------------------------------*/ + /* * @brief Create task to demonstrate the HTTP API over a server-authenticated * network connection with a server. diff --git a/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_S3_Upload/DemoTasks/S3UploadHTTPExample.c b/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_S3_Upload/DemoTasks/S3UploadHTTPExample.c index e4a50471fc1..e1bbc408c76 100644 --- a/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_S3_Upload/DemoTasks/S3UploadHTTPExample.c +++ b/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_S3_Upload/DemoTasks/S3UploadHTTPExample.c @@ -295,6 +295,10 @@ static BaseType_t prvVerifyS3ObjectFileSize( const TransportInterface_t * pxTran /*-----------------------------------------------------------*/ +extern BaseType_t xPlatformIsNetworkUp( void ); + +/*-----------------------------------------------------------*/ + /* * @brief Create the task that demonstrates the HTTP API Demo over a * server-authenticated network connection with an HTTP server. diff --git a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Keep_Alive/DemoTasks/KeepAliveMQTTExample.c b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Keep_Alive/DemoTasks/KeepAliveMQTTExample.c index b89bb644d80..95aa751c516 100644 --- a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Keep_Alive/DemoTasks/KeepAliveMQTTExample.c +++ b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Keep_Alive/DemoTasks/KeepAliveMQTTExample.c @@ -71,6 +71,9 @@ /* Transport interface include. */ #include "transport_plaintext.h" +/* FreeRTOS+TCP IP config include. */ +#include "FreeRTOSIPConfig.h" + /*-----------------------------------------------------------*/ /* Compile time error for undefined configs. */ diff --git a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Multitask/demo_config.h b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Multitask/demo_config.h index 5debbd328ea..35bd51f57f1 100644 --- a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Multitask/demo_config.h +++ b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Multitask/demo_config.h @@ -293,4 +293,10 @@ extern void vLoggingPrintf( const char * pcFormatString, #define democonfigMQTT_LIB "core-mqtt@"MQTT_LIBRARY_VERSION #endif +/** + * @brief The number of command structures to allocate in the pool + * for the agent. + */ +#define MQTT_COMMAND_CONTEXTS_POOL_SIZE 10 + #endif /* DEMO_CONFIG_H */ diff --git a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Multitask/mqtt_broker_setup.txt b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Multitask/mqtt_broker_setup.txt index 5db8e918642..64f860654c8 100644 --- a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Multitask/mqtt_broker_setup.txt +++ b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Multitask/mqtt_broker_setup.txt @@ -4,7 +4,7 @@ TLS mutual authentication for use with this MQTT demo. a. Download and install [Git For Windows](https://git-scm.com/download/win). Most of you may already have this installed. Git For Windows provides an OpenSSL binary for generating certificates. - b. Open PowerShell and enter the following commands to generate TLS certificates: + b. Open PowerShell and enter the following commands to generate TLS certificates [Note: While creating the certificates make sure to not use same organization name for all the certificates to prevent "self-signed certificate" error.]: i. cd "C:\Program Files\Git\usr\bin" # If Git is installed elsewhere, update the path. ii. mkdir $home\Documents\certs iii. .\openssl.exe req -x509 -nodes -sha256 -days 365 -newkey rsa:2048 -keyout $home\Documents\certs\ca.key -out $home\Documents\certs\ca.crt @@ -13,16 +13,19 @@ TLS mutual authentication for use with this MQTT demo. vi. .\openssl.exe genrsa -out $home\Documents\certs\client.key 2048 vii. .\openssl.exe req -new -out $home\Documents\certs\client.csr -key $home\Documents\certs\client.key viii. .\openssl.exe x509 -req -in $home\Documents\certs\client.csr -CA $home\Documents\certs\ca.crt -CAkey $home\Documents\certs\ca.key -CAcreateserial -out $home\Documents\certs\client.crt -days 365 + ix. [Optional] .\openssl.exe verify -CAfile $home\Documents\certs\ca.crt $home\Documents\certs\server.crt # verify the server certificate is correctly signed + x. [Optional] .\openssl.exe verify -CAfile $home\Documents\certs\ca.crt $home\Documents\certs\client.crt # verify the client certificate is correctly signed 2. Download Mosquitto from https://mosquitto.org/download/ 3. Install Mosquitto as a Windows service by running the installer. 4. Go to the path where Mosquitto was installed. The default path is C:\Program Files\mosquitto. -5. Update mosquitto.conf to have the following entries and don't forget to substitute your Windows username: - port 8883 +5. Update mosquitto.conf to have the following entries and don't forget to substitute your Windows username [Mosquitto Version 2.0.0 onwards]: + listener 8883 cafile C:\Users\%Substitute Windows username%\Documents\certs\ca.crt certfile C:\Users\%Substitute Windows username%\Documents\certs\server.crt keyfile C:\Users\%Substitute Windows username%\Documents\certs\server.key require_certificate true tls_version tlsv1.2 + allow_anonymous true 6. Start the Mosquitto service. More details about running Mosquitto as a Windows service can be found at https://github.com/eclipse/mosquitto/blob/master/readme-windows.txt and diff --git a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Mutual_Auth_wolfSSL/user_settings.h b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Mutual_Auth_wolfSSL/user_settings.h index fc077b7a508..a95f37ed0cf 100644 --- a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Mutual_Auth_wolfSSL/user_settings.h +++ b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Mutual_Auth_wolfSSL/user_settings.h @@ -103,6 +103,8 @@ #define NO_MD4 #define NO_PWDBASED +#define WOLFSSL_ALT_CERT_CHAINS + /*-- Debugging options ------------------------------------------------------ * * "DEBUG_WOLFSSL" definition enables log to output into stdout. diff --git a/FreeRTOS-Plus/Demo/coreSNTP_Windows_Simulator/SNTPClientTask.c b/FreeRTOS-Plus/Demo/coreSNTP_Windows_Simulator/SNTPClientTask.c index 77a8ea09d88..17f8b528049 100644 --- a/FreeRTOS-Plus/Demo/coreSNTP_Windows_Simulator/SNTPClientTask.c +++ b/FreeRTOS-Plus/Demo/coreSNTP_Windows_Simulator/SNTPClientTask.c @@ -550,7 +550,7 @@ static void populateAuthContextForServer( const char * pServer, static SntpStatus_t addClientAuthCode( SntpAuthContext_t * pAuthContext, const SntpServerInfo_t * pTimeServer, void * pRequestBuffer, - uint16_t bufferSize, + size_t bufferSize, uint16_t * pAuthCodeSize ); @@ -586,7 +586,7 @@ static SntpStatus_t addClientAuthCode( SntpAuthContext_t * pAuthContext, static SntpStatus_t validateServerAuth( SntpAuthContext_t * pAuthContext, const SntpServerInfo_t * pTimeServer, const void * pResponseData, - size_t responseSize ); + uint16_t responseSize ); /** * @brief Generates a random number using PKCS#11. @@ -668,6 +668,7 @@ void calculateCurrentTime( UTCTime_t * pBaseTime, UTCTime_t * pCurrentTime ) { uint64_t msElapsedSinceLastSync = 0; + uint64_t currentTimeSecs; TickType_t ticksElapsedSinceLastSync = xTaskGetTickCount() - lastSyncTickCount; /* Calculate time elapsed since last synchronization according to the number @@ -686,13 +687,30 @@ void calculateCurrentTime( UTCTime_t * pBaseTime, /* Set the current UTC time in the output parameter. */ if( msElapsedSinceLastSync >= 1000 ) { - pCurrentTime->secs = pBaseTime->secs + msElapsedSinceLastSync / 1000; + currentTimeSecs = ( uint64_t ) ( pBaseTime->secs ) + ( msElapsedSinceLastSync / 1000 ); + + /* Support case of UTC timestamp rollover on 7 February 2038. */ + if( currentTimeSecs > UINT32_MAX ) + { + /* Assert when the UTC timestamp rollover. */ + configASSERT( !( currentTimeSecs > UINT32_MAX ) ); + + /* Subtract an extra second as timestamp 0 represents the epoch for + * UTC era 1. */ + LogWarn( ( "UTC timestamp rollover." ) ); + pCurrentTime->secs = ( uint32_t ) ( currentTimeSecs - UINT32_MAX - 1 ); + } + else + { + pCurrentTime->secs = ( uint32_t ) ( currentTimeSecs ); + } + pCurrentTime->msecs = msElapsedSinceLastSync % 1000; } else { pCurrentTime->secs = pBaseTime->secs; - pCurrentTime->msecs = msElapsedSinceLastSync; + pCurrentTime->msecs = ( uint32_t ) ( msElapsedSinceLastSync ); } } @@ -842,7 +860,7 @@ static int32_t UdpTransport_Recv( NetworkContext_t * pNetworkContext, static void sntpClient_GetTime( SntpTimestamp_t * pCurrentTime ) { UTCTime_t currentTime; - uint64_t ntpSecs; + uint32_t ntpSecs; /* Obtain mutex for accessing system clock variables */ xSemaphoreTake( xMutex, portMAX_DELAY ); @@ -862,8 +880,12 @@ static void sntpClient_GetTime( SntpTimestamp_t * pCurrentTime ) * converting from UNIX time to SNTP timestamp. */ if( ntpSecs > UINT32_MAX ) { + /* Assert when SNTP time rollover. */ + configASSERT( !( ntpSecs > UINT32_MAX ) ); + /* Subtract an extra second as timestamp 0 represents the epoch for * NTP era 1. */ + LogWarn( ( "SNTP timestamp rollover." ) ); pCurrentTime->seconds = ntpSecs - UINT32_MAX - 1; } else @@ -977,7 +999,7 @@ static void populateAuthContextForServer( const char * pServer, for( index = 0; index < strlen( pKeyHexString ); index += 2 ) { char byteString[ 3 ] = { pKeyHexString[ index ], pKeyHexString[ index + 1 ], '\0' }; - uint8_t byteVal = strtoul( byteString, NULL, 16 ); + uint8_t byteVal = ( uint8_t ) ( strtoul( byteString, NULL, 16 ) ); pAuthContext->pAuthKey[ index / 2 ] = byteVal; } } @@ -1014,7 +1036,7 @@ static CK_RV setupPkcs11ObjectForAesCmac( const SntpAuthContext_t * pAuthContext }; /* Update the attributes array with the key of AES-CMAC operation. */ - aes_cmac_template[ 6 ].pValue = pAuthContext->pAuthKey; + aes_cmac_template[ 6 ].pValue = ( uint8_t * ) ( pAuthContext->pAuthKey ); aes_cmac_template[ 6 ].ulValueLen = sizeof( pAuthContext->pAuthKey ); result = xInitializePkcs11Session( pPkcs11Session ); @@ -1056,7 +1078,7 @@ static CK_RV setupPkcs11ObjectForAesCmac( const SntpAuthContext_t * pAuthContext SntpStatus_t addClientAuthCode( SntpAuthContext_t * pAuthContext, const SntpServerInfo_t * pTimeServer, void * pRequestBuffer, - uint16_t bufferSize, + size_t bufferSize, uint16_t * pAuthCodeSize ) { CK_RV result = CKR_OK; @@ -1279,7 +1301,7 @@ static uint32_t generateRandomNumber() if( pkcs11Status == CKR_OK ) { if( pFunctionList->C_GenerateRandom( session, - &randomNum, + ( uint8_t * ) ( &randomNum ), sizeof( randomNum ) ) != CKR_OK ) { LogError( ( "Failed to generate random number. " @@ -1304,7 +1326,7 @@ static uint32_t generateRandomNumber() void initializeSystemClock( void ) { /* On boot-up initialize the system time as the first second in the configured year. */ - int64_t startupTimeInUnixSecs = translateYearToUnixSeconds( democonfigSYSTEM_START_YEAR ); + uint32_t startupTimeInUnixSecs = translateYearToUnixSeconds( democonfigSYSTEM_START_YEAR ); systemClock.baseTime.secs = startupTimeInUnixSecs; systemClock.baseTime.msecs = 0; @@ -1429,7 +1451,6 @@ static bool createUdpSocket( Socket_t * pSocket ) static void closeUdpSocket( Socket_t * pSocket ) { bool status = false; - struct freertos_sockaddr bindAddress; configASSERT( pSocket != NULL ); @@ -1455,7 +1476,7 @@ static bool calculateBackoffForNextPoll( BackoffAlgorithmContext_t * pBackoffCon if( shouldInitializeContext == true ) { /* Initialize reconnect attempts and interval.*/ - BackoffAlgorithm_InitializeParams( &pBackoffContext, + BackoffAlgorithm_InitializeParams( pBackoffContext, minPollPeriod, SNTP_DEMO_POLL_MAX_BACKOFF_DELAY_SEC, SNTP_DEMO_MAX_SERVER_BACKOFF_RETRIES ); @@ -1463,7 +1484,7 @@ static bool calculateBackoffForNextPoll( BackoffAlgorithmContext_t * pBackoffCon /* Generate a random number and calculate the new backoff poll period to wait before the next * time poll attempt. */ - status = BackoffAlgorithm_GetNextBackoff( &pBackoffContext, generateRandomNumber(), &newPollPeriod ); + status = BackoffAlgorithm_GetNextBackoff( pBackoffContext, generateRandomNumber(), &newPollPeriod ); if( status == BackoffAlgorithmRetriesExhausted ) { diff --git a/FreeRTOS-Plus/Source/Application-Protocols/network_transport/transport_wolfSSL.c b/FreeRTOS-Plus/Source/Application-Protocols/network_transport/transport_wolfSSL.c index 847dcf0382d..d5d70da1098 100644 --- a/FreeRTOS-Plus/Source/Application-Protocols/network_transport/transport_wolfSSL.c +++ b/FreeRTOS-Plus/Source/Application-Protocols/network_transport/transport_wolfSSL.c @@ -143,11 +143,11 @@ static int wolfSSL_IORecvGlue( WOLFSSL * ssl, read = TCP_Sockets_Recv( xSocket, ( void * ) buf, ( size_t ) sz ); if( ( read == 0 ) || - ( read == -TCP_SOCKETS_ERRNO_EWOULDBLOCK ) ) + ( read == TCP_SOCKETS_ERRNO_EWOULDBLOCK ) ) { read = WOLFSSL_CBIO_ERR_WANT_READ; } - else if( read == -TCP_SOCKETS_ERRNO_ENOTCONN ) + else if( read == TCP_SOCKETS_ERRNO_ENOTCONN ) { read = WOLFSSL_CBIO_ERR_CONN_CLOSE; } @@ -169,11 +169,11 @@ static int wolfSSL_IOSendGlue( WOLFSSL * ssl, Socket_t xSocket = ( Socket_t ) context; BaseType_t sent = TCP_Sockets_Send( xSocket, ( void * ) buf, ( size_t ) sz ); - if( sent == -TCP_SOCKETS_ERRNO_EWOULDBLOCK ) + if( sent == TCP_SOCKETS_ERRNO_EWOULDBLOCK ) { sent = WOLFSSL_CBIO_ERR_WANT_WRITE; } - else if( sent == -TCP_SOCKETS_ERRNO_ENOTCONN ) + else if( sent == TCP_SOCKETS_ERRNO_ENOTCONN ) { sent = WOLFSSL_CBIO_ERR_CONN_CLOSE; } diff --git a/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/FreeRTOSConfig.h b/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/FreeRTOSConfig.h index 20e59ea3114..97117870ad7 100644 --- a/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/FreeRTOSConfig.h +++ b/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/FreeRTOSConfig.h @@ -131,4 +131,6 @@ #define bktPRIMARY_PRIORITY ( configMAX_PRIORITIES - 3 ) #define bktSECONDARY_PRIORITY ( configMAX_PRIORITIES - 4 ) +#define configENABLE_BACKWARD_COMPATIBILITY 0 + #endif /* FREERTOS_CONFIG_H */ diff --git a/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/build/gcc/Makefile b/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/build/gcc/Makefile index b8ced5da37d..f268700e4f2 100644 --- a/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/build/gcc/Makefile +++ b/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/build/gcc/Makefile @@ -1,19 +1,28 @@ OUTPUT_DIR := ./output -IMAGE := RTOSDemo.out -SUB_MAKEFILE_DIR = ./library-makefiles +IMAGE := $(OUTPUT_DIR)/RTOSDemo.out # The directory that contains the /source and /demo sub directories. -FREERTOS_ROOT = ./../../../../ +FREERTOS_ROOT = ./../../../.. CC = arm-none-eabi-gcc LD = arm-none-eabi-gcc SIZE = arm-none-eabi-size MAKE = make - -CFLAGS += $(INCLUDE_DIRS) -nostartfiles -ffreestanding -mthumb -mcpu=cortex-m3 \ - -Wall -Wextra -g3 -Os -ffunction-sections -fdata-sections \ - -MMD -MP -MF"$(@:%.o=%.d)" -MT $@ +CFLAGS += -ffreestanding -mthumb -mcpu=cortex-m3 +CFLAGS += -Wall -Wextra -Wshadow +CFLAGS += -g3 -Os -ffunction-sections -fdata-sections +CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)" -MT $@ +#CFLAGS += -std=c99 +#CFLAGS += -Wpedantic -fanalyzer +#CFLAGS += -flto +CFLAGS += $(INCLUDE_DIRS) + +LDFLAGS = -T ./mps2_m3.ld +LDFLAGS += -Xlinker -Map=$(OUTPUT_DIR)/RTOSDemo.map +LDFLAGS += -Xlinker --gc-sections +LDFLAGS += -nostartfiles +LDFLAGS += -specs=nano.specs -specs=nosys.specs # -specs=rdimon.specs # # Kernel build. @@ -33,7 +42,7 @@ SOURCE_FILES += $(KERNEL_DIR)/portable/MemMang/heap_4.c SOURCE_FILES += $(KERNEL_DIR)/portable/GCC/ARM_CM3/port.c # -# Common demo files for the "full" build, as opposed to the "blinky" build - +# Common demo files for the "full" build, as opposed to the "blinky" build - # these files are build by all the FreeRTOS kernel demos. # DEMO_ROOT = $(FREERTOS_ROOT)/Demo @@ -93,27 +102,25 @@ DEP_FILES := $(SOURCE_FILES:%.c=$(OUTPUT_DIR)/%.d) DEP_FILES_NO_PATH = $(notdir $(DEP_FILES)) DEP_OUTPUT = $(DEP_FILES_NO_PATH:%.d=$(OUTPUT_DIR)/%.d) -all: $(OUTPUT_DIR)/$(IMAGE) +all: $(IMAGE) %.o : %.c $(OUTPUT_DIR)/%.o : %.c $(OUTPUT_DIR)/%.d Makefile $(CC) $(CFLAGS) -c $< -o $@ -$(OUTPUT_DIR)/$(IMAGE): ./mps2_m3.ld $(OBJS_OUTPUT) Makefile +$(IMAGE): ./mps2_m3.ld $(OBJS_OUTPUT) Makefile @echo "" @echo "" @echo "--- Final linking ---" @echo "" - $(LD) $(OBJS_OUTPUT) $(CFLAGS) -Xlinker --gc-sections -Xlinker -T ./mps2_m3.ld \ - -Xlinker -Map=$(OUTPUT_DIR)/RTOSDemo.map -specs=nano.specs \ - -specs=nosys.specs -specs=rdimon.specs -o $(OUTPUT_DIR)/$(IMAGE) - $(SIZE) $(OUTPUT_DIR)/$(IMAGE) + $(LD) $(CFLAGS) $(LDFLAGS) $(OBJS_OUTPUT) -o $(IMAGE) + $(SIZE) $(IMAGE) $(DEP_OUTPUT): include $(wildcard $(DEP_OUTPUT)) clean: - rm -f $(OUTPUT_DIR)/$(IMAGE) $(OUTPUT_DIR)/*.o $(OUTPUT_DIR)/*.d + rm -f $(IMAGE) $(OUTPUT_DIR)/RTOSDemo.map $(OUTPUT_DIR)/*.o $(OUTPUT_DIR)/*.d #use "make print-[VARIABLE_NAME] to print the value of a variable generated by #this makefile. diff --git a/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/build/gcc/startup_gcc.c b/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/build/gcc/startup_gcc.c index d0531116cce..fe6d2b1e997 100644 --- a/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/build/gcc/startup_gcc.c +++ b/FreeRTOS/Demo/CORTEX_MPS2_QEMU_IAR_GCC/build/gcc/startup_gcc.c @@ -27,22 +27,6 @@ #include #include -/* UART peripheral register addresses and bits. */ -#define UART0_ADDR ( ( UART_t * ) ( 0x40004000 ) ) -#define UART_DR( baseaddr ) ( *( uint32_t * ) ( baseaddr ) ) -#define UART_STATE( baseaddr ) ( *( uint32_t * ) ( baseaddr + 4 ) ) -#define UART_STATE_TXFULL ( 1 << 0 ) - -typedef struct UART_t -{ - volatile uint32_t DATA; - volatile uint32_t STATE; - volatile uint32_t CTRL; - volatile uint32_t INTSTATUS; - volatile uint32_t BAUDDIV; -} UART_t; - - /* FreeRTOS interrupt handlers. */ extern void vPortSVCHandler( void ); extern void xPortPendSVHandler( void ); @@ -53,13 +37,13 @@ extern void TIMER1_Handler( void ); /* Exception handlers. */ static void HardFault_Handler( void ) __attribute__( ( naked ) ); static void Default_Handler( void ) __attribute__( ( naked ) ); -void Reset_Handler( void ); +void Reset_Handler( void ) __attribute__( ( naked ) ); extern int main( void ); extern uint32_t _estack; /* Vector table. */ -const uint32_t* isr_vector[] __attribute__((section(".isr_vector"))) = +const uint32_t* isr_vector[] __attribute__((section(".isr_vector"), used)) = { ( uint32_t * ) &_estack, ( uint32_t * ) &Reset_Handler, // Reset -15 @@ -68,15 +52,15 @@ const uint32_t* isr_vector[] __attribute__((section(".isr_vector"))) = ( uint32_t * ) &Default_Handler, // MemManage_Handler -12 ( uint32_t * ) &Default_Handler, // BusFault_Handler -11 ( uint32_t * ) &Default_Handler, // UsageFault_Handler -10 - 0, // reserved - 0, // reserved - 0, // reserved + 0, // reserved -9 + 0, // reserved -8 + 0, // reserved -7 0, // reserved -6 - ( uint32_t * ) &vPortSVCHandler, // SVC_Handler -5 - ( uint32_t * ) &Default_Handler, // DebugMon_Handler -4 - 0, // reserved - ( uint32_t * ) &xPortPendSVHandler, // PendSV handler -2 - ( uint32_t * ) &xPortSysTickHandler,// SysTick_Handler -1 + ( uint32_t * ) &vPortSVCHandler, // SVC_Handler -5 + ( uint32_t * ) &Default_Handler, // DebugMon_Handler -4 + 0, // reserved -3 + ( uint32_t * ) &xPortPendSVHandler, // PendSV handler -2 + ( uint32_t * ) &xPortSysTickHandler,// SysTick_Handler -1 0, 0, 0, @@ -86,7 +70,7 @@ const uint32_t* isr_vector[] __attribute__((section(".isr_vector"))) = 0, 0, ( uint32_t * ) TIMER0_Handler, // Timer 0 - ( uint32_t * ) TIMER1_Handler, // Timer 1 + ( uint32_t * ) TIMER1_Handler, // Timer 1 0, 0, 0, @@ -99,7 +83,7 @@ void Reset_Handler( void ) } /* Variables used to store the value of registers at the time a hardfault - * occurs. These are volatile to try and prevent the compiler/linker optimising + * occurs. These are volatile to try and prevent the compiler/linker optimizing * them away as the variables never actually get used. */ volatile uint32_t r0; volatile uint32_t r1; @@ -113,7 +97,7 @@ volatile uint32_t psr;/* Program status register. */ /* Called from the hardfault handler to provide information on the processor * state at the time of the fault. */ -void prvGetRegistersFromStack( uint32_t *pulFaultStackAddress ) +__attribute__( ( used ) ) void prvGetRegistersFromStack( uint32_t *pulFaultStackAddress ) { r0 = pulFaultStackAddress[ 0 ]; r1 = pulFaultStackAddress[ 1 ]; diff --git a/FreeRTOS/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC/FreeRTOSConfig.h b/FreeRTOS/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC/FreeRTOSConfig.h index 01fefd710db..e83bb33c70b 100644 --- a/FreeRTOS/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC/FreeRTOSConfig.h +++ b/FreeRTOS/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC/FreeRTOSConfig.h @@ -72,7 +72,6 @@ extern void vAssertCalled( void ); #define configUSE_COUNTING_SEMAPHORES 1 #define configSUPPORT_DYNAMIC_ALLOCATION 1 #define configSUPPORT_STATIC_ALLOCATION 1 -#define configNUM_TX_DESCRIPTORS 15 #define configSTREAM_BUFFER_TRIGGER_LEVEL_TEST_MARGIN 2 #define configCHECK_FOR_STACK_OVERFLOW 2 #define configALLOW_UNPRIVILEGED_CRITICAL_SECTIONS 0 @@ -134,9 +133,4 @@ unsigned long ulGetRunTimeCounterValue( void ); /* Prototype of function that re extern void vLoggingPrintf( const char * pcFormatString, ... ); -#ifdef HEAP3 - #define xPortGetMinimumEverFreeHeapSize ( x ) - #define xPortGetFreeHeapSize ( x ) -#endif - #endif /* FREERTOS_CONFIG_H */ diff --git a/FreeRTOS/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC/Makefile b/FreeRTOS/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC/Makefile index 87fc5f0ac4e..82c018698d2 100644 --- a/FreeRTOS/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC/Makefile +++ b/FreeRTOS/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC/Makefile @@ -1,4 +1,5 @@ CC = arm-none-eabi-gcc +SIZE = arm-none-eabi-size BIN := RTOSDemo.axf BUILD_DIR := build @@ -34,33 +35,23 @@ INCLUDE_DIRS += -I$(FREERTOS_DIR)/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC/C INCLUDE_DIRS += -I$(KERNEL_DIR)/include INCLUDE_DIRS += -I$(KERNEL_DIR)/portable/GCC/ARM_CM3_MPU -DEFINES := -DQEMU_SOC_MPS2 DEFINES := -DHEAP4 - CPPFLAGS += $(DEFINES) -CFLAGS += -mcpu=cortex-m3 -CFLAGS += -Wno-error=implicit-function-declaration -CFLAGS += -Wno-builtin-declaration-mismatch -CFLAGS += -Werror -CFLAGS += -Wall -CFLAGS += -Wextra -CFLAGS += -fstrict-aliasing -CFLAGS += -Wstrict-aliasing -CFLAGS += -Wno-error=address-of-packed-member -CFLAGS += -Wno-unused-parameter +CFLAGS += -mthumb -mcpu=cortex-m3 +CFLAGS += -Wall -Wextra -Wshadow -Wno-unused-parameter +#CFLAGS += -Wpedantic -fanalyzer CFLAGS += $(INCLUDE_DIRS) LDFLAGS = -T ./scripts/mps2_m3.ld -LDFLAGS += -mthumb - LDFLAGS += -Xlinker -Map=${BUILD_DIR}/output.map +LDFLAGS += -Xlinker --gc-sections LDFLAGS += -nostartfiles -nostdlib -nolibc -nodefaultlibs ifeq ($(DEBUG), 1) - CFLAGS += -ggdb3 -Og -save-temps=obj + CFLAGS += -g3 -Og -ffunction-sections -fdata-sections -save-temps=obj else - CFLAGS += -O3 + CFLAGS += -Os -ffunction-sections -fdata-sections endif ifeq ($(PICOLIBC), 1) @@ -73,7 +64,8 @@ OBJ_FILES := $(SOURCE_FILES:%.c=$(BUILD_DIR)/%.o) .PHONY: clean $(BUILD_DIR)/$(BIN) : $(OBJ_FILES) - $(CC) -ffunction-sections -fdata-sections $(LDFLAGS) $+ -o $(@) + $(CC) $(CFLAGS) $(LDFLAGS) $+ -o $(@) + $(SIZE) $(@) %.d: %.c @set -e; rm -f $@; \ diff --git a/FreeRTOS/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC/init/startup.c b/FreeRTOS/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC/init/startup.c index 425bea09ed9..4a9752d4607 100644 --- a/FreeRTOS/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC/init/startup.c +++ b/FreeRTOS/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC/init/startup.c @@ -34,8 +34,10 @@ extern void vPortSVCHandler( void ); extern void xPortPendSVHandler( void ); extern void xPortSysTickHandler( void ); -extern void uart_init(); -extern int main(); +extern void uart_init( void ); +extern int main( void ); + +void _start( void ); extern uint32_t _estack, _sidata, _sdata, _edata, _sbss, _ebss; @@ -61,13 +63,12 @@ void Reset_Handler( void ) } /* jump to board initialisation */ - void _start( void ); _start(); } void prvGetRegistersFromStack( uint32_t * pulFaultStackAddress ) { -/* These are volatile to try and prevent the compiler/linker optimising them +/* These are volatile to try and prevent the compiler/linker optimizing them * away as the variables never actually get used. If the debugger won't show the * values of the variables, make them global my moving their declaration outside * of this function. */ @@ -122,6 +123,7 @@ void Default_Handler( void ) "NVIC_INT_CTRL_CONST: .word 0xe000ed04\n" ); } + static void HardFault_Handler( void ) __attribute__( ( naked ) ); void HardFault_Handler( void ) { @@ -232,12 +234,12 @@ const uint32_t * const isr_vector[] __attribute__( ( section( ".isr_vector" ) ) void _start( void ) { uart_init(); - main( 0, 0 ); + main(); exit( 0 ); } __attribute__( ( naked ) ) -void exit( __attribute__( ( unused ) ) int status ) +void exit( int status ) { /* Force qemu to exit using ARM Semihosting */ __asm volatile ( @@ -250,4 +252,6 @@ void exit( __attribute__( ( unused ) ) int status ) "bkpt 0xab\n" "end: b end\n" ); + + ( void ) status; } diff --git a/FreeRTOS/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC/main.c b/FreeRTOS/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC/main.c index d24cfa890ed..6481ac42969 100644 --- a/FreeRTOS/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC/main.c +++ b/FreeRTOS/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC/main.c @@ -37,7 +37,7 @@ void vApplicationIdleHook( void ); void vApplicationTickHook( void ); -int main() +int main( void ) { app_main(); return 0; diff --git a/FreeRTOS/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC/syscall.c b/FreeRTOS/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC/syscall.c index 03668fdde39..d8fc48cb9d6 100644 --- a/FreeRTOS/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC/syscall.c +++ b/FreeRTOS/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC/syscall.c @@ -45,15 +45,10 @@ typedef struct UART_t #define UART_CTRL_TX_EN ( 1 << 0 ) #define UART_CTRL_RX_EN ( 1 << 1 ) - -extern unsigned long _heap_bottom; -extern unsigned long _heap_top; -extern unsigned long g_ulBase; - /** * @brief initializes the UART emulated hardware */ -void uart_init() +void uart_init(void) { UART0_ADDR->BAUDDIV = 16; UART0_ADDR->CTRL = UART_CTRL_TX_EN; @@ -74,7 +69,7 @@ void uart_init() int _uart_putc(char c, FILE *file) { - (void) file; + ( void ) file; UART_DR( UART0_ADDR ) = c; return (unsigned char) c; } @@ -85,15 +80,19 @@ FILE *const stdout = &__stdio; #else -static void * heap_end = 0; +extern unsigned long _heap_bottom; +extern unsigned long _heap_top; + +static char * heap_end = ( char * ) &_heap_bottom; /** * @brief not used anywhere in the code * @todo implement if necessary * */ -int _fstat( __attribute__( ( unused ) ) int file ) +int _fstat( int file ) { + ( void ) file; return 0; } @@ -102,10 +101,13 @@ int _fstat( __attribute__( ( unused ) ) int file ) * @todo implement if necessary * */ -int _read( __attribute__( ( unused ) ) int file, - __attribute__( ( unused ) ) char * buf, - __attribute__( ( unused ) ) int len ) +int _read( int file, + char * buf, + int len ) { + ( void ) file; + ( void ) buf; + ( void ) len; return -1; } @@ -117,12 +119,14 @@ int _read( __attribute__( ( unused ) ) int file, * @param [in] len length of the buffer * @returns the number of bytes written */ -int _write( __attribute__( ( unused ) ) int file, - __attribute__( ( unused ) ) char * buf, +int _write( int file, + char * buf, int len ) { int todo; + ( void ) file; + for( todo = 0; todo < len; todo++ ) { UART_DR( UART0_ADDR ) = *buf++; @@ -139,16 +143,9 @@ int _write( __attribute__( ( unused ) ) int file, */ void * _sbrk( int incr ) { - char * prev_heap_end; - - if( heap_end == 0 ) - { - heap_end = ( void * ) &_heap_bottom; - } - - prev_heap_end = heap_end; + void * prev_heap_end = heap_end; - if( ( heap_end + incr ) > ( void * ) &_heap_top ) + if( ( heap_end + incr ) > ( char * ) &_heap_top ) { return ( void * ) -1; } @@ -157,6 +154,7 @@ void * _sbrk( int incr ) return prev_heap_end; } + void _close( int fd ) { ( void ) fd; @@ -202,7 +200,7 @@ void _kill( pid_t pid, ( void ) sig; } -int _getpid() +int _getpid( void ) { return 1; } diff --git a/FreeRTOS/Demo/Common/Minimal/AbortDelay.c b/FreeRTOS/Demo/Common/Minimal/AbortDelay.c index 55f0ba638e8..581fcbe8aef 100644 --- a/FreeRTOS/Demo/Common/Minimal/AbortDelay.c +++ b/FreeRTOS/Demo/Common/Minimal/AbortDelay.c @@ -488,20 +488,21 @@ uint8_t uxRxData; #if ( configSUPPORT_STATIC_ALLOCATION == 1 ) - { - /* Defines the memory that will actually hold the streams within the - * stream buffer. */ - static uint8_t ucStorageBuffer[ sizeof( configMESSAGE_BUFFER_LENGTH_TYPE ) + 1 ]; - /* The variable used to hold the stream buffer structure. */ + /* The variable used to hold the stream buffer structure. + * This control information is valid as long as xStreamBuffer + * is valid. */ StaticStreamBuffer_t xStreamBufferStruct; - - - xStreamBuffer = xStreamBufferCreateStatic( sizeof( ucStorageBuffer ), - xTriggerLevelBytes, - ucStorageBuffer, - &xStreamBufferStruct ); - } + { + /* Defines the memory that will actually hold the streams within the + * stream buffer. */ + static uint8_t ucStorageBuffer[ sizeof( configMESSAGE_BUFFER_LENGTH_TYPE ) + 1 ]; + + xStreamBuffer = xStreamBufferCreateStatic( sizeof( ucStorageBuffer ), + xTriggerLevelBytes, + ucStorageBuffer, + &xStreamBufferStruct ); + } #else /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) */ { xStreamBuffer = xStreamBufferCreate( sizeof( uint8_t ), xTriggerLevelBytes ); diff --git a/FreeRTOS/Demo/Posix_GCC/CMakeLists.txt b/FreeRTOS/Demo/Posix_GCC/CMakeLists.txt index 199de7508b5..6131634b6c0 100644 --- a/FreeRTOS/Demo/Posix_GCC/CMakeLists.txt +++ b/FreeRTOS/Demo/Posix_GCC/CMakeLists.txt @@ -4,6 +4,8 @@ project( posix_demo ) add_compile_options( -D_WINDOWS_ ) +add_compile_options( -Wall -Wextra -Wpedantic ) + if( TRACE_ON_ENTER ) add_compile_options( -DTRACE_ON_ENTER=1 ) else() @@ -33,6 +35,9 @@ else() set( CMAKE_BUILD_TYPE "debug" ) endif() +set(CMAKE_CXX_FLAGS_RELEASE "-O3") +set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g3") + if( SANITIZE_ADDRESS ) add_compile_options( -fsanitize=address -fsanitize=alignment ) endif() diff --git a/FreeRTOS/Demo/Posix_GCC/main.c b/FreeRTOS/Demo/Posix_GCC/main.c index 52a9753c9be..7f0fcf9fbc9 100644 --- a/FreeRTOS/Demo/Posix_GCC/main.c +++ b/FreeRTOS/Demo/Posix_GCC/main.c @@ -91,6 +91,7 @@ /* This demo uses heap_3.c (the libc provided malloc() and free()). */ /*-----------------------------------------------------------*/ + extern void main_blinky( void ); extern void main_full( void ); static void traceOnEnter( void ); @@ -118,11 +119,15 @@ void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer, StackType_t ** ppxTimerTaskStackBuffer, uint32_t * pulTimerTaskStackSize ); -/* - * Writes trace data to a disk file when the trace recording is stopped. - * This function will simply overwrite any trace files that already exist. - */ -static void prvSaveTraceFile( void ); +#if ( projENABLE_TRACING == 1 ) + + /* + * Writes trace data to a disk file when the trace recording is stopped. + * This function will simply overwrite any trace files that already exist. + */ + static void prvSaveTraceFile( void ); + +#endif /* if ( projENABLE_TRACING == 1 ) */ /* * Signal handler for Ctrl_C to cause the program to exit, and generate the @@ -139,8 +144,6 @@ static void handle_sigint( int signal ); * in a different file. */ StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ]; -static clockid_t cid = CLOCK_THREAD_CPUTIME_ID; - /*-----------------------------------------------------------*/ int main( void ) @@ -183,6 +186,7 @@ int main( void ) return 0; } + /*-----------------------------------------------------------*/ void vApplicationMallocFailedHook( void ) @@ -201,6 +205,7 @@ void vApplicationMallocFailedHook( void ) * information. */ vAssertCalled( __FILE__, __LINE__ ); } + /*-----------------------------------------------------------*/ void vApplicationIdleHook( void ) @@ -227,6 +232,7 @@ void vApplicationIdleHook( void ) } #endif } + /*-----------------------------------------------------------*/ void vApplicationStackOverflowHook( TaskHandle_t pxTask, @@ -242,6 +248,7 @@ void vApplicationStackOverflowHook( TaskHandle_t pxTask, * when running the FreeRTOS POSIX port. */ vAssertCalled( __FILE__, __LINE__ ); } + /*-----------------------------------------------------------*/ void vApplicationTickHook( void ) @@ -259,7 +266,9 @@ void vApplicationTickHook( void ) #endif /* mainSELECTED_APPLICATION */ } -void traceOnEnter() +/*-----------------------------------------------------------*/ + +void traceOnEnter( void ) { #if ( TRACE_ON_ENTER == 1 ) int xReturn; @@ -286,6 +295,8 @@ void traceOnEnter() #endif /* if ( TRACE_ON_ENTER == 1 ) */ } +/*-----------------------------------------------------------*/ + void vLoggingPrintf( const char * pcFormat, ... ) { @@ -295,15 +306,17 @@ void vLoggingPrintf( const char * pcFormat, vprintf( pcFormat, arg ); va_end( arg ); } + /*-----------------------------------------------------------*/ void vApplicationDaemonTaskStartupHook( void ) { /* This function will be called once only, when the daemon task starts to - * execute (sometimes called the timer task). This is useful if the + * execute (sometimes called the timer task). This is useful if the * application includes initialisation code that would benefit from executing * after the scheduler has been started. */ } + /*-----------------------------------------------------------*/ void vAssertCalled( const char * const pcFileName, @@ -345,9 +358,11 @@ void vAssertCalled( const char * const pcFileName, } taskEXIT_CRITICAL(); } + /*-----------------------------------------------------------*/ #if ( projENABLE_TRACING == 1 ) + static void prvSaveTraceFile( void ) { FILE * pxOutputFile; @@ -367,7 +382,9 @@ void vAssertCalled( const char * const pcFileName, printf( "\r\nFailed to create trace dump file\r\n" ); } } + #endif /* if ( projENABLE_TRACING == 1 ) */ + /*-----------------------------------------------------------*/ /* configUSE_STATIC_ALLOCATION is set to 1, so the application must provide an @@ -377,9 +394,9 @@ 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. */ + /* 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 ]; @@ -395,6 +412,7 @@ void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, * configMINIMAL_STACK_SIZE is specified in words, not bytes. */ *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; } + /*-----------------------------------------------------------*/ /* configUSE_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so the @@ -404,9 +422,9 @@ 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. */ + /* 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; /* Pass out a pointer to the StaticTask_t structure in which the Timer @@ -422,20 +440,26 @@ void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer, *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; } +/*-----------------------------------------------------------*/ + void handle_sigint( int signal ) { int xReturn; - xReturn = chdir( BUILD ); /* changing dir to place gmon.out inside build */ + ( void ) signal; + + xReturn = chdir( BUILD ); /* Changing dir to place gmon.out inside build. */ if( xReturn == -1 ) { printf( "chdir into %s error is %d\n", BUILD, errno ); } - exit( 2 ); + _exit( 2 ); } +/*-----------------------------------------------------------*/ + static uint32_t ulEntryTime = 0; void vTraceTimerReset( void ) @@ -443,12 +467,18 @@ void vTraceTimerReset( void ) ulEntryTime = xTaskGetTickCount(); } +/*-----------------------------------------------------------*/ + uint32_t uiTraceTimerGetFrequency( void ) { return configTICK_RATE_HZ; } +/*-----------------------------------------------------------*/ + uint32_t uiTraceTimerGetValue( void ) { return( xTaskGetTickCount() - ulEntryTime ); } + +/*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Demo/Posix_GCC/main_full.c b/FreeRTOS/Demo/Posix_GCC/main_full.c index 49fa10617ae..ea6a755be83 100644 --- a/FreeRTOS/Demo/Posix_GCC/main_full.c +++ b/FreeRTOS/Demo/Posix_GCC/main_full.c @@ -269,7 +269,6 @@ static void prvCheckTask( void * pvParameters ) { TickType_t xNextWakeTime; const TickType_t xCycleFrequency = pdMS_TO_TICKS( 10000UL ); - HeapStats_t xHeapStats; /* Just to remove compiler warning. */ ( void ) pvParameters; diff --git a/FreeRTOS/Demo/WIN32-MingW/.cproject b/FreeRTOS/Demo/WIN32-MingW/.cproject index 0cc3eaa9372..89dd1c2386f 100644 --- a/FreeRTOS/Demo/WIN32-MingW/.cproject +++ b/FreeRTOS/Demo/WIN32-MingW/.cproject @@ -30,7 +30,8 @@