OpenOCD flash programming SAM7-P256 AT91S

Hello. I have recently received an Olimex SAM7-P256 development board with an Atmel AT91SAM7S256. I have also received an OCD-USB-TINY which I would like to use with the YAGARTO (or similar) toolchain.I am powering the board from an external 5V DC supply. (WinXPSp2, I gave up on using my linux box a week ago)

I have managed to connect to the OCD-USB-TINY using openocd and a custom config file, but have been unable to program or even attempt to program by all accounts.

Any comments are appreciated.

openocd_at91sam7s_flash_ftdi.cfg

#
# Flash AT91SAM7S memory using openocd 
# and a FTDI FT2232-based JTAG-interface
#
# created by Martin Thomas 
# based on information from Dominic Rath
#

#daemon configuration
telnet_port 4444
gdb_port 3333

#interface
interface ft2232
ft2232_device_desc "Olimex OpenOCD JTAG TINY A"
ft2232_layout "olimex-jtag"
ft2232_vid_pid 0x15BA 0x0004
jtag_speed 0
jtag_nsrst_delay 200
jtag_ntrst_delay 200

#use combined on interfaces or targets that can't set TRST/SRST separately
reset_config srst_only srst_pulls_trst

#jtag scan chain
#format L IRC IRCM IDCODE (Length, IR Capture, IR Capture Mask, IDCODE)
jtag_device 4 0x1 0xf 0xe

#target configuration
daemon_startup reset

#target  
#target arm7tdmi    
target arm7tdmi little run_and_init 0 arm7tdmi
run_and_halt_time 0 30

# flash-options AT91
target_script 0 reset openocd_at91sam7s_flash.script
working_area 0 0x00200000 0x4000 nobackup
flash bank at91sam7 0 0 0 0 0

# For more information about the configuration files, take a look at:
# http://openfacts.berlios.de/index-en.phtml?title=Open+On-Chip+Debugger

openocd_at91sam7s_flash.script

# 
# The following commands will be executed on
# reset (because of run_and_init in the config-file)
# - halt target
# - init ecr
# - flash content of file main.bin into target-memory
# - shutdown openocd
#
# created by Martin Thomas 
# http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects
# based on information from Dominic Rath 
#

halt
sleep 10

# Init - taken form the script openocd_at91sam7_ecr.script 
mww 0xfffffd44 0x00008000	# disable watchdog
mww 0xfffffd08 0xa5000001	# enable user reset
mww 0xfffffc20 0x00000601	# CKGR_MOR : enable the main oscillator
sleep 10
mww 0xfffffc2c 0x00481c0e 	# CKGR_PLLR: 96.1097 MHz
sleep 10
mww 0xfffffc30 0x00000007	# PMC_MCKR : MCK = PLL / 2 ~= 48 MHz
sleep 10
mww 0xffffff60 0x003c0100	# MC_FMR: flash mode (FWS=1,FMCN=60)
# arm7_9 force_hw_bkpts enable	# program resides in flash

# AT91SAM7 flash command-"batch"
# adapted by Martin Thomas based on information from Dominic Rath - Thanks
arm7_9 dcc_downloads enable
sleep 10
poll
flash probe 0
flash write 0 main.bin 0x0
# flash write is deprecated but still available. 
# Update to flash write_binary 0 main.bin 0x0
reset run
sleep 10
shutdown

Here’s the result, i see red flashing on the device, but the embeddedice_read_reg_w_check just runs forever.

C:\Program Files\openocd-r247\bin>openocd-ftd2xx.exe --debug 3 -f openocd_at91sam7s_flash_ftdi.cfg
Info:    openocd.c:93 main(): Open On-Chip Debugger (2007-12-30 17:00 CET) svn:
247
Info:    openocd.c:94 main(): $URL: http://svn.berlios.de/svnroot/repos/openocd/
trunk/src/openocd.c $
Debug:   jtag.c:1409 jtag_init(): -
Debug:   ft2232.c:1336 ft2232_init_ftd2xx(): 'ft2232' interface using FTD2XX with 'olimex-jtag' layout (15ba:0004)
Debug:   ft2232.c:1425 ft2232_init_ftd2xx(): current latency timer: 2
Debug:   ft2232.c:1772 olimex_jtag_init(): 80 (oh eight) 1b
Debug:   ft2232.c:1815 olimex_jtag_init(): 82 09 0f
Debug:   ft2232.c:258 ft2232_speed(): 86 00 00
Debug:   jtag.c:295 jtag_call_event_callbacks(): jtag event: TRST asserted
Debug:   jtag.c:1197 jtag_reset_callback(): -
Debug:   jtag.c:295 jtag_call_event_callbacks(): jtag event: TRST asserted
Debug:   jtag.c:1197 jtag_reset_callback(): -
Info:    jtag.c:1291 jtag_examine_chain(): JTAG device found: 0x3f0f0f0f (Manufacturer: 0x787, Part: 0xf0f0, Version: 0x3)
Debug:   jtag.c:295 jtag_call_event_callbacks(): jtag event: TRST asserted
Debug:   jtag.c:1197 jtag_reset_callback(): -
Debug:   openocd.c:114 main(): jtag init complete
Debug:   embeddedice.c:220 embeddedice_read_reg_w_check(): 4
Debug:   jtag.c:295 jtag_call_event_callbacks(): jtag event: TRST released
Debug:   jtag.c:1197 jtag_reset_callback(): -
Debug:   arm7_9_common.c:715 arm7_9_assert_reset(): target->state: unknown
Debug:   jtag.c:295 jtag_call_event_callbacks(): jtag event: SRST asserted
Debug:   jtag.c:1197 jtag_reset_callback(): -
Debug:   jtag.c:295 jtag_call_event_callbacks(): jtag event: TRST asserted
Debug:   jtag.c:1197 jtag_reset_callback(): -
Warning: arm7_9_common.c:742 arm7_9_assert_reset(): srst resets test logic, too
Debug:   jtag.c:295 jtag_call_event_callbacks(): jtag event: SRST asserted
Debug:   jtag.c:1197 jtag_reset_callback(): -
Debug:   jtag.c:295 jtag_call_event_callbacks(): jtag event: TRST asserted
Debug:   jtag.c:1197 jtag_reset_callback(): -
Debug:   ft2232.c:1000 olimex_jtag_reset(): trst: 0, srst: 1, high_output: 0x03, high_direction: 0x0f
Debug:   ft2232.c:1000 olimex_jtag_reset(): trst: 0, srst: 1, high_output: 0x03, high_direction: 0x0f
Debug:   arm7_9_common.c:781 arm7_9_deassert_reset(): target->state: reset
Debug:   jtag.c:295 jtag_call_event_callbacks(): jtag event: SRST released
Debug:   jtag.c:1197 jtag_reset_callback(): -
Debug:   ft2232.c:1000 olimex_jtag_reset(): trst: 0, srst: 0, high_output: 0x09, high_direction: 0x0f
Debug:   openocd.c:118 main(): target init complete
Debug:   openocd.c:122 main(): flash init complete
Debug:   openocd.c:126 main(): NAND init complete
Debug:   openocd.c:130 main(): pld init complete
Debug:   gdb_server.c:1807 gdb_init(): gdb service for target arm7tdmi at port 3333
Debug:   embeddedice.c:220 embeddedice_read_reg_w_check(): 1
Debug:   jtag.c:295 jtag_call_event_callbacks(): jtag event: TRST released
Debug:   jtag.c:1197 jtag_reset_callback(): -
Debug:   arm7_9_common.c:937 arm7_9_halt(): target->state: running
Debug:   embeddedice.c:384 embeddedice_write_reg(): 9: 0xffffffff
Debug:   embeddedice.c:384 embeddedice_write_reg(): 11: 0xffffffff
Debug:   embeddedice.c:384 embeddedice_write_reg(): 12: 0x00000100
Debug:   embeddedice.c:384 embeddedice_write_reg(): 13: 0x000000f7
Debug:   embeddedice.c:220 embeddedice_read_reg_w_check(): 4
Debug:   embeddedice.c:220 embeddedice_read_reg_w_check(): 4
Debug:   embeddedice.c:220 embeddedice_read_reg_w_check(): 4
Debug:   embeddedice.c:220 embeddedice_read_reg_w_check(): 4
Debug:   embeddedice.c:220 embeddedice_read_reg_w_check(): 4
Debug:   embeddedice.c:220 embeddedice_read_reg_w_check(): 4
Debug:   embeddedice.c:220 embeddedice_read_reg_w_check(): 4
Debug:   embeddedice.c:220 embeddedice_read_reg_w_check(): 1
Debug:   embeddedice.c:220 embeddedice_read_reg_w_check(): 4
Debug:   embeddedice.c:220 embeddedice_read_reg_w_check(): 4
Debug:   embeddedice.c:220 embeddedice_read_reg_w_check(): 4

Try to lower the JTAG speed in openocd_at91sam7s_flash_ftdi.cfg

jtag_speed 10 ( higher values are slower)

Regards,

Magnus

Increasing the jtag_speed seems to have no effect. Also I misspoke earlier I have a ARM-USB-TINY not a OCD-USB-TINY.

I wonder why nothing is happening?

It was the BDS jumper on the dev board. I thought I tried that, but this time it worked.

C:\Program Files\openocd-r247\bin>openocd-ftd2xx.exe -f openocd_at91sam7s_flash_ftdi.cfg
Info:    openocd.c:93 main(): Open On-Chip Debugger (2007-12-30 17:00 CET) svn:247
Info:    openocd.c:94 main(): $URL: http://svn.berlios.de/svnroot/repos/openocd/trunk/src/openocd.c $
Info:    jtag.c:1291 jtag_examine_chain(): JTAG device found: 0x3f0f0f0f (Manufacturer: 0x787, Part: 0xf0f0, Version: 0x3)
Warning: arm7_9_common.c:742 arm7_9_assert_reset(): srst resets test logic, too
Info:    target.c:233 target_init_handler(): executing reset script 'openocd_at91sam7s_flash.script'
Info:    configuration.c:50 configuration_output_handler(): requesting target halt...
Warning: arm7_9_common.c:941 arm7_9_halt(): target was already halted
Info:    configuration.c:50 configuration_output_handler(): target already halted
Info:    configuration.c:50 configuration_output_handler(): dcc downloads are enabled
Info:    configuration.c:50 configuration_output_handler(): target state: halted

Info:    configuration.c:50 configuration_output_handler(): target halted in ARM state due to debug request, current mode: Supervisor
Info:    configuration.c:50 configuration_output_handler(): cpsr: 0x600000d3 pc: 0x0000028c
Info:    configuration.c:50 configuration_output_handler(): flash 'at91sam7' found at 0x00100000
Info:    configuration.c:50 configuration_output_handler(): wrote  4964 byte from file main.bin to flash bank 0 at offset 0x00000000 in 11s 171875us (0.433916 kb/s)
Warning: arm7_9_common.c:742 arm7_9_assert_reset(): srst resets test logic, too

Hi all,

I have the same problem on Windows Vista. I’m using openOCD 204, ARM-USB-TINY. Here’s what I get:

Error: ft2232.c:1341 ft2232_init_ftd2xx(): unable to open ftdi device: 2

Error: ft2232.c:1356 ft2232_init_ftd2xx(): ListDevices: 2

Error: ft2232.c:1358 ft2232_init_ftd2xx(): 0: Olimex OpenOCD JTAG TINY B

Error: ft2232.c:1358 ft2232_init_ftd2xx(): 1: Xš:

This is the part of the config that matters:

#interface

interface ft2232

ft2232_device_desc “Olimex OpenOCD JTAG TINY A”

ft2232_layout “olimex-jtag”

ft2232_vid_pid 0x15BA 0x0004

jtag_speed 20

What is the solution?

Thanks,

Gil

Problem solved with this config:

telnet_port 4444

gdb_port 3333

interface ft2232

ft2232_device_desc “Olimex OpenOCD JTAG TINY A”

ft2232_layout “olimex-jtag”

ft2232_vid_pid 0x15BA 0x0004

jtag_speed 20

reset_config trst_and_srst separate

jtag_device 4 0x1 0xf 0xe

jtag_nsrst_delay 333

jtag_ntrst_delay 333

daemon_startup reset

target arm7tdmi little run_and_halt 0 arm7tdmi-s_r4

run_and_halt_time 0 30

target_script 0 reset oocd_flash2294.script

working_area 0 0x40000000 0x4000 nobackup

flash bank lpc2000 0x0 0x40000 0 0 0 lpc2000_v1 14746 calc_checksum

Thanks,

Gil