Hi,
I am using Windows 7 (32bit), Eclipse Helios, Yagarto 2.20.1 with GCC 4.5.0, Zylin and OLIMEX ARM-USB-TINY-H JTAG debbuger. OpenOCD 0.4.0 for debbuging. This is connected to OLIMEX SAM7-P256 eval board with Atmel ARM7 core.
I am not able to download flash to the board through the openOCD
I am using libusb-win32 driver.
The problem is, that I do not know, how to make (customize a bit) .cfg file for OpenOCD in version 0.4.0.
There is a great manual how to do this for older version of OpenOCD:
http://gnuarm.alexthegeek.com/atmel/Usi ⌠sion_C.pdf
The old_version.cfg file looks like this:
#define our ports
telnet_port 4444
gdb_port 3333
#commands specific to the Olimex ARM-USB-OCD
interface ft2232
ft2232_device_desc "Olimex OpenOCD JTAG A"
ft2232_layout "olimex-jtag"
ft2232_vid_pid 0x15BA 0x0003
jtag_speed 2
jtag_nsrst_delay 200
jtag_ntrst_delay 200
#reset_config <signals> [combination] [trst_type] [srst_type]
reset_config srst_only srst_pulls_trst
#jtag_device <IR length> <IR capture> <IR mask> <IDCODE instruction>
jtag_device 4 0x1 0xf 0xe
#daemon_startup <'attach'|'reset'>
daemon_startup reset
#target <type> <endianess> <reset_mode> <jtag#> [variant]
target arm7tdmi little run_and_init 0 arm7tdmi_r4
#run_and_halt_time <target#> <time_in_ms>
run_and_halt_time 0 30
# commands below are specific to AT91sam7 Flash Programming
# ---------------------------------------------------------
#target_script specifies the flash programming script file
target_script 0 reset script.ocd
#working_area <target#> <address> <size> <'backup'|'nobackup'>
working_area 0 0x40000000 0x4000 nobackup
#flash bank at91sam7 0 0 0 0 <target#>
flash bank at91sam7 0 0 0 0 0
with the script.ocd file:
wait_halt # halt the processor and wait
armv4_5 core_state arm # select the core state
mww 0xffffff60 0x00320100 # set flash wait state (AT91C_MC_FMR)
mww 0xfffffd44 0xa0008000 # watchdog disable (AT91C_WDTC_WDMR)
mww 0xfffffc20 0xa0000601 # enable main oscillator (AT91C_PMC_MOR)
wait 100 # wait 100 ms
mww 0xfffffc2c 0x00480a0e # set PLL register (AT91C_PMC_PLLR)
wait 200 # wait 200 ms
mww 0xfffffc30 0x7 # set master clock to PLL (AT91C_PMC_MCKR)
wait 100 # wait 100 ms
mww 0xfffffd08 0xa5000401 # enable user reset AT91C_RSTC_RMR
flash write 0 main.bin 0x0 # program the onchip flash
reset # reset processor
shutdown # stop OpenOCD
However, this is not working with OpenOCD V 0.4.0.
If I run this script with:
openocd -f old_version.cfg
I will receive the error:
Runtime error, file "old_version.cfg", line 9
invalid command name "jtag_speed"
If I change the âjtag_speed 2â to the âjtag_khz 15000â I will receive the error:
Runtime error, file "old_version.cfg", line 9
invalid command name "jtag_device"
I have read the lot from âOpenOCD Userâs Guide.pdfâ and I found, that in C:\Program Files\OpenOCD\0.4.0\ there are some examples for OLIMEX ARM-USB-TINY-H as well as for at91sam7sx ARM core.
I tried to use these:
olimex-arm-usb-tiny-h.cfg and at91sam7sx.cfg
olimex-arm-usb-tiny-h.cfg:
interface ft2232
ft2232_device_desc "Olimex OpenOCD JTAG ARM-USB-TINY-H"
ft2232_layout olimex-jtag
ft2232_vid_pid 0x15ba 0x002a
at91sam7sx.cfg:
reset_config srst_only srst_pulls_trst
if { [info exists CHIPNAME] } {
set _CHIPNAME $CHIPNAME
} else {
set _CHIPNAME at91sam7s
}
if { [info exists ENDIAN] } {
set _ENDIAN $ENDIAN
} else {
set _ENDIAN little
}
if { [info exists CPUTAPID ] } {
set _CPUTAPID $CPUTAPID
} else {
set _CPUTAPID 0x3f0f0f0f
}
jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID
set _TARGETNAME $_CHIPNAME.cpu
target create $_TARGETNAME arm7tdmi -endian $_ENDIAN -chain-position $_TARGETNAME -variant arm7tdmi
$_TARGETNAME configure -event reset-init {
soft_reset_halt
# RSTC_CR : Reset peripherals
mww 0xfffffd00 0xa5000004
# disable watchdog
mww 0xfffffd44 0x00008000
# enable user reset
mww 0xfffffd08 0xa5000001
# CKGR_MOR : enable the main oscillator
mww 0xfffffc20 0x00000601
sleep 10
# CKGR_PLLR: 96.1097 MHz
mww 0xfffffc2c 0x00481c0e
sleep 10
# PMC_MCKR : MCK = PLL / 2 ~= 48 MHz
mww 0xfffffc30 0x00000007
sleep 10
# MC_FMR: flash mode (FWS=1,FMCN=73)
mww 0xffffff60 0x00490100
sleep 100
}
$_TARGETNAME configure -work-area-phys 0x00200000 -work-area-size 0x4000 -work-area-backup 0
#flash bank <driver> <base_addr> <size> <chip_width> <bus_width> <target_number> [<target_name> <banks> <sectors_per_bank> <pages_per_sector> <page_size> <num_nvmbits> <ext_freq_khz>]
set _FLASHNAME $_CHIPNAME.flash
flash bank $_FLASHNAME at91sam7 0 0 0 0 0 0 0 0 0 0 0 0 18432
In script:
openocd -f olimex-arm-usb-tiny-h.cfg -f at91sam7sx.cfg
I received the error:
Open On-Chip Debugger 0.4.0 (2010-02-22-19:05)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.berlios.de/doc/doxygen/bugs.html
srst_only srst_pulls_trst srst_gates_jtag srst_open_drain
Warn : use 'at91sam7s.cpu' as target identifier, not '0'
Info : max TCK change to: 30000 kHz
Info : clock speed 30000 kHz
Info : JTAG tap: at91sam7s.cpu tap/device found: 0x7f1f1f1f (mfg: 0x78f, part: 0xf1f1, ver: 0x7)
Warn : JTAG tap: at91sam7s.cpu UNEXPECTED: 0x7f1f1f1f (mfg: 0x78f, part: 0xf1f1, ver: 0x7)
Error: JTAG tap: at91sam7s.cpu expected 1 of 1: 0x3f0f0f0f (mfg: 0x787, part: 0xf0f0, ver: 0x3)
Error: Trying to use configured scan chain anyway...
Error: at91sam7s.cpu: IR capture error; saw 0x03 not 0x01
Info : JTAG tap: at91sam7s.cpu tap/device found: 0x7f1f1f1f (mfg: 0x78f, part: 0xf1f1, ver: 0x7)
Warn : JTAG tap: at91sam7s.cpu UNEXPECTED: 0x7f1f1f1f (mfg: 0x78f, part: 0xf1f1, ver: 0x7)
Error: JTAG tap: at91sam7s.cpu expected 1 of 1: 0x3f0f0f0f (mfg: 0x787, part: 0xf0f0, ver: 0x3)
Error: Trying to use configured scan chain anyway...
Error: at91sam7s.cpu: IR capture error; saw 0x03 not 0x01
Command handler execution failed
Warn : jtag initialization failed; try 'jtag init' again.
Then I changed the olimex-arm-usb-tiny-h.cfg to:
interface ft2232
ft2232_device_desc "Olimex OpenOCD JTAG ARM-USB-TINY-H"
ft2232_layout olimex-jtag
ft2232_vid_pid 0x15ba 0x002a
jtag_khz 15000
jtag_nsrst_delay 200
jtag_ntrst_delay 200
and I received no errors at all:
Open On-Chip Debugger 0.4.0 (2010-02-22-19:05)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.berlios.de/doc/doxygen/bugs.html
15000 kHz
jtag_nsrst_delay: 200
jtag_ntrst_delay: 200
srst_only srst_pulls_trst srst_gates_jtag srst_open_drain
Warn : use 'at91sam7s.cpu' as target identifier, not '0'
Info : max TCK change to: 30000 kHz
Info : clock speed 15000 kHz
Info : JTAG tap: at91sam7s.cpu tap/device found: 0x3f0f0f0f (mfg: 0x787, part: 0xf0f0, ver: 0x3)
Info : Embedded ICE version 1
Info : at91sam7s.cpu: hardware has 2 breakpoint/watchpoint units
If I added the âshutdown # stop OpenOCDâ line at the end of at91sam7sx.cfg, I received no errors and the OpenOCD has finished:
C:\Program Files\OpenOCD\0.4.0\bin>openocd -f olimex-arm-usb-tiny-h.cfg -f at91s
am7sx.cfg
Open On-Chip Debugger 0.4.0 (2010-02-22-19:05)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.berlios.de/doc/doxygen/bugs.html
15000 kHz
jtag_nsrst_delay: 200
jtag_ntrst_delay: 200
srst_only srst_pulls_trst srst_gates_jtag srst_open_drain
Warn : use 'at91sam7s.cpu' as target identifier, not '0'
shutdown command invoked
Info : max TCK change to: 30000 kHz
Info : clock speed 15000 kHz
Info : JTAG tap: at91sam7s.cpu tap/device found: 0x3f0f0f0f (mfg: 0x787, part: 0
xf0f0, ver: 0x3)
Info : Embedded ICE version 1
Info : at91sam7s.cpu: hardware has 2 breakpoint/watchpoint units
C:\Program Files\OpenOCD\0.4.0\bin>
That is fine, because I know, that âOpenOCD - JTAG - Eval Boardâ works fine, with no errors.
However, how to flash the main.bin to the onchip flash?
in script.ocd there was:
flash write 0 main.bin 0x0 # program the onchip flash
what should flash the device.
but in at91sam7sx.cfg, there is nothing like that.
I tried to put the line âtarget_script 0 reset script.ocdâ somewhere in at91sam7sx.cfg, but I received the error, or nothing happened.
Any idea how to write main.bin to the onchip flash?
I have the correct main.bin, because I am able to flash it to the onchip flash with SAM-BA through the SAM-ICE and the leds are blinking. I used the example: âdemo_at91sam7_p64_blink_flashâ for compiling.
Thanks in advance.
Afi