cancel
Showing results for 
Search instead for 
Did you mean: 

Hard fault, vector table | jump from boot to app

Vmere.1
Senior

I'm using Keil (Scatter file, not lnker) and I have a bootloader and a place for two images (one active and other is for the over the air update).

i use Cortex M0 processor where there is no Vector Table Offset Register and i used to copy the vector table from flash to sram.

The problem here:

1. I do the ota update using the application and not using the bootloader.

2. I build the firmware for a specific location and when the ota update is happening the active application (which is in slot A) is downloading the new image in Slot B (but the image is built using the linker script for slot A).

3. When I jump from bootloader to app using the function pointer (I see the function ptr is holding the right address.)

4. But when jumping it is creating a hard fault. 

5. So the image built for a specific place should only be used there? Can't I use it for other slots (I also look for page alignment)? if not what can be the possible reason for hard fault?

1 ACCEPTED SOLUTION

Accepted Solutions
MM..1
Chief II

Clearer, but set flag in a memory is ? You only jump into slot B = cant work

You have two solution In point 6 copy B to A and jump

or build app for slot B

Try debug bootloader after OTA...

View solution in original post

10 REPLIES 10
MM..1
Chief II

 in Slot B (but the image is built using the linker script for slot A). Idea???

Since I have only one linker script. I build the image with the same.

For example:

  1. In production: I flash a particular image in Slot A.
  2. I found a bug and planned to do OTA.
  3. Then I created a bugFix Firmware. ( I didn't modify the linker script here).
  4. Then I put it in the cloud.
  5. The tool current application (not bootloader) downloads it to slot B (some other location in flash).
  6. I will set a flag in a memory section which bootloader reads everytime it boots and goes to the specific section
  7. Then when bootloader starts it is going to hard fault.

I think this should be pretty clear (what I'm trying to do now).

Slot A: 0x08001800 (size 59 pages with each page of 2 kb)

slot B; 0x0801f000 (size 59 pages with the same page size)

using stm32f0xx

MM..1
Chief II

Clearer, but set flag in a memory is ? You only jump into slot B = cant work

You have two solution In point 6 copy B to A and jump

or build app for slot B

Try debug bootloader after OTA...

Okay, But I did one more thing.

Since new firmware vector table is pointing towards slot A's location, I copied the vector table to RAM and then added the offset value (slot B start - slot A start) and the jumped to the actual reset handler location directly. Even then it doesn't work.

I did debug after OTA (but anyways I think i should do some deeper investigation).

But are you sure that image build for a particular location using keil linker script can't be used for another location ?(they use the word scatter loading if you use scatter file).

The flag in memory..

This is a concept which I introduced for my project.

When there is a new firmware I set a variable as True when the OTA completes.

This flag is not specific to a particular controller (it is just a specific logic which I introduced). Since I'm not willing to update application using bootloader. I update the app using old active app and then set the flag in the specific section and the trigger a system reset.

Then bootloader has some if else which will see where to jump now.

if bl sees a new firmware in the slot B it jumps to slot B.

In the two point solution which you mentioned (the first one is a nice idea, now I hve to check how much ram is available) and second one is the solution which I have now, but not a practically good solution.

Yes cant be on another location

Can you elaborate a little on why it is not possible? Bcoz I can do some additional research for my Master Thesis.​