Arrrg, 3 days... 3 days of trying to track down this silly bug where a read port may freeze when running my DDR3 controller in Quarter Rate Mode with an unusual slip in the read address (when slanting 1 of 2 superimposed video layers on my VGA controller) only after millions of read commands issued. I just cant simulate it and the signal tap would be useless as there are too many environment variables to track at 300MHz. It's driving me nuts as it is the one thing I have left before issuing a proper v1.6 release. There is no reason for this to operate properly in half-rate mode, but not quarter-rate mode and I know which modules are involved. Worse, turning off the read-cache solves the problem at the expense of making repetitive reads slow.
Eesh - didn't realise it was such a pervasive little problem!
I'll take a look at the updated DDR3 controller this weekend and update my project with it.
I've managed to keep plugging away at the SD interface this last week or so and have made some significant progress - I'm now at the testing and bug-hunting stage, having written a WRITE function for the interface. It is somewhat based on the existing SDReader module, but I've leaned heavily on the HDL within the SD-card-controller sd_data_serial_host module for guidance. I've also been deep-diving the SD Part_1_Physical_Layer_Specification (albeit version 3.01, but it's not the simplified version and has some key diagrams showing WRITE timings).
I'm reading Sector 0 off the SD card into the SD Buffer in GPU RAM. Then I'm trying to write that data (the FAT32 MBR, basically) to Sector 3. I'm writing it to Sector 3 as Sector 3 appears to be all zeros on the SD card, and failed writes erase the sector but don't write anything, so I'm not changing any data on the SD card with a failed write (which is all I'm managing to do at the moment).
It appears that I'm not getting anything back from the SD card when I attempt to write to it. I'm sending CMD24, then writing the 512-byte payload, immediately followed by the 16-bit CRC and STOP bit, but I'm not seeing any life on DAT0 when the SD card should be responding with the CRC response byte (which should be an error or OK, if I've got the CRC function working correctly).
Here's a SignalTap of the start of the process, showing the start of payload transmission to the SD card (CMD24 is sent using the same module that the READ command is sent, I have no reason to think it's not working as intended):
And here's a SignalTap of the end of the process, showing the last two bytes of the payload (0x55 and 0xAA being the last two bytes of Sector 0) and the 16 CRC bits and STOP bit:
It seems there are quite a few possible points of failure in this process - I'm gravitating towards it being an issue with the DAT0 direction or the CRC being incorrect, but the SD card should respond if it's a CRC error.
I'd really,
really appreciate the help of anyone who knows a bit about the SD interface and 1-bit SD mode, which is what I'm using here. Latest project files attached for reference. The SD modules are in the SDCard_Interface folder in the project folder - SDWriter is the module that I'm debugging.