Posted on March 27, 2013 at 23:32Hello all,
I will apreciate any help that can give me some light to understand what is happening.
The firmware has a loader, data flash and an application.
ROM memory mapping:
* Loader 0x0000h - 0x3FFFh
* EEPROM DATA 0x4000h - 0x4FFFh
* Aplication 0x5000h - 0x1FFFh
Due to some reason that I don't know HardFault exception happend.
As recomended in some post I implemented the Joseph Yiu code as follow:
startup_stm32f10x_md.s
;HardFault_Handler
; B HardFault_Handler
HardFault_Handler
TST LR, &sharp4
ITE EQ
MRSEQ R0, MSP
MRSNE R0, PSP
B HardFault_Handler
And implemented the Joseph Yiu code in the interrupts.c file (application NVIC region), I can post it if needed.
The problem happend when the applicaiton is running.
This is the output that I get when the exception happend (application NVIC):
-- DEBUG -- HardFault_Handler
[Hard fault handler - all numbers in hex]
-- DEBUG -- HardFault_Handler R0 = 20000478
-- DEBUG -- HardFault_Handler R1 = 8003b15
-- DEBUG -- HardFault_Handler R2 = 800368d
-- DEBUG -- HardFault_Handler R3 = 800369d
-- DEBUG -- HardFault_Handler R12 = 80036ad
-- DEBUG -- HardFault_Handler LR [R14] = 80036bd subroutine call return address
-- DEBUG -- HardFault_Handler PC [R15] = 80036cd program counter
-- DEBUG -- HardFault_Handler PSR = 0
-- DEBUG -- HardFault_Handler BFAR = e000ed38
-- DEBUG -- HardFault_Handler CFSR = 100
-- DEBUG -- HardFault_Handler HFSR = 40000000
-- DEBUG -- HardFault_Handler DFSR = 0
-- DEBUG -- HardFault_Handler AFSR = 0
-- DEBUG -- HardFault_Handler SCB_SHCSR = 0
Well the PC point directly to the UsageFault handler located in the loader NVIC
void UsageFault_Handler(void) {
UsageFault_Handler:
0x80036cc: 0xb580 PUSH {r7, lr}
debugPrint(''LOADER - UsageFault Handler'');
0x80036ce: 0xf20f 0x1130 ADR.W r1, ?<Constant ''LOADER - UsageFault H...''> ; 0x44414f4c (1145130828)
0x80036d2: 0xf20f 0x1018 ADR.W r0, ??__FUNCTION___5 ; 0x67617355 (1734439765)
0x80036d6: 0xf7fe 0xfd81 BL debugPrintMsg ; 0x80021dc
while (1) {
??UsageFault_Handler_0:
0x80036da: 0xe7fe B.N ??UsageFault_Handler_0 ; 0x80036da
And the values stored in R0(stack), R1, R2,R3 y R12 are Loader handlers interrupts as I can show bellow.
Reset_Handler 0x08003b15 Code Wk startup_stm32f10x_md_vl.o [1]
NMI_Handler 0x0800368d 0x10 Code Gb interrupciones.o [1]
HardFault_Handler 0x0800369d 0x10 Code Gb interrupciones.o [1]
When I try to execute some code for example debugPrint in this interrups I can't get data.
When I start the Micro, run loader and start the application correctly,
but it seems that when the application is running can't go back to the loader.
Any idea to understand what is happening and how to get the error source. I think that it happening someting in the code but run the loader NVIC exceptions and can't get the cause of the exception.
Thanks in advance.
#stm32-hardfault-exception