Skip to main content
Scotty55
Associate III
June 27, 2026
Solved

STM32G474 flash im single bank mode

  • June 27, 2026
  • 6 replies
  • 141 views

I am using STM32CubeIde version 2.1.1, STM32CubeMX version 6.15.0, Segger JLink, and a STM32G474RB chip.

The CubeMX generates a linker file which looks like single bank flash mode, I have uploaded the ioc and ld files.

With CubeProgrammer, I set the option bits to DBANK = 0 for single mode or DBANK = 1 for dual mode.

In every case the debugger stops flash programming at 0x08010000 (64kB), all beyond 0x08010000 reads 0XFFFFFFFF.

That leads to a hard fault right after starting a debugger session.

How can I fix this problem?

And no, I can’t switch to dual mode as the text section file exceeds 64kB, and I can’t update the CubeMX as all versions 6.16 and 6.17 contain a HRTIM configuration bug.

Best answer by AScha.3

>How can I fix this problem?

A: buy a chip with enough continuous flash for your program, STM32G474RE . or -C , if some cents are important.

btw. I just looked at mouser, 474RC is 30 cents more expensive than 474RB .

 

B: just for a test, until you have the cpu version with enough flash :

As there is the same die inside :

….you can try: make a new project , with Cube, set it to: STM32G474RE .

Generate…, then copy your program to main…, compile and try debug. If flash is not disabled, it should work.

  • or try: make  a new project , with Cube, set it to: STM32G474RE . Generate code.
  • Then look in the linker file, whats different and write it to your linker file; then try debug...

6 replies

AScha.3
AScha.3Best answer
Super User
June 28, 2026

>How can I fix this problem?

A: buy a chip with enough continuous flash for your program, STM32G474RE . or -C , if some cents are important.

btw. I just looked at mouser, 474RC is 30 cents more expensive than 474RB .

 

B: just for a test, until you have the cpu version with enough flash :

As there is the same die inside :

….you can try: make a new project , with Cube, set it to: STM32G474RE .

Generate…, then copy your program to main…, compile and try debug. If flash is not disabled, it should work.

  • or try: make  a new project , with Cube, set it to: STM32G474RE . Generate code.
  • Then look in the linker file, whats different and write it to your linker file; then try debug...
If you feel a post has answered your question, please click on " Best Answer ".
Scotty55
Scotty55Author
Associate III
July 3, 2026

Thank you AScha.3, this trick solves my problem, though it’s a bad trick. The CubeIde should handle the flash configuration rightly, in single and dual bank mode

Associate
June 28, 2026

The linker script generated by CubeMX might still have FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 64K even in single-bank mode — open the .ld file and verify LENGTH is 128K.

Also confirm the option bytes are actually being written. CubeProgrammer sometimes shows the change but doesn't commit it — power cycle the board after writing option bits, don't just reset.

For JLink specifically, make sure the device name in your debug config is STM32G474RB and not a generic G4 entry. Wrong device name = JLink uses wrong flash algorithm = stops at 64K.

Ghofrane GSOURI
ST Technical Moderator
July 1, 2026

Hello ​@Scotty55 

The HRTIM issue has been fixed in the latest version of STM32CubeMX 6.18.0

Download STM32CubeMX6.18.0 from  here 

THX

Ghofrane

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.
Scotty55
Scotty55Author
Associate III
July 3, 2026

Please note my Flash experiences as a bug. CubeIde with Segger JLink can’t handle STM32G474xx in single and dual bank mode.

The gap between the banks is ignored and so the instruction pointer may hit non initialized address space. And there is no warning when in dual bank mode e.g. the text segment size exceeds the first bank size.

Scotty55
Scotty55Author
Associate III
July 3, 2026

ignore this...