I’m writing simple programs for the PicoCalc using Rust. I’m trying to read the SD card with the following code [1], but it keeps failing with the following error [2]. I’m using the embedded-sdmmc crate.
Additionally, the card size is incorrect. The SD card that came with the kit reads as 32GB when connected to my laptop, but it’s only recognized as 8GB when I try to access it through the Rust program. I have already tried formatting the card (FAT32, MBR) and partitioning it with the official script from the ClockworkPi repo [3].
Take a look at the “sdcard” branch at my repo. It only supports reading right now; I am still actively developing this. The initialisation code seems solid so far.
The interesting part about SD Cards is that you are inserting different hardware with each card and they are all not created equally even if they are following the same specifications.
I have been using that SD card image during development of my FAT32 driver and I know the structure of that image at byte level. Please let me know how I can help.
Where in the embedded-sdmmc crate is it throwing that error?
I’m new to embedded development and I’ve been trying to get this to work for a few days now. Still having the same issues.
I’ve checked your repo and ensured that the pins are right. The only difference is the speed. I believe you’re using 25MHz. I’m initialising the card with 200kHz and then increasing it to 16MHz. I’ve also tried directly initialising with higher speed instead of starting slower. That doesn’t work as well.
Okay. Unfortunately even the mutex and the critical section did not help. I think there could still be something wrong with how the SD Card is formatted and partitioned.
What do you think is the best way to format it? I’ve tried the windows formatter, the official tool from the SD Association and also the clockworkpi official linux script.
I reformatted the SD card that came with my PicoCalc with mkfs.fat on Debian (because I never bothered to implement support for long file names in zeptoforth), and haven’t had any problems with it. Note that I did not regenerate the partition table, so I am still using the stock partition table that came with the SD card from ClockworkPi.
My guess is that there is data corruption in the communication between the SD card and your board. In the case of zeptoforth, I send/receive dummy bytes in many places when communicating with the SD card, and previously had communication problems without the right number of dummy bytes.
Could be. And a few people I spoke to said that they’ve only used this crate with microSD cards and not full sized once. I should probably test that as well.
This is the point where I would hook up my logic analyzer to the SD card pins and dump the entire transaction out. Trying to debug subtle communication errors without actually seeing what is on the wire is only going to drive you insane.
This is either a software problem or a hardware one.
I do remember someone here, and for the life of me I cannot find the post, had a hardware problem with the SD card socket not soldered correctly and he repaired it with his soldering iron.
I don’t think it’s hardware. I just tried the “print mm.info(free space)” in picomite and it returns 31663472640. I’m also able to access the files in the sd card. This makes it clear that there’s nothing wrong with the both the SD card and the SD Card Socket.
So it’s probably the code or the crate. I still want to check the code with a micro sd card. But I haven’t been able to source an adapter in nearby stores. If it works then it’s the SD Card + embedded-sdmmc crate combo that’s the issue. If it doesn’t then it’s probably the code.
I’m inclined to agree, but like I said, most people that I checked with haven’t really had an opportunity to use this particular library with a full size SD Card. I just want to rule that out.
I can definitely confirm this. You are adding slightly different hardware to you PicoCalc with each SD card you connect. I had to play around with short delays in magic places and sending dummy bytes here and there to get different cards to work. The older the card, the more eccentric it seemed to be.
Did you already try a different SD card? Cheaper cards might not have wear leveling and its easier than you might expect to get errors in the allocation table