flashrom 

flashrom Svn Source Tree

Root/trunk/Documentation/serprog-protocol.txt

  • Property svn:eol-style set to native
1Serial Flasher Protocol Specification - version 1 (0x01 return value == 1)
2
3Command And Answer Sequence - all commands give an answer.
4PC: COMMAND(8bit) <parameters determined by opcode>
5DEV: ACK/NAK(8bit) <OPTIONAL RETURN BYTES (only if ACK)> / nothing
6Command 0x10 (SYNCNOP) has a special return of NAK+ACK for synchronization.
7
8ACK = 0x06
9NAK = 0x15
10
11All multibyte values are little-endian. Addresses and lengths are 24-bit.
12
13COMMANDDescriptionParametersReturn Value
140x00NOPnoneACK
150x01Query programmer iface versionnoneACK + 16bit version (nonzero)
160x02Query supported commands bitmapnoneACK + 32 bytes (256 bits) of supported cmds flags
170x03Query programmer namenoneACK + 16 bytes string (null padding) / NAK
180x04Query serial buffer sizenoneACK + 16bit size / NAK
190x05Query supported bustypesnoneACK + 8-bit flags (as per flashrom) / NAK
200x06Query connected address linesnoneACK + 8bit line count / NAK
210x07Query operation buffer sizenoneACK + 16bit size / NAK
220x08Query maximum write-n lengthnoneACK + 24bit length (0==2^24) / NAK
230x09Read byte24-bit addrACK + BYTE / NAK
240x0ARead n bytes24-bit addr + 24-bit lengthACK + length bytes / NAK
250x0BInitialize operation buffernoneACK / NAK
260x0CWrite to opbuf: Write byte24-bit addr + 8-bit byteACK / NAK (NOTE: takes 5 bytes in opbuf)
270x0DWrite to opbuf: Write n24-bit length + 24-bit addr +ACK / NAK (NOTE: takes 7+n bytes in opbuf)
28 + length bytes of data
290x0EWrite to opbuf: delay32-bit usecsACK / NAK (NOTE: takes 5 bytes in opbuf)
300x0FExecute operation buffernoneACK / NAK
310x10Sync NOPnoneNAK + ACK (for synchronization)
320x11Query maximum read-n lengthnoneACK + 24-bit length (0==2^24) / NAK
330x12Set used bustype8-bit flags (as with 0x05)ACK / NAK
340x13Perform SPI operation24-bit slen + 24-bit rlenACK + rlen bytes of data / NAK
35 + slen bytes of data
360x14Set SPI clock frequency in Hz32-bit requested frequencyACK + 32-bit set frequency / NAK
370x15Toggle flash chip pin drivers8-bit (0 disable, else enable)ACK / NAK
380x??unimplemented command - invalid.
39
40
41Additional information of the above commands:
42About unimplemented commands / startup sequence:
43Only commands allowed to be used without checking anything are 0x00,0x10 and 0x01 (NOP,SYNCNOP,Q_IFACE).
44If 0x01 doesn't return 1, dont do anything if you dont support a newer protocol.
45Then, check support for any other opcode (except 0x02) by using 0x02 (Q_CMDMAP).
460x02 (Q_CMDMAP):
47The map's bits are mapped as follows:
48cmd 0 support: byte 0 bit 0
49cmd 1 support: byte 0 bit 1
50cmd 7 support: byte 0 bit 7
51cmd 8 support: byte 1 bit 0, and so on.
520x04 (Q_SERBUF):
53If the programmer has a guaranteed working flow control,
54it should return a big bogus value - eg 0xFFFF.
550x05 (Q_BUSTYPE):
56The bit's are defined as follows:
57bit 0: PARALLEL, bit 1: LPC, bit 2: FWH, bit 3: SPI.
580x06 (Q_CHIPSIZE):
59Only applicable to parallel programmers.
60An LPC/FWH/SPI-programmer can report this as not supported in the command bitmap.
610x08 (Q_WRNMAXLEN):
62If a programmer reports a bigger maximum write-n length than the serial buffer size,
63it is assumed that the programmer can process the data fast enough to take in the
64reported maximum write-n without problems.
650x0F (O_EXEC):
66Execute operation buffer will also clear it, regardless of the return value.
670x11 (Q_RDNMAXLEN):
68If this command is not supported, assume return of 0 (2^24).
690x12 (S_BUSTYPE):
70Set's the used bustype if the programmer can support more than one flash protocol.
71Sending a byte with more than 1 bit set will make the programmer decide among them
72on it's own. Bit values as with Q_BUSTYPE.
730x13 (O_SPIOP):
74Send and receive bytes via SPI.
75Maximum slen is Q_WRNMAXLEN in case Q_BUSTYPE returns SPI only or S_BUSTYPE was used
76to set SPI exclusively before. Same for rlen and Q_RDNMAXLEN.
77This operation is immediate, meaning it doesn't use the operation buffer.
780x14 (S_SPI_FREQ):
79Set the SPI clock frequency. The 32-bit value indicates the
80requested frequency in Hertz. Value 0 is reserved and should
81be NAKed by the programmer. The requested frequency should be
82mapped by the programmer software to a supported frequency
83lower than the one requested. If there is no lower frequency
84available the lowest possible should be used. The value
85chosen is sent back in the reply with an ACK.
860x15 (S_CMD_S_PIN_STATE):
87Sets the state of the pin drivers connected to the flash chip. Disabling them allows other
88devices (e.g. a mainboard's chipset) to access the chip. This way the serprog controller can
89remain attached to the flash chip even when the board is running. The user is responsible to
90NOT connect VCC and other permanently externally driven signals to the programmer as needed.
91If the value is 0, then the drivers should be disabled, otherwise they should be enabled.
92About mandatory commands:
93The only truly mandatory commands for any device are 0x00, 0x01, 0x02 and 0x10,
94but one can't really do anything with these commands.
95Support for the following commands is necessary for flashrom to operate properly:
96S_CMD_Q_SERBUF, S_CMD_Q_OPBUF, S_CMD_Q_WRNMAXLEN, S_CMD_R_BYTE,
97S_CMD_R_NBYTES, S_CMD_O_INIT, S_CMD_O_WRITEB, S_CMD_O_WRITEN,
98S_CMD_O_DELAY, S_CMD_O_EXEC.
99In addition, support for these commands is recommended:
100S_CMD_Q_PGMNAME, S_CMD_Q_BUSTYPE, S_CMD_Q_CHIPSIZE (if parallel).
101
102See also serprog.h.

Archive Download this file

Revision: HEAD