EmbeddedRelated.com
Forums
Memfault State of IoT Report

SD(HC) support on LPC21XX? Using pre-written driver, SC works but HC fails CRC16

Started by lawzaz July 1, 2012
>
> Thanks again for the eyes and time. Hopefully someone else is learning along with me.
>

Thanks very much - I am watching you thread with interest and, with a bit of luck, will help me fix my own SDHC problems, once I can get rid of the other nasty bugs in the rest of my app:(

Again, many thanks for posting your problems and debugging results

Rgds,
Martin

An Engineer's Guide to the LPC2100 Series

I'm back with more progress and lessons learned, but no complete solution (yet).

1. SD card class has nothing to do with SPI data rates. My Class 2 card is happy humming along at 10MHz, while my Class 6 card barfs at anything over 4.

2. This driver was obviously not tested with SDHC cards. While address /= 512, dataLen was not /= 512 and it should have been (in the case of SDHC cards).

3. With the clock set to 4MHz and these changes made, I spoke with my first SDHC card! But not all SDHC cards work. While AData and MicroCenter cards work fine, SanDisk returns CRC16 errors.

4. At this point, I'm stuck trying to figure out this pesky CRC16 error. I believe the algorithm to be correct since the two other brands work; however, SanDisk CRC16's return invalid and ignoring the error results in a 'NO FILESYSTEM' error. It does seem strange that the test is:

if (sd_crc16_data(data+(dataIndex-sd_block_len), sd_block_len) != crc16)

because for SDHC cards, I would have thought that it should be

if (sd_crc16_data(data+(dataIndex-1), sd_block_len) != crc16)

but in this case, all SDHC cards fail.

I'll keep trucking along -- but if anyone has ideas or thoughts about why CRC16 might work on some cards and fail with others, please let me know.

If it helps, the cards that work are 4.02GB while the cards that fail are 3.97GB. It's possible that the cards that work are made by the same manufacturer and therefore share an error in CRC, but who knows.. The card data indicate different manufacturers.

--- In l..., "mjames_doveridge" wrote:
>
> >
> > Thanks again for the eyes and time. Hopefully someone else is learning along with me.
> >
>
> Thanks very much - I am watching you thread with interest and, with a bit of luck, will help me fix my own SDHC problems, once I can get rid of the other nasty bugs in the rest of my app:(
>
> Again, many thanks for posting your problems and debugging results
>
> Rgds,
> Martin
>

--- In l..., "lawzaz" wrote:
>
> I'm back with more progress and lessons learned, but no complete solution (yet).
>
> 1. SD card class has nothing to do with SPI data rates. My Class 2 card is happy humming along at 10MHz, while my Class 6 card barfs at anything over 4.
>

Hmm.. interesting. I have got my controller fired up just about as fast as it can go - the divider is set at 1 since it works with my old cards

I wil try setting my divider to 15 and see if I get any better responses from the big cards.

Rgds,
Martin

Interesting. Because SanDisk, PNY and other big name cards always works
for me. The off brands seem to not cooperate sometimes.

Even though I'm not using your library, which command is causing the
CRC16 error? I vaguely remember a command where I physically had to
figure out the CRC (based on my parameters) in order for the command to
work properly.

Sutton Mehaffey
Lookout Portable Security
4040 Royal Dr.
Kennesaw, GA 30144
770-514-7999, 800-207-6269
Fax: 770-514-1285
http://www.lookoutportablesecurity.com
s...@lookoutportablesecurity.com
On 7/5/2012 2:09 PM, lawzaz wrote:
>
> I'm back with more progress and lessons learned, but no complete
> solution (yet).
>
> 1. SD card class has nothing to do with SPI data rates. My Class 2
> card is happy humming along at 10MHz, while my Class 6 card barfs at
> anything over 4.
>
> 2. This driver was obviously not tested with SDHC cards. While address
> /= 512, dataLen was not /= 512 and it should have been (in the case of
> SDHC cards).
>
> 3. With the clock set to 4MHz and these changes made, I spoke with my
> first SDHC card! But not all SDHC cards work. While AData and
> MicroCenter cards work fine, SanDisk returns CRC16 errors.
>
> 4. At this point, I'm stuck trying to figure out this pesky CRC16
> error. I believe the algorithm to be correct since the two other
> brands work; however, SanDisk CRC16's return invalid and ignoring the
> error results in a 'NO FILESYSTEM' error. It does seem strange that
> the test is:
>
> if (sd_crc16_data(data+(dataIndex-sd_block_len), sd_block_len) != crc16)
>
> because for SDHC cards, I would have thought that it should be
>
> if (sd_crc16_data(data+(dataIndex-1), sd_block_len) != crc16)
>
> but in this case, all SDHC cards fail.
>
> I'll keep trucking along -- but if anyone has ideas or thoughts about
> why CRC16 might work on some cards and fail with others, please let me
> know.
>
> If it helps, the cards that work are 4.02GB while the cards that fail
> are 3.97GB. It's possible that the cards that work are made by the
> same manufacturer and therefore share an error in CRC, but who knows..
> The card data indicate different manufacturers.
>
> --- In l... ,
> "mjames_doveridge" wrote:
> >
> > >
> > > Thanks again for the eyes and time. Hopefully someone else is
> learning along with me.
> > >
> >
> > Thanks very much - I am watching you thread with interest and, with
> a bit of luck, will help me fix my own SDHC problems, once I can get
> rid of the other nasty bugs in the rest of my app:(
> >
> > Again, many thanks for posting your problems and debugging results
> >
> > Rgds,
> > Martin
> >




Memfault State of IoT Report