Zelf gebruik ik de WinARM omgeving, ARM-USB-OCD en Ecllipse ook (voor een LPC2148, maar voor de 2106 geld denk ik het zelfde).
Dat het verwarrent in elkaar zit heb ik ook gemerkt. Ben er zelf ook een tijd mee bezig geweest voordat ik alles draaiend had. Nu heb ik dit net vorige week weer moeten doen, want vorige maand is mijn PC naar de eeuwige jachtvelden vertrokken (MB kappot, gelukkig de HD en data niet) en ik was toch toe aan een nieuwe, dus maar een nieuw systeem gekocht.
Maar ik gebruikte altijd een parallele poort programmer (zelfgemaakte wriggler) en mijn nieuwe PC heeft geen PP meer. Dan maar de ARM-USB-OCD kopen en 'even' installeren.
Nauw, dat installeren duurde iets langer dan gedacht. Vooral de verschillende versies van OpenOCD waarbij de syntax veranderd is. Erg lastig.
Maar om een kort verhaal nog iets langer te maken, dit is wat ik (zo uit mijn hoofd) heb gedaan:
- OpenOCD intstalleren (via yagarto: http://www.yagarto.de/download/openocd/openocd-r717-20080619.exe)
- WinArm geinstallerd (http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/WinARM-200…) Deze kan je gewoon op c:\ uitpakken.
- Ecllipse geinstallerd (IDE for C/C++ via http://www.eclipse.org/). Voor installatie heb geloof ik de handleiding van yagarto gevolgd.
- Paden goed gezet (dus de %PATH%).
Nu kon ik eindelijk compileren. Proggen ging nog niet.
Na het uitproberen van verschillende soorten config files en 'reset' scripts ben ik achter 2 zaken gekomen die erg vervelend zijn:
1. een aantal commando's in de scripts zijn vervangen, o.a. de 'flash write' in 'flash write_binary'.
2. Ik had mijn LPC2148 in een staat gebracht, zodat i niet meer te proggen was via de jtag. Ik heb toen via de FlashMagic tool (http://www.flashmagictool.com/) het device volledig ge-erased. Daarna werkte de JTAG prima!
Ik prog niet vanuit Eclipse, maar heb een batch file + config + script die in de source dir staat van mijn eclipse project:
Batch file prog.cmd:
@echo programing flash...
@REM @openocd-pp -f prog-flash.cfg
openocd-ftd2xx -f prog-flash-usb.cfg
@echo Done.
config file prog-flash.cfg:
#
# Flash LPC2138 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 "Amontec JTAGkey A"
ft2232_layout jtagkey
ft2232_vid_pid 0x0403 0xcff8
jtag_speed 3
jtag_nsrst_delay 200
jtag_ntrst_delay 200
#use combined on interfaces or targets that can't set TRST/SRST separately
reset_config trst_and_srst 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-s_r4
run_and_halt_time 0 30
# flash-options LPC2138
working_area 0 0x40000000 0x4000 nobackup
target_script 0 reset openocd_lpc2138_flash.script
# LPC2138 @ 12MHz / 0x7D000 from 500*1024 (not 512!)
## up to version SVN188:
#flash bank lpc2000 0x0 0x7D000 0 0 lpc2000_v2 0 12000 calc_checksum
## from Version SVN189:
flash bank lpc2000 0x0 0x7D000 0 0 0 lpc2000_v2 12000 calc_checksum
# For more information about the configuration files, take a look at:
# http://openfacts.berlios.de/index-en.phtml?title=Open+On-Chip+Debugger
script file openocd_lpc2138_flash.script
#
# The following commands will be executed on
# reset (because of run_and_init in the config-file)
# - wait for target halt
# - erase memory
# - 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
#
arm7_9 dcc_downloads enable
wait_halt
sleep 500
poll
flash probe 0
sleep 500
# erase first bank only:
flash erase_sector 0 0 26
sleep 500
# erase all banks:
# flash erase 0 0 26
# if flash erase is not longer available in your OpenOCD-version use
# flash erase_sector
flash write_bank 0 main.bin 0x0
sleep 500
# flash write is deprecated and my not be available in your OpenOCD-version, update to:
# flash write_binary 0 main.bin 0x0
# flash write_binary is deprecated and my not be available in your OpenOCD-version, update to:
# flash write_bank 0 main.bin 0x00
# also check flash write_image which can be uses together with flash auto_erase on
reset run
sleep 10
shutdown
Dit zou in principe ook met de complete yagarto omgeving moeten werken (ik gebruik WinARM omdat daar de newlib bij inzit).
Inmiddels heb ik vanmiddag ook nog een keer met crossworks geprobeerd, maar ook dit heeft niets opgeleverd helaas.
Nu weer gewoon verder in Eclipse, waar ik wel al kan compilen. Met Flash Magic moet ik dan zelf de hex file inladen.
Maargoed het blijft frustrerend dat ik JTAG niet aan de praat krijg op het Olimex lpc-p2378 board
Mijn cfg file ziet er nu als volgt uit:
#daemon configuration
telnet_port 4444
gdb_port 3333
#interface
interface ft2232
ft2232_device_desc "Olimex OpenOCD JTAG A"
ft2232_layout "olimex-jtag"
ft2232_vid_pid 0x15BA 0x0003
jtag_speed 30
jtag_nsrst_delay 200
jtag_ntrst_delay 200
#use combined on interfaces or targets that can't set TRST/SRST separately
reset_config trst_and_srst separate
#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 <type> <startup mode>
#target arm7tdmi <reset mode> <chainpos> <endianness> <variant>
target arm7tdmi little run_and_halt 0 arm7tdmi-s_r4
run_and_halt_time 0 30
target_script 0 reset openocd_flash_lpc2378.script
working_area 0 0x40000000 0x7fff nobackup
#flash configuration
#flash bank lpc2000 0x0 0x40000 0 0 0 lpc2000_v1 14746 calc_checksum
flash bank lpc2000 0x0 0x80000 0 0 0 lpc2000_v2 12000 calc_checksum
#flash bank cfi 0x80000000 0x800000 2 2 0
# For more information about the configuration files, take a look at:
# http://openfacts.berlios.de/index-en.phtml?title=Open+On-Chip+Debugger
Ver heb ik dus in mijn project tree ook nog een script file genaamd openocd_flash_lpc2378.script staan:
#
# The following command wills be executed on
# reset (because of run_and_init in the config-file)
# - wait for target halt
# - erase memory
# - flash content of file main.bin into target-memory
# - shutdown openocd
#
# PRELIMINARY - first test for LPC2378
#
#
# Martin Thomas
# http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects
# based on information from Dominic Rath
#
halt
sleep 20
wait_halt
# ignore my comments - setup works without the following.
# disable PLL and switch to IRC (4 MHz nom.)
# hmm - should not be needed since IRC is default source after Reset...
# any interaction with the ISP startup??
# doesn't work anyway - something missing
# TODO: read manual.
#mww 0xE01FC080 0x00000000 # PLLCON = 0
#mww 0xE01FC08C 0x000000AA # PLLFEED = 0xAA
#mww 0xE01FC08C 0x00000055 # PLLFEED = 0x55
#mww 0xE01FC040 0x00000001 # MEMMAP = 0x01
#sleep 10
arm7_9 dcc_downloads enable
flash probe 0
# erase complete flash:
#flash erase 0 0 26
# just erase the 3 first sectors of bank 0
flash erase_sector 0 0 5
flash write_image 0 main.bin 0x0
sleep 30
reset run
sleep 30
shutdown
Moet flash write_image 0 main.bin 0x0 niet flash write_image 0 main.hex 0x0 zijn trouwens?
Hij geeft nog steeds aan dat hij het device niet kan vinden:
Info: openocd.c:93 main(): Open On-Chip Debugger (2007-09-05 09:00 CEST)
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 B
Error: ft2232.c:1358 ft2232_init_ftd2xx(): 1: X>
Wat opvallend is dat hij als error de JTAG B aangeeft, terwijl hij in mijn cfg file JTAG A heet.
Als ik dat in de config file verander, veranderd er niet heel erg veel