fusesoc / sd_device

SD device emulator from ProjectVault
Apache License 2.0
15 stars 5 forks source link

Using it as a linux SDCARD in SPI mode. #2

Open Dolu1990 opened 4 years ago

Dolu1990 commented 4 years ago

Hi,

We are using the sd_device for simulation purpose (verilator) to emulate a SDCARD used by a softcore running linux. (https://github.com/SpinalHDL/SaxonSoc/pull/7)

Got a few issue, had to add some "state exit" logic to unblock the situation durring the weird sequance that the linux SDCARD driver does to unlock/unfreeze sdcard on boot (https://github.com/SpinalHDL/sd_device/commit/414c9356aeeb36a2616d6a7af2c1869afd55e53d#diff-6903b38ec20622e06f2d9b5083d4f347R327)

Also, had to add support for RESP_R1B (used after MULTIPLE_READ)

Now seem there is some issue with WRITE_MULTIPLE ending.

Do you have some ideas about those issues ? If you want we can setup a easy to use case reproduction for you to get some waves :)

Anyway, thanks for the project ^^

danielkucera commented 6 months ago

Hi @Dolu1990 , I have the same issue with CMD25 WRITE_MULTIPLE. Did you manage to get it to work?

danielkucera commented 6 months ago

I have made a logic capture: image you can see the DAT0 is kept low and clock is enabled so the host is waiting for something. From the spec:

After receiving a block of data and completing the CRC check, the card will begin writing and hold the DAT0 line low if its write buffer is full and unable to accept new data from a new WRITE_BLOCK command.

So the bug is probably somewhere around here? https://github.com/fusesoc/sd_device/blob/master/rtl/verilog/sd_link.v#L968 Maybe block_write_done is not set?

Dolu1990 commented 6 months ago

Hi @danielkucera

Didn't got it to work, but didn't tried enough i guess.