Working with Flash memory

The NVM Subsystem

  • Data Memory Unit (DMU)
  • Program Flash Interface (PFI)
  • Non Volatile Memory Module comprising of the
    - Flash Standard Interface (FSI)
    - Program and Data Flash memories and
    - Program Flash Read Write buffer
  • Controls command sequences executed on all program and data flash memories.
  • Has separate command sequence interpreter for HSM and Host Cores.
  • Connects a PFLASH bank to a CPU core.
  • Executes erase, program and verify operations on all the flash memories.
  • It is used by the application to store program code and data constants.
  • Divided into one or more banks, each connected to a CPU.
  • The Data Flash Module is used to emulate EEPROM and store data.
  • This is supported for both the host core and HSM core.
  • DFLASH read accesses are relatively slow compared to PFLASH accesses.
  • Data Flash Module also contains regions to store configuration data
  • User Configuration Blocks (UCBs), and
  • Configuration Sector (CFS), which is not accessible by the user.

Definition of Terms

Flash Structure Reference
  • PFLASH: 8 pages (256 bytes).
  • DFLASH: 4 pages (32 bytes).
Size of flash memory structures
Minimum write and erase sizes for Program Flash and Data Flash
Word Sizes

How to handle Flash Memory in software

Reading Flash Memory

  • Reading Flash Memory is a lot easier than writing to it.
  • All read accesses to Flash are memory-mapped reads. Therefore, it does not need to go through the DMU and FSI of the NVM subsystem.
  • In code, reading a flash memory can be as simple as pointing to a location and getting the data.
  • To simplify reading larger amounts of data, one can implement a simple memcpy function.
  • Make it safe and reliable as per any coding guideline that you are following, MISRA-C, CERT etc.
  • Run the code quality checks on this using any tools like QAC or Polyspace.
  • Use this for all memory read operations.

Writing flash memory

  • Writing to flash memory is a little complicated.
  • Before you can write to flash memory, it needs to be erased. This is the physical nature of flash memory.
  • Erase operations are done at block levels. In our case, logical sector level. For PFlash 16kb memory size or 4kb/2kb in case of DFlash.
  • Write operations happen at page scales, for PFlash 32 bytes or 8 bytes in the case of DFlash.
  • All write and erase operations go through the DMU and FSI of the NvM Subsystem.
  • When the software requests a erase or write function, specific command sequences are sent to DMU.
  • These commands are written to the registers of DMU. DMU then sends instructions to FSI.
  • FSI operates over the flash memory to perform those operations. There are restrictions on the page boundary, logical sector boundary, physical sector boundary or bank boundaries in the drivers. Be sure to be aware of them when working with the erase and write operations.
  • Silicon vendors provide flash memory driver libraries for their chips. A typical flash erase function would look like this.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store