Edit:
An explanation based on a vague memory of why stuff breaks:
When reading and writing data from/to the SD card, it’s done in transfers of 512 bytes. SDFS calls this the “window”. If you seek to the 10th byte of a file and write 1 byte, SDFS will change that byte in the window, then copy the entire 512 bytes to the disk. PFFS, iirc, doesn’t have a window. It will zero bytes 0-9, write the 10th byte and, if you close the file, zero bytes 11 to 511 to complete the transfer.
Doesn’t seem to work even after formatting Emulator shows the files but Pokitto still doesn’t.
I guess I could use PFFS for listing the files and SDFS for opening and saving, but after a quick try now it does this: listing directory files works (PFFS), then I save a file (SDFS), and now I can no longer list directory files (PFFS, even if I call pokInitSD before every attempt to list the files. Code here).
EDIT:
And also now I found that I can’t even open a file on Pokitto with SDFS (PFFS was able to open it. Emulator opens it even with SDFS). I dunno, I must be doing something horribly wrong.
You can’t use both libs at the same time, SD cards have state and the libs will interfere with each other.
I’ll give the code a look when I get home, I don’t have my Pokitto with me.
Edit: Have you tried my loader? Does it work with your card? Just trying to isolate the cause.
Maybe, maybe not. That filesystem lib there has been tweaked/bugfixed a bit.
Now we know it’s not an issue with your card, I’ll try to see if I can reproduce the issue here.
Nope sorry, still doesn’t work for me I’ve even reformatted the card again. I’ll have to get a sleep for this. But you’ve fixed me one bug at least, that’s good.
It’s not easy I know. You first want to make automated tests to make sure you don’t break things in the process. This needs some planning.
I formatted the card to FAT32, put two small txt files on it, then put the card to Pokitto, turn it on, open the menu in the editor (just navigate with arrow keys), select “open” and there it freezes (ATM there’s no error checking so NULL dereference happens… on emulator files are correctly listed).
Hmm… that’s exactly what I did, but the file list worked and I was able to open a file, go back to the list, open another, and so on.
Try my build? firmware.bin (97.4 KB)
(No hurry, go to sleep already )
Am on mobile now, but I’ll try it before sleep. This definitely seems weird, I bet it’s some awkward mistake on my side
EDIT:
Your bin freezes as well. I don’t get it, your loader worked, so the card has to be working. And PFFS was able to list the files as well. Yes, my SD card is actually in the Pokitto right now. Very very strange. I’ll look at it tomorrow!
Unless your SD card isn’t plugged in properly (actually happened to me once, had me scratching my head wondering why file access suddenly stopped working), it doesn’t sound like it’s just a mistake.