Page 3 of 3

Re: Bootloader topic

Posted: Thu May 21, 2015 7:58 am
by Giovanni
The Cortex-M0 does not have a VTOR register.

Giovanni

Re: Bootloader topic

Posted: Thu May 21, 2015 8:33 am
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?

Re: Bootloader topic

Posted: Thu May 21, 2015 8:47 am
by Giovanni
Anywhere before chSysInit(). But how do you relocate the vectors table in RAM? is that a F0 feature?

Giovanni

Re: Bootloader topic

Posted: Fri May 22, 2015 1:49 am
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)