cancel
Showing results for 
Search instead for 
Did you mean: 

Bootloader Jump failing going to Usage Handler Fault

holeygaurav
Associate II
Posted on May 05, 2015 at 14:48

Dear All,

I am writing STM32F105 based bootloader. I am able to write the Application File contents to the Flash Application Area. But the Jump to Application is failing; I am getting following Errors:

1. Usage Fault Handler/ Hard Fault

2. Unknown Handler

3. CSTACK  going outside Range

@ => _set_MSP(....) my CSTACK is going haywired....

Before Jumping to application I am doing following things:

1. Disable Interrupts

2. Set the Jump Address

3. Setting MSP

4. Going to Privilege Mode

(asm instruction)

5. Changing MSP to PSP for Application jump (asm instruction)

6. Jump

My Jump Address is 0x08008000.

CSTACK is 1800

HEAP is 1400

I am using IAR Workbench/JTAG Debugging

Kindly suggest where things are going wrong.

Regards,

hgaurav 
3 REPLIES 3
Posted on May 05, 2015 at 16:52

Seems a bit complicated.

So use the debugger and step through the code until you get to main.

Have the Hard Fault providing information about the core state and instructions it's faulting on.

Make sure you've got the Vector Table address changed, and that SystemInit() gets the system in a state it can work with. ie clocks, pll settings, flash settings, etc

Disabling interrupts is different than turning them off, if you hand a broken system off to the application, as some of the interrupts are re-enabled it will have to deal with whatever mess it's been left, so it better be prepared to handle any/all interrupts left pending.

I've gone over this topic a lot, please try to dig up and review some of the prior threads.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on May 05, 2015 at 16:53

My Jump Address is 0x08008000.

Are you sure that's viable? It can only run THUMB code.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
tm3341
Associate II
Posted on May 05, 2015 at 21:23

Did you compile program with vector table offset?

This value must be multiple of 0x200 somewhere in system_stm32f10x.c should be something similar to this:

#define VECT_TAB_OFFSET 0x0 /*!< Vector Table base offset field.

This value must be a multiple of 0x */

Set this value to your flash offset. In your case, you should set to 0x8000. This is in the most cases main problem when you get hardfault.