2025-07-24 12:59 AM
I'm working on a project requiring me to save a frame captured by a camera to an SD Card. I'm using SPI to do this. I am able to save the image from an OV5640 camera to sram in a buffer using DMA, where the size is more than 300,000 bytes. I am able to save a text file to the card if I have something short like "Hello World," but when I try to save the buffer containing the frame, error code 1 is returned signaling a hard fault. Also, the errors aren't always the same, sometimes the close and un-mounting steps end in a hard fault too, but that usually goes away after rerunning the code. I am using SD Card drivers from KiwiH here. I added debug print statements throughout the f_write function in ff.c and I saw that the line that is causing the error is the here (line ~3691):
if (disk_write(fs->drv, wbuff, sect, cc) != RES_OK) ABORT(fs, FR_DISK_ERR);
This line is only ran when the contents of the buffer span multiple sectors, which than makes sense that the short messages work correctly. My code is exactly the same as the code in kiwiH's github repo for testing, but I try to write my frame buffer to the SD card. The github repository for my project is here.
Thanks so much in advance!
2025-07-24 4:09 AM
Why you choose a high speed cpu like H753 , but then use not its SDMMC interface to SDcard, but the only on tiny and slow cpus used SPI mode ?
Only SDMMC in 4bit mode giving useful data rate for video. imho.
2025-07-24 10:16 AM
Yeah, I realized that after I had already bought a micro-SD SPI interface peripheral. I probably would have went with that if I had realized earlier. I don't have too much more time to work on this project, so I decided to stick with SPI even if its slower.
2025-07-24 11:39 AM
For testing just use a sd-card adapter with soldered wires; i always do it this way;
anyway wires should be max. 30 mm long;
2025-07-24 1:29 PM
Oh wow, I didn't know that that worked. Well I might try that later on if this still doesn't work, but I would love to get this working with SPI if possible.