New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hangup, and 'no SD card detected' after reset #7
Comments
Certainly something is locking up in the driver which is leaving the card in a broken state. When the system hangs it does so with the SD card LED turned on, so it must be doing something to the SD card at the time. Whether it's actually the driver for the SD, or the driver for the SPI, or even something else like the swapper that's causing it, I have no clue. |
It can be a timer interrupt in the middle of block transfer. I'm not sure the card tolerates this kind of intrusion. In perspective, it makes sense to modify sd driver to use DMA for block transfer, with interrupt on completion. It will free cpu resources for user tasks and network packet processing. It could solve this issue as well. |
Should the DMA transfer be implemented in the SD driver, or in the SPI driver? I'd vote for the SPI driver, so it could be used for other things besides the SD card. |
Seems like the initiation of a transfer belongs to SPI side. But the interrupt processing should be done in SD driver. So SD driver need to provide the DMA channel number to SPI, as it should match the IRQ number. |
Either that or the SD driver provides a function pointer to the SPI library as an interrupt callback routine? That way the SPI library could allocate a DMA channel (or better still the DMA driver could allocate a channel to the SPI device). |
I don't think we need too much dynamics here. The DMA channel can be assigned statically at configuration/compile time, like dma0 - for sd0, dma1 - for sd1 (when on separate SPI port) etc. It would simplify the switch in sys/mips/pic32/trap.c:
|
True enough. I do tend to overthink these things :) |
Just for fun I just wrapped all the SPI bulk transfers in global disable/enable interrupts. It's solid as a rock. Not had a crash yet, and been making that SD LED flash like crazy. |
Sometimes the system hangs up, and when restarted using Reset button, the kernel fails to boot up with message:
sd0: no SD card detected
Seems like a bug in sd driver. Wrong timing or something.
The text was updated successfully, but these errors were encountered: