I2C SPI USB CAN eSPI Cable Testing View All Quick Start Guides User Manuals Software Downloads Knowledge Base Videos Case Studies App Notes White Papers Sales Support About Us
Products Blog Sales Support Contact Search
Programming SPI Flash Using Aardvark Adapter and Flash Center
Programming SPI Flash Using Aardvark Adapter and Flash Center

Introduction

Programming SPI memory devices is a common use case for the Aardvark Adapter. There are several ways to do this with the Aardvark adapter, including using Control Center, Flash Center, or the Aardvark API. Using the Aardvark adapter with the Flash Center software makes it extremely easy to program EEPROM and flash devices. With one Flash Center click the user can erase, program, and verify an entire device. This article focuses on how to program SPI flash with Flash Center and Aardvark adapter. Although the following describes the ST Micro SPI Flash M25P32 assembled on the SPI Flash Demo Board, similar steps can be used for other devices. The goal of this article is to demonstrate how to program SPI flash and then read back the data

Overview

In this article the Aardvark adapter erases, programs and reads the M25P32. Here the Aardvark adapter is the SPI master and the SPI flash on the SPI Flash Demo board is the SPI slave.

It's first helpful to understand the different operations options provided by Flash Center. Specifically, there are three programming modes: Program + Verify, Program, and Program (No Erase). In addition there are Read Device, Verify, and Erase operations.

    • Program + Verify - Writes data to one or more attached memory devices and then reads back the data to verify it for correctness. If the device is an SPI Flash, an erase cycle will be performed first. The erase will cover only those sectors which will be written. Note that it is possible to erase more data than is written if a write ends in the middle of a sector. A warning will be logged if this is the case. Also, if the data to be written is large enough to require the entire device to be erase, and the memory device has an “erase all” instruction, the software will use the “erase all” instruction.

 

    • Program - Writes data to the device, but does not perform the verification step. If the device is an SPI Flash, an erase cycle will be performed first, with the same caveats as Program + Verify.

 

    • Program (No Erase) - A special mode for SPI Flash devices. It writes data to the device, but does not perform an erase cycle. This is useful if multiple memory images are to be programmed to the device. Use FF as the pad value when loading each memory image to avoid corrupting previously written data. Because the device may have been programmed prior to this operation, it does not perform the verification step.

 

    • Read Device - Reads the contents of the selected device and replaces it in the current contents in the data buffer.

 

    • Verify - Verifies the contents of the selected devices against the contents of the data buffer.

 

    • Erase - Allows the user to erase the entire memory device or allows the erasure of portion of it. For partial erasure, users can specify the start addresses and length in the erase parameters dialog as either a decimal value or as a hexadecimal value.

 

M25P32 Details

The 32 Mbit (4M bytes) SPI Flash M25P32 found on the SPI Flash Demo Board has 64 sectors. Each sector has 256 pages or 65,536 (64K, 0x10000) bytes. Each page has 256 bytes. Therefore, the memory has 16,384 pages or 4,194,304 (0x400000) bytes. The whole memory can be erased using the Bulk Erase instruction, or a sector at a time, using the Sector Erase instruction. For reference, provided below are the M25P32 instructions list and memory map. For additional information about the SPI Flash M25P32 take a look at the M25P32 datasheet.

Figure 1: M25P32 Memory Map

M25P32 Sectors Map

Figure 2: M25P32 Instructions List

Memory Programing and Reading Guidelines

    1. Download and run the latest version of the Total Phase USB Drivers Installer.
    2. Download and unzip the latest version of Flash Center. (?)
    3. Connect the Aardvark adapter to the PC via the USB connector.
    4. Connect the Aardvark adapter to the SPI Flash Demo board via the I2C/SPI connector. (?)
    5. Launch Flash Center. (?)
    6. Connect the Aardvark adapter to Flash Center. (?)
      1. Click Adapters > Add Adapters.
      2. Select the Aardvark adapter.
      3. Click Add to connect to the adapter.
    7. Enable Target Power. (?)
    8. Click Operations > Choose Target and choose M25P32. (?)
    9. Configure Bit Rate to 8 MHz. (?)
    10. Read the memory device (?).
      1. Click Operations > Read Target.

Figure 3: Aardvark Adapter Reads From M25P32

    1. Program the M25P32, and read (?).
      1. Click Operations > Program + Verify > Click OK.
      2. Click Operations > Read Target.

Figure 4: Aardvark Adapter Writes to M25P32 and Reads

Notes

For additional information, take a look at the Aardvark adapter user manual, Flash Center manual and SPI Flash Demo Board User Manual.