Quality RTOS & Embedded Software

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


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 ]    [ Privacy ]    [ Sitemap ]    [ ]


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

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

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

Xilinx Microblaze and Zynq partner