Quality RTOS & Embedded Software

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




Loading

Hardfault on cortex M3

Posted by bertino on May 28, 2014

Hi,

I'm working on an application that sometimes fails and gets into the HardFaultHandler.

I was trying to find a way to understand the cause by implementing your suggestions in: http://www.freertos.org/Debugging-Hard-Faults-On-Cortex-M-Microcontrollers.html

but looks like the asm code in your example has a syntax that is not compatible with IAR Embedded Workbench v7.10, for example the decalration :

static void HardFault_Handler( void ) attribute( ( naked ) );

makes IAR complain for a missing "{"

so since assembly directives are not my bread and butter, do you have a reference example based on IAR that I can look at to get over this quickly? Not for lazyness, I actually would like to increment my knowledge on asm but since I have tight deadlines I'm looking for the fast track if there is any suggestion that can help;

Thanks, Adalberto


Hardfault on cortex M3

Posted by rtel on May 28, 2014

The code as posted on the FreeRTOS.org site is using GCC syntax. IAR do a pretty good job of allowing GCC syntax through their compiler, but it looks from your post that the naked attribute is not supported all the same.

There would be a couple of options. First look in the IAR manual to see if they have an equivalent to the naked attribute (which prevents the compiler from inserting any prologue or epilogue code), or second move all the code into an assembly file.

Does your project have any assembly files already? It probably will do for the C start up code and vector table. Somewhere you will have a default HardFault_Handler function, and you would be able to add the assembly code from the web page in that.

If the HardFault_Handler function is a C file and you don't have any assembler files in your project you will have to create your own assembly file and add it to the project. In IAR syntax it would look something like the following:


    RSEG    CODE:CODE(2)
    thumb

    PUBLIC HardFault_Handler
    EXTERN prvGetRegistersFromStack

HardFault_Handler	

    tst lr, #4
    ite eq
    mrseq r0, msp
    mrsne r0, psp
    ldr r1, [r0, #24]
    ldr r2, prvGetRegistersFromStack
    bx r2
	
	END

Regards, Richard Barry.


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




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists