Flash Center Software should be used with our Cheetah SPI Host Adapter to program large files to SPI flash memory. A common use case related to this topic is loading field-programmable gate array (FPGA) images to different addresses within SPI flash memory.
When loading large files, you often need to program one sector of memory while leaving others unaffected. In this tutorial, we will review how you can achieve that objective.
We will start by providing useful background information and context to help you understand the software and components involved and then dive into the process.
Before you begin, you will need the following items:
Note: a Promira Serial Platform can be used to achieve similar functionality
An SPI flash device like the SPI Flash Demo Board
The Flash Center Software offers four programming modes: Program + Verify, Program, Program (No Erase), and Erase Cycle. It is useful to understand the behavior of the software in each of the modes before programming your device. Below, we will provide explanations for each.
Program + Verify mode writes data to one or more attached memory devices and then reads back the data to verify it. If the device is an SPI Flash, an erase cycle is performed first. The erase will affect only the sectors of memory that will be written to.
If a write ends in the middle of a sector, it is possible to erase more data that is written. If more data will be erased than written, a warning will be logged. Additionally, if the data to be written is large enough to require the entire memory of the device to be erased, and the memory device has an “erase all” function, the Flash Center Software will use the device’s “erase all” function.
Program mode writes data to the device but does not perform a verification step. If the device is an SPI Flash device, an erase cycle will be performed first, with the same caveats as Program + Verify mode.
Program (No Erase) mode is a special mode for use with 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 a pad value when loading each memory image to avoid corrupting previously written data. As the device may have been programmed prior to the operation, there is no verification step.
Erase Cycle allows you to erase the entire memory device or select a portion to erase. To select a portion of memory to erase, you must specify the start address and the length in the Erase Parameters dialog box.
If a device does not have an erase instruction, zeros are written to the specified range within the device. Otherwise, refer to the memory device’s data sheet for its erase behavior.
For additional information about Flash Center Software program modes and more details on the software, review the Flash Center manual.
To program a single memory sector using the Flash Center Software, you will take advantage of the following properties of flash devices:
Programming a flash device can only change the value of a bit from 1 to 0 and has no affect when attempting to change a bit from 0 to 1.
Erasing a flash device changes all the bits in a sector (or the entire device) to 1.
By manually erasing specific sectors along with using the Program (No Erase) mode, data can be written to any sector of a flash device without affecting other sectors.
We will use a specific flash device in our process: the SPI Flash Demo Board. This demo board uses a Micron SPI Flash M25P32. While the process is generally applicable to a variety of flash devices, it will be helpful for you to understand the characteristics of the Micron SPI Flash M25P32 to get the most out of this tutorial and best apply it to your use case.
The 32 Mb (4 MB) 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 entire memory can be erased using the Bulk Erase function. Alternatively, and more usefully in this scenario, memory can be erased a sector at a time, using the Sector Erase instruction. For additional information about the M25P32 review the M25P32 datasheet.
This process describes how to use the Cheetah SPI Host Adapter to program data to the first sector, then program data to the second sector without overwriting the data in the first. You can find the latest software and drivers on our downloads page.
Download and install the latest version of the Total Phase USB Drivers Installer.
Download and unzip the latest version of Flash Center Software.
Connect the Cheetah adapter to your PC using the USB connector.
Connect the Cheetah adapter to the SPI flash demo board using the 10-pin header.
Launch the Flash Center Software.
Connect the Cheetah adapter to Flash Center. In the Flash Center software:
Click Adapters > Add Adapter.
Select the Cheetah adapter.
Click Add to connect the adapter.
Enable Target Power to provide power to the SPI Flash Demo Board.
Click Operations > Choose Target and choose STMicro M25P32.
Read the contents of the memory device.
Click Operations > Read Target
Write zeros to the first two sectors of the device.
Clear the data buffer by clicking on the Clear button. This only clears the software buffer and does not change the data on the device.
Enter 00 in the Pad field.
Click the Fill... button, enter a byte count of 131072 (64k x 2 = size of first two sectors), and click OK.
Click Operations > Program + Verify to commit the new buffer to the device.
Program 8 bytes to the start of the device and notice that Flash Center erases only the necessary sectors.
Clear the data buffer by clicking on the Clear button.
Type 00 11 22 33 44 55 66 77 in the first 8 bytes in the Data section.
Click Operations > Program + Verify then click Yes. Note: a warning is displayed because the data supplied does not end on a sector boundary. The entire sector will be erased before programming.
Click Operations > Read Target.
Note how the first 8 bytes are as expected and the rest of the first sectors are all 0xFF. Additionally, note that the second sector remains all 0x00.
Use the Program (No Erase) option to program data to the second sector and not affect the first. Before doing so, you need to ensure the target sector has been erased.
Click Operations > Erase...and select a specific address range starting at 0x10000 with a length of 1. Note: Flash Center will erase only the necessary sectors to cover the supplied range. In this case, only the second sector will be erased.
Click OK > Yes to erase the entire second sector.
Program 8 bytes to the start of the second sector while not affecting the contents in the first sector.
Clear the data buffer by clicking on the Clear button.
Enter FF in the Pad field.
Click the Fill... button, enter a byte count of 65536, and click OK. This data will fill the entire first sector and be used as padding since programming 1s, without first erasing, does not affect existing data.
Type 88 99 AA BB CC DD EE FF at the start of the second sector (address 0x10000).
Click Operations > Program (No Erase) to commit the new buffer to the device without first performing an erase.
Click Operations > Read Target.
Note how the first 8 bytes of the device remain 00 11 22 33 44 55 66 77 and the first 8 bytes of the second sector are 88 99 AA BB CC DD EE FF.
That’s all! The process is complete. We hope this tutorial was helpful in explaining how to program a single sector of an SPI flash device using our products! If you have questions about the Cheetah SPI Host Adapter, Flash Center Software, or any other Total Phase products, please to contact us at sales@totalphase.com. You can also request a demo!