While creating a static timer (and all the dynamic support being dropped out), I found that the kernel calls the vPortFree() function, and as it doesn’t exist, then the program doesn’t compile.
StaticTimer_t timer1_tcb;
TimerHandle_t timer1_handler;
timer1_handler =
xTimerCreateStatic(
( const portCHAR* ) "TMR1",
pdMS_TO_TICKS( 10 ),
pdTRUE,
( void* ) 0,
timer1,
&timer1_tcb );
In the Makefile I have:
#define configSUPPORT_STATIC_ALLOCATION 1
//#define configSUPPORT_DYNAMIC_ALLOCATION 0
//#define configTOTAL_HEAP_SIZE (( UBaseType_t )( 1500 ))
A stripped output is:
build-uno/libcore.a(timers.c.o): In function prvTimerTask': timers.c:(.text.prvTimerTask+0x202): undefined reference to
vPortFree’
collect2: error: ld returned 1 exit status
Tracing back into the function xTimerCreateStatic() (in the file timers.c) I guess some copy and paste is the guilty one:
#if( configSUPPORT_STATIC_ALLOCATION == 1 )
TimerHandle_t xTimerCreateStatic( const char * const pcTimerName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
const TickType_t xTimerPeriodInTicks,
const UBaseType_t uxAutoReload,
void * const pvTimerID,
TimerCallbackFunction_t pxCallbackFunction,
StaticTimer_t *pxTimerBuffer )
{
Timer_t *pxNewTimer;
#if( configASSERT_DEFINED == 1 )
{
/* Sanity check that the size of the structure used to declare a
variable of type StaticTimer_t equals the size of the real timer
structure. */
volatile size_t xSize = sizeof( StaticTimer_t );
configASSERT( xSize == sizeof( Timer_t ) );
}
#endif /* configASSERT_DEFINED */
/* A pointer to a StaticTimer_t structure MUST be provided, use it. */
configASSERT( pxTimerBuffer );
pxNewTimer = ( Timer_t * ) pxTimerBuffer; /*lint !e740 Unusual cast is ok as the structures are designed to have the same alignment, and the size is checked by an assert. */
if( pxNewTimer != NULL )
{
prvInitialiseNewTimer( pcTimerName, xTimerPeriodInTicks, uxAutoReload, pvTimerID, pxCallbackFunction, pxNewTimer );
#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) //<== I GUESS THIS IS THE TROUBLE-MAKER ===
{
/* Timers can be created statically or dynamically so note this
timer was created statically in case it is later deleted. */
pxNewTimer->ucStaticallyAllocated = pdTRUE;
}
#endif /* configSUPPORT_DYNAMIC_ALLOCATION */
}
return pxNewTimer;
}
#endif /* configSUPPORT_STATIC_ALLOCATION */
I haven’t tried to correct the code from
#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
to
#if( configSUPPORT_STATIC_ALLOCATION == 1 )
because I don’t want to break things (I like to break things, but not now). Let the creator to give us green light.
Any advice, good or bad?