Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT




Loading

Hardfault in prvAllocate TCBAndStack

Posted by sureshthiraviam on December 18, 2013

Hi

I am working with the cortex - m0plus controller. when we optimize the code to -O2 we are getting the hardfault during the debug.

static tskTCB *prvAllocateTCBAndStack( unsigned short usStackDepth, portSTACK_TYPE *puxStackBuffer ) { tskTCB *pxNewTCB;

/* Allocate space for the TCB.  Where the memory comes from depends on
the implementation of the port malloc function. */
pxNewTCB = ( tskTCB * ) pvPortMalloc( sizeof( tskTCB ) );

if( pxNewTCB != NULL )
{
	/* Allocate space for the stack used by the task being created.
	The base of the stack memory stored in the TCB so the task can
	be deleted later if required. */
	pxNewTCB->pxStack = ( portSTACK_TYPE * ) pvPortMallocAligned( ( ( ( size_t )usStackDepth ) * sizeof( portSTACK_TYPE ) ), puxStackBuffer );

	if( pxNewTCB->pxStack == NULL )
	{
		/* Could not allocate the stack.  Delete the allocated TCB. */
		vPortFree( pxNewTCB );
		pxNewTCB = NULL;
	}
	else
	{

		/* Just to help debugging. */
		memset( pxNewTCB->pxStack, ( int ) tskSTACK_FILL_BYTE, ( size_t ) usStackDepth * sizeof( portSTACK_TYPE ) );
	}
}

return pxNewTCB;

}

I am getting the hardfault in the else part...


Hardfault in prvAllocate TCBAndStack

Posted by rtel on December 18, 2013

I just tried this GCC Cortex-M0+ project with optimisations set to -O0, -O2 and -O3, and in each case the code executed as expected.

http://www.freertos.org/AtmelSAMD20RTOS.html

Your code appears to be crashing when it calls a library function, not when it is calling a FreeRTOS function. You could try writing your own simple memset() implementation to see if that helps.

Regards.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS