Mini2440 OpenOCD configuration

renaud171968
Hi,

First let me thank everybody for their great advices, tutorials, and
walkthroughs. I am currently trying to learn the basics of bootloading with
the help of JTAG debugging.

After some time trying to connect via the JTAG parallel cable supplied with
my new mini2440, I finally managed to get it working, somewhat...

Contrary to what I have read in other places, it seems that the cable is
closer to a chameleon than a triton.
D25 PIN assignment seems to be:
D1 => TCK
D2 => TDI
D3 => TMS
S7 => TDO
As far as I understand the supplied parallel cable does not include the
TRST signal.

I am able to detect the CPU, halt it and resume it (see log on Ubuntu
10.04). 

Open On-Chip Debugger 0.4.0 (2010-09-19-21:25)
Licensed under GNU GPL v2
For bug reports, read
  http://openocd.berlios.de/doc/doxygen/bugs.html
parport port = 0x0
Info : clock speed 500 kHz
Info : JTAG tap: s3c2440.cpu tap/device found: 0x0032409d (mfg: 0x04e,
part: 0x0324, ver: 0x0)
Info : Embedded ICE version 2
Info : s3c2440.cpu: hardware has 2 breakpoint/watchpoint units
halt
Info : accepting 'telnet' connection from 0
target state: halted
target halted in ARM state due to debug-request, current mode: Supervisor
cpsr: 0x200000d3 pc: 0x30008e08
MMU: enabled, D-Cache: enabled, I-Cache: enabled


My understanding is that not having any TRST signal only leaves me with the
soft reset option.
Which I tried : soft_reset_halt. The mini2440 is indeed halted with PC=0x0,
but a resume always fails (even after jtag arp_init):

timeout waiting for SYSCOMP & DBGACK, last DBG_STATUS: 4
timeout waiting for SYSCOMP & DBGACK, last DBG_STATUS: 4
timeout waiting for SYSCOMP & DBGACK, last DBG_STATUS: 4
timeout waiting for SYSCOMP & DBGACK, last DBG_STATUS: 4
target state: halted
target halted in ARM state due to breakpoint, current mode: Supervisor
cpsr: 0x000000d3 pc: 0x00554ad0
MMU: disabled, D-Cache: disabled, I-Cache: disabled

I would like to debug the bootloader being loaded from flash.
Do you known if this is feasible with the provided cable?

Here is my configuration file in case anybody is interested
:
#
# Mini2440 parallel JTAG Cable on port 0 (/dev/parport0)
#

interface parport
parport_port 0
parport_cable chameleon

# Target configuration for the Samsung 2440 system on chip
# Tested on a S3C2440 Evaluation board by keesj
# Processor : ARM920Tid(wb) rev 0 (v4l)
# Info: JTAG tap: s3c2440.cpu tap/device found: 0x0032409d (Manufacturer:
0x04e, Part: 0x0324, Version: 0x0)

if { [info exists CHIPNAME] } {    
   set _CHIPNAME $CHIPNAME
} else {    
   set _CHIPNAME s3c2440
}

if { [info exists ENDIAN] } {    
   set _ENDIAN $ENDIAN
} else {    
  # this defaults to a bigendian
   set _ENDIAN little
}

if { [info exists CPUTAPID ] } {
   set _CPUTAPID $CPUTAPID
} else {
  # force an error till we get a good number
   set _CPUTAPID 0x0032409d
}

#jtag scan chain
jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0x0f
-expected-id $_CPUTAPID


set _TARGETNAME [format "%s.cpu" $_CHIPNAME]
target create $_TARGETNAME arm920t -endian $_ENDIAN -chain-position
$_TARGETNAME -variant arm920t

renaud171968
Attachment: debug.txt (2.15 KB)
Actually, I posted my message too fast. I finally managed to debug a
bootloader on my mini2440 using opencd 3.1 and the supplied jtag cable.
Since I could not find a working configuration anywhere and it took me some
time to solve it, I'll detail my setup (Ubuntu 10.04).

Start your mini2440 with the jtag cable attached (NOR or NAND, it does not
matter). Mine is connected to /dev/parport0.

Modify debug.cfg to match your configuration:
# set parameters
set FIRMWARE_PATH "/home/user/myFirmware.bin"
set CODE_ENTRY   "0x30000000"
set CODE_BP   "0x30000034"

In my case, I want to download my firmware image at 0x30000000.
Entry point is at the same address.
The breakpoint address is past the few first instructions (the exception
table - which needs to be relocated BTW) because I could not make the BP
work at 0x30000000 (?!?).

then run :
> sudo openocd -f mini-jtag.cfg -f scripts/debug.cfg 

Open On-Chip Debugger 0.3.1 (2010-01-18-14:21)
$URL$
For bug reports, read
  http://openocd.berlios.de/doc/doxygen/bugs.html
parport port = 0
Error: Translation from jtag_speed to khz not implemented
Info : interface specific clock speed value 0
Info : JTAG tap: s3c2440.cpu tap/device found: 0x0032409d (mfg: 0x04e,
part: 0x0324, ver: 0x0)
Info : Embedded ICE version 2
target state: halted
target halted in ARM state due to breakpoint, current mode: Supervisor
cpsr: 0x200000d3 pc: 0x30001824
MMU: disabled, D-Cache: disabled, I-Cache: enabled
background polling: on
TAP: s3c2440.cpu (enabled)
target state: halted
target halted in ARM state due to breakpoint, current mode: Supervisor
cpsr: 0x200000d3 pc: 0x30001824
MMU: disabled, D-Cache: disabled, I-Cache: enabled
requesting target halt and executing a soft reset
target state: halted
target halted in ARM state due to breakpoint, current mode: Supervisor
cpsr: 0x200000d3 pc: 0x00000000
MMU: disabled, D-Cache: disabled, I-Cache: disabled
1140 bytes written at address 0x30000000
downloaded 1140 byte in 0.109127s
breakpoint set at 0x30000034
target state: halted
target halted in ARM state due to breakpoint, current mode: Supervisor
cpsr: 0x200000d3 pc: 0x30000034
MMU: disabled, D-Cache: disabled, I-Cache: disabled
= Ready for debug =

At that stage, the mini2440 is halted at the address set in $CODE_BP and
the temporary hardware breakpoint is deleted.

And you are ready to use gdb:
>arm-none-eabi-gdb myFirmware.elf
>target remote localhost:3333
>monitor gdb_sync

Or ddd:
ddd --eval-command="target remote localhost:3333" --debugger
arm-none-eabi-gdb myFirmware.elf

or eclipse with Zylin (see tutorials anywhere). The initialize commands
should be:
target remote 127.0.0.1:3333
monitor gdb_sync

Note: It is important that you specify the elf output to gdb/ddd otherwise
you will have no symbols and no source code automatically loaded. It is
obviously better if you add the "-g" flag to your gcc settings.

Hope it helps

open-nandra
Hi,

thanks for very useful info. I'm porting barebox bootloader for mini2440
(http://repo.or.cz/w/barebox-mini2440.git) and when I load it to RAM it
works perfectly. When it's loaded in NAND it doesn't start at all. I would
like to debug it but waiting for usb_prog device to come. But if it works
with parallel jtag it's very nice. Thanks again.

open-nandra
Hi,

I follow your howto debug. I'm trying to debug barebox image to add nand
boot support. I got following error when run openocd:

 openocd -f /home/open-nandra/mini_240.cfg -f /home/open-nandra/debug.cfg 
Open On-Chip Debugger 0.4.0 (2010-02-22-22:50)
Licensed under GNU GPL v2
For bug reports, read
  http://openocd.berlios.de/doc/doxygen/bugs.html
parport port = 0x0
Info : clock speed 500 kHz
Info : JTAG tap: s3c2440.cpu tap/device found: 0x0032409d (mfg: 0x04e,
part: 0x0324, ver: 0x0)
Info : Embedded ICE version 2
Info : s3c2440.cpu: hardware has 2 breakpoint/watchpoint units
background polling: on
TAP: s3c2440.cpu (enabled)
target state: running
target state: halted
target halted in ARM state due to debug-request, current mode: Supervisor
cpsr: 0x400000d3 pc: 0x33f80d18
MMU: disabled, D-Cache: enabled, I-Cache: enabled
requesting target halt and executing a soft reset
target state: halted
target halted in ARM state due to debug-request, current mode: Supervisor
cpsr: 0x400000d3 pc: 0x00000000
MMU: disabled, D-Cache: disabled, I-Cache: disabled
127852 bytes written at address 0x31000000
downloaded 127852 bytes in 16.158264s (7.727 kb/s)
breakpoint set at 0x31000034
Error: timed out while waiting for target halted
Command handler execution failed
[root@nandra-network share]# 
[root@nandra-network share]# openocd -f /home/open-nandra/mini_240.cfg -f
/home/open-nandra/debug.cfg 
Open On-Chip Debugger 0.4.0 (2010-02-22-22:50)
Licensed under GNU GPL v2
For bug reports, read
  http://openocd.berlios.de/doc/doxygen/bugs.html
parport port = 0x0
Info : clock speed 500 kHz
Info : JTAG tap: s3c2440.cpu tap/device found: 0x0032409d (mfg: 0x04e,
part: 0x0324, ver: 0x0)
Info : Embedded ICE version 2
Info : s3c2440.cpu: hardware has 2 breakpoint/watchpoint units
background polling: on
TAP: s3c2440.cpu (enabled)
target state: running
target state: halted
target halted in ARM state due to debug-request, current mode: Supervisor
cpsr: 0x200000d3 pc: 0x00000918
MMU: disabled, D-Cache: disabled, I-Cache: enabled
requesting target halt and executing a soft reset
target state: halted
target halted in ARM state due to debug-request, current mode: Supervisor
cpsr: 0x200000d3 pc: 0x00000000
MMU: disabled, D-Cache: disabled, I-Cache: disabled
127852 bytes written at address 0x30000000
downloaded 127852 bytes in 16.539181s (7.549 kb/s)
breakpoint set at 0x30000034
Error: timed out while waiting for target halted
Command handler execution failed

Any ideas?

Thanks,

Marek

Krishna
Hi~,

I also faced similar issue:
"Error: timed out while waiting for target halted"

Found that in mini_240.cfg or mini2440.cfg "srst_pulls_trst" => should be
removed. in reset_config

"
#reset configuration
reset_config trst_and_srst"


I am using mini2440.cgf config file from
http://lyre.hg.sourceforge.net/hgweb/lyre/lyre/rev/8f0f0f03df67

And need to make above change to make OpenOCD working.

Good luck!!!

Tejas
Hi,All
I want to use OpenOCD with mini2440, but does Openocd works on vmware or I
require host machine

Kavitha
Hi

I am currently working on Mini2440 and trying to Debug the boot loader but
I have problem with OpenOCD configuration.I followed the exact steps given
online. while configuring OpenOCD.

./configure --enable-parport0--enable--parport0-ppdev
 make
 make install

But when i run openocd with following config file i am getting this error
message.

root@ubuntu:/home/mini# openocd -f interface/parport.cfg -f
target/samsung_s3c2440.cfg
Open On-Chip Debugger 0.6.1 (2013-03-07-21:11)
Licensed under GNU GPL v2
For bug reports, read
  http://openocd.sourceforge.net/doc/doxygen/bugs.html
Error: The specified debug interface was not found (parport)
The following debug interfaces are available:
Runtime Error: /usr/local/share/openocd/scripts/interface/parport.cfg:13: 
in procedure 'script' 
at file "embedded:startup.tcl", line 58
in procedure 'interface' called at file
"/usr/local/share/openocd/scripts/interface/parport.cfg", line 13

what's is wrong in my commands, kindly any one let me know.

Devarsh Thakkar
Hi,
Iam using SBC2440 Board with Embest Jtag 2410 parallel cable and iam 
trying to load a test program and debug it using breakpoints and step run.I
also intend to load uboot image.

Iam getting following error

Error: The specified debug interface was not found (parport)


following is the logs:
devarsh@devarsh-desktop:~/openocd-0.7.0/tcl$ openocd -f
interface/chameleon.cfg board/mini2440.cfg 
Open On-Chip Debugger 0.7.0 (2013-06-17-16:23)
Licensed under GNU GPL v2
For bug reports, read
  http://openocd.sourceforge.net/doc/doxygen/bugs.html
Error: The specified debug interface was not found (parport)
The following debug interfaces are available:
Runtime Error: interface/chameleon.cfg:7: 
in procedure 'script' 
at file "embedded:startup.tcl", line 58
in procedure 'interface' called at file "interface/chameleon.cfg", line 7

STEPS FOLLOWED BY ME:

1. First downloaded the openocd using sudo apt-get  install openocd
2. Then downloaded the openocd.tar.bz2 unpacked it in my home directory
                /home/devarsh/openocd-0.7.0 
3. Then i go to tcl directory 
devarsh@devarsh-desktop:~/openocd-0.7.0/tcl$ 
4.And write following command
               openocd -f interface/chameleon.cfg board/mini2440.cfg 

I have also tried the above steps after using ./configure script,make and
make install but it didn't work.

Devika
Dear Devarsh,

One thing you need to consider, while installing you should give options
like
 you require some library for that
sudo apt-get install libftdi-dev libftdi1 libtool git-core asciidoc \
    build-essential flex bison \
    libgmp3-dev libmpfr-dev autoconf \
    texinfo libncurses5-dev libexpat1 libexpat1-dev \
    tk tk8.4 tk8.4-dev

./configure --enable-maintainer-mode \
            --enable-ft2232_libftdi 
make
sudo make install

and while executing you should do sudo .

devarsh
Thanks for the reply Devika.
Finally I was able to debug as well as flash sbc2440 board using Embest
JTAG cable.
Following are the steps I followed:
Apply configurations for parallel port and compile
  ./configure –enable-parport.
  make
  make install
Set up the OpenOCD server
In openocd/tcl directory 
   → openocd -f sbc2440.cfg

If all goes well we would get a message showing device ID ,tap ID and other
information .for e.g (mfg: 0x04e, part: 0x0324, ver: 0x0)
.
For debugging purposes we have merged interface and target configuration
files to one file called “openocd.cfg”  and written another file debug.cfg
containing settings required for debugging.
Open another terminal tab and connect to OpenOCD server through telnet 
  → telnet localhost 4444

4444 is the default port number where openOCD server runs.
Open another terminal tab and connect to the OpenOCD using gdb
  →  arm-none-linux-gnueabi-gdb u-boot.elf

Here  arm-none-linux-gnueabi-gdb is the name of gdb binary that came with
the toolchains we installed previously and u-boot.elf is the name of symbol
file to be used to debug.
Open the terminal containing our gdb 
  → Connect gdb to the OpenOCD server by using the below command:
    target remote localhost:3333
Now we have to servers one is gdb server and the other is openocd server
connected through telnet.
Debugging using OpenOCD server
You can search on some commonly used openocd commands like.
 arm reg
  Lists all the available arm registers.
arm disassemble “address” “Number of instruction”
  e.g arm disassemble 0x30000000 10
  Lists the 10 instructions from address 0x30000000.
step 
To step through the code.
There are many other commands like
scan_chain,halt,soft_reset_halt,virt_to_phys,flash etc .
Debugging using GDB
load
It's used to load the symbol table.
monitor gdb_sync
use “monitor” prefix to fire a “openOCD” command from gdb server.
This is used so that we stepi command doesn't affect the target state.
stepi
To step through the code.
Info reg
To get the list of registers with their current states.
---------------------------SOURCE CODE------------------------------------

interface parport
parport_port 0
parport_cable chameleon

gdb_port 3333
telnet_port 4444

adapter_khz 100
# Target configuration for the Samsung 2440 system on chip
# Tested on a S3C2440 Evaluation board by keesj
# Processor : ARM920Tid(wb) rev 0 (v4l)
# Info: JTAG tap: s3c2440.cpu tap/device found: 0x0032409d (Manufacturer:
0x04e, Part: 0x0324, Version: 0x0)

if { [info exists CHIPNAME] } {    
   set _CHIPNAME $CHIPNAME
} else {    
   set _CHIPNAME s3c2440
}

if { [info exists ENDIAN] } {    
   set _ENDIAN $ENDIAN
} else {    
  # this defaults to a bigendian
   set _ENDIAN little
}

if { [info exists CPUTAPID ] } {
   set _CPUTAPID $CPUTAPID
} else {
  # force an error till we get a good number
   set _CPUTAPID 0x0032409d
}

#jtag scan chain
jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0x0f
-expected-id $_CPUTAPID


set _TARGETNAME [format "%s.cpu" $_CHIPNAME]
target create $_TARGETNAME arm920t -endian $_ENDIAN -chain-position
$_TARGETNAME -variant arm920t
#
# download an image and break
#

# set parameters
set FIRMWARE_PATH "/home/devarsh/u-boot.bin"
set CODE_ENTRY   "0x30000000"
set CODE_BP   "0x30000001"

# run the configuration steps
init

# configure polling
puts "activating poll"
poll
sleep 1

# halt board 
puts "Halting CPU..."
halt
wait_halt

# reset board
puts "CPU halted, soft reset"
soft_reset_halt

# download the binary image
puts "Downloading image"
load_image $FIRMWARE_PATH $CODE_ENTRY bin
sleep 200
puts "Image downloaded"

# set hardware breakpoint at code start
puts "Setting hardware breakpoint at code entry=$CODE_ENTRY"
bp $CODE_BP 4 hw

# resume execution
puts "Resuming execution"
resume $CODE_ENTRY

# wait for breakpoint to be hit
wait_halt
puts "CPU halted, breakpoint hit"

# remove previous breakpoint
puts "Removing breakpoint"
rbp $CODE_BP

puts "= Ready for debug"