Shop OBEX P1 Docs P2 Docs Learn Events
Secure digital read/write code released - Page 3 — Parallax Forums

Secure digital read/write code released

13»

Comments

  • Goran (Sweden)Goran (Sweden) Posts: 68
    edited 2007-02-20 07:03
    Parsko

    Are shure you go to pick RUN and then enter "compmgmt.msc" for formatting in WXP.

    I missed that in my start with the SDcard routines. I tried the format which is found in the explorer and that one dont give you the choice to change the sector size.

    I also made the mistake to try with some MMC cards, which is the predessesors to the Secure Digital cards.

    Are you shure the 16 Mb card mentioned earlier is a SD and not a MMC?

    FYI I have used 22K as pullup all the time, No problem

    Regards Goran
  • Ferret7Ferret7 Posts: 4
    edited 2007-02-21 02:45
    Hi All,
    Here is the error handler I put together for use with the fsrw_speed.spin
    I got both the SD Flash Media Card and the Micro SD working just fine.

    -jay-

    -=-
    PUB main | x
    Num.Init
    x := \start
    ErrorTrap( x )
    -=-


    -=-
    PUB ErrorTrap( ErrNum )
    ' Error Handler/Trap reporting
    '
    term.str( string( "ERROR " ) )
    term.dec( ErrNum )
    term.str( string( " : " ) )
    '
    IF( ErrNum =< -21 )
    IF( ErrNum == -21 )
    term.str( string( "bad bytes per sector" ) )
    ELSEIF( ErrNum == -22 )
    term.str( string( "bad sectors per cluster" ) )
    ELSEIF( ErrNum == -23 )
    term.str( string( "not two FATs" ) )
    ELSEIF( ErrNum == -24 )
    term.str( string( "bad FAT signature" ) )
    ELSEIF( ErrNum == -25 )
    term.str( string( "too many clusters" ) )
    ELSEIF( ErrNum == -26 )
    term.str( string( "bad cluster number" ) )
    ELSEIF( ErrNum == -27 )
    term.str( string( "not open for writing" ) )
    ELSEIF( ErrNum == -28 )
    term.str( string( "???" ) )
    ELSEIF( ErrNum == -29 )
    term.str( string( "???" ) )
    ELSEIF( ErrNum == -30 )
    term.str( string( "???" ) )
    ELSEIF( ErrNum == -86 )
    term.str( string( "metadata event updated - conditionally" ) )
    ELSEIF( ErrNum =< -11 )
    IF( ErrNum == -11 )
    term.str( string( "???" ) )
    ELSEIF( ErrNum == -12 )
    term.str( string( "???" ) )
    ELSEIF( ErrNum == -13 )
    term.str( string( "SD card removed from socket" ) )
    ELSEIF( ErrNum == -14 )
    term.str( string( "???" ) )
    ELSEIF( ErrNum == -15 )
    term.str( string( "???" ) )
    ELSEIF( ErrNum == -16 )
    term.str( string( "???" ) )
    ELSEIF( ErrNum == -17 )
    term.str( string( "???" ) )
    ELSEIF( ErrNum == -18 )
    term.str( string( "???" ) )
    ELSEIF( ErrNum == -19 )
    term.str( string( "???" ) )
    ELSEIF( ErrNum == -20 )
    term.str( string( "not a fat16 volume" ) )
    ELSEIF( ErrNum =< -1 )
    IF( ErrNum == -1 )
    term.str( string( "???" ) )
    ELSEIF( ErrNum == -2 )
    term.str( string( "no empty directory entry" ) )
    ELSEIF( ErrNum == -3 )
    term.str( string( "bad argument" ) )
    ELSEIF( ErrNum == -4 )
    term.str( string( "???" ) )
    ELSEIF( ErrNum == -5 )
    term.str( string( "???" ) )
    ELSEIF( ErrNum == -6 )
    term.str( string( "no permission to write" ) )
    ELSEIF( ErrNum == -7 )
    term.str( string( "EOF repeat while following chain" ) )
    ELSEIF( ErrNum == -8 )
    term.str( string( "???" ) )
    ELSEIF( ErrNum == -9 )
    term.str( string( "bad cluster value" ) )
    ELSEIF( ErrNum == -10 )
    term.str( string( "???" ) )
    ELSE
    IF( ErrNum == 0 )
    term.str( string( "test completed with no errors." ) )
    ELSE
    term.str( string( "unknown error ???" ) )

    term.out( 13 )
    return
    -=-
    1600 x 1200 - 154K
  • El PaisaEl Paisa Posts: 375
    edited 2007-02-25 16:44
    Recently I got a SD/MMC Breakout card from Spark Fun Electronics.
    The· pin outs od this card does not agreed with pinouts shown above.
    Could anyone please show me how to connect this Breakout card to the demo board?
    115 x 89 - 3K
  • Mike CookMike Cook Posts: 829
    edited 2007-02-25 17:02
    SparkFun SD pinout posted here:

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

    for convenience.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Mike
  • CyberboundCyberbound Posts: 8
    edited 2007-03-09 17:01
    Okay, I just got my Spark Fun SD/MMC Breakout card yesterday. I've added the "Propeller Accessories Kit" (VGA, mouse and keyboard) to my Protoboard. No TV out though. How do I make this work using VGA? Has anyone modified the SD card code for VGA yet or is everyone with an SD card using a TV for output using a demo board?
  • rokickirokicki Posts: 1,000
    edited 2007-03-09 18:27
    To my knowledge there should be no conflict between the SD card and the VGA (at least, on the protoboard or the demo board).
    Why do you think there's a conflict?
  • Mike GreenMike Green Posts: 23,101
    edited 2007-03-09 18:44
    Cyberbound,
    FemtoBasic will work with either a TV display or a VGA display and uses the SD card code. There's a precompiled version in the posted archive (http://forums.parallax.com/showthread.php?p=634092) for VGA. The Demo Board version uses pins 0-3 for the SD card. The Protoboard version uses pins 8-11. Otherwise they're the same. You can also read and write to the extra 32K of EEPROM.
  • CyberboundCyberbound Posts: 8
    edited 2007-03-09 20:02
    rokicki, no... I didn't say there was a conflict.· I just wasn't finding any example code that used VGA.· Sorry if there was any confusion.· I'm just looking for the simplest way to implement reading and writing to the SD card using spin on my proto board. Thanks again for your efforts on this.· Adding an SD card to the prop is one of the reasons I moved to the prop in the first place.··smilewinkgrin.gif
    rokicki said...
    To my knowledge there should be no conflict between the SD card and the VGA (at least, on the protoboard or the demo board).
    Why do you think there's a conflict?
  • CyberboundCyberbound Posts: 8
    edited 2007-03-09 20:05
    Mike, I have to admit I haven't touched FemtoBasic yet.· I'll have to take a look.· THANKS!
    Mike Green said...
    Cyberbound,
    FemtoBasic will work with either a TV display or a VGA display and uses the SD card code. There's a precompiled version in the posted archive (http://forums.parallax.com/showthread.php?p=634092) for VGA. The Demo Board version uses pins 0-3 for the SD card. The Protoboard version uses pins 8-11. Otherwise they're the same. You can also read and write to the extra 32K of EEPROM.
  • T ChapT Chap Posts: 4,223
    edited 2007-03-09 22:54
    I have started an Eagle library for a Digikey part number HR845CT-ND cut tape $4.97 no min. It is a pricey part in small quantities, but I spent a half an hour and still couldn't locate a PCB layout for the mouser part mentioned in this thread.

    The part I found is SMT but would be easy to hand solder. Are the switches used at all for card detect and lock? I didn't think so, so I left out the connections, but the pads are there. It would be a neat feature in code where when the card is inserted, the Prop could do something when inserted, like auto-update the software etc.

    Below is the library and some pics. I need to proof this further.


    www.hirose.co.jp/cataloge_hp/e60900048.pdf

    Post Edited (originator) : 3/9/2007 11:00:17 PM GMT
    563 x 594 - 23K
    700 x 433 - 49K
  • Mike CookMike Cook Posts: 829
    edited 2007-03-09 23:36
    Here's the Alps data sheet for the·Mouser SD Socket. May not be a current inventory item for Alps since I could not find it on their web site. It's also on order according to www.mouser.com inventory status.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Mike
  • RobotWorkshopRobotWorkshop Posts: 2,307
    edited 2007-05-02 21:45
    Almost all the posts i've read about using the SD cards with the propeller seem to focus on the regular size SD cards. Has anyone used the Micro SD cards directly with the Propeller and FemtoBASIC? In particular SparkFun has their MicroSD adapters with the following signals:

    CS
    DI
    VCC
    SCK
    GND
    DO
    CD

    It appears that all the lines (CS, DI, SCK, DO, and CD) should have pull-ups to 3.3v The remaining connections would be:

    P0 - DO
    P1 - CLK
    P2 - DI
    P3 - CS
    GND - gound
    VCC - 3.3v

    Does that look right?

    Robert
  • Mike GreenMike Green Posts: 23,101
    edited 2007-05-02 22:24
    Robert,
    I've bought one of the MicroSD adapters and a Micro SD card, but haven't hooked it up yet. Tomas indicated that he has gotten SD cards to work without the pullups, but I plan to use them anyway. Your connections are the ones I'm going to use myself. It should work fine.
  • rokickirokicki Posts: 1,000
    edited 2007-05-02 22:26
    Yes, I've also tried microSD cards with a physical microSD->SD adaptor (which contains just wires, no components) and they worked
    great for me.

    Your connections look good. You should have no trouble.
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2007-05-03 01:07
    I was able to connect my own SD cards using my "Junkshop Floppy" interface without the pullups. I've ordered some of those microSD adapters with the idea of soldering some pins directly to the adapter and using microSD cards.

    Oldbitcollector

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The comments and code above are proof that a million monkeys with a million propeller chips *could* write Shakespeare!
  • OwenOwen Posts: 100
    edited 2007-05-05 02:13
    can anyone explain to me how to use the "brwlong(w, v)" methode for writing longs to the sd card. Sorry for the beginer question but i'm not realy sure what i'm suposed to pass to the method as "w" and "v" ? anyone have a quick example or explanation of writing longs to the sd card? thanks!

    Owen
  • rokickirokicki Posts: 1,000
    edited 2007-05-05 20:02
    Don't call those routines. (Are they even public? They shouldn't be.) Call only these routines:

    pub mount(basepin) 
    pub pflush
    pub pclose
    pub popen(s, mode) 
    pub pread(ubuf, count)
    pub pgetc 
    pub pwrite(ubuf, count)
    pub pputc(c)
    pub opendir 
    pub nextfile(fbuf) 
    
    



    To write a long you can use

    pwrite(@var, 4)

    This writes the long as four bytes in "native" order (whatever order it is
    stored at in the propeller itself).
  • edlikestoboogieedlikestoboogie Posts: 71
    edited 2007-07-04 22:20
    if i use 22k resistors instead of 20k.. is that okay?
  • Mike GreenMike Green Posts: 23,101
    edited 2007-07-04 22:44
    Anything over a wide range will probably work (say 4.7K to 47K or more). I use 10K on my SD sockets.
  • giannissamgiannissam Posts: 22
    edited 2008-08-03 01:59
    hi all.
    i followed the instructions and tried to make this work on a breadboard.
    I keep geting the message

    Mounting.
    Returned from start
    -13

    what is this error code?
  • giannissamgiannissam Posts: 22
    edited 2008-08-03 02:10
    got it...
    sd not connected
  • KlapKlap Posts: 65
    edited 2009-04-02 08:24
    I just wanted to say thank you to rokicki. This code that you have created is amazing. I have been using it to create a number of applications. See thread:

    http://forums.parallax.com/forums/default.aspx?f=25&m=339479

    Keep up the good coding.

    Just wondering, is there any way to update the date on the files manually? I saw an application that used a clock DIP connected to the Propeller to do it but I was wondering if there was a way around that.
  • mikedivmikediv Posts: 825
    edited 2009-12-27 00:17
    giannissam that's funny I keep getting Mounting returned from start -20 can anyone tell me what that means?
  • LeonLeon Posts: 7,620
    edited 2009-12-27 00:58
    edlikestoboogie said...
    if i use 22k resistors instead of 20k.. is that okay?

    Pullups shouldn't be necessary.

    Leon

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Amateur radio callsign: G1HSM
  • Luis DigitalLuis Digital Posts: 371
    edited 2010-01-15 23:10
    Hello all,

    I am a new user and have successfully tested this code.

    I used my camera card (full of photos) with good results: AData 2GB SD (FAT16)

    I also tried another card, but did not work. It is those selling on eBay from China/HK:
    SanDisk micro-SD 8GB SD-HC (FAT32)

    Someone else has tried with a card like that?

    Thanks.
  • rokickirokicki Posts: 1,000
    edited 2010-01-15 23:42
    Howdy!

    The old code you have does not support FAT32 nor SDHC.

    The new code does:

    http://forums.parallax.com/forums/default.aspx?f=25&m=368563

    It should be pretty close to a drop-in replacement.
  • Luis DigitalLuis Digital Posts: 371
    edited 2010-01-16 01:47
    Hello rokicki,

    I think I'm using the latest version fsrw26.

    I used the program serial_terminal.spin

    The result:
    mount [noparse][[/noparse]ENTER]
    mount returned

    And the program stops working (until reset again the Propeller).
  • Luis DigitalLuis Digital Posts: 371
    edited 2010-01-30 19:00
    I discovered the problem: head and sectors with wrong values.

    Apparently the reader (microSD-USB) often corrupt values, but the computer reads the memory without problems.
    TestDisk was very helpful.

    I hope this report serves to improve the code.

    Thank you.
Sign In or Register to comment.