Stm32 cortex-m3 memory remap

1.7k views Asked by At

I am working on a stm32l152 now.

My boot up vector table is located on flash 0x0800 0000, where there is a valid reset handler vector and stack pointer. The rest of the exception/interrupt vectors are just endless loops. Then I setup another vector table in ram, starting at 0x2000 0000. This vector table will have all necessary vectors.

My problem is that after doing a memory remap to map 0x0000 0000 to 0x2000 0000, and when my interrupt fires off, it seems the mcu is still looking for the vectors in 0x0800 0000. I have confirmed this by changing my related-vector in the flash table to that of the one in the ram table. If the flash table related-vector points to a endless loop, my program will loop endlessly. Also, I confirmed my memory remap is correct by writing/read back some memory locations across 0x0000 0000, 0x0800 0000, 0x2000 0000.

Next I use the other method of changing the VTOR in the mcu to offset the vector table by 0x2000 0000. Now, it works and the mcu will find the vector in the ram. Note that in this method, I did not do any above memory remapping.

My question is: can I use memory remap to relocate my vector table (Without changing VTOR)?

What other uses are there for memory remapping?

Can I write to 0x0000 0000 (mapped to 0x0800 0000 flash) and modify flash during runtime?

1

There are 1 answers

0
Tagli On

You probably have done it right in your first attempt. However, SystemInit() function supplied by the IDE silently sets VTOR = 0x8000000, so the table at the beginning of the flash is used regardless of your memory remap settings.