cancel
Showing results for 
Search instead for 
Did you mean: 

Boot from flash bank 2 broken on STM32G483VE

TDani.2
Associate II

This is the same problem described in this thread, except the proposed solution does not fix the issue: https://community.st.com/s/question/0D50X0000CEqc1SSQR/dual-boot-on-the-stm32g4-not-quite-working-boot-from-second-bank-fails?t=1591957302322

Basically, I can't get the STM32G483VE to boot from flash bank 2, despite my stack pointer being correct. The bootloader always falls back to flash bank 1.

What works:

  • Program stored in flash bank 1 at 0x8000000
  • Flash option bytes set to 0xD8EE8DAA

What doesn't work:

  • Same exact program stored in flash bank 2 at 0x8040000
  • Flash option bytes set to 0xD8FE8DAA

Other details:

  • The stack pointer is set to 0x20002000, which is 8KiB after the start of SRAM1
  • Bootloader version read from 0x1FFF6FFE is 0xFFFF00D4, so 13.4
  • The program is always linked to run from 0x8000000, even when stored in flash bank 2

My test program does a ping pong between both flash banks:

  1. Check which bank is the current one by checking FB_MODE in SYSCFG_MEMRMP
  2. Mass erase the other bank
  3. Copy 256KiB from 0x8000000 to 0x8040000
  4. Set or clear BFB2 in FLASH_OPTR
  5. Reload option bytes

All of these steps work, except FB_MODE is never set at boot because the bootloader is always falling back to flash bank 1. There does not seem to be any reason for the bootloader to reject the stack pointer.

  • Are there any other conditions that have to be met for the bootloader to boot on flash bank 2?
  • Is it correct that the bootloader sets FB_MODE on its own when booting from flash bank 2?

Note: I'm not using STM32Cube, my firmware is custom and runs on a custom board.

0 REPLIES 0