public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] Running code from on-chip flash
@ 2009-09-27  3:28 Mandeep Sandhu
  2009-09-27 16:37 ` Andrew Lunn
  2009-09-30  7:50 ` Bob Brusa
  0 siblings, 2 replies; 8+ messages in thread
From: Mandeep Sandhu @ 2009-09-27  3:28 UTC (permalink / raw)
  To: ecos-discuss

Hi all,

I'm going to be using a real hardware for the first time (with ECOS).
The h/w is the Atmel AT91SAM7X512 SoC.

In order to save RAM, i'll be running the code from the on-chip flash
itself (512KB).

Now is it true that if my code resides on the flash, I will not be
able to write to it? I.e is the whole flash area is marked as
readonly?

Thanks,
-mandeep

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [ECOS] Running code from on-chip flash
  2009-09-27  3:28 [ECOS] Running code from on-chip flash Mandeep Sandhu
@ 2009-09-27 16:37 ` Andrew Lunn
  2009-09-30  7:58   ` Bob Brusa
  2009-09-30  7:50 ` Bob Brusa
  1 sibling, 1 reply; 8+ messages in thread
From: Andrew Lunn @ 2009-09-27 16:37 UTC (permalink / raw)
  To: Mandeep Sandhu; +Cc: ecos-discuss

On Sun, Sep 27, 2009 at 08:57:59AM +0530, Mandeep Sandhu wrote:
> Hi all,
> 
> I'm going to be using a real hardware for the first time (with ECOS).
> The h/w is the Atmel AT91SAM7X512 SoC.
> 
> In order to save RAM, i'll be running the code from the on-chip flash
> itself (512KB).
> 
> Now is it true that if my code resides on the flash, I will not be
> able to write to it?

Wrong. You just need to be careful where you write. The AT91SAM7X512
is also a bit easier since it has two controllers, so you could have
one controller for code and the other for data.

    Andrew


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [ECOS] Running code from on-chip flash
  2009-09-27  3:28 [ECOS] Running code from on-chip flash Mandeep Sandhu
  2009-09-27 16:37 ` Andrew Lunn
@ 2009-09-30  7:50 ` Bob Brusa
  2009-09-30  8:25   ` Mandeep Sandhu
  2009-09-30 10:35   ` Andrew Lunn
  1 sibling, 2 replies; 8+ messages in thread
From: Bob Brusa @ 2009-09-30  7:50 UTC (permalink / raw)
  To: Mandeep Sandhu, ecos-discuss

Am 27.09.2009, 05:27 Uhr, schrieb Mandeep Sandhu  
<mandeepsandhu.chd@gmail.com>:

> Hi all,
>
> I'm going to be using a real hardware for the first time (with ECOS).
> The h/w is the Atmel AT91SAM7X512 SoC.
>
> In order to save RAM, i'll be running the code from the on-chip flash
> itself (512KB).
>
> Now is it true that if my code resides on the flash, I will not be
> able to write to it? I.e is the whole flash area is marked as
> readonly?
>
> Thanks,
> -mandeep
>
Yes, its true. You will not be able to run tricks like self-modifying code  
that resides in flash. You would have to move such a routine to RAM and  
execute it there.
   Robert

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [ECOS] Running code from on-chip flash
  2009-09-27 16:37 ` Andrew Lunn
@ 2009-09-30  7:58   ` Bob Brusa
  0 siblings, 0 replies; 8+ messages in thread
From: Bob Brusa @ 2009-09-30  7:58 UTC (permalink / raw)
  To: Andrew Lunn, Mandeep Sandhu; +Cc: ecos-discuss

Am 27.09.2009, 18:37 Uhr, schrieb Andrew Lunn <andrew@lunn.ch>:

> On Sun, Sep 27, 2009 at 08:57:59AM +0530, Mandeep Sandhu wrote:
>> Hi all,
>>
>> I'm going to be using a real hardware for the first time (with ECOS).
>> The h/w is the Atmel AT91SAM7X512 SoC.
>>
>> In order to save RAM, i'll be running the code from the on-chip flash
>> itself (512KB).
>>
>> Now is it true that if my code resides on the flash, I will not be
>> able to write to it?
>
> Wrong. You just need to be careful where you write. The AT91SAM7X512
> is also a bit easier since it has two controllers, so you could have
> one controller for code and the other for data.
>
>     Andrew
>
>
....and make sure that while you are fiddeling around in one bunch of  
flash, interrupts are either off or interrupts do not use code from this  
same bunch of flash....
   Robert

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [ECOS] Running code from on-chip flash
  2009-09-30  7:50 ` Bob Brusa
@ 2009-09-30  8:25   ` Mandeep Sandhu
  2009-09-30  9:19     ` Robin Randhawa
  2009-09-30 10:35   ` Andrew Lunn
  1 sibling, 1 reply; 8+ messages in thread
From: Mandeep Sandhu @ 2009-09-30  8:25 UTC (permalink / raw)
  To: bob.brusa; +Cc: ecos-discuss

On Wed, Sep 30, 2009 at 1:20 PM, Bob Brusa <bob.brusa@gmail.com> wrote:
> Am 27.09.2009, 05:27 Uhr, schrieb Mandeep Sandhu
> <mandeepsandhu.chd@gmail.com>:
>
>> Hi all,
>>
>> I'm going to be using a real hardware for the first time (with ECOS).
>> The h/w is the Atmel AT91SAM7X512 SoC.
>>
>> In order to save RAM, i'll be running the code from the on-chip flash
>> itself (512KB).
>>
>> Now is it true that if my code resides on the flash, I will not be
>> able to write to it? I.e is the whole flash area is marked as
>> readonly?
>>
>> Thanks,
>> -mandeep
>>
> Yes, its true. You will not be able to run tricks like self-modifying code
> that resides in flash. You would have to move such a routine to RAM and
> execute it there.

Ok, I'm confused now!

Andrew mentioned that I _could_ write to a different area of the flash
(i.e different from the one from where the code is running).

To give an example, say I have to do a firmware upgrade. Now I
download the image from, say an ethernet interface, and keep writing
chunks of it (since the whole firmware image won't fit in my RAM of
128KB) to a "well-known" safe area on the flash.

Wont this work?

I'm not going to be modifying my code segment at all.

Thanks,
-mandeep


>  Robert
>

--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [ECOS] Running code from on-chip flash
  2009-09-30  8:25   ` Mandeep Sandhu
@ 2009-09-30  9:19     ` Robin Randhawa
  2009-09-30 10:36       ` Mandeep Sandhu
  0 siblings, 1 reply; 8+ messages in thread
From: Robin Randhawa @ 2009-09-30  9:19 UTC (permalink / raw)
  To: Mandeep Sandhu; +Cc: ecos-discuss

Hi.

On 30 Sep 2009, at 09:25, Mandeep Sandhu wrote:

> On Wed, Sep 30, 2009 at 1:20 PM, Bob Brusa <bob.brusa@gmail.com>  
> wrote:
>> Am 27.09.2009, 05:27 Uhr, schrieb Mandeep Sandhu
>> <mandeepsandhu.chd@gmail.com>:
>>
>>> Hi all,
>>>
>>> I'm going to be using a real hardware for the first time (with  
>>> ECOS).
>>> The h/w is the Atmel AT91SAM7X512 SoC.
>>>
>>> In order to save RAM, i'll be running the code from the on-chip  
>>> flash
>>> itself (512KB).
>>>
>>> Now is it true that if my code resides on the flash, I will not be
>>> able to write to it? I.e is the whole flash area is marked as
>>> readonly?
>>>
>>> Thanks,
>>> -mandeep
>>>
>> Yes, its true. You will not be able to run tricks like self- 
>> modifying code
>> that resides in flash. You would have to move such a routine to RAM  
>> and
>> execute it there.
>
> Ok, I'm confused now!
>
> Andrew mentioned that I _could_ write to a different area of the flash
> (i.e different from the one from where the code is running).
>
> To give an example, say I have to do a firmware upgrade. Now I
> download the image from, say an ethernet interface, and keep writing
> chunks of it (since the whole firmware image won't fit in my RAM of
> 128KB) to a "well-known" safe area on the flash.

IMHO, this is subject to the Flash part's abilities. I have worked  
with NOR Flash parts in the past where it was possible to run code  
from one sector while erasing/programming another sector. I suppose  
that the AT91SAM7X512's manuals and/or the Flash part manufacturer's  
manuals should shed light on this.

Bear in mind that the Flash chips might need a sector's worth of data  
to be buffered in RAM before writing to the sector in one go.

Cheers,
Robin

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [ECOS] Running code from on-chip flash
  2009-09-30  7:50 ` Bob Brusa
  2009-09-30  8:25   ` Mandeep Sandhu
@ 2009-09-30 10:35   ` Andrew Lunn
  1 sibling, 0 replies; 8+ messages in thread
From: Andrew Lunn @ 2009-09-30 10:35 UTC (permalink / raw)
  To: Bob Brusa; +Cc: Mandeep Sandhu, ecos-discuss

> Yes, its true. You will not be able to run tricks like
> self-modifying code that resides in flash. You would have to move
> such a routine to RAM and execute it there.

eCos FLASH routines are already magically in RAM. 

Also the AT91SAM7 devices have a flash controller which handles most
of the details and does most of the work for you. It can halt the CPU
while writing to FLASH if it needs to be halted because it tries to
make an access while the write operation is active.

As usual, the datasheet and the source code is the definitive source
of information.

   Andrew

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [ECOS] Running code from on-chip flash
  2009-09-30  9:19     ` Robin Randhawa
@ 2009-09-30 10:36       ` Mandeep Sandhu
  0 siblings, 0 replies; 8+ messages in thread
From: Mandeep Sandhu @ 2009-09-30 10:36 UTC (permalink / raw)
  To: Robin Randhawa; +Cc: ecos-discuss

On Wed, Sep 30, 2009 at 2:49 PM, Robin Randhawa
<robin.randhawa@gmail.com> wrote:
> Hi.
>
> On 30 Sep 2009, at 09:25, Mandeep Sandhu wrote:
>
>> On Wed, Sep 30, 2009 at 1:20 PM, Bob Brusa <bob.brusa@gmail.com> wrote:
>>>
>>> Am 27.09.2009, 05:27 Uhr, schrieb Mandeep Sandhu
>>> <mandeepsandhu.chd@gmail.com>:
>>>
>>>> Hi all,
>>>>
>>>> I'm going to be using a real hardware for the first time (with ECOS).
>>>> The h/w is the Atmel AT91SAM7X512 SoC.
>>>>
>>>> In order to save RAM, i'll be running the code from the on-chip flash
>>>> itself (512KB).
>>>>
>>>> Now is it true that if my code resides on the flash, I will not be
>>>> able to write to it? I.e is the whole flash area is marked as
>>>> readonly?
>>>>
>>>> Thanks,
>>>> -mandeep
>>>>
>>> Yes, its true. You will not be able to run tricks like self-modifying
>>> code
>>> that resides in flash. You would have to move such a routine to RAM and
>>> execute it there.
>>
>> Ok, I'm confused now!
>>
>> Andrew mentioned that I _could_ write to a different area of the flash
>> (i.e different from the one from where the code is running).
>>
>> To give an example, say I have to do a firmware upgrade. Now I
>> download the image from, say an ethernet interface, and keep writing
>> chunks of it (since the whole firmware image won't fit in my RAM of
>> 128KB) to a "well-known" safe area on the flash.
>
> IMHO, this is subject to the Flash part's abilities. I have worked with NOR
> Flash parts in the past where it was possible to run code from one sector
> while erasing/programming another sector. I suppose that the AT91SAM7X512's
> manuals and/or the Flash part manufacturer's manuals should shed light on
> this.
>
> Bear in mind that the Flash chips might need a sector's worth of data to be
> buffered in RAM before writing to the sector in one go.

Thanks. I'll go through the manual in detail. As Andrew mentioned, it
has 2 flash controllers, where one can be used to control the sector
which has RO data (code seg), while I can use the other controller to
write to it.

-mandeep

>
> Cheers,
> Robin
>

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-09-30 10:36 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-27  3:28 [ECOS] Running code from on-chip flash Mandeep Sandhu
2009-09-27 16:37 ` Andrew Lunn
2009-09-30  7:58   ` Bob Brusa
2009-09-30  7:50 ` Bob Brusa
2009-09-30  8:25   ` Mandeep Sandhu
2009-09-30  9:19     ` Robin Randhawa
2009-09-30 10:36       ` Mandeep Sandhu
2009-09-30 10:35   ` Andrew Lunn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).