cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G474RET6: Always boot from bank1 and to jump bank2

AlexHalf
Associate III

Hello

In STM32G474RET6 I want to have 2 banks. Bank 1 for golden (boot image) and Bank 2 for an application image.

As I want to have a robust solution I always want to boot from Bank 1 (address: 0x8000000), to check if valid firmware exist in Bank 2 (address 0x8040000) and if ok to jump to Bank 2 and to run firmware stored there.

My code based on FLASH_DualBoot example of STM32Cube_FW_G4_V1.5.0 is working ok, but it is not good enough for me as it toggle the boot between Bank 1 and Bank 2. 

Where I can't find simple example code that will simply jump to Bank 2 from Bank 1 (and still remain boot from Bank 1 after next power up)?

 

Thank you.

 

Alex

1 ACCEPTED SOLUTION

Accepted Solutions
FBL
ST Employee

Hello @AlexHalf 

It is not possible that example code jump to Bank 2 from Bank 1 (and still remain boot from Bank 1 after next power up). This is because when BFB2 bit is set, the system memory remains aliased at @0x0000 0000 as detailed in the reference manual.

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

5 REPLIES 5
liaifat85
Senior III

To implement a solution where you can jump from Bank 1 to Bank 2 and persistently boot from Bank 1 on subsequent power-ups, you need to carefully manage the boot configuration and set a flag or identifier that indicates the selected bank. You can try with the  STM32 HAL library.

Why I need flag indicating selected bank? Firmware programmed in each bank are different.

If currently running firmware in Bank 1 there will be an option to jump only to Bank 2 (and back from Bank 2 to Bank 1).

What specifically to look in STM32 HAL library?

Is there any code example for a jump between banks (without toggling BFB2 bit)? 

I am not a software developer (but a hardware developer) - but still need to implement this jump in firmware.

So please elaborate any suggestions with examples.

Thank you.

Alex

FBL
ST Employee

Hello @AlexHalf 

It is not possible that example code jump to Bank 2 from Bank 1 (and still remain boot from Bank 1 after next power up). This is because when BFB2 bit is set, the system memory remains aliased at @0x0000 0000 as detailed in the reference manual.

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

>>Is there any code example for a jump between banks (without toggling BFB2 bit)? 

It's surely just a control transfer, code and vector builds at the address you have for the second bank. Be that 0x08100000 or 0x08008000 ..

Make the linker fixup the __Vectors  or _gfnVector you write into SCB->VTOR, and use a c function pointer. None of this is magically different from any other IAP that would be viable for a single bank (or non swapping) solution.

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

The other alternative if you must have things built for the same address basis and perhaps swap at some point. Say one image which has a version / sequence number and you always want to run the newest valid / signed version.

Implement something like fork(), have the exact same code in the front of both banks, a loader, determine which image is the desired one, and then just change the mapping as you're executing, flow will then take you into the image you want.

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