Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4906

Bare metal, Assembly language • Re: SDHOST block read returns CRC in data

$
0
0
I am now reading the card and its MBR but have found the read block command (CMD17) returns a 64 byte data block before the actual 512 bytes of the requested sector. I assume this is CRC related
the SD protocol puts the crc at the end of a read, not the start

i believe the proboelm your seeing, is that the sdhost keeps shifting the DAT pins into the FIFO, even after a read completes
and the FIFO can only hold 64 bytes of data, so it gets jammed with garbage at the end of each read

https://github.com/christinaa/rpi-open- ... #L335-L343

Code:

void drain_fifo() {wait();while (SH_HSTS & SH_HSTS_DATA_FLAG_SET) {SH_DATA;mfence();}}virtual bool read_block(uint32_t sector, uint32_t* buf) override {if (!card_ready)panic("card not ready");if (!is_high_capacity)sector <<= 9;/* drain junk from FIFO */drain_fifo();
this is how the rpi-open-firmware projects deals with it, draining the FIFO before each read

Statistics: Posted by cleverca22 — Tue Oct 08, 2024 12:13 am



Viewing all articles
Browse latest Browse all 4906

Trending Articles