Shop OBEX P1 Docs P2 Docs Learn Events
Speeding up file access in FSRW — Parallax Forums

Speeding up file access in FSRW

CarlosFandangoCarlosFandango Posts: 67
edited 2008-10-05 05:16 in Propeller 1
Well I have been programming the prop for about three weeks now, and thanks to the help of the knowledgeable users of this forum and the brilliant OBEX, things are going well. I'm using Rockiki's excellent FSRW + sdspiqasm to interface to the SD card on the uOLED-96, and so far (with very little requirement for modification) this has solved all of my SD issues. However I have run into a problem, specifically the time it takes to find a file during popen(). The application I'm developing requires a large number of small files - hundreds in fact - on the card, and if the file I'm looking for is further up the FAT table it takes progressively longer to locate. The time delay thus incurred is now significant.

So I wondered if anyone has encountered the same problem and developed an asm version? That's a little unlikely I guess, but it's worth asking! Otherwise, I will have a go at reverse engineering the code and implementing an asm version of my own. To that end, I thought I saw a post somewhere on this forum with a link to some very useful information on SD card interfacing, but now I can't find it. If anyone knows where this link is, or has a good (that's to say, readily understandable) source of information on this subject, I would be very grateful.

-CF

Comments

  • BaggersBaggers Posts: 3,019
    edited 2008-10-03 11:16
    Carlos, I don't think it has been done, ( well none that have been mentioned, and that I know of anyway ).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    http://www.propgfx.co.uk/forum/·home of the PropGFX Lite

    ·
  • CarlosFandangoCarlosFandango Posts: 67
    edited 2008-10-03 11:57
    I had a feeling that this was probably the case. I can modify the existing code (I think - I'm still a proplearner) but it would really help if I could find a no-nonsense guide to the SD card format. I've downloaded the SD card spec from www.sdcard.org but boy that datasheet is complicated. It will take a while to wade through that - and things were going so well...! Sure I saw one somewhere...
  • BaggersBaggers Posts: 3,019
    edited 2008-10-03 12:39
    Andre' has one with his SD Max ( think that's what it's called ) plug in board for the Hydra, which apparently goes into depth on how to do a FAT16 file system.
    I've not got one, but I believe this is something that might help you.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    http://www.propgfx.co.uk/forum/·home of the PropGFX Lite

    ·
  • CarlosFandangoCarlosFandango Posts: 67
    edited 2008-10-03 12:59
    OK, thanks - do you have Andre's userid so I can ask? Or is that his ID? I suppose I should look!

    Also, I note in this thread (to which you responded)

    http://forums.parallax.com/showthread.php?p=711374

    there is a discussion on file seeking which I found very interesting. I think I need a fundemental change of direction; my small files are all individual characters making up a 65K color font for the OLED - you can't store these in memory, they're too big - so there are a lot of them for different font sizes. But implementing the file seek as discussed in this thread, I could compound all of my fonts into one large file (per font), store the block address of the file, and access it directly (and in a fairly random way). After making sure the font files are contiguous, anyway. That would make things blisteringly quick I believe - but I do have more windows programming to do now, which isn't as much fun as programming the prop shakehead.gif

    -CF
  • rokickirokicki Posts: 1,000
    edited 2008-10-04 00:04
    Can you flesh out a bit what you are doing? How many files, and what size are they?

    The best technique here might be a contiguous file approach and using lower-layer block I/O; if you
    put it in one file, and it's contiguous, then you can just do a simple block read to get random access.

    But I'd need to see more of the big picture before I can make any solid recommendations.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-10-04 01:00
    The sdspiFemto.spin routine in FemtoBasic is written in assembly and designed so it can be used for double buffering. The included low level Spin routines always wait for the I/O to complete before continuing, but the assembly routines can do multiple block I/O while the high level routines (in a separate cog) are busy doing something else. If you allocate your files contiguously, you can use the high level fsrw routines to look up a file name and provide the starting block number and block count, then do everything else with just the low level routines.
  • CarlosFandangoCarlosFandango Posts: 67
    edited 2008-10-04 06:18
    Rockicki said...
    Can you flesh out a bit what you are doing? How many files, and what size are they?

    Hi Rockicki... Well, at the moment there are about 120 files but if I were to continue down that path, I would end up with several hundred at least. They are font characters - images that are blitted to the OLED, so that I can do 65K color fonts, and are around 800-100 bytes each. W x H x 2 + 4-byte header actually. 0-9, A-Z, plus other characters, and of course multiple font sizes.
    Rockicki said...
    The best technique here might be a contiguous file approach and using lower-layer block I/O; if you
    put it in one file, and it's contiguous, then you can just do a simple block read to get random access.

    Yep, I've come to that conclusion already, so I'm in the middle of rewriting my VB.NET image encoder to stuff all of the characters for a given font in a single file with a lookup table in block 0. Then I'll reformat the card, and put all of the font files on the card FIRST....! Thanks to the help supplied by everyone on this forum and the various informative threads here, that will in fact be the first time I've had to remove the card from the OLED to put files on it - everything so far has been transferred over the comms link.
    Mike Green said...
    The sdspiFemto.spin routine in FemtoBasic is written in assembly and designed so it can be used for double buffering.

    Hi Mike. I have looked at these, and do have them downloaded here. I think that this would be a good solution, but the logic in these routines is quite complex (thereby leading to a more compact and undoubtedly more elegant solution). I don't really understand it, at least not yet. So if I needed to change anything for any reason I don't think I would be able to, not at the moment anyway. I'm a bit confused generally by the various flavors of basic on offer (although I understand the routines you mention would be usable without the basic interpreter). So I'm going to modify Rockiki's routines to provide a seek, which looks easy, and will revisit the sdspiFemto code when I have learned enough to cope with it! The app I'm working on has to function in less than two weeks smile.gif


    I have to say though that after lots of PIC and Atmel programming (am I allowed to say that?!) this little prop chip is amazing. I love it.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2008-10-04 18:38
    Data transfer can be sped up by rewriting the driver to support the 4 bit transfer mode. The problem with this is that the information to do this is getting increasingly difficult to find, and if you do find it, it is a proprietary protocol which requires establishing a liscencing agreeement to·legally use it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • CarlosFandangoCarlosFandango Posts: 67
    edited 2008-10-05 05:16
    Paul Baker said...
    Data transfer can be sped up by rewriting the driver to support the 4 bit transfer mode. The problem with this is that the information to do this is getting increasingly difficult to find, and if you do find it, it is a proprietary protocol which requires establishing a liscencing agreeement to legally use it.

    That sounds interesting, but somewhat awkward! Anyway, I seem to have solved this problem just by doing what others have already done. My screen updates are now so fast, I have to put delays between them to make it readable. I'm becoming increasingly surprised at how flexible this system is; I now have file support, comms, I2C and screen drivers all in place (largely pre-existing in the OBEX) and still have more than half of the HUB left for the actual application code. Good job! Can't wait to see how good the propII will be. And despite obvious shortcomings, the development environment is in my opinion more than adequate. I've also got a windows app built using the propellent dll that allows field firmware updates. Overall I think you guys (parallax AND the user base) have made a brilliant effort. Try getting this level of support from other manufacturers and see how far you get!
Sign In or Register to comment.