This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Bootloader STM32 interrupt problem

I made a bootloader that makes it possible to program the device in application. The bootloader software uses interrupts and communicate over an RS485 bus. When I jump to the base address of my firmware, it seems that the interrupts aren't working. I use the command below to redirect the vectortable in the firmware.

NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x08008000);

The method of jumping to my applicaton is the one documented in the AN2557.

static const uint32_t FIRMWARE_START_ADDRESS = 0x08008000ul;
typedef void (*pFunction)(void);

...

//Initialize jump to firmware
uint32_t startAddress = *(__IO uint32_t*)(FIRMWARE_START_ADDRESS + 4);
pFunction RestartFirmware = (pFunction)startAddress;
//Initialize firmware Stack Pointer */
__set_MSP(*(__IO uint32_t*)FIRMWARE_START_ADDRESS);

I've tested the code and the jump occurs, and the code is run, but none of my interrupt driven deviced work properly.

I've tested the code by using the example from the AN2557 to jump to the my bootloader (recompiled to address 0x08002000) and then the jump to my bootloader works. Then I let my bootloader jump back (FIRMWARE_START_ADDRESS = 0x08000000) to the AN2557 bootloader and that also worked. But when I jump for a second time to my bootloader it doesn't work anymore. I've added the vector redirection to both projects and it still doesn't work.

My bootloader is written in c++. Most of my hardware is managed by singleton classes. Is something not initialized properly (statics)?

Parents
  • The following works on my MCBSTM32C board.

    You can verify if it works for you too and then find
    what does not make it work in your project.

    1. Download latest CMSIS at www.onarm.com/.../download396.asp

    2. Open project CM3\Example\arm\STM32F107\CMSIS_Example_STM32F107.uv2 for Keil's MCBSTM32C.

    3. edit main_STM32F107.c and add tagged lines:

    
    int main (void) {
    
      uint32_t nn = 50; // tag: added to test reset
    
      if (SysTick_Config(SystemCoreClock / 1000)) { /* Setup SysTick Timer for 1 msec interrupts  */
        while (1);                                  /* Capture error */
      }
    
      LED_Config();
    
      // tag: added to test reset
      LED_On (0x100);
      Delay (5*1000);
    
      while(1) {
        LED_On (0x100);                             /* Turn on the LED. */
        Delay (100);                                /* delay  100 Msec */
        LED_Off (0x100);                            /* Turn off the LED. */
        Delay (100);                                /* delay  100 Msec */
    
        // tag: added to test reset
        if(--nn == 0)
        {
            NVIC_SystemReset();
        }
      }
    
    }
    
    
    

    If you have a MCBSTM32 board you can use the project CMSIS_Example_STM32F103.uv2 but remember to chacneh some settings (type of micro, inhibit use of external memory) and change startup file.

    Regards, Marco.

Reply
  • The following works on my MCBSTM32C board.

    You can verify if it works for you too and then find
    what does not make it work in your project.

    1. Download latest CMSIS at www.onarm.com/.../download396.asp

    2. Open project CM3\Example\arm\STM32F107\CMSIS_Example_STM32F107.uv2 for Keil's MCBSTM32C.

    3. edit main_STM32F107.c and add tagged lines:

    
    int main (void) {
    
      uint32_t nn = 50; // tag: added to test reset
    
      if (SysTick_Config(SystemCoreClock / 1000)) { /* Setup SysTick Timer for 1 msec interrupts  */
        while (1);                                  /* Capture error */
      }
    
      LED_Config();
    
      // tag: added to test reset
      LED_On (0x100);
      Delay (5*1000);
    
      while(1) {
        LED_On (0x100);                             /* Turn on the LED. */
        Delay (100);                                /* delay  100 Msec */
        LED_Off (0x100);                            /* Turn off the LED. */
        Delay (100);                                /* delay  100 Msec */
    
        // tag: added to test reset
        if(--nn == 0)
        {
            NVIC_SystemReset();
        }
      }
    
    }
    
    
    

    If you have a MCBSTM32 board you can use the project CMSIS_Example_STM32F103.uv2 but remember to chacneh some settings (type of micro, inhibit use of external memory) and change startup file.

    Regards, Marco.

Children