View previous topic :: View next topic |
Author |
Message |
jecottrell
Joined: 16 Jan 2005 Posts: 559 Location: Tucson, AZ
|
Formatting SD/MMC Cards |
Posted: Tue Sep 04, 2007 7:57 am |
|
|
Hello All,
I'm having problems with some FAT32 code and I remember there being an odd requirement for formatting cards. I recall having to do it through the command line. I have searched CCS forums without luck. Can anyone offer any help?
Thanks,
John |
|
|
icesynth
Joined: 03 Sep 2007 Posts: 32 Location: Edmonton, Alberta
|
|
Posted: Tue Sep 04, 2007 8:29 am |
|
|
Are you trying to format the card on the PC or from your device? I'm assuming from the PC, Linux or Windows?
For windows:
Code: | format X: /FS:FAT32 |
Where X is the drive letter of your SD card.
Works for my library _________________ Programming for the the real world.
--Chris Burchett
Sylver Technologies Inc. |
|
|
jecottrell
Joined: 16 Jan 2005 Posts: 559 Location: Tucson, AZ
|
|
Posted: Tue Sep 04, 2007 9:40 am |
|
|
Thanks, I had found the MS KB article on command line formatting. But, I think I remember having to set the sectors or something? No?
Thanks,
John |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Tue Sep 04, 2007 10:25 am |
|
|
You do not need to do anything special to format these under windows. You can format it from the windows GUI - the default mode is FAT32. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
Pret
Joined: 18 Jul 2006 Posts: 92 Location: Iasi, Romania
|
|
Posted: Wed Sep 05, 2007 12:30 am |
|
|
Depends on your FAT32 implementation. Most of PIC codes can handle only one sector per cluster. You must add the /A:512 to the format command line. |
|
|
dreamit Guest
|
|
Posted: Mon Sep 17, 2007 12:23 pm |
|
|
hi
i would like to know if someone can help me with a tiny problem. i trying to read\write to pre-formatted fat32 -512block- 512MB MMC in SPI mode. I have no problem in initializing the MMC, but when i want to read the first sector of the flash i get somewhere in the reading "Invalid partition table Error loading operating system Missing operating system". first i thought the card was not well formatted, but when i put it in the card reader windows can read\write files and folders.
Anyone here might know what this is all about? |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Mon Sep 17, 2007 5:06 pm |
|
|
The first physical sector of your card is not the same as the first logical sector of the FAT32 file system. The message you are quoting is from the Master Boot Record (MBR), which has pointers to one or more partition tables which finally lead to your FAT32 directory.
Quiet complex, try reading http://en.wikipedia.org/wiki/Master_boot_record
For your dedicated system there might be easier ways to find the start of your files but I've never tried those. |
|
|
Guest
|
|
Posted: Wed Sep 19, 2007 2:13 pm |
|
|
thanks you for your reply, i understand now that i'm not reading the first fisical sector of the card. but i am using the read_single_block command of the MMC card SPI specification. Isn't it supose to give-me the absolute first sector of the card? if not, how can i access it. this point is giving me an headache.:s |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Wed Sep 19, 2007 3:04 pm |
|
|
It's just the other way around: read_single_block() will give you the very first block of the card. The directory or file you want to read starts at a higher block number. Finding the right block number is not easy as you will have to analyse the Master Boot Record (The block with the error message), then scan the partition table and finaly find the FAT32 root sector.
If you want to read and write multiple files on FAT32 you can save yourself a lot of time by using one of the FAT libraries from the 'Code Library' in this forum or from internet.
Some quick-and-dirty hacks are possible by using a card that is pre-formatted on the PC and contains one huge file. Put a known string of data at the start of this file and then you can scan the memory card for this string. When found you know you have the start of the file. |
|
|
Dreamit Guest
|
|
Posted: Wed Sep 19, 2007 4:18 pm |
|
|
yes i know if i want to read a file or directory i can use one of the FAT libraries from here. but right now i just wanted to "scan" all the fisical sector of the card.just to know what is in there. the thing is, using the read_single_block command, with the 0 address on it, it gives me the MBR sector and not the first one. the one that starts with 0xEB ou E9, the Boot sector.
am i making any sense? |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Wed Sep 19, 2007 4:54 pm |
|
|
As far as I understand the basics:
- MBR _is_ the very first sector, that's why it is called the Master. Ends with 0xAA55. Here you will find the primary partition table with pointers to start of the partitions.
- Each FAT32 partition in turn also has a boot sector, this starts with 0xEB or 0xE9. |
|
|
Dreamit Guest
|
|
Posted: Thu Sep 20, 2007 9:35 am |
|
|
thank you very much. it's all understood now. :D
thanks... it's almost done! |
|
|
incubus22
Joined: 15 Nov 2007 Posts: 14
|
|
Posted: Wed Nov 21, 2007 8:13 pm |
|
|
Dreamit wrote: | thank you very much. it's all understood now. :D
thanks... it's almost done! |
Hello Dreamit!
Did you implement a hardware or software SPI on your MMC? Is it FAT32? Can you help me? Currently, I am using software SPI on my MMC using a 20MHz crystal on PIC18F4550.
My problem is that it's slow. I've read that using the hardware SPI is much faster than the software SPI. Can you help me? Please... |
|
|
incubus22
Joined: 15 Nov 2007 Posts: 14
|
|
Posted: Sun Nov 25, 2007 10:31 am |
|
|
Hello Dreamit! Are you there? Please reply to my message. |
|
|
|