AT91SAM7S Flash as general purpose NV memory

  • Follow


Hi,

Is it possible to use the AT91SAM7S internal flash memory for general
purpose non volatile storage?

I mean: suppose you have a buffer declared in C, like this:

char myBuff[100];

During program execution you write and read data from myBuff. Suddenly
the system is powered off. Once the system is powered on again, I want
to have the contents of myBuff intact, holding the values stored the
last time I wrote (at runtime) to it, prior to power off.

Is that possible? If so, how?

Regards.

0
Reply jaime.aranguren (90) 5/7/2006 7:43:46 PM

jaac wrote:
> Hi,
>
> Is it possible to use the AT91SAM7S internal flash memory for general
> purpose non volatile storage?
>
> I mean: suppose you have a buffer declared in C, like this:
>
> char myBuff[100];
>
> During program execution you write and read data from myBuff. Suddenly
> the system is powered off. Once the system is powered on again, I want
> to have the contents of myBuff intact, holding the values stored the
> last time I wrote (at runtime) to it, prior to power off.
>
> Is that possible? If so, how?

No, unless you write your own compiler, the buffer will be in sram, not
flash.

> 
> Regards.

0
Reply me5463 (1320) 5/7/2006 9:13:44 PM


linnix wrote:

> jaac wrote:
> 
>>Hi,
>>
>>Is it possible to use the AT91SAM7S internal flash memory for general
>>purpose non volatile storage?
>>
>>I mean: suppose you have a buffer declared in C, like this:
>>
>>char myBuff[100];
>>
>>During program execution you write and read data from myBuff. Suddenly
>>the system is powered off. Once the system is powered on again, I want
>>to have the contents of myBuff intact, holding the values stored the
>>last time I wrote (at runtime) to it, prior to power off.
>>
>>Is that possible? If so, how?
> 
> 
> No, unless you write your own compiler, the buffer will be in sram, not
> flash.

plus you need to read the data sheet, as FLASH writes often have their 
own caveats.  You cannot read-while-write of the same Flash.

Some chips have dual Flash planes, so you run in one, while writing to 
the other.
Some chips pause the core during write ( Interrupts OFF)
Some chips expect the write code to run in RAM.
If the power fails DURING write, you have undefined FLASH content.

-jg

0
Reply no.spam4875 (840) 5/7/2006 10:25:28 PM

jaac wrote:
> Hi,
>
> Is it possible to use the AT91SAM7S internal flash memory for general
> purpose non volatile storage?
>
> I mean: suppose you have a buffer declared in C, like this:
>
> char myBuff[100];
>
> During program execution you write and read data from myBuff. Suddenly
> the system is powered off. Once the system is powered on again, I want
> to have the contents of myBuff intact, holding the values stored the
> last time I wrote (at runtime) to it, prior to power off.
>
> Is that possible? If so, how?
>
Yes, it is possible, but you must run the routine which writes the flash in 
SRAM.
This as actually the way most flash loaders work.
There are limitations in the number of write cycles which makes this 
somewhat less useful.
Atmel has a USB Mass Storage application which uses internal memory (as well 
as other methods)


> Regards.

-- 
Best Regards,
Ulf Samuelsson
ulf@a-t-m-e-l.com
This message is intended to be my own personal view and it
may or may not be shared by my employer Atmel Nordic AB 


0
Reply ulf495 (998) 5/8/2006 12:06:15 AM

In comp.arch.embedded jaac <jaime.aranguren@gmail.com> wrote:

> Is it possible to use the AT91SAM7S internal flash memory for general
> purpose non volatile storage?

Yes.

> I mean: suppose you have a buffer declared in C, like this:

> char myBuff[100];

No, doing it like this isn't going to be feasible.  The problem is
that C, as a programming language, has no concept of non-volatile
storage.  It only treats ordinary RAM and, to some extent, ROM (via
the 'const' qualifier).

> During program execution you write and read data from myBuff. Suddenly
> the system is powered off. 

That's where the problem presents itself most prominently.  C
generally gives you no control over how exactly it will access that
memory, so there's no way to preven the power from going off right in
the middle of a write access, leaving you with corrupted data.

A function-like interface to the NV buffer will work better in the
long run.

-- 
Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.
0
Reply broeker (1253) 5/8/2006 3:04:23 PM

Hans-Bernhard Broeker wrote:
> 
.... snip ...
> 
> No, doing it like this isn't going to be feasible.  The problem is
> that C, as a programming language, has no concept of non-volatile
> storage.  It only treats ordinary RAM and, to some extent, ROM (via
> the 'const' qualifier).

Yes it does.  It is called a FILE.

-- 
"They that can give up essential liberty to obtain a little
 temporary safety deserve neither liberty nor safety." 
                                        -- B. Franklin, 1759
"When I want to make a man look like an idiot, I quote him."
                                               -- Mark Twain
"I hear the voices."                    G W Bush, 2006-04-18


0
Reply cbfalconer (19183) 5/8/2006 5:44:03 PM

Hans-Bernhard Broeker wrote:
> In comp.arch.embedded jaac <jaime.aranguren@gmail.com> wrote:
>
> > Is it possible to use the AT91SAM7S internal flash memory for general
> > purpose non volatile storage?
>
> Yes.

How?

> > I mean: suppose you have a buffer declared in C, like this:
>
> > char myBuff[100];
>
> No, doing it like this isn't going to be feasible.  The problem is
> that C, as a programming language, has no concept of non-volatile
> storage.  It only treats ordinary RAM and, to some extent, ROM (via
> the 'const' qualifier).

Fully understood... The question in the "how, then?"

> > During program execution you write and read data from myBuff. Suddenly
> > the system is powered off.
>
> That's where the problem presents itself most prominently.  C
> generally gives you no control over how exactly it will access that
> memory, so there's no way to preven the power from going off right in
> the middle of a write access, leaving you with corrupted data.
>
> A function-like interface to the NV buffer will work better in the
> long run.

It would be very helpful if someone here (maybe Ulf Samuelson from
Atmel, or Hans-Bernhard, or somebody else) provides some code to start
with.

I understand that the compiler does not allow to do this directly, and
that I will need to write a custom routine to do it (like sending data
to an external EEPROM or Flash memory), but I don't know where to
start.

All your help is very welcome.

Regards.

JaaC

0
Reply jaime.aranguren (90) 5/9/2006 3:40:40 PM

"jaac" <jaime.aranguren@gmail.com> wrote in message
news:1147189240.482815.253220@e56g2000cwe.googlegroups.com...
> It would be very helpful if someone here (maybe Ulf Samuelson from
> Atmel, or Hans-Bernhard, or somebody else) provides some code to start
> with.
>
> I understand that the compiler does not allow to do this directly, and
> that I will need to write a custom routine to do it (like sending data
> to an external EEPROM or Flash memory), but I don't know where to
> start.

Well, I just did a similar thing for an ATmega162. And I started reading the
datasheet, which also provides code samples.

Couldn't find any code sample in the SAM datasheet though, but Atmel has an
application note where the SAM's flash is used as an USB drive, including
code.

Meindert


0
Reply ms159 (367) 5/9/2006 8:11:11 PM

"Meindert Sprang" <ms@NOJUNKcustomORSPAMware.nl> wrote in message 
news:1261tuap7t1hdc0@corp.supernews.com...
> "jaac" <jaime.aranguren@gmail.com> wrote in message
> news:1147189240.482815.253220@e56g2000cwe.googlegroups.com...
>> It would be very helpful if someone here (maybe Ulf Samuelson from
>> Atmel, or Hans-Bernhard, or somebody else) provides some code to start
>> with.
>>
>> I understand that the compiler does not allow to do this directly, and
>> that I will need to write a custom routine to do it (like sending data
>> to an external EEPROM or Flash memory), but I don't know where to
>> start.
>
> Well, I just did a similar thing for an ATmega162. And I started reading 
> the
> datasheet, which also provides code samples.
>
> Couldn't find any code sample in the SAM datasheet though, but Atmel has 
> an
> application note where the SAM's flash is used as an USB drive, including
> code.
>
> Meindert

Where is the code? Most I can get 
(http://www.at91.com/Pages/gettingstarted/samba/sam_ba/fourth.html) is this:

REMARK: THE MASS STORAGE & FILE SYSTEM PROJECT CAN BE DELIVERED UNDER NDA 
ONLY.

What can be downloaded is an .exe file, with some .bin and no source code

From the Atmel website 
(http://www.atmel.com/dyn/products/tools.asp?family_id=605), one gets this:

Demo for AT91 USB Mass Storage module and AT91 FAT File System module (72 
KB, updated 11/05)
- Can be downloaded here (click on icon)
- Download the User Guide (Mass Storage and File System Demo for 
AT91SAM7S-EK Development Board)
- Download the source code using a registration form

Clicking the last line sends one to:

http://www.at91.com/Pages/registration/wwwatmel/legal_terms.html

But selecting "I Agree to these terms" and then "Valid" leads to nowhere!!!

Can someone help?

Thanks 



*** Posted via a free Usenet account from http://www.teranews.com ***
0
Reply jaac (126) 5/10/2006 6:56:49 PM

8 Replies
39 Views

(page loaded in 0.141 seconds)


Reply: