Minimal SD card reader code, if possible
Harley
Posts: 997
I'm not sure what all the various SD card reader's code size is. Looking for a minimal one.
I have a touchscreen 'input' but no keyboard to name files. Is there a way to automatically have new files automatically 'named', say with incrementing number at end? Like it reads the DIRectory and then 'knows' the last file, adds one for a new file name to save. Or is that a dumb idea?
Maybe I could put up a virtual keyboard and 'type' file names in that way. That might add a lot of code space. Suggestions???
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Harley Shanko
I have a touchscreen 'input' but no keyboard to name files. Is there a way to automatically have new files automatically 'named', say with incrementing number at end? Like it reads the DIRectory and then 'knows' the last file, adds one for a new file name to save. Or is that a dumb idea?
Maybe I could put up a virtual keyboard and 'type' file names in that way. That might add a lot of code space. Suggestions???
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Harley Shanko
Comments
I don't think anyone has documented the size of the SD card reader code. I believe the smallest one is Rokicki's FSRW 2.4. His newer version 2.6 is a little bigger. Remember that there are two layers, a low-level SD card driver that reads and writes sectors given a sector address and a high level FAT file system driver that knows about directories and files.
There's no ready-to-go routines to automatically number files, but it shouldn't be hard to make your own. There are calls to FSRW for listing the directory which return successive file names in the directory. You can have code to look at the returned strings, check for the format of the names and, if numeric with some prefix that you define, look for the highest number that exists and increment it, then use that to create a new file. It's easy to compare numeric strings and increment them, particularly if they're fixed length (like "000123")
I will search for Rokicki's file you mentioned. That should keep me busy for a while.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Harley Shanko
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
Rayman's PTP board provides a SD card socket. So figured I should make use of that with my program. Hopefully all will fit in EEPROM and run OK.
Thanks also to heater for your size on fsrw/sdispi Femto.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Harley Shanko
@localroger. Thanks for your input. Again, I have to get more done on this project to see if SD card use can be done. Originally wasn't a requirement, but would be a great advantage for keeping reference files.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Harley Shanko
I'm lazy and the files increment slowly (once a day), so I haven't worried about what happens when it gets to 999...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hugh - the thinking woman's Geoffrey Pyke.
RossH has some mean and lean low level SD card driver in his Catalina package. Sadly I have yet to make it work here.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
safe_spi: the current default block driver (uses multi-block mode)
size = 1330 longs
write = 975 KB/s
read = 878 KB/s
smaller multi-block mode
size = 1283 longs
write = 847 KB/s
read = 843 KB/s
smaller single-block mode
size = 1185 longs
write = 170 KB/s
read = 606 KB/s
Note the super-slow writing speed on the single-block driver...this is typical of SDHC cards. The older SD or MMC cards are typically on the same order of magnitude as the read speeds, but all SDHC cards I've tried do not like single-block mode writing. I do get to chop out a bunch of code from the single-block driver because I don't have to be careful of timeouts and auto-exiting multiblock read/write mode.
I can also make versions of the drivers that do not use the read-ahead and write-behind, but that's taking us back to the same basic mechanism as the old FSRW 1.6 code, where the only addition is the support of MMC and SDHC cards. I'm not too keen on investing time (and then support) on those versions unless someone really really needs them.
Jonathan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
lonesock
Piranha are people too.
(geek humor escalation => "There are 100 types of people: those who understand binary, and those who understand bit masks")
I like to use the old sdspiQ block driver. This driver is relatively fast and very small. The initialization of the SD is all done inside the assembly code.
Would it be possible to add some commands to this initialization code to support also SDHC cards? Yes it will be single block access and the write speed is not high, but for many applications the read speed is what counts. I think if we not support MMC we need no slow SPI and it's just a matter of adding the right initialization sequence of commands at initialization.
This is on my Todo list, but you have much more experience with SD and it is maybe only a work of some minutes for you (?)
Andy
I store the last·character of the file name in EEPROM.· I'm even lazer than Hugh; I use a letter for the last character of the file name so I never let more than 26 files exist on the card at a time.· I do have the program check the card to make sure the new file name isn't already used.
I've been rewiting my code to use Kye's method's.· My new plan is to have a new folder made each month and have the files' names based on the date (someone else on the forum suggested something similar).· I should have some useable code within a week (hopefully later today).· It depends on how many other things scream for attention louder(than a new file system).· I'd be surprised if my code would be usefully to anyone else, but I'm very willing to shared my hacked together methods.
Duane
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,
@sssidney: Great question! I will look into a read-only version soon.
Jonathan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
lonesock
Piranha are people too.
(geek humor escalation => "There are 100 types of people: those who understand binary, and those who understand bit masks")
Is it OK to attach the modified files here?
I also tried doing simultaneous access from 2 cogs while protecting the fs code with spin locks. It works great.
Post Edited (sssidney) : 7/23/2010 3:33:21 PM GMT
thanks,
Jonathan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
lonesock
Piranha are people too.
(geek humor escalation => "There are 100 types of people: those who understand binary, and those who understand bit masks")
#ifdef SID_INCLUDE_WRITE and #ifdef SID_INCLUDE_SEEK.
Thank you very much for the sdspiasm code with SDHC and MMC initialization. Should not be hard to merge that with the sdspiq when I have time.
Andy