CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Formatting SD/MMC Cards

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
jecottrell



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

Formatting SD/MMC Cards
PostPosted: Tue Sep 04, 2007 7:57 am     Reply with quote

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

View user's profile Send private message Visit poster's website

PostPosted: Tue Sep 04, 2007 8:29 am     Reply with quote

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 Wink
_________________
Programming for the the real world.
--Chris Burchett
Sylver Technologies Inc.
jecottrell



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

PostPosted: Tue Sep 04, 2007 9:40 am     Reply with quote

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

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Tue Sep 04, 2007 10:25 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Sep 05, 2007 12:30 am     Reply with quote

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







PostPosted: Mon Sep 17, 2007 12:23 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Sep 17, 2007 5:06 pm     Reply with quote

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








PostPosted: Wed Sep 19, 2007 2:13 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Sep 19, 2007 3:04 pm     Reply with quote

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







PostPosted: Wed Sep 19, 2007 4:18 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Sep 19, 2007 4:54 pm     Reply with quote

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







PostPosted: Thu Sep 20, 2007 9:35 am     Reply with quote

thank you very much. it's all understood now. :D

thanks... it's almost done!
incubus22



Joined: 15 Nov 2007
Posts: 14

View user's profile Send private message

PostPosted: Wed Nov 21, 2007 8:13 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Nov 25, 2007 10:31 am     Reply with quote

Hello Dreamit! Are you there? Please reply to my message.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group