Announcement

Collapse
No announcement yet.

Unable to Format uSD - 4DGL rescue

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Unable to Format uSD - 4DGL rescue

    Hi there,

    For some unknown reason, my uSD cards are becomming un-usable over time. I have put a lot of effort into reducing file write / erase cycles for the stored files on the uSD but they are still failing. I have a suspician that R26 PMMC may help, along with some new methods for handling uSD and I2C before and after a sys_Sleep().

    So anyway, I have 8 or 9 2GB uSD cards that Windows will refuse to format, RMPET won't recognise them either. What's the best method for a low-level, all '0' write to recover these cards. I read somewhere to write 0's to the first few sectors.., and I recall sample code ages ago, (however the forum will not let me search for 'uSD')

    Shall I just use a loop with Media_WriteByte(0) or do I need to worry about sector adressing?

    Ta
    Andy
    MicroLec Industries P/L
    www.intelligym.com.au

  • #2


    Something like the below should work. Windows seems to refuse to touch an SD card with CRC errors, doesn't even offer to try and write to them (like it does with bad sectors on a real disk). Hopefully you will be able to find the sector in error, it's usually near the start of the disk though.




    #platform "uLCD-32PT_GFX2"
    var sector[256] ;
    func
    main()
    var i ;



    media_Init();
    for (i := 0; i < 256; i++)

    sector[i] := 0 ;

    next
    for (i := 0; i < 200; i++)

    media_SetSector(0, i);
    media_WrSector(sector);
    next


    print("Done!") ;


    repeat
    forever
    endfunc





    Mark

    Comment


    • #3


      yeah I saw that in the other guys post about long write times. (by the way I get 1900 - 2100ms average on a Sandisk 2GB.. and strangely enough, I gave up waiting on a Kingston (more expensive) 2GB uSD, however the Kingston definately works in fat16 mode with the file_XXX functions in 4DGL...)

      After running that code windows was able to format, but my first attempt to copy infomration to the disk failed. THen following the failure windows was again unable to detect the card. Maybe the card is indeed stuffed... THe code has since worked on a couple of other cards..

      Should similar code using media_WriteByte(0) in a couple of nested loops work? because I tried that and kept getting "error 16" runtime error..

      Andy
      MicroLec Industries P/L
      www.intelligym.com.au

      Comment


      • #4


        media_WriteByte() should work just the same, although it would be slower. I'll get Dave to have a look



        Perhaps the failing uSD card has a CRC error further in and windows is doing something funny as soon as it hits it. Try writing over a few thousand sectors to see if that clears it up.
        Mark

        Comment


        • #5


          am doing exactly that... ;-) 2000 seems to work on 5 of the 6 cards I have tried..

          It doesn't take too long so I might even do more (10 000) just to be safe / future proof for data expansion.

          Thanks for the replies.

          Andy
          MicroLec Industries P/L
          www.intelligym.com.au

          Comment


          • #6


            Just a quick summary of the uSD card issue. The problem was initially thought to be over use of the same memory space (re using the same file always)
            To rectify I developed a date filename system that generated up to 240 or so files then deleted them all.. this did not fix the issue.
            Next theory that it was cheap uSD cards.. So I bought 'expensive' cards and they still failed.
            As of R26, by shutting things down before sleeping, then re initializing everything when waking, I have not had a problem with any uSD card but usually it takes about a month.. So time will tell.. I will load R27 pmmc and use it as a basis for my long term tests as well

            Andy
            MicroLec Industries P/L
            www.intelligym.com.au

            Comment

            Working...
            X