Shop OBEX P1 Docs P2 Docs Learn Events
Help needed - Fast(er) 4-Channel SD R/W Object — Parallax Forums

Help needed - Fast(er) 4-Channel SD R/W Object

MacTuxLinMacTuxLin Posts: 821
edited 2013-09-09 09:43 in Propeller 1
Over the last few months, I've managed to mastered Rhino3D (only to the level of what I planned to do) plus going through the pain of 3D printing (its still an ongoing pain once a while). Anyway, I have designed the casing for one of my old product, propeller-powered X4 duplicator. However, I am not happy with the speed at which it is duplicating. My code uses safe_spi_var.spin by Jonathan "lonesock" Dummer but not writing in a concurrent fashion. However, I just don't have the time to work on this as I'm working on other critical projects. So, I'm seeking help from the community. In return, I can offer to ship to you 1 unit of my Portable microSD X4 Duplicator plus 4 pcs of SanDisk 2GB microSD cards. On top of that, I'll throw in 5 pcs of P8X32A-Q44 if you could achieve this within a week.

[video=youtube_share;IO5nRekoPXc]

Ok, now on to my requirement. Basically:

1. The object will READ from the Master card & WRITE to the Target card(s) in sector-mode.
2. The object will need to know how many sectors there are in the Master card & write accordingly.
3. If each microSD uses 1 Cog, then the object must allow start & stop of unused target sockets.
4. The writing onto the Target cards should be done in parallel.
5. The maximum number of allowable cogs is 4 as my main code will need the other 4.
6. Maximum allowable main hub memory space is 3,072 long.
7. Object in PASM is preferable.

The connection between the prop & the microSDs are direct:
#0,   uSDMasDO, uSDMasCLK, uSDMasDI, uSDMasCS,{
  }     uSDTar1DO, uSDTar1CLK, uSDTar1DI, uSDTar1CS,{
  }     uSDTar2DO, uSDTar2CLK, uSDTar2DI, uSDTar2CS,{
  }     uSDTar3DO, uSDTar3CLK, uSDTar3DI, uSDTar3CS
Think, that's about it. Any questions & suggestions are welcome. PM me.

Thanks!

Comments

  • msrobotsmsrobots Posts: 3,709
    edited 2013-09-01 19:21
    Hi Ken,

    good to hear that you are busy...

    876 kB/s is about the fastest you can read a sd with save_spi in blockmode in PASM. (writing is faster).

    advanced tools of the RAISD-System (C - create array out of sd-1) loads a PASM BLOB doing exactly that.

    Even reading one card in block mode and writing the other three in blockmode parallel just in PASM without spin takes about 15 min/GB.

    4-pin sd-mode was very long classified (you needed to be member in the sd-card association) but is available now.

    BUT just works with checksum enabled. Not without checksum like spi allows you.

    and you need to create a checksum for each PIN (yes each bit has its own checksum).

    Somewhere here in this forum I read of someone trying? it and deciding that the time to create the checksums eat up the gain of the 4 pin transfer.

    We need a P2 board fitting into the RAISD-KIT ...

    Enjoy!

    Mike
  • MacTuxLinMacTuxLin Posts: 821
    edited 2013-09-02 17:00
    Hey Mike,

    Yeap, really appreciated your advices early this year & some of that did take roots, just so you know. I'm re-inventing my business & looking forward to make a dent in the market :lol:

    Thanks! I think I'd did tried on 2 cards late last year as well & guess that's the best for now. I'll might be able to lock myself up for 3 days somewhere end of next month to work on this...

    You're right. P2 might just be the much needed catalyst for RAISD-KIT. Let's keep this in the back-burner for now.

    Cheers!
  • lonesocklonesock Posts: 917
    edited 2013-09-02 19:24
    Interesting. For block copy you definitely don't want the overhead of the FSRW Spin-only code. One thing to note: doing an all-block copy will flag all blocks as written, and thus not reusable for the wear-leveling controller. I don't mind taking a look at this tomorrow, if nobody else jumps on it first. [8^)

    thanks,
    Jonathan
  • MacTuxLinMacTuxLin Posts: 821
    edited 2013-09-03 03:09
    Do I hear a taker?

    Hey Jonathan,
    If you do take this up, you can have the option of taking the current designed case which already has the 2 designed-in microSD pockets at the back or a cut-out slot for inserting your Prop-Plug, you'll just loose one pocket. Just let me know.

    Thanks

    Current.png
    BoardWithPropPLug.jpg
    550 x 383 - 180K
    498 x 282 - 50K
  • msrobotsmsrobots Posts: 3,709
    edited 2013-09-04 00:05
    @ Jonathan ... very very interesting
    One thing to note: doing an all-block copy will flag all blocks as written, and thus not reusable for the wear-leveling controller.

    so I we write all blocks once we can disable this "feature"?

    and may get rid of those unpredictable 'lag' hitting once in a while ?

    please explain more ...

    Enjoy!

    Mike
  • lonesocklonesock Posts: 917
    edited 2013-09-04 10:39
    I'm attaching the simplest possible copy procedure in Spin.

    Warning: this is very untested!! Also, there is no error checking going on.

    The actual SD controller has read-ahead and write-behind, so the speed should not be as bad as you fear. Can you test this and see if it does what you want...maybe add some timing?

    Mike: If you copied an entire blank SD card to another blank SD card, the newly copied card has had all blocks written. The wear leveling controller on the card is in trouble now, because it thinks it has to keep around all those copies of 0 blocks, even though the user may not have any interest in them. This _might_ get rid of the timing jitters, if there are no wear-leveling operations to perform, but it also means the life of the card is reduced.

    Jonathan
  • MacTuxLinMacTuxLin Posts: 821
    edited 2013-09-05 21:58
    Thanks Jonathan! I'll get right to testing this very shortly.

    Also, please PM me your address so I could pack & ship you your items.

    Cheers
  • MacTuxLinMacTuxLin Posts: 821
    edited 2013-09-09 03:01
    Just got some time to test but seems to have problem writing.
    CON
            _clkmode = xtal1 + pll16x                                               'Standard clock mode * crystal frequency = 80 MHz
            _xinfreq = 5_000_000
    
    
            ' Pin definitions
            #0,   uSDMasDO, uSDMasCLK, uSDMasDI, uSDMasCS,{
      }     uSDTar1DO, uSDTar1CLK, uSDTar1DI, uSDTar1CS,{
      }     uSDTar2DO, uSDTar2CLK, uSDTar2DI, uSDTar2CS,{
      }     uSDTar3DO, uSDTar3CLK, uSDTar3DI, uSDTar3CS
    
    
    VAR
      long  buf[512/4] ' a long-aligned block of 512-bytes (SD size)
       
    OBJ
      sd[1+3]       : "safe_spi_2_7"                        ' using VAR to get 4 copies in 4 cogs
      DBG   : "FullDuplexSerialExt.spin"
      
    
    
    PUB Demo
      DIRA[24..25]~~
      OUTA[24..25]~
    
    
      DBG.Start(31, 30, 0, 115_200)
      waitcnt(cnt + clkfreq)
      DBG.Tx(0)
      DBG.Str(String("--- Test Dupping ---",13,13))
      
      'do_copy( (64 << 20) / 512 ) ' copy 64MB
      do_copy( 2 )  'sector(s)
    
    
    
    
      DBG.Str(String("--- Dupping Completed ---",13,13))
    
    
      repeat
        !OUTA[24..25]
        waitcnt(cnt + clkfreq/5)
    
    
    PUB do_copy( N_blocks_of_512 ) : i
    
    
      DBG.Str(String("Inside do_copy",13))
       
    
    
      ' read from object 0
      sd.start( uSDMasDO )
      DBG.Str(String("Reader Started...",13)) 
      
      ' write to objects 1-3
      sd[1].start( uSDTar1DO )
      DBG.Str(String("Writer Started...",13))
      
      'sd[2].start( uSDTar2DO )
      'sd[3].start( uSDTar3DO )
    
    
      ' do the copy
      repeat i from 0 to N_blocks_of_512-1
        sd.readblock( i, @buf )
        DBG.Str(String("Block Read...",13))
        
        sd[1].writeblock( i, @buf )
        DBG.Str(String("Block Wrote...",13))
        
        'sd[2].writeblock( i, @buf )
        'sd[3].writeblock( i, @buf )
      
      ' done
      repeat i from 0 to 1 '3
        sd[i].stop
    
    
    


    PST Showed
    --- Test Dupping ---
    
    
    Inside do_copy
    Reader Started...
    Writer Started...
    Block Read...
    

    Tried 3 different uSD cards but result was the same. Any ideas?
  • lonesocklonesock Posts: 917
    edited 2013-09-09 07:52
    I'll look at it later tonight. The first thing I would do is print the return value on all start operations:
    retval := \sd.start( uSDMasDO )
    
    And on the readblock and writeblock commands:
    retval := \sd.readblock( i, @buf )
    
    I don't have any boards with multiple SD slots up and running at the moment, or I would love to test this.

    sorry,
    Jonathan
  • MacTuxLinMacTuxLin Posts: 821
    edited 2013-09-09 08:53
    Thanks Jonathan.

    The result seems right.
    --- Test Dupping ---
    
    
    Inside do_copy
    Reader Start: 2
    Writer Started: 2
    Block Read: 0
    

    And, I'd like to make good my offer so I just PMed you about delivering those items to you. Don't worry, I'm a good guy :smile:.
  • lonesocklonesock Posts: 917
    edited 2013-09-09 09:43
    Heh, I'm not worried about you being a good guy! It's just that I don't think the 10 minutes I've spent on this warrant any kind of payment. [8^)

    Jonathan
Sign In or Register to comment.