Forum: Mikrocontroller und Digitale Elektronik Welches CRC16 Verfahren verwenden SD Karten?


von Tastkopf (Gast)


Lesenswert?

Hey,
Wie der Titel schon sagt versuch ich gerade rauszufinden welches CRC16 
Verfahren SD Karten verwenden.
Die Spec sagt einem zwar das es eine CRC-16 mit dem polynom 
x^16+x^12+x^5+1 (1021) ist, allerdings find ich keine Angabe zu 
init-Value, Xorout, refin, refout.
Das Tool SRP16, welches einem aus einem Datensatz + CRC-Value die 
möglichen Verfahren ermitteln kann, hat mir folgendes geliefert:
Found known algorithm: CRC-16/ZMODEM
CRC=$7fa1  Poly=$1021  init=$0000  xorout=$0000  refin=false 
refout=false

Stimmt das? gilt das Verfahren für alle SD-Karten? und hat jemand ne 
Beispielimplementierung?

von f.all (Gast)


Lesenswert?

Findest du in der SD-Spec. Genauer Part 1, Physical Layer, Kapitel 4.5. 
Ist auch in der (kostenlosen) Simplified Specification.

"CRC7
The CRC7 check is used for all commands, for all responses except type 
R3, and for the CSD and CID registers. The CRC7 is a 7-bit value and is 
computed as follows:
Generator polynomial: G(x) = x7 + x3 + 1. M(x) = (first bit) * xn + 
(second bit) * xn-1 +...+ (last bit) * x0 CRC[6...0] = Remainder [(M(x) 
* x7)/G(x)]
The first bit is the most left bit of the corresponding bit string (of 
the command, response, CID or CSD). The degree n of the polynomial is 
the number of CRC protected bits decreased by one. The number of bits to 
be protected is 40 for commands and responses (n = 39), and 120 for the 
CSD and CID (n = 119).

CRC7 Examples
The CRC section of the command/response is bolded.
CMD0   (Argument=0) --> 01 000000 00000000000000000000000000000000 
"1001010" 1
CMD17 (Argument=0) --> 01 010001 00000000000000000000000000000000 
"0101010" 1 Response of CMD17 --> 00 010001 
00000000000000000000100100000000 "0110011" 1
"
"CRC16
In the case of one DAT line usage, the CRC16 is used for payload 
protection in block transfer mode. The CRC check sum is a 16-bit value 
and is computed as follows:
Generator polynomial G(x) = x16 +x12 +x5 +1 M(x) = (first bit) * xn + 
(second bit)* xn-1 +...+ (last bit) * x0 CRC[15...0] = Remainder [(M(x) 
* x16)/G(x)]
The first bit is the first data bit of the corresponding block. The 
degree n of the polynomial denotes the number of bits of the data block 
decreased by one (e.g. n = 4095 for a block length of 512 bytes). The 
generator polynomial G(x) is a standard CCITT polynomial. The code has a 
minimal distance d=4 and is used for a payload length of up to 2048 
Bytes (n <= 16383).
The same CRC16 method shall be used in single DAT line mode and in wide 
bus mode. In wide bus mode, the CRC16 is done on each line separately."

"512 bytes with 0xFF data --> CRC16 = 0x7FA1"

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.