Skip to content

Add configuration option to prevent configASSERT checks on ipBUFFER_PADDING #1271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 20 additions & 17 deletions source/FreeRTOS_IP_Utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -1004,26 +1004,29 @@ void vPreCheckConfigs( void )
{
size_t uxSize;

/* Check if ipBUFFER_PADDING has a minimum size, depending on the platform.
* See FreeRTOS_IP.h for more details. */
#if ( UINTPTR_MAX > 0xFFFFFFFFU )
#if ( ipconfigSUPPRESS_BUFFER_PADDING_CHECK == 0 )

/* Check if ipBUFFER_PADDING has a minimum size, depending on the platform.
* See FreeRTOS_IP.h for more details. */
#if ( UINTPTR_MAX > 0xFFFFFFFFU )

/*
* This is a 64-bit platform, make sure there is enough space in
* pucEthernetBuffer to store a pointer.
*/
configASSERT( ipBUFFER_PADDING >= 14U );
#else
/* This is a 32-bit platform. */
configASSERT( ipBUFFER_PADDING >= 10U );
#endif /* UINTPTR_MAX > 0xFFFFFFFFU */

/*
* This is a 64-bit platform, make sure there is enough space in
* pucEthernetBuffer to store a pointer.
* The size of the Ethernet header (14) plus ipBUFFER_PADDING should be a
* multiple of 32 bits, in order to get aligned access to all uint32_t
* fields in the protocol headers.
*/
configASSERT( ipBUFFER_PADDING >= 14U );
#else
/* This is a 32-bit platform. */
configASSERT( ipBUFFER_PADDING >= 10U );
#endif /* UINTPTR_MAX > 0xFFFFFFFFU */

/*
* The size of the Ethernet header (14) plus ipBUFFER_PADDING should be a
* multiple of 32 bits, in order to get aligned access to all uint32_t
* fields in the protocol headers.
*/
configASSERT( ( ( ( ipSIZE_OF_ETH_HEADER ) + ( ipBUFFER_PADDING ) ) % 4U ) == 0U );
configASSERT( ( ( ( ipSIZE_OF_ETH_HEADER ) + ( ipBUFFER_PADDING ) ) % 4U ) == 0U );
#endif /* if ( ipconfigSUPPRESS_BUFFER_PADDING_CHECK == 0 ) */

/* LCOV_EXCL_BR_START */
uxSize = ipconfigNETWORK_MTU;
Expand Down
18 changes: 18 additions & 0 deletions source/include/FreeRTOSIPConfigDefaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -3403,6 +3403,24 @@ STATIC_ASSERT( ipconfigDNS_SEND_BLOCK_TIME_TICKS <= portMAX_DELAY );

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

/*
* ipconfigSUPPRESS_BUFFER_PADDING_CHECK
*
* Type: BaseType_t ( ipconfigENABLE | ipconfigDISABLE )
*
* Suppress configuration check when user configuration
* for ipconfigPACKET_FILLER_SIZE or ipconfigBUFFER_PADDING is
* sub optimal. Useful when porting to a MAC that does not include
* the option to pad received packets ipconfigPACKET_FILLER_SIZE
* within a word boundary.
*/

#ifndef ipconfigSUPPRESS_BUFFER_PADDING_CHECK
#define ipconfigSUPPRESS_BUFFER_PADDING_CHECK ipconfigDISABLE
#endif

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

/*
* ipconfigINCLUDE_EXAMPLE_FREERTOS_PLUS_TRACE_CALLS
*
Expand Down