Shop OBEX P1 Docs P2 Docs Learn Events
Better than sliced bread! SD3.01 FAT16/32 Driver Updated! - Page 3 — Parallax Forums

Better than sliced bread! SD3.01 FAT16/32 Driver Updated!

13567

Comments

  • KyeKye Posts: 2,200
    edited 2011-01-15 20:48
    Yeah, the code won't crash on your now. Stuff can still go wrong since the errors aren't handled.

    Don't kill yourself on graphics. =)
  • timmehtimmeh Posts: 9
    edited 2011-02-21 04:52
    Hi Guys,

    I'm having problems getting even the demo to work. I'm using a stingray board with nothing but a micro SD card adapter attached to a breadboard. Voltages are good.

    Setup is as follows:
    CON
    
      _clkmode = xtal1 + pll16x
      _xinfreq = 5_000_000
    
      _leftChannelVolume = 32
      _rightChannelVolume = 32
    
      _baudRateSpeed = 57600        '250_000
      _newLineCharacter = 13
      _clearScreenCharacter = 16
      _homeCursorCharacter = 1
    
      _receiverPin = 31
      _transmitterPin = 30
    
      _RTC_DAT = -1 ' -1 ifnot installed.
      _RTC_CLK = -1 ' -1 ifnot installed.
    
      _VGA_Enabled = false
      _VGA_PinGroup = 2
      _VGA_H_Res = 160
      _VGA_V_Res = 120
      _VGA_BG_Color = bmp#black
      _VGA_FG_Color = bmp#green
    
      _leftChannelAudioPin = -1 ' -1 ifnot installed.
      _rightChannelAudioPin = -1 ' -1 ifnot installed.
    
      _leftMicFeedBackPin = -1 ' -1 ifnot installed.
      _leftMicInputPin = -1 ' -1 ifnot installed.
    
      _rightMicFeedBackPin = -1 ' -1 ifnot installed.
      _rightMicInputPin = -1 ' -1 ifnot installed.
    
      _SD_DO = 0
      _SD_CLK = 1
      _SD_DI = 2
      _SD_CS = 3
    
      _SD_WP = -1 ' -1 ifnot installed.
      _SD_CD = -1 ' -1 ifnot installed.
    

    I've tried with CD both enabled and disabled.

    All I get is 'Card not mounted', and when I type 'mount' or 'mount 0' I get 'Disk I/O error'. The microSD card is brand new and has been formatted for FAT32.

    This is the sum total of my experience with this so far, and would really like to know where I'm going wrong.
  • JLockeJLocke Posts: 354
    edited 2011-02-21 07:01
    Do you have pull-up resistors on the lines? I'm using 10-K to 3.3V; it makes a big difference!
  • KyeKye Posts: 2,200
    edited 2011-02-21 07:19
    Are you trying to connect through the I/O translators on the stringray board? You need to disable them and bypass them. (Requires soldering).

    Also, you may have also applied 5V to the 3.3v card and killed it.

    The stringray board is not designed to allow easy access to an SD card.
  • jazzedjazzed Posts: 11,803
    edited 2011-02-21 08:29
    Your 3.0v1.1 package fails to find my SDcard on pins 16-19.
    The 2.0v1.0 package finds SDcard but has serial port problems > 96MHz.

    When I release my product, there will be an on-line list of supported code and optional CD.
    I wouldn't normally care about this, but others do use your code. I prefer to see this working.
    CON
    
      _clkmode = xtal1 + pll16x
      _xinfreq = 5_000_000
    
      _leftChannelVolume = 32
      _rightChannelVolume = 32
    
      _baudRateSpeed = 115_200
      _newLineCharacter = 13
      _clearScreenCharacter = 16
      _homeCursorCharacter = 1
    
      _receiverPin = 31
      _transmitterPin = 30
    
      _RTC_DAT = 29 ' -1 ifnot installed.
      _RTC_CLK = 28 ' -1 ifnot installed.
    
      _VGA_Enabled = false
      _VGA_PinGroup = 2
      _VGA_H_Res = 160
      _VGA_V_Res = 120
      _VGA_BG_Color = bmp#black
      _VGA_FG_Color = bmp#green
    
      _leftChannelAudioPin = -1 ' -1 ifnot installed.
      _rightChannelAudioPin = -1 ' -1 ifnot installed.
    
      _leftMicFeedBackPin = -1 ' -1 ifnot installed.
      _leftMicInputPin = -1 ' -1 ifnot installed.
    
      _rightMicFeedBackPin = -1 ' -1 ifnot installed.
      _rightMicInputPin = -1 ' -1 ifnot installed.
    
      _SD_DO = 16
      _SD_CLK = 17
      _SD_DI = 18
      _SD_CS = 19
    
      _SD_WP = -1 ' -1 ifnot installed.
      _SD_CD = -1 ' -1 ifnot installed.
    
    
  • jazzedjazzed Posts: 11,803
    edited 2011-02-21 14:37
    If all else fails, reformat! Grr.
  • timmehtimmeh Posts: 9
    edited 2011-02-21 15:06
    JLocke wrote: »
    Do you have pull-up resistors on the lines? I'm using 10-K to 3.3V; it makes a big difference!

    Hi JLocke,

    I'm using the Parallax Micro SD adapter (#32312), which to my understanding has the 10K pull-up in it's design, so no.
  • timmehtimmeh Posts: 9
    edited 2011-02-21 15:10
    Kye,

    I am trying to connect via the translator pins. Didn't realise this was going to be an issue, but may also explain problems using the USB datalogger.

    I'm definitely using 3.3V, not the 5V feed, so this should be ok.

    Sounds like I need to take to the board with a soldering iron and some new headers. Thanks for the advice!
  • KyeKye Posts: 2,200
    edited 2011-02-21 20:02
    Jazzed - Are you following the electrical schematics? The block driver should work with or without pull ups. It drives the DI and CLK lines. Open drains the CS line and uses the DI line as an input. the SD card should have an internal pull up on the CS line for the open draining of the CS line to work.

    I've worked really hard to make the SD card driver work with alot of stuff. I do not believe it is a problem on my end.
  • jazzedjazzed Posts: 11,803
    edited 2011-02-21 20:11
    Kye wrote: »
    Jazzed - Are you following the electrical schematics? The block driver should work with or without pull ups. It drives the DI and CLK lines. Open drains the CS line and uses the DI line as an input. the SD card should have an internal pull up on the CS line for the open draining of the CS line to work.

    I've worked really hard to make the SD card driver work with alot of stuff. I do not believe it is a problem on my end.

    I reformatted the disk and it worked after that. I've never had an issue with sdcard hardware. I was very distracted because it worked perfectly with your SD2.0 stuff - except for the serial port weirdness.
  • KyeKye Posts: 2,200
    edited 2011-02-21 20:14
    Don't use the SD2.0 version. When it unmounts it corrupts the SD card FAT32 File System Info Sector - which is not critical or anything but, bad... (I was horrified when I found that error - the problem is that I pass the data in the place of the index into the functions that write to the SD block ... reversed the arguments).

    Yeah, the serial driver is flaky. It will be updated before Parallax Semi is up and out. Just ignore the bad characters for now.
  • timmehtimmeh Posts: 9
    edited 2011-02-22 05:43
    Thanks for the tip with the Stingray board Kye!

    I've soldered in a new set of headers for pins 16-23 and a bypass header. Plugged it all in, changed the pin numbers in the code and up she came, first try.

    Will have to keep this in mind for other components I need to add.

    Thanks again!
  • KyeKye Posts: 2,200
    edited 2011-02-22 07:13
    Good to see it worked!
  • jazzedjazzed Posts: 11,803
    edited 2011-04-25 18:46
    I find that one of my 2GB SDcards does not work with SD3.01. Works fine with Tom Rokkiki's FAT16 code. Reformatting does not help. It fails with File System Unsupported here:
        partition := (((partition <# 3) #> 0) << 4)
        case blockToByte(450 + partition)
          $4, $6, $B .. $C, $E, $14, $16, $1B .. $1C, $1E:
          other: abortError(MyErrorMessage)
    ' was File_System_Unsupported. added MyErrorMessage to errorStringAddress array for isolating failure.
    

    A 4GB SDcard works fine in the same Propeller board.
  • KyeKye Posts: 2,200
    edited 2011-04-25 21:37
    Tom's code checks alot less stuff. So, its pretty easy for it to work with his.

    I have every public code for FAT16/FAT32 file systems out there in the list in the code you posted. $4, $6, $B .. $C, $E, $14, $16, $1B .. $1C, $1E... those are all the FAT file system types to support. So, what has happened is that your SD card has a slightly corrupted MBR or it was formatted with something really weird.

    You can just disable that check. Its just a check to prevent bogus file systems from coming in.

    If you want to fix your SD card you'll need to rewrite the MBR on it. Windows won't do this for you easily. You have to use FDisk. Or force the disk to be completely corrupted so that windows will format everything on the disk.

    ---

    This is not a problem with the driver but expected behaviour. Be thankful I did not actually implement all of the checks and balances I found if other drivers I examined. I could have FILLED!!! the mount function with just endless amounts of sanity checks.

    But, instead I just left in the few I thought were necessary to catch serious errors. =)
  • jazzedjazzed Posts: 11,803
    edited 2011-04-25 23:00
    Thanks for that explanation. I can rest easier now. DOS chkdsk /F was no help.

    I was not suggesting the driver is bad, just that i could not use my 2G SD card.
    The surprises I see with SD card stuff is generally very annoying though.
  • potatoheadpotatohead Posts: 10,261
    edited 2011-04-25 23:07
    either fdisk /MBR, or... on a *nix, just use dd to write the whole thing to zeros.

    There is also this nice little utility!

    http://en.kioskea.net/download/download-127-hp-usb-disk-storage-format-tool

    (there may be newer versions around)
  • KyeKye Posts: 2,200
    edited 2011-04-26 07:39
    I understand its a little annyoning. But... I mean, its better to know that the SD card is courrpted before you start trying to plug it into another embeded system and wonder why it doesn't work.

    Comment out the sanity checks if ya want. ;)
  • Jorge PJorge P Posts: 385
    edited 2011-04-28 21:51
    Thanks Kye for the new SD3.01 Fat16/32 driver and demo code. I managed to remove the rtc and audio code in your demo, I also removed some spaces from the help string to free up some space and didn't actualy beak any code.

    I can't seem to remove the rtc calls from the SD3.01_FATEngine.spin without breaking some code. I dont want it removed totaly, I want it for referance when I make an attempt to use the DS1302 rtc instead so I am just commenting out various parts, Can the DS1307 code be completely removed/commented out from the engine? I am also going to try to find some string handeling functions to replace some commonly repeated words in the strings to try and free up some more space, maybee even read the help string from a file that resides on the sd-card.

    Since I have programming experiance in MS windows I have the mentality that I can use a type of .dll file with the propeller, is this possible? For instance having a wav driver as a dll/bin file on SD-media and only loading it in memory when I need to read or write a wav or just access a function from file. Would I need to do this in pasm only and keep it inder 2k???

    One last question, do you plan on implimenting any swap space in a future version?

    If you, or anyone else reading, have any links on the dll subject with the prop that would be great too but I guess I could do a search for that...

    Thanks in advance,
    Jorge P.
  • M. K. BorriM. K. Borri Posts: 279
    edited 2011-04-28 22:13
    Dude this is heroic! Thanks!!!
  • Heater.Heater. Posts: 21,230
    edited 2011-04-28 23:16
    Jorge P,

    Nothing like dll or dynamic libraries for the prop I'm afraid. However various people have come up with schemes for loading and running programs. Mini operating systems in fact.
    Then there are the "cogjects" by Dr_Acular. Load a PASM code to COG, run it, unload it, reuse the COG for another one...
    http://forums.parallax.com/showthread.php?130537-Cogjects-load-cog-code-from-SD-and-save-hub-ram&highlight=cogjects

    Then there is the overlay scheme by Cluso, load small bits of PASM into a COG from a running PASM program, run them, load another overlay...
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-04-28 23:29
    For instance having a wav driver as a dll/bin file on SD-media and only loading it in memory when I need to read or write a wav or just access a function from file. Would I need to do this in pasm only and keep it inder 2k???

    Yes as heater says we can do this with other code. There are 10 cogjects now - vga, keyboard, mouse, serial. Lots more to do though. And yes, these bits of code need to be kept under 2k.

    If you are running out of memory, you could take a look at Catalina - this can run C programs in external memory - up to many megabytes in size.
  • Jorge PJorge P Posts: 385
    edited 2011-04-28 23:34
    thanks hearter, your link, the visual text, is correct but when you hover over it, the forums forgot to add .com after http://forums.parallax so it is broken in that respect.....
  • KyeKye Posts: 2,200
    edited 2011-04-29 07:07
    Here's a version that supports the DS1302. Will be released offically later (it works already however).

    I have no plans to put anymore work in this driver unless I am paid todo so. Gotta keep moving on! (I've spent 2 years writing this driver for free).
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-04-29 07:18
    (I've spent 2 years writing this driver for free).

    Free software is very much appreciated. But occasionally, sometimes, people (like me) sometimes want to say thanks in a monetary way too. How would one do this?

    I was just thinking this having gone to sourceforge to download the latest catalina version, bearing in mind I have donated in the past to the author of catalina, and probably will do so again.

    Have you thought about putting all your brilliant software on somewhere like sourceforge, maybe with a "donate" button, and a link on the bottom of your posts?

    I can't promise rivers of gold or anything, but it may not be zero either?
  • KyeKye Posts: 2,200
    edited 2011-04-29 10:58
    Ha, something like this should be added to the obex. That would improve object quality.
  • Jorge PJorge P Posts: 385
    edited 2011-04-29 15:04
    Dr_Acula wrote: »
    Free software is very much appreciated. But occasionally, sometimes, people (like me) sometimes want to say thanks in a monetary way too. How would one do this?

    I know exactly how you feel, The link in my sig is my website, I enjoy writing software for Windows and have had that site for 5 years or more with free software kindly asking for donations. Over the entire 5 years, only one donation. I dont realy mind too much since the software I write is mainly for my own use but if i think others will benifit from it I release it for free. Support for my software requires a donation of atleast $1.

    as a developer, I agree with Kye to a certain extent.
    Ha, something like this should be added to the obex. That would improve object quality.

    Good code could require a certain cogject and most FTDI chips have unique ID's that cannot be changed, atleast I read that someplace. You would have to have something like that for better encryption mechanisms. But with certain encryptions, you canot export their code overseas to some countries.

    Just as well, you could create your own boards with some catchy features and make money that way. It just costs an initial investment of the proto's and initial production run.
  • william chanwilliam chan Posts: 1,326
    edited 2011-05-06 05:18
    Hi Kye,

    I don't quite understand why the FATEngine object has to be declared twice

    fat: "SD3.01_FATEngine.spin"
    taf: "SD3.01_FATEngine.spin"

    what is the rational behind this?
  • KyeKye Posts: 2,200
    edited 2011-05-06 09:08
    Each SPIN object include is its own contatiner with with own variables.Each version of my file system driver supports only one file open at a time. If you want to files open at a time you must include it twice. (Thus making two sets of variables to access the file system with).
  • Jorge PJorge P Posts: 385
    edited 2011-05-06 23:11
    If you want to files open at a time you must include it twice. (Thus making two sets of variables to access the file system with).

    I was wondering about that too, thank for the info Kye. BTW, The DS1302 code works great for me so far, I look forward to your final release of this.

    Are you planning on setting up a website to feature all your code and projects Kye? Put a donate link and I'd be glad to donate something for your ds1302 version.

    Thanks for your time with this...
Sign In or Register to comment.