Shop OBEX P1 Docs P2 Docs Learn Events
Crashing system leaves SD cards unable to be formatted — Parallax Forums

Crashing system leaves SD cards unable to be formatted

ElectricAyeElectricAye Posts: 4,561
edited 2008-09-25 02:12 in Propeller 1
I'm suffering from an onslaught of system crashes. In the past, I've always had to reformat my SD cards every time. Now my Windows XP tells me that "Windows can't reformat this disk." even though it can see the disk is there. My lovely Propeller-based system has now left two SD cards in this zombie-like state. I've shut everything down, restarted, tried various methods to safely shut down the disk, etc. Windows just refuses to deal with them anymore. Does this mean they are probably fried? Any suggestions on what to do next?


freaked.gif

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
It might be the Information Age but the Eon of Ignorance has yet to end.

Post Edited (ElectricAye) : 9/18/2008 3:41:02 PM GMT
«1

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-09-17 16:33
    The problem is likely with the Windows formatter. Unless you've burned out the SD card (very unlikely), it should be able to be formatted. You should look for some kind of 3rd party disk recovery program (try before you buy ... most may not work). If you know someone with Linux or MacOS, they may be able to reformat it.
  • Tim-MTim-M Posts: 522
    edited 2008-09-17 16:36
    Some digital camera can format SD cards too... could be another option to try.

    Tim
  • hippyhippy Posts: 1,981
    edited 2008-09-17 16:57
    I've had similar problems ( not through Propeller usage ) with CF cards and Linux has always been the saviour there.
  • rokickirokicki Posts: 1,000
    edited 2008-09-17 17:11
    Likely what's happened is the partition table has been destroyed. Windows is just being cautious.

    I (or someone) should write a formatter in Spin. There's probably a way to do it using the Disk Management tools in Administration Tools
    rather than the command-line formatter.

    When you say system crashes, do you mean Windows crashes, or Spin/Prop crashes? You shouldn't need to reformat your cards every time
    Windows crashes, nor every time the Prop crashes . . .
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-09-17 17:20
    If you don't have a Linux machine, you can still boot it from a "live" CD, such as Knoppix (a free download). Knoppix has rescued me from many a system crash by gaining access to system resources that Windows would not or could not.

    -Phil

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Still some PropSTICK Kit bare PCBs left!
  • SapiehaSapieha Posts: 2,964
    edited 2008-09-17 17:21
    Hi ElectricAye.

    I have some problem on format 2GB SD on my XP.
    After some research it was no problem in XP ..
    It wsa problem in Card reder/writer ...
    I buy new and it function perfectly

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nothing is impossible, there are only different degrees of difficulty.
    For every stuipid question there is atleast one inteligent answer
    If you dont ask you wont know
    If your gonna construct something, make it the simplest possible yet as versalite as posible


    Sapieha
  • ElectricAyeElectricAye Posts: 4,561
    edited 2008-09-17 17:57
    Thanks to all,
    I should have been better at describing what Windows XP says, it says it can not COMPLETE the formatting of the disk. I went and tried the disk anyway and so far it now seems to be working.... well, uh, until the system just crashed again.

    Rokicki, I should have said it is my Prop-based system that is crashing, not the Windows program. Heaven forbid a Windows product would ever crash! What would give you such silly ideas? ...As for having to reformat after every Prop crash, it seems my Spin program will get stuck if I don't. Is there something I should be doing to avoid that nuisance?

    Mike, I have a MacOS. So maybe I'll try that to see if I can clean up the SD cards.

    Thanks again,
    Mark
  • rokickirokicki Posts: 1,000
    edited 2008-09-17 20:07
    I think I may make the next release of fsrw have a "safe mode" that would simply forbid writing sector 0, since that seems to be the most common
    cause of problems, and in normal use you'd never write that sector.

    Needing to reformat your card after a spin crash should not happen, frankly.

    You might post the whole source code (if you are willing) just so we can have a few eyeballs glance over it for common errors.
  • AribaAriba Posts: 2,690
    edited 2008-09-17 20:33
    I also had to reformat the SD card many times when I was testing a code with many SD card accesses. I have the suspicion it had to do with Open a new file for write, without Closing the previous one (But how shoud I close it if the program crahes).
    Two or three times Windows was not able to reformat it, it does not found the SD card anymore.

    My solution was to overwrite sector 0 of the card with all Zeros. And I have done this with the WriteBlock method of the sdspi object!
    Then Windows found the SD card again.

    Andy
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2008-09-17 20:47
    Perhaps someone needs to come up with a Propeller Tool to write a bunch of 0's to the SD.
    I've noticed that you can break Windows pretty easy with a Prop when it comes to SD.

    OBC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    New to the Propeller?

    Getting started with a Propeller Protoboard?
    Check out: Introduction to the Proboard & Propeller Cookbook 1.4
    Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
    Got an SD card connected? - PropDOS
  • BradCBradC Posts: 2,601
    edited 2008-09-17 20:51
    Oldbitcollector said...
    Perhaps someone needs to come up with a Propeller Tool to write a bunch of 0's to the SD.
    I've noticed that you can break Windows pretty easy with a Prop when it comes to SD.

    OBC
    Why bother qualifying it with "with a Prop.." and so on.. Windows (particularly when it comes to any form of removable device) is a complete flake in any case, dating back to floppies!
    An overwrite of sector 0 is almost always a universal cure. Windows just can't cope with a malformed partition table or MBR.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Pull my finger!
  • rokickirokicki Posts: 1,000
    edited 2008-09-17 21:17
    If anyone can cause calls to fsrw to break a card, I need to know. This should not happen; fsrw is pretty careful;
    if you look at popen(), the first thing it does is call pclose(), so opening for write when there's an open file should
    not break anything. I have tested this stuff pretty intensively, and also it's in pretty wide-spread use without
    complaints, so if there's a failure mode we should find it and fix it.
  • ElectricAyeElectricAye Posts: 4,561
    edited 2008-09-17 21:58
    rokicki,
    I'm both thrilled and amazed by your enthusiasm for pursuing this problem. I'll be happy to post my horrible code that has messed up my two SD cards. I'm sure the fault lies with me and not with your venerable code. It will be a great embarrassment for me, exposing myself as a newbie fool, but I'll post everything just as soon as I get to my other computer. I'm on my Mac right now, and its disk utility failed to repair whatever happened to both SD cards. I just hope my code isn't so bad that it will cloud your efforts to find what might be wrong and how these SD cards got fouled up.

    The results of my attempt to repair one of the SD cards looks like this:

    Verify and Repair volume “BANR1”
    ** /dev/disk1s1
    ** Phase 1 - Preparing FAT
    ** Phase 2 - Checking Directories
    /80912135.CSV starts with cluster out of range (65535)
    Truncate? yes
    ** Phase 3 - Checking for Orphan Clusters
    Found orphan cluster(s)
    Fix? yes
    Marked 1 clusters as free
    1 files, 1973856 KiB free (61683 clusters)

    ***** FILE SYSTEM WAS MODIFIED *****

    My effort to verify the card gave me this:

    Verifying volume “BANR1”
    ** /dev/disk1s1
    ** Phase 1 - Preparing FAT
    ** Phase 2 - Checking Directories
    /80912135.CSV starts with cluster out of range (65535)
    Truncate? no
    ** Phase 3 - Checking for Orphan Clusters
    Found orphan cluster(s)
    Fix? no
    Found 1 orphaned clusters
    1 files, 1973824 KiB free (61682 clusters)
    Error: Filesystem verify or repair failed.
  • mirrormirror Posts: 322
    edited 2008-09-17 22:06
    I informed rokicki of this weakness in his code many months ago, but it is still there, so here is my solution:
    The original code in sdspiqasm:
       if_z jmp #pause
            cmp acca,#"B" wz
       if_z jmp #byteio
            mov ctr2,sector
            cmp acca,#"R" wz
       if_z jmp #rblock
    wblock
            mov starttime,cnt
            mov cmdo,#24
            rdlong cmdp,parptr2
            call #cmd
    

    In other words, if the command is not valid, then write some rubbish to a sector!
    The fixed code:
       if_z jmp #pause
            cmp acca,#"B" wz
       if_z jmp #byteio
            mov ctr2,sector
            cmp acca,#"R" wz
       if_z jmp #rblock
            cmp acca,#"W" wz     '<--- Add this line
      if_nz jmp #finished        '<--- Add this line
    wblock
            mov starttime,cnt
            mov cmdo,#24
            rdlong cmdp,parptr2
            call #cmd
    

    I have not trashed an·SD card·since adding these two lines!
    ·
  • ElectricAyeElectricAye Posts: 4,561
    edited 2008-09-17 22:13
    rokicki,
    here's the spin file of my monstrous code that has mess up my SD cards.· I apologize for the mess that it is.· I hope it helps in some way.

    thanks,
    Mark
  • rokickirokicki Posts: 1,000
    edited 2008-09-17 23:45
    Oooh, mirror, I completely forgot about that! EletricAye, try mirror's change and see if that eliminates the SD munging on
    crash for you.

    I have to get a new fsrw out the door . . .
  • Bob Lawrence (VE1RLL)Bob Lawrence (VE1RLL) Posts: 1,720
    edited 2008-09-18 00:08
    I've had luck with this SD formatting program in the past:

    ========================================================================================================================================================
    SD Memory Card Formatting Software
    Software Description
    This software formats SD Memory Card and SDHC Memory Card(SD/SDHC Memory Card) using a formatting program that complies with the SD Memory Card specification SD formatting provides quick and easy access to the SD Memory Card.

    Generally, SD/SDHC Memory Card file systems formatted with generic operating system formatting software do not comply with the SD Memory Card specification.
    ===========================================================================================================================================================

    You can download it here:

    panasonic.jp/support/global/cs/sd/download/sd_formatter.html

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Aka: CosmicBob
  • VIRANDVIRAND Posts: 656
    edited 2008-09-18 00:08
    hop.gifOh Oh! jumpin.gif

    How can we format the SD Card with the Propeller???

    Post Edited (VIRAND) : 9/18/2008 12:13:30 AM GMT
  • parskoparsko Posts: 501
    edited 2008-09-18 12:40
    Ariba said...
    My solution was to overwrite sector 0 of the card with all Zeros. And I have done this with the WriteBlock method of the sdspi object!
    Then Windows found the SD card again

    Oh thank you! I have a card sitting on my desk that has suffered this fate. I never knew the fix was so easy!

    This is a little gem of info!!!!

    Tom, yes, this would be a great addition to your SD routines. Simple and effective. Maybe call it the "recover" routine?

    -Parsko

    Post Edited (parsko) : 9/18/2008 2:54:55 PM GMT
  • ElectricAyeElectricAye Posts: 4,561
    edited 2008-09-18 13:53
    Ariba said...


    My solution was to overwrite sector 0 of the card with all Zeros. And I have done this with the WriteBlock method of the sdspi object!
    Then Windows found the SD card again.

    Andy

    Ariba, that's great. Would you mind posting the exact code you used for doing this? So far I've tried Norton Disk Doctor running on Windows XP, the MacOS disk utility program, and the plain ole Windows XP format task thing to try to fix these SD cards, but none of them has worked. I've tried to erase the SD cards but that doesn't work because it gives me "input/output error" or "CRC failure" when I try to do that.

    It's times like these I wish I really knew what I was doing.

    confused.gif
    Mark
  • ElectricAyeElectricAye Posts: 4,561
    edited 2008-09-18 15:41
    Actually, what I should be asking is: how do I direct the sdspi object to aim at sector 0 ?
  • SapiehaSapieha Posts: 2,964
    edited 2008-09-18 15:46
    Hi ElectricAye

    This is one fine program to edit pchsical sectors od al media
    WinHex 15.1

    And much more

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nothing is impossible, there are only different degrees of difficulty.
    For every stupid question there is at least one intelligent answer
    If you don't ask you wont know
    If your gonna construct something, make it·as simple as·possible yet as versatile as posible


    Sapieha
  • ElectricAyeElectricAye Posts: 4,561
    edited 2008-09-18 18:20
    Hi Sapieha,

    I'll take a look at WinHex and give it a try. At this point, I'll try anything. If I find I can't recover SD cards after a system crash with the Prop, I'm screwed. There would be no way to move on with the debugging process, unless I don't mind spending 10 bucks a pop.

    thanks,
    Mark

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    It might be the Information Age but the Eon of Ignorance has yet to end.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-09-18 18:36
    You could use the sdspiFemto object from FemtoBasic.

    You call "initSDcard" with the pin numbers for the various signals from the SD card, then call "writeSDcard"
    with the sector address, address of a 512 block to write, and byte count. If you use a byte count of 1, the
    rest of the block is padded with zeroes. That way, you only need to furnish the address of a single zero byte
    for the data to be written. Both routines return TRUE if successful, FALSE otherwise. Call "stopSDcard"
    before removing the SD card.

    Something like:
    CON
       _clkmode = xtal1 + pll16x
       _xinfreq = 5_000_000
    
    OBJ card : "sdspiFemto"
    
    VAR long control[noparse][[/noparse] 2 ]
    
    PUB main
       card.start(@control)
       IF card.initSDcard(8, 9, 10, 11)  {or whatever I/O pins are needed}
          card.writeSDcard(0, @result, 1)
          card.stopSDcard
       card.stop
    
  • ElectricAyeElectricAye Posts: 4,561
    edited 2008-09-18 18:57
    Thanks, Mike,
    I'll have a look at this FemtoBasic program. I've got two brand new SD cards ready to meet their maker if need be. Hopefully your Femto will save them from the burnt sacrificial altar of my horrible programming skills.

    cheers,
    Mark

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    It might be the Information Age but the Eon of Ignorance has yet to end.
  • SapiehaSapieha Posts: 2,964
    edited 2008-09-18 19:09
    Hi Mike Green..

    This was very useful for raw data write to SD.
    It is same for Read raw sectors ?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nothing is impossible, there are only different degrees of difficulty.
    For every stupid question there is at least one intelligent answer
    If you don't ask you wont know
    If your gonna construct something, make it·as simple as·possible yet as versatile as posible


    Sapieha
  • AribaAriba Posts: 2,690
    edited 2008-09-18 19:39
    This should work, but is untested because my SD card works fine at the moment [noparse];)[/noparse]
    {{ Clear Sector 0 of SDcard }}
    
    CON
       basepin = 0       '<-- set the right SD card Basepin here
       
    OBJ
       sdspi: "sdspiqasm"
    
    PUB main
       sdspi.start(basepin)
       bytefill($6000,0,512)
       sdspi.writeblock(0,$6000)
       repeat
    
    



    Not shure if this always helps, perhaps it was only the solution for my specific SD card malfunction.
    Good luck

    Andy
  • ElectricAyeElectricAye Posts: 4,561
    edited 2008-09-18 21:38
    Ariba, Ariba,
    thank you! thank you!

    And thanks to all who've given suggestions on fixing this problem. I'm away from my gadgetry at the moment, so I'll need some time before I can provide some feedback.

    cheers,
    Mark

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    It might be the Information Age but the Eon of Ignorance has yet to end.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-09-18 21:43
    Sapieha,
    Yes, there is a readSDcard routine as well that has the same parameters.
  • ElectricAyeElectricAye Posts: 4,561
    edited 2008-09-19 16:08
    CON
       _clkmode = xtal1 + pll16x
       _xinfreq = 5_000_000
    OBJ card : "sdspiFemto"
    debug    : "tv_text"
    VAR long control[noparse][[/noparse] 2 ]
    PUB main
    {Start up the TV output on pin 12...}
    debug.start(12)
    debug.str(string($01, "SD card recovery...", 13))
    card.start(@control)
    {SD card uses pins 0 thru 3}
    IF card.initSDcard(0, 1, 2, 3) {If card initializes...} 
         debug.str(string("Card initialized okay.", 13))
         card.writeSDcard(0, @result, 1)  {Fix the mess...}
         card.stopSDcard
         card.stop
    else
       debug.str(string("Card failed.", 13))
    repeat   
    
    


    Mike, I entered the above code based on your suggestion but I'm getting "Card failed."· Is there something I've left out?

    I tried Ariba's suggestion, too, but that didn't work either.·

    cry.gif·
Sign In or Register to comment.