Skip to main content
Visitor II
November 25, 2022
Solved

Hard fault, vector table | jump from boot to app

  • November 25, 2022
  • 2 replies
  • 3698 views

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?

    This topic has been closed for replies.
    Best answer by MM..1

    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...

    2 replies

    Graduate II
    November 25, 2022

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

    Vmere.1Author
    Visitor II
    November 25, 2022

    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).

    Vmere.1Author
    Visitor II
    November 25, 2022

    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..1Answer
    Graduate II
    November 25, 2022

    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...

    Vmere.1Author
    Visitor II
    November 25, 2022

    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).

    Graduate II
    November 25, 2022

    Yes cant be on another location