Using OpenOCD and ARMv7 Cortex-M3

Martin Thomas, updated 9. Apr. 2008, still preliminary

Magnus Lundin, extended Dominic Rath's OpenOCD by functions to access the debug-interface of ARMv7 Cortex-M3 controllers and added flash-programming support for LMI Stellaris Cortex-M3 controllers. Spencer Oliver has added support for ST STM32 Cortex-M3.

The methods described on this page have been tested with Windows 2000 and Windows XP, Linux users will find useful information on Sean Ellis's page "Using the LM3S811 Evaluation Board under Linux". The tests have been done with the LMI EVB-LM3S811 evaluation-board using the on-board FTDI FT2232-based JTAG hardware-interface.

Thanks to Dominic Rath who fixed a problem in a makefile in "real time" and thanks to Magnus Lundin who has fixed a problem with the flash-programming a few hours after reporting the issue. The OpenOCD developers can be reached via the OpenOCD developer mailing-list and will be happy if you provide patches to improve OpenOCD. You can support the OpenOCD-project with donations.

The software-package Version 20080409 includes the following files:



Flash Programming

The file prg.cmd just starts OpenOCD with the configuration for flash-programming (run_and_init/reset script).

@echo off
openocd_local -d3 -f lmi.cfg 
rem pause

lmi.cfg is the configration file based on examples from Magnus Lundin and Spencer Oliver. I adapted the device-description to the name used by the Windows-driver and lowered the JTAG-speed to 10 (faster not tested yet).

# mthomas 4/2008, tested with OpenOCD SVN555

#daemon configuration
telnet_port 4444
gdb_port 3333

#interface
interface ft2232
ft2232_device_desc "LM3S811 Evaluation Board A"
ft2232_layout evb_lm3s811
ft2232_vid_pid 0x0403 0xbcd9

jtag_speed 10
jtag_nsrst_delay 100
jtag_ntrst_delay 100

#LM3S811 Evaluation Board has only srst
#reset_config srst_only
#reset_config srst_only separate
reset_config trst_and_srst

#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 cortex_m3 little run_and_init 0
#target cortex_m3 little reset_init 0
#target cortex_m3 little run_and_halt 0

#flash configuration
flash bank stellaris 0 0 0 0 0
flash auto_erase on

# working area 
working_area 0 0x20000000 0x2000 nobackup

# script running on reset
target_script 0 reset lmi.script 
#target_script 0 post_halt lmi.script 

Since reset_and_init is configured as reset-mode and the target_reset script (lmi.script is given this script will be called after OpenOCD has been started-up and connected to the target. The flash will be erased automaticaly since flash auto_erase on is given in the configuraiton and the file tmpflash.bin with the machine-code of the user-application will be transfered into the controller's flash-memory. After this the target gets reseted and the application starts.

# mthomas 4/2008, tested with OpenOCD SVN555

flash probe 0
flash erase_check 0
flash protect_check 0
flash info 0

#flash erase_sector 0 0 63
#flash write_bank 0 tmpflash.bin 0

flash write_image tmpflash.bin 0 bin

sleep 200

reset run
shutdown

Debugging

The configuration will for debugging is very similar to the one used for the "scripted" flash-programming. Just comment out the line with run_and_init and uncomment the line with run_and_halt the reset-script line should be commented out too.

#daemon configuration
telnet_port 4444
gdb_port 3333

#interface
interface ft2232
ft2232_device_desc "LM3S811 Evaluation Board A"
ft2232_layout evb_lm3s811
ft2232_vid_pid 0x0403 0xbcd9

jtag_speed 10
jtag_nsrst_delay 100
jtag_ntrst_delay 100

#LM3S811 Evaluation Board has only srst
#reset_config srst_only
#reset_config srst_only separate
reset_config trst_and_srst

#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 cortex_m3 little run_and_init 0
#target cortex_m3 little run_and_halt 0

#flash configuration
flash bank stellaris 0 0 0 0 0
flash auto_erase on

# working area 
working_area 0 0x20000000 0x2000 nobackup

# script running on reset
#target_script 0 reset lmi.script 

So far I have only done some tests with insight-gdb from Devkitpro (Win32) as included in WinARM (6/06) and the gdb from Codesourcery (Win32). Attaching to the OpenOCD-CM3-version and debugging (breakpoints etc.) seems to work as expected. Eclipse's gdb-interface should work too but has not been tested by me.


The very old software-package Version 20061127 is still available and includes the following files: (just keep for reference, do no use)


To my ARM-Projects page (WinARM, other ARM projects)

To my Atmel AVR-Projects page


Martin Thomas
mail-adress: mthomas /at/ rhrk /dot/ uni-kl /dot/ de


42629 hits since November 9, 2006
Last mod.: Tuesday, 15-Apr-2008 16:13:42 CEST