UK
Offline
Newbie
Karma: 0
Posts: 46
Love Arduino, Want the T-Shirt.
|
 |
« on: January 03, 2010, 07:38:06 am » |
Would it be possible to have a very low level file system on an SD card or similar so that one could log simply and not have the SD rewrite the file system every time which can eventually break...The file system would ideally be a byte by byte writing system much like the EPROM chip memory access
|
|
|
|
|
Logged
|
Never wing it, unless it's convenient.
|
|
|
|
Canada
Offline
Full Member
Karma: 0
Posts: 218
You will become one with the Arduino!
|
 |
« Reply #1 on: January 03, 2010, 09:13:03 am » |
It is certainly possible; but there are some limitations - most notably would be that you have to write in 512 byte sector blocks.
You could buffer the data until 512 bytes was received and then write the sector, move to the next sector, etc., or write a padded sector (2 real bytes, then 510 blank bytes).
You may even want to use the start sector to mark which is the current sector in case of power outage, or taking out and later replacing the data card for more logging.
However- remember that any given sector usually has a limit to the number of writes. If the limit for the card technology is 10,000 writes - then you can only write 10,000 sectors before the first sector can't be written to.
Most cards use wear levelling - i.e. you think you are reading/writing to sector 1, but the card maps it somewhere else so the card can exist after more than 10,000 writes.
I have worked on a Unix filesystem with Write-Once Magneto Optical media where the control data is written from the beginning of the media (aka sample date/time) and the data(sample data) is written from the end back until the two meet. In this scenario, any given sector is never overwritten. (With WORM media, you can not overwrite, ever, unlike your SD card.)
|
|
|
|
|
Logged
|
|
|
|
|
UK
Offline
Newbie
Karma: 0
Posts: 46
Love Arduino, Want the T-Shirt.
|
 |
« Reply #2 on: January 04, 2010, 05:33:25 am » |
So I could do 510byte packages for a 2GB (say) card once or what? Im a little confused...So whatever I write i can only do 10,000 sectors once? The application would only have to do one total write and then one read once in its life as the application is high end.
|
|
|
|
|
Logged
|
Never wing it, unless it's convenient.
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 277
Posts: 25517
Solder is electric glue
|
 |
« Reply #3 on: January 04, 2010, 06:10:26 am » |
most notably would be that you have to write in 512 byte sector blocks. I think you can write individually but only erase in 512 byte sectors. So whatever I write i can only do 10,000 sectors once? No you can only write to the same byte in the same sector 10,000 times. Or in other words erase the same sector 10,000 times which amounts to the same thing.
|
|
|
|
|
Logged
|
|
|
|
|
UK
Offline
Newbie
Karma: 0
Posts: 46
Love Arduino, Want the T-Shirt.
|
 |
« Reply #4 on: January 04, 2010, 06:59:18 am » |
Thanks, this clears that up.. Ive not done any work with SD cards so is there any good places with information as to how to write to them without FAT.
|
|
|
|
|
Logged
|
Never wing it, unless it's convenient.
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 277
Posts: 25517
Solder is electric glue
|
 |
« Reply #5 on: January 04, 2010, 07:12:45 am » |
|
|
|
|
|
Logged
|
|
|
|
|
Offline
God Member
Karma: 3
Posts: 985
Arduino rocks
|
 |
« Reply #6 on: January 04, 2010, 07:46:46 am » |
It is unlikely that cards with wear levelling will ever break as a result of too many erase/write cycles. The SD specification was written well aware of the fact that cards are typically used with a FAT file system and the onchip controller will distribute data across all sectors to minimize wear for every single sector.
Consider the following:
- SD card with 2GB capacity - Minimum 10,000 erase/write cycles per sector - We write 512 bytes or less to the card every second - We use FAT16 file system
Less than 3 writes per second on average (file system allocation table, directory record, data record). There are 4 writes when you cross a sector boundary, otherwise 2.
Total number of 512 byte blocks is 4194304 Total number of erase/write cycles is 4194304*10000 Number of seconds until card wears out is 4194304*10000/3
If we calculate above, this equals 443.03 years.
If we log data 10 times as often (or write 5kB every second) the card will still be OK (with respect to the erase/write limitation) for 40+ years. For data volumes higher than this we're likely to run into capacity issues and other limitations before we ever challenge the write/ease limitiation.
|
|
|
|
|
Logged
|
|
|
|
|
UK
Offline
Newbie
Karma: 0
Posts: 46
Love Arduino, Want the T-Shirt.
|
 |
« Reply #7 on: January 04, 2010, 08:43:08 am » |
Thanks, sounds good. What about Micro SDs (I think this has been answered somewhere else)? Many thanks for the help...
|
|
|
|
|
Logged
|
Never wing it, unless it's convenient.
|
|
|
|
Offline
God Member
Karma: 3
Posts: 985
Arduino rocks
|
 |
« Reply #8 on: January 04, 2010, 09:12:45 am » |
MicroSD/MiniSD or SD dosn't realy matter in this context. The only difference is form factor (physical size). File system, write/erase cycles, speed, interface/protocol is all the same.
The SDHC (high capacity SD) cards however are made to a revised/updated SD specification and I would avoid these unless whatever hardware (interface/breakout design) and software you plan to use specifically states to be compatible with these cards.
|
|
|
|
|
Logged
|
|
|
|
|
UK
Offline
Newbie
Karma: 0
Posts: 46
Love Arduino, Want the T-Shirt.
|
 |
« Reply #9 on: January 09, 2010, 11:01:17 am » |
I cant find the basic command set to get started with...Im using the mbed so I dont have to work out the whole SPI think to start with...
|
|
|
|
|
Logged
|
Never wing it, unless it's convenient.
|
|
|
|
|