cancel
Showing results for 
Search instead for 
Did you mean: 

FLASH TWO CODES ON SAME CONTROLLER (STM32F7)

Faiz Ahmed
Associate II
Posted on January 03, 2018 at 05:30

Hi,

i am trying to flash two different codes on same controller at different memory locations, at power-on condition code-1 will be executed, from that code i want to call code-2. i tried below method which is not working (ONLY CODE-1 IS GETTING EXECUTED), can anyone suggest any other method or any modifications needed to this code.

code-1: at memory location 0x8000000

int main (void)

{

      fp = (int(*)(void))0x80400000;                            //Here i am using function pointer to call another code

while(1)

   {

         printf(' this is code-1 \n');

         int (*fp)(void);

    }

}

code-2:at memory location 0x8040000

int main (void)

{

         printf(' this is code-2 \n');

}

#multiple-codes-on-single-controller #stm32 #flash #stm32f7 #function-pointer
4 REPLIES 4
Nesrine M_O
Lead II
Posted on January 03, 2018 at 08:03

Hi

faizahmed7799

,

I recommend you to have a look to ready examples under the STM32CUBEF7,it may help you to start:

  • STM32Cube_FW_F7_V1.8.0\Projects\STM32756G_EVAL\Applications\IAP
  • STM32Cube_FW_F7_V1.8.0\Projects\STM32F769I-Discovery\Examples\FLASH\FLASH_SwapBank

-Nesrine-

Posted on January 04, 2018 at 13:31

Is the code actually starting at 0x08040000 or is that the vector table for the secondary image?

Jumping to an EVEN address on an Cortex-M is going to Hard Fault, have a handler that outputs some diagnostics.

Maybe review a manual, or two, on the Cortex-M parts so your understanding of how they work is clearer.

Use a debugger and step the code to understand what happens.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Doug Kehn
Senior
Posted on January 04, 2018 at 14:49

The second image can certainly be loaded at 0x8040000 (in either single/dual-bank mode) but as Clive indicated, 0x8040000 will be the vector table. You will need to look at the linker map file to determine where the second main() is located to compute the address to call from the first main().

Do you have the Option Bytes set for dual-bank mode? I assume from the use of address 0x8040000 for the second image that you are using STM32F7 with 512K of flash. If you are interested in dual-bank mode, in addition to the examples code references from Nesrine, look at

http://www.st.com/content/ccc/resource/technical/document/application_note/group0/ab/6a/0f/b7/1a/84/40/c3/DM00230416/files/DM00230416.pdf/jcr:content/translations/en.DM00230416.pdf

.
Posted on January 04, 2018 at 14:59

...I should have included this

http://www.st.com/content/ccc/resource/training/technical/product_training/91/e3/aa/26/e6/69/4f/de/STM32L4_Memory_Flash.pdf/files/STM32L4_Memory_Flash.pdf/jcr:content/translations/en.STM32L4_Memory_Flash.pdf

as well. Even though it references STM32L4, most of the information is applicable to STM32F7 as well.