EmbDev.net

Forum: ARM programming with GCC/GNU tools Write to flash


Author: Martin Gajdusek (martin-ga)
Posted on:

Rate this post
0 useful
not useful
Hi,
I'm starting with the WinArm and try to find some example with writing
data to flash memory. I place my Flash_write function into RAM but
program frozen when I try to write anything into flash, but information
is stored correctly! Under IAR EW I don't have problem. Thanks for any
suggestion
Martin

Author: Stefan (Guest)
Posted on:

Rate this post
0 useful
not useful
Which µC and which Flash?

I need code for µC AT91R40008 and Flash-ROM AT49BV322A in order to build
a GPS datalogger.

Perhaps we can work this out together?

Author: Martin Gajdusek (martin-ga)
Posted on:

Rate this post
0 useful
not useful
Stefan wrote:
> Which µC and which Flash?
>
> I need code for µC AT91R40008 and Flash-ROM AT49BV322A in order to build
> a GPS datalogger.
>
> Perhaps we can work this out together?

I'm using AT91SAM7S64 and I mean internal on-chip flash not external.
Unfortunately I don't have any experiances with external flash.

Martin

Author: Stefan (Guest)
Posted on:

Rate this post
0 useful
not useful
OK. Some general hints for debugging (from
http://www.mikrocontroller.net/forum/read-2-187912.html)

- switch code optimizing off
- try to compile without thumb-interwork
- try newer or newest WINARM version or GNUARM
- is the bug related to the return from the ramfunc or to the flash
write? Check with non flash writing ramfunc. Perhaps you tried this test
already ("I try to write anything into flash, but information is stored
correctly!") and i didn't get it.

Author: Clifford Slocombe (clifford)
Posted on:

Rate this post
0 useful
not useful
Martin Gajdusek wrote:
> I place my Flash_write function into RAM but
> program frozen when I try to write anything into flash, but information
> is stored correctly! Under IAR EW I don't have problem. Thanks for any
> suggestion

"Program frozen" is not very informative. Has the processor generated an
exception, stuck polling an event that never occurs or what? You need to
determine what it is doing and how it got there.

Such events can occur for many reasons, and are no doubt down to the
code you are using. It is not uncommon for faulty code to appear to work
on won compiler and not another - if for example it is due to accessing
uninitialised data or out-of-bounds access, the results will depend on
what gets stomped on or the value of the invalid data - this is likley
to be different because of the compiler's different code generation and
code location.

Presumably if you call the Flash_write() function, and it does not
return, but the data is still written, then teh problem occurs late in
the code (after the actual write process). Possibly you are corrupting
the return stack with an out of bounds array access on a local variable,
or exceeding its maximum size and stomping on the static data or code
space. This will typically cause the code to 'return' to the wrong
address. If this address is not MMU mapped, a data abort will occur.
Even if it is MMU mapped, the 'code' at sich a location is unlikely to
make any sense and an abort would occur in any case.

If you have debug hardware, this should be easy to determine. If not,
then toggling some I/O in the exception handler and monitoring it with a
scope or an LED will at least tell you that the exception has occurred.

Clifford

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.