Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.arch.embedded > #24843

Re: What is your strategy to save non volatile data?

From Joe Chisolm <jchisolm6@earthlink.net>
Subject Re: What is your strategy to save non volatile data?
Newsgroups comp.arch.embedded
References <nohs7p$ff3$1@dont-email.me>
Message-ID <gaydnb_QsOlinzPKnZ2dnUU7-eGdnZ2d@earthlink.com> (permalink)
Date 2016-08-12 12:10 -0500

Show all headers | View raw


On Thu, 11 Aug 2016 14:48:57 +0200, pozz wrote:

> Many times I work on embedded projects where it is required to save some
> data in a non volatile way.  Usualy I use external (to the main
> microcontroller) serial/parallel EEPROM or internal Flash memory (with a
> software layer for EEPROM emulation).
> 
> However my goal isn't to discuss the hw alternatives, but the data
> format and strategy.
> 
> I know there are many serialization data format (XML, JSON, Protocol
> Buffer, SQLite), but I don't think they are valid solutions for
> medium/low end microcontrollers.  They are complex to implement and they
> aren't really necessary.
> Data are written and read from the same platform, so the endianess and
> byte order are not a problem.
> 
> IMHO directly saving a C structure to the non-volatile memory is the
> best method.  When you will load bytes from the non volatile memory, you
> will have magically your C structure in RAM filled with the saved
> values.
> 
> Is it the same strategy that you use?

I think JSON, XML, etc are over kill for data that will never be
exposed to the outside world.  If you are going to have an editable
config file, then yes.

Writing structs directly to storage can introduce upgrade/downgrade
issues.  But depending on the stability of the structs and how you
manage introducing new data sets into the struct it can work.  Saving
the entire config data set works well with flash where you are block
erasing, block writing anyway.

I have always used either on chip or external byte writable EEPROM.
Address zero is always a version id of the data in the eeprom. I decouple
the FW rev from the eeprom rev.  All new items are added at the end.
FW rev 1 reads 0x00 to say 0x50 with offsets known.  FW rev 2
reads 0x00-0x50 for existing items, and 0x51... for new items.  If I need
to downgrade to FW rev 1 the EEPROM items 0x51 and beyond are simply
ignored.

Another simple way is a tag-length-value list.  You have a search
routine that reads through the eeprom looking for the specific tag.

With either of these approaches  you have to deal with the issue of
config item "X" is a u_int8 and now needs to be a u_int32.  How do you
manage upgrade path fw ver 1 -> fw ver 2 (that needs u_int32) and then
downgrade back to fw ver 1 because of some fatal flaw in ver 2 that will
take you a month to fix and QA.  You have to roll back the fw so the
units will be operational until you can fix ver 2.

-- 
Chisolm
Republic of Texas

Back to comp.arch.embedded | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

What is your strategy to save non volatile data? pozz <pozzugno@gmail.com> - 2016-08-11 14:48 +0200
  Re: What is your strategy to save non volatile data? Don Y <blockedofcourse@foo.invalid> - 2016-08-11 06:27 -0700
  Re: What is your strategy to save non volatile data? David Brown <david.brown@hesbynett.no> - 2016-08-11 16:12 +0200
    Re: What is your strategy to save non volatile data? Don Y <blockedofcourse@foo.invalid> - 2016-08-11 07:53 -0700
      Re: What is your strategy to save non volatile data? Don Y <blockedofcourse@foo.invalid> - 2016-08-11 08:27 -0700
        Re: What is your strategy to save non volatile data? bitrex <bitrex@de.lete.earthlink.net> - 2016-08-11 12:11 -0400
          Re: What is your strategy to save non volatile data? bitrex <bitrex@de.lete.earthlink.net> - 2016-08-11 12:12 -0400
            Re: What is your strategy to save non volatile data? Don Y <blockedofcourse@foo.invalid> - 2016-08-11 11:35 -0700
              Re: What is your strategy to save non volatile data? bitrex <bitrex@de.lete.earthlink.net> - 2016-08-11 20:59 -0400
          Re: What is your strategy to save non volatile data? Don Y <blockedofcourse@foo.invalid> - 2016-08-11 11:33 -0700
        Re: What is your strategy to save non volatile data? pozz <pozzugno@gmail.com> - 2016-08-12 00:21 +0200
          Re: What is your strategy to save non volatile data? Don Y <blockedofcourse@foo.invalid> - 2016-08-11 15:40 -0700
      Re: What is your strategy to save non volatile data? David Brown <david.brown@hesbynett.no> - 2016-08-11 23:07 +0200
        Re: What is your strategy to save non volatile data? pozz <pozzugno@gmail.com> - 2016-08-12 00:17 +0200
          Re: What is your strategy to save non volatile data? Don Y <blockedofcourse@foo.invalid> - 2016-08-11 15:30 -0700
            Re: What is your strategy to save non volatile data? pozz <pozzugno@gmail.com> - 2016-08-12 09:02 +0200
              Re: What is your strategy to save non volatile data? Don Y <blockedofcourse@foo.invalid> - 2016-08-12 09:29 -0700
            Re: What is your strategy to save non volatile data? David Brown <david.brown@hesbynett.no> - 2016-08-12 11:54 +0200
              Re: What is your strategy to save non volatile data? John Devereux <john@devereux.me.uk> - 2016-08-12 13:14 +0100
                Re: What is your strategy to save non volatile data? David Brown <david.brown@hesbynett.no> - 2016-08-12 15:22 +0200
              Re: What is your strategy to save non volatile data? Don Y <blockedofcourse@foo.invalid> - 2016-08-12 09:40 -0700
                Re: What is your strategy to save non volatile data? David Brown <david.brown@hesbynett.no> - 2016-08-12 22:40 +0200
                Re: What is your strategy to save non volatile data? Don Y <blockedofcourse@foo.invalid> - 2016-08-13 09:44 -0700
                Re: What is your strategy to save non volatile data? David Brown <david.brown@hesbynett.no> - 2016-08-14 23:01 +0200
          Re: What is your strategy to save non volatile data? David Brown <david.brown@hesbynett.no> - 2016-08-12 09:52 +0200
            Re: What is your strategy to save non volatile data? pozz <pozzugno@gmail.com> - 2016-08-12 16:30 +0200
              Re: What is your strategy to save non volatile data? David Brown <david.brown@hesbynett.no> - 2016-08-12 17:09 +0200
        Re: What is your strategy to save non volatile data? Don Y <blockedofcourse@foo.invalid> - 2016-08-11 15:36 -0700
        Re: What is your strategy to save non volatile data? Paul <paul@pcserviceselectronics.co.uk> - 2016-08-12 03:21 +0100
    Re: What is your strategy to save non volatile data? bitrex <bitrex@de.lete.earthlink.net> - 2016-08-11 12:19 -0400
      Re: What is your strategy to save non volatile data? pozz <pozzugno@gmail.com> - 2016-08-11 23:49 +0200
        Re: What is your strategy to save non volatile data? Don Y <blockedofcourse@foo.invalid> - 2016-08-11 15:37 -0700
    Re: What is your strategy to save non volatile data? John Devereux <john@devereux.me.uk> - 2016-08-11 20:50 +0100
    Re: What is your strategy to save non volatile data? pozz <pozzugno@gmail.com> - 2016-08-12 00:16 +0200
      Re: What is your strategy to save non volatile data? Paul <paul@pcserviceselectronics.co.uk> - 2016-08-12 03:34 +0100
      Re: What is your strategy to save non volatile data? David Brown <david.brown@hesbynett.no> - 2016-08-12 11:59 +0200
  Re: What is your strategy to save non volatile data? Paul Rubin <no.email@nospam.invalid> - 2016-08-11 11:29 -0700
  Re: What is your strategy to save non volatile data? Les Cargill <lcargill99@comcast.com> - 2016-08-12 12:15 -0500
  Re: What is your strategy to save non volatile data? Joe Chisolm <jchisolm6@earthlink.net> - 2016-08-12 12:10 -0500
    Re: What is your strategy to save non volatile data? Paul <paul@pcserviceselectronics.co.uk> - 2016-08-12 22:00 +0100
  Re: What is your strategy to save non volatile data? Tim Wescott <tim@seemywebsite.com> - 2016-08-13 12:06 -0500
    Re: What is your strategy to save non volatile data? pozz <pozzugno@gmail.com> - 2016-08-13 23:42 +0200
      Re: What is your strategy to save non volatile data? Don Y <blockedofcourse@foo.invalid> - 2016-08-13 15:55 -0700
      Re: What is your strategy to save non volatile data? Paul <paul@pcserviceselectronics.co.uk> - 2016-08-14 00:08 +0100
      Re: What is your strategy to save non volatile data? Tim Wescott <tim@seemywebsite.com> - 2016-08-13 19:06 -0500
        Re: What is your strategy to save non volatile data? pozz <pozzugno@gmail.com> - 2016-08-22 09:46 +0200

csiph-web