EmbDev.net

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


von Mike S. (epic)


Rate this post
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
* ARM-USB-TINY JTAG
* Using OpenOCD 0.3.1 2009-11-13
* Running YAGARTO 
(yagarto-bu-2.20_gcc-4.4.2-c-c++_nl-1.18.0_gdb-7.0.1_20091223.exe)

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

# CKGR_MOR
monitor mww 0xFFFFFC20 0x00000601
monitor sleep 100

# CKGR_PLLR
monitor mww 0xFFFFFC2C 0x00480a0e
monitor sleep 200

# PMC_MCKR
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
load
break main
continue

von Mike S. (epic)


Rate this post
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:
http://clearboxsolutions.com/index.php?option=com_content&view=article&id=8:microcontroller-development-environment-using-open-source-tools&catid=5:microcontrollers&Itemid=15

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.