cancel
Showing results for 
Search instead for 
Did you mean: 

How to configure swap bank on STM32H7 P2

FBL
ST Employee

How to configure swap bank on STM32H7? (Part 2)

Following Part 1

Step 3: Building Binary file for Bank1

1. Add FLASH_BANK1 as preprocessor: Project Options> C/C++ Compiler > Preprocessor1666.png

2. Check that vector table settings are as following (Project Options > Linker > Linker Configuration File Editor):
  • _intvec start: 0x08000000
  • ROM Start: 0x08000000 under Memory Regions
  • ROM End: 0x080FFFFF under Memory Regions
1667.png
3. In output converter, select Raw binary and name the output file for bank1 as shown in the figure below
1668.png
4.  Build the first part of the program dedicated to BANK1.
 

Step 4: Building binary File for Bank2

Next, let us update the configuration for Bank2. Let us follow these steps.
 
1. Remove the previously added defined symbol preprocessor: FLASH_BANK1
2. Make sure that Linker Configuration is the same.
  •  _intvec start: 0x08000000
  • ROM Start: 0x08000000 under Memory Regions
  • ROM End: 0x080FFFFF under Memory Regions
 
3. Go back to Output Converter and change the name of the binary file as follows.
1669.png

Step 5: Execute the binaries & check behavior
Use CubeProgrammer to connect and download the binary files.

  1. From Download>file path, select the path of your binary SWAP_Bank1.bin ( it should be under your workspace: xx\Swap\EWARM\Swap_CM7\Exe)
  2. Make sure that the start address is 0x0800 0000
  3. Click on download.
1670.png
    4. The same way as previously described; you can download the second binary file at the start address of Bank2 (0x0810 0000).
  1671.png
At this level, you can disconnect from STM32CubeProgrammer. You can check that: 
  • LED1 (Green led) is blinking ==> code execution from Bank1 
  • Once you press on user push button or tamper then on reset, LED2 (yellow led) will be blinking ==> code execution from Bank2 
For further tests, you can write in the flash for example starting from 0x08003232 in bank1. You can see the content is swapped to 0x08103232.
Program counter should be always started executing from 0x0800 0000.

 

Conclusion

Now, we can conclude that we have two different codes in two different banks of the flash memory on STM32H745. The user can adjust the code in the first bank then swap to the second bank to run a different code.
Same example should be working for CubeIDE. Don't hesitate to come back if still having issues.
 
Version history
Last update:
‎2024-01-04 06:52 AM
Updated by:
Contributors