Author Topic: microsd flash structure  (Read 14357 times)

0 Members and 1 Guest are viewing this topic.

Offline SirNick

  • Frequent Contributor
  • **
  • Posts: 589
Re: microsd flash structure
« Reply #25 on: October 22, 2014, 11:35:28 pm »
If you have some sort of dying-gasp notification anyway, would it be possible to log to RAM and bulk-write on shutdown?
 

Offline trevwhiteTopic starter

  • Frequent Contributor
  • **
  • Posts: 955
  • Country: gb
Re: microsd flash structure
« Reply #26 on: December 15, 2014, 12:33:02 pm »
Just a follow up on this thread. I used a dedicated flash ic in the end and rolled my own very simple filesystem. I only needed append and read operations so it was relatively straight forward.

Thanks everyone for your comments. I think you saved me a lot of problems with the SD Card approach and this flash ic based version is a lot faster and more robust.



 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4620
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: microsd flash structure
« Reply #27 on: December 15, 2014, 12:44:59 pm »
What technique did you use for wear leveling?
 

Offline trevwhiteTopic starter

  • Frequent Contributor
  • **
  • Posts: 955
  • Country: gb
Re: microsd flash structure
« Reply #28 on: December 15, 2014, 04:48:59 pm »
I do not have wear issues to worry about. My need is just to keep taking measurements and append the data each time to my current position memory. I will probably erase data several times a year. When I do I will just erase all sectors and start again. I am not taxing this memory at all..






 

Offline tonyarkles

  • Regular Contributor
  • *
  • Posts: 118
Re: microsd flash structure
« Reply #29 on: December 17, 2014, 04:52:31 pm »
My somewhat hacky solution would be to have a series of headers like this:

Code: [Select]
header:
- block number
- address of next block
- checksum

record:
- num bytes of data
- [data]
- checksum

When you power on, you read the first sector of your file, and follow the pointer to the address of the next header. Try reading the data there, and if it passes the checksum, repeat until you reach a block that doesn't pass the checksum. You now know that you've found the last block of valid data. Go back to the last valid header, and start reading data records. Keep going until you find a record that doesn't pass its checksum. That's where you start writing from.

It's not perfect, but given the constraints it should probably work reasonably well.

 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4620
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: microsd flash structure
« Reply #30 on: December 17, 2014, 06:51:58 pm »
A linked list approach is an nice linear way of using the available flash. Better than FAT.
I would also use fixed sized blocks, if for some reason the crc fails the next/prev address could be invalid. You don't want to lose all data in the following sectors. If it does, you can still reassemble the remaining blocks by scanning *all* supposed block positions.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

- - -
-->