cancel
Showing results for 
Search instead for 
Did you mean: 

Application does not start - Flash changed to 0x8020000 and VECT_TAB_OFFSET changed to 0x20000

Martin42
Associate III

Hello,
I created a bootloader and the two applications according to the YouTube tutorial (https://www.youtube.com/watch?v=OkUQ3iMmiYQ&list=PLnMKNibPkDnEb1sphpdFJ3bR9dNy7S6mO&index=1). This works so far.

The application is started by the bootloader using the go2APP() function.

 

void go2APP(void)
{
    uint32_t JumpAddress;
    pFunction Jump_To_Application;

    //check if there is something "installed" in the app FLASH region
    if (((*(uint32_t*) FLASH_APP2_ADDR) & 0x2FFE0000) == 0x20000000)
    {
        HAL_Delay(100);
        //jump to the application
        JumpAddress = *(uint32_t *) (FLASH_APP2_ADDR + 4); // Original
        Jump_To_Application = (pFunction) JumpAddress;
        //initialize application's stack pointer
        __set_MSP(*(uint32_t *) FLASH_APP2_ADDR);
        Jump_To_Application();
    }
    else if (((*(uint32_t*) FLASH_APP1_ADDR) & 0x2FFE0000) == 0x20000000)
    {
        HAL_Delay(100);
        //jump to the application
        JumpAddress = *(uint32_t *) (FLASH_APP1_ADDR + 4);
        Jump_To_Application = (pFunction) JumpAddress;
        //initialize application's stack pointer
        __set_MSP(*(uint32_t *) FLASH_APP1_ADDR);
        Jump_To_Application();
    }
    else
    {
..
    }
}

 

The linker script of the application:

 

/* Specify the memory areas */
MEMORY
{
RAM (xrw)      : ORIGIN = 0x20000000, LENGTH = 64K
FLASH (rx)      : ORIGIN = 0x8020000, LENGTH = 96K
}


/* Define output sections */
SECTIONS
{
    .myBufBlockRAM 0x20000100 :
    {
        KEEP(*(.myBufSectionRAM))
    } > RAM

  /* The startup code goes first into FLASH */
  .isr_vector :
  {
    . = ALIGN(4);
    KEEP(*(.isr_vector)) /* Startup code */
    . = ALIGN(4);
  } >FLASH

 

I don't need the section in RAM and remove the block myBufBlockRAM. 

In main.c I also remove the variable that was mapped to this area in RAM.

 

uint8_t __attribute__((section(".myBufSectionRAM"))) buf_ram[128] = {42};

 

Now the application no longer starts via the bootloader.

What could be the reason?

 

What I also don't understand is why +4 is added to the application on the jump?

 

JumpAddress = *(uint32_t *) (FLASH_APP1_ADDR + 4);

 

 

Thanks in advance.

- Martin

1 ACCEPTED SOLUTION

Accepted Solutions
Dor_RH
ST Employee

Hello @Martin42 ,

When you remove the .myBufBlockRAM section and the corresponding variable buf_ram, it's possible that the memory layout of your application has changed in a way that affects the execution.

The reason for adding 4 to the FLASH_APP1_ADDR when calculating the JumpAddress is related to the structure of the vector table in ARM Cortex-M microcontrollers. The vector table is located at the beginning of the application code in flash memory and contains a series of addresses.

The first address at the very beginning (FLASH_APP1_ADDR) is the initial stack pointer value, and the second address (FLASH_APP1_ADDR + 4) is the reset vector, which is the address of the entry point of the application.

I hope my answer has helped you. When your question is answered, please select this topic as solution that answered you, it will help others find that answer faster.

Thanks for your contribution.

Dor_RH

View solution in original post

1 REPLY 1
Dor_RH
ST Employee

Hello @Martin42 ,

When you remove the .myBufBlockRAM section and the corresponding variable buf_ram, it's possible that the memory layout of your application has changed in a way that affects the execution.

The reason for adding 4 to the FLASH_APP1_ADDR when calculating the JumpAddress is related to the structure of the vector table in ARM Cortex-M microcontrollers. The vector table is located at the beginning of the application code in flash memory and contains a series of addresses.

The first address at the very beginning (FLASH_APP1_ADDR) is the initial stack pointer value, and the second address (FLASH_APP1_ADDR + 4) is the reset vector, which is the address of the entry point of the application.

I hope my answer has helped you. When your question is answered, please select this topic as solution that answered you, it will help others find that answer faster.

Thanks for your contribution.

Dor_RH