dev builds
themes manual
device status forums
mailing lists
IRC bugs
dev guide

Rockbox mail archive

Subject: Re: Lyre project -- what I am being doing

Re: Lyre project -- what I am being doing

From: Casainho <>
Date: Tue, 17 Mar 2009 09:54:34 +0000

> But now most part of time I get an SD Card error, so, I am working now
> to make the SD Card drivers more robust, mainly I will start using the
> CRC7 for commands...
> I am using CRC16 for data readed from SD Card. I got errors while
> reading sectors(512 bytes) but after testing with CRC16, I detect them
> and I just read again.

CRC7 code:

Length = 5
CRC = 0x95

Length = 5
CRC = 0xD1

// _____________________________________________________________________________________________
// Function: SD_CRC_7()
// Description:
// ------------
// calulates the 7-bit CRC for a list of bytes...
// Design Notes:
// -------------
// In the case of CRC-7, the remainder can be calculated using a 7-bit
shift register in
// software. This shift register is initialized to all zeros at the
start of the calculation. As
// each bit (MSB first) of the protected data is shifted into the LSB
of the shift register,
// the MSB of the shift register is shifted out and examined. If the
bit just shifted out is
// one, the contents of the shift register are modified by XORing with
the CRC-7 polynomial
// value 0x09. If the bit shifted out of the shift register is zero,
no XOR is performed. Once
// the last bit of protected data is shifted in and the conditional
XOR completed, six more
// zeros must be shifted through in a similar manner. This process is
referred to as
// augmentation, and completes the polynomial division. At this point,
the CRC-7 value can be
// read directly from the shift register.
// _____________________________________________________________________________________________
BYTE SD_CRC_7( BYTE *List, BYTE Length )
   idata BYTE crc = 0x00;
   idata BYTE i, j, mask;

   for( i=0; i<Length; i++ )
      mask = List[ i ];
      for( j=0; j<8; j++)
         crc <<= 1;
         if(( mask & 0x80 ) ^ ( crc & 0x80 ) )
            crc ^= 0x09;
         mask <<= 1;
   crc = (crc << 1) | 1;
   return( crc );
Received on 2009-03-17

Page template was last modified "Tue Sep 7 00:00:02 2021" The Rockbox Crew -- Privacy Policy