OpenOCD 0.4.0 cofiguration for OLIMEX ARM-USB-TINY-H

Hello Ernest,

ernestw:
When you get these everything working to the point of the halt command then you can start to look at the specific instructions to flash the memory. At the moment OpenOCD is not working.

I’m still messing around with it.

ernestw:
Unfortunately I cannot get OpenOCD to find the FTDI device

-Did you try compiling the FTDI driver yourself?

(I did, and mine seems to blink the LED on the arm-usb-tiny-h JTAG interface, so I think it finds the device)

Update: I just looked in the ‘mylogfile.log’ and looked for the first occurring error; here it is…

Debug: 112 11 command.c:133 script_debug(): command - ocd_flash ocd_flash bank at91sam7s.flash 0 0 0 0 at91sam7s.cpu 12000000
Error: 114 11 tcl.c:802 handle_flash_bank_command(): target '12000000' not defined

Progress:

Changed the flash line to read:

flash bank $_FLASHNAME at91sam7 0 0 0 0 at91sam7s.cpu 12000000

Removed jtag_reset 0 0, as OpenOCD complained about it had to be after the init.

Changed the halt to exit (as halt lets OpenOCD stay resident and it eats up my CPU time)

Got errors when using ‘exit’, so changed to shutdown, and finally I got a status code 0 (no errors)

Messed around a little more, found out that I need the ‘halt’, as the log said “target not halted”, so I added the ‘halt’ back in before the shutdown.

Tried changing the flash line to read:

flash bank $_FLASHNAME at91sam7 0 0 0 0 $_TARGETNAME 0 0 0 0 0 0 0 18432

This also seems to produce a ‘no error’ code.

More progress… Found out I don’t need absolute paths, but paths relative to the scripts directory seems necessary:

openocd -d3 -l mylogfile.log -f interface/olimex-arm-usb-tiny-h.cfg -f target/at91sam7sx.cfg --command "init" --command "halt" --command "shutdown"
```(until now, both at91sam7sx.cfg and sam7x256.cfg gives me a successful exit; without any modifications)

I tried copying and pasting afinko's .cfg above again, but I get the following:

Error: status register: 0x30005
Error: Lock Error Bit Detected, Operation Abort
Error: error writing to flash at address 0x00100000 at offset 0x00000000 (-902)

(details from logfile:)

Debug: 479 2071 target.c:1488 target_read_u32(): address: 0xffffff68, value: 0x00030005
Debug: 480 2071 at91sam7.c:238 at91sam7_wait_status_busy(): status[0]: 0x30005
Error: 481 2071 at91sam7.c:242 at91sam7_wait_status_busy(): status register: 0x30005
Error: 482 2071 at91sam7.c:244 at91sam7_wait_status_busy(): Lock Error Bit Detected, Operation Abort
Error: 483 2071 core.c:76 flash_driver_write(): error writing to flash at address 0x00100000 at offset 0x00000000 (-902)
Debug: 484 2071 command.c:620 run_command(): Command failed with error code -902


I searched the net and found [[this thread](http://embdev.net/topic/129413). I think the key here is the line:

flash protect 0 0 1 off


Which I placed right here...

arm7_9 fast_memory_access enable
flash protect 0 0 1 off
wait_halt


...so I got the following:


Warn : srst pulls trst - can not reset into halted mode. Issuing halt after reset.
target state: halted
target halted in ARM state due to debug-request, current mode: System
cpsr: 0x8000005f pc: 0x001021e8
dcc downloads are enabled
fast memory access is enabled
cleared protection for sectors 0 through 1 on flash bank 0
flash ‘at91sam7’ found at 0x00100000
wrote 488 bytes from file main.bin to flash bank 0 at offset 0x00000000 in 0.042289s (11.269 kb/s)
shutdown command invoked


Seems something has changed. The mouse-driver which the board ships with no longer works. That's an indication that I wrote something to the flash. :)

-Why my LED does not flash is probably because I made a mistake in my code; but I believe I'm on the right track.

Sorry for the long post. I'll keep most of it here, in case other people find themselves stuck with one of my problems.

And when looking at the cfg from afinko, clearly it shows the line I just added, 5 lines later! =D](http://embdev.net/topic/129413)