P2 SD Driver V2.60 (pasm cog from spin2)
Cluso99
Posts: 18,069
P2 SD Driver V2.60
This is an SD Driver which resides in its' own cog and can be accessed via a 4 long mailbox in hub ram from either spin2 or pasm.
The current demo shows access from spin2 only. I have used Eric's FlexSpin to compile - I have not tried pnut or PropTool.
The hub mailbox is
The currently supported commands are
Please report any bugs here. Enjoy
This is an SD Driver which resides in its' own cog and can be accessed via a 4 long mailbox in hub ram from either spin2 or pasm.
The current demo shows access from spin2 only. I have used Eric's FlexSpin to compile - I have not tried pnut or PropTool.
The hub mailbox is
'' + sd_mailbox '\ [16] mailbox for SD Driver + '' + mbox_command byte 0 '| [1] command + '' + mbox_status byte 0 '| [1] status + '' + mbox_spare word 0 '| [2] -spare- + '' + mbox_bufad long 0 '| [4] address of disk buffer in hub + '' + mbox_sector long 0 '| [4] sector + '' + mbox_aux long 0 '/ [4] aux eg filesize +
The currently supported commands are
'' + "I" = Initialise SD Driver + '' + "R" = readFastSector + '' + "W" = writeFastSector + '' + "D" = find Directory + '' + "F" = find File + '' + "X" = Load/Execute (usually after "F") (see Warning) +WARNING: The "X" command will likely fail because it will likely overwrite hub code in use. Special care must be taken when using this command.
Please report any bugs here. Enjoy
Comments
btw, where's the file?
No multiblock read/write.
However the read and write spi routines have been extremely optimised by unravelling the bits sent within each byte, so it is as fast as is possible (4 instructions per bit), and then the 512 bytes are done with a rep instruction, all without smartpins. The CRCs are optimised even further to 2 instructions per bit since they are not used.
Should be about 3MB/s (30Mb/s). Of course, the SD card will have overheads.
I am going to defy anyone to improve upon this with bit-bashing
Here is an extract for 2 bits read And 2 bits write
I think you can use RCZL to get down to 3.5 instructions per bit.
I can read and flip and render a 640x480x8 bmp in under 100ms. There's a test there for you.
IIRC on P1 with the usual 1-instruction-per-bit read routine, the single block read time is roughly 50:50 between waiting and actual transfer. I don't remember if that measurement was on an A1 card or some ol 2GB crust flake though.
When did we get that instruction
Almost none of my P1 or P2 code could even utilise it. I don't read/write video files.