You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
FreeRTOS/FreeRTOS-Plus/Demo/Common/Logging/windows/Logging_WinSim.c

556 lines
21 KiB
C

/*
* FreeRTOS V202212.00
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* https://www.FreeRTOS.org
FreeRTOS Windows Simulator Build Changes and LTS 2.0 Update (#872) * Update mbedtls to version v3.2.1 * Adjust include paths for github workflow * Update FreeRTOS+TCP to v3.1.0 * Add initial VS project files for Kernel, +TCP, and mbedtls * winpcap: Consolidate to a single copy of WinPcap * Downgrade library projects to VS 2019. Add heap_4 to kernel. * Remove *.vcxproj.user files and add to gitignore * Disable unwanted kernel config options * Update FreeRTOS+TCP and Kernel include paths * Update FreeRTOS+TCP Windows Minimal sln * Remove .suo and .vcxproj.user files * Update mbedtls transport implementations for mbedtls v3.2.1 * Fix typo in mbedtls_freertos_port.c * Update vcxproj files for +TCP, Kernel, Mbedtls * Fix typo in name WindowSimulator -> WindowsSimulator * Add wpcap lib to FreeRTOS+TCP.vcxproj * Update FreeRTOS+TCP Minimal Demo for Windows Simulator * Mask MSVC string function warnings Aad _CRT_SECURE_NO_WARNINGS preprocessor definition. * Move projects to their own directories to make VisualStudio happy * mbedtls_freertos_port.c: Fix formatting? * Add coreHTTP, Logging libs. Adjust dependencies * Disable FreeRTOS Kernel malloc failed hook * Update coreHTTP Plaintext demo * Rename / relocate transport interface implementations * Remove old VS project files * Remove extra core_http_config.h files * Remove extra FreeRTOSConfig.h files * Remove extra FreeRTOSIPConfig.h files * Remove old mbedtls_config.h files * Remove old FreeRTOSConfig and core_http_config files * Update HTTP Mutual Auth Demo build files * Fix transport_plaintext.h include name * Update HTTP_Plaintext demo build files * Update CoreHTTP_S3_Download VS project files * Update HTTP_S3_Upload demo build files * Update CoreHTTP_S3_Download_Multithreaded demo build files * Add GithubActions builds for FreeRTOS+ CoreHTTP Demos * Update S3DownloadHTTPExample.c to be compatible with mbedtls 3.x * Update GithubActions FreeRTOS+ config file * Combine core_pkcs11_config.h files into a single one * Add corePKCS11 VS project file * Update corePKCS11 WinSim demo project and build files * Update corePKCS11 library to version 3.5.0 * Modifiying demos to build using static libraries * Adding a header file * Two more demos * Update corePKCS11 demo code and auto-format * Downgrade corePKCS11 library build file to v142 / VS 2019 * Speed up CI builds with selective submodule initialization * Separate corePKCS11 demo into it's own job. * Remove WIN32.vcxproj and WIN32.vcxproj.filters files * Remove old configuration header files Partially reverts 73829ced6061e4584e521185178a61b4a437c5e0 * Revert unwanted coreHTTP demo changes * Changing include paths for demos * Adding an include * MQTT WoflSSL Demo update * wolfSSL Demo changes * Config changes for MQTT Demos * Initial Device Defender demo update. * Initial Device Shadow demo update. * Update mbedtls_transport_pkcs11 for Mbedtls 3.x * Update corePKCS11 MQTT Mutual Auth demo * Add a default definition of SdkLog * Update CorePKCS11 + MQTT Mutual Auth demo sln name * Build all configs of coreHTTP demos * Update coreSNTP Demo build files. * Update coreSNTP Demo sln name * Update FreeRTOS+TCP Posix demo * Update FreeRTOS+TCP Qemu ARM MPS2 AN385 Demo * Update FreeRTOS+TCP Demo Github Actions builds * Update Fleet Provisioning WinSim Demo build files * Remove mbedtls_pk_info_t references from mbedtls_pk_pkcs11.h * Restore / update the FreeRTOS+TCP Minimal WinSim demo * Initial Jobs demo update. * Fix jobs demo build. * Initial OTA over HTTP demo update. * Initial OTA over MQTT demo update. * Ota_Over_Mqtt_Demo build fix. * OTA over MQTT demo fix. * Update HTTP demo solution file name for CI. * Update Github actions workflow to old HTTP demo names. * Update coreSTNP demo to old solution name. * Fix defender demo / fix mbedtls config to use threading alt. * Add MBEDTLS_CONFIG_FILE definition to each config * Fix config file name. * MQTT Mutual auth fixes. * Fix job demo. * Device shadow demo fixes. * Fix coreSNTP demo not setting alt threading functions for mbedtls. * Enable Static allocation, Add default hooks for FreeRTOS Kernel and +TCP * Add xPlatformIsNetworkUp platform function to FreeRTOS+TCP hooks * Enable runtime statistics in the Windows Simualator Kernel config * Revert "Fix coreSNTP demo not setting alt threading functions for mbedtls." This reverts commit 9069707519561ca8136d58c0f18fb176c9050a1d. * Revert mbedtls threading related config changes * Add xPlatformIsNetworkUp function prototype * Remove boileplate FreeRTOS kernel and +tcp hooks * Refactor device defender demo for clarity * Add wait loop calling xPlatformIsNetworkUp * Add missing vPlatformInitLogging function * Add vPlatformInitLogging and vLoggingPrintf defitions to logging headers * Updating the FreeRTOS_Plus_CLI_with_Trace_Windows_Simulator * Updating the FreeRTOS_Plus_Reliance_Edge_and_CLI_Windows_Simulator demo * Updates to the FreeRTOS_Plus_WolfSSL_Windows_Simulator demo * Fixing wrong include path * Upating FreeRTOS_Plus_WolfSSL_FIPS_Ready_Windows_Simulator demo * Update coreMQTT WinSim demos to print start and end condition. * Modifiying repos updated as part of the CLI demo GitHub workflow * Removing duplicate functions from the FreeRTOS_Plus_TCP_Minimal_Windows_Simulator demo * Updated FreeRTOS_Plus_TCP_UDP_Mode_CLI_Windows_Simulator demo * Updating corePKCS11_MQTT_Mutual_Auth_Windows_Simulator Demo to call the static function that creates task * Fix log message using unitialized string in MQTT Multitask demo. * Fixing a broken extern function * Fixing a typo extern function name * Added a reference to coreHTTP * Fixing a pre-processor issue in the OTA_Over_Http_Demo * Updating the MQTT_Mutual_Auth_Demo_with_BG96 demo * Updating the MQTT_Mutual_Auth_Demo_with_HL7802 demo * Changes to the MQTT_Mutual_Auth_Demo_with_SARA_R4 demo * Fix demos for CI. * Adding the source path to the CBMC proofs for FreeRTOS+TCP * Spell check fixes, adding words to lexicons * Fixing a typo * Add arg to skip prompt in setup script. * Update paths of script to be relative to the file. * Changing manifest.yml file to point to corePKCS11 3.5.0 * Added CI markers to cellular demos. * Fix cellular demo flow. * Fix celullar demos. * Initial TCP sockets wrapper rework - will break things. * First cellular demo fix for new sockets wrapper. * Minor fix to cellular sockets wrapper. * Fix mbedtls bio using FreeRTOS Plus TCP call. * Clean up BG96 demo project files. * Update HL7802 demo. * Fix SARA R4 demo for new sockets wrapper. * Fix Device Defender, Device Shadow, and Fleet PRovisioning. * Fix Jobs demo. * Fix OTA over HTTP demo. * Fix OTA over MQTT demo. * Fix HTTP mutual auth demo. * Fix OTA over MQTT demo endianness. * Fix OTA over HTTP demo endianness. * Fix HTTP Plaintext demo. * Fix HTTP S3 download demo. * Fix plaintext transport * Fix OTA demos. * Fix OTA demos. * Fix OTA HTTP demo. * Fix HTTP S3 Download multithreaded demo. * Fix HTTP S3 Upload demo * Fix corePKCS11 Mutual Auth demo. * Updating MQTT_Mutual_Auth * Update pkcs11 setup script. * Updating the MQTT_Basic_TLS Demo * Organize PKCS11 demos project. * Updating MQTT_Keep_Alive demo * Clean up SNTP demo. * Updated MQTT_Multitask demo * Updated MQTT_Plain_Text * Updating the MQTT_Serializer Demo * Updating corePKCS11_MQTT_Mutual_Auth_Windows_Simulator * Updating coreSNTP_Windows_Simulator * Clean up demo projects. * Add markers to PKCS11 mutual auth demo. * Fix Fleet Provisioning demo script. * Fix SNTP demo solution. * Fix coreSNTP project files. * Fix Fleet Provisiong script. * Fix fleet provisioning script. * Fix demo config template. * Fleet provisioning demo markers. * Updating MQTT_Mutual_Auth_wolfSSL demo and the transport_wolfSSL file * Fixing FreeRTOS_Plus_TCP_Echo_POSIX * Fixing CLI and Trace Demos * Fixing TCP_ECHO_POSIX demo * Adding a word to the lexicon * Remove unneeded files. * Update github workflows to use Ubuntu 20.04. * Change OTA demo target names to RTOSDemo for OTAE2E tests. * Fixing Headers * Updating headers * Two more headers * Adding words to the lexicon * Whitepsace * Ignore mbedtls config file for header check. * Removing FreeRTOS Header from the mbedtls_config_v3.2.1.h file * Fix bug in lPKCS11PkMbedtlsCloseSessionAndFree. Add doxygen api docs. * Update lexicon.txt * Fix spelling * Apply suggestions from code review Co-authored-by: jasonpcarroll <23126711+jasonpcarroll@users.noreply.github.com> * Add return code comment for p11_ecdsa_ctx_init * Rename WindowsSimulator folder to VisualStudio_StaticProjects. * Remove references to coroutines * Fix mbedtls_pk_pkcs11.c * Update to LTS 2.0 submodule pointers (#880) * Update submodule pointers to LTS 2.0 * Initial coreMQTT 2.1.1 update. * Update AWS demos for coreMQTT 2.1.1 * Fix deprecated macro for coreMQTT demos. * Fix keep alive demo. * Fix plaintext demo. * Fix MQTT wolfSSL demo. * Fix MQTT PKCS11 demo. * Remove duplicate functions. * Fix Mutual auth demos for Cellular. * Fix OTA demos. * Fix header of plaintext demo config. * Set writev to NULL for OTA demos. * Fix mbedlts config for OTA demos. * Fix spelling. Co-authored-by: Jason Carroll <czjaso@amazon.com> * Removing blank line * Fix jobs demo race condition. * Fix race condition from WinPCap network interface. * Update lexicon. Co-authored-by: Paul Bartell <pbartell@amazon.com> Co-authored-by: Jason Carroll <czjaso@amazon.com> Co-authored-by: Paul Bartell <paul.bartell@gmail.com> Co-authored-by: jasonpcarroll <23126711+jasonpcarroll@users.noreply.github.com>
2 years ago
* https://github.com/FreeRTOS
*
*/
/*
* Logging utility that allows FreeRTOS tasks to log to a UDP port, stdout, and
* disk file without making any Win32 system calls themselves.
*
* Messages logged to a UDP port are sent directly (using FreeRTOS+TCP), but as
* FreeRTOS tasks cannot make Win32 system calls messages sent to stdout or a
* disk file are sent via a stream buffer to a Win32 thread which then performs
* the actual output.
*/
/* Standard includes. */
#include <stdio.h>
#include <stdint.h>
#include <stdarg.h>
#include <io.h>
#include <ctype.h>
/* FreeRTOS includes. */
FreeRTOS Windows Simulator Build Changes and LTS 2.0 Update (#872) * Update mbedtls to version v3.2.1 * Adjust include paths for github workflow * Update FreeRTOS+TCP to v3.1.0 * Add initial VS project files for Kernel, +TCP, and mbedtls * winpcap: Consolidate to a single copy of WinPcap * Downgrade library projects to VS 2019. Add heap_4 to kernel. * Remove *.vcxproj.user files and add to gitignore * Disable unwanted kernel config options * Update FreeRTOS+TCP and Kernel include paths * Update FreeRTOS+TCP Windows Minimal sln * Remove .suo and .vcxproj.user files * Update mbedtls transport implementations for mbedtls v3.2.1 * Fix typo in mbedtls_freertos_port.c * Update vcxproj files for +TCP, Kernel, Mbedtls * Fix typo in name WindowSimulator -> WindowsSimulator * Add wpcap lib to FreeRTOS+TCP.vcxproj * Update FreeRTOS+TCP Minimal Demo for Windows Simulator * Mask MSVC string function warnings Aad _CRT_SECURE_NO_WARNINGS preprocessor definition. * Move projects to their own directories to make VisualStudio happy * mbedtls_freertos_port.c: Fix formatting? * Add coreHTTP, Logging libs. Adjust dependencies * Disable FreeRTOS Kernel malloc failed hook * Update coreHTTP Plaintext demo * Rename / relocate transport interface implementations * Remove old VS project files * Remove extra core_http_config.h files * Remove extra FreeRTOSConfig.h files * Remove extra FreeRTOSIPConfig.h files * Remove old mbedtls_config.h files * Remove old FreeRTOSConfig and core_http_config files * Update HTTP Mutual Auth Demo build files * Fix transport_plaintext.h include name * Update HTTP_Plaintext demo build files * Update CoreHTTP_S3_Download VS project files * Update HTTP_S3_Upload demo build files * Update CoreHTTP_S3_Download_Multithreaded demo build files * Add GithubActions builds for FreeRTOS+ CoreHTTP Demos * Update S3DownloadHTTPExample.c to be compatible with mbedtls 3.x * Update GithubActions FreeRTOS+ config file * Combine core_pkcs11_config.h files into a single one * Add corePKCS11 VS project file * Update corePKCS11 WinSim demo project and build files * Update corePKCS11 library to version 3.5.0 * Modifiying demos to build using static libraries * Adding a header file * Two more demos * Update corePKCS11 demo code and auto-format * Downgrade corePKCS11 library build file to v142 / VS 2019 * Speed up CI builds with selective submodule initialization * Separate corePKCS11 demo into it's own job. * Remove WIN32.vcxproj and WIN32.vcxproj.filters files * Remove old configuration header files Partially reverts 73829ced6061e4584e521185178a61b4a437c5e0 * Revert unwanted coreHTTP demo changes * Changing include paths for demos * Adding an include * MQTT WoflSSL Demo update * wolfSSL Demo changes * Config changes for MQTT Demos * Initial Device Defender demo update. * Initial Device Shadow demo update. * Update mbedtls_transport_pkcs11 for Mbedtls 3.x * Update corePKCS11 MQTT Mutual Auth demo * Add a default definition of SdkLog * Update CorePKCS11 + MQTT Mutual Auth demo sln name * Build all configs of coreHTTP demos * Update coreSNTP Demo build files. * Update coreSNTP Demo sln name * Update FreeRTOS+TCP Posix demo * Update FreeRTOS+TCP Qemu ARM MPS2 AN385 Demo * Update FreeRTOS+TCP Demo Github Actions builds * Update Fleet Provisioning WinSim Demo build files * Remove mbedtls_pk_info_t references from mbedtls_pk_pkcs11.h * Restore / update the FreeRTOS+TCP Minimal WinSim demo * Initial Jobs demo update. * Fix jobs demo build. * Initial OTA over HTTP demo update. * Initial OTA over MQTT demo update. * Ota_Over_Mqtt_Demo build fix. * OTA over MQTT demo fix. * Update HTTP demo solution file name for CI. * Update Github actions workflow to old HTTP demo names. * Update coreSTNP demo to old solution name. * Fix defender demo / fix mbedtls config to use threading alt. * Add MBEDTLS_CONFIG_FILE definition to each config * Fix config file name. * MQTT Mutual auth fixes. * Fix job demo. * Device shadow demo fixes. * Fix coreSNTP demo not setting alt threading functions for mbedtls. * Enable Static allocation, Add default hooks for FreeRTOS Kernel and +TCP * Add xPlatformIsNetworkUp platform function to FreeRTOS+TCP hooks * Enable runtime statistics in the Windows Simualator Kernel config * Revert "Fix coreSNTP demo not setting alt threading functions for mbedtls." This reverts commit 9069707519561ca8136d58c0f18fb176c9050a1d. * Revert mbedtls threading related config changes * Add xPlatformIsNetworkUp function prototype * Remove boileplate FreeRTOS kernel and +tcp hooks * Refactor device defender demo for clarity * Add wait loop calling xPlatformIsNetworkUp * Add missing vPlatformInitLogging function * Add vPlatformInitLogging and vLoggingPrintf defitions to logging headers * Updating the FreeRTOS_Plus_CLI_with_Trace_Windows_Simulator * Updating the FreeRTOS_Plus_Reliance_Edge_and_CLI_Windows_Simulator demo * Updates to the FreeRTOS_Plus_WolfSSL_Windows_Simulator demo * Fixing wrong include path * Upating FreeRTOS_Plus_WolfSSL_FIPS_Ready_Windows_Simulator demo * Update coreMQTT WinSim demos to print start and end condition. * Modifiying repos updated as part of the CLI demo GitHub workflow * Removing duplicate functions from the FreeRTOS_Plus_TCP_Minimal_Windows_Simulator demo * Updated FreeRTOS_Plus_TCP_UDP_Mode_CLI_Windows_Simulator demo * Updating corePKCS11_MQTT_Mutual_Auth_Windows_Simulator Demo to call the static function that creates task * Fix log message using unitialized string in MQTT Multitask demo. * Fixing a broken extern function * Fixing a typo extern function name * Added a reference to coreHTTP * Fixing a pre-processor issue in the OTA_Over_Http_Demo * Updating the MQTT_Mutual_Auth_Demo_with_BG96 demo * Updating the MQTT_Mutual_Auth_Demo_with_HL7802 demo * Changes to the MQTT_Mutual_Auth_Demo_with_SARA_R4 demo * Fix demos for CI. * Adding the source path to the CBMC proofs for FreeRTOS+TCP * Spell check fixes, adding words to lexicons * Fixing a typo * Add arg to skip prompt in setup script. * Update paths of script to be relative to the file. * Changing manifest.yml file to point to corePKCS11 3.5.0 * Added CI markers to cellular demos. * Fix cellular demo flow. * Fix celullar demos. * Initial TCP sockets wrapper rework - will break things. * First cellular demo fix for new sockets wrapper. * Minor fix to cellular sockets wrapper. * Fix mbedtls bio using FreeRTOS Plus TCP call. * Clean up BG96 demo project files. * Update HL7802 demo. * Fix SARA R4 demo for new sockets wrapper. * Fix Device Defender, Device Shadow, and Fleet PRovisioning. * Fix Jobs demo. * Fix OTA over HTTP demo. * Fix OTA over MQTT demo. * Fix HTTP mutual auth demo. * Fix OTA over MQTT demo endianness. * Fix OTA over HTTP demo endianness. * Fix HTTP Plaintext demo. * Fix HTTP S3 download demo. * Fix plaintext transport * Fix OTA demos. * Fix OTA demos. * Fix OTA HTTP demo. * Fix HTTP S3 Download multithreaded demo. * Fix HTTP S3 Upload demo * Fix corePKCS11 Mutual Auth demo. * Updating MQTT_Mutual_Auth * Update pkcs11 setup script. * Updating the MQTT_Basic_TLS Demo * Organize PKCS11 demos project. * Updating MQTT_Keep_Alive demo * Clean up SNTP demo. * Updated MQTT_Multitask demo * Updated MQTT_Plain_Text * Updating the MQTT_Serializer Demo * Updating corePKCS11_MQTT_Mutual_Auth_Windows_Simulator * Updating coreSNTP_Windows_Simulator * Clean up demo projects. * Add markers to PKCS11 mutual auth demo. * Fix Fleet Provisioning demo script. * Fix SNTP demo solution. * Fix coreSNTP project files. * Fix Fleet Provisiong script. * Fix fleet provisioning script. * Fix demo config template. * Fleet provisioning demo markers. * Updating MQTT_Mutual_Auth_wolfSSL demo and the transport_wolfSSL file * Fixing FreeRTOS_Plus_TCP_Echo_POSIX * Fixing CLI and Trace Demos * Fixing TCP_ECHO_POSIX demo * Adding a word to the lexicon * Remove unneeded files. * Update github workflows to use Ubuntu 20.04. * Change OTA demo target names to RTOSDemo for OTAE2E tests. * Fixing Headers * Updating headers * Two more headers * Adding words to the lexicon * Whitepsace * Ignore mbedtls config file for header check. * Removing FreeRTOS Header from the mbedtls_config_v3.2.1.h file * Fix bug in lPKCS11PkMbedtlsCloseSessionAndFree. Add doxygen api docs. * Update lexicon.txt * Fix spelling * Apply suggestions from code review Co-authored-by: jasonpcarroll <23126711+jasonpcarroll@users.noreply.github.com> * Add return code comment for p11_ecdsa_ctx_init * Rename WindowsSimulator folder to VisualStudio_StaticProjects. * Remove references to coroutines * Fix mbedtls_pk_pkcs11.c * Update to LTS 2.0 submodule pointers (#880) * Update submodule pointers to LTS 2.0 * Initial coreMQTT 2.1.1 update. * Update AWS demos for coreMQTT 2.1.1 * Fix deprecated macro for coreMQTT demos. * Fix keep alive demo. * Fix plaintext demo. * Fix MQTT wolfSSL demo. * Fix MQTT PKCS11 demo. * Remove duplicate functions. * Fix Mutual auth demos for Cellular. * Fix OTA demos. * Fix header of plaintext demo config. * Set writev to NULL for OTA demos. * Fix mbedlts config for OTA demos. * Fix spelling. Co-authored-by: Jason Carroll <czjaso@amazon.com> * Removing blank line * Fix jobs demo race condition. * Fix race condition from WinPCap network interface. * Update lexicon. Co-authored-by: Paul Bartell <pbartell@amazon.com> Co-authored-by: Jason Carroll <czjaso@amazon.com> Co-authored-by: Paul Bartell <paul.bartell@gmail.com> Co-authored-by: jasonpcarroll <23126711+jasonpcarroll@users.noreply.github.com>
2 years ago
#include "FreeRTOS.h"
#include "task.h"
/* FreeRTOS+TCP includes. */
#include "FreeRTOS_IP.h"
#include "FreeRTOS_Sockets.h"
#include "FreeRTOS_Stream_Buffer.h"
/* Demo includes. */
#include "logging.h"
/*-----------------------------------------------------------*/
/* The maximum size to which the log file may grow, before being renamed
* to .ful. */
#define dlLOGGING_FILE_SIZE ( 40ul * 1024ul * 1024ul )
/* Dimensions the arrays into which print messages are created. */
#define dlMAX_PRINT_STRING_LENGTH 255
/* The size of the stream buffer used to pass messages from FreeRTOS tasks to
* the Win32 thread that is responsible for making any Win32 system calls that are
* necessary for the selected logging method. */
#define dlLOGGING_STREAM_BUFFER_SIZE 32768
/* A block time of zero simply means don't block. */
#define dlDONT_BLOCK 0
/*-----------------------------------------------------------*/
/*
* Called from vLoggingInit() to start a new disk log file.
*/
static void prvFileLoggingInit( void );
/*
* Attempt to write a message to the file.
*/
static void prvLogToFile( const char * pcMessage,
size_t xLength );
/*
* Simply close the logging file, if it is open.
*/
static void prvFileClose( void );
/*
* Before the scheduler is started this function is called directly. After the
* scheduler has started it is called from the Windows thread dedicated to
* outputting log messages. Only the windows thread actually performs the
* writing so as not to disrupt the simulation by making Windows system calls
* from FreeRTOS tasks.
*/
static void prvLoggingFlushBuffer( void );
/*
* The windows thread that performs the actual writing of messages that require
* Win32 system calls. Only the windows thread can make system calls so as not
* to disrupt the simulation by making Windows calls from FreeRTOS tasks.
*/
static DWORD WINAPI prvWin32LoggingThread( void * pvParam );
/*
* Creates the socket to which UDP messages are sent. This function is not
* called directly to prevent the print socket being created from within the IP
* task - which could result in a deadlock. Instead the function call is
* deferred to run in the RTOS daemon task - hence it prototype.
*/
static void prvCreatePrintSocket( void * pvParameter1,
uint32_t ulParameter2 );
/*-----------------------------------------------------------*/
/* Windows event used to wake the Win32 thread which performs any logging that
* needs Win32 system calls. */
static void * pvLoggingThreadEvent = NULL;
/* Stores the selected logging targets passed in as parameters to the
* vLoggingInit() function. */
BaseType_t xStdoutLoggingUsed = pdFALSE, xDiskFileLoggingUsed = pdFALSE, xUDPLoggingUsed = pdFALSE;
/* Circular buffer used to pass messages from the FreeRTOS tasks to the Win32
* thread that is responsible for making Win32 calls (when stdout or a disk log is
* used). */
static StreamBuffer_t * xLogStreamBuffer = NULL;
/* Handle to the file used for logging. This is left open while there are
* messages waiting to be logged, then closed again in between logs. */
static FILE * pxLoggingFileHandle = NULL;
/* When true prints are performed directly. After start up xDirectPrint is set
* to pdFALSE - at which time prints that require Win32 system calls are done by
* the Win32 thread responsible for logging. */
BaseType_t xDirectPrint = pdTRUE;
/* File names for the in use and complete (full) log files. */
static const char * pcLogFileName = "RTOSDemo.log";
static const char * pcFullLogFileName = "RTOSDemo.ful";
/* As an optimization, the current file size is kept in a variable. */
static size_t ulSizeOfLoggingFile = 0ul;
/* The UDP socket and address on/to which print messages are sent. */
Socket_t xPrintSocket = FREERTOS_INVALID_SOCKET;
struct freertos_sockaddr xPrintUDPAddress;
/*-----------------------------------------------------------*/
void vLoggingInit( BaseType_t xLogToStdout,
BaseType_t xLogToFile,
BaseType_t xLogToUDP,
uint32_t ulRemoteIPAddress,
uint16_t usRemotePort )
{
/* Can only be called before the scheduler has started. */
configASSERT( xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED );
#if ( ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) )
{
HANDLE Win32Thread;
/* Record which output methods are to be used. */
xStdoutLoggingUsed = xLogToStdout;
xDiskFileLoggingUsed = xLogToFile;
xUDPLoggingUsed = xLogToUDP;
/* If a disk file is used then initialize it now. */
if( xDiskFileLoggingUsed != pdFALSE )
{
prvFileLoggingInit();
}
/* If UDP logging is used then store the address to which the log data
* will be sent - but don't create the socket yet because the network is
* not initialized. */
if( xUDPLoggingUsed != pdFALSE )
{
/* Set the address to which the print messages are sent. */
xPrintUDPAddress.sin_port = FreeRTOS_htons( usRemotePort );
#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 )
{
xPrintUDPAddress.sin_address.ulIP_IPv4 = ulRemoteIPAddress;
}
#else
{
xPrintUDPAddress.sin_addr = ulRemoteIPAddress;
}
#endif /* defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 ) */
xPrintUDPAddress.sin_family = FREERTOS_AF_INET;
}
/* If a disk file or stdout are to be used then Win32 system calls will
* have to be made. Such system calls cannot be made from FreeRTOS tasks
* so create a stream buffer to pass the messages to a Win32 thread, then
* create the thread itself, along with a Win32 event that can be used to
* unblock the thread. */
if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) )
{
/* Create the buffer. */
xLogStreamBuffer = ( StreamBuffer_t * ) malloc( sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) + dlLOGGING_STREAM_BUFFER_SIZE + 1 );
configASSERT( xLogStreamBuffer );
memset( xLogStreamBuffer, '\0', sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) );
xLogStreamBuffer->LENGTH = dlLOGGING_STREAM_BUFFER_SIZE + 1;
/* Create the Windows event. */
pvLoggingThreadEvent = CreateEvent( NULL, FALSE, TRUE, "StdoutLoggingEvent" );
/* Create the thread itself. */
Win32Thread = CreateThread(
NULL, /* Pointer to thread security attributes. */
0, /* Initial thread stack size, in bytes. */
prvWin32LoggingThread, /* Pointer to thread function. */
NULL, /* Argument for new thread. */
0, /* Creation flags. */
NULL );
/* Use the cores that are not used by the FreeRTOS tasks. */
SetThreadAffinityMask( Win32Thread, ~0x01u );
SetThreadPriorityBoost( Win32Thread, TRUE );
SetThreadPriority( Win32Thread, THREAD_PRIORITY_IDLE );
}
}
#else /* if ( ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) ) */
{
/* FreeRTOSIPConfig is set such that no print messages will be output.
* Avoid compiler warnings about unused parameters. */
( void ) xLogToStdout;
( void ) xLogToFile;
( void ) xLogToUDP;
( void ) usRemotePort;
( void ) ulRemoteIPAddress;
}
#endif /* ( ipconfigHAS_DEBUG_PRINTF == 1 ) || ( ipconfigHAS_PRINTF == 1 ) */
}
/*-----------------------------------------------------------*/
static void prvCreatePrintSocket( void * pvParameter1,
uint32_t ulParameter2 )
{
static const TickType_t xSendTimeOut = pdMS_TO_TICKS( 0 );
Socket_t xSocket;
/* The function prototype is that of a deferred function, but the parameters
* are not actually used. */
( void ) pvParameter1;
( void ) ulParameter2;
xSocket = FreeRTOS_socket( FREERTOS_AF_INET, FREERTOS_SOCK_DGRAM, FREERTOS_IPPROTO_UDP );
if( xSocket != FREERTOS_INVALID_SOCKET )
{
/* FreeRTOS+TCP decides which port to bind to. */
FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_SNDTIMEO, &xSendTimeOut, sizeof( xSendTimeOut ) );
FreeRTOS_bind( xSocket, NULL, 0 );
/* Now the socket is bound it can be assigned to the print socket. */
xPrintSocket = xSocket;
}
}
/*-----------------------------------------------------------*/
void vLoggingPrintf( const char * pcFormat,
... )
{
char cPrintString[ dlMAX_PRINT_STRING_LENGTH ];
char cOutputString[ dlMAX_PRINT_STRING_LENGTH ];
char * pcSource, * pcTarget, * pcBegin;
size_t xLength, xLength2, rc;
static BaseType_t xMessageNumber = 0;
static BaseType_t xAfterLineBreak = pdTRUE;
va_list args;
uint32_t ulIPAddress;
const char * pcTaskName;
const char * pcNoTask = "None";
int iOriginalPriority;
HANDLE xCurrentTask;
if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) || ( xUDPLoggingUsed != pdFALSE ) )
{
/* There are a variable number of parameters. */
va_start( args, pcFormat );
/* Additional info to place at the start of the log. */
if( xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED )
{
pcTaskName = pcTaskGetName( NULL );
}
else
{
pcTaskName = pcNoTask;
}
if( ( xAfterLineBreak == pdTRUE ) && ( strcmp( pcFormat, "\r\n" ) != 0 ) )
{
xLength = snprintf( cPrintString, dlMAX_PRINT_STRING_LENGTH, "%lu %lu [%s] ",
xMessageNumber++,
( unsigned long ) xTaskGetTickCount(),
pcTaskName );
xAfterLineBreak = pdFALSE;
}
else
{
xLength = 0;
memset( cPrintString, 0x00, dlMAX_PRINT_STRING_LENGTH );
xAfterLineBreak = pdTRUE;
}
xLength2 = vsnprintf( cPrintString + xLength, dlMAX_PRINT_STRING_LENGTH - xLength, pcFormat, args );
if( xLength2 < 0 )
{
/* Clean up. */
xLength2 = dlMAX_PRINT_STRING_LENGTH - 1 - xLength;
cPrintString[ dlMAX_PRINT_STRING_LENGTH - 1 ] = '\0';
}
xLength += xLength2;
va_end( args );
/* For ease of viewing, copy the string into another buffer, converting
* IP addresses to dot notation on the way. */
pcSource = cPrintString;
pcTarget = cOutputString;
while( ( *pcSource ) != '\0' )
{
*pcTarget = *pcSource;
pcTarget++;
pcSource++;
/* Look forward for an IP address denoted by 'ip'. */
if( ( isxdigit( pcSource[ 0 ] ) != pdFALSE ) && ( pcSource[ 1 ] == 'i' ) && ( pcSource[ 2 ] == 'p' ) )
{
*pcTarget = *pcSource;
pcTarget++;
*pcTarget = '\0';
pcBegin = pcTarget - 8;
while( ( pcTarget > pcBegin ) && ( isxdigit( pcTarget[ -1 ] ) != pdFALSE ) )
{
pcTarget--;
}
sscanf( pcTarget, "%8X", &ulIPAddress );
rc = sprintf( pcTarget, "%lu.%lu.%lu.%lu",
( unsigned long ) ( ulIPAddress >> 24UL ),
( unsigned long ) ( ( ulIPAddress >> 16UL ) & 0xffUL ),
( unsigned long ) ( ( ulIPAddress >> 8UL ) & 0xffUL ),
( unsigned long ) ( ulIPAddress & 0xffUL ) );
pcTarget += rc;
pcSource += 3; /* skip "<n>ip" */
}
}
/* How far through the buffer was written? */
xLength = ( BaseType_t ) ( pcTarget - cOutputString );
/* If the message is to be logged to a UDP port then it can be sent directly
* because it only uses FreeRTOS function (not Win32 functions). */
if( xUDPLoggingUsed != pdFALSE )
{
if( ( xPrintSocket == FREERTOS_INVALID_SOCKET ) && ( FreeRTOS_IsNetworkUp() != pdFALSE ) )
{
/* Create and bind the socket to which print messages are sent. The
* xTimerPendFunctionCall() function is used even though this is
* not an interrupt because this function is called from the IP task
* and the IP task cannot itself wait for a socket to bind. The
* parameters to prvCreatePrintSocket() are not required so set to
* NULL or 0. */
xTimerPendFunctionCall( prvCreatePrintSocket, NULL, 0, dlDONT_BLOCK );
}
if( xPrintSocket != FREERTOS_INVALID_SOCKET )
{
FreeRTOS_sendto( xPrintSocket, cOutputString, xLength, 0, &xPrintUDPAddress, sizeof( xPrintUDPAddress ) );
/* Just because the UDP data logger I'm using is dumb. */
FreeRTOS_sendto( xPrintSocket, "\r", sizeof( char ), 0, &xPrintUDPAddress, sizeof( xPrintUDPAddress ) );
}
}
/* If logging is also to go to either stdout or a disk file then it cannot
* be output here - so instead write the message to the stream buffer and wake
* the Win32 thread which will read it from the stream buffer and perform the
* actual output. */
if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) )
{
configASSERT( xLogStreamBuffer );
/* How much space is in the buffer? */
xLength2 = uxStreamBufferGetSpace( xLogStreamBuffer );
/* There must be enough space to write both the string and the length of
* the string. */
if( xLength2 >= ( xLength + sizeof( xLength ) ) )
{
/* First write in the length of the data, then write in the data
* itself. Raising the thread priority is used as a critical section
* as there are potentially multiple writers. The stream buffer is
* only thread safe when there is a single writer (likewise for
* reading from the buffer). */
xCurrentTask = GetCurrentThread();
iOriginalPriority = GetThreadPriority( xCurrentTask );
SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL );
uxStreamBufferAdd( xLogStreamBuffer, 0, ( const uint8_t * ) &( xLength ), sizeof( xLength ) );
uxStreamBufferAdd( xLogStreamBuffer, 0, ( const uint8_t * ) cOutputString, xLength );
SetThreadPriority( GetCurrentThread(), iOriginalPriority );
}
/* xDirectPrint is initialized to pdTRUE, and while it remains true the
* logging output function is called directly. When the system is running
* the output function cannot be called directly because it would get
* called from both FreeRTOS tasks and Win32 threads - so instead wake the
* Win32 thread responsible for the actual output. */
if( xDirectPrint != pdFALSE )
{
/* While starting up, the thread which calls prvWin32LoggingThread()
* is not running yet and xDirectPrint will be pdTRUE. */
prvLoggingFlushBuffer();
}
else if( pvLoggingThreadEvent != NULL )
{
/* While running, wake up prvWin32LoggingThread() to send the
* logging data. */
SetEvent( pvLoggingThreadEvent );
}
}
}
}
/*-----------------------------------------------------------*/
static void prvLoggingFlushBuffer( void )
{
size_t xLength;
char cPrintString[ dlMAX_PRINT_STRING_LENGTH ];
/* Is there more than the length value stored in the circular buffer
* used to pass data from the FreeRTOS simulator into this Win32 thread? */
while( uxStreamBufferGetSize( xLogStreamBuffer ) > sizeof( xLength ) )
{
memset( cPrintString, 0x00, dlMAX_PRINT_STRING_LENGTH );
uxStreamBufferGet( xLogStreamBuffer, 0, ( uint8_t * ) &xLength, sizeof( xLength ), pdFALSE );
uxStreamBufferGet( xLogStreamBuffer, 0, ( uint8_t * ) cPrintString, xLength, pdFALSE );
/* Write the message to standard out if requested to do so when
* vLoggingInit() was called, or if the network is not yet up. */
if( ( xStdoutLoggingUsed != pdFALSE ) || ( FreeRTOS_IsNetworkUp() == pdFALSE ) )
{
/* Write the message to stdout. */
_write( _fileno( stdout ), cPrintString, strlen( cPrintString ) );
}
/* Write the message to a file if requested to do so when
* vLoggingInit() was called. */
if( xDiskFileLoggingUsed != pdFALSE )
{
prvLogToFile( cPrintString, xLength );
}
}
prvFileClose();
}
/*-----------------------------------------------------------*/
static DWORD WINAPI prvWin32LoggingThread( void * pvParameter )
{
const DWORD xMaxWait = 1000;
( void ) pvParameter;
/* From now on, prvLoggingFlushBuffer() will only be called from this
* Windows thread */
xDirectPrint = pdFALSE;
for( ; ; )
{
/* Wait to be told there are message waiting to be logged. */
WaitForSingleObject( pvLoggingThreadEvent, xMaxWait );
/* Write out all waiting messages. */
prvLoggingFlushBuffer();
}
}
/*-----------------------------------------------------------*/
static void prvFileLoggingInit( void )
{
FILE * pxHandle = fopen( pcLogFileName, "a" );
if( pxHandle != NULL )
{
fseek( pxHandle, SEEK_END, 0ul );
ulSizeOfLoggingFile = ftell( pxHandle );
fclose( pxHandle );
}
else
{
ulSizeOfLoggingFile = 0ul;
}
}
/*-----------------------------------------------------------*/
static void prvFileClose( void )
{
if( pxLoggingFileHandle != NULL )
{
fclose( pxLoggingFileHandle );
pxLoggingFileHandle = NULL;
}
}
/*-----------------------------------------------------------*/
static void prvLogToFile( const char * pcMessage,
size_t xLength )
{
if( pxLoggingFileHandle == NULL )
{
pxLoggingFileHandle = fopen( pcLogFileName, "a" );
}
if( pxLoggingFileHandle != NULL )
{
fwrite( pcMessage, 1, xLength, pxLoggingFileHandle );
ulSizeOfLoggingFile += xLength;
/* If the file has grown to its maximum permissible size then close and
* rename it - then start with a new file. */
if( ulSizeOfLoggingFile > ( size_t ) dlLOGGING_FILE_SIZE )
{
prvFileClose();
if( _access( pcFullLogFileName, 00 ) == 0 )
{
remove( pcFullLogFileName );
}
rename( pcLogFileName, pcFullLogFileName );
ulSizeOfLoggingFile = 0;
}
}
}
/*-----------------------------------------------------------*/
FreeRTOS Windows Simulator Build Changes and LTS 2.0 Update (#872) * Update mbedtls to version v3.2.1 * Adjust include paths for github workflow * Update FreeRTOS+TCP to v3.1.0 * Add initial VS project files for Kernel, +TCP, and mbedtls * winpcap: Consolidate to a single copy of WinPcap * Downgrade library projects to VS 2019. Add heap_4 to kernel. * Remove *.vcxproj.user files and add to gitignore * Disable unwanted kernel config options * Update FreeRTOS+TCP and Kernel include paths * Update FreeRTOS+TCP Windows Minimal sln * Remove .suo and .vcxproj.user files * Update mbedtls transport implementations for mbedtls v3.2.1 * Fix typo in mbedtls_freertos_port.c * Update vcxproj files for +TCP, Kernel, Mbedtls * Fix typo in name WindowSimulator -> WindowsSimulator * Add wpcap lib to FreeRTOS+TCP.vcxproj * Update FreeRTOS+TCP Minimal Demo for Windows Simulator * Mask MSVC string function warnings Aad _CRT_SECURE_NO_WARNINGS preprocessor definition. * Move projects to their own directories to make VisualStudio happy * mbedtls_freertos_port.c: Fix formatting? * Add coreHTTP, Logging libs. Adjust dependencies * Disable FreeRTOS Kernel malloc failed hook * Update coreHTTP Plaintext demo * Rename / relocate transport interface implementations * Remove old VS project files * Remove extra core_http_config.h files * Remove extra FreeRTOSConfig.h files * Remove extra FreeRTOSIPConfig.h files * Remove old mbedtls_config.h files * Remove old FreeRTOSConfig and core_http_config files * Update HTTP Mutual Auth Demo build files * Fix transport_plaintext.h include name * Update HTTP_Plaintext demo build files * Update CoreHTTP_S3_Download VS project files * Update HTTP_S3_Upload demo build files * Update CoreHTTP_S3_Download_Multithreaded demo build files * Add GithubActions builds for FreeRTOS+ CoreHTTP Demos * Update S3DownloadHTTPExample.c to be compatible with mbedtls 3.x * Update GithubActions FreeRTOS+ config file * Combine core_pkcs11_config.h files into a single one * Add corePKCS11 VS project file * Update corePKCS11 WinSim demo project and build files * Update corePKCS11 library to version 3.5.0 * Modifiying demos to build using static libraries * Adding a header file * Two more demos * Update corePKCS11 demo code and auto-format * Downgrade corePKCS11 library build file to v142 / VS 2019 * Speed up CI builds with selective submodule initialization * Separate corePKCS11 demo into it's own job. * Remove WIN32.vcxproj and WIN32.vcxproj.filters files * Remove old configuration header files Partially reverts 73829ced6061e4584e521185178a61b4a437c5e0 * Revert unwanted coreHTTP demo changes * Changing include paths for demos * Adding an include * MQTT WoflSSL Demo update * wolfSSL Demo changes * Config changes for MQTT Demos * Initial Device Defender demo update. * Initial Device Shadow demo update. * Update mbedtls_transport_pkcs11 for Mbedtls 3.x * Update corePKCS11 MQTT Mutual Auth demo * Add a default definition of SdkLog * Update CorePKCS11 + MQTT Mutual Auth demo sln name * Build all configs of coreHTTP demos * Update coreSNTP Demo build files. * Update coreSNTP Demo sln name * Update FreeRTOS+TCP Posix demo * Update FreeRTOS+TCP Qemu ARM MPS2 AN385 Demo * Update FreeRTOS+TCP Demo Github Actions builds * Update Fleet Provisioning WinSim Demo build files * Remove mbedtls_pk_info_t references from mbedtls_pk_pkcs11.h * Restore / update the FreeRTOS+TCP Minimal WinSim demo * Initial Jobs demo update. * Fix jobs demo build. * Initial OTA over HTTP demo update. * Initial OTA over MQTT demo update. * Ota_Over_Mqtt_Demo build fix. * OTA over MQTT demo fix. * Update HTTP demo solution file name for CI. * Update Github actions workflow to old HTTP demo names. * Update coreSTNP demo to old solution name. * Fix defender demo / fix mbedtls config to use threading alt. * Add MBEDTLS_CONFIG_FILE definition to each config * Fix config file name. * MQTT Mutual auth fixes. * Fix job demo. * Device shadow demo fixes. * Fix coreSNTP demo not setting alt threading functions for mbedtls. * Enable Static allocation, Add default hooks for FreeRTOS Kernel and +TCP * Add xPlatformIsNetworkUp platform function to FreeRTOS+TCP hooks * Enable runtime statistics in the Windows Simualator Kernel config * Revert "Fix coreSNTP demo not setting alt threading functions for mbedtls." This reverts commit 9069707519561ca8136d58c0f18fb176c9050a1d. * Revert mbedtls threading related config changes * Add xPlatformIsNetworkUp function prototype * Remove boileplate FreeRTOS kernel and +tcp hooks * Refactor device defender demo for clarity * Add wait loop calling xPlatformIsNetworkUp * Add missing vPlatformInitLogging function * Add vPlatformInitLogging and vLoggingPrintf defitions to logging headers * Updating the FreeRTOS_Plus_CLI_with_Trace_Windows_Simulator * Updating the FreeRTOS_Plus_Reliance_Edge_and_CLI_Windows_Simulator demo * Updates to the FreeRTOS_Plus_WolfSSL_Windows_Simulator demo * Fixing wrong include path * Upating FreeRTOS_Plus_WolfSSL_FIPS_Ready_Windows_Simulator demo * Update coreMQTT WinSim demos to print start and end condition. * Modifiying repos updated as part of the CLI demo GitHub workflow * Removing duplicate functions from the FreeRTOS_Plus_TCP_Minimal_Windows_Simulator demo * Updated FreeRTOS_Plus_TCP_UDP_Mode_CLI_Windows_Simulator demo * Updating corePKCS11_MQTT_Mutual_Auth_Windows_Simulator Demo to call the static function that creates task * Fix log message using unitialized string in MQTT Multitask demo. * Fixing a broken extern function * Fixing a typo extern function name * Added a reference to coreHTTP * Fixing a pre-processor issue in the OTA_Over_Http_Demo * Updating the MQTT_Mutual_Auth_Demo_with_BG96 demo * Updating the MQTT_Mutual_Auth_Demo_with_HL7802 demo * Changes to the MQTT_Mutual_Auth_Demo_with_SARA_R4 demo * Fix demos for CI. * Adding the source path to the CBMC proofs for FreeRTOS+TCP * Spell check fixes, adding words to lexicons * Fixing a typo * Add arg to skip prompt in setup script. * Update paths of script to be relative to the file. * Changing manifest.yml file to point to corePKCS11 3.5.0 * Added CI markers to cellular demos. * Fix cellular demo flow. * Fix celullar demos. * Initial TCP sockets wrapper rework - will break things. * First cellular demo fix for new sockets wrapper. * Minor fix to cellular sockets wrapper. * Fix mbedtls bio using FreeRTOS Plus TCP call. * Clean up BG96 demo project files. * Update HL7802 demo. * Fix SARA R4 demo for new sockets wrapper. * Fix Device Defender, Device Shadow, and Fleet PRovisioning. * Fix Jobs demo. * Fix OTA over HTTP demo. * Fix OTA over MQTT demo. * Fix HTTP mutual auth demo. * Fix OTA over MQTT demo endianness. * Fix OTA over HTTP demo endianness. * Fix HTTP Plaintext demo. * Fix HTTP S3 download demo. * Fix plaintext transport * Fix OTA demos. * Fix OTA demos. * Fix OTA HTTP demo. * Fix HTTP S3 Download multithreaded demo. * Fix HTTP S3 Upload demo * Fix corePKCS11 Mutual Auth demo. * Updating MQTT_Mutual_Auth * Update pkcs11 setup script. * Updating the MQTT_Basic_TLS Demo * Organize PKCS11 demos project. * Updating MQTT_Keep_Alive demo * Clean up SNTP demo. * Updated MQTT_Multitask demo * Updated MQTT_Plain_Text * Updating the MQTT_Serializer Demo * Updating corePKCS11_MQTT_Mutual_Auth_Windows_Simulator * Updating coreSNTP_Windows_Simulator * Clean up demo projects. * Add markers to PKCS11 mutual auth demo. * Fix Fleet Provisioning demo script. * Fix SNTP demo solution. * Fix coreSNTP project files. * Fix Fleet Provisiong script. * Fix fleet provisioning script. * Fix demo config template. * Fleet provisioning demo markers. * Updating MQTT_Mutual_Auth_wolfSSL demo and the transport_wolfSSL file * Fixing FreeRTOS_Plus_TCP_Echo_POSIX * Fixing CLI and Trace Demos * Fixing TCP_ECHO_POSIX demo * Adding a word to the lexicon * Remove unneeded files. * Update github workflows to use Ubuntu 20.04. * Change OTA demo target names to RTOSDemo for OTAE2E tests. * Fixing Headers * Updating headers * Two more headers * Adding words to the lexicon * Whitepsace * Ignore mbedtls config file for header check. * Removing FreeRTOS Header from the mbedtls_config_v3.2.1.h file * Fix bug in lPKCS11PkMbedtlsCloseSessionAndFree. Add doxygen api docs. * Update lexicon.txt * Fix spelling * Apply suggestions from code review Co-authored-by: jasonpcarroll <23126711+jasonpcarroll@users.noreply.github.com> * Add return code comment for p11_ecdsa_ctx_init * Rename WindowsSimulator folder to VisualStudio_StaticProjects. * Remove references to coroutines * Fix mbedtls_pk_pkcs11.c * Update to LTS 2.0 submodule pointers (#880) * Update submodule pointers to LTS 2.0 * Initial coreMQTT 2.1.1 update. * Update AWS demos for coreMQTT 2.1.1 * Fix deprecated macro for coreMQTT demos. * Fix keep alive demo. * Fix plaintext demo. * Fix MQTT wolfSSL demo. * Fix MQTT PKCS11 demo. * Remove duplicate functions. * Fix Mutual auth demos for Cellular. * Fix OTA demos. * Fix header of plaintext demo config. * Set writev to NULL for OTA demos. * Fix mbedlts config for OTA demos. * Fix spelling. Co-authored-by: Jason Carroll <czjaso@amazon.com> * Removing blank line * Fix jobs demo race condition. * Fix race condition from WinPCap network interface. * Update lexicon. Co-authored-by: Paul Bartell <pbartell@amazon.com> Co-authored-by: Jason Carroll <czjaso@amazon.com> Co-authored-by: Paul Bartell <paul.bartell@gmail.com> Co-authored-by: jasonpcarroll <23126711+jasonpcarroll@users.noreply.github.com>
2 years ago
void vPlatformInitLogging( void )
FreeRTOS Windows Simulator Build Changes and LTS 2.0 Update (#872) * Update mbedtls to version v3.2.1 * Adjust include paths for github workflow * Update FreeRTOS+TCP to v3.1.0 * Add initial VS project files for Kernel, +TCP, and mbedtls * winpcap: Consolidate to a single copy of WinPcap * Downgrade library projects to VS 2019. Add heap_4 to kernel. * Remove *.vcxproj.user files and add to gitignore * Disable unwanted kernel config options * Update FreeRTOS+TCP and Kernel include paths * Update FreeRTOS+TCP Windows Minimal sln * Remove .suo and .vcxproj.user files * Update mbedtls transport implementations for mbedtls v3.2.1 * Fix typo in mbedtls_freertos_port.c * Update vcxproj files for +TCP, Kernel, Mbedtls * Fix typo in name WindowSimulator -> WindowsSimulator * Add wpcap lib to FreeRTOS+TCP.vcxproj * Update FreeRTOS+TCP Minimal Demo for Windows Simulator * Mask MSVC string function warnings Aad _CRT_SECURE_NO_WARNINGS preprocessor definition. * Move projects to their own directories to make VisualStudio happy * mbedtls_freertos_port.c: Fix formatting? * Add coreHTTP, Logging libs. Adjust dependencies * Disable FreeRTOS Kernel malloc failed hook * Update coreHTTP Plaintext demo * Rename / relocate transport interface implementations * Remove old VS project files * Remove extra core_http_config.h files * Remove extra FreeRTOSConfig.h files * Remove extra FreeRTOSIPConfig.h files * Remove old mbedtls_config.h files * Remove old FreeRTOSConfig and core_http_config files * Update HTTP Mutual Auth Demo build files * Fix transport_plaintext.h include name * Update HTTP_Plaintext demo build files * Update CoreHTTP_S3_Download VS project files * Update HTTP_S3_Upload demo build files * Update CoreHTTP_S3_Download_Multithreaded demo build files * Add GithubActions builds for FreeRTOS+ CoreHTTP Demos * Update S3DownloadHTTPExample.c to be compatible with mbedtls 3.x * Update GithubActions FreeRTOS+ config file * Combine core_pkcs11_config.h files into a single one * Add corePKCS11 VS project file * Update corePKCS11 WinSim demo project and build files * Update corePKCS11 library to version 3.5.0 * Modifiying demos to build using static libraries * Adding a header file * Two more demos * Update corePKCS11 demo code and auto-format * Downgrade corePKCS11 library build file to v142 / VS 2019 * Speed up CI builds with selective submodule initialization * Separate corePKCS11 demo into it's own job. * Remove WIN32.vcxproj and WIN32.vcxproj.filters files * Remove old configuration header files Partially reverts 73829ced6061e4584e521185178a61b4a437c5e0 * Revert unwanted coreHTTP demo changes * Changing include paths for demos * Adding an include * MQTT WoflSSL Demo update * wolfSSL Demo changes * Config changes for MQTT Demos * Initial Device Defender demo update. * Initial Device Shadow demo update. * Update mbedtls_transport_pkcs11 for Mbedtls 3.x * Update corePKCS11 MQTT Mutual Auth demo * Add a default definition of SdkLog * Update CorePKCS11 + MQTT Mutual Auth demo sln name * Build all configs of coreHTTP demos * Update coreSNTP Demo build files. * Update coreSNTP Demo sln name * Update FreeRTOS+TCP Posix demo * Update FreeRTOS+TCP Qemu ARM MPS2 AN385 Demo * Update FreeRTOS+TCP Demo Github Actions builds * Update Fleet Provisioning WinSim Demo build files * Remove mbedtls_pk_info_t references from mbedtls_pk_pkcs11.h * Restore / update the FreeRTOS+TCP Minimal WinSim demo * Initial Jobs demo update. * Fix jobs demo build. * Initial OTA over HTTP demo update. * Initial OTA over MQTT demo update. * Ota_Over_Mqtt_Demo build fix. * OTA over MQTT demo fix. * Update HTTP demo solution file name for CI. * Update Github actions workflow to old HTTP demo names. * Update coreSTNP demo to old solution name. * Fix defender demo / fix mbedtls config to use threading alt. * Add MBEDTLS_CONFIG_FILE definition to each config * Fix config file name. * MQTT Mutual auth fixes. * Fix job demo. * Device shadow demo fixes. * Fix coreSNTP demo not setting alt threading functions for mbedtls. * Enable Static allocation, Add default hooks for FreeRTOS Kernel and +TCP * Add xPlatformIsNetworkUp platform function to FreeRTOS+TCP hooks * Enable runtime statistics in the Windows Simualator Kernel config * Revert "Fix coreSNTP demo not setting alt threading functions for mbedtls." This reverts commit 9069707519561ca8136d58c0f18fb176c9050a1d. * Revert mbedtls threading related config changes * Add xPlatformIsNetworkUp function prototype * Remove boileplate FreeRTOS kernel and +tcp hooks * Refactor device defender demo for clarity * Add wait loop calling xPlatformIsNetworkUp * Add missing vPlatformInitLogging function * Add vPlatformInitLogging and vLoggingPrintf defitions to logging headers * Updating the FreeRTOS_Plus_CLI_with_Trace_Windows_Simulator * Updating the FreeRTOS_Plus_Reliance_Edge_and_CLI_Windows_Simulator demo * Updates to the FreeRTOS_Plus_WolfSSL_Windows_Simulator demo * Fixing wrong include path * Upating FreeRTOS_Plus_WolfSSL_FIPS_Ready_Windows_Simulator demo * Update coreMQTT WinSim demos to print start and end condition. * Modifiying repos updated as part of the CLI demo GitHub workflow * Removing duplicate functions from the FreeRTOS_Plus_TCP_Minimal_Windows_Simulator demo * Updated FreeRTOS_Plus_TCP_UDP_Mode_CLI_Windows_Simulator demo * Updating corePKCS11_MQTT_Mutual_Auth_Windows_Simulator Demo to call the static function that creates task * Fix log message using unitialized string in MQTT Multitask demo. * Fixing a broken extern function * Fixing a typo extern function name * Added a reference to coreHTTP * Fixing a pre-processor issue in the OTA_Over_Http_Demo * Updating the MQTT_Mutual_Auth_Demo_with_BG96 demo * Updating the MQTT_Mutual_Auth_Demo_with_HL7802 demo * Changes to the MQTT_Mutual_Auth_Demo_with_SARA_R4 demo * Fix demos for CI. * Adding the source path to the CBMC proofs for FreeRTOS+TCP * Spell check fixes, adding words to lexicons * Fixing a typo * Add arg to skip prompt in setup script. * Update paths of script to be relative to the file. * Changing manifest.yml file to point to corePKCS11 3.5.0 * Added CI markers to cellular demos. * Fix cellular demo flow. * Fix celullar demos. * Initial TCP sockets wrapper rework - will break things. * First cellular demo fix for new sockets wrapper. * Minor fix to cellular sockets wrapper. * Fix mbedtls bio using FreeRTOS Plus TCP call. * Clean up BG96 demo project files. * Update HL7802 demo. * Fix SARA R4 demo for new sockets wrapper. * Fix Device Defender, Device Shadow, and Fleet PRovisioning. * Fix Jobs demo. * Fix OTA over HTTP demo. * Fix OTA over MQTT demo. * Fix HTTP mutual auth demo. * Fix OTA over MQTT demo endianness. * Fix OTA over HTTP demo endianness. * Fix HTTP Plaintext demo. * Fix HTTP S3 download demo. * Fix plaintext transport * Fix OTA demos. * Fix OTA demos. * Fix OTA HTTP demo. * Fix HTTP S3 Download multithreaded demo. * Fix HTTP S3 Upload demo * Fix corePKCS11 Mutual Auth demo. * Updating MQTT_Mutual_Auth * Update pkcs11 setup script. * Updating the MQTT_Basic_TLS Demo * Organize PKCS11 demos project. * Updating MQTT_Keep_Alive demo * Clean up SNTP demo. * Updated MQTT_Multitask demo * Updated MQTT_Plain_Text * Updating the MQTT_Serializer Demo * Updating corePKCS11_MQTT_Mutual_Auth_Windows_Simulator * Updating coreSNTP_Windows_Simulator * Clean up demo projects. * Add markers to PKCS11 mutual auth demo. * Fix Fleet Provisioning demo script. * Fix SNTP demo solution. * Fix coreSNTP project files. * Fix Fleet Provisiong script. * Fix fleet provisioning script. * Fix demo config template. * Fleet provisioning demo markers. * Updating MQTT_Mutual_Auth_wolfSSL demo and the transport_wolfSSL file * Fixing FreeRTOS_Plus_TCP_Echo_POSIX * Fixing CLI and Trace Demos * Fixing TCP_ECHO_POSIX demo * Adding a word to the lexicon * Remove unneeded files. * Update github workflows to use Ubuntu 20.04. * Change OTA demo target names to RTOSDemo for OTAE2E tests. * Fixing Headers * Updating headers * Two more headers * Adding words to the lexicon * Whitepsace * Ignore mbedtls config file for header check. * Removing FreeRTOS Header from the mbedtls_config_v3.2.1.h file * Fix bug in lPKCS11PkMbedtlsCloseSessionAndFree. Add doxygen api docs. * Update lexicon.txt * Fix spelling * Apply suggestions from code review Co-authored-by: jasonpcarroll <23126711+jasonpcarroll@users.noreply.github.com> * Add return code comment for p11_ecdsa_ctx_init * Rename WindowsSimulator folder to VisualStudio_StaticProjects. * Remove references to coroutines * Fix mbedtls_pk_pkcs11.c * Update to LTS 2.0 submodule pointers (#880) * Update submodule pointers to LTS 2.0 * Initial coreMQTT 2.1.1 update. * Update AWS demos for coreMQTT 2.1.1 * Fix deprecated macro for coreMQTT demos. * Fix keep alive demo. * Fix plaintext demo. * Fix MQTT wolfSSL demo. * Fix MQTT PKCS11 demo. * Remove duplicate functions. * Fix Mutual auth demos for Cellular. * Fix OTA demos. * Fix header of plaintext demo config. * Set writev to NULL for OTA demos. * Fix mbedlts config for OTA demos. * Fix spelling. Co-authored-by: Jason Carroll <czjaso@amazon.com> * Removing blank line * Fix jobs demo race condition. * Fix race condition from WinPCap network interface. * Update lexicon. Co-authored-by: Paul Bartell <pbartell@amazon.com> Co-authored-by: Jason Carroll <czjaso@amazon.com> Co-authored-by: Paul Bartell <paul.bartell@gmail.com> Co-authored-by: jasonpcarroll <23126711+jasonpcarroll@users.noreply.github.com>
2 years ago
{
vLoggingInit( pdTRUE, pdFALSE, pdFALSE, 0U, 0U );
FreeRTOS Windows Simulator Build Changes and LTS 2.0 Update (#872) * Update mbedtls to version v3.2.1 * Adjust include paths for github workflow * Update FreeRTOS+TCP to v3.1.0 * Add initial VS project files for Kernel, +TCP, and mbedtls * winpcap: Consolidate to a single copy of WinPcap * Downgrade library projects to VS 2019. Add heap_4 to kernel. * Remove *.vcxproj.user files and add to gitignore * Disable unwanted kernel config options * Update FreeRTOS+TCP and Kernel include paths * Update FreeRTOS+TCP Windows Minimal sln * Remove .suo and .vcxproj.user files * Update mbedtls transport implementations for mbedtls v3.2.1 * Fix typo in mbedtls_freertos_port.c * Update vcxproj files for +TCP, Kernel, Mbedtls * Fix typo in name WindowSimulator -> WindowsSimulator * Add wpcap lib to FreeRTOS+TCP.vcxproj * Update FreeRTOS+TCP Minimal Demo for Windows Simulator * Mask MSVC string function warnings Aad _CRT_SECURE_NO_WARNINGS preprocessor definition. * Move projects to their own directories to make VisualStudio happy * mbedtls_freertos_port.c: Fix formatting? * Add coreHTTP, Logging libs. Adjust dependencies * Disable FreeRTOS Kernel malloc failed hook * Update coreHTTP Plaintext demo * Rename / relocate transport interface implementations * Remove old VS project files * Remove extra core_http_config.h files * Remove extra FreeRTOSConfig.h files * Remove extra FreeRTOSIPConfig.h files * Remove old mbedtls_config.h files * Remove old FreeRTOSConfig and core_http_config files * Update HTTP Mutual Auth Demo build files * Fix transport_plaintext.h include name * Update HTTP_Plaintext demo build files * Update CoreHTTP_S3_Download VS project files * Update HTTP_S3_Upload demo build files * Update CoreHTTP_S3_Download_Multithreaded demo build files * Add GithubActions builds for FreeRTOS+ CoreHTTP Demos * Update S3DownloadHTTPExample.c to be compatible with mbedtls 3.x * Update GithubActions FreeRTOS+ config file * Combine core_pkcs11_config.h files into a single one * Add corePKCS11 VS project file * Update corePKCS11 WinSim demo project and build files * Update corePKCS11 library to version 3.5.0 * Modifiying demos to build using static libraries * Adding a header file * Two more demos * Update corePKCS11 demo code and auto-format * Downgrade corePKCS11 library build file to v142 / VS 2019 * Speed up CI builds with selective submodule initialization * Separate corePKCS11 demo into it's own job. * Remove WIN32.vcxproj and WIN32.vcxproj.filters files * Remove old configuration header files Partially reverts 73829ced6061e4584e521185178a61b4a437c5e0 * Revert unwanted coreHTTP demo changes * Changing include paths for demos * Adding an include * MQTT WoflSSL Demo update * wolfSSL Demo changes * Config changes for MQTT Demos * Initial Device Defender demo update. * Initial Device Shadow demo update. * Update mbedtls_transport_pkcs11 for Mbedtls 3.x * Update corePKCS11 MQTT Mutual Auth demo * Add a default definition of SdkLog * Update CorePKCS11 + MQTT Mutual Auth demo sln name * Build all configs of coreHTTP demos * Update coreSNTP Demo build files. * Update coreSNTP Demo sln name * Update FreeRTOS+TCP Posix demo * Update FreeRTOS+TCP Qemu ARM MPS2 AN385 Demo * Update FreeRTOS+TCP Demo Github Actions builds * Update Fleet Provisioning WinSim Demo build files * Remove mbedtls_pk_info_t references from mbedtls_pk_pkcs11.h * Restore / update the FreeRTOS+TCP Minimal WinSim demo * Initial Jobs demo update. * Fix jobs demo build. * Initial OTA over HTTP demo update. * Initial OTA over MQTT demo update. * Ota_Over_Mqtt_Demo build fix. * OTA over MQTT demo fix. * Update HTTP demo solution file name for CI. * Update Github actions workflow to old HTTP demo names. * Update coreSTNP demo to old solution name. * Fix defender demo / fix mbedtls config to use threading alt. * Add MBEDTLS_CONFIG_FILE definition to each config * Fix config file name. * MQTT Mutual auth fixes. * Fix job demo. * Device shadow demo fixes. * Fix coreSNTP demo not setting alt threading functions for mbedtls. * Enable Static allocation, Add default hooks for FreeRTOS Kernel and +TCP * Add xPlatformIsNetworkUp platform function to FreeRTOS+TCP hooks * Enable runtime statistics in the Windows Simualator Kernel config * Revert "Fix coreSNTP demo not setting alt threading functions for mbedtls." This reverts commit 9069707519561ca8136d58c0f18fb176c9050a1d. * Revert mbedtls threading related config changes * Add xPlatformIsNetworkUp function prototype * Remove boileplate FreeRTOS kernel and +tcp hooks * Refactor device defender demo for clarity * Add wait loop calling xPlatformIsNetworkUp * Add missing vPlatformInitLogging function * Add vPlatformInitLogging and vLoggingPrintf defitions to logging headers * Updating the FreeRTOS_Plus_CLI_with_Trace_Windows_Simulator * Updating the FreeRTOS_Plus_Reliance_Edge_and_CLI_Windows_Simulator demo * Updates to the FreeRTOS_Plus_WolfSSL_Windows_Simulator demo * Fixing wrong include path * Upating FreeRTOS_Plus_WolfSSL_FIPS_Ready_Windows_Simulator demo * Update coreMQTT WinSim demos to print start and end condition. * Modifiying repos updated as part of the CLI demo GitHub workflow * Removing duplicate functions from the FreeRTOS_Plus_TCP_Minimal_Windows_Simulator demo * Updated FreeRTOS_Plus_TCP_UDP_Mode_CLI_Windows_Simulator demo * Updating corePKCS11_MQTT_Mutual_Auth_Windows_Simulator Demo to call the static function that creates task * Fix log message using unitialized string in MQTT Multitask demo. * Fixing a broken extern function * Fixing a typo extern function name * Added a reference to coreHTTP * Fixing a pre-processor issue in the OTA_Over_Http_Demo * Updating the MQTT_Mutual_Auth_Demo_with_BG96 demo * Updating the MQTT_Mutual_Auth_Demo_with_HL7802 demo * Changes to the MQTT_Mutual_Auth_Demo_with_SARA_R4 demo * Fix demos for CI. * Adding the source path to the CBMC proofs for FreeRTOS+TCP * Spell check fixes, adding words to lexicons * Fixing a typo * Add arg to skip prompt in setup script. * Update paths of script to be relative to the file. * Changing manifest.yml file to point to corePKCS11 3.5.0 * Added CI markers to cellular demos. * Fix cellular demo flow. * Fix celullar demos. * Initial TCP sockets wrapper rework - will break things. * First cellular demo fix for new sockets wrapper. * Minor fix to cellular sockets wrapper. * Fix mbedtls bio using FreeRTOS Plus TCP call. * Clean up BG96 demo project files. * Update HL7802 demo. * Fix SARA R4 demo for new sockets wrapper. * Fix Device Defender, Device Shadow, and Fleet PRovisioning. * Fix Jobs demo. * Fix OTA over HTTP demo. * Fix OTA over MQTT demo. * Fix HTTP mutual auth demo. * Fix OTA over MQTT demo endianness. * Fix OTA over HTTP demo endianness. * Fix HTTP Plaintext demo. * Fix HTTP S3 download demo. * Fix plaintext transport * Fix OTA demos. * Fix OTA demos. * Fix OTA HTTP demo. * Fix HTTP S3 Download multithreaded demo. * Fix HTTP S3 Upload demo * Fix corePKCS11 Mutual Auth demo. * Updating MQTT_Mutual_Auth * Update pkcs11 setup script. * Updating the MQTT_Basic_TLS Demo * Organize PKCS11 demos project. * Updating MQTT_Keep_Alive demo * Clean up SNTP demo. * Updated MQTT_Multitask demo * Updated MQTT_Plain_Text * Updating the MQTT_Serializer Demo * Updating corePKCS11_MQTT_Mutual_Auth_Windows_Simulator * Updating coreSNTP_Windows_Simulator * Clean up demo projects. * Add markers to PKCS11 mutual auth demo. * Fix Fleet Provisioning demo script. * Fix SNTP demo solution. * Fix coreSNTP project files. * Fix Fleet Provisiong script. * Fix fleet provisioning script. * Fix demo config template. * Fleet provisioning demo markers. * Updating MQTT_Mutual_Auth_wolfSSL demo and the transport_wolfSSL file * Fixing FreeRTOS_Plus_TCP_Echo_POSIX * Fixing CLI and Trace Demos * Fixing TCP_ECHO_POSIX demo * Adding a word to the lexicon * Remove unneeded files. * Update github workflows to use Ubuntu 20.04. * Change OTA demo target names to RTOSDemo for OTAE2E tests. * Fixing Headers * Updating headers * Two more headers * Adding words to the lexicon * Whitepsace * Ignore mbedtls config file for header check. * Removing FreeRTOS Header from the mbedtls_config_v3.2.1.h file * Fix bug in lPKCS11PkMbedtlsCloseSessionAndFree. Add doxygen api docs. * Update lexicon.txt * Fix spelling * Apply suggestions from code review Co-authored-by: jasonpcarroll <23126711+jasonpcarroll@users.noreply.github.com> * Add return code comment for p11_ecdsa_ctx_init * Rename WindowsSimulator folder to VisualStudio_StaticProjects. * Remove references to coroutines * Fix mbedtls_pk_pkcs11.c * Update to LTS 2.0 submodule pointers (#880) * Update submodule pointers to LTS 2.0 * Initial coreMQTT 2.1.1 update. * Update AWS demos for coreMQTT 2.1.1 * Fix deprecated macro for coreMQTT demos. * Fix keep alive demo. * Fix plaintext demo. * Fix MQTT wolfSSL demo. * Fix MQTT PKCS11 demo. * Remove duplicate functions. * Fix Mutual auth demos for Cellular. * Fix OTA demos. * Fix header of plaintext demo config. * Set writev to NULL for OTA demos. * Fix mbedlts config for OTA demos. * Fix spelling. Co-authored-by: Jason Carroll <czjaso@amazon.com> * Removing blank line * Fix jobs demo race condition. * Fix race condition from WinPCap network interface. * Update lexicon. Co-authored-by: Paul Bartell <pbartell@amazon.com> Co-authored-by: Jason Carroll <czjaso@amazon.com> Co-authored-by: Paul Bartell <paul.bartell@gmail.com> Co-authored-by: jasonpcarroll <23126711+jasonpcarroll@users.noreply.github.com>
2 years ago
}
/*-----------------------------------------------------------*/