target: use consistent halt timeout

On slow targets we sometimes get false messages about timeouts due to poll
using 1sec rather than the default 5sec timeout.

Change-Id: Icc81c78e0ca86cebf9eeb2f5307cf7a82f1f4ee8
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/1466
Tested-by: jenkins
ULINK driver: port from libusb-0.1 to libusb-1.0 API

The ULINK driver now uses libusb-1.0 calls (synchronous device I/O) directly
(not the common layer provided by libusb1_common.c)

Successfully tested with ULINK probe and STM32F103 (debug, erase and write
flash).

Change-Id: Ic037a3582db85e49a8cc1ec0dd36f629e4757929
Signed-off-by: Martin Schmölzer <martin.schmoelzer@student.tuwien.ac.at>
Reviewed-on: http://openocd.zylin.com/1459
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
OpenULINK firmware: fix name of USB Jump Table symbol

Fix a case mistake in the name of the USB Jump Table ("USB_jump_table"
vs. "USB_Jump_Table") which led to an assembler error when attempting
to build the firmware with recent SDCC versions, because the assembler
now treats symbol names as case-sensitive.

Successfully tested with ULINK probe and STM32F103 (debug, erase and write
flash).

Change-Id: I979667b9130efcdccc3ac73269c38f06e0590048
Signed-off-by: Martin Schmölzer <martin.schmoelzer@student.tuwien.ac.at>
Reviewed-on: http://openocd.zylin.com/1482
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
ULINK driver and OpenULINK firmware: whitespace and comment fixes (trivial)

In commit de0130a0aad83c1ef692ee4d68ab996a8668424d, some doxygen documentation
blocks of the form "///< ..." (documentation after member) got changed to
"/* /< ...", which is not recognized by doxygen. This commit changes them to
the correct form "/**< ...".

Also, remove some leading whitespace characters and fix alignment of comment
blocks where appropriate.

Change-Id: I73a5cf55753722fa0e1d6551f05c47ee88172f0f
Signed-off-by: Martin Schmölzer <martin.schmoelzer@student.tuwien.ac.at>
Reviewed-on: http://openocd.zylin.com/1483
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
OpenULINK firmware: Use C99 designated struct initializers

Recent versions of SDCC added support for C99 designated struct initializers.
This provides better code readability (no functional changes).

Successfully tested with ULINK probe and STM32F103 (debug, erase and write
flash).

Change-Id: Idfa35147d2c3043baaa21a811b926b3845c85f9b
Signed-off-by: Martin Schmölzer <martin.schmoelzer@student.tuwien.ac.at>
Reviewed-on: http://openocd.zylin.com/1484
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
OpenULINK firmware: change .lnk file extension to .lk in "make clean"

Recent versions of SDCC generate .lk files instead of .lnk - change the
OpenULINK Makefile "clean" target and top level .gitignore file to reflect
this.

Change-Id: I36f38638b712b962498c69c362f123378e1aa045
Signed-off-by: Martin Schmölzer <martin.schmoelzer@student.tuwien.ac.at>
Reviewed-on: http://openocd.zylin.com/1485
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
OpenULINK firmware: update firmware hex image

This image has been re-compiled with SDCC 3.3.0 and achieves slightly better
performance (50-100 Byte/s for STM32F103 flash write) due to new/improved
compiler optimizations.

Successfully tested with ULINK probe and STM32F103 (debug, erase and write
flash).

Change-Id: I4329aa42f50461fa3719fd63d0054d8e86982727
Signed-off-by: Martin Schmölzer <martin.schmoelzer@student.tuwien.ac.at>
Reviewed-on: http://openocd.zylin.com/1486
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
mips_ejtag: cache ejtag version to avoid recalculation

Some parts of code are version specific. It will be easier
if we extract ejtag version and store it some where.

Change-Id: I8f9addc42108cba5ae9d61b8ade8f9d7f02a0fb5
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Reviewed-on: http://openocd.zylin.com/1462
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
mips_ejtag: remove memory protection bit before DM

Change-Id: Id1564ae063cea4f056b350436d52df5381ca9608
Signed-off-by: Oleksij Rempel <bug-track@fisher-privat.net>
Reviewed-on: http://openocd.zylin.com/1341
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
mips32_dmaacc: add new funct ejtag_dma_dstrt_poll

Change-Id: I8472a85032e397445408dce917f60c8e6ce852e2
Signed-off-by: Oleksij Rempel <bug-track@fisher-privat.net>
Reviewed-on: http://openocd.zylin.com/1343
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
do not wait forever on ejtag_dma_dstrt_poll

Change-Id: I26adab09839795ecf363b7db912392bd5314cec5
Signed-off-by: Oleksij Rempel <bug-track@fisher-privat.net>
Reviewed-on: http://openocd.zylin.com/1344
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
mips32: add jump instruction

This instruction we will need to make jump to 0xff20.0000

Change-Id: Ic723e683e8848492cd8e186e71fd668dbd1d97e6
Signed-off-by: Oleksij Rempel <bug-track@fisher-privat.net>
Reviewed-on: http://openocd.zylin.com/1338
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
mips32_pracc: jump to 0xff20.0200 if cpu reads wrong addr

On some CPUs, like bcm7401 with EJTAG v2.0 we can have situation where
CPU do not stops execution. For example, all CP0 commands will have this issue.
In this case we should some hove recover our session. Currently
jump to 0xff20.0200 seems to be good option. If it brake some thing on
newer EJTAG, then check for EJTAG v2.0 should be added.

Change-Id: Icd8841f38a1a85e0f7682b6dc358af8dfaae0744
Signed-off-by: Oleksij Rempel <bug-track@fisher-privat.net>
Reviewed-on: http://openocd.zylin.com/1353
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
mips32: add new functions mips32_configure_ibs and _dbs

Split function mips32_configure_break_unit
to mips32_configure_ibs and mips32_configure_dbs
to make code more readable.

This will probably make work easyer with differnet EJTAG versions.

Change-Id: I666f949fd7bc3656bdf75e7bcaadb164f15855dd
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Reviewed-on: http://openocd.zylin.com/1463
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
mips: add breakpoint support for EJTAG 2.0

EJTAG 1.5, 2.0 and 2.5 have different breakpoint register addresses.
This patch add support of EJTAG 2.0, which is part some broadcom
SoCs.

This work was testet on Broadcom BCM7401.

Change-Id: I4b0ee23871fa9205f9001b7c9165e7b6ebe9ccbf
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Reviewed-on: http://openocd.zylin.com/1464
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
etm: prevent segfault when reading bogus information

When I do not have the JTAG adapter connected to the target, I often
end up always reading 1s from the chain. If the OpenOCD is configured
to connect to an ETM-equipped target (i.MX25 ARM9 in my case), this
results in writing garbage values in the etm reg_cache as the ETM bit
fields for the comparators, counters and outputs are wider than the
amount of entries in the corresponding arrays. This later results in a
segfault in the first etm_reg_lookup() call.

Change-Id: Ied81fdbf3a53a3dd749e2e5e97adf86c012df575
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/1505
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
target: fix halt and wait_halt timeout units

Documentation says they should be given values in milliseconds,
DEFAULT_HALT_TIMEOUT matches that too.

Change-Id: Ic1a30fa90f75b412c43fe50ba187d01c3d0a5fba
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/1504
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>