cancel
Showing results for 
Search instead for 
Did you mean: 

Cortex-M0 Vector table relocation.

Vmere.1
Senior

To give a context:

I'm working to implement OTA for an existing project which uses stm32f091xx.

And it already contains separate bootloader(0x08000000) and application(0x08001000) with their own vector tables.

Currently, when a reset occurs, the bootloader which is remapped to 0x0 will call the application at 0x08001000.

Question:

Both bootloader and application have their own vector table.

But on the internet, I found that Cortex-M0 doesn't have a vector table offset.

Just to know more about it, I tried to create a hard fault on the application and surprisingly, the hard fault is now in a location which is relative to the application and not the bootloader.

This is map of the bootloader:

HardFault_Handler                        0x080000e3   Thumb Code     2  startup_stm32f0xx.o(.text)

This is map of the application:

HardFault_Handler                        0x08002447   Thumb Code     2  stm32f0xx_startup.o(.text)

Why is this working? I mean when I set a hard fault, it should go to 0x080000e3  but why it is going to 0x08002447? Can someone give me any ideas about what is happening?

1 ACCEPTED SOLUTION

Accepted Solutions

Typically on the CM0 you have to copy the vector table into the base of RAM, and then remap that into the zero address space. Register in SYSCFG ​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

2 REPLIES 2

Typically on the CM0 you have to copy the vector table into the base of RAM, and then remap that into the zero address space. Register in SYSCFG ​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
; Vector Table Mapped to Address 0 at Reset
                AREA    RESET, DATA, READONLY
                EXPORT  __Vectors
                EXPORT  __Vectors_End
                EXPORT  __Vectors_Size
 
__Vectors       DCD     __initial_sp                   ; Top of Stack
                DCD     Reset_Handler                  ; Reset Handler
                DCD     NMI_Handler                    ; NMI Handler
                DCD     HardFault_Handler              ; Hard Fault Handler
                DCD     0                              ; Reserved
                DCD     0                              ; Reserved
                DCD     0                              ; Reserved

Now I can relate why the start up file above was defined like this.

They mentioned it in Data section I found it like this.

; Vector Table Mapped to Address 0 at Reset
                AREA    RESET, DATA, READONLY
                EXPORT  __Vectors
                EXPORT  __Vectors_End
                EXPORT  __Vectors_Size
 
__Vectors       DCD     __initial_sp                   ; Top of Stack
                DCD     Reset_Handler                  ; Reset Handler
                DCD     NMI_Handler                    ; NMI Handler
                DCD     HardFault_Handler              ; Hard Fault Handler
                DCD     0                              ; Reserved
                DCD     0                              ; Reserved
                DCD     0                              ; Reserved
                DCD     0                              ; Reserved
                DCD     0                              ; Reserved
                DCD     0                              ; Reserved
                DCD     0                              ; Reserved
                DCD     SVC_Handler                    ; SVCall Handler
                DCD     0                              ; Reserved
                DCD     0                              ; Reserved
                DCD     PendSV_Handler                 ; PendSV Handler
                DCD     SysTick_Handler                ; SysTick Handler

Thank you.