From SEGGER Wiki
Revision as of 15:01, 3 June 2020 by Nino (talk | contribs)
Jump to: navigation, search

STM32G4 option byte programming

For STM32G4 devices, the option byte page(s) can be programmed via J-Flash. When programming the option bytes, the following conditions must be met:

  • Per bank: All option bytes must be written in one go. It is not possible to only write - for example - one word.
  • Reserved bits must be written with "1" otherwise writing the option bytes will not work as expected and the verify of the written area will fail.

STM32G47xx Flash Dual Bank Mode

The ST STM32G47xx series devices come with a dual-bank flash memory. The layout of the dual-bank flash memory can be configured by the user through the option byte nDBANK. By default, the value of this option byte is DBANK == 1, which means that the flash is configured as dual bank memory while DBANK == 0 means that the flash is configured as single bank memory flash. The total flash size is exactly the same for both modes.

Problem description

  • The sector layout is different depending on the DBANK bit
  • The flash algorithm has to behave different (pass different sector indices to erase sector)

By default, the J-Link flash loader assumes that the flash controller is configured for the dual bank flash layout (DBANK == 1) because it is the default configuration. In case of the flash controller is configured for the single bank flash layout (DBANK == 0), the default flash algorithm / sector layout won't work.


When operating the flash in single bank flash mode (DBANK == 0), the flash algorithm as well as the sector layout used by the J-Link DLL needs to be overwritten. This can be done using the SEGGER Open Flashloader. Please find below three precompiled flash algorithms, one for the 128KB, one for the 256KB and one for the 512KB variant of the STM32G47xx device series. The algorithms assume that the flash is configured in single bank mode. Detailed information how to use the precompiled flashloaders can be found here:

Tracing on STM32G4 series

This section describes how to get started with trace on the ST STM32G4 MCUs. This section assumes that there is already a basic knowledge about trace in general (what is trace, what different implementations of trace are there, etc.). If this is not the case, we recommend to read Trace chapter in the J-Link User Manual (UM08001).


  • The sample projects come with a pre-configured project file for Ozone that runs out-of-the box.
  • The following sample project is designed to be used with J-Trace PRO for streaming trace and Ozone to demonstrate streaming trace.
  • In order to rebuild the sample project, SEGGER Embedded Studio can be used.
  • All examples are shipped with a compiled .JLinkScriptfile (.pex), should you need the original source it can be requested at

Tracing on ST STM32G484

Minimum requirements

In order to use trace on the ST STM32G484 MCU devices, the following minimum requirements have to be met:

  • J-Link software version V6.80a or later
  • Ozone V3.20 or later (if streaming trace and / or the sample project from below shall be used)
  • J-Trace PRO for Cortex-M HW version V1.0 or later for streaming trace

Streaming trace

The project has been tested with the minimum requirements mentioned above and a STM32G474-EVAL board.

Example project:


The eval board used for this example setup needs some hardware modifications for trace to work reliably as the trace pins are shared with multiple peripherals that would otherwise impact the signal quality. For more information consult the boards user manual. Please note that these modifications will also disable the JTAG interface so only SWD can be used on this particular board in parallel with pin tracing.

Tested Hardware

This project has been created and tested on a STM32G474-EVAL board.

Reference trace signal quality


Trace clock signal quality


Rise time


Setup time