by Martin THOMAS
Updated 20061013
OpenOCD created by Dominic Rath is a gdb-server and flash-utility for ARM-Controllers.
It supports ARM7 and ARM9 controllers. Wiggler-type and FTDI2232-based devices can be
used as hardware-interfaces. Supported host-plattforms are Linux/Unix-systems or MS-Windows-systems (native and cygwin).
Michael Fischer has created a page on which he describes how OpenOCD can be used together
with the GNU-debugger (gdb, Insight-gdb, ddd etc.). The following section will describe methods
how to use the flash-programming functionality in OpenOCD.
OpenOCD supports flash programming on NXP/Philips LPC2000, Atmel AT91SAM7 and ST STR7 ARM7-controllers
(version SVN100). Flash-programming can be done by accessing the OpenOCD-telnet-server but I prefer a
method where the flash programming is automated. This is very convenient when working with make.
If everything is setup correctly a simple make program will transfer the binary-code into the flash-memory.
All files mentioned in this section are available for download (see below). A simple example-application
is also included in the file archive. Target-controller is a NXP LPC2138 on a Keil LPC2130-board.
But the basic method can be used for all LPC2000 controllers after minimal changes.
In addition to the three files basicly needed for the automated flash programming I have added some small
"glue"-files to make configuration and usage a little easier.
The first file openocd_install_info.cmd is simple "batch-file" to set some variables. All cmd-files
are made for MS Windows OS but Unix-Users will get the idea how to create own "shell-scripts". The locations
of the OpenOCD binaries and the used JTAG-interface are given in the file:
rem -
rem Modify this to the installed OpenOCD-binaries
rem The following is for the precompiled binaries from Michael Fischer
rem with sources from OpenOCD SVN-version 100 installed on a
rem PC running Windows-2000 (german)
rem -
set OOCD_INSTALLDIR=C:\Programme\openocd-2006re100\bin
set OOCD_BIN_FTDI=%OOCD_INSTALLDIR%\openocd-ftd2xx.exe
set OOCD_BIN_PP=%OOCD_INSTALLDIR%\openocd-pp.exe
rem The used interface either FTDI(=WinARM-JTAG, JTAGKEY etc.) or PP(="Wiggler")
set OOCD_INTERFACE=FTDI
rem set OOCD_INTERFACE=PP
OpenOCD is called from openocd_go_flash.cmd:
@echo off
call openocd_install_info.cmd
if %OOCD_INTERFACE% == PP goto LAB_PP
if %OOCD_INTERFACE% == FTDI goto LAB_FTDI
echo ERROR - set interface in openocd_install_info
goto LAB_END
:LAB_FTDI
set OOCD_EXE=%OOCD_BIN_FTDI%
set OOCD_CFG=openocd_lpc2138_flash_ftdi.cfg
goto LAB_DOIT
:LAB_PP
set OOCD_EXE=%OOCD_BIN_PP%
set OOCD_CFG=openocd_lpc2138_flash_wiggler.cfg
:LAB_DOIT
rem set OOCD_DBG=-d 1
%OOCD_EXE% %OOCD_DBG% -f %OOCD_CFG%
:LAB_END
rem pause
As you can see the script just calls the "install-info" so set the configuration-variables
after that it calls the OpenOCD-binary with the config-file for the used (configured) JTAG-hardware.
The files openocd_lpc2138_flash_ftdi.cfg and openocd_lpc2138_flash_wigger.cfg are
basicly the same and just differ in the interface-defintion-section. Here just the
configuration for FTDI FT2232-based hardware is shown. The configuration-file for Wiggler-type hardware
can be found in the file-archive. In the content listed below you will notice that the
jtag_speed has been set to 3, this has been found out by "try and error", the settings 0,1 and 2
did not work form me with a JTAGKEY and WinARM-JTAG (in the cfg for the Wiggler-hardware jtag_speed
0 has been used and worked reliably).
#
# 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
target_script 0 reset openocd_lpc2138_flash.script
working_area 0 0x40000000 0x4000 nobackup
# LPC2138 @ 12MHz / 0x7D000 from 500*1024 (not 512!)
flash bank lpc2000 0x0 0x7D000 0 0 lpc2000_v2 0 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
The file openocd_lpc2138_flash.script includes the commands which are called on reset
(since reset_and_init is given as parameter for target).
#
# 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 10
poll
flash probe 0
flash erase 0 0 0
flash write 0 main.bin 0x0
reset run
sleep 10
shutdown
An example for a program-target (make program) in the makefile. Make shure the file main.bin is
in "raw-binary" format (objcopy format-option binary):
program: $(TARGET).$(IMGEXT)
@echo
@echo "Programming with OPENOCD"
openocd_go_flash.cmd
文章评论(0条评论)
登录后参与讨论