Bootloader topic

This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome. This forum is NOT for support.
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Bootloader topic

Post by Giovanni »

The Cortex-M0 does not have a VTOR register.

Giovanni
User avatar
DeusExMachina
Posts: 223
Joined: Tue Apr 03, 2012 5:08 am
Has thanked: 3 times
Been thanked: 3 times

Re: Bootloader topic

Post by DeusExMachina »

Hm, it seems that it is impossible to move vector table for STM32F0. The only option is to use vector table in RAM, and copy vectors at the beginning of hardware initialization process.

Code: Select all

/* Relocate by software the vector table to the internal SRAM at 0x20000000 ***/

  /* Copy the vector table from the Flash (mapped at the base of the application
     load address 0x08003000) to the base address of the SRAM at 0x20000000. */
  for(i = 0; i < 48; i++)
  {
    VectorTable[i] = *(__IO uint32_t*)(APPLICATION_ADDRESS + (i<<2));
  }

/* Enable the SYSCFG peripheral clock*/
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
 
/* Remap SRAM at 0x00000000 */
SYSCFG_MemoryRemapConfig(SYSCFG_MemoryRemap_SRAM);



STM32F0xx_AN4065_FW_V1.0.0\Project\STM32F0xx_IAP\binary_template

What is the best place to put this code during Chibios initialization?
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Bootloader topic

Post by Giovanni »

Anywhere before chSysInit(). But how do you relocate the vectors table in RAM? is that a F0 feature?

Giovanni
User avatar
DeusExMachina
Posts: 223
Joined: Tue Apr 03, 2012 5:08 am
Has thanked: 3 times
Been thanked: 3 times

Re: Bootloader topic

Post by DeusExMachina »

According to ST's appnote AN4065
The user application to be loaded into the Flash memory using IAP should be built with the
following configuration settings:
1. Set the program load address at 0x08003000, using the toolchain linker file.
2. Relocate the vector table at address 0x20000000 (reserve 48 word starting in RAM @
0x20000000 ).

So it is possible by using SYSCFG according to RM0091 Reference manual
Bits 1:0 MEM_MODE[1:0]: Memory mapping selection bits
These bits are set and cleared by software. They control the memory internal mapping at
address 0x0000 0000. After reset these bits take on the value selected by the actual boot
mode configuration. Refer to Chapter 2.5: Boot configuration for more details.
x0: Main Flash memory mapped at 0x0000 0000
01: System Flash memory mapped at 0x0000 0000
11: Embedded SRAM mapped at 0x0000 0000

So it is possible to copy vector table from flash to the beginning of SRAM and perform mapping (this approach is used in IAP appnote AN4065)
Post Reply