Forums

EFSL and SDHC

Started by drproton2003 July 7, 2009
Hello everyone,

I am attempting to get EFSL to work with SDHC cards. I have downloaded version 0.2.9 RC7 from this page

http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/arm_memcards/

After realizing that I needed to use the SSP FIFO mode I had it working with a 1GB SD card.

Now that I am using a SDHC card I am having some problems. The problems start in the sd_Init function. Namely, this block of code here:

if ( sd_Command( iface, CMD8, 0, 0x01AA) == 1 ) {
/* SDHC */
for ( n=0; n<4; n++ ) {
ocr[n] = if_spiSend( iface, 0xff );
}
if ( ocr[2] == 0x01 && ocr[3] == 0xAA )

The card I am using responds to CMD8 with a value of 9, so it fails this check and goes to the SDSC case. As I understand it if CMD8 responds the card is SDHC, does the response need to be 1? If I remove the == 1 from the first if, ocr[] is filled in with 0xFF, so the next test fails.

Has anyone used EFSL with SDHC cards? What might be the cause of my problems? Also where can I find documentation on interfacing with SDHC cards? I've found a lot of docs for standard SD, but not too much for SDHC.

An Engineer's Guide to the LPC2100 Series

I've got one step further with this. Turns out the sd_Command function was using the wrong CRC for CMD8. The CRC was orignally set to 0x97 and it should be 0x87.

Now the initialization gets stuck in the next few lines. ACMD41 always seems to return 1, so I get stuck in the do loop.

if ( ocr[2] == 0x01 && ocr[3] == 0xAA ) {
retry = LOOP_CNT_1000; /* should retry 1000ms */
do {
//Wait for leaving idle state (ACMD41 with HCS bit)
resp = sd_Command( iface, ACMD41,((1UL << 30)>>16), 0 );
retry--;
} while ( retry && (resp != 0) );

if ( retry && sd_Command( iface, CMD58, 0, 0 ) == 0) {
/* Check CCS bit in the OCR */
for ( n = 0; n < 4; n++ ) {
ocr[n] = if_spiSend( iface, 0xff );
}
ty = (ocr[0] & 0x40) ? 12 : 4;
if ( ty == 12 ) DBG((TXT("SDHC HighCap\n")));
if ( ty == 4 ) DBG((TXT("SDHC\n")));
}

Seeing as how the CRC was wrong it makes me think that this code has never been tested with SDHC.

--- In l..., "drproton2003" wrote:
>
> Hello everyone,
>
> I am attempting to get EFSL to work with SDHC cards. I have downloaded version 0.2.9 RC7 from this page
>
> http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/arm_memcards/
>
> After realizing that I needed to use the SSP FIFO mode I had it working with a 1GB SD card.
>
> Now that I am using a SDHC card I am having some problems. The problems start in the sd_Init function. Namely, this block of code here:
>
> if ( sd_Command( iface, CMD8, 0, 0x01AA) == 1 ) {
> /* SDHC */
> for ( n=0; n<4; n++ ) {
> ocr[n] = if_spiSend( iface, 0xff );
> }
> if ( ocr[2] == 0x01 && ocr[3] == 0xAA )
>
> The card I am using responds to CMD8 with a value of 9, so it fails this check and goes to the SDSC case. As I understand it if CMD8 responds the card is SDHC, does the response need to be 1? If I remove the == 1 from the first if, ocr[] is filled in with 0xFF, so the next test fails.
>
> Has anyone used EFSL with SDHC cards? What might be the cause of my problems? Also where can I find documentation on interfacing with SDHC cards? I've found a lot of docs for standard SD, but not too much for SDHC.
>

Are you preceding ACMD41 with a CMD55?

drproton2003 wrote:
> I've got one step further with this. Turns out the sd_Command function
> was using the wrong CRC for CMD8. The CRC was orignally set to 0x97
> and it should be 0x87.
>
> Now the initialization gets stuck in the next few lines. ACMD41 always
> seems to return 1, so I get stuck in the do loop.
>
> if ( ocr[2] == 0x01 && ocr[3] == 0xAA ) {
> retry = LOOP_CNT_1000; /* should retry 1000ms */
> do {
> //Wait for leaving idle state (ACMD41 with HCS bit)
> resp = sd_Command( iface, ACMD41,((1UL << 30)>>16), 0 );
> retry--;
> } while ( retry && (resp != 0) );
>
> if ( retry && sd_Command( iface, CMD58, 0, 0 ) == 0) {
> /* Check CCS bit in the OCR */
> for ( n = 0; n < 4; n++ ) {
> ocr[n] = if_spiSend( iface, 0xff );
> }
> ty = (ocr[0] & 0x40) ? 12 : 4;
> if ( ty == 12 ) DBG((TXT("SDHC HighCap\n")));
> if ( ty == 4 ) DBG((TXT("SDHC\n")));
> }
>
> Seeing as how the CRC was wrong it makes me think that this code has
> never been tested with SDHC.
>
> --- In l... ,
> "drproton2003" wrote:
> >
> > Hello everyone,
> >
> > I am attempting to get EFSL to work with SDHC cards. I have
> downloaded version 0.2.9 RC7 from this page
> >
> >
> http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/arm_memcards/
>
> >
> > After realizing that I needed to use the SSP FIFO mode I had it
> working with a 1GB SD card.
> >
> > Now that I am using a SDHC card I am having some problems. The
> problems start in the sd_Init function. Namely, this block of code here:
> >
> > if ( sd_Command( iface, CMD8, 0, 0x01AA) == 1 ) {
> > /* SDHC */
> > for ( n=0; n<4; n++ ) {
> > ocr[n] = if_spiSend( iface, 0xff );
> > }
> > if ( ocr[2] == 0x01 && ocr[3] == 0xAA )
> >
> > The card I am using responds to CMD8 with a value of 9, so it fails
> this check and goes to the SDSC case. As I understand it if CMD8
> responds the card is SDHC, does the response need to be 1? If I remove
> the == 1 from the first if, ocr[] is filled in with 0xFF, so the next
> test fails.
> >
> > Has anyone used EFSL with SDHC cards? What might be the cause of my
> problems? Also where can I find documentation on interfacing with SDHC
> cards? I've found a lot of docs for standard SD, but not too much for
> SDHC.
> >

--
Sutton Mehaffey
Lookout Portable Security
4040 Royal Dr. #100
Kennesaw, GA 30144
800-207-6269, 770-514-7999, 770-514-1285 FAX
s...@lookoutportablesecurity.com

I don't seem to be having this problem any more. The only thing I can point to is that it didn't like me having a breakpoint in that block of code.

That being said, it still doesn't work. efs_init now returns -2 (failed to initialize file system). One problem is that when I try to view the results of a sector read from the debugger it is different than what the hex editor on my computer says. The really weird part is that this occurs for both the 1GB card that works fine and the 4GB SDHC card that doesn't.

I've spent all day working on this now so I think it is time for a break.
--- In l..., Sutton Mehaffey wrote:
>
> Are you preceding ACMD41 with a CMD55?
>
> drproton2003 wrote:
> >
> >
> > I've got one step further with this. Turns out the sd_Command function
> > was using the wrong CRC for CMD8. The CRC was orignally set to 0x97
> > and it should be 0x87.
> >
> > Now the initialization gets stuck in the next few lines. ACMD41 always
> > seems to return 1, so I get stuck in the do loop.
> >
> > if ( ocr[2] == 0x01 && ocr[3] == 0xAA ) {
> > retry = LOOP_CNT_1000; /* should retry 1000ms */
> > do {
> > //Wait for leaving idle state (ACMD41 with HCS bit)
> > resp = sd_Command( iface, ACMD41,((1UL << 30)>>16), 0 );
> > retry--;
> > } while ( retry && (resp != 0) );
> >
> > if ( retry && sd_Command( iface, CMD58, 0, 0 ) == 0) {
> > /* Check CCS bit in the OCR */
> > for ( n = 0; n < 4; n++ ) {
> > ocr[n] = if_spiSend( iface, 0xff );
> > }
> > ty = (ocr[0] & 0x40) ? 12 : 4;
> > if ( ty == 12 ) DBG((TXT("SDHC HighCap\n")));
> > if ( ty == 4 ) DBG((TXT("SDHC\n")));
> > }
> >
> > Seeing as how the CRC was wrong it makes me think that this code has
> > never been tested with SDHC.
> >
> > --- In l... ,
> > "drproton2003" wrote:
> > >
> > > Hello everyone,
> > >
> > > I am attempting to get EFSL to work with SDHC cards. I have
> > downloaded version 0.2.9 RC7 from this page
> > >
> > >
> > http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/arm_memcards/
> >
> > >
> > > After realizing that I needed to use the SSP FIFO mode I had it
> > working with a 1GB SD card.
> > >
> > > Now that I am using a SDHC card I am having some problems. The
> > problems start in the sd_Init function. Namely, this block of code here:
> > >
> > > if ( sd_Command( iface, CMD8, 0, 0x01AA) == 1 ) {
> > > /* SDHC */
> > > for ( n=0; n<4; n++ ) {
> > > ocr[n] = if_spiSend( iface, 0xff );
> > > }
> > > if ( ocr[2] == 0x01 && ocr[3] == 0xAA )
> > >
> > > The card I am using responds to CMD8 with a value of 9, so it fails
> > this check and goes to the SDSC case. As I understand it if CMD8
> > responds the card is SDHC, does the response need to be 1? If I remove
> > the == 1 from the first if, ocr[] is filled in with 0xFF, so the next
> > test fails.
> > >
> > > Has anyone used EFSL with SDHC cards? What might be the cause of my
> > problems? Also where can I find documentation on interfacing with SDHC
> > cards? I've found a lot of docs for standard SD, but not too much for
> > SDHC.
> > >
> >
> > --
> Sutton Mehaffey
> Lookout Portable Security
> 4040 Royal Dr. #100
> Kennesaw, GA 30144
> 800-207-6269, 770-514-7999, 770-514-1285 FAX
> sutton@...
>

I assume you are using CMD55 before ACMD41 and getting a status of 1
before issuing ACMD41. I don't see that in your code. The sequence
needs to be:

CMD8
CMD55
ACMD41

Sutton

drproton2003 wrote:
> I don't seem to be having this problem any more. The only thing I can
> point to is that it didn't like me having a breakpoint in that block
> of code.
>
> That being said, it still doesn't work. efs_init now returns -2
> (failed to initialize file system). One problem is that when I try to
> view the results of a sector read from the debugger it is different
> than what the hex editor on my computer says. The really weird part is
> that this occurs for both the 1GB card that works fine and the 4GB
> SDHC card that doesn't.
>
> I've spent all day working on this now so I think it is time for a break.
>
> --- In l... ,
> Sutton Mehaffey wrote:
> >
> > Are you preceding ACMD41 with a CMD55?
> >
> >
> >
> > drproton2003 wrote:
> > >
> > >
> > > I've got one step further with this. Turns out the sd_Command
> function
> > > was using the wrong CRC for CMD8. The CRC was orignally set to 0x97
> > > and it should be 0x87.
> > >
> > > Now the initialization gets stuck in the next few lines. ACMD41
> always
> > > seems to return 1, so I get stuck in the do loop.
> > >
> > > if ( ocr[2] == 0x01 && ocr[3] == 0xAA ) {
> > > retry = LOOP_CNT_1000; /* should retry 1000ms */
> > > do {
> > > //Wait for leaving idle state (ACMD41 with HCS bit)
> > > resp = sd_Command( iface, ACMD41,((1UL << 30)>>16), 0 );
> > > retry--;
> > > } while ( retry && (resp != 0) );
> > >
> > > if ( retry && sd_Command( iface, CMD58, 0, 0 ) == 0) {
> > > /* Check CCS bit in the OCR */
> > > for ( n = 0; n < 4; n++ ) {
> > > ocr[n] = if_spiSend( iface, 0xff );
> > > }
> > > ty = (ocr[0] & 0x40) ? 12 : 4;
> > > if ( ty == 12 ) DBG((TXT("SDHC HighCap\n")));
> > > if ( ty == 4 ) DBG((TXT("SDHC\n")));
> > > }
> > >
> > > Seeing as how the CRC was wrong it makes me think that this code has
> > > never been tested with SDHC.
> > >
> > > --- In l...
> ,
> > > "drproton2003" wrote:
> > > >
> > > > Hello everyone,
> > > >
> > > > I am attempting to get EFSL to work with SDHC cards. I have
> > > downloaded version 0.2.9 RC7 from this page
> > > >
> > > >
> > >
> http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/arm_memcards/
> > >
> > >
> > > >
> > > > After realizing that I needed to use the SSP FIFO mode I had it
> > > working with a 1GB SD card.
> > > >
> > > > Now that I am using a SDHC card I am having some problems. The
> > > problems start in the sd_Init function. Namely, this block of code
> here:
> > > >
> > > > if ( sd_Command( iface, CMD8, 0, 0x01AA) == 1 ) {
> > > > /* SDHC */
> > > > for ( n=0; n<4; n++ ) {
> > > > ocr[n] = if_spiSend( iface, 0xff );
> > > > }
> > > > if ( ocr[2] == 0x01 && ocr[3] == 0xAA )
> > > >
> > > > The card I am using responds to CMD8 with a value of 9, so it fails
> > > this check and goes to the SDSC case. As I understand it if CMD8
> > > responds the card is SDHC, does the response need to be 1? If I
> remove
> > > the == 1 from the first if, ocr[] is filled in with 0xFF, so the next
> > > test fails.
> > > >
> > > > Has anyone used EFSL with SDHC cards? What might be the cause of my
> > > problems? Also where can I find documentation on interfacing with
> SDHC
> > > cards? I've found a lot of docs for standard SD, but not too much for
> > > SDHC.
> > > >
> > >
> > >
> >
> > --
> > Sutton Mehaffey
> > Lookout Portable Security
> > 4040 Royal Dr. #100
> > Kennesaw, GA 30144
> > 800-207-6269, 770-514-7999, 770-514-1285 FAX
> > sutton@...
> >

--
Sutton Mehaffey
Lookout Portable Security
4040 Royal Dr. #100
Kennesaw, GA 30144
800-207-6269, 770-514-7999, 770-514-1285 FAX
s...@lookoutportablesecurity.com

The code I am using (EFSL) does just this. It it just hidden in another function that I did not paste in. In any case the initialization part seems to be working now, but the file system part is not.

--- In l..., Sutton Mehaffey wrote:
>
> I assume you are using CMD55 before ACMD41 and getting a status of 1
> before issuing ACMD41. I don't see that in your code. The sequence
> needs to be:
>
> CMD8
> CMD55
> ACMD41
>
> Sutton
>
> drproton2003 wrote:
> >
> >
> > I don't seem to be having this problem any more. The only thing I can
> > point to is that it didn't like me having a breakpoint in that block
> > of code.
> >
> > That being said, it still doesn't work. efs_init now returns -2
> > (failed to initialize file system). One problem is that when I try to
> > view the results of a sector read from the debugger it is different
> > than what the hex editor on my computer says. The really weird part is
> > that this occurs for both the 1GB card that works fine and the 4GB
> > SDHC card that doesn't.
> >
> > I've spent all day working on this now so I think it is time for a break.
> >
> > --- In l... ,
> > Sutton Mehaffey wrote:
> > >
> > > Are you preceding ACMD41 with a CMD55?
> > >
> > >
> > >
> > > drproton2003 wrote:
> > > >
> > > >
> > > > I've got one step further with this. Turns out the sd_Command
> > function
> > > > was using the wrong CRC for CMD8. The CRC was orignally set to 0x97
> > > > and it should be 0x87.
> > > >
> > > > Now the initialization gets stuck in the next few lines. ACMD41
> > always
> > > > seems to return 1, so I get stuck in the do loop.
> > > >
> > > > if ( ocr[2] == 0x01 && ocr[3] == 0xAA ) {
> > > > retry = LOOP_CNT_1000; /* should retry 1000ms */
> > > > do {
> > > > //Wait for leaving idle state (ACMD41 with HCS bit)
> > > > resp = sd_Command( iface, ACMD41,((1UL << 30)>>16), 0 );
> > > > retry--;
> > > > } while ( retry && (resp != 0) );
> > > >
> > > > if ( retry && sd_Command( iface, CMD58, 0, 0 ) == 0) {
> > > > /* Check CCS bit in the OCR */
> > > > for ( n = 0; n < 4; n++ ) {
> > > > ocr[n] = if_spiSend( iface, 0xff );
> > > > }
> > > > ty = (ocr[0] & 0x40) ? 12 : 4;
> > > > if ( ty == 12 ) DBG((TXT("SDHC HighCap\n")));
> > > > if ( ty == 4 ) DBG((TXT("SDHC\n")));
> > > > }
> > > >
> > > > Seeing as how the CRC was wrong it makes me think that this code has
> > > > never been tested with SDHC.
> > > >
> > > > --- In l...
> > ,
> > > > "drproton2003" wrote:
> > > > >
> > > > > Hello everyone,
> > > > >
> > > > > I am attempting to get EFSL to work with SDHC cards. I have
> > > > downloaded version 0.2.9 RC7 from this page
> > > > >
> > > > >
> > > >
> > http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/arm_memcards/
> >
> >
> > > >
> > > > >
> > > > >
> > > > > After realizing that I needed to use the SSP FIFO mode I had it
> > > > working with a 1GB SD card.
> > > > >
> > > > > Now that I am using a SDHC card I am having some problems. The
> > > > problems start in the sd_Init function. Namely, this block of code
> > here:
> > > > >
> > > > > if ( sd_Command( iface, CMD8, 0, 0x01AA) == 1 ) {
> > > > > /* SDHC */
> > > > > for ( n=0; n<4; n++ ) {
> > > > > ocr[n] = if_spiSend( iface, 0xff );
> > > > > }
> > > > > if ( ocr[2] == 0x01 && ocr[3] == 0xAA )
> > > > >
> > > > > The card I am using responds to CMD8 with a value of 9, so it fails
> > > > this check and goes to the SDSC case. As I understand it if CMD8
> > > > responds the card is SDHC, does the response need to be 1? If I
> > remove
> > > > the == 1 from the first if, ocr[] is filled in with 0xFF, so the next
> > > > test fails.
> > > > >
> > > > > Has anyone used EFSL with SDHC cards? What might be the cause of my
> > > > problems? Also where can I find documentation on interfacing with
> > SDHC
> > > > cards? I've found a lot of docs for standard SD, but not too much for
> > > > SDHC.
> > > > >
> > > >
> > > >
> > >
> > > --
> > > Sutton Mehaffey
> > > Lookout Portable Security
> > > 4040 Royal Dr. #100
> > > Kennesaw, GA 30144
> > > 800-207-6269, 770-514-7999, 770-514-1285 FAX
> > > sutton@
> > >
> >
> > --
> Sutton Mehaffey
> Lookout Portable Security
> 4040 Royal Dr. #100
> Kennesaw, GA 30144
> 800-207-6269, 770-514-7999, 770-514-1285 FAX
> sutton@...
>

I am the author of the EFSL SSP FIFO support code, and
Martin Thomas kindly added this into the build he has on his site.

Currently, the SSP FIFO code does not support SDHC cards. It would
appear that Martin added support for SDHC after I originated
the FIFO support, and did not update my code to support SDHC as
well. I have had this on my todo list for sometime, but I have
not had a chance to get started on it.

If you turn off the SSP FIFO support, it may work ok.

If you want to fix the FIFO code, it looks like a few simple patches
to if_command(), if_readBuf() and if_writeBuf() would be required.
Mostly what is needed is to use a block address rather than a byte
address for SDHC cards. Look at the corresponding non-FIFO routines
to see how this is handled.

The FIFO code has been carefully optimized for speed, which is one
of the reasons that it is so different than the non-FIFO code. As a
result of this, it can be a bit more problematic to modify, and
understand.

Good luck,

Mike Anton

> -----Original Message-----
> From: l...
> [mailto:l...]On Behalf
> Of drproton2003
> Sent: Tuesday, July 07, 2009 8:24 PM
> To: l...
> Subject: [lpc2000] Re: EFSL and SDHC
> The code I am using (EFSL) does just this. It it just hidden
> in another function that I did not paste in. In any case the
> initialization part seems to be working now, but the file
> system part is not.
>
> --- In l..., Sutton Mehaffey wrote:
> >
> > I assume you are using CMD55 before ACMD41 and getting a
> status of 1
> > before issuing ACMD41. I don't see that in your code. The
> sequence
> > needs to be:
> >
> > CMD8
> > CMD55
> > ACMD41
> >
> > Sutton
> >
> >
> >
> > drproton2003 wrote:
> > >
> > >
> > > I don't seem to be having this problem any more. The only
> thing I can
> > > point to is that it didn't like me having a breakpoint in
> that block
> > > of code.
> > >
> > > That being said, it still doesn't work. efs_init now returns -2
> > > (failed to initialize file system). One problem is that
> when I try to
> > > view the results of a sector read from the debugger it is
> different
> > > than what the hex editor on my computer says. The really
> weird part is
> > > that this occurs for both the 1GB card that works fine
> and the 4GB
> > > SDHC card that doesn't.
> > >
> > > I've spent all day working on this now so I think it is
> time for a break.
> > >
> > > --- In l...
> ,
> > > Sutton Mehaffey wrote:
> > > >
> > > > Are you preceding ACMD41 with a CMD55?
> > > >
> > > >
> > > >
> > > > drproton2003 wrote:
> > > > >
> > > > >
> > > > > I've got one step further with this. Turns out the sd_Command
> > > function
> > > > > was using the wrong CRC for CMD8. The CRC was
> orignally set to 0x97
> > > > > and it should be 0x87.
> > > > >
> > > > > Now the initialization gets stuck in the next few
> lines. ACMD41
> > > always
> > > > > seems to return 1, so I get stuck in the do loop.
> > > > >
> > > > > if ( ocr[2] == 0x01 && ocr[3] == 0xAA ) {
> > > > > retry = LOOP_CNT_1000; /* should retry 1000ms */
> > > > > do {
> > > > > //Wait for leaving idle state (ACMD41 with HCS bit)
> > > > > resp = sd_Command( iface, ACMD41,((1UL << 30)>>16), 0 );
> > > > > retry--;
> > > > > } while ( retry && (resp != 0) );
> > > > >
> > > > > if ( retry && sd_Command( iface, CMD58, 0, 0 ) == 0) {
> > > > > /* Check CCS bit in the OCR */
> > > > > for ( n = 0; n < 4; n++ ) {
> > > > > ocr[n] = if_spiSend( iface, 0xff );
> > > > > }
> > > > > ty = (ocr[0] & 0x40) ? 12 : 4;
> > > > > if ( ty == 12 ) DBG((TXT("SDHC HighCap\n")));
> > > > > if ( ty == 4 ) DBG((TXT("SDHC\n")));
> > > > > }
> > > > >
> > > > > Seeing as how the CRC was wrong it makes me think
> that this code has
> > > > > never been tested with SDHC.
> > > > >
> > > > > --- In l...
>
> > > ,
> > > > > "drproton2003" wrote:
> > > > > >
> > > > > > Hello everyone,
> > > > > >
> > > > > > I am attempting to get EFSL to work with SDHC cards. I have
> > > > > downloaded version 0.2.9 RC7 from this page
> > > > > >
> > > > > >
> > > > >
> > >
> http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/ar
> m_memcards/
> > >
> > rm_memcards/>
> > >
> > > > >
> > >
> > rm_memcards/
> > >
> > rm_memcards/>>
> > > > > >
> > > > > > After realizing that I needed to use the SSP FIFO
> mode I had it
> > > > > working with a 1GB SD card.
> > > > > >
> > > > > > Now that I am using a SDHC card I am having some
> problems. The
> > > > > problems start in the sd_Init function. Namely, this
> block of code
> > > here:
> > > > > >
> > > > > > if ( sd_Command( iface, CMD8, 0, 0x01AA) == 1 ) {
> > > > > > /* SDHC */
> > > > > > for ( n=0; n<4; n++ ) {
> > > > > > ocr[n] = if_spiSend( iface, 0xff );
> > > > > > }
> > > > > > if ( ocr[2] == 0x01 && ocr[3] == 0xAA )
> > > > > >
> > > > > > The card I am using responds to CMD8 with a value
> of 9, so it fails
> > > > > this check and goes to the SDSC case. As I understand
> it if CMD8
> > > > > responds the card is SDHC, does the response need to
> be 1? If I
> > > remove
> > > > > the == 1 from the first if, ocr[] is filled in with
> 0xFF, so the next
> > > > > test fails.
> > > > > >
> > > > > > Has anyone used EFSL with SDHC cards? What might be
> the cause of my
> > > > > problems? Also where can I find documentation on
> interfacing with
> > > SDHC
> > > > > cards? I've found a lot of docs for standard SD, but
> not too much for
> > > > > SDHC.
> > > > > >
> > > > >
> > > > >
> > > >
> > > > --
> > > > Sutton Mehaffey
> > > > Lookout Portable Security
> > > > 4040 Royal Dr. #100
> > > > Kennesaw, GA 30144
> > > > 800-207-6269, 770-514-7999, 770-514-1285 FAX
> > > > sutton@
> > > >
> > >
> > >
> >
> > --
> > Sutton Mehaffey
> > Lookout Portable Security
> > 4040 Royal Dr. #100
> > Kennesaw, GA 30144
> > 800-207-6269, 770-514-7999, 770-514-1285 FAX
> > sutton@...
> >
>
Mike,

Thanks for the info. Originally I had not intended on using the FIFO code. However I found that the non-fifo functions did not work even for the standard SD cards. On the webpage it says "Does not work in simple SPI mode".

Do you have a non-fifo version that works with SDHC?

--- In l..., "Michael Anton" wrote:
>
> I am the author of the EFSL SSP FIFO support code, and
> Martin Thomas kindly added this into the build he has on his site.
>
> Currently, the SSP FIFO code does not support SDHC cards. It would
> appear that Martin added support for SDHC after I originated
> the FIFO support, and did not update my code to support SDHC as
> well. I have had this on my todo list for sometime, but I have
> not had a chance to get started on it.
>
> If you turn off the SSP FIFO support, it may work ok.
>
> If you want to fix the FIFO code, it looks like a few simple patches
> to if_command(), if_readBuf() and if_writeBuf() would be required.
> Mostly what is needed is to use a block address rather than a byte
> address for SDHC cards. Look at the corresponding non-FIFO routines
> to see how this is handled.
>
> The FIFO code has been carefully optimized for speed, which is one
> of the reasons that it is so different than the non-FIFO code. As a
> result of this, it can be a bit more problematic to modify, and
> understand.
>
> Good luck,
>
> Mike Anton
>
>
>
> > -----Original Message-----
> > From: l...
> > [mailto:l...]On Behalf
> > Of drproton2003
> > Sent: Tuesday, July 07, 2009 8:24 PM
> > To: l...
> > Subject: [lpc2000] Re: EFSL and SDHC
> >
> >
> > The code I am using (EFSL) does just this. It it just hidden
> > in another function that I did not paste in. In any case the
> > initialization part seems to be working now, but the file
> > system part is not.
> >
> > --- In l..., Sutton Mehaffey wrote:
> > >
> > > I assume you are using CMD55 before ACMD41 and getting a
> > status of 1
> > > before issuing ACMD41. I don't see that in your code. The
> > sequence
> > > needs to be:
> > >
> > > CMD8
> > > CMD55
> > > ACMD41
> > >
> > > Sutton
> > >
> > >
> > >
> > > drproton2003 wrote:
> > > >
> > > >
> > > > I don't seem to be having this problem any more. The only
> > thing I can
> > > > point to is that it didn't like me having a breakpoint in
> > that block
> > > > of code.
> > > >
> > > > That being said, it still doesn't work. efs_init now returns -2
> > > > (failed to initialize file system). One problem is that
> > when I try to
> > > > view the results of a sector read from the debugger it is
> > different
> > > > than what the hex editor on my computer says. The really
> > weird part is
> > > > that this occurs for both the 1GB card that works fine
> > and the 4GB
> > > > SDHC card that doesn't.
> > > >
> > > > I've spent all day working on this now so I think it is
> > time for a break.
> > > >
> > > > --- In l...
> > ,
> > > > Sutton Mehaffey wrote:
> > > > >
> > > > > Are you preceding ACMD41 with a CMD55?
> > > > >
> > > > >
> > > > >
> > > > > drproton2003 wrote:
> > > > > >
> > > > > >
> > > > > > I've got one step further with this. Turns out the sd_Command
> > > > function
> > > > > > was using the wrong CRC for CMD8. The CRC was
> > orignally set to 0x97
> > > > > > and it should be 0x87.
> > > > > >
> > > > > > Now the initialization gets stuck in the next few
> > lines. ACMD41
> > > > always
> > > > > > seems to return 1, so I get stuck in the do loop.
> > > > > >
> > > > > > if ( ocr[2] == 0x01 && ocr[3] == 0xAA ) {
> > > > > > retry = LOOP_CNT_1000; /* should retry 1000ms */
> > > > > > do {
> > > > > > //Wait for leaving idle state (ACMD41 with HCS bit)
> > > > > > resp = sd_Command( iface, ACMD41,((1UL << 30)>>16), 0 );
> > > > > > retry--;
> > > > > > } while ( retry && (resp != 0) );
> > > > > >
> > > > > > if ( retry && sd_Command( iface, CMD58, 0, 0 ) == 0) {
> > > > > > /* Check CCS bit in the OCR */
> > > > > > for ( n = 0; n < 4; n++ ) {
> > > > > > ocr[n] = if_spiSend( iface, 0xff );
> > > > > > }
> > > > > > ty = (ocr[0] & 0x40) ? 12 : 4;
> > > > > > if ( ty == 12 ) DBG((TXT("SDHC HighCap\n")));
> > > > > > if ( ty == 4 ) DBG((TXT("SDHC\n")));
> > > > > > }
> > > > > >
> > > > > > Seeing as how the CRC was wrong it makes me think
> > that this code has
> > > > > > never been tested with SDHC.
> > > > > >
> > > > > > --- In l...
> >
> > > > ,
> > > > > > "drproton2003" wrote:
> > > > > > >
> > > > > > > Hello everyone,
> > > > > > >
> > > > > > > I am attempting to get EFSL to work with SDHC cards. I have
> > > > > > downloaded version 0.2.9 RC7 from this page
> > > > > > >
> > > > > > >
> > > > > >
> > > >
> > http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/ar
> > m_memcards/
> > > >
> > > > rm_memcards/>
> > > >
> > > > > >
> > > >
> > > > rm_memcards/
> > > >
> > > > rm_memcards/>>
> > > > > > >
> > > > > > > After realizing that I needed to use the SSP FIFO
> > mode I had it
> > > > > > working with a 1GB SD card.
> > > > > > >
> > > > > > > Now that I am using a SDHC card I am having some
> > problems. The
> > > > > > problems start in the sd_Init function. Namely, this
> > block of code
> > > > here:
> > > > > > >
> > > > > > > if ( sd_Command( iface, CMD8, 0, 0x01AA) == 1 ) {
> > > > > > > /* SDHC */
> > > > > > > for ( n=0; n<4; n++ ) {
> > > > > > > ocr[n] = if_spiSend( iface, 0xff );
> > > > > > > }
> > > > > > > if ( ocr[2] == 0x01 && ocr[3] == 0xAA )
> > > > > > >
> > > > > > > The card I am using responds to CMD8 with a value
> > of 9, so it fails
> > > > > > this check and goes to the SDSC case. As I understand
> > it if CMD8
> > > > > > responds the card is SDHC, does the response need to
> > be 1? If I
> > > > remove
> > > > > > the == 1 from the first if, ocr[] is filled in with
> > 0xFF, so the next
> > > > > > test fails.
> > > > > > >
> > > > > > > Has anyone used EFSL with SDHC cards? What might be
> > the cause of my
> > > > > > problems? Also where can I find documentation on
> > interfacing with
> > > > SDHC
> > > > > > cards? I've found a lot of docs for standard SD, but
> > not too much for
> > > > > > SDHC.
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > > --
> > > > > Sutton Mehaffey
> > > > > Lookout Portable Security
> > > > > 4040 Royal Dr. #100
> > > > > Kennesaw, GA 30144
> > > > > 800-207-6269, 770-514-7999, 770-514-1285 FAX
> > > > > sutton@
> > > > >
> > > >
> > > >
> > >
> > > --
> > > Sutton Mehaffey
> > > Lookout Portable Security
> > > 4040 Royal Dr. #100
> > > Kennesaw, GA 30144
> > > 800-207-6269, 770-514-7999, 770-514-1285 FAX
> > > sutton@
> > >
> >
> >
> >
> >
> >
> >
> >
> -----Original Message-----
> From: l...
> [mailto:l...]On Behalf
> Of drproton2003
> Sent: Tuesday, July 07, 2009 10:28 PM
> To: l...
> Subject: [lpc2000] Re: EFSL and SDHC
> Mike,
>
> Thanks for the info. Originally I had not intended on using
> the FIFO code. However I found that the non-fifo functions
> did not work even for the standard SD cards. On the webpage
> it says "Does not work in simple SPI mode".

This comment appears to relate to the AVR. There are no significant
differences in lpc2000_sd.c between version 0.2.9RC4 and 0.2.9RC7.
Certainly I don't see anything that would break either mode of
operation. I would expect that even the FIFO enabled code would
work ok for non-SDHC cards, but, I haven't tried it.

>
> Do you have a non-fifo version that works with SDHC?
>

I suspect it works, but you will need to try it.

I have not attempted to get it to work with SDHC, but I have been
meaning to. Eventually I will get at it, and make the SSP FIFO
code work properly, but no doubt that will be much later than you
would like.

Do you absolutely need SDHC support. If not, I would suggest trying
one of the earlier releases from that site, as at least I know
they work (at least RC4 does).

If you continue to have difficulties, let me know. I may try
to find some time to look into this further.

One question: how do you have all of this wired up?

Mike
Well, I found the problem. It looks as though SDHC is only supported on the MCI, not the SPI. I simply did a search for SDHC in all the files. The only hit, other than the initialization routine was in lpc2000_mci.c. From there the only difference I could see is that when reading/writing a sector the address is multiplied by 512 for standard cards and not for SDHC.

I did a quick bandaid test. I externed CardType from sd.c to lpc2000_sd.c. In the if_readBuf I added the following, likewise in if_writeBuf.

if(CardType==1||CardType==2||CardType==4)
if_Command(CMDREAD, 512 * address);
if(CardType=)
if_Command(CMDREAD, address);

With this mod it works with the fifo for both SD and SDHC cards. By this I mean that I have successfully made files on both cards, but have no measures of reliability or stability.

As to the problems with the non-fifo routines. Here is the function that clocks in the sector:

static euint8 rcvr_datablock (
hwInterface *iface,
euint8 *buff, /* Data buffer to store received data */
euint16 btr /* Byte count (must be even number) */
)
{
euint8 token;
euint16 retry;

retry = LOOP_CNT_100;
/* should retry 100ms */
do {
token = if_spiSend( iface, 0xff );
retry--;
} while ((token == 0xFF) && retry);

if(token != 0xFE) {
return 0; /* If not valid data token, retutn with error */
}

do { /* Receive the data block into buffer */
if_spiSend( iface, *buff++ );
if_spiSend( iface, *buff++ );
} while (btr -= 2);
if_spiSend( iface, 0xff); /* Discard CRC */
if_spiSend( iface, 0xff); /* Discard CRC */

return 1; /* Return with success */
}

and it calls:

euint8 if_spiSend(hwInterface *iface, euint8 outgoing)
{
euint8 incoming;

#if ( HW_ENDPOINT_LPC2000_SPINUM == 0 )
S0SPDR = outgoing;
while( !(S0SPSR & (1< incoming = S0SPDR;
#endif

#if ( HW_ENDPOINT_LPC2000_SPINUM == 1 )
while( !(SPI_STATUS_REG & (1< SSPDR = outgoing;
while( !(SPI_STATUS_REG & (1< incoming = SSPDR;
#endif

return(incoming);
}

Seems to me like if_spiSend( iface, *buff++ ); should be something like *buff++=if_spiSend( iface, 0xFF);

--- In l..., "Michael Anton" wrote:
>
> > -----Original Message-----
> > From: l...
> > [mailto:l...]On Behalf
> > Of drproton2003
> > Sent: Tuesday, July 07, 2009 10:28 PM
> > To: l...
> > Subject: [lpc2000] Re: EFSL and SDHC
> >
> >
> > Mike,
> >
> > Thanks for the info. Originally I had not intended on using
> > the FIFO code. However I found that the non-fifo functions
> > did not work even for the standard SD cards. On the webpage
> > it says "Does not work in simple SPI mode".
>
> This comment appears to relate to the AVR. There are no significant
> differences in lpc2000_sd.c between version 0.2.9RC4 and 0.2.9RC7.
> Certainly I don't see anything that would break either mode of
> operation. I would expect that even the FIFO enabled code would
> work ok for non-SDHC cards, but, I haven't tried it.
>
> >
> > Do you have a non-fifo version that works with SDHC?
> > I suspect it works, but you will need to try it.
>
> I have not attempted to get it to work with SDHC, but I have been
> meaning to. Eventually I will get at it, and make the SSP FIFO
> code work properly, but no doubt that will be much later than you
> would like.
>
> Do you absolutely need SDHC support. If not, I would suggest trying
> one of the earlier releases from that site, as at least I know
> they work (at least RC4 does).
>
> If you continue to have difficulties, let me know. I may try
> to find some time to look into this further.
>
> One question: how do you have all of this wired up?
>
> Mike
>