Programming non memory-mapped flash

From SEGGER Wiki
Jump to: navigation, search

There are different types of flash memories available to be connected to an MCU. Some are designed to allow execution in place where the flash is readable by the MCU in its address space (like RAM and peripheral registers are). Some other flashes can only be connected to certain peripherals and be accessed indirectly through the peripheral. These are called "non memory-mapped flashes". In the following some examples for non memory-mapped flashes are given.

Flash type MCU connection
Serial NOR flash Connected to a traditional SPI peripheral of the MCU. The flash contents cannot be read directly via memory-mapped accesses. The MCU needs to run an application that feeds the SPI peripheral to get the data from the flash and copy it into some addressable memory (e.g. RAM)
Parallel NAND flash Connected to a NAND flash controller of the MCU. The flash contents cannot be read directly via memory-mapped accesses. The MCU needs to run an application that feeds the NAND flash controller to get the data from the flash and copy it into some addressable memory (e.g. RAM)
Serial NAND flash Connected to a NAND flash controller of the MCU. The flash contents cannot be read directly via memory-mapped accesses. The MCU needs to run an application that feeds the NAND flash controller to get the data from the flash and copy it into some addressable memory (e.g. RAM)

Programming serial NOR flash

As the connection between MCU and the serial NOR flash is custom (many MCUs provide multiple SPIs the flash could be connected to), there is no out-of-the box solution available for J-Link to program such flashes indirectly through the MCU and the SPI. There are basically 2 options available for J-Link to program these types of flashes:

  1. Direct programming: J-Link is directly connected to the flash, no MCU in between. For more info about the setup, see article SPI Flash. Programming is done via J-Flash SPI software (for more info, see J-Flash SPI
  2. Indirect programming: J-Link is connected to the debug interface of the MCU and performs programming by feeding MCU peripherals via a flash loader temporarily downloaded to RAM (RAMCode). For more information about how to write such a flash loader, please refer to Adding Support for New Devices

Notes

  • When going for the indirect programming, a virtual address needs to be assigned to the serial NOR flash because all J-Link software is designed for address based flash programming. It is recommended to choose a virtual address for the serial NOR flash that is reserved in the MCU address space, so there is no overlap with other memories / peripherals etc.

Programming parallel NAND flash

As the connection between MCU and the parallel NAND flash is custom (some MCUs provide multiple NAND flash controllers the flash could be connected to), there is no out-of-the box solution available for J-Link to program such flashes indirectly through the MCU and the NAND flash controller. In order to program these devices: J-Link is connected to the debug interface of the MCU and performs programming by feeding the NAND flash controller via a flash loader temporarily downloaded to RAM (RAMCode). For more information about how to write such a flash loader, please refer to Adding Support for New Devices

Notes

  • NAND flashes do not only contain the pure application data but also have a so called spare area per NAND flash page. In this spare area, some additional information like ECC and bad block markers are placed. This area needs to be handled by the flash algorithm. It cannot be expected that the data for this area is provided by the application image that is programmed.

Programming serial NAND flash

See Programming parallel NAND flash