Writing an image to flash memory

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

Show/hidePrerequisites

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

Note

To use this feature you must have a valid ARM® Compiler license file.

Show/hideProcedure

To set up the memory map and write an image to flash memory:

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

    memory flash 0x08000000 0x0801FFFF Keil.STM32F10x_128.FLX clockSpeed=8000000
                # Defines a flash region for Keil.STM32F10x_128.FLX algorithm
    
  2. Use the mem command to define a region of RAM and insert it into the memory map for the target. For example:

    memory 0x20000000 0x20004FFF     # specify RW region 0x20000000 0x20004FFF
    
  3. Use the info mem 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.

    For example:

    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 22. 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 ARM. All rights reserved.ARM DUI 0446B
Non-ConfidentialID100410