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

CortexM3 HardFault with FreeRTOS7.5.2

Posted by vicui on December 6, 2013

ALL

my Cortex M3 happen Hardfault after running some time. it is long sometimes and short sometimes. no rule. and it use FreeRTOS7.5.2, after Hardfault, I dump CPU context as following [Hard fault handler] R0 = 2e R1 = 0 R2 = ffffffff R3 = 20005f48 R12 = 4f588000 LR = fffffffd PC = 28024f14 PSR = 21000035 BFAR = e000ed38 CFSR = 100 HFSR = 40000000 DFSR = 0 AFSR = 0

it is strange that PC value is not a valid address, anyone meet same problem ?


CortexM3 HardFault with FreeRTOS7.5.2

Posted by rtel on December 6, 2013

If the dump was done while you were in the hardfault handler then I would expect the PC to point to code inside the hardfault handler.

I would suggest starting here: http://www.freertos.org/FAQHelp.html for a list of possible problems if the hardfault is occurring in FreeRTOS itself (rather than in your application).

Regards.


CortexM3 HardFault with FreeRTOS7.5.2

Posted by vicui on December 10, 2013

I always enable conf_assert and make sure that there is no assert when hardfault happen. I start to guess HW issue and collect more record about PC value, it may be 0x0Cxxxxxx, 0x28xxxxxx, 0xc8xxxxxx, it is random case


CortexM3 HardFault with FreeRTOS7.5.2

Posted by rtel on December 10, 2013

How are you working out the PC value?

Regards.


CortexM3 HardFault with FreeRTOS7.5.2

Posted by vicui on December 11, 2013

use following code to save cpu context when hardfault happen IMPORT hardfaulthandlerc
TST LR, #4
ITE EQ
MRSEQ R0, MSP
MRSNE R0, PSP
B hardfaulthandlerc then, go to hardfault_handle to dump those context

void hardfaulthandlerc(unsigned int * hardfaultargs)
{
unsigned int stackedr0;
unsigned int stackedr1;
unsigned int stackedr2;
unsigned int stackedr3;
unsigned int stackedr12;
unsigned int stackedlr;
unsigned int stackedpc;
unsigned int stackedpsr;

while(1)
{
    stacked_r0 = ((unsigned long) hardfault_args[0]);  
    stacked_r1 = ((unsigned long) hardfault_args[1]);  
    stacked_r2 = ((unsigned long) hardfault_args[2]);  
    stacked_r3 = ((unsigned long) hardfault_args[3]);  
    stacked_r12 = ((unsigned long) hardfault_args[4]);  
    stacked_lr = ((unsigned long) hardfault_args[5]);  
    stacked_pc = ((unsigned long) hardfault_args[6]);  
    stacked_psr = ((unsigned long) hardfault_args[7]);  
    printf ("[Hard fault handler]\n");  
    printf ("R0 = %x\n", stacked_r0);  
    printf ("R1 = %x\n", stacked_r1);  
    printf ("R2 = %x\n", stacked_r2);  
    printf ("R3 = %x\n", stacked_r3);  
    printf ("R12 = %x\n", stacked_r12);  
    printf ("LR = %x\n", stacked_lr);  
    printf ("PC = %x\n", stacked_pc);  
    printf ("PSR = %x\n", stacked_psr);  
    printf ("BFAR = %x\n", (*((volatile unsigned long *)(0xE000ED38))));  
    printf ("CFSR = %x\n", (*((volatile unsigned long *)(0xE000ED28))));  
    printf ("HFSR = %x\n", (*((volatile unsigned long *)(0xE000ED2C))));  
    printf ("DFSR = %x\n", (*((volatile unsigned long *)(0xE000ED30))));  
    printf ("AFSR = %x\n", (*((volatile unsigned long *)(0xE000ED3C))));  
    printf ("SCB_SHCSR = %x\n", SCB->SHCSR);
    getkeychar();
}

}


CortexM3 HardFault with FreeRTOS7.5.2

Posted by davedoors on December 11, 2013

Could the problem be in the printf() from an exception handler? If you look at the value of stacked_pc in the debugger does it match the value printed out?


[ 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