Skip to content

Commit

Permalink
Remove DS store; Fix formatting (#52)
Browse files Browse the repository at this point in the history
* Use only a specified cipher suite

* Clean up folder by removing support packages

* Remove DS store; Fix formatting

* Fix whitespace
  • Loading branch information
AniruddhaKanhere authored Jul 11, 2024
1 parent eb22b58 commit c8c8f6b
Show file tree
Hide file tree
Showing 24 changed files with 604 additions and 888 deletions.
Binary file removed .DS_Store
Binary file not shown.
34 changes: 19 additions & 15 deletions Middleware/FreeRTOS/transport_mbedtls/using_mbedtls.c
Original file line number Diff line number Diff line change
Expand Up @@ -627,10 +627,12 @@ static TlsTransportStatus_t tlsSetup( NetworkContext_t * pNetworkContext,
&( pNetworkContext->sslContext.certProfile ) );

/* Only use this cipher suite to connect to the broker. */
const int ciphersuites[] = {
MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
0 /* End of list. */
};
const int ciphersuites[] =
{
MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
0 /* End of list. */
};

mbedtls_ssl_conf_ciphersuites( &( pNetworkContext->sslContext.config ), ciphersuites );

/* Parse the server root CA certificate into the SSL context. */
Expand Down Expand Up @@ -731,8 +733,8 @@ static TlsTransportStatus_t tlsSetup( NetworkContext_t * pNetworkContext,
/* coverity[misra_c_2012_rule_11_2_violation] */
mbedtls_ssl_set_bio( &( pNetworkContext->sslContext.context ),
( void * ) pNetworkContext->tcpSocket,
xMbedTLSBioTCPSocketsWrapperSend,
xMbedTLSBioTCPSocketsWrapperRecv,
xMbedTLSBioTCPSocketsWrapperSend,
xMbedTLSBioTCPSocketsWrapperRecv,
NULL );
}
}
Expand Down Expand Up @@ -810,6 +812,7 @@ static TlsTransportStatus_t tlsSetup( NetworkContext_t * pNetworkContext,
}

/*-----------------------------------------------------------*/

/**
* @brief Sends data over TCP socket.
*
Expand Down Expand Up @@ -856,6 +859,7 @@ int xMbedTLSBioTCPSocketsWrapperSend( void * ctx,
}

/*-----------------------------------------------------------*/

/**
* @brief Receives data from TCP socket.
*
Expand Down Expand Up @@ -949,15 +953,15 @@ TlsTransportStatus_t TLS_FreeRTOS_Connect( NetworkContext_t * pNetworkContext,
returnStatus = tlsSetup( pNetworkContext, pHostName, pNetworkCredentials );
}

// if( returnStatus == TLS_TRANSPORT_SUCCESS )
// {
// opt = 1;
//
// if( lwip_ioctl( pNetworkContext->tcpSocket, FIONBIO, &opt ) != 0 )
// {
// returnStatus = TLS_TRANSPORT_CONNECT_FAILURE;
// }
// }
/* if( returnStatus == TLS_TRANSPORT_SUCCESS ) */
/* { */
/* opt = 1; */
/* */
/* if( lwip_ioctl( pNetworkContext->tcpSocket, FIONBIO, &opt ) != 0 ) */
/* { */
/* returnStatus = TLS_TRANSPORT_CONNECT_FAILURE; */
/* } */
/* } */

/* Clean up on failure. */
if( returnStatus != TLS_TRANSPORT_SUCCESS )
Expand Down
68 changes: 34 additions & 34 deletions examples/common/mqtt_agent/mqtt_agent_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -576,12 +576,12 @@ static BaseType_t prvCreateTLSConnection( NetworkContext_t * pxNetworkContext )
xNetworkCredentials.disableSni = democonfigDISABLE_SNI;

/*
xNetworkCredentials.pClientCert = democonfigCLIENT_CERT;
xNetworkCredentials.clientCertSize = sizeof( democonfigCLIENT_CERT );
xNetworkCredentials.pPrivateKey = democonfigPRIVATE_KEY;
xNetworkCredentials.privateKeySize = sizeof( democonfigPRIVATE_KEY );
*/
* xNetworkCredentials.pClientCert = democonfigCLIENT_CERT;
* xNetworkCredentials.clientCertSize = sizeof( democonfigCLIENT_CERT );
*
* xNetworkCredentials.pPrivateKey = democonfigPRIVATE_KEY;
* xNetworkCredentials.privateKeySize = sizeof( democonfigPRIVATE_KEY );
*/

if( xConnected == pdPASS )
{
Expand Down Expand Up @@ -785,7 +785,7 @@ void prvMQTTAgentTask( void * pvParameters )
ulGlobalEntryTimeMs = prvGetTimeMs();

/* Load broker endpoint and thing name for client connection, from the key store. */
pcThingName = prvKVStoreGetString( KVS_CORE_THING_NAME ); //democonfigCLIENT_IDENTIFIER; //
pcThingName = prvKVStoreGetString( KVS_CORE_THING_NAME ); /*democonfigCLIENT_IDENTIFIER; // */
LogInfo( ( "Thing name %s\n", pcThingName ) );

if( pcThingName != NULL )
Expand All @@ -799,7 +799,7 @@ void prvMQTTAgentTask( void * pvParameters )

if( xStatus == pdPASS )
{
pcBrokerEndpoint = prvKVStoreGetString( KVS_CORE_MQTT_ENDPOINT ); //democonfigMQTT_BROKER_ENDPOINT; //
pcBrokerEndpoint = prvKVStoreGetString( KVS_CORE_MQTT_ENDPOINT ); /*democonfigMQTT_BROKER_ENDPOINT; // */
LogInfo( ( "Endpoint %s\n", pcBrokerEndpoint ) );

if( pcBrokerEndpoint == NULL )
Expand All @@ -810,29 +810,29 @@ void prvMQTTAgentTask( void * pvParameters )

if( xStatus == pdPASS )
{
ulBrokerPort = KVStore_getUInt32( KVS_CORE_MQTT_PORT, &xStatus ); //democonfigMQTT_BROKER_PORT; //
ulBrokerPort = KVStore_getUInt32( KVS_CORE_MQTT_PORT, &xStatus ); /*democonfigMQTT_BROKER_PORT; // */
LogInfo( ( "Port %u\n", ulBrokerPort ) );
}

if( xStatus == pdPASS )
{
pcDevicePrivKeyID = prvKVStoreGetString( KVS_DEVICE_PRIVKEY_ID );
{
pcDevicePrivKeyID = prvKVStoreGetString( KVS_DEVICE_PRIVKEY_ID );

if( pcDevicePrivKeyID == NULL )
{
xStatus = pdFAIL;
}
}
if( pcDevicePrivKeyID == NULL )
{
xStatus = pdFAIL;
}
}

if( xStatus == pdPASS )
{
pcDeviceCertID = prvKVStoreGetString( KVS_DEVICE_CERT_ID );
if( xStatus == pdPASS )
{
pcDeviceCertID = prvKVStoreGetString( KVS_DEVICE_CERT_ID );

if( pcDeviceCertID == NULL )
{
xStatus = pdFAIL;
}
}
if( pcDeviceCertID == NULL )
{
xStatus = pdFAIL;
}
}

/* Initialize the MQTT context with the buffer and transport interface. */
if( xStatus == pdPASS )
Expand Down Expand Up @@ -899,16 +899,16 @@ void prvMQTTAgentTask( void * pvParameters )
}

if( pcDevicePrivKeyID != NULL )
{
vPortFree( pcDevicePrivKeyID );
pcDevicePrivKeyID = NULL;
}

if( pcDeviceCertID != NULL )
{
vPortFree( pcDeviceCertID );
pcDeviceCertID = NULL;
}
{
vPortFree( pcDevicePrivKeyID );
pcDevicePrivKeyID = NULL;
}

if( pcDeviceCertID != NULL )
{
vPortFree( pcDeviceCertID );
pcDeviceCertID = NULL;
}

vTaskDelete( NULL );
}
Expand Down
2 changes: 1 addition & 1 deletion examples/evkbmimxrt1060/bootloader/sbl_boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ int boot_single_go( struct boot_rsp * rsp )

int sbl_boot_main( void )
{
/* Reset ISR is at: 0x6004071c. */
/* Reset ISR is at: 0x6004071c. */
struct image_header br_hdr1 = { .ih_hdr_size = 0x2000 };
struct boot_rsp rsp = { .br_hdr = &br_hdr1, .br_flash_dev_id = 1, .br_image_off = 0x80000 };
int rc = 0;
Expand Down
2 changes: 1 addition & 1 deletion examples/evkbmimxrt1060/bootloader/sblconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
/* secure */

#define COMPONENT_MCUBOOT_SECURE
//#define CONFIG_BOOT_SIGNATURE_TYPE_ROM
/*#define CONFIG_BOOT_SIGNATURE_TYPE_ROM */
#define CONFIG_BOOT_SIGNATURE
#define CONFIG_BOOT_SIGNATURE_TYPE_RSA
#define CONFIG_BOOT_SIGNATURE_TYPE_RSA_LEN 2048
Expand Down
1 change: 0 additions & 1 deletion examples/evkbmimxrt1060/bootloader/signing_pub_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,3 @@ const unsigned char ecdsa_pub_key[] = { 0x00 };
const unsigned int ecdsa_pub_key_len = 0;

#endif /* if defined( MCUBOOT_SIGN_RSA ) */

96 changes: 48 additions & 48 deletions examples/evkbmimxrt1060/pubsub/NetworkInterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@
#include "NetworkInterface.h"

#if ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES != 1
#define ipCONSIDER_FRAME_FOR_PROCESSING( pucEthernetBuffer ) eProcessBuffer
#define ipCONSIDER_FRAME_FOR_PROCESSING( pucEthernetBuffer ) eProcessBuffer
#else
#define ipCONSIDER_FRAME_FOR_PROCESSING( pucEthernetBuffer ) eConsiderFrameForProcessing( ( pucEthernetBuffer ) )
#define ipCONSIDER_FRAME_FOR_PROCESSING( pucEthernetBuffer ) eConsiderFrameForProcessing( ( pucEthernetBuffer ) )
#endif

/* MDIO operations. */
Expand All @@ -72,25 +72,25 @@

/* The length or RX buffer. */
#ifndef ENET_RXBUFF_SIZE
#define ENET_RXBUFF_SIZE ( ENET_FRAME_MAX_FRAMELEN )
#define ENET_RXBUFF_SIZE ( ENET_FRAME_MAX_FRAMELEN )
#endif

/* ENET IRQ priority. Used in FreeRTOS. */
/* Interrupt priorities. */
#ifdef __CA7_REV
#ifndef ENET_PRIORITY
#define ENET_PRIORITY ( 21U )
#endif
#ifndef ENET_1588_PRIORITY
#define ENET_1588_PRIORITY ( 20U )
#endif
#ifndef ENET_PRIORITY
#define ENET_PRIORITY ( 21U )
#endif
#ifndef ENET_1588_PRIORITY
#define ENET_1588_PRIORITY ( 20U )
#endif
#else
#ifndef ENET_PRIORITY
#define ENET_PRIORITY ( 6U )
#endif
#ifndef ENET_1588_PRIORITY
#define ENET_1588_PRIORITY ( 5U )
#endif
#ifndef ENET_PRIORITY
#define ENET_PRIORITY ( 6U )
#endif
#ifndef ENET_1588_PRIORITY
#define ENET_1588_PRIORITY ( 5U )
#endif
#endif /* ifdef __CA7_REV */

/* The number of ENET buffers needed to receive frame of maximum length. */
Expand All @@ -99,55 +99,55 @@

/* The length or TX buffer. */
#ifndef ENET_TXBUFF_SIZE
#define ENET_TXBUFF_SIZE ( ENET_FRAME_MAX_FRAMELEN )
#define ENET_TXBUFF_SIZE ( ENET_FRAME_MAX_FRAMELEN )
#endif

/* The number of buffer descriptors in ENET RX ring. */
#ifndef ENET_RXBD_NUM
#define ENET_RXBD_NUM ( 5 )
#define ENET_RXBD_NUM ( 5 )
#endif

/* Ring should be able to receive at least 1 frame with maximum length. */
#if ENET_RXBD_NUM < MAX_BUFFERS_PER_FRAME
#error "ENET_RXBD_NUM < MAX_BUFFERS_PER_FRAME"
#error "ENET_RXBD_NUM < MAX_BUFFERS_PER_FRAME"
#endif

/* The number of RX buffers. ENET_RXBD_NUM is always held by ENET driver. */
#ifndef ENET_RXBUFF_NUM
#define ENET_RXBUFF_NUM ( ENET_RXBD_NUM * 2 )
#define ENET_RXBUFF_NUM ( ENET_RXBD_NUM * 2 )
#endif

/* At least ENET_RXBD_NUM number of buffers is always held by ENET driver
* for RX. */
#if ENET_RXBUFF_NUM < ( ENET_RXBD_NUM + MAX_BUFFERS_PER_FRAME )
#error "ENET_RXBUFF_NUM < (ENET_RXBD_NUM + MAX_BUFFERS_PER_FRAME)"
#error "ENET_RXBUFF_NUM < (ENET_RXBD_NUM + MAX_BUFFERS_PER_FRAME)"
#endif

/* The number of buffer descriptors in ENET TX ring. */
#ifndef ENET_TXBD_NUM
#define ENET_TXBD_NUM ( 3 )
#define ENET_TXBD_NUM ( 3 )
#endif

/* Set the timeout values such that the total timeout adds up to 4000ms. */
#define MAX_AUTONEG_FAILURE_COUNT ( 40 )
#define SINGLE_ITERATION_TIMEOUT ( 100 )

#if defined( FSL_SDK_ENABLE_DRIVER_CACHE_CONTROL ) && FSL_SDK_ENABLE_DRIVER_CACHE_CONTROL
#if defined( FSL_FEATURE_L2CACHE_LINESIZE_BYTE ) && \
#if defined( FSL_FEATURE_L2CACHE_LINESIZE_BYTE ) && \
( ( !defined( FSL_SDK_DISBLE_L2CACHE_PRESENT ) ) || ( FSL_SDK_DISBLE_L2CACHE_PRESENT == 0 ) )
#if defined( FSL_FEATURE_L1DCACHE_LINESIZE_BYTE )
#define FSL_CACHE_LINESIZE_MAX MAX( FSL_FEATURE_L1DCACHE_LINESIZE_BYTE, FSL_FEATURE_L2CACHE_LINESIZE_BYTE )
#define FSL_ENET_BUFF_ALIGNMENT MAX( ENET_BUFF_ALIGNMENT, FSL_CACHE_LINESIZE_MAX )
#else
#define FSL_ENET_BUFF_ALIGNMENT MAX( ENET_BUFF_ALIGNMENT, FSL_FEATURE_L2CACHE_LINESIZE_BYTE )
#endif
#elif defined( FSL_FEATURE_L1DCACHE_LINESIZE_BYTE )
#define FSL_ENET_BUFF_ALIGNMENT MAX( ENET_BUFF_ALIGNMENT, FSL_FEATURE_L1DCACHE_LINESIZE_BYTE )
#else
#define FSL_ENET_BUFF_ALIGNMENT ENET_BUFF_ALIGNMENT
#endif /* if defined( FSL_FEATURE_L2CACHE_LINESIZE_BYTE ) && ( ( !defined( FSL_SDK_DISBLE_L2CACHE_PRESENT ) ) || ( FSL_SDK_DISBLE_L2CACHE_PRESENT == 0 ) ) */
#if defined( FSL_FEATURE_L1DCACHE_LINESIZE_BYTE )
#define FSL_CACHE_LINESIZE_MAX MAX( FSL_FEATURE_L1DCACHE_LINESIZE_BYTE, FSL_FEATURE_L2CACHE_LINESIZE_BYTE )
#define FSL_ENET_BUFF_ALIGNMENT MAX( ENET_BUFF_ALIGNMENT, FSL_CACHE_LINESIZE_MAX )
#else
#define FSL_ENET_BUFF_ALIGNMENT MAX( ENET_BUFF_ALIGNMENT, FSL_FEATURE_L2CACHE_LINESIZE_BYTE )
#endif
#elif defined( FSL_FEATURE_L1DCACHE_LINESIZE_BYTE )
#define FSL_ENET_BUFF_ALIGNMENT MAX( ENET_BUFF_ALIGNMENT, FSL_FEATURE_L1DCACHE_LINESIZE_BYTE )
#else
#define FSL_ENET_BUFF_ALIGNMENT ENET_BUFF_ALIGNMENT
#endif /* if defined( FSL_FEATURE_L2CACHE_LINESIZE_BYTE ) && ( ( !defined( FSL_SDK_DISBLE_L2CACHE_PRESENT ) ) || ( FSL_SDK_DISBLE_L2CACHE_PRESENT == 0 ) ) */
#else /* if defined( FSL_SDK_ENABLE_DRIVER_CACHE_CONTROL ) && FSL_SDK_ENABLE_DRIVER_CACHE_CONTROL */
#define FSL_ENET_BUFF_ALIGNMENT ENET_BUFF_ALIGNMENT
#define FSL_ENET_BUFF_ALIGNMENT ENET_BUFF_ALIGNMENT
#endif /* if defined( FSL_SDK_ENABLE_DRIVER_CACHE_CONTROL ) && FSL_SDK_ENABLE_DRIVER_CACHE_CONTROL */

/* A bigger value is chosen so that the previous notification values are
Expand All @@ -156,7 +156,7 @@
#define DRIVER_FATAL ( DRIVER_READY << 1 )

#if defined( ENET_ENHANCEDBUFFERDESCRIPTOR_MODE )
#error "ENET_ENHANCEDBUFFERDESCRIPTOR_MODE is not supported by this driver"
#error "ENET_ENHANCEDBUFFERDESCRIPTOR_MODE is not supported by this driver"
#endif

typedef uint8_t rx_buffer_t[ SDK_SIZEALIGN( ENET_RXBUFF_SIZE, FSL_ENET_BUFF_ALIGNMENT ) ];
Expand Down Expand Up @@ -479,7 +479,7 @@ static void prvEMACHandlerTask( void * parameter )
break;

case kStatus_ENET_RxFrameError: /* Received an error frame. Read & drop it */
FreeRTOS_printf( ( "RX Receive Error" ) );
FreeRTOS_printf( ( "RX Receive Error" ) );
ENET_ReadFrame( ethernetifLocal->base, &( ethernetifLocal->handle ), NULL, 0, 0, NULL );
/* Not sure if a trace is required. The MAC had an error and needed to dump bytes */
break;
Expand Down Expand Up @@ -554,28 +554,28 @@ static void prvProcessFrame( int length )
}
else
{
#if ( ( ipconfigHAS_DEBUG_PRINTF == 1 ) && defined( FreeRTOS_debug_printf ) )
const EthernetHeader_t * pxEthernetHeader;
char ucSource[ 18 ];
char ucDestination[ 18 ];
#if ( ( ipconfigHAS_DEBUG_PRINTF == 1 ) && defined( FreeRTOS_debug_printf ) )
const EthernetHeader_t * pxEthernetHeader;
char ucSource[ 18 ];
char ucDestination[ 18 ];

pxEthernetHeader = ( ( const EthernetHeader_t * ) pxBufferDescriptor->pucEthernetBuffer );
pxEthernetHeader = ( ( const EthernetHeader_t * ) pxBufferDescriptor->pucEthernetBuffer );


FreeRTOS_EUI48_ntop( pxEthernetHeader->xSourceAddress.ucBytes, ucSource, 'A', ':' );
FreeRTOS_EUI48_ntop( pxEthernetHeader->xDestinationAddress.ucBytes, ucDestination, 'A', ':' );
FreeRTOS_EUI48_ntop( pxEthernetHeader->xSourceAddress.ucBytes, ucSource, 'A', ':' );
FreeRTOS_EUI48_ntop( pxEthernetHeader->xDestinationAddress.ucBytes, ucDestination, 'A', ':' );

FreeRTOS_debug_printf( ( "Invalid target MAC: dropping frame from: %s to: %s", ucSource, ucDestination ) );
#endif /* if ( ( ipconfigHAS_DEBUG_PRINTF == 1 ) && defined( FreeRTOS_debug_printf ) ) */
FreeRTOS_debug_printf( ( "Invalid target MAC: dropping frame from: %s to: %s", ucSource, ucDestination ) );
#endif /* if ( ( ipconfigHAS_DEBUG_PRINTF == 1 ) && defined( FreeRTOS_debug_printf ) ) */
vReleaseNetworkBufferAndDescriptor( pxBufferDescriptor );
/* Not sure if a trace is required. The stack did not want this message */
}
}
else
{
#if ( ( ipconfigHAS_DEBUG_PRINTF == 1 ) && defined( FreeRTOS_debug_printf ) )
FreeRTOS_debug_printf( ( "No Buffer Available: dropping incoming frame!!" ) );
#endif
#if ( ( ipconfigHAS_DEBUG_PRINTF == 1 ) && defined( FreeRTOS_debug_printf ) )
FreeRTOS_debug_printf( ( "No Buffer Available: dropping incoming frame!!" ) );
#endif
ENET_ReadFrame( ENET, &( ethernetifLocal->handle ), NULL, 0, 0, NULL );

/* No buffer available to receive this message */
Expand Down
2 changes: 1 addition & 1 deletion examples/evkbmimxrt1060/pubsub/app_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ int app_main( void )
if( xResult == pdPASS )
{
xResult = xMQTTAgentInit( appmainMQTT_AGENT_TASK_STACK_SIZE, appmainMQTT_AGENT_TASK_PRIORITY );
//SRC->SCR |= SRC_SCR_CORE0_RST_MASK;
/*SRC->SCR |= SRC_SCR_CORE0_RST_MASK; */
}

#if ( appmainINCLUDE_OTA_UPDATE_TASK == 1 )
Expand Down
Loading

0 comments on commit c8c8f6b

Please sign in to comment.