Forum: ARM programming with GCC/GNU tools OpenOCD/GDB AT91SAM7

Author: Mike Sutton (epic)
Posted on:

Rate this post
0 useful
not useful
I'm stumped trying to get things working on a Olimex AT91SAM7-P256 
evaluation board.

Here's the setup:
* Olimex SAM7-Pxxx evaluation board
* Using OpenOCD 0.3.1 2009-11-13
* Running YAGARTO 

I'm trying to get the example blinker program from Peter Lynch's 
tutorial running (that tutorial is quite old).  It looks like OpenOCD 
has been extensively modified.

I'm able to compile and link the example.

I'm able to run OpenOCD.

I'm able to run GDB and load the file and run to a break point placed at 
the start of main().

However, when I get there, the program doesn't seem to really modify any 
of the memory.  For example, there is a variable that is in memory 
location 0xfe20.  I try to set that variable to some value and it always 
ends up reading back -1.

Here is the script that I'm using for gdb:

#copy this to the init command box in Eclipse Gdb settings

target remote localhost:3333
monitor reset
monitor sleep 500
monitor poll
monitor soft_reset_halt
#monitor arm7_9 sw_bkpts enable
monitor gdb_breakpoint_override hard

# select the core state
monitor armv4_5 core_state arm

# WDT_MR, disable watchdog
monitor mww 0xFFFFFD44 0xa0008000

# RSTC_MR, enable user reset
monitor mww 0xfffffd08 0xa5000401

monitor mww 0xFFFFFC20 0x00000601
monitor sleep 100

monitor mww 0xFFFFFC2C 0x00480a0e
monitor sleep 200

monitor mww 0xFFFFFC30 0x00000007
monitor sleep 100

# PMC_IER, set flash wait state (AT91C_MC_FMR)
monitor mww 0xffffff60 0x00320100
monitor sleep 100

#Go ahead
break main

Author: Mike Sutton (epic)
Posted on:

Rate this post
0 useful
not useful
After working on this into the wee hours of the morning last night, I 
finally figured out what was going on.

The AT91SAM7 remaps the first part of memory.  It can be either flash or 
RAM.  After boot up it is flash and must be remapped to be RAM.  I was 
trying to save variables to flash.

To fix things, all I had to do was add a line in the gdb configuration 
script which remaps that first section of memory to RAM:

# remap 0x0 memory to RAM
monitor mww 0xffffff00 0x1
monitor sleep 100

Since I spent more time on this than I would have liked, I decided to 
create a little HOWTO that collects a lot of the information that is 
already out there into one spot.

The HOWTO is at:


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.