SPCN 323

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

National Conference on Advances in Signal Processing, Communications and Networking (NCASPCN-13) Paper ID:

ISBN: 978-81-927765-0-7@2013 SSIT SPCN-323

OpenOCD:The Yoke to ARM Programming on


Ubiquitously Available Windows Platform
Prateek Arora#1, Ravi Sharma#2, Rohanjeet#3,Sudipta Ghosh*4(IEEE Student Member),
Manish Puri*5(IEEE Student Member), Jitendra Singh Sengar*6(IEEE Member)
#
Electronics and Communication Department, Lovely Professional University, Phagwara, Punjab, India
1
prateekarora89@gmail.com
2
ravishaggy@gmail.com
3
jeetrohan92@gmail.com
4
sudipta.kanti@gmail.com
5
manishpuri1790@gmail.com
6
jitendra.sengar@gmail.com

Abstract— ARM programming over LINUX/UNIX based circuit (ASIC) based processor. Earlier ARM processor were
operating system is a common practice in the industry. programmed using LINUX commands but windows capturing
Astonishingly the most widely used ‘windows’ platform has not huge market as an operating system requires an environment
been employed for the aforesaid intent. This paper contemplateswhich can work on windows, and Eclipse makes it possible
to contrive a cross development environment congruent with the
with OpenOCD. Integrated Development Environment (IDE)
windows platform using OpenOCD through the JTAG port. The
IDE used is Eclipse as it comprises a composite C/C++ called Eclipse, which is an open source tool, adds to its
Development tool which makes the programming seamless. usability in various programming languages such as
OpenOCD is used for flash programming and debugging. embedded C, C++ and Java for the development of mobile
Hardware interface is done employing ARM USB OCD. It has applications. OpenOCD (Open On-Chip Debugger) is open-
proved its reliability for years. Olimex SAM7P-256 is an source software which communicates with a hardware
AT91SAM7S256 ARM based processor board which can debugger's JTAG port. OpenOCD provides in-system
communicate with ARM USB OCD for flash programming and programming and debugging for embedded target devices.
debugging. OpenOCD has the ability to flash NAND and NOR FLASH
memory devices that are attached on the target system [2].
Keywords— ARM Processors; Cross Development Environment; OpenOCD supports run/stop control, software and hardware
Debugging; Flash Programming; ARM USB OCD; Open OCD. breakpoints and also it can be used to program the ARM
internal FLASH memory. When the hardware connection is
I. INTRODUCTION established our next task is to program our flash with source
Embedded system is a special-purpose computer system code and debug our code to get the desired output for real-
designed to perform one or more dedicated function having time embedded application. Using OpenOCD for this process
higher quality and reliability requirements than other type of will lead to less complexity and better results.
computer systems [1]. It is a combination of software and The Open On-Chip Debugger (OpenOCD) provides
hardware components. Embedded system consists of debugging and in-system programming as well as boundary-
electronic components such as microprocessor, digital signal scan testing for embedded target devices that are based on the
processor, timers, serial communication ports, input output ARM7, ARM9 and Cortex-M3 with Embedded-ICE macro
devices, micro-controller, memory devices etc. It has cell support with the help of JTAG port. It also enables source
diversified application such as in android phones, military level debugging with the standard GNU Debugger GDB
application, NASA and space organization, robotics and compiled for the ARM architecture. Also the internal and
fabrication equipment to name a few. The ARM processor external FLASH memory programming is supported. A GDB
core is a leading RISC processor architecture in the embedded aware integrated development environment such as Eclipse
domain. The ARM processor is a multi-purpose, 32-bit RISC IDE can benefit from OpenOCD.
microprocessor which is an application specific integrated It supports various JTAG interface

1 Dept of Electronics & Communication Engg, SSIT, Tumkur Vol. 1, Issue 1, August 2013
National Conference on Advances in Signal Processing, Communications and Networking (NCASPCN-13) Paper ID:
ISBN: 978-81-927765-0-7@2013 SSIT SPCN-323

• Macraigor Wiggler language is Java but with the help of plug-ins it can
• Olimex ARM-USB-OCD be made to work with languages like c, c++, Fortran
• Amontec JTAG key and Java script. It is used as a development
The ARM cores that OpenOCD supports are
• ARM ARM7TDMI (-s)
environment for Java or android application. It is
• ARM9TDMI released under the terms of Eclipse Public License
• ARM ARM920t (EPL) managed by Eclipse Foundation. EPL
• ARM ARM922t [3]. licensed programs are open source and can be
modified and distributed free of charge.
D. Olimex ARM USB OCD

II. GENERAL TERMS RELATED TO ARM CROSS DEVELOPMENT It is a device that connects JTAG debug hardware,
RS232 virtual port and power supply adapter in one single
An easy way to comply with the conference compact form [7]. Since most of the PC have no parallel or
paper formatting requirements is to use this serial ports but only USB, so with ARM USB OCD we can
document as a template and simply type your text debug our ARM boards.
into it.
A. GNU Debugger
GNU Debugger called as GDB debugger is a jumpers
debugger for the GNU Operating System and works
for programming languages like Fortran, Java, C
and C++. This powerful debugger allows us to run
programs under controlled conditions. It is a free
Fig. 1 Olimex ARM USB OCD
tool and is released under the GNU General Public
License (GPL) [4]. GNU debugger runs in two The power supply jumpers on the right side of the
different modes: graphical interface (Insight), and 2x10 pin connector [Fig.1] provides different output
command-line interface. Graphical interface is used voltage depending on the jumper being open or
for basic debugging whereas the command line closed.
interface is used for more complicated task. If both jumpers are open the output voltage is 12V
B. JTAG DC.
JTAG Joint Test Action Group (JTAG) is an IEEE Standard
If right jumper is closed the output voltage is 9V
used for board level manufacturing test applications and to DC.
address test point access issues on PCB with surface mount If left jumper is closed the output voltage is 5V DC.
devices. It was initially designed for testing printed circuit
boards and now it is being used for IC debug port that is
known as the TAP (Test Access Port) [5]. JTAG tool is III. CREATING ENVIRONMENT FOR WINDOWS
software that enables working with JTAG aware device with When IDE receives the debug command, GNU
the help of JTAG adaptor. JTAG tool is a free software
package under the General Public License (GPL). GDB debugger gets started automatically. It
communicates with eclipse using the GDB/MI
C. ECLIPSE protocol.GDB reads the main.out file containing
Eclipse is an Integrated Development instruction and symbol information. GDB then
Environment (IDE), which is open source tool with sends a memory read command using a serial
the capability of creating diverse computer solution protocol called RSP (Remote Serial Protocol) to the
and better applications and also provides TCP port[6]. A special daemon is required to
widespread plug-in system. Its basic programming receive a command through RSP protocol. The

2 Dept of Electronics & Communication Engg, SSIT, Tumkur Vol. 1, Issue 1, August 2013
National Conference on Advances in Signal Processing, Communications and Networking (NCASPCN-13) Paper ID:
ISBN: 978-81-927765-0-7@2013 SSIT SPCN-323

daemon may be OpenOCD (TCP port- OpenOCD complete software daemon which runs in
localhost:3333) or J-Link GDB Server (TCP port- background makes eclipse and ARM USB OCD to
communicate for flash programming and debugging, and it
localhost:2331). The RSP protocol command is need tools to be downloaded and then installed. OpenOCD is
converted into ARM protocol command using a part of the Yagarto GNU ARM tool chain and can be found
JTAG hardware interface which will ultimately go on the link [8]. YAGARTO is a cross development
to the ARM chip’s embedded-ICE macrocell environment for the ARM architecture, running on a Windows
[Fig.2]. Daemon communicates with JTAG operating system. It consists of the GNU C/C++ toolchain and
the Eclipse IDE. It provides easy to install pre-compiled ARM
hardware interface via USB port of PC. toolchain [Fig. 3].

Start start

Download Open OCD and run


Eclipse SDK (Main. out)
OpeOCD.exe

DGB/MI Interface
Click next and accept the license agreement then
select all 3 components,
GNU GDB Debugger Arm-elf- click next
gdb.exe

RSP protocol VIA TCP Browse installation path, Click next to Install

Daemon Server OpenOCD or J-Link


Gdb Click Finish to complete the Installation Process

USB Protocol
Connect Olimex ARM-USB-OCD with USB
port
JTAG Hardware Interface

Arm JTAG Protocol Select no, not this time and click next

JTAG Port Select Advanced install option from specific


V.next.
location, click

Embedded-ICE macrocell Click on browse to locate the path for driver

Atmel AT917SAM256 microprocessor


Click next and pass continue anyway command

Fig. 2 Environment for Windows


End AND INSTALLATION
IV. DOWNLOAD Click finish to complete installation process

3 Dept of Electronics & Communication Engg, SSIT, Tumkur Vol. 1, End


Issue 1, August 2013
National Conference on Advances in Signal Processing, Communications and Networking (NCASPCN-13) Paper ID:
ISBN: 978-81-927765-0-7@2013 SSIT SPCN-323

Fig. 4 Flow Diagram for External Tool

VI. USING OPENOCD TO PROGRAM THE FLASH MEMORY


OpenOCD is a utility that converts Eclipse/GDB remote
serial protocol to the JTAG protocol supported by the
AT91SAM7 on chip debugging unit. In this role, it acts as a
“daemon. The other role for OpenOCD is to program the on
Fig. 3 Flow Diagram for Installation of OpenOCD chip FLASH using the JTAG. In this role, OpenOCD is run in
Note: Install virtual drivers following the same a “batch” mode where the program is executed with a special
process as in Fig.3. configuration file and a “script” file with the flash
programming commands. If we are using Olimex ARM-USB-
OCD or the Amontec JTAG Key JTAG hardware interface,
V. CONFIGURATION FILE AND EXTERNAL TOOL we can use the OpenOCD utility to program the flash.
For the OpenOCD to access the configuration files of To program the on chip FLASH, OpenOCD is
debugging and on chip flash programming, these run as a one-time-only execution with a list of
configuration file has to be moved into the OpenOCD bin programming commands read from a script file
folder. Setting up OpenOCD as an external tool for Eclipse named script.ocd. This file is part of the project.
SDK makes it convenient to start it from the Eclipse screen This file contains register setups to reset the
[Fig. 4]. The tool installed as an external tool can be easily
accessed from “Run” pull-down menu or via a toolbar button.
processor and establish the PLL clocks to full speed.
This is necessary to program the FLASH at full
Star speed
A. Script file for OpenOCD – SCRIPT.OCD[9]

Move the OpenOCD configuration Files wait_halt # halt the processor and wait
to the OpenOCD Directory armv4_5 core_state arm # select the core state
#if the lock bits are on use the two below commands to
clear the lock bits
Setting up OpenOCD as an external tool for #mww 0xffffff64 0x5a000004 #clear lock bit 0
eclipse SDK #mww 0xffffff64 0x5a002004 #clear lock bit 1
mww 0xffffff60 0x00320100
# set flash wait state (AT91C_MC_FMR)
mww 0xfffffd44 0xa0008000
Open eclipse, Click on run -> external tool # watchdog disable (AT91C_WDTC_WDMR)
dialog->program-> new mww 0xfffffc20 0xa0000601
# enable main oscillator (AT91C_PMC_MOR)
wait 100 # wait 100 ms
Enter name of tool mww 0xfffffc2c 0x00480a0e
# set PLL register (AT91C_PMC_PLLR)
wait 200 # wait 200 ms
Browse the file system for Driver location mww 0xfffffc30 0x7
and working directory with arguments # set master clock to PLL (AT91C_PMC_MCKR)
below wait 100 # wait 100 ms
mww 0xfffffd08 0xa5000401
# enable user reset AT91C_RSTC_RMR
Click on apply and close flash write 0 main.bin 0x0
# program the on chip flash
reset # reset processor
shutdown # stop OpenOCD
End

4 Dept of Electronics & Communication Engg, SSIT, Tumkur Vol. 1, Issue 1, August 2013
National Conference on Advances in Signal Processing, Communications and Networking (NCASPCN-13) Paper ID:
ISBN: 978-81-927765-0-7@2013 SSIT SPCN-323

B. OpenOCD Configuration File for ARMUSBOCD (FLASH We have to create a debug launch configuration
programming version)[9] before we can debug the flash application [Fig.5].
OpenOCD configuration files to support flash The debug launch configuration locates the GDB
programming on an Atmel AT91SAM7S. debugger for the Eclipse, locates the project’s
#define our ports executable file and provides a start-up script of
telnet_port 4444 GDB commands that areStart
to be run as the debugger
gdb_port 3333 starts up.
#commands for the Olimex ARM-USB-OCD Navigate Run on the eclipse SDK
interface ft2232
ft2232_device_desc "Olimex OpenOCD JTAG Select open debug dialog and click
A"ft2232_layout "olimex-jtag" embedded debug native
ft2232_vid_pid 0x15BA 0x0003
jtag_speed 2 Select main tab and provide the name
jtag_nsrst_delay 200 of project and application file
jtag_ntrst_delay 200
#reset_config <signals> [combination] [trst_type]
Select the debugger tab and locate the
[srst_type] GDB debugger
reset_config srst_only srst_pulls_trst
#jtag_device <IR length> <IR capture> <IR mask>
<IDCODE #instruction> Select he command tab and provide the
jtag_device 4 0x1 0xf 0xe initialize and run command
#daemon_startup <'attach'|'reset'>
daemon_startup reset Click close to complete the debug
#target <type> <endianess> <reset_mode> launch configuration
<jtag#> [variant]
target arm7tdmi little run_and_init 0 TABLE I
End
arm7tdmi_r4
#run_and_halt_time <target#> <time_in_ms>
run_and_halt_time 0 30
# commands specific to AT91sam7 Flash
Programming
#target_script specifies the flash programming
Fig. 5 Flow Diagram for Debug Launch Configuration
script file
target_script 0 reset script.ocd A. Initialize command
#working_area <target#> <address> <size> “target remote localhost: 3333”.
This initialize command directs the GDB debugger to output
<'backup'|'nobackup'> commands in RSP format to the TCP port “localhost:3333”
working_area 0 0x40000000 0x4000 nobackup (the port OpenOCD is configured to).
#flash bank at91sam7 0 0 0 0 <target#>
flash bank at91sam7 0 0 0 B. Run command[9]:
# Halt the processor and wait
VII. CONFIGURING A DEBUG LAUNCH CONFIGURATION monitor soft_reset_halt
#Select the core state

5 Dept of Electronics & Communication Engg, SSIT, Tumkur Vol. 1, Issue 1, August 2013
National Conference on Advances in Signal Processing, Communications and Networking (NCASPCN-13) Paper ID:
ISBN: 978-81-927765-0-7@2013 SSIT SPCN-323

monitor armv4_5 core_state arm shows no errors but only warnings. Then we start
# Set flash wait state (AT91C_MC_FMR) the eclipse debugger by clicking the debug
monitor mww 0xffffff60 0x00320100
# Watchdog disable (AT91C_WDTC_WDMR) monitor
toolbar button and select the debug launch
mww 0xfffffd44 0xa0008000 configuration. Now the program can be finally
# Enable main oscillator (AT91C_PMC_MOR) debugged using the various tools and techniques
monitor mww 0xfffffc20 0xa0000601 available in the Eclipse IDE.
# Wait 100 ms
monitor wait 100 VIII. CONCLUSIONS
# Set PLL register (AT91C_PMC_PLLR) monitor mww This paper presents a method of creating a cross
0xfffffc2c 0x00480a0e # #wait 200 ms
monitor wait 200 development environment for ARM Flash
# Set master clock to PLL (AT91C_PMC_MCKR) Programming and debugging on windows platform
monitor mww 0xfffffc30 0x7 using OpenOCD. It is easy to implement as eclipse
# Wait 100 ms IDE is GUI (Graphical user Interface), hence it is
monitor wait 100 advantageous for programmers as they need not to
# Enable user reset AT91C_RSTC_RMR
monitor mww 0xfffffd08 0xa5000401 use different source commands as in LINUX.
# Setup GDB for faster downloads ACKNOWLEDGMENT
set remote memory-write-packet-size
1024 The authors would like to thank ARC Pioneer
set remote memory-write-packet-size fixed Technologies for the guidance and support
set remote memory-read-packet-size 1024 extended by the faculties. They would also like to
set remote memory-read-packet-size fixed
appreciate the facilities and laboratory provided by
# Conversion of all the breakpoints to hardware
breakpoints ARC Pioneer Technologies to accomplish the
monitor arm7_9 force_hw_bkpts enable research project.
# read the symbol information from main.out
symbol-file main.out REFERENCES
# Resume execution from reset vector-will break at main( ) [1] Tammy Noergaard’s “Embedded SystemsArchitecture:A
Comprehensive Guide for Engineers”. A.P.Godse , A.O.Mulani’s
continue. Embedded Systems.
[2] http://elinux.org/OpenOCD
With this we complete the debug launch configuration. [3] http://www.amontec.com/openocd.shtml
[4] An Introduction to the GNU Debugger --www.zap.org.au/elec2041-
cdrom/unsw/common/gdb-intro.
Now for the final process of debugging we need to switch to [5] IEEE Standard 1149.1-2001 Test Access Port and Boundary-Scan
the Debug perspective from the C/C++ perspective. This can Architecture Available as Print (ISBN 0-7381-2944-5) or PDF (ISBN
0-7381-2945-3) edition,2001
be achieved in either of the two ways: [6] GDB developers GDB Remote Serial Protocol Available from
1. In the eclipse main menu click->Window->Open http://sources.redhat.com/gdb/current/onlinedocs/gdb_33.html
Perspective->Debug [7] https://www.olimex.com/Products/ARM/JTAG/_resources/ARM-
2. In the eclipse toolbar click on Open Perspective and select USB-OCD.pdf
[8] http://sourceforge.net/projects/openocd/?source=directory
Debug. [9] ] JP Lynch’s Using Open Source Tools for AT91SAM7S Cross
Development,Revision2 . www2.amontec.com/sdk4arm/ext/jlynch-
Then we can start the OpenOCD from the tutorial-20061124.pdf
External Tool of eclipse. Then the debug view
console shows that the OpenOCD is running and

6 Dept of Electronics & Communication Engg, SSIT, Tumkur Vol. 1, Issue 1, August 2013

You might also like