sdmmc SD_Write()/SD_Read() failed with ATP card

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

sdmmc SD_Write()/SD_Read() failed with ATP card

2,958 Views
JohnU
Contributor III

Hi,

 

I test FSL sdmmc on OM13092 LPCXpresso54608 using sdcard_polling example (SDK 2.2.0).

I have found it fails on SD_Read() / SD_Write() a single 512-byte sector with the microSD card: ATP 512MB Industrial Grade (AF512UDI AML 16020015 161316M83ENM E1606BA).

I've also tried with decreased busClock_Hz to 3MHz and both 4 and 1-bit bus width.

On SD_Write(startBlock=2, blockSize=512, blockCount=1):

SD_WaitWriteComplete() is succressful (R1 response[0]=0x900).

Unfortunately kSDMMC_WriteSingleBlock (CMD24, argument=1024) fails due to SD_Transfer() failure:

- SDIF_WaitCommandDone(): status = 0x84 after SDIF_GetInterruptStatus() (DCRC bit is set). R1 response[0] = 0x20000900 (BLOCK_LEN_ERROR).

On SD_Read(startBlock=2, blockSize=512, blockCount=1):

SD_WaitWriteComplete() is succressful (R1 response[0]=0x900).

Unfortunately kSDMMC_ReadSingleBlock (CMD17, argument=1024) fails due to SD_Transfer() failure:

- SDIF_WaitCommandDone(): status = 0x84 after SDIF_GetInterruptStatus() (DCRC bit is set). R1 response[0] = 0x900 ("success")

- first SDIF_GetInternalDMAStatus() call returns IDSTS=0x122

- SDIF_TransferDataBlocking(): SDIF_GetInternalDMAStatus() returns dmaStatus=0x122 (kSDIF_DMACardErrorSummary, ie. CES bit)

Card data:

RawCid Details:{4261479477, 269648260, 1176524100, 155275329}

RawCsd Details:{373293205, 3988258703, 1532592598, 6160434}

RawScr Details:{36012032, 0}

ocr 0x80ff8000

Is it known problem?

 

best regards

J.

7 Replies

1,894 Views
Eli_H
NXP Pro Support
NXP Pro Support

Are you using the SDK code and also have SDRAM enabled?   If so, see this:

https://community.nxp.com/message/931558 

I was getting weird SD card issues/failures.    This may solve your problem.

0 Kudos

1,894 Views
JohnU
Contributor III

Thanks Eli.

Pinmux is set according to the errara. But probably your hint helps others.

Described issue is related to SD specifications, eg. Part 1 Physical Layer, Simplified Specification version 2.00.

Some SD cards works, some not - especially older controllers.

kind regards

J.

0 Kudos

1,894 Views
JohnU
Contributor III

When DMA support disabled in fsl_host.c:

SDIF_TransferFunction(): SDIF_TransferBlocking(base, /*&dmaConfig*/NULL, content):

On SD_Write(startBlock=2, blockSize=512, blockCount=1):

SD_Transfer() failure:

- SDIF_WaitCommandDone(): status = 0x14 after SDIF_GetInterruptStatus(). R1 response[0] = 0x20000900 (BLOCK_LEN_ERROR).

On SD_Read(startBlock=2, blockSize=512, blockCount=1):

SD_Transfer() failure:

- SDIF_WaitCommandDone(): status = 0x24 after SDIF_GetInterruptStatus(). R1 response[0] = 0x900 ("success")

- SDIF_TransferDataBlocking(): SDIF_ReadDataPortBlocking():

via step-by-step debugging:

* first SDIF_GetInterruptStatus() call returns 0x420, SDIF_ReadDataPort() returns transferredWords=0xF

* 2nd SDIF_GetInterruptStatus() call returns 0x20, SDIF_ReadDataPort() returns transferredWords=0x1E

* 3rd SDIF_GetInterruptStatus() call returns 0x420, SDIF_ReadDataPort() returns transferredWords=0x2D

* 4th SDIF_GetInterruptStatus() call returns 0x20, SDIF_ReadDataPort() returns transferredWords=0x3C

* 5th SDIF_GetInterruptStatus() call returns 0x420, SDIF_ReadDataPort() returns transferredWords=0x4B

* 6th SDIF_GetInterruptStatus() call returns 0x20, SDIF_ReadDataPort() returns transferredWords=0x5A

* 7th SDIF_GetInterruptStatus() call returns 0x420, SDIF_ReadDataPort() returns transferredWords=0x69

* 8th SDIF_GetInterruptStatus() call returns 0x88(failed - DCRC, DTO - data transfer over - likely FIFO overflow due to step-by-step debugging)

via breakpoints on error:

* last SDIF_GetInterruptStatus() call returns 0x80 (DCRC), transferredWords=0x78 (underrun?)

best regards

J.

0 Kudos

1,894 Views
soledad
NXP Employee
NXP Employee

Hi,

I found the below thread: sdmmc hangs on SD_Init() , is the same issue?

in the thread sdmmc eMMC Decode CID properly did you find the solution to this issue?

Regards

Sol

0 Kudos

1,894 Views
JohnU
Contributor III

Hi,

no, each of the issues is separate.

The issue concerns sdmmc library bug (I finally solved) in SD_Init() in the file sdmmc/src/fsl_sd.c:

SD_SelectBusTiming() calls SD_SwitchFunction() which sets block size to 64bytes (512bits).

Therefore SD_SetBlockSize(card, FSL_SDMMC_DEFAULT_BLOCK_SIZE) should be called again before SD_Init() exits.

best regards

J.

1,894 Views
andyjackson
Contributor III

Thanks for identifying this issue. It fixed the problem i was having accessing an SD card.

Can't see how this could every have worked as released?

   Andy

0 Kudos

1,894 Views
JohnU
Contributor III

Hi,

exactly. You can see other issues I found for sdmmc :/

Personally I'd suggest do not use the library for general SD card socket on the moment. It is rather good for embedded dedicated cards or chips like eMMC.

Unfortunately there is no NXP reaction yet. I've not found new version of the library here kinetis-sdk2/middleware/sdmmc_2.1.2/port/sdhc/freertos at master · kylemanna/kinetis-sdk2 · GitHub 

It would be nice if NXP team reviewed the sdmmc library code against eg. uboot code: git.denx.de Git - u-boot.git/blob - drivers/mmc/mmc.c or just Linux kernel.

best regards

J.

0 Kudos