cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to boot from BANK2

THsu.1
Associate II

Hi, I am new to STM32G4 series. I am implementing dual bank firmware update on STM32G473 custom board. I've prepared two identical bin files(compiled to 0x08000000), and flashed them to 0x08000000 and 0x08040000.

With options bytes:

BFB2=0

nBOOT0=1

nBOOT1=1

nSWBOOT0=1

My board boot from BANK1 and function correctly.

Then I tried to change BFB2 to 1 with STM32CubeProgrammer to boot from BANK2. According to AN2606, it will first boot into system bootloader, and the loader will do valid bank check and boot from it.

However, our board boot into BANK1 code. But I've confirmed by debugger they've entered system loader before running BANK1 code.

I used the following code to check BANK, get_bank() always return 0

/**
  * @brief  get current bank
  * @retval int 0 for bank 1, while 1 for bank 2
  */
static inline int get_bank()
{
    return READ_BIT(SYSCFG->MEMRMP, SYSCFG_MEMRMP_FB_MODE);
}

8 REPLIES 8
Raouf
ST Employee

Hi THsu.1

In order to check whether the MCU has booted from BK2 or not, you can simply check if binary seen @0x08040000 is also mapped @0x00000000, so with CubeProgrammer try to show the content of those addresses. You can also check the FB mode bit and MEMRMP filed.

So please check BFB2 is set and make a power on reset then check if it works.

Regards,

RBEN

THsu.1
Associate II

0693W000000V7BSQA0.png

I read the contents of 0x00000000 with BFB2=1. It seems the mcu will start from bootloader. Which is like AN2606 says, system bootloader will help to check bank2 then do bank swap. . Is it really possible to check if system boot from bank2 with cube programmer? cube programmer will halt the mcu on connection

0693W000000V7BSQA0.png

 I've found that we can actually run mcu in the "CPU" tab in stm32cubeprogrammer

But bootloader doesn't re-map neither BANK1 nor BANK2 to 0x00000000

I read the contents of 0x00000000 with BFB2=1. It seems the mcu will start from bootloader. Which is like AN2606 says, system bootloader will help to check bank2 then do bank swap. . Is it really possible to check if system boot from bank2 with cube programmer? cube programmer will halt the mcu on connection

Oh I've found we can actually run mcu, simple go to "CPU Tab" in cube programmer and press run.

But after bootloader jumps to 0x08000000, 0x00000000 still remains bootloader's vector table

After a day of tracing, I found that I cannot read SYSCFG->MEMRMP register correctly.

SYSCFG->MEMRMP |= SYSCFG_MEMRMP_FB_MODE is able swap bank correctly.

I confirm with both CubeProgrammer and gdb by writing different words into each band and read out before and after band swap.

The problem is reading from SYSCFG->MEMRMP is always 0....

Were you eventually able to find a solution to your problem? I think I'm running into a similar issue...

Sorry, can you check the clock enable for SYSCFGR?

RCC->APB2ENR & RCC_APB2ENR_SYSCFGEN == 1

kip18
Associate II

I have the same issue, where you able to resolve the problem? How do you tell if your Bank2 program is incorrect