|
|
View previous topic :: View next topic |
Author |
Message |
soonc
Joined: 03 Dec 2013 Posts: 215
|
Best utility for formatting SD Memory Card ? |
Posted: Fri Sep 01, 2017 10:23 am |
|
|
I tried using Windows to format an SD memory card and it left a bunch of boot messages in sector 0.
I also tried "SD Card Formatter" by www.SDCard.org but it also put a bunch of garbage in sector 0.
Does anyone have a link to a formatting utility aimed at formatting SD card for embedded use ?
Or suggest another way to get the boot sector back to normal.
Excuse if this question has been asked before but I could not find anything. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19553
|
|
Posted: Fri Sep 01, 2017 1:26 pm |
|
|
First, how big is the card?.
Then neither routine should put garbage in sector 0. However a lot of things may be left in here, which don't matter.
What are the last two bytes of the sector?. They should be 55 AA. If not then I'd say you have a faulty card. |
|
|
soonc
Joined: 03 Dec 2013 Posts: 215
|
|
Posted: Fri Sep 01, 2017 2:09 pm |
|
|
Ttelmah wrote: | First, how big is the card?.
Then neither routine should put garbage in sector 0. However a lot of things may be left in here, which don't matter.
What are the last two bytes of the sector?. They should be 55 AA. If not then I'd say you have a faulty card. |
2 GByte. Yes the last two bytes are 55AA.
When I use WinHex to inspect the card the Sectors_Per_Cluster = 64
Using CCS FAT_PIC.C in fat_init() the Sectors_Per_Cluster is 24128 ! Something wrong with that I think! and it may be the reason I'm not getting a good "Data_Start" value.
I'm trying to get a "Data_Start" number. At the moment the code returns
368128 for the Data_Start but if I write to that address it ends up at 327680.
Most likely something to do with LBA which I've never understood, or that the Sectors_Per_Cluster is not correct..
My tests show if I use a higher number to start writing at the data ends up above 368128 reported by fat_init() the code read's and writes data all day long.
So what I really would like to do is to get a "real number" but my search for a formula is not working out very well.
Note! I do NOT want to use FAT. The pic code is far too bloated.
I need to read the data on a Window PC, and for that I've written a Window program to directly access the SD when plugged into a USB reader.
At the moment it's searching the card for the start of data location by searching until it finds a unique signature.
This all works...
The whole process is wasting SD space so if I can calculate where to start it would be best. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19553
|
|
Posted: Fri Sep 01, 2017 2:25 pm |
|
|
If you are not using FAT, there is no point in formatting the card....
All formatting does, is partition and put the FAT file-system on the card. There is no low level formatting done on an SD card. No sector boundaries to be initialised, these are in the hardware. If you want to talk to the card as a simple memory device, you don't need FAT drivers, just the basic hardware drivers. 32K per cluster is quite normal, but again you don't need this if you are not using FAT.
Most of the first sector won't actually be initialised at all, since it contains the space designed for the boot sector, and unless the card is bootable this will be left unchanged. This is the first 446 bytes of the first sector. |
|
|
soonc
Joined: 03 Dec 2013 Posts: 215
|
|
Posted: Fri Sep 01, 2017 3:56 pm |
|
|
Ttelmah wrote: | If you are not using FAT, there is no point in formatting the card....
All formatting does, is partition and put the FAT file-system on the card. There is no low level formatting done on an SD card. No sector boundaries to be initialised, these are in the hardware. If you want to talk to the card as a simple memory device, you don't need FAT drivers, just the basic hardware drivers. 32K per cluster is quite normal, but again you don't need this if you are not using FAT.
Most of the first sector won't actually be initialised at all, since it contains the space designed for the boot sector, and unless the card is bootable this will be left unchanged. This is the first 446 bytes of the first sector. |
Yes I understand, but I'd prefer to not write into the FAT system at all. Anyway I'll just carry on... Thanks |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9246 Location: Greensville,Ontario
|
|
Posted: Fri Sep 01, 2017 5:40 pm |
|
|
Unless you really, really HAVE to use an SD card, you might consider the Vinculum series of flashdrive interfaces.
EASY to use, simple serial interface commands and EASY to transfer data to/from a PC.
I used one for a remote data logging product, having the PIC store the data in CSV (Comma separated values) format. This allowed Excel to import data and display without any 'translations'.
Perhaps this can be an option for you?
There are other 'data logging' devices, though the flash drive system is EASY as every PC has USB these days not all have SD interfaces.
Jay |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19553
|
|
Posted: Sat Sep 02, 2017 12:41 am |
|
|
Quote: |
Yes I understand, but I'd prefer to not write into the FAT system at all. Anyway I'll just carry on... Thanks
|
The point I'm making is that if you are not using a FAT filesystem, then you don't want to be using a formatter.
The card is just a memory. All that formatting does is write the partition table, and the data needed to support a FAT filesystem. It creates the MBR, and the directory for the filesystem. If you are just going to use the card as a 'memory', then don't format. It's just wasting lives.
On a device like a floppy disk, there is a 'low level' format, which actually records the sectors, but on a memory based device, there is no such operation. It is ready to go 'out of the box'. |
|
|
soonc
Joined: 03 Dec 2013 Posts: 215
|
Thought I had a home run... ! |
Posted: Sat Sep 02, 2017 11:24 pm |
|
|
Ttelmah wrote: | Quote: |
Yes I understand, but I'd prefer to not write into the FAT system at all. Anyway I'll just carry on... Thanks
|
The point I'm making is that if you are not using a FAT filesystem, then you don't want to be using a formatter.
The card is just a memory. All that formatting does is write the partition table, and the data needed to support a FAT filesystem. It creates the MBR, and the directory for the filesystem. If you are just going to use the card as a 'memory', then don't format. It's just wasting lives.
On a device like a floppy disk, there is a 'low level' format, which actually records the sectors, but on a memory based device, there is no such operation. It is ready to go 'out of the box'. |
Yes I agree, and I thought I was home and clear until today.
Using my original 2GB MicroSd card made by ATP My code works.
Today I Received 2GB SwissBit card and the code gets through mmcsd_init() so again: I thought it was a "home run".... !
But mmcsd_write_block() failed and mmcsd_read_block() works !
Back to the ATP card and everything works.
The ATP is a SLC card and the SwissBit is a PSLC !
Using yet another card: Kingston 2GB MLC the code works.
Using a cheap no name brand: the code fails.
Before anyone asks: I have tried with and without 10K Pull up resistors....
ATP works either way.
Vdd for the entire system is 3.3V.
So I could just buy the ATP cards and get one with life.... sure but what happens when the ATP card I'm now using is no longer available ?
And to be more precise... the ATP costs me US$24.95 and the SwissBit US$20.nn about a $4.95 savings.... I need to buy 1000pcs so the incentive is to get other cards working as I could save $5000.00 on the initial purchase.
We have Brush Electronics code but it's so poorly supported with NO real clear examples... a person can go nuts trying to understand the maze of #ifdefs etc... I suspect some kind of obfustication ! who knows but it sure put me off !
I'm not saying it's bad code but it's not clear, and I like clear concise code.
I'd prefer not using it.
Anyway so I'm back to using the mmcsd code which so far has proven OK with the ATP card. I must use an SLC card for temperature range and lower current. The ATP draws 1/2 the current of the Kingston MLC.
The most significant thing wrong with the CCS release of the mmcsd code was/is the lack of sending 80 bits to get the card talking spi(). I think someone added a fix to it (for which I'm thankful), and that got things up and running.
I'll close by saying thanks for all the help, if I find a clear solution I'll post a fix, it not I'll spend $5000.00 more than I have to, and use ATP !
PS it all started when I tried formatting some cards.... but as you pointed out it's not needed. Thanks for that confirmation. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19553
|
|
Posted: Sun Sep 03, 2017 1:17 am |
|
|
SLC is still by far the most reliable form of SD.
pSLC, is an attempt to 'appear' to be SLC, using cheaper technology.
SLC is still the preferred technology for 'industrial' rated storage devices.
However both should work the same for simple read/writes.
One thing often missed, is that these later cards take a lot longer to initialise than their simpler brethren. The internal error correction controller takes a significant time to wake up. The SD card specifications talk about units of mSec, but leave the actual time undefined. However some (especially latter cards) can take up to about 400mSec before they have finished their own initialisation....
Second comment, though you talk about 3.3v (good), it is vital to have a high capacity low ESR capacitor close to the card. At nSec timings, there are large current spikes on the supply _particularly when writing_. Your write problems could simply be that the supply is does not have sufficient reservoir capacitance close to the card.
The initialisation done by the CCS driver, is actually correct. The 80 pulse requirement, was removed in the 2007 edition SD specifications, and was replaced with using the IO_SEND_OP_COND command to initialise. This is what CCS do. However the older command is still often more reliable...
The resistors are _mandatory_ (not optional).
I'd be suspicious that either you do not have an adequate reservoir on the supply close to the card, or that you are starting a little too quickly. |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1635 Location: Perth, Australia
|
Re: Thought I had a home run... ! |
Posted: Sun Sep 03, 2017 10:42 am |
|
|
soonc wrote: |
We have Brush Electronics code but it's so poorly supported with NO real clear examples... a person can go nuts trying to understand the maze of #ifdefs etc... I suspect some kind of obfustication ! who knows but it sure put me off !
I'm not saying it's bad code but it's not clear, and I like clear concise code.
I'd prefer not using it. |
No body thinks their baby is ugly and tends to see their creation as wonderful. Despite being intimately familiar with the software as it has been shipping for years, based on your post I went back and re-examined my code based on your comments.
I have decided you do not know what your talking about.
Send me a private message with your proof of purchase of the driver software along with the email address used to purchase the software and I will look at your support history.
One of my failings as a software developer is my inability to predict the unique hardware and software combination used by each of my individual customers and am forced to produce code that use constructs such as #ifdef to enable these customers to define their target platform and what debugging if any they want embedded in the code.
NO real clear examples??? The software comes with two fully operational examples including a commercial real time data logger implementation that demonstrates use of the file system with advanced techniques such as asynchronous logging of real-time data decoupling data acquisition from logging. The example include a DOS like interface to exercise file system functions so the developer can see how to use these functions.
You can lead a horse to water, but you can't make them drink. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19553
|
|
Posted: Sun Sep 03, 2017 12:35 pm |
|
|
I think the key thing is that whichever driver he is using or intends to use, he needs to get his hardware working first.
The Brush drivers work fine, and I found them easy to modify to use DMA, with plenty of explanation. However all the drivers require that the hardware is able to read and write a sector properly. His erratic behaviour with different chips, says to me that he has a hardware issue. Now SD normally works fine (except with the increasing number of fake cards around), provided you are using 3.3v (which he is), have the correct resistors (he says he has), and have a really clean supply both for the PIC and the SD. A failure to be able to write 'smells' of inadequate reservoir capacitance on the supply, since this is when the demand is highest, and people often don't realise the frequencies involved. The other possibility is ringing in the signal traces. Again good HF layout is vital. |
|
|
soonc
Joined: 03 Dec 2013 Posts: 215
|
|
Posted: Sun Sep 03, 2017 8:52 pm |
|
|
Ttelmah wrote: | I think the key thing is that whichever driver he is using or intends to use, he needs to get his hardware working first.
The Brush drivers work fine, and I found them easy to modify to use DMA, with plenty of explanation. However all the drivers require that the hardware is able to read and write a sector properly. His erratic behaviour with different chips, says to me that he has a hardware issue. Now SD normally works fine (except with the increasing number of fake cards around), provided you are using 3.3v (which he is), have the correct resistors (he says he has), and have a really clean supply both for the PIC and the SD. A failure to be able to write 'smells' of inadequate reservoir capacitance on the supply, since this is when the demand is highest, and people often don't realise the frequencies involved. The other possibility is ringing in the signal traces. Again good HF layout is vital. |
The supply is capable of providing 500mA continuous with 750mA peak .
Scope on the supply proves the ripple is low and less than 10-15 mV while the good ATP card is fully operational.
Scope also on the clock DO and DI lines show it's clean i.e. no ringing.
PIC24 to the MicroSd card spi lines are about 1" in length!
10uF LOW ESR Tantalum cap at the VDD.
10K pull up on SPI DO and DI.
Layout is based upon 30 years of designing successful products.
Similar older design using Regular SD card and PIC18 has been working for several years.
When I redesigned this newer version I wanted to save space and hence the MicroSD card.
Putting the MicroSD card in an adapter in the old design works but NOT with the SwissBit PSEL card or the no name (which likely is a fake card).
I'm sticking with the ATP as it works With and Without pull up resistors, and the MMCSD.C code.
However no card works without first sending the 80 cycle cycles.
I inserted a 1000mS delay after mmcsd_init() but the SwissBit still fails.
Thanks for the help I need to use what works so ATP card it is. |
|
|
soonc
Joined: 03 Dec 2013 Posts: 215
|
Re: Thought I had a home run... ! |
Posted: Sun Sep 03, 2017 8:58 pm |
|
|
asmallri wrote: | soonc wrote: |
We have Brush Electronics code but it's so poorly supported with NO real clear examples... a person can go nuts trying to understand the maze of #ifdefs etc... I suspect some kind of obfustication ! who knows but it sure put me off !
I'm not saying it's bad code but it's not clear, and I like clear concise code.
I'd prefer not using it. |
No body thinks their baby is ugly and tends to see their creation as wonderful. Despite being intimately familiar with the software as it has been shipping for years, based on your post I went back and re-examined my code based on your comments.
I have decided you do not know what your talking about.
Send me a private message with your proof of purchase of the driver software along with the email address used to purchase the software and I will look at your support history.
One of my failings as a software developer is my inability to predict the unique hardware and software combination used by each of my individual customers and am forced to produce code that use constructs such as #ifdef to enable these customers to define their target platform and what debugging if any they want embedded in the code.
NO real clear examples??? The software comes with two fully operational examples including a commercial real time data logger implementation that demonstrates use of the file system with advanced techniques such as asynchronous logging of real-time data decoupling data acquisition from logging. The example include a DOS like interface to exercise file system functions so the developer can see how to use these functions.
You can lead a horse to water, but you can't make them drink. |
Don't be so defensive! Calm down you will be giving yourself a heart attack...
Lesson for you to learn: You CANNOT please everybody, and I'm one of those you could not please. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19553
|
|
Posted: Mon Sep 04, 2017 12:12 am |
|
|
The delay needs to be _before_ you init the card.
Unless your scope has GHz responses, it will not see the micro ripples the SD can generate. This is why there must be a traps for these really close to the card itself. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9246 Location: Greensville,Ontario
|
|
Posted: Mon Sep 04, 2017 5:40 am |
|
|
This post is a classic 'should have left well enough alone' nightmare. While my 'business' hat sees the save $5 per unit is good, the 'tech' hat sees a LOT of $$ wasted on precious R&D time. That $5,000 'saved' by the new device is 50 hrs to me,so 4 days, more or less, for ONE person.
You should consider buying the more expensive part. It would allow you time to R&D while those 1,000 units get shipped out. I don't know if 1,000 is a weeks sales, month or year BUT using a known good device does get the product out the door, into the client's hands and his cash in yours.
The FIRST thing I do when a client asks for 'cost reduction' is to spend a day doing the 'numbers'. Reading a lot(like part availability((2nd source?)), deciding if a new PCB needs to be made($$), parts pricing($/1,000 vs $/5,000) and then the R&D required( double that time!).
I find it scary that there ARE fake chips out there, buy those and ALL profits can be wiped out.
What I'm saying is , it's better to go with what you KNOW works. When(if !) you have time, then play with new devices to see IF you can save.
Have you kept a log of all the time you have spent on this? Research of the chips, buying,bench testing, posting here ? It ALL should be accounted for and the time spent may suprise you.
Jay |
|
|
|
|
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
|