Here is a version of FSRW that works with both FastSpin and the Parallax Spin compiler (AKA PNut and soon to be PropTool for P2).
Thanks to @cheezus
for providing the base from which this came from as discussed here: http://forums.parallax.com/discussion/169786/
Thanks to input from @Cluso99
and @Peter Jakacki
for showing me how to improve read speed.
And, of course thanks to Tomas Rokicki and Jonathan Dummer for providing the original P1 FSRW 2.6 from where this all came from...
This driver works very much like the P1 version, with some small differences:
- Mount() used to return 0 on success and negative on failure. Now, it returns 1 or 2 on success to tell you card type (1==SD and 2==SDHC).
- There are two versions of the low level SPI driver, sdspi, to select from in Fsrw.spin2. The "bashed" version does not use a separate cog, while the other, "ASM" one does. The "ASM" version is about 10% or so faster in some tests.
Note: If you choose the assembly version, edit the "sdspi_asm_mb.spin2" driver if you want to change the cog# being used. This version has "SPI_COG=6".
- There are two new functions FastBlocksRead() and FasterBlocksRead() that blindly read a series of blocks without following the FAT chain. This can be useful for maximizing read speed of large files on freshly formatted disks. Both of these options require the use of the new remount() function to switch files.
The read speed can be tested using the "fsrw_test2.spin2" file in the attached. There are three different read options to choose from.
This code repeatedly loads and displays the file bitmap2.bmp over VGA and sends diagnostic info over the USB serial connection. This is useful for checking for read errors.
With the FasterBlocksRead() option, I'm seeing about 2000 kB/s at 250 MHz clock and 2400 kB/s at 300 MHz clock.
This is fast enough to do QVGA video demonstrated by the included file, "P2VideoPlayer.spin2", as described here: http://www.rayslogic.com/Propeller2/P2Video/P2Video.html
This is by no means complete, there are still a lot of improvements that can be made. Any improvements or suggestions are welcome.
I don't know if I'll be the one doing any updates or not as it seems to fill my needs as is now.
Also, I haven't really tested the writing part of this very much, mostly just been focused on reading.
25May20: Fixed a timeout issue with the bashed version that would cause opening a new file to fail when a long time passed since opening the first file. Also, added in a basic timeout to the assembly version.
29May20: removed a PINL(56) and a PINL(57) in fsrw.spin2 that was used for debugging.