cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F0 IAP function

jeff0118
Associate II
Posted on November 19, 2015 at 12:31

Hi all

I try to implement a boot loader that can be jump to user application of STM32F030R8 chip , and I find the IAP sample as follow.

http://www.st.com/web/en/catalog/tools/FM147/CL1794/SC961/SS1743/LN1734/PF258152

It seams look like have the feature I need, but this sample is for STM320518-EVAL, I can't use it on STM32F030R8 directly.

So I find out the function code for jump as below and add these to my main function.

     if (((*(__IO uint32_t*)APPLICATION_ADDRESS) & 0x2FFE0000 ) == 0x20000000)

    {

      /* Jump to user application */

      JumpAddress = *(__IO uint32_t*) (APPLICATION_ADDRESS + 4);

      Jump_To_Application = (pFunction) JumpAddress;

      

      /* Initialize user application's Stack Pointer */

      __set_MSP(*(__IO uint32_t*) APPLICATION_ADDRESS);

      

      /* Jump to application */

      Jump_To_Application();

    }

Then, debug with IAR step by step, it was executed the ''Jump_To_Application'' , but I didn't see the address have jump to the APPLICATION_ADRRESS.

So does anyone can point where is I missing?

Thank you very much.

3 REPLIES 3
Posted on November 19, 2015 at 12:58

It's jumping to an address in a vector table, ie indirectly, there is no code at APPLICATION_ADDRESS

Suggest you review the Cortex-M0 architecture a bit, either via the ARM TRM (Technical Reference Manual) or Joseph Yiu's series of books on the core.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jeff0118
Associate II
Posted on November 23, 2015 at 10:12

Thank you

It can be worked after I set the vector table of app as follow.

/* Private typedef -----------------------------------------------------------*/

/* Private define ------------------------------------------------------------*/

#define APPLICATION_ADDRESS     (uint32_t)0x08004000

/* Private macro -------------------------------------------------------------*/

/* Private variables ---------------------------------------------------------*/

static __IO uint32_t TimingDelay;

#if   (defined ( __CC_ARM ))

  __IO uint32_t VectorTable[48] __attribute__((at(0x20000000)));

#elif (defined (__ICCARM__))

#pragma location = 0x20000000

  __no_init __IO uint32_t VectorTable[48];

#elif defined   (  __GNUC__  )

  __IO uint32_t VectorTable[48] __attribute__((section(''.RAMVectorTable'')));

#elif defined ( __TASKING__ )

  __IO uint32_t VectorTable[48] __at(0x20000000);

#endif

  for(i = 0; i < 48; i++)

  {

    VectorTable[i] = *(__IO uint32_t*)(APPLICATION_ADDRESS + (i<<2));

  }

  /* Enable the SYSCFG peripheral clock*/

  RCC_APB2PeriphResetCmd(RCC_APB2Periph_SYSCFG, ENABLE);

  /* Remap SRAM at 0x00000000 */

  SYSCFG_MemoryRemapConfig(SYSCFG_MemoryRemap_SRAM);

Now, I need to implement the user app jump back to loader when I update the new user app, and jump to the new app again when the new app upload finished, can I use the same jump function to do it?

Posted on November 23, 2015 at 14:43

I'd use a reset based method, as I've discussed on the forum several times before. Please search/Google for specifics.

The ST examples as broken, so

RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);  // Not the RESET of the peripheral

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..