Skip to main content
Jimis
Associate II
May 16, 2021
Question

IAP programming

Hi

I'm trying use In App programming for the STM32L432KC board. Unfortunately there is no working example provided (app note AN4657 has STM3210C_EVAL and STM32L476G_EVAL which is dual bank).

I have managed to modify the example and written correctly the Flash (verified with debugger). The problem is when jumping to the address I get a hardfault_handler error.

The details of my setup are these:

I have separated flash in 2 areas since I don't have dual banks

area A 0x0800 0000

area B 0x0802 0000

I write my new binary (blink code) file in area B and I jump using the following code, where APPLICATION_ADDRESS=0x0802 0000 (area B):

 //SCB->VTOR = APPLICATION_ADDRESS;
 
 
 /* execute the new program */
 
 JumpAddress = *(__IO uint32_t*) (APPLICATION_ADDRESS + 4);
 
 /* Jump to user application */
 
 JumpToApplication = (pFunction) JumpAddress;
 
 
 /* Initialize user application's Stack Pointer */
 
 __set_MSP(*(__IO uint32_t*) APPLICATION_ADDRESS);
 
 JumpToApplication();

I read in this post that you need to add SCB->VTOR = APPLICATION_ADDRESS; for the interrupt vectors to initialize to the new address but I still get the error

inside the hardfault_handler I read the SCB and get the following

0693W00000AOWdmQAH.jpgwhich gives a BFSR register error at address 0x20010000 which points to a reserved space

Any ideas what I'm doing wrong ? According to the example you don't need to do anything else after you have loaded new program to flash. Just set MSP and jump.

Thanks in advance

This topic has been closed for replies.

13 replies

Jimis
JimisAuthor
Associate II
May 17, 2021

Found it. I needed to re-enable IRQs in the loaded app (blink).

Question is why didn't blink crash before without this line ? Isn't the init of the code the same when uploading via debugger or via IAP ?

Wasted so many hours for a few details that could have been written in the app note. Really frustrating