Re: [avr-gcc-list] including default eeprom values in flash memory

2009-10-21 Thread Michael Clift

Thanks for all the responses guys, some interesting ideas.
I don't really want to put all of my EEPROM data into one structure, as 
I have many eeprom variables with initializers distributed across a 
number of files.


What I ended up doing, was to change the .eep output format to binary, 
then I copied this to an object file as described here 
http://www.nongnu.org/avr-libc/user-manual/FAQ.html#faq_binarydata
I then linked this object into my main code. It works a treat, only I 
have to build my code twice to get the initial values updated to flash, 
once to create .eep, and again to link in the object.


The main reason for doing this, is that I have a boot loader that I want 
our clients to be able to use, only the boot loader does not support 
eeprom loading. It also saves me having to program the eeprom in production.



Regards, Michael.



___
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list


Re: [avr-gcc-list] including default eeprom values in flash memory

2009-10-21 Thread Bob Paddock
> Ditto. Declare the variables twice, once with a name that is obvious to
> you is EEPROM in the EEPROM space, and again with a name that is obvious
> to you is stored in FLASH. Then when/if you wish to restore EEPROM
> contents to their initial default values use the PGM modifier to read
> from FLASH and call the routine(s) used to write EEPROM.

I have been trying to find the origin of a story, without success so
far, related to
restoring  default EEPROM settings to "factory" settings.

Story goes like this:

A lady took her car back to the dealer, and asked that they disable the
front seat passenger air bags, as her son always road there.  The dealer
did as the lady asked.  Some time later something happened, possibly
a jump start due to dead battery, which caused the ECU to restore
the EEPROM to factory specs, which included turning the passenger side
air bag back on.  There was then an accident, where boy was killed.

Even if the story is not true, it still illustrates just how hard it is to do
a "safe" embedded system.

"Programming is a race between writing a program that any idiot can use,
and the Universe building bigger and better idiots.  The Universe is winning."



-- 
http://www.wearablesmartsensors.com/
http://www.softwaresafety.net/
http://www.designer-iii.com/
http://www.unusualresearch.com/


___
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list


Re: [avr-gcc-list] including default eeprom values in flash memory

2009-10-21 Thread Dusan Ferbas

Hi,

I am using for many years a system, I published as open source (LGPL 
like) at http://www.ethernut.de/en/documents/phat.html. Look for 
'SPIFlashFileSystem' link to a zip file.
This is a complete project, but there is a subdirectory eeparams, 
which can be extracted from it.


Common problem is, that your variables in EEPROM changes between 
firmware revisions. Idea is to assign a unique ID to each data 
structure and to place a table with these IDs, offsets and lengths at 
the beginning of EEPROM area. Default table occupies space in flash. 
However this is not suitable for uPs with limited code, I found it 
usefull, because the code supports also fw downgrade, while 
preserving variables existing in both revisions and placing default 
values for new ones.


At 11:34 21.10.2009, Michael Clift wrote:
Hi, I am using winavr, and would like to include the default eeprom 
values (normally output to .eep) in flash memory. I want to do this 
so that my application can easily default the eeprom. Whats the best 
way to do this? can it be done with a modification to the linker 
script? or should it be done in the makefile somehow?


Dusan 




___
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list


Re: [avr-gcc-list] including default eeprom values in flash memory

2009-10-21 Thread David Kelly
On Wed, Oct 21, 2009 at 07:40:50AM -0700, Parthasaradhi Nayani wrote:
> 
> >From: Michael Clift 
> >
> >??? Hi, I am using winavr, and would like to include the default
> >eeprom values (normally output >to .eep) in flash memory. I want to
> >do this so that my application can easily default the >eeprom. 
> 
> Hello,
> EEPROM data in FLASH memory? then the easy way is to use the PGM space
> attribute to the variables you want in flash.

Ditto. Declare the variables twice, once with a name that is obvious to
you is EEPROM in the EEPROM space, and again with a name that is obvious
to you is stored in FLASH. Then when/if you wish to restore EEPROM
contents to their initial default values use the PGM modifier to read
from FLASH and call the routine(s) used to write EEPROM.

Duplicating the default data in your source code sounds wasteful but it
will be easier to understand 6 months from now than an edit of the
Makefile plus hacks to the memory segment definitions. I think it is
possible that way to write the .eeprom segment to two places in memory,
is just that you don't want to do it that way when there is an easier
way that is also easier to understand.

-- 
David Kelly N4HHE, dke...@hiwaay.net

Whom computers would destroy, they must first drive mad.


___
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list


Re: [avr-gcc-list] including default eeprom values in flash memory

2009-10-21 Thread Parthasaradhi Nayani

>From: Michael Clift 
>
>    Hi, I am using winavr, and would like to include the default eeprom values 
>(normally output >to .eep) in flash memory. I want to do this so that my 
>application can easily default the >eeprom. 

Hello,
EEPROM data in FLASH memory? then the easy way is to use the PGM space 
attribute to the variables you want in flash.

Nayani




  ___
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list


R: [avr-gcc-list] including default eeprom values in flash memory

2009-10-21 Thread palmerino tallarico
Hi
I'm using this (for example):

File eedata.c 

#include "eedata.h"

TOTAL_DATA total_data;
ERROR_DATA error_data;

TOTAL_DATA __attribute__((section(".eeprom"))) e2total_data =
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

ERROR_DATA __attribute__((section(".eeprom"))) error_data = {0,0};

File eedata.h

#define TOTAL_DATA_ADDR 0  // Starting address of SYS_DATA image
data in eeprom 
#define ERROR_DATA_ADDR (TOTAL_DATA_ADDR + sizeof(total_data))
// Starting address of ERROR_DATA image in eeprom

typedef struct  {
  u32 .; (fill as you need)
}TOTAL_DATA;

extern TOTAL_DATA total_data

typedef struct  {
  u16 ;
}ERROR_DATA;

extern ERROR_DATA error_data;

hope this help U!

Rino Tallarico
_

-Messaggio originale-
Da: avr-gcc-list-bounces+palmerinotallarico=vodafone...@nongnu.org
[mailto:avr-gcc-list-bounces+palmerinotallarico=vodafone...@nongnu.org] Per
conto di Prashant D. Kharade
Inviato: mercoledì 21 ottobre 2009 12.35
A: Michael Clift; avr-gcc-list@nongnu.org
Oggetto: RE: [avr-gcc-list] including default eeprom values in flash memory

Hi,

One method, which I have read on the net & also used by myself in my
project is as follows.

As per this we have to write the default eeprom values in our 'C' file.

1. Create one variable named eeload.
2. In your main program, if eeload !=250 (any random value) then put all
your default values in EEprom.
3. And also load eeload = 250.
4. Because of this, next time eeload will be 250 & default values will
not be reloaded.
5. Hence after you load your main hex file, at first instant all the
default eeprom values will get loaded alongwith eeload=250.
6. This part of code will never get executed in future because eeload =
250.

Hope this will help you.
Good Luck

Prashant
India

-Original Message-
From: avr-gcc-list-bounces+pdkharade=adorpower@nongnu.org
[mailto:avr-gcc-list-bounces+pdkharade=adorpower@nongnu.org] On
Behalf Of Michael Clift
Sent: 21 October 2009 15:04
To: avr-gcc-list@nongnu.org
Subject: [avr-gcc-list] including default eeprom values in flash memory

Hi, I am using winavr, and would like to include the default eeprom 
values (normally output to .eep) in flash memory. I want to do this so 
that my application can easily default the eeprom. Whats the best way to

do this? can it be done with a modification to the linker script? or 
should it be done in the makefile somehow?



Regards, Michael.



___
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list

No virus found in this incoming message.
Checked by AVG - www.avg.com 
Version: 8.5.423 / Virus Database: 270.14.24/2449 - Release Date:
10/20/09 18:42:00



___
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list



___
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list


RE: [avr-gcc-list] including default eeprom values in flash memory

2009-10-21 Thread Prashant D. Kharade
Hi,

One method, which I have read on the net & also used by myself in my
project is as follows.

As per this we have to write the default eeprom values in our 'C' file.

1. Create one variable named eeload.
2. In your main program, if eeload !=250 (any random value) then put all
your default values in EEprom.
3. And also load eeload = 250.
4. Because of this, next time eeload will be 250 & default values will
not be reloaded.
5. Hence after you load your main hex file, at first instant all the
default eeprom values will get loaded alongwith eeload=250.
6. This part of code will never get executed in future because eeload =
250.

Hope this will help you.
Good Luck

Prashant
India

-Original Message-
From: avr-gcc-list-bounces+pdkharade=adorpower@nongnu.org
[mailto:avr-gcc-list-bounces+pdkharade=adorpower@nongnu.org] On
Behalf Of Michael Clift
Sent: 21 October 2009 15:04
To: avr-gcc-list@nongnu.org
Subject: [avr-gcc-list] including default eeprom values in flash memory

Hi, I am using winavr, and would like to include the default eeprom 
values (normally output to .eep) in flash memory. I want to do this so 
that my application can easily default the eeprom. Whats the best way to

do this? can it be done with a modification to the linker script? or 
should it be done in the makefile somehow?



Regards, Michael.



___
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list

No virus found in this incoming message.
Checked by AVG - www.avg.com 
Version: 8.5.423 / Virus Database: 270.14.24/2449 - Release Date:
10/20/09 18:42:00



___
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list


[avr-gcc-list] including default eeprom values in flash memory

2009-10-21 Thread Michael Clift
Hi, I am using winavr, and would like to include the default eeprom 
values (normally output to .eep) in flash memory. I want to do this so 
that my application can easily default the eeprom. Whats the best way to 
do this? can it be done with a modification to the linker script? or 
should it be done in the makefile somehow?




Regards, Michael.



___
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list