cancel
Showing results for 
Search instead for 
Did you mean: 

VTOR does not work when ROM is loaded from 0x8003000

zexx86
Associate II
Posted on June 18, 2015 at 11:41

Hello,

I have written own bootloader/IAP that should start next firmware (jump to it).

It is working very well, but when the firmware is loaded, then interrupts are not working.

Of course I have configured:

#define VECT_TAB_OFFSET  0x3000

....

SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET;

in SystemInit()

and I have tried various addresses but it still does not work.

It seems as VTOR value is ignored in the firmware

Other than that firmware is working correctly - USART, GPIOs and other peripherals are active.

I have also tried NVIC function for VTOR setup in main() but the result is same always.

I guess that the problem is not in my bootloader, because when I am trying to start the code directly from address 0x8003000 then it is same. Firmware is working but interrupts are not.

SysTick, USART and other interrupt handlers are not called at all.

When the firmware is located at 0x8000000 then everything is working (bootloader is replaced).

VTOR in my bootloader is OK and is reacting to changes.

I have also tried disabling interrupts before changing the address and then enabling back.

But still no luck.

In map file from the firmware I can see: http://pastebin.com/svYBzzaW

so isr_vector is at the correct address.

Strange is, that my firmware has maybe some problems with reading the data from FLASH. It seems as the data are not accessible even they are stored in the flash on very different sector than the firmware. When firmware is at 0x8000000 then it can see the data.

Maybe there is relocated memory somehow, but it shouldn't be.

My linker script is: http://pastebin.com/BrU40tn8

and after SystemInit VTOR is 0x8003000 as it should be.

In the bootloader VTOR is of course at 0x8000000. But as I said, it does not work even if bootloader is ''skipped'' and the firmware is executed directly from 0x8003000.

Even I have changed VTOR to 0x8003000 in the bootloader (before Jump) and I can see that VTOR is configured properly in the firmware then it does not work.

I am using ST Stdlib and STM32F1RBT6 with linaro gcc.

UPDATE: I have found that when very same firmware (linked to 0x8003000) is flashed to 0x8000000 and then flashed again to 0x8003000 then it is working as it should.

VTOR in the firmware must be configured to 0x3000. Interestingly it works even that firmware size is 60kB so it can't fit in 0x3000 bytes but when it is started from 0x8000000 or 0x8003000 it is working... Very strange. So there is no bootloader, but only beginning of the firmware at the start and then whole firmware again after 12kB.

UPDATE2: firmware is working when I am trying to start it directly (without flashing) even when bootloader is flashed. But when started by my bootloader it does not work.

So it is only needed to fix the bootloader.

Where can be a problem?

Thank you very much!

UPDATE3: Problem solved! It was caused by __asm volatile ('' CPSID F \n''); in Jump code.

But still there is a problem with reading the data from the flash.
3 REPLIES 3
Posted on June 18, 2015 at 14:34

> firmware is working when I am trying to start it directly (without flashing)

How do you do that?

> But when started by my bootloader

How do you do that?

JW
Posted on June 18, 2015 at 14:57

Can you use a debugger?

What happens as you step from the boot loader into the application code?

Is it actually calling SystemInit()?

Are you using an RTOS?

Providing very selective snippets it's very difficult to debug remotely.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
zexx86
Associate II
Posted on June 18, 2015 at 16:40

Thank you very much. I am calling/flashing the code from internal ST bootloader from USART.

All problems solved now.

Problem with Flash was caused by unexpected mass erase - this was my fault.

So everything is good now.