Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I change the start address on flash?

I'm using STM32F746ZG and FreeRTOS. The start address of flash is 0x08000000. But I want to change it to 0x08040000. I've searched this issue through google but I didn't find the solution.

I changed the linker script like the following.

MEMORY
{
RAM (xrw)      : ORIGIN = 0x20000000, LENGTH = 320K
/* FLASH (rx)      : ORIGIN = 0x8000000, LENGTH = 1024K */
FLASH (rx)      : ORIGIN = 0x8040000, LENGTH = 768K
}

If I only change it and run the debugger, it has the problem. If I change the VECT_TAB_OFFSET from 0x00 to 0x4000, it works fine.

/* #define VECT_TAB_SRAM */
#define VECT_TAB_OFFSET  0x40000  /* 0x00 */

SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; 

But if I don't use debugger, it doesn't work anything. It means it only works when using ST-Linker.

Please let me know if you know the solution. Thank you for in advance of your reply.

like image 695
Hans Avatar asked Jul 05 '19 03:07

Hans


1 Answers

The boot address can be set in the option bytes.

You can set any address in the flash with 16k increments. There are two 16 bit registers in the option bytes area, one is used when the boot pin is low at reset, the other when the pin is high. Write the desired address shifted right by 14 bits, i.e. divided by 16384.

To boot from 0x08040000, write 0x2010 into the register as described in the Option bytes programming chapter of the reference manual.

enter image description here

like image 198
followed Monica to Codidact Avatar answered Oct 21 '22 01:10

followed Monica to Codidact