SPI EEPROM Command
This is a placeholder for documentation in progress.
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.
You do need to specify the device type, there is no non-destructive autodetect method for I2C EEPROMs.
SPI EEPROM list supported devices
I2C> eeprom list
eeprom list
- list all EEPROM devices supported by theeeprom
command
Product(s) | Density | Size (bytes) | Page Size (Bytes) | Address Bytes | Block Select Bits | |
---|---|---|---|---|---|---|
AT25010B | 1 Kbit | 128 | 8 | 1 | 0 | |
25AA/LC010A | 1 Kbit | 128 | 16 | 1 | 0 | |
AT25020B | 2 Kbit | 256 | 8 | 1 | 0 | |
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 Kbit | 256 | 16 | 1 | 0 | |
AT25040B | 4 Kbit | 512 | 8 | 1 | opcode 0x02 bit 3 | |
25AA/LC040A | 4 Kbit | 512 | 16 | 1 | opcode 0x02 bit 3 | |
25AA/LC080C | 8 Kbit | 1024 | 16 | 2 | 0 | |
AT25080B, 25AA/LC080D | 8 Kbit | 1024 | 32 | 2 | 0 | |
25AA/LC160C | 16 Kbit | 2048 | 16 | 2 | 0 | |
AT25160B, 25AA/LC160D | 16Kbit | 2048 | 32 | 2 | 0 | |
25CS320 (ECC), AT25320B, 25AA/LC320A | 32 Kbit | 4096 | 32 | 2 | 0 | |
25CS640, AT25640B, 25AA/LC640A | 64 Kbit | 8192 | 32 | 2 | 0 | |
AT25128B, 25AA/LC128 | 128 Kbit | 16384 | 64 | 2 | 0 | |
AT25256B, 25LC256, 25AA256 | 256 Kbit | 32768 | 64 | 2 | 0 | |
AT25512, 25LC512, 25AA512 | 512 Kbit | 65536 | 128 | 2 | 0 | |
AT25M01, 25LC1024, 25AA1024 | 1 Mbit | 131072 | 256 | 3 | 0 | |
AT25M02 | 2 Mbit | 262144 | 256 | 3 | 0 | |
25CSM04 | 4 Mbit | 524288 | 256 | 3 | 0 |
Registers
Status Register
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
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).
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.
24x chips have a variety of part numbers, but tend to operate in the same way. Often a manufacturer specific part number indicates a different voltage range or upgraded features. AT24C, 24C, 24LC, 24AA, 24FC are all generally part of same basic 24x family of chips.
Chip voltage requirements
24xx Family | Minimum Voltage | Maximum Voltage | Notes |
---|---|---|---|
AT24C | 2.7V | 5.5V | 400kHz max |
24C | 2.7V | 5.5V | 400kHz max |
24LC | 2.5V | 5.5V | 400kHz max |
24AA | 1.7V | 5.5V | 400kHz max |
24FC | 1.8V | 5.5V | 1MHz 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.
Most EEPROMs should be fine with a 3.3 volt power supply, but if possible check the datasheet to be sure!
I2C EEPROM dump to terminal
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 contentsdump -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 -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 -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 contentserase -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 -d <device>
- test EEPROM functionality
I2C EEPROM options and flags
Option | Description |
---|---|
eeprom list | List all supported EEPROM devices |
eeprom dump | Dump EEPROM contents to terminal |
eeprom read | Read EEPROM contents to file |
eeprom write | Write EEPROM from file |
eeprom verify | Verify EEPROM contents against file |
eeprom erase | Erase EEPROM contents, writing 0xFF to all bytes |
eeprom test | Test EEPROM functionality, erase and write alternating patterns |
Options tell the eeprom
command what to do.
Flag | Description |
---|---|
-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 |
-v | Verify the read or write operation |
-a | Specify an alternate I2C address (0x50 default) |
-h | Show help for the eeprom command |