Please note that User Registration has been temporarily disabled due to a recent increase in automated registrations. If anyone needs an account, please request one here: RequestAccount. Thanks for your patience!--Wmat (talk)
Please email User:Wmat if you experience any issues with the Request Account form.

Difference between revisions of "LeapFrog Pollux Platform: JTAG Kernel Boot"

From eLinux.org
Jump to: navigation, search
(Created page with '= Disclaimer = You know the drill: absolutely no warranty on this information whatsoever. You might fry your Didj following these instructions. I'll also add that I barely kno…')
 
(Connect your JTAG Dongle)
 
(15 intermediate revisions by 6 users not shown)
Line 1: Line 1:
 
= Disclaimer =
 
= Disclaimer =
  
You know the drill: absolutely no warranty on this information whatsoever.  You might fry your Didj following these instructions.
+
You know the drill: absolutely no warranty on this information whatsoever.  You might fry your Didj following these instructions. I'll also add that I barely know how openocd and JTAG work.  But my JTAG setup seems to work okay.
 
+
I'll also add that I barely know how openocd and JTAG work.  Accordingly, my JTAG setup barely works.  Hopefully there's a JTAG ninja out there that can help improve it.
+
  
 
= Introduction =
 
= Introduction =
  
The goal here is to be able to debug early boot code like lightning-boot and u-boot.  The plan is to get the JTAG on the Didj hooked up to my [http://www.sparkfun.com/commerce/product_info.php?products_id=7834 Olimex ARM-USB-OCD dongle] talking to [http://openocd.berlios.de/doc/html/index.html openocd], which works with gdb.  Here we go.
+
The goal here is to be able to debug early boot code like lightning-boot and u-boot.  The plan is to get the JTAG on the Didj hooked up to my [http://www.sparkfun.com/commerce/product_info.php?products_id=7834 Olimex ARM-USB-OCD dongle] or [[Flyswatter]] talking to [http://openocd.berlios.de/doc/html/index.html openocd], which works with gdb.  Here we go.
  
 
= Connect your JTAG Dongle =
 
= Connect your JTAG Dongle =
 +
[[LeapFrog_Pollux_Platform:_JTAG_Pinouts| LeapFrog Pollux Platform JTAG Pinouts]]
  
I soldered on a 20-pin ARM JTAG header to the pads discovered by others on this wiki:
+
The connection between the device and your JTAG adapter may vary, please consult your adapters documentation.
  
<gallery widths=200px>
+
'''NOTE: if you don't have a usb JTAG device, you can purchase a [[Flyswatter]] from [http://www.tincantools.com TinCanTools] for $49.95'''
Image:JTAG PADS.jpg|JTAG Test Pads
+
</gallery>
+
 
+
Note that only 7 of the pins are connected.
+
 
+
* JTAG on pads
+
** TP8 - VREF
+
** TP9 - nTRST
+
** TP10 - TDI
+
** TP11 - TMS
+
** TP12 - TCK
+
** TP13 - TDO
+
** TP14 - GND
+
 
+
For details on mapping these pins to a standard 20-pin ARM JTAG adapter, see http://www.jtagtest.com/pinouts/arm20.
+
 
+
I'll leave it up to you to figure out how the JTAG header connects to the dongle which connects to the PC:)
+
 
+
Question: Anybody out there know of a suitable test pad to which we could connect nSRST?
+
  
 
= Build openocd =
 
= Build openocd =
  
I'm using Ubuntu 9.04, which has a version of openocd.  But I couldn't get that version to talk to my Olimex dongle.  So I built from source using the instructions found [http://www.openhardware.net/Embedded_ARM/OpenOCD_JTAG/ here]:
+
I'm using Ubuntu 9.04, which has a version of openocd.  But I couldn't get that version to talk to my Olimex dongle.  So I built from source.  Note that I also had to build libftdi from source because the Ubuntu/9.04 version was not current enough:
  
# Grab ftdi's binary lib:
+
# Build libftdi:
mkdir libftd2xx
+
  wget http://www.intra2net.com/en/developer/libftdi/download/libftdi-0.17.tar.gz
cd libftd2xx
+
  tar xvzf libftdi-0.17.tar.gz  
  wget http://www.ftdichip.com/Drivers/D2XX/Linux/libftd2xx0.4.13.tar.gz
+
  cd libftdi-0.17/
  tar xvzf ./libftd2xx0.4.13.tar.gz  
+
  ./configure --prefix /your/prefix
  cp libftd2xx.so.0.4.13 /usr/local/lib/
+
  make
  sudo cp libftd2xx.so.0.4.13 /usr/local/lib/
+
  make install
sudo ln -s /usr/local/lib/libftd2xx.so.0.4.13 /usr/local/lib/libftd2xx.so
+
sudo ln -s /usr/local/lib/libftd2xx.so.0.4.13 /usr/lib/libftd2xx.so
+
  sudo ldconfig
+
  sudo cp ftd2xx.h /usr/local/include/
+
sudo cp WinTypes.h /usr/local/include/
+
  
 
# Grab and build openocd:
 
# Grab and build openocd:
 
  git clone git://openocd.git.sourceforge.net/gitroot/openocd/openocd
 
  git clone git://openocd.git.sourceforge.net/gitroot/openocd/openocd
 
  cd openocd
 
  cd openocd
sudo apt-get install libftdi
 
 
  ./bootstrap
 
  ./bootstrap
  ./configure --prefix=/your/favorite/path --enable-maintainer-mode --enable-ft2232_ftd2xx
+
  ./configure --prefix=/your/prefix --enable-maintainer-mode --enable-ft2232_libftdi
 
  make
 
  make
 
  make install
 
  make install
Line 65: Line 39:
  
 
  source [find interface/olimex-arm-usb-ocd.cfg]
 
  source [find interface/olimex-arm-usb-ocd.cfg]
  reset_config trst_only
+
# length of reset signal: [ms]
  jtag_rclk 8
+
jtag_nsrst_assert_width 100
 +
# don't talk to JTAG after reset for: [ms]
 +
jtag_nsrst_delay 250
 +
  reset_config trst_and_srst separate
 +
  # end reset config
 +
# reset_config trst_only
 
  if { [info exists CHIPNAME] } {
 
  if { [info exists CHIPNAME] } {
 
   set  _CHIPNAME $CHIPNAME
 
   set  _CHIPNAME $CHIPNAME
Line 89: Line 68:
  
 
Now you can launch it:
 
Now you can launch it:
  sudo /path/to/openocd -s /path/to/openocd/source/tree/tcl/
+
  LD_LIBRARY_PATH=/your/prefix/lib sudo /path/to/openocd -s /path/to/openocd/tcl/
  
 
Expect output something like this:
 
Expect output something like this:
  Open On-Chip Debugger 0.5.0-dev-00201-g14f4606 (2010-05-03-14:21)
+
  Open On-Chip Debugger 0.5.0-dev-00257-gf40faeb (2010-05-26-17:39)
 
  Licensed under GNU GPL v2
 
  Licensed under GNU GPL v2
 
  For bug reports, read
 
  For bug reports, read
 
  http://openocd.berlios.de/doc/doxygen/bugs.html
 
  http://openocd.berlios.de/doc/doxygen/bugs.html
 
  trst_only separate trst_push_pull
 
  trst_only separate trst_push_pull
RCLK - adaptive
+
  Info : clock speed 6000 kHz
  Info : RCLK (adaptive clock speed) not supported - fallback to 8 kHz
+
 
  Info : JTAG tap: pollux.cpu tap/device found: 0x07926f0f (mfg: 0x787, part: 0x7926, ver: 0x0)
 
  Info : JTAG tap: pollux.cpu tap/device found: 0x07926f0f (mfg: 0x787, part: 0x7926, ver: 0x0)
 
  Info : Embedded ICE version 6
 
  Info : Embedded ICE version 6
Line 114: Line 92:
 
  exec-file /path/to/your/image
 
  exec-file /path/to/your/image
 
  symbol-file /path/to/your/image
 
  symbol-file /path/to/your/image
# We are executing with all fast transfer features disabled.  So we have to
 
# tell gdb to wait a long time before giving up.
 
set remotetimeout 120
 
 
  define reload
 
  define reload
 +
  monitor halt
 
   monitor soft_reset_halt
 
   monitor soft_reset_halt
 
   load
 
   load
Line 134: Line 110:
 
  For bug reporting instructions, please see:
 
  For bug reporting instructions, please see:
 
  <https://support.codesourcery.com/GNUToolchain/>.
 
  <https://support.codesourcery.com/GNUToolchain/>.
  0x04ae319c in ?? ()
+
  0x00000000 in ?? ()
 
  (gdb) reload
 
  (gdb) reload
 
  requesting target halt and executing a soft reset
 
  requesting target halt and executing a soft reset
Line 145: Line 121:
 
  Loading section .rodata.str1.1, size 0x69e lma 0x1958
 
  Loading section .rodata.str1.1, size 0x69e lma 0x1958
 
  Start address 0x0, load size 8182
 
  Start address 0x0, load size 8182
  Transfer rate: 322 bytes/sec, 2727 bytes/write.
+
  Transfer rate: 31 KB/sec, 2727 bytes/write.
 
  (gdb) break main
 
  (gdb) break main
 
  Breakpoint 1 at 0x1170: file main.c, line 278.
 
  Breakpoint 1 at 0x1170: file main.c, line 278.
 
  (gdb) c
 
  (gdb) c
 
  Continuing.
 
  Continuing.
 +
 
  Breakpoint 1, main () at main.c:278
 
  Breakpoint 1, main () at main.c:278
 
  278 BIT_SET(REG16(LF1000_UDC_BASE+UDC_PCR), PCE);
 
  278 BIT_SET(REG16(LF1000_UDC_BASE+UDC_PCR), PCE);
 
  (gdb) n
 
  (gdb) n
 
  267 {
 
  267 {
  (gdb) n
+
  (gdb)  
 
  278 BIT_SET(REG16(LF1000_UDC_BASE+UDC_PCR), PCE);
 
  278 BIT_SET(REG16(LF1000_UDC_BASE+UDC_PCR), PCE);
  (gdb) n
+
  (gdb)  
 
  280 adc_init();
 
  280 adc_init();
 
  (gdb) c
 
  (gdb) c
Line 168: Line 145:
 
  Uncompressing Linux....................................................... done, booting the kernel.
 
  Uncompressing Linux....................................................... done, booting the kernel.
  
= Next Steps =
 
  
* Experiment with faster JTAG clock
+
 
* Figure out why I can't always halt and reload the image (no nSRST?)
+
[[Category:Didj]]
 +
[[Category:Leapster Explorer]]
 +
[[Category:LeapPad Explorer]]
 +
[[Category:LeapFrog Pollux Platform]]

Latest revision as of 18:58, 16 September 2011

Disclaimer

You know the drill: absolutely no warranty on this information whatsoever. You might fry your Didj following these instructions. I'll also add that I barely know how openocd and JTAG work. But my JTAG setup seems to work okay.

Introduction

The goal here is to be able to debug early boot code like lightning-boot and u-boot. The plan is to get the JTAG on the Didj hooked up to my Olimex ARM-USB-OCD dongle or Flyswatter talking to openocd, which works with gdb. Here we go.

Connect your JTAG Dongle

LeapFrog Pollux Platform JTAG Pinouts

The connection between the device and your JTAG adapter may vary, please consult your adapters documentation.

NOTE: if you don't have a usb JTAG device, you can purchase a Flyswatter from TinCanTools for $49.95

Build openocd

I'm using Ubuntu 9.04, which has a version of openocd. But I couldn't get that version to talk to my Olimex dongle. So I built from source. Note that I also had to build libftdi from source because the Ubuntu/9.04 version was not current enough:

  1. Build libftdi:
wget http://www.intra2net.com/en/developer/libftdi/download/libftdi-0.17.tar.gz
tar xvzf libftdi-0.17.tar.gz 
cd libftdi-0.17/
./configure --prefix /your/prefix
make
make install
  1. Grab and build openocd:
git clone git://openocd.git.sourceforge.net/gitroot/openocd/openocd
cd openocd
./bootstrap
./configure --prefix=/your/prefix --enable-maintainer-mode --enable-ft2232_libftdi
make
make install

Launch openocd

I used this config file, which I named openocd.cfg in my favorite working directory. I put this together based on the openocd documentation and examples in the source tree.

source [find interface/olimex-arm-usb-ocd.cfg]
# length of reset signal: [ms]
jtag_nsrst_assert_width 100
# don't talk to JTAG after reset for: [ms]
jtag_nsrst_delay 250
reset_config trst_and_srst separate
# end reset config
# reset_config trst_only
if { [info exists CHIPNAME] } {
  set  _CHIPNAME $CHIPNAME
} else {
  set  _CHIPNAME pollux
}
if { [info exists ENDIAN] } {
  set  _ENDIAN $ENDIAN
} else {
  set  _ENDIAN little
}
if { [info exists CPUTAPID ] } {
  set _CPUTAPID $CPUTAPID
} else {
  # force an error till we get a good number
  set _CPUTAPID 0x07926f0f
}
#jtag scan chain
jtag newtap $_CHIPNAME cpu -irlen 4 -expected-id $_CPUTAPID
set _TARGETNAME $_CHIPNAME.cpu
target create $_TARGETNAME arm926ejs -endian $_ENDIAN -chain-position $_TARGETNAME -variant arm926ejs

Now you can launch it:

LD_LIBRARY_PATH=/your/prefix/lib sudo /path/to/openocd -s /path/to/openocd/tcl/

Expect output something like this:

Open On-Chip Debugger 0.5.0-dev-00257-gf40faeb (2010-05-26-17:39)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.berlios.de/doc/doxygen/bugs.html
trst_only separate trst_push_pull
Info : clock speed 6000 kHz
Info : JTAG tap: pollux.cpu tap/device found: 0x07926f0f (mfg: 0x787, part: 0x7926, ver: 0x0)
Info : Embedded ICE version 6
Info : pollux.cpu: hardware has 2 breakpoint/watchpoint units

Build a suitable binary

I built the vanilla lightning-boot from the leapfrog distribution adding the -g option and disabling the -DSELF_BOOTSTRAP and enabling -DDEBUG. I happen to be using "gcc version 4.4.1 (Sourcery G++ Lite 2009q3-68)" from Code Sourcery

Launch GDB

Now you should be able to launch gdb, load your image, set a break point, and continue. First of all, here's the .gdbinit file that I'm using:

target remote localhost:3333
exec-file /path/to/your/image
symbol-file /path/to/your/image
define reload
  monitor halt
  monitor soft_reset_halt
  load
end

And now here's a transcript of how I launch gdb, load the image, set a break point, step through a few lines of code, then continue:

$ arm-none-eabi-gdb
GNU gdb (Sourcery G++ Lite 2009q3-68) 6.8.50.20090630-cvs
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-pc-linux-gnu --target=arm-none-eabi".
For bug reporting instructions, please see:
<https://support.codesourcery.com/GNUToolchain/>.
0x00000000 in ?? ()
(gdb) reload
requesting target halt and executing a soft reset
target state: halted
target halted in ARM state due to debug-request, current mode: Supervisor
cpsr: 0x600000d3 pc: 0x00000000
MMU: disabled, D-Cache: disabled, I-Cache: disabled
Loading section .text, size 0x1528 lma 0x0
Loading section .rodata, size 0x430 lma 0x1528
Loading section .rodata.str1.1, size 0x69e lma 0x1958
Start address 0x0, load size 8182
Transfer rate: 31 KB/sec, 2727 bytes/write.
(gdb) break main
Breakpoint 1 at 0x1170: file main.c, line 278.
(gdb) c
Continuing.
Breakpoint 1, main () at main.c:278
278		BIT_SET(REG16(LF1000_UDC_BASE+UDC_PCR), PCE);
(gdb) n
267	{
(gdb) 
278		BIT_SET(REG16(LF1000_UDC_BASE+UDC_PCR), PCE);
(gdb) 
280		adc_init();
(gdb) c
Continuing.

...And on the serial console, you can see the debug lines, which strongly suggests that I'm not simply booting from NAND:

lightning-boot 1.0
tfs: loaded summary 0x00000002 files
Starting the kernel...
Uncompressing Linux....................................................... done, booting the kernel.