I.MX8 - usdhc - adma2

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

I.MX8 - usdhc - adma2

1,215 Views
DiGh
Contributor I

Hi

I'm trying to read/write data to eMMC using the usdhc with ADMA2 engine.  Without success so far (using PIO mode works fine).

I'd like to send data (1024 characters located at 0xc7800a80).  Therefore, I have made my descriptor table with 2 entries, located at address 0xc78001ac:

0xc7800a80  |  512  | 0  | 0x21 (TRANS + VALID)
0xc7800c80  | 512   | 0  | 0x23 (TRANS + VALID + END)

contents of registers before sending command-25 (multiblock write):
ADMA_SYS_ADDR = 0xc78001ac
BLK_ATT = 0x20200 (2 blocks of 512 bytes)

(all other flags are set correctly)

After sending command-25, I always get ADMA_ERR_STATUS 0x7 (length mismatch error).  Register ADMA_SYS_ADDR contains 0xc (I have no clue what this value means).
BLK_ATT contains now 0x200 (so I suppose the DMA engine has read 2 blocks)

Someone who can help me with this problem ?

Thanks

0 Kudos
Reply
4 Replies

1,207 Views
DiGh
Contributor I

Some extra information:

The contents of INT_STATUS register is 0x3, so I suppose command-25 is successfully executed.

The contents of CMD_RESP3 is 0x00c (relation with ADMA_SYS_ADDR ?) - does this hint towards "auto CMD12" ?  I haven't setup anything regarding "auto CMD12" ?

0 Kudos
Reply

1,195 Views
igorpadykov
NXP Employee
NXP Employee

Hi DiGh

 

for adma2 example one can look at below link:

https://github.com/RT-Thread/rt-thread/blob/master/bsp/imx6sx/iMX6_Platform_SDK/sdk/drivers/usdhc/sr...

 

Best regards
igor

0 Kudos
Reply

1,182 Views
DiGh
Contributor I

Thanks Igor for your reply.

I already use this code as an example for my project.  There must be some very small difference, but I can't see it.

This is what I do:

1. allocate some data: char some_data[512] = "..." stored at address '0xc7800a84'
2. make sure the length (in bytes) is a multiple of 512 (block aligned)
3. send command-16 (SET_BLOCKLEN)
4. set the BLK_ATT register to '0x10200' - 1 block of 512 bytes to be sent
5. set the WTMK_LVL register, field WR_WML, to 0x80
6. create my adma2 descriptor:
  > address = 0xc7800a84
  > length = 512
  > attributes = 0x23 (TRAN + VALID + END)

  > result = 0xc7800a8402000023 stored at address '0xc78009b4'
7. set the ADMA_SYS_ADDR to '0xc78009b4'
8. send command-25 (WRITE_MULTIPLE_BLOCK)

register MIX_CTRL = 0x27
register PROT_CTRL = 0x800220 (DMASEL = '10' (adma2) and endian-mode is '10' (little endian) )

Then, immediately after register CMD_XFR_TYPE is set, I get a DMA error interrupt and the error is 0x7.  The contents of the ADMA_SYS_ADDR is 0xc.  I'm wondering if it is a coincidence that the address of my descriptor table also starts with '0xc...' (0xc78009b4)

Command-25 is executed completely without errors.

The only thing I don't do is flushing the d-cache because, in my environment (DDC-I Deos operating system), I don't know how to do this yet....

0 Kudos
Reply

1,174 Views
igorpadykov
NXP Employee
NXP Employee
0 Kudos
Reply