Ok All the SD card guru's
James Long
Posts: 1,181
While I've been starting a business to build the boards, all of you guys have gotten so far ahead of me, I'm lost.
I have a simple question, and want to make sure I have this right.
I want to read the directory of a SD card.
I really have no clue as to how to perform the task. I have looked at fsrw and friends, theSD Trainer, etc.
I can read a file, and write a file. I have figured that out. But when I run the sdrw test, I get nothing on the dir:
Is there a way to list file names one at a time? (like progressing to the next file name with an input?)
Any help?
James L
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
James L
Partner/Designer
Lil Brother SMT Assembly Services
Post Edited (James Long) : 4/7/2009 6:41:17 AM GMT
I have a simple question, and want to make sure I have this right.
I want to read the directory of a SD card.
I really have no clue as to how to perform the task. I have looked at fsrw and friends, theSD Trainer, etc.
I can read a file, and write a file. I have figured that out. But when I run the sdrw test, I get nothing on the dir:
Is there a way to list file names one at a time? (like progressing to the next file name with an input?)
Any help?
James L
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
James L
Partner/Designer
Lil Brother SMT Assembly Services
Post Edited (James Long) : 4/7/2009 6:41:17 AM GMT
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:
· Home of the MultiBladeProps: TriBladeProp, SixBladeProp, website (Multiple propeller pcbs)
· Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
· Prop Tools under Development or Completed (Index)
· Emulators: Micros eg Altair, and Terminals eg VT100 (Index)
· Search the Propeller forums (via Google)
My cruising website is: ·www.bluemagic.biz·· MultiBladeProp is: www.bluemagic.biz/cluso.htm
Note that most (but not all) SD cards have a partition table and they don't always put the volume in the same place. A few don't have a partition table and the first sector of the SD is the bios parameter block. FSRW checks for the latter case by looking for the "FAT16" string in sector 0 before trying to read it as a master boot record.
You da man!
OBTW multiple open files too.
Post Edited (Bill Drummond) : 4/7/2009 5:59:15 PM GMT
makes it too easy to trash the card. FSRW was intended as a small, simple, but reliable way to read and write SD cards.
I have not added new features primarily due to lack of time, and I am excited to see others take up the torch. With the new
Spin compilers and conditional compilation, it should be possible to build a new fsrw with much more functionality, while not
penalizing those who don't need that additional functionality.
For bonus points, speaking of trashing the SD, would anybody be interested in format/fdisk? It is a real pain to do anything to the MBR, and thus the partition table, in Windows, but quite easy LOL with the SD block driver.
Thanks for all the response to my question/issue.
I know have a few different methods to "borrow" from to get what I need.
I hate to say, but programming is not my strong suit. I am a decent designer, good assembler, but come up short in the programming arena. I pretty good with the Basic Stamp, but never totally gotten my head around the Prop. I figure mainly because i haven't dedicated enough time to actual programming.
I have a project that need to be totally programmed, so the practice is coming.
I'll report back my other problems as they arise. I know I will have more.
James L
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
James L
Partner/Designer
Lil Brother SMT Assembly Services
I am reading a 1MB block to load into my SRAM on my TriBladeProp. I have an 8KB hub buffer. Since my hardware lacks enough pins I share DI/DO on the SD card with the A0/A1 on the SRAM. I had to modify the close routine in sdspiFemto to do this - see the PropCMD thread (OBC was going to update SD_Trainer in OBEX).
Initially I had to open and re-read all 8KB blocks to fine where I was up to to get the next block. So loading took about 7 minutes. I have found that the SD card next sector is available in ioControl[noparse][[/noparse]0] after the read call and so if you initially open the file and read 1 byte, ioControl[noparse][[/noparse]0] will have the next sector in it. So subtract 1 and you have the start sector. Now read using the readSDCard command. I KNOW I have 16KB clusters and the file is CONTIGUOUS. I have not yet found where the cluster size is kept. For anyone interested, this top level code is within the ZiCog code I posted on that thread last night (zicog006_demo_rr050.spin).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:
· Home of the MultiBladeProps: TriBladeProp, SixBladeProp, website (Multiple propeller pcbs)
· Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
· Prop Tools under Development or Completed (Index)
· Emulators: Micros eg Altair, and Terminals eg VT100 (Index)
· Search the Propeller forums (via Google)
My cruising website is: ·www.bluemagic.biz·· MultiBladeProp is: www.bluemagic.biz/cluso.htm
http://home.teleport.com/~brainy/fat16.htm
If you look at the fsrw source you'll see that the mount command starts by loading sector 0 and checking for the "FAT16" sig at offset $36, then if it doesn't find it does some magic and loads a different sector from the long at sector 0 offset $1C6 (the pointer to the start of the volume for the first of four partitions in a MBR partition table) then in THAT sector checks for "FAT16." Once it's happy "FAT16" is there one way or the other we know it's the boot record or sector 0 of the mounted volume. Within the boot record, offset $0D is a byte giving the number of 512 byte sectors in a cluster. There's a lot of other good info in there too, it pretty much describes the whole volume structure.
I realized today that the SPIN command pretty much requires sectors to be contiguous on disk, since it depens on PASM cog code to load the RAM and it can't possibly be aware of the FAT, and if the cluster size is < 64KB that is an extremely dangerous assumption, particularly if you wrote the .bin from another system -- NO dos file system ever guarantees this even though it's considered a good strategy in some CS circles. PropCMD 2.0 will be aware of this and will check for contiguous clusters and abort smartly if things aren't right. I may even have room for a utility to contiguify a file that's been split, but I keep thinking of neat stuff to do and PropCMD 1.0 takes half the hub RAM as it is, so we'll see.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:
· Home of the MultiBladeProps: TriBladeProp, SixBladeProp, website (Multiple propeller pcbs)
· Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
· Prop Tools under Development or Completed (Index)
· Emulators: Micros eg Altair, and Terminals eg VT100 (Index)
· Search the Propeller forums (via Google)
My cruising website is: ·www.bluemagic.biz·· MultiBladeProp is: www.bluemagic.biz/cluso.htm
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Need to make your prop design easier or secure? Get a PropMod has crystal, eeprom, and programing header in a 40 pin dip 0.7" pitch module with uSD reader, and RTC options.