AnsweredAssumed Answered

VTOR does not work when ROM is loaded from 0x8003000

Question asked by pavelm on Jun 18, 2015
Latest reply on Jun 18, 2015 by pavelm

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

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.