Programming flash memory

Flash is a common type of non-volatile memory used to store code and data. DS-5 Debugger can erase and write NOR flash memory, provided that a suitable flash algorithm is available. NOR flash memory is usually mapped into the address space of the processor, and in this case its contents can be read using the normal debugger memory read operations, such as the x command and the Memory view. Other types of flash memory, such as NAND flash, are not supported by DS-5 Debugger, and you must use alternative methods to access these, such as software supplied with any target operating system you are running or by using tools supplied by your processor or board manufacturer.

Show/hidePrerequisites

Before carrying out any flash programming operations you must register your flash algorithm with the debugger.

Show/hideProcedure

You must define a suitable memory map for your algorithm before the debugger can carry out flash programming operations. To do this:

  1. Use the memory flash command to define a region of flash memory and insert it into the memory map for the target. :

    memory flash 0x08000000 0x0801FFFF Keil.STM32F10x_128.FLX clockSpeed=8000000
                # Defines a flash region for Keil.STM32F10x_128.FLX algorithm
    

    Note

    To use the memory flash command you must have a valid ARM® Compiler license file.

  2. Use the memory command to define a region of RAM and insert it into the memory map for the target. :

    memory 0x20000000 0x20004FFF     # specify RW region 0x20000000 0x20004FFF
    
  3. Use the info memory command to verify the memory map for the target.

  4. Use the set flash-buffer command to define a region of RAM memory for use as a buffer when programming flash memory. The memory range is written to as part of flash programming, and the original content is not restored afterwards. For example, to define the buffer shown in the figure you can use the following:

    set flash-buffer 0x20000100 0x20004EFF # set flash buffer
    
  5. When all the regions are set up then you can use the same commands that you normally use when writing to RAM.

    :

    load myFlashImage.axf                  # Image that loads into flash
                                           # memory addresses
    restore myFile.bin binary 0x08000000   # Restore content of binary file
                                           # myFile.bin starting at 0x08000000
    

The following figure shows the memory map for this example.

Figure 27. Memory map showing flash regions

To view this graphic, your browser must support the SVG format. Either install a browser with native support, or install an appropriate plugin such as Adobe SVG Viewer.


Show/hideSee also

Copyright © 2010, 2011 ARM. All rights reserved.ARM DUI 0446H
Non-ConfidentialID111711