eeprom Read, write, erase, verify, test, dump SPI EEPROMs

eeprom is a command to read, write, erase, verify, test and dump common 25x SPI EEPROMs.

SPI EEPROM list supported devices

I2C> eeprom list
  • eeprom list - list all EEPROM devices supported by the eeprom command
Product(s)DensitySize (bytes)Page Size (Bytes)Address BytesBlock Select Bits
AT25010B1 Kbit128810
25AA/LC010A1 Kbit1281610
AT25020B2 Kbit256810
25AA/LC020A, 25AA02UID (32 bit ID, 0XC0 locked, location 0xFA-0xFF)), 25AA02E64/48(64 or 48 bit EUI-x Node Address, 0XC0 locked, location 0xFA-0xFF or 0xF8 to 0xFF)2 Kbit2561610
AT25040B4 Kbit51281opcode 0x02 bit 3
25AA/LC040A4 Kbit512161opcode 0x02 bit 3
25AA/LC080C8 Kbit10241620
AT25080B, 25AA/LC080D8 Kbit10243220
25AA/LC160C16 Kbit20481620
AT25160B, 25AA/LC160D16Kbit20483220
25CS320 (ECC), AT25320B, 25AA/LC320A32 Kbit40963220
25CS640, AT25640B, 25AA/LC640A64 Kbit81923220
AT25128B, 25AA/LC128128 Kbit163846420
AT25256B, 25LC256, 25AA256256 Kbit327686420
AT25512, 25LC512, 25AA512512 Kbit6553612820
AT25M01, 25LC1024, 25AA10241 Mbit13107225630
AT25M022 Mbit26214425630
25CSM044 Mbit52428825630

Registers

alt text

Status Register

alt text

The status register bit 0 indicates a write is in progress, bit 1 indicates if the write enable latch is set (data can be written to the memory or status register).

Write protection blocks

alt text

Many, but not all, EEPROMs have a write protection block feature. This allows you to protect a portion of the EEPROM from being written to, even if the write enable latch is set. The block select bits are used to select which block is protected: none (0b00), the upper 1/4 (0b01), the upper 1/2 (0b10), or the entire EEPROM (0b11).

alt text

Fewer devices have a WPEN bit that disables the Write Protect (WP) pin. When WPEN is 0, the WP pin is ignored. When WPEN is 1, the WP pin is used to control write protection. If the WP pin is high, the EEPROM is write protected. If the WP pin is low, the EEPROM can be written to.

We can test which bits are available in a chip by writing 0x00 to the status register, then writing 0b10001100, enabling all the protection bits. If the chip supports WPEN or BPx bits, they will be set to 1 after the write. If they are not supported, they will remain 0.

Chip voltage requirements
24xx FamilyMinimum VoltageMaximum VoltageNotes
AT24C2.7V5.5V400kHz max
24C2.7V5.5V400kHz max
24LC2.5V5.5V400kHz max
24AA1.7V5.5V400kHz max
24FC1.8V5.5V1MHz max

Before using the eeprom command, you’ll need to enable a power supply with the W command and pull-up resistors with the P command.

I2C EEPROM dump to terminal

Bus Pirate [/dev/ttyS0]
I2C> eeprom dump -d 24x02 -s 0x50 -b 64
24X02: 256 bytes,  0 block select bits, 1 byte address, 8 byte pages

Start address: 0x00000050, end address: 0x0000008F, total bytes: 64

          00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
---------------------------------------------------------
00000050: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF |................|
00000060: 48 65 6C 6C 6F 21 FF FF FF FF FF FF FF FF FF FF |Hello!..........|
00000070: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF |................|
00000080: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF |................|

I2C> 

Display the contents of an I2C EEPROM in the terminal.

  • dump -d <device> - display EEPROM contents
  • dump -d <device> -s <start> - display EEPROM contents, starting at address <start>
  • dump -d <device> -s <start> -b <bytes> - display a specific range of bytes, starting at address <start> and reading <bytes> bytes

I2C EEPROM read to file

I2C> eeprom read -d 24x02 -f eeprom.bin -v
24X02: 256 bytes,  0 block select bits, 1 byte address, 8 byte pages

Read: Reading EEPROM to file eeprom.bin...
Progress: [###########################] 100.00%
Read complete
Read verify...
Progress: [###########################] 100.00%
Read verify complete
Success :)

I2C> 

Read the contents of an I2C EEPROM and save it to a file.

  • read -d <device> -f <file> - read EEPROM contents to file <file>
  • read -d <device> -f <file> -v - read EEPROM contents to file <file>, verify the read operation

I2C EEPROM write from file

I2C> eeprom write -d 24x02 -f eeprom.bin -v
24X02: 256 bytes,  0 block select bits, 1 byte address, 8 byte pages

Write: Writing EEPROM from file eeprom.bin...
Progress: [###########################] 100.00%
Write complete
Write verify...
Progress: [###########################] 100.00%
Write verify complete
Success :)
I2C> 
Write the contents of a file to an I2C EEPROM.

  • write -d <device> -f <file> - write EEPROM from file <file>
  • write -d <device> -f <file> -v - write EEPROM from file <file>, verify the write operation

I2C EEPROM verify against file

I2C> eeprom verify -d 24x02 -f eeprom.bin
24X02: 256 bytes,  0 block select bits, 1 byte address, 8 byte pages

Verify: Verifying EEPROM contents against file eeprom.bin...
Progress: [###########################] 100.00%
Verify complete
Success :)
I2C> 
Verify the contents of an I2C EEPROM match a file.

  • verify -d <device> -f <file> - verify EEPROM contents against file <file>

I2C EEPROM erase

I2C> eeprom erase -d 24x02 -v
24X02: 256 bytes,  0 block select bits, 1 byte address, 8 byte pages

Erase: Writing 0xFF to all bytes...
Progress: [###########################] 100.00%
Erase complete
Erase verify...
Progress: [###########################] 100.00%
Erase verify complete
Success :)
I2C> 

Erase the contents of an I2C EEPROM, writing 0xFF to all bytes.

  • erase -d <device> - erase EEPROM contents
  • erase -d <device> -v - erase EEPROM contents, verify the erase operation

I2C EEPROM test

I2C> eeprom test -d 24x02
24X02: 256 bytes,  0 block select bits, 1 byte address, 8 byte pages

Erase: Writing 0xFF to all bytes...
Progress: [###########################] 100.00%
Erase complete
Erase verify...
Progress: [###########################] 100.00%
Erase verify complete

Test: Writing alternating patterns
Writing 0xAA 0x55...
Progress: [###########################] 100.00%
Write complete
Write verify...
Progress: [###########################] 100.00%
Write verify complete
Writing 0x55 0xAA...
Progress: [###########################] 100.00%
Write complete
Write verify...
Progress: [###########################] 100.00%
Write verify complete
Success :)

I2C> 
Test I2C EEPROM functionality. Erase the EEPROM to 0xff and verify the erase. Then write alternating patterns of 0xAA and 0x55, verifying each write operation. Any stuck bits should be detected during the test.

  • test -d <device> - test EEPROM functionality

I2C EEPROM options and flags

OptionDescription
eeprom listList all supported EEPROM devices
eeprom dumpDump EEPROM contents to terminal
eeprom readRead EEPROM contents to file
eeprom writeWrite EEPROM from file
eeprom verifyVerify EEPROM contents against file
eeprom eraseErase EEPROM contents, writing 0xFF to all bytes
eeprom testTest EEPROM functionality, erase and write alternating patterns

Options tell the eeprom command what to do.

FlagDescription
-d <device>Specify the EEPROM device type, e.g. 24x02
-f <file>Specify the file for read, write and verify
-s <start>Specify the start address for dump and read operations
-b <bytes>Specify the number of bytes to read for dump operations
-vVerify the read or write operation
-aSpecify an alternate I2C address (0x50 default)
-hShow help for the eeprom command