Discussing SD Drivers (depreciated fsrw)
cheezus
Posts: 298
Sd Drivers for P2 REVa
Because most of my projects with the P1 made extensive use of SD cards, I found myself needing a good SD driver. I'm in the process of building several drivers and this thread is to document the progress, as well as hold the releases for now. I will keep this first post updated with the current Release Candidate, as well as current release notes.
FSRW RC3-w/Ymodem
/discussion/download/127271/FSRW_V1.zip
FSRW RC3
https://forums.parallax.com/uploads/FileUpload/97/912b9bd3f13f2eafe94d5928f65e9c.zip
Based on FSRW2.x for p1. sdspi_asm is default and is starting to take shape. sdspi_sp_inline uses the same methods to read/write to pins but doesn't start it's own cog and instead uses inline assembly to handle smartpins. sdspi_bashed uses bit-bashing to control pins and is only included for cases where data/clock pins aren't within smartpin reach.
There's much on the TODO list, including releasing pins (release does nothing right now) as well as much needed documentation. Since I'm not a "professional" developer, I could use a lot of help and really appreciate suggestions and even complaints. Hopefully others will find this work helpful and useful!
I though I saw someone working on and possibly having a working FSRW for the P2. Any help would be great!
I've been working on porting FSRW2.6 to the Propeller 2 under fastspin and I'm finally getting somewhere. I have inline ASM working up to 320MHZ on a couple cards, although I need to thoroughly test things still. It's SLOWWWWW but seems to be working with SD as well as SDHC. Removing SD support would speed things up but the goal is "most compatible." Tested with FAT32, FAT16, FAT12 not supported but wouldn't be too hard to add.
I'm going be working on a cogdriver for this next as I think that's the next big speed bump at this point. Please test, break, comment, complain.
Because most of my projects with the P1 made extensive use of SD cards, I found myself needing a good SD driver. I'm in the process of building several drivers and this thread is to document the progress, as well as hold the releases for now. I will keep this first post updated with the current Release Candidate, as well as current release notes.
FSRW RC3-w/Ymodem
/discussion/download/127271/FSRW_V1.zip
FSRW RC3
https://forums.parallax.com/uploads/FileUpload/97/912b9bd3f13f2eafe94d5928f65e9c.zip
Based on FSRW2.x for p1. sdspi_asm is default and is starting to take shape. sdspi_sp_inline uses the same methods to read/write to pins but doesn't start it's own cog and instead uses inline assembly to handle smartpins. sdspi_bashed uses bit-bashing to control pins and is only included for cases where data/clock pins aren't within smartpin reach.
There's much on the TODO list, including releasing pins (release does nothing right now) as well as much needed documentation. Since I'm not a "professional" developer, I could use a lot of help and really appreciate suggestions and even complaints. Hopefully others will find this work helpful and useful!
I though I saw someone working on and possibly having a working FSRW for the P2. Any help would be great!
I've been working on porting FSRW2.6 to the Propeller 2 under fastspin and I'm finally getting somewhere. I have inline ASM working up to 320MHZ on a couple cards, although I need to thoroughly test things still. It's SLOWWWWW but seems to be working with SD as well as SDHC. Removing SD support would speed things up but the goal is "most compatible." Tested with FAT32, FAT16, FAT12 not supported but wouldn't be too hard to add.
I'm going be working on a cogdriver for this next as I think that's the next big speed bump at this point. Please test, break, comment, complain.
Comments
I have a P1 OS that uses Kye's SD code as a base and I will be converting/rewriting for a P2 OS soon.
Peter has also done SD routines for P2 in TAQOZ.
What do you need help with?
This is the current version's interface, modified 1.5fsrw for P1. This isn't something I'm able to develop right now, I was going to focus on implementing a serial driver to start. I was just hoping someone had something working or was working on something already.
The Touch.spin OS is largely built on your OS (I'm pretty sure) and Kye's SD would be amazing to have for the P2. The RAM and Touchscreen PASM cog is a modified version of your triblade RAM driver. Some beautiful code there..
I plan on porting the touch os to P2 but I've got quite a few things I need to do first. Getting the new PCB to work is step 1, but it's made me realize some of the tools I need to develop to make my life easier first. I just finished some work on Ymodem and wanted to start the P2 branch while things are fresh in my mind.
I thought I saw one of the C guru's working on a pure spin FSRW but I can't find the right thread. Thanks in advance!
I am still working on serial, but as @Cluso99 said in the source of the boot rom is the basics already there, pin config, init, SPI block access, even basic FAT32. That is what I would and will start with as soon as I finished my serial buffered in COG driver.
Because there is some common stuff with buffering and HUB transfers.
There are two reasons why @lonesock's code shines.
The first one is read ahead and write behind using a sector buffer in the COG. This does speed up block transfers quite nice.
The second one is that insane HUB/COG transfer @kuroneko helped to put in there.
I studied that source for hours, it is just beautiful.
So to get FSRW running one basic just need a PASM block driver for the SD, I think the whole init part is done in spin.
The Spin part should work with fastspin on P2 and another block driver.
But first I need to finalize my serial driver.
Enjoy!
Mike
I'll have to investigate the ROM code. I was hoping for a "drop in" replacement but I know it's still very early in the development lifetime and there's not a lot of existing code. Sector read and write are the functions used, not sure if char is ever used. It sounds like this might be a better starting point, although it's becoming obvious it's going to be a while before I have anything working.
Thanks again guys, at least I have some direction to go now.
Once working one can replace it thru some more extended thing like buffer in COG and read ahead write behind
That should be easy. Watch me. Famous words. No first the serial driver/
Enjoy!
Mike
*edit - Getting somewhere, if I compile with propeller tool the SD card mounts but when compiling with fastspin it never does.
* aedit - It looks like something's still not working right with the pure spin code. I'm going to keep digging to see what I can find.
For P1 sdspi.spin, expects: P2ES SD: Unless you are setting up your own MOD'ed SD plugin...
dgately
@dgately , yes I'm testing on the P1 before I even plug the P2 in. This is in attempt to create a codebase that works for P1 and P2. I'll keep in mind the pin numbering issue. I've already been trying to figure out what to do about sd testing. I'm really not happy with the way pins are shared with sd and flash. I'm also aware there's some issues with added capacitance on some of the pins to resolve boot issues.
@"Dave Hein"
This seems like a good place to start investigating for the P1. My last test suggests a timing issue since the regular spin code seems to function but the fastspin does not and returns a -41 read timeout. I thought the pure spin was hanging but maybe its just way slower than I'm willing to wait out.
I may be able to post P2 SD PASM code that will help as soon as I get the ROM changes done for the respin. Will just need to add back the write sector routine and you will have read/write sector, search DIR for a file, and read the files start sector and size, and load/run if you wish. You will need the extra functions to operate on the FAT32 though.
That might be enough to get me working. I'm still trying some basic diagnostics on SDSPI. I hope I just caught something in the read function. I'm thinking this should be a shift and or?
The spin test code finally finished. I'm not sure what these numbers mean but i'm guessing clock cycles?
I've tried both versions of the read code and both seem to work in spin? FastSpin gives -20 not fat16 volume.
Either version of the read code works, I should quit being lazy and hook up my logic analyzer. I tried adding in delays in the usual places, ie clock edges. I was hoping to get lucky on this one, guess not.
One of the best parts of fast spin is that one can include objects written in different languages, so why not FSRW in C?
Enjoy!
Mike
I tried a while ago to make it work under FastSpin and it didn't...
Think I'll try again...
This means you have to really understand the timing or you will get errors and nothing will work.
It works with Prop Tool on P1 and I'm pretty sure it'd work with FastSpin on a P1 too, but haven't tried that...
Well, it might -- as I mentioned I've seen some programs that when moved from PropTool/bstc/openspin to fastspin (on P1) need delays added, because the operations are happening so much faster in PASM than in bytecode. I don't know if that's the case here, but it's something to watch for. Of course P2 with its higher clock and faster instructions is even more sensitive to this kind of thing.
The P1 has minimal pipeline delay.
world is very different from the CMOS core, where capacitances are measured in fF (femto farads) - such slewing
also causes propagation delays, which are in time units, not clock cycles, so get worse at higher clock frequencies.
I've got the spin only FSRW working on the P1 using the regular compilers. But when I use fastspin to try to produce a P1 binary, there's an issue. I'll grab some LA caps today to try and figure things out better. I'm almost 100% sure it's just a timing issue but without seeing what the timing is now vs what it's supposed to be..
I want to get this working on the P1 so I have some "known good" condition to debug against. I'm expecting the P2's in/out delays to give me some grief. I hope I'm wrong.