This tool allows you to read or write the nDBANK
bit on STM32F76x/F77x microcontrollers using a debug probe. It is based on the probe-rs
library.
To read the current state:
stm32-opts --chip STM32F767ZI ndbank
To set new value:
stm32-opts --chip STM32F767ZI ndbank false
While exploring the STM32F767ZI, I discovered that its flash memory can operate in one of two modes: a 2 MB single-bank mode or a dual-bank mode with 1 MB per bank. The factory setting for this particular chip is the single-bank mode.
In dual-bank mode, the firmware can execute from one bank while data is written to the other bank without stalling the CPU (read-while-write or RWW for short).
This capability is particularly important for real-time applications that need to perform the following tasks while the firmware is executing:
- Download firmware upgrades (swapped by the bootloader at the next boot)
- Update configuration data
- Log data to flash
Changing the flash mode alters the flash memory addressing scheme, which invalidates any firmware written for the previous mode. Therefore, the most practical approach is to configure the desired mode before flashing software to the device.
Alternative solutions exist, primarily ST's own STM32CubeProgrammer. However, incorporating a closed-source tool into the development process can be cumbersome. For example, STM32CubeProgrammer requires more than 1 GB of disk space.
Using the Rust embedded ecosystem for your newly configured dual-bank chip has additional challenges:
embassy-stm32
only supports the default flash mode.probe-rs
must use this flash algorithm which is not the default algorithm.