embassy-stm32

Crates

git

Versions

stm32h745zg-cm4

Flavors

Skip to main content

Module flash

Module flash 

Source
Expand description

Flash memory (FLASH)

Flash gives access to the whole internal flash, addressed by offsets from FLASH_BASE. Flash::into_regions and Flash::into_blocking_regions split it into one driver per flash region (bank, or group of equally sized sectors), which can be handed to different parts of the application.

The driver is shared by all families. Writes are done in units of WRITE_SIZE bytes, which is the native program unit of the chip (a half-word on F0/F1/F3, a 256-bit flash word on H7, …), and erases are done per sector/page.

§ECC

Many families protect each flash word with an error correction code:

  • Single-bit errors are corrected transparently.
  • Two (or more) bit errors can’t be corrected. The read fails with Error::Ecc.

With the Cortex-M7 data cache enabled, a read also fails when another flash word of the same 32-byte cache line has an uncorrectable error.

§EDATA

On H5 and C5, part of the flash can be used as EDATA (“flash high-cycle data” on H5): flash with 16-bit words and a higher endurance, meant for storing data. It is enabled in the option bytes (EDATA_EN on C5, EDATA1_EN/EDATA1_STRT and EDATA2_EN/EDATA2_STRT on H5). FlashLayout::edata_bank1 and FlashLayout::edata_bank2 are Edata drivers for the EDATA area of each bank.

§EEPROM

L0 and L1 have a data EEPROM, which can be rewritten without erasing it first. FlashLayout::eeprom is an Eeprom driver for it.

Structs§

Bank1Region
Bank2Region
Config
Flash driver configuration.
Flash
Internal flash memory driver.
FlashLayout
FlashRegion
Flash memory region
FlashSector
Flash sector.
InterruptHandler
Flash interrupt handler.

Enums§

EraseParallelism
Parallelism used for flash erase operations.
Error
Flash error
FlashBank
Flash bank.

Constants§

BANK1_REGION
BANK2_REGION
FLASH_BASE
FLASH_REGIONS
FLASH_SIZE
MAX_ERASE_SIZE
READ_SIZE
Read size (always 1)
WRITE_SIZE

Functions§

banks_swapped
Returns whether flash banks 1 and 2 are currently swapped in the memory map.
get_flash_regions
Get all flash regions.