cancel
Showing results for 
Search instead for 
Did you mean: 

Overwriting program flash area

andy2
Associate II
Posted on October 09, 2015 at 07:31

Hi all,  I have a project that is in late stage, and client is suddenly asking (forcing) toenable firmware upgrade.  We have a bluetooth module on board and is connecting to the MCU by UART, is it possible that I could send commands to the bluetooth from my phone and rewrite the program flash area, so it is upgraded? I am currently using STM32F051 MCU.

Thank you in advance!

5 REPLIES 5
e1369008
Associate II
Posted on October 09, 2015 at 09:09

It's called in-application programming. You must split your program into two parts: a bootloader and the main program. The bootloader is always there, it updates the main program if requested, then jumps into it (to execute).

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

If you are using the Cube, look also at

http://www.st.com/web/en/catalog/tools/FM147/CL1794/SC961/SS1743/LN1920/PF262163

.
andy2
Associate II
Posted on October 09, 2015 at 12:27

Thank you!  After knowing this and reading more, I am able to put my program that I want to run after some check at 0x8002000, put that into flash first, and then make a simple program at 0x8000000 with a few lines of code like the following:

uint32_t startAddress = *(__IO uint32_t*)(FIRMWARE_START_ADDRESS + 4);

pFunction RestartFirmware = (pFunction)startAddress;

__set_MSP(*(__IO uint32_t*)FIRMWARE_START_ADDRESS);

RestartFirmware();

And jump to that address of 0x8002000 (FIRMWARE_START_ADDRESS).  However, seems the interrupts are not working.

Seems I need to set the vector table to my firmware too, but I cannot find the function to actually set the vector table. I am using STM32F0, is there a way to set it?

e1369008
Associate II
Posted on October 09, 2015 at 12:35

I assume you downloaded the zip file from my first link.

Look at STM32F0xx_AN4065_FW_V1.0.0\Project\STM32F0xx_IAP\binary_template\src\main.c to see how to relocate the vector table of the main application.

andy2
Associate II
Posted on October 11, 2015 at 08:46

Thank you! I used the first link and can see how the vector table is copied to the RAM and remapping to it.  However, due to the lack of knowledge in this, I am unable to understand what this error means?

Error: L6971E: stm32f0xx_hal.o(.data) type RW incompatible with main.o(.ARM.__AT_0x20000000) type ZI in er RW_IRAM1.

Please help.

andy2
Associate II
Posted on October 12, 2015 at 08:24

Found out it is the address problem. However, still one problem not solved, can anyone tell me how to write the following lines using HAL driver?

    /* Enable the SYSCFG peripheral clock*/

  RCC_APB2PeriphResetCmd(RCC_APB2Periph_SYSCFG, ENABLE); 

  /* Remap SRAM at 0x00000000 */

  SYSCFG_MemoryRemapConfig(SYSCFG_MemoryRemap_SRAM);