cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G4 flash banks description ambiguity

Wasilewski.Piotr
Associate III

Hello,

I'm currently designing a bootloader and an application for stm32g474ccu6 MCU (256kB flash). Today I wanted to implement a bootloader feature allowing the user app to take up more than one flash bank in flash memory (Im working in dual bank mode - the default configuration). It's not really clear to me how the RM0440 flash layout looks like for a 128 or 256 kB flash. Let's assume a 256 kB version:

  • are the banks divided into two 128 kB chunks and then the second bank start address is equal to 0x08002000?
  • or are they rather discontinued with a gap-flash region in between (the bank2 start address in the RM seems to be constant?)

I tested it and to my surprise, I was able to program the flash memory using bank1 setting in HAL library and addresses starting at 0x08001f800 (presumably the last page of bank 1) going for 40 kB (presumably first pages of bank 2)! This actually contradicts both of my theories - it seems my stm32g474ccu6 acts completely as a 512 kB unit (even considering the bank division). How is that possible?

I can actually read the whole 512 kB memory (its the same die across different flash versions just not tested right?), so I'm guessing the division between banks is always made at 0x0804 0000, but there's a region of discontinuity that may or may not work (depending on the manufacturing process?).

Best Regards,

Piotr Wasilewski

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

On this, the RM clearly states they're consecutive in single bank mode.

Your question is answered nicely by ST here:

https://community.st.com/s/question/0D50X0000BrDcCsSQK/flash-layout-of-stm32g4xx-cat-3-with-less-than-512-kbyte-missing-in-rm0440

The STM32CubeMX generated script is correct for single bank mode.

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

9 REPLIES 9
Bruno_ST
ST Employee

Hello @Wasilewski.Piotr​ 

Yes it is same die, except that the manufacturing process (and so ST) doesn't guaranty that the remaining part of the FLASH is fully functional as it is not tested.

BR,

Bruno

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.

Wasilewski.Piotr
Associate III

Ok, thank you, that's pretty clear to me, but what about the flash address space? Does it have a gap in it in case the address bonds to that part of the memory are cut at the factory or the untested block is corrupted? Where does the second flash bank start in the 128 kB and 256 kB versions?

Best Regards,

Piotr Wasilewski

Bruno_ST
ST Employee

0693W00000JOcjmQAD.pngHere is your answer in the RM0440 Table 7. Flash module - 512/256/128 KB dual bank organization (64 bits read width).

Br,

Bruno

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.

Wasilewski.Piotr
Associate III

I'm sorry but that does not answer my question. I've seen the table and analyzed it a few times but I still cannot understand how can it be that two banks can have different sizes (in different flash size variants), yet the second one always (in all memory size variants) starts at a constant address. Does it mean there's a gap in the address space in the 128 kB and 256 kB memory variants?

Best Regards,

Piotr Wasilewski

TDK
Guru

> Does it mean there's a gap in the address space in the 128 kB and 256 kB memory variants?

Yes.

The table is (awkwardly) saying that each bank has half the capacity of the total. The start of bank 2 is the same in all cases.

If you feel a post has answered your question, please click "Accept as Solution".
Wasilewski.Piotr
Associate III

@TDK​  thank you this is what I needed. So basically the default linker scripts (generated from cubeIDE) are incorrect (as they suggest a constant memory addresses space from 0x8000000) and can cause troubles when I surpass the 128kb boundary (in my MCU 256 kB version) since by default its in the double bank mode?

What about a single bank configuration? Is there still a gap or the addresses are mapped to a continuous space?

Best Regards,

Piotr Wasilewski

TDK
Guru

On this, the RM clearly states they're consecutive in single bank mode.

Your question is answered nicely by ST here:

https://community.st.com/s/question/0D50X0000BrDcCsSQK/flash-layout-of-stm32g4xx-cat-3-with-less-than-512-kbyte-missing-in-rm0440

The STM32CubeMX generated script is correct for single bank mode.

If you feel a post has answered your question, please click "Accept as Solution".
Wasilewski.Piotr
Associate III

Ahh, thank you now this is clear! I must have missed this topic when I searched for a similar question.

Thank you!

Hello

For me is not clear, i use a stm32g491rct6 with 256k flash in factory dual bank mode, the project created with cubeide 1.15.1 map all flash in contiguos mode from 800000 to 803ffff, so the linker load the firmware in the "gap zone"?

Another thing is that when I use cubeprogrammer 2.17 with the same micro displays the blocks with strange index and here I try to delete a block in the second bank tries to execute and remains in infinite hang loop