Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Aug 2009 04:21:18 GMT
From:      Robert Jenssen <robertjenssen@ozemail.com.au>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/137945: openocd-0.2.0 fails to find ATMEL SAM-ICE as Segger jlink
Message-ID:  <200908190421.n7J4LIeh058621@www.freebsd.org>
Resent-Message-ID: <200908190430.n7J4U1Uu042010@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         137945
>Category:       ports
>Synopsis:       openocd-0.2.0 fails to find ATMEL SAM-ICE as Segger jlink
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Aug 19 04:30:00 UTC 2009
>Closed-Date:
>Last-Modified:
>Originator:     Robert Jenssen
>Release:        FreeBSD  7-Stable
>Organization:
>Environment:
FreeBSD kraken.wollstonecraft 7.2-STABLE FreeBSD 7.2-STABLE #0: Sun Aug 16 23:51:27 EST 2009     root@kraken.wollstonecraft:/usr/obj/usr/src/sys/KRAKEN  i386
>Description:
Thanks for updating the openocd port. 

I find that the original source needs to be patched to work with the ATMEL SAM-ICE (a.k.a. Segger jlink) on FreeBSD. In the attached patch the extra find_jlink_device() and usb_open() calls in openocd-0.2.0/src/jtag/jlink.c:jlink_usb_open() are #ifdef'ed out.

There is a lengthy thread at:
http://lists.berlios.de/pipermail/openocd-development/2009-July/009397.html
FreeBSD isn't mentioned. It seems there is a portability problem in libusb.
>How-To-Repeat:
I am using an ATMEL AT91SAM7S-EK baord with the ATMEL SAM-ICE JTAG emulator. Using the following samice.cfg:

# Daemon configuration
telnet_port 4444
gdb_port 3333

# Interface is SAM-ICE
interface jlink
jtag_khz 0

reset_config srst_only srst_pulls_trst

set _CHIPNAME sam7s256
set _ENDIAN little
set _CPUTAPID 0x3f0f0f0f
set _TARGETNAME [format "%s.cpu" $_CHIPNAME]

jtag newtap $_CHIPNAME cpu \
       -irlen 4 \
       -ircapture 0x1 \
       -irmask 0xf \
       -expected-id $_CPUTAPID

target create $_TARGETNAME arm7tdmi \
       -endian $_ENDIAN \
       -chain-position $_TARGETNAME \
       -variant arm7tdmi \
       -work-area-virt 0 \
       -work-area-phys 0x00200000 \
       -work-area-size 0x4000 \
       -work-area-backup 0

# Commands performed after a reset-init event
$_TARGETNAME configure -event reset-init {
   mww 0xfffffd44 0x00008000
   mww 0xfffffd08 0xa5000001
   mww 0xfffffc20 0x00000601
   sleep 100
   mww 0xfffffc30 0x00000001
   sleep 1000
   mww 0xffffff60 0x003c0100
   sleep 100
}

flash bank at91sam7 0 0 0 0 0
arm7_9 fast_memory_access enable
armv4_5 core_state arm

init
halt

# end of samice.cfg

I run:

/usr/local/bin/openocd -f ./samice.cfg
Open On-Chip Debugger 0.2.0 (2009-08-19-13:58) Release
$URL: http://svn.berlios.de/svnroot/repos/openocd/tags/openocd-0.2.0/src/openocd.c $
For bug reports, read http://svn.berlios.de/svnroot/repos/openocd/trunk/BUGS
RCLK - adaptive
fast memory access is enabled
core state: ARM
Error: Cannot find jlink Interface! Please check connection and permissions.
Runtime error, file "./samice.cfg", line 47:


>Fix:
Patch with the attached file and recompile giving:


/usr/local/arm-toolchain/bin/openocd -f ./samice.cfg
Open On-Chip Debugger 0.2.0 (2009-08-03-16:55) Release
$URL: http://svn.berlios.de/svnroot/repos/openocd/tags/openocd-0.2.0/src/openocd.c $
For bug reports, read http://svn.berlios.de/svnroot/repos/openocd/trunk/BUGS
RCLK - adaptive
fast memory access is enabled
core state: ARM
Info : J-Link initialization started / target CPU reset initiated
Info : J-Link ARM V8 compiled Jun 30 2009 11:00:16
Info : JLink caps 0xb9ff7bbf
Info : JLink hw version 80000
Info : JLink max mem block 9792
Info : Vref = 3.280 TCK = 1 TDI = 0 TDO = 1 TMS = 0 SRST = 0 TRST = 0

Info : J-Link JTAG Interface ready
Info : JTAG tap: sam7s256.cpu tap/device found: 0x3f0f0f0f (mfg: 0x787, part: 0xf0f0, ver: 0x3)
Info : JTAG Tap/device matched
target state: halted
target halted in ARM state due to breakpoint, current mode: Supervisor
cpsr: 0x40000053 pc: 0x00101a18




Patch attached with submission follows:

*** openocd-0.2.0/src/jtag/jlink.c.orig	2009-08-03 15:28:39.000000000 +1000
--- openocd-0.2.0/src/jtag/jlink.c	2009-08-03 15:29:01.000000000 +1000
***************
*** 891,896 ****
--- 891,897 ----
  		 * test them carefully on all platforms before committing them!
  		 */
  
+ #if 0
  #if IS_WIN32 == 0
  
  		usb_reset(result->usb_handle);
***************
*** 918,924 ****
  
  		result->usb_handle = usb_open(dev);
  #endif
! 
  #endif
  
  		if (result->usb_handle)
--- 919,925 ----
  
  		result->usb_handle = usb_open(dev);
  #endif
! #endif
  #endif
  
  		if (result->usb_handle)


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200908190421.n7J4LIeh058621>