AnsweredAssumed Answered

Bootloader and STM32F091

Question asked by Peden.Fabrice on Jul 27, 2016
Latest reply on Jul 28, 2016 by Clive One
Hi everybody,

I try to make a bootloader with my STM32f091 to copy a new firmware to my boards using the Power Line Current.

First, I bought the evaluation kit (STEVAL-IHP005V1), it works very without any problem (µc use on these boards : STM32F103VB - Cortex M3). The principle is that there are two zones in flash where the both firmwares are located. (cf. figure 21 of UM1619).
So I'm trying to the same with my µc (STM32F091 - Cortex M0). So I use the same code :

/* Private define ------------------------------------------------------------*/
#define FLASH_BASE_ADDRESS      ((uint32_t)0x08000000)
#define BOOT_LOADER_SIZE        (0x1000)  /*  4 Kb (3 Kb Boot loader firmware -max-, 1 Kb boot loader data) */
#define IMAGE_MAX_SIZE          (0x19000)
#define BOOT_DATA_SIZE          (0x400)   /*  1 Kb */
//#define FLASH_PAGE_SIZE         (0x400)   /*  1 Kb */
#define BOOT_DATA_ADDRESS       (FLASH_BASE_ADDRESS + BOOT_LOADER_SIZE - BOOT_DATA_SIZE)
#define ACTIVE_IMAGE_ADDRESS    (BOOT_DATA_ADDRESS)
 
#define FIRST_IMAGE_ADDRESS     (FLASH_BASE_ADDRESS + BOOT_LOADER_SIZE)
#define SECOND_IMAGE_ADDRESS    (FIRST_IMAGE_ADDRESS + IMAGE_MAX_SIZE)
#define DEFAULT_IMAGE_ADDRESS   FIRST_IMAGE_ADDRESS
 
/* ADRESSE DE BASE DU BOOTLOADER        : 0x0800 0000 */
/* ACTIVE IMAGE ADRESSE                 : 0x0800 0C00 */
/* FIRMWARE #1                          : 0x0800 1000 */
/* FIRMWARE #2                          : 0x0801 9FFF */
 
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
  int *application_address = (int *)BOOT_DATA_ADDRESS;
  int vector_table_address;
  int test = 0;
 
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
 
/*******************************************************************************
* Function Name  : main
* Description    : Main program
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
main(void)
{
 
  
     
  /* Read the active image and default vector table address */
  test = FIRST_IMAGE_ADDRESS;
  application_address = &test;
 
   
  /* Set the correct offsets before jump to new image */
  vector_table_address = *application_address;
  application_address = (int *)(vector_table_address + 4);
     
  /* Jump to application */
  __set_MSP(*(int*)vector_table_address);
  *(int *)(0xE000ED08) = 0x08001000;     /* SCB->VTOR */
  ((void (*)(void))(*application_address))();
  while(1);
  
}

It seems to work up to the following line *(int *)(0xE000ED08) = 0x08001000 which normally allows to remap the vector table. I saw on different website also this instruction : SCB->VTOR = xxx but my compiler doesn't know it.

Then I have found on some website that with M0 I cannot remap the vector table. Could you confirm it or not ?

https://www.lpcware.com/content/forum/2nd-bootloader-requiring-the-same-interrupt-in-bootloader-and-main-application
http://www.embedded.com/print/4229843

Thank you in advance,

Best regards,

Fabrice

Outcomes