Commit Graph

5448 Commits

Author SHA1 Message Date
Paul Fertser
d0db4bfcec Makefile.am: link libusb-1.0 after libusb-0.1 to fix dependencies
Since libusb-0.1 might be provided by libusb-compat, it will depend on
libusb-1.0, so needs to be mentioned before it in the link command
line, this is relevant for static linking.

Thanks go to mingwandroid for spotting it during MSYS2 build.

Change-Id: I15cf0b8f084c351b4f93e75686bd0f843477352b
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2485
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2015-02-04 21:56:45 +00:00
Paul Fertser
35de943d35 flash/nor/stm32f2x: add new revisions of STM32F4x parts
Change-Id: I7585ccbe12fe079e960ce9e33d9a143672a6a08c
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2493
Tested-by: jenkins
Reviewed-by: Rémi PRUD'HOMME <prudhomme.remi@gmail.com>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2015-02-04 21:56:23 +00:00
Rémi PRUD’HOMME
fb1b388dea Subject: [PATCH] update src/flash/nor/stm32f2x.c
Add the new STM32F446 mcu with 512 Ko
Tested with a eval board

Change-Id: I0c16ce7d32d249c7634d697815207c20e7f778c4
Signed-off-by: prudhomme.remi@gmail.com
Reviewed-on: http://openocd.zylin.com/2484
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2015-02-04 21:56:13 +00:00
Uwe Bonnes
5ffe5b9b2c Add more STM32F3 IDs in target/stm32f3.cfg.
Change-Id: I4c4462aa025639c4d20e6fa23c8845a69e60afc5
Signed-off-by: Uwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>
Reviewed-on: http://openocd.zylin.com/2435
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2015-02-02 10:29:01 +00:00
Paul Fertser
d537cfa124 drivers/stlink: clarify "init mode failed" message
The message as it was didn't let the user know that something was wrong
with the target or wiring.

Change-Id: Ib609c2d31959e77413e61c348d0e31d7269d5c58
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2365
Tested-by: jenkins
Reviewed-by: Uwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>
Reviewed-by: Jens Bauer <jens@gpio.dk>
2015-01-30 09:44:24 +00:00
Paul Fertser
4f441486e5 jtag/drivers: remove useless checks causing build failure with clang 3.5.0
Change-Id: Icafab6ac1e3e79c6da1bc163c30744eee4bde8d3
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2482
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-by: Andreas Färber <afaerber@suse.de>
2015-01-30 09:02:20 +00:00
Andreas Fritiofson
f2c85452cf armv4_5: Continue the change from uint32_t to uint8_t[4] for regs
Also remove an unrelated no-op cast.

Change-Id: Ibeb6c72e5b0b0347abb568947a05a179661faf2d
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/2473
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
Tested-by: jenkins
2015-01-30 08:57:55 +00:00
Paul Fertser
355f4cadbb Use (uint8_t *) for buf_(set|get)_u(32|64) instead of (void *)
This helps to uncover incorrect usage when a pointer to uint32_t is
passed to those functions which leads to subtle bugs on BE systems.

The reason is that it's normally assumed that any uint32_t variable
holds its value in host byte order, but using but_set_u32 on it
silently does implicit pointer conversion to (void *) and the
assumption ends up broken without any indication.

Change-Id: I48ffd190583d8aa32ec1fef8f1cdc0b4184e4546
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2467
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2015-01-30 08:56:54 +00:00
Jens Bauer
9d745a0690 stm32f2x: Fix byte order bug.
Do not use buf_set_u32 on integers; they're not buffers.
If using buf_set_u32 on integers, bytes will be exchanged on Big Endian targets.
In this particular case, FLASH_OPTCR was incorrectly written, causing it to often
contain one of these values: 0x00aaaae1, 0x00aaffef, 0x00ffabe1 or 0x00abffe1.
This write-protected the device before flash-programming, causing this command...
flash write_image erase unlock myfile.elf
... to fail, complaining about write-protection.
Repeating the above command would change the OPTCR register each time.
After applying this patch, the OPTCR remains "unchanged".

Change-Id: I73d510fcc2e81a01973ad5c6e1aa22715ebd2743
Signed-off-by: Jens Bauer <jens@gpio.dk>
Reviewed-on: http://openocd.zylin.com/2466
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2015-01-30 08:55:23 +00:00
Paul Fertser
08da1b4258 flash/nor/kinetis: pull SRST low during mass erase
Mass erase operation might be impacted by different factors,
apparently the most reliable way is to do it while asserting the chip
reset line.

Change-Id: Id6ab57eaec86e402ffdf4f5c8843e7735640f03e
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2424
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2015-01-30 08:54:25 +00:00
Andreas Fritiofson
1fa4c728aa jtag: Rewrite TAP verification/auto-probe logic
Enable auto-creating additional discovered TAPs even if some TAPs are
predefined, avoiding initialization failure when it's not necessary.

Also, drop the arbitrary limit on the number of predefined TAPs. Still,
don't auto-create any if there are more than 20 TAPs already, to stop
a noisy connection from creating unlimited TAPs.

Create auto-probed TAPs with less noise.

Reduce code duplication between verification and auto-probing.

Change-Id: I82a504d92dbcc0060206e71f10c5158256b5f561
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/2236
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2015-01-28 08:01:43 +00:00
Uwe Kleine-König
24fb042a73 ARMv7-A: remove useless switch construct
The default label does just return the same error code as the case for
zero, so this can be handled by a simple if statement.

Change-Id: I61a8cb51b5e261f21eca386af7d8cbf17ffa2d44
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-on: http://openocd.zylin.com/2430
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2015-01-28 06:57:57 +00:00
Jaakko Kukkohovi
fe04314c2a jtag/drivers/cmsis-dap-usb: fix cmsis_dap_serial
Previously the serial wasn't actually used in hid_open() call,
which meant that the first device with matching vid:pid was opened
irrespective of the actual serial number.

Change-Id: I45216ae5d9e0798e97be693c30e2f03c89b9a02b
Signed-off-by: Jaakko Kukkohovi <jkukkohovi@gmail.com>
Reviewed-on: http://openocd.zylin.com/2487
Tested-by: jenkins
Reviewed-by: Jörg Wunsch <openocd@uriah.heep.sax.de>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2015-01-26 21:16:42 +00:00
Paul Fertser
d940a3224b jtag/drivers/stlink: demote the output of available speeds to DEBUG
Change-Id: If0afb6fb1cb2f39619e4e614573065c145255c3e
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2469
Reviewed-by: Jens Bauer <jens@gpio.dk>
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2015-01-26 20:56:25 +00:00
Paul Fertser
9a160c6334 jtag/hla_interface: avoid segfault with adapters that do not have configurable speed
Change-Id: I0386cbfc85ba8b28d3819530f9950b31545d6821
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2468
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2015-01-26 20:56:18 +00:00
Uwe Bonnes
d61795c625 stm32f07/9: Both devices have 256 kByte Flash Maximum.
See RM0091, Rev.7. page 56.

Change-Id: I9a98094d49739686f93e26a5112eb0a2a8a7c883
Signed-off-by: Uwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>
Reviewed-on: http://openocd.zylin.com/2458
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2015-01-26 20:55:31 +00:00
Uwe Bonnes
5b38f862f8 stm32f0x: Remove duplicate code for revision string.
As of RM0091, Rev. 7, all F0 have the same revisioning scheme.

Change-Id: I0b344a1d3ca3f61f48fa151e83c549ca5333ae47
Signed-off-by: Uwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>
Reviewed-on: http://openocd.zylin.com/2457
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2015-01-26 20:55:23 +00:00
Uwe Bonnes
5420ff3638 stm32f09x: Print info in get_stm32x_info.
Change-Id: I5f9b765fe04906e124e2c95ff6bf7193be9d4ce2
Signed-off-by: Uwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>
Reviewed-on: http://openocd.zylin.com/2456
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2015-01-26 20:55:17 +00:00
Uwe Bonnes
43aadbf5dc flash/nor/stm32f1: Add handling of stm32f09, nearly same as stm32f07.
Change-Id: I9cb2aa75decca0e8a065fe7f5353de44d6877274
Signed-off-by: Uwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>
Reviewed-on: http://openocd.zylin.com/2394
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2015-01-26 20:54:10 +00:00
Jörg Wunsch
03b1905223 flash: add AT91SAM4SD16C device
Change-Id: I12f740a1a2d10637b0e5b1e8d054dd912576d190
Signed-off-by: Jörg Wunsch <openocd@uriah.heep.sax.de>
Reviewed-on: http://openocd.zylin.com/2455
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2015-01-15 23:25:05 +00:00
Spencer Oliver
145f8ed817 stlink: add reconfigurable speed support
The ability to change the speed has been added to firmware versions J22 and
above. Any attempt to change on earlier versions will be ignored without error,
as the existing code does.

For supported firmware versions the driver will attempt to get as close as
possible to supported speeds (never higher).

The default stlink speed on power up is 1.8MHz.
The driver will now also print supported clocl speeds during init.

Change-Id: Iee9bd018bb8b6f94672a12538912d41c23d48a7e
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/2335
Tested-by: jenkins
2015-01-15 23:21:18 +00:00
Spencer Oliver
ab0432176c hla: add ability to change adapter speed (if supported)
As a note we need to cache the requested speed setting, as the
hla interface may not be ready when the first adapter_khz is called.

Change-Id: I2fa6807d5f0bd3f0365cf178bd10a230c39415a7
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/2334
Tested-by: jenkins
2015-01-15 23:21:01 +00:00
Paul Fertser
1f8518fef4 jtag/hla: output possible idcode candidates in case of mismatch
Output a similar message to what we have on low-level JTAG adapters to
avoid confusing users. Reported on IRC by chickensk.

Change-Id: I96d58410ef715b966e32d79c0aacf38596c5eb3f
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2451
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2015-01-15 23:17:29 +00:00
Evan Hunter
d25b43b163 jtag: Avoid extra SRSTn resets when connecting
Previously the jtag_add_reset(1, 0) caused the processor to be released,
and if SRSTn existed then it would then be reset again two lines later.

Change-Id: I58b7a12607f46f83caa7ed3b3cebc4195eb51ef6
Signed-off-by: Evan Hunter <ehunter@broadcom.com>
Reviewed-on: http://openocd.zylin.com/2398
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2015-01-15 23:16:06 +00:00
Nemui Trinomius
a39d1ced36 lpc2000: Improve lpc2000 flash driver.
This patch adds flash programming support for LPC5410x and LPC82x.
And adds auto flash size detection for LPC800 series.
Tested on below listed boards/chips.
LPC54102(LPCLPC54102Xpresso)
LPC824(LPCXpresso824-MAX)
LPC812(LPC812MAX)
LPC811,LPC810

Change-Id: Ie68b6d425b17ccfa83814607ee61056e99800c1c
Signed-off-by: Nemui Trinomius <nemuisan_kawausogasuki@live.jp>
Reviewed-on: http://openocd.zylin.com/2442
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2015-01-15 23:13:49 +00:00
Alexander Stein
1567caea2c cortex_a: Add support for A7 MPCore
A7 MPCore needs unlocking the debug registers same as with A15 MPCore.
Found out by hacking on the code.

Change-Id: I613cb4fb35007b85b4a9a401577b47768bc1a08b
Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
Reviewed-on: http://openocd.zylin.com/2344
Tested-by: jenkins
Reviewed-by: Kamal Dasu <kamal.dasu@gmail.com>
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2015-01-10 00:57:09 +00:00
Kamal Dasu
e519099ab7 cortex_a: Add support for A15 MPCore
Added Cortex-A15 support for DAP AHB-AP init code as per ADI V5 spec.
Also added changes to make the APB MEM-AP to work with A15.
Made the the cortex_a target code  generic to work with A8, A9
and A15 single core or multicore implementation. Added armv7a code
for os_border calculation to work for known A8, A9 and A15
platforms based on the ARM DDI 0344H, ARM DDI 0407F, ARM DDI 0406C
ARMV7A architecture docs.

Change-Id: Ib2803ab62588bf40f1ae4b9192b619af31525a1a
Signed-off-by: Kamal Dasu <kdasu.kdev@gmail.com>
Reviewed-on: http://openocd.zylin.com/1601
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2015-01-10 00:56:45 +00:00
Tomas Vanek
806872a34a ChibiOS: struct ChibiOS_params_list[] should not be const
Procedure ChibiOS_update_memory_signature() sets struct member signature.

Change-Id: I45adbd14fa7cda99413fd0b516d45b3fb55e322d
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/2427
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2015-01-09 08:56:10 +00:00
Karl Palsson
881d08ddbd transport: clarify error message when transport is not selected
When no transport is selected, the error message dumps the available
transports, but not how to actually select one.

Change-Id: I63da2a4b59e3f6cc8d30bd631e41a82636a056ef
Signed-off-by: Karl Palsson <karlp@tweak.net.au>
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2406
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2015-01-09 08:48:18 +00:00
Spencer Oliver
513436a17a flash: fix kinetis driver typos
Change-Id: I0a4557f08507c61cb8ab33b38d2b6b069c344c09
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/2385
Tested-by: jenkins
2015-01-09 08:47:39 +00:00
Salvador Arroyo
1d37b37dc7 avoid segfaulting when attempting to set an unavailable type of breackpoint
For example "bp 0x20000000 8 2" makes openocd segfaulting on a
stm32f4x Discovery board.

Change-Id: I1ddd46b1fa9ade78db2234ed975ccefb72539331
Signed-off-by: Salvador Arroyo <sarroyofdez@yahoo.es>
Reviewed-on: http://openocd.zylin.com/2342
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2015-01-09 08:46:45 +00:00
Jens Bauer
2eacb8fdfb Mac/PPC: Fix build.
GCC-4.2 on Mac/PPC complains about size_t is expected for %zx and the build stops.
In order to avoid other problems, I've chosen simply to typecast.

Change-Id: I99b569c4d1100e729712e31d24d6539f8b5971b6
Signed-off-by: Jens Bauer <jens@gpio.dk>
Reviewed-on: http://openocd.zylin.com/2360
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2015-01-09 08:42:15 +00:00
Paul Fertser
9f6d4d1302 swd: handle various failure conditions
When communication with target fails for whatever reason, it makes
sense to do JTAG-to-SWD (in case the target got power-cycled or the
DAP method was reset anyhow), SWD line reset sequence (part of
JTAG-to-SWD already) and the mandatory IDCODE read. Schedule that to
be performed on the next poll.

Fix the return values for ftdi and jlink drivers to be consistent with
OpenOCD error codes and remove ad-hoc calls to perform DAP method
switching (as it's now done from the upper layer automatically).

Change-Id: Ie18797d4ce7ac43d8249f8f81f1064a2424e02be
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2371
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-by: Mateusz Manowiecki <segmentation@fault.pl>
2015-01-09 08:36:52 +00:00
Paul Fertser
c120fb6d89 target: improve robustness of polling and reexamination
When a target was present on OpenOCD start but later disappeared for
whatever reason (typically unstable connection or target going to
sleep) and reappeared only for a brief period of time, reexamination
would fail, and poll would no longer run. This patch fixes it.

Change-Id: I61f9b5a3f366a761320e233f4e1689f926b5556d
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2370
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Tested-by: jenkins
2015-01-09 08:36:06 +00:00
Spencer Oliver
420bd49b5b rtos: free gdb packet allocated memory
compile tested only.

Change-Id: I3bc06c212967a3ce44a875f802b554c178537d1d
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/2382
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2015-01-09 00:19:11 +00:00
Andreas Fritiofson
1e23496f6e jtag: Remove unnecessary global variable
Change-Id: I96e5f13b12da2970eafc5fca24b7952d427eeca9
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/2235
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2015-01-07 23:23:14 +00:00
Andreas Fritiofson
9330147fae jtag: Fix memory leaks in jtag_tap_free()
Change-Id: I953fbb346fbf168fb50b349d245f2aa64dbfdcb3
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/2234
Tested-by: jenkins
2015-01-07 23:23:01 +00:00
Grigori Goronzy
c4b52f8fd7 lpc2000: ignore status of part ID IAP command
The IAP firmware won't return a proper status with some versions. This
happens on my CCC r0ket board and others have seen it as well [1]. So
just ignore the status code and do a (weak) consistency check instead.

[1] http://www.lpcware.com/content/forum/lpc1343-iap-read-part-identification-command

Change-Id: I0daa779d520a540629677c56857bbc20d6db422d
Signed-off-by: Grigori Goronzy <greg@chown.ath.cx>
Reviewed-on: http://openocd.zylin.com/2364
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2014-11-24 22:27:02 +00:00
Antony Pavlov
9777284ae0 or1k: remove address of the Free Software Foundation
The FSF address has changed; The FSF site says that
address is

  Free Software Foundation
  51 Franklin Street, Fifth Floor
  Boston, MA 02110-1301
  USA

(see http://www.fsf.org/about/contact/)

Instead of updating it each time the address changes,
just drop it completely treewide.

Change-Id: I27199f7625901f677d8105d1e8876cff00147b71
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Reviewed-on: http://openocd.zylin.com/2340
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-11-24 22:23:28 +00:00
Antony Pavlov
f16b7a6d7e mips32: fix typos
Change-Id: Ibb98fe3da68bf670a5bb83600bb49647db8a4163
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Reviewed-on: http://openocd.zylin.com/2338
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-11-24 22:22:53 +00:00
Christian Gudrian
f83e1dc13f Added FPU support for ChibiOS/RT
When an enabled FPU is detected we now use an appropriate stacking.

Change-Id: I1b0f43ec22e1c55c4f10e2ffa97d4aaa77bca5ee
Signed-off-by: Christian Gudrian <christian.gudrian@gmx.de>
Reviewed-on: http://openocd.zylin.com/2354
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-11-24 22:22:11 +00:00
Christian Gudrian
8b99681346 rtos: add support for ChibiOS/RT 3.0
In ChibiOS/RT 3.0 the ready list pointer "rlist" is now part of the system
data structure. Since the ready list is the first element in that
structure it can be accessed via the structure's symbol "ch".

Change-Id: Idc7eaa87cb7bbad0afa0ff1dafd54283bf429766
Signed-off-by: Christian Gudrian <christian.gudrian@gmx.de>
Reviewed-on: http://openocd.zylin.com/2352
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-11-24 22:21:47 +00:00
Paul Fertser
6d562283b5 rtos: allow symbols to be optional for a particular RTOS
Default to non-optional.

Change-Id: Ifc9ddb1ab701a19c3760f95da47da6f7d412ff2e
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2355
Tested-by: jenkins
Reviewed-by: Christian Gudrian <christian.gudrian@gmx.de>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-11-24 22:21:37 +00:00
Andrey Yurovsky
08607aefc0 flash: at91samd: fix use of is_erased in check
is_erased can be one of -1, 0, or 1 so it must not be checked like a
boolean value.  In this case we want to erase a page unless we know it's
already erased so we just check for is_erased != 1.

Thanks to Jim Paris for pointing this out on another driver.

Change-Id: I4591186228153b64e5a9608a2aac18745e578d4a
Signed-off-by: Andrey Yurovsky <yurovsky@gmail.com>
Reviewed-on: http://openocd.zylin.com/2368
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-11-24 22:18:59 +00:00
Paul Fertser
921eb4213a jtag/drivers/jlink: implement register command to fix SWD
Some J-Link fw versions require registration to be performed before
SWD operation is possible. It doesn't harm anyway, vendor's utilities
do it unconditionally.

Thanks go to Segger for providing the necessary information.

Change-Id: Iabd76c743eca86e2c817a97cb93c969fec3f7ac6
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2331
Tested-by: jenkins
2014-11-24 22:18:30 +00:00
Thomas Schmid
61de77ef88 at91sam4: Adding support for the AT91SAM4S4A.
Added the chip definition for the Atmel AT91SAM4S4A. This chip is a 48-pin
package with 256k flash and 64k ram.

Change-Id: I8ada7d5735e31e0ce086f96f5906c7358464245c
Signed-off-by: Thomas Schmid <thomas@rfranging.com>
Reviewed-on: http://openocd.zylin.com/2254
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-11-24 22:15:36 +00:00
Anders
1662c854e2 flash/nor/lpcspifi.c: fix bug that prevented clean reset after flash write
After SPI flash was written by the assembly language stub,
the last SPI command was not terminated by raising CS.
This left the SPI device in a hung state that prevented the
flash from being read by the M4 SPIFI controller, even after
the M4 was fully reset. To access the flash via SPIFI, it was
necessary to completely power cycle the board.

This fix adds the missing instructions to raise CS and
terminate the SPI command after the last byte. This allows
the M4 to be resumed or reset cleanly after flashing. The
SPIFI memory is now immediately accessable at address
0x1400 0000 after flashing is complete.

Change-Id: I4d5e03bded0fa00c430c2991f182dc18611d5f48
Signed-off-by: Anders <anders@openpuma.org>
Reviewed-on: http://openocd.zylin.com/2359
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-11-24 22:14:38 +00:00
Nemui Trinomius
78cad16187 lpc2000: Added LPC1500 series flash programming support.
This patch adds flash programming support for LPC1547/8/9 and LPC1517/8/9.
Tested on LPC1549(LPC1549 LPCXpresso Board with CMSIS-DAP firmware).

Change-Id: Ic95b4d62055bb9fdc2ca484696a38ccaf49ad951
Signed-off-by: Nemui Trinomius <nemuisan_kawausogasuki@live.jp>
Reviewed-on: http://openocd.zylin.com/2304
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-by: Grigori G <greg@chown.ath.cx>
2014-11-24 22:01:12 +00:00
Jim Paris
a59e8058e7 nrf51: fix checks for is_erased
is_erased can take the value 0 (no), 1 (yes), or -1 (unknown).
Checks like (!is_erased) don't do the right thing if it's -1.

Change-Id: I10ba32c99494ca803e0a7a1ba56fdd78184b96bb
Signed-off-by: Jim Paris <jim@jtan.com>
Reviewed-on: http://openocd.zylin.com/2366
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-11-24 21:54:11 +00:00
Jim Paris
56802d794e nrf51: verify that UICR needs erasing before triggering an error about it
If the UICR is already empty, there's no reason to return an error
just because it can't be erased again.  This happens, for example,
when flashing UICR from GDB after a "monitor nrf51 mass_erase".

Change-Id: Ia6d28c43189205fb5a7120b1c7312e45eb32edb7
Signed-off-by: Jim Paris <jim@jtan.com>
Reviewed-on: http://openocd.zylin.com/2363
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-11-24 21:54:02 +00:00
Jim Paris
f30bb58644 nrf51: fix UICR erase
nrf51_erase_page() checks for (sector->offset == NRF51_UICR_BASE) to
determine if the UICR should be erased.  However, sector->offset for
the UICR bank is set to 0 in nrf51_probe, so this code is never hit.
Attempting to erase UICR ends up erasing the first flash sector.

Use bank->base instead to determine if UICR is being erased.

Change-Id: Ie5df0f9732f23662085ae2b713d64968cd801472
Signed-off-by: Jim Paris <jim@jtan.com>
Reviewed-on: http://openocd.zylin.com/2362
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-11-24 21:53:38 +00:00
Jim Paris
6412b0656b nrf51: fix UICR region size
The UICR region is actually 0x100 bytes in size.  Besides making the
full region accessible, having the right value is important because
GDB rounds flash addresses to the nearest multiple of the block size
when determing which flash blocks to erase.

Change-Id: I416c391cbfc7be41a03a9b9c6e42326c87391f38
Signed-off-by: Jim Paris <jim@jtan.com>
Reviewed-on: http://openocd.zylin.com/2361
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Tested-by: jenkins
2014-11-24 21:53:24 +00:00
Peter Lawrence
30203b3d8b arm_adi_v5: added two CoreSight peripheral IDs
added "Single Wire Output" and "Trace Memory Controller" peripheral 
IDs to dap_rom_display(), which is invoked by the "dap info" command

Change-Id: Iea3201007bb98e6376fbb50be40a4a2e031b0a03
Signed-off-by: Peter Lawrence <majbthrd@gmail.com>
Reviewed-on: http://openocd.zylin.com/2369
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-11-03 19:30:59 +00:00
Spencer Oliver
885f438814 cmsis-dap: add serial number support
Change-Id: I66926d1013e2b3a43ce0d18d3599771428706b6a
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/2329
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-10-16 12:30:50 +00:00
Spencer Oliver
ef02315de3 cmsis-dap: refactor HID PID/VID check loop
In preparation for adding serial number support.

Change-Id: I3c9fb411b79d54a4d2de067039255436ba6708c7
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/2328
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-10-16 12:30:45 +00:00
Rémi PRUD'HOMME
832f0a5bfb stm32: add mass erase support for STM32L
The mass erase for STM32L was lack because the procedure is more complex
than the procedure for the STM32F4xx.

The reference manual RM0038 (L100 subfamily) page 79 is more accurate
than the reference manual for the STM32L0xx. On the L0, the mass-erase
erase also the EEPROM. This is a limit to mass erase on L0.

The mass erase procedure is a command of telnet interface.

Tested on Discovery L053 and Discovery L100.

Change-Id: I6a1d7a3669789aea89c59a006ab2d883f3d827ca
Signed-off-by: Rémi PRUD'HOMME <prudhomme.remi@gmail.com>
Reviewed-on: http://openocd.zylin.com/2319
Tested-by: jenkins
Reviewed-by: Andrey Yurovsky <yurovsky@gmail.com>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-10-06 18:41:30 +00:00
Paul Fertser
cdcae765de flash/nor/stellaris: implement protection statuses and procedures
This should make protection work as expected on all stellaris
families, including the latest Tiva C Snowflake.

Run-time tested on TM4C123x (Blizzard).

Change-Id: Ia017edb119bec32382b08fc037b5bbc02dd9000c
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2267
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-10-06 18:40:46 +00:00
Paul Fertser
487c57d9a2 libusb: introduce jtag_libusb_choose_interface() and use it for JLink
This introduces a new common function that allows auto-discovery of a
suitable USB interface based on class, subclass and protocol
matching. It claims the interface and returns the corresponding
endpoints number to the caller.

The need for this arised due to nRF51822 USB dongle which comes with
an "on-board Segger J-link debugger" having 3 interfaces, so the
current code can't work at all with it (in this particular case the
last interface needs to be choosen). This also removes special
handling of JLink-OB endpoint numbers as it's now possible to
autodetect them as well as the standard JLink endpoints.

Change-Id: I4d990a7a3b373efdd2949a394b32d855a168e138
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2327
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-10-06 18:40:39 +00:00
Paul Fertser
b631e78b25 flash/nor/stellaris: actually enable protection and unprotection with ICDI
This is still limited to pre-Snowflake parts and the first 64K of
flash.

Change-Id: I9ca872ada3d1a87dba6261464b2a72a15eda5ecf
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2264
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-10-06 12:03:36 +00:00
Paul Fertser
1f6a66ab7f hla: add a way to pass arbitrary commands from user to layout and use for ICDI
TI's ICDI adapter supports some additional commands which a user might
want to run for debugging or other purposes, the most useful of them
being "debug unlock" that fully mass-erases the device and unprotects
the flash.

Change-Id: I26990e736094367f92106fa891e9bb8fb0382efb
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2263
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-10-06 12:03:30 +00:00
Anders
61d8b2cabf jtag/drivers/jlink.c: fix for LPC Link-2 running JLink firmware on Linux
Change 2288 fixed the extraneous reset caused by set_configuration that
crashed the LPC Link-2 running JLink firmware and works on windows platforms.
On Linux however, conditional code was still calling USB reset and caused
the adapter to crash on any non-windows platforms.

Change-Id: Ibf2a02d0dcdd91ccb71d86231cd8311dcadfee1e
Signed-off-by: anders@openpuma.org
Reviewed-on: http://openocd.zylin.com/2297
Tested-by: jenkins
Reviewed-by: Xiaofan <xiaofanc@gmail.com>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-10-06 11:58:57 +00:00
Anders
ca8f8e7e77 jtag/drivers/libusb1_common: avoid device reset when reselecting configuration
According to [1], we shouldn't reselect an already active configuration to avoid needless device reset. This is known to cause issues with e.g. LPC Link2 with JLink firmware.

[1] http://libusb.sourceforge.net/api-1.0/caveats.html#configsel

Change-Id: I3568ada77780a521548c450090db7173f8d0b2dd
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Signed-off-by: Anders Oleson <anders@openpuma.org>
Reviewed-on: http://openocd.zylin.com/2288
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-10-06 11:58:32 +00:00
Spencer Oliver
48a681c741 helper: constify log_strings
Change-Id: I5bdd8958e79b754d56bb7aee2892856e557eed76
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/2296
Tested-by: jenkins
2014-10-06 11:57:44 +00:00
Spencer Oliver
3160c66408 target: constify structures
Change-Id: I875cfab8dec4ade72ed9c9cd7d52baaca182a1ef
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/2295
Tested-by: jenkins
2014-10-06 11:57:40 +00:00
Spencer Oliver
b675edcc95 jtag: constify driver arrays
Change-Id: I81574fa8ca3cc748526dc61b75a2c75d6335ef04
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/2294
Tested-by: jenkins
2014-10-06 11:57:36 +00:00
Spencer Oliver
36bc83b174 flash: constify driver data structures
Change-Id: Ia5c3de48119f036e1d7a41be62a672a6fb37e59b
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/2293
Tested-by: jenkins
2014-10-06 11:57:32 +00:00
Spencer Oliver
03410e92da rtos: constify symbol names and lists
Change-Id: I72f3cd50fc6a33a178e72e169c9660e707751524
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/2292
Tested-by: jenkins
2014-10-06 11:57:29 +00:00
Spencer Oliver
40815bd39a nuc1x: fix typos
Change-Id: Ia67b55ccb2bea71a99daa176def82960f487ca9f
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/2291
Tested-by: jenkins
2014-10-06 11:57:26 +00:00
Andrey Yurovsky
db4b2c2536 at91samd: fix protect, add EEPROM and boot commands
There were two problems with the _protect() feature:
1. The address written was off by a factor of two because the address
register takes 16-bit rather than 8-bit addresses.  As a result the
wrong sectors were (un)protected with the protect command.  This has
been fixed.
2. The protection settings issued via the lock or unlock region commands
don't persist after reset.  Making them persist requires modifying the
LOCK bits in the User Row using the infrastructure described below.

The Atmel SAMD2x MCUs provide a User Row (the size of which is one
page).  This contains a few settings that users may wish to modify from
the debugger, especially during production.  This change adds commands
to inspect and set:
- EEPROM size, the size in bytes of the emulated EEPROM region of the
  Flash.
- Bootloader size, the size in bytes of the protected "boot" section of
  the Flash.

This is done by a careful read-modify-write of the special User Row
page, avoiding erasing when possible and disallowing the changing of
documented reserved bits.  The Atmel SAMD20 datasheet was used for bit
positions and descriptions, size tables, etc. and testing was done on a
SAMD20 Xplained Pro board.

It's technically possible to store arbitrary user data (ex: serial
numbers, MAC addresses, etc) in the remaining portion of the User Row
page (that is, beyond the first 64 bits of it).  The infrastructure used
by the eeprom and bootloader commands can be used to access this as
well, and this seems safer than exposing the User Row as a normal Flash
sector that openocd understands due to the delicate nature of some of
the data stored there.

Change-Id: I29ca1bdbdc7884bc0ba0ad18af1b6bab78c7ad38
Signed-off-by: Andrey Yurovsky <yurovsky@gmail.com>
Reviewed-on: http://openocd.zylin.com/2326
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-10-06 11:56:40 +00:00
Andrey Yurovsky
592d0d514d at91samd: add erase/secure commands, minor fix
Reference code for the SAMD2x disables caching in the NVM controller when
issuing NVM commands.  Let's do this as well to be consistent and safer.

Add a "chip-erase" for the Atmel SAMD targets that issues a complete Chip Erase
via the Device Service Unit (DSU).  This can be used to "unlock" or otherwise
unbrick a chip that can't be halted or inspected, allowing the user to reflash
with new firmware.

Add a "set-security" command which issues an SSB.  Once that's done and the
device is power-cycled, the flash cannot be written to until a "chip-erase" is
issued.  The chip-erase cannot be issued by openocd at this time because
the device will not respond to a request for the DAP IDCODE.

Change-Id: I80122f0bbf7e3aedffe052c1e77d69dc2dba25ed
Signed-off-by: Andrey Yurovsky <yurovsky@gmail.com>
Reviewed-on: http://openocd.zylin.com/2239
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-10-06 11:56:27 +00:00
Paul Fertser
ec9ccaa288 arm_adi_v5: make dap_lookup_cs_component() traverse subtables and handle multicore
When looking for a debug base address of a core, one should search
through all the ROM tables, not just the top-level one.

This code also assumes that the first found entry (in a depth-first
search) will correspond to core 0, the second to core 1 etc.

The patch is supposed to be an alternative implementation of
http://openocd.zylin.com/#/c/1313/.

Change-Id: Ifc88971a02fe3d9c00d9bf72a822ade5804d4e09
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/1920
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-10-06 11:54:54 +00:00
Jon Burgess
1601c1a40b gdb_server: Include current RTOS thread in signal packets
This allows GDB to automatically switch to the thread that has
been interrupted and show you where it has stopped.

Change-Id: Icb9500dc42a61eb977e9fac55ce9503c9926bf5d
Signed-off-by: Jon Burgess <jburgess777@gmail.com>
Reviewed-on: http://openocd.zylin.com/2303
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-09-29 20:11:59 +00:00
Jon Burgess
0a5e03c12a cortex_m.c: Use two byte breakpoint for 32bit Thumb-2 request
When GDB requests a breakpoint on a 32bit Thumb-2 instruction it
sends a length of 3 which the current code rejects. Using the
existing two byte breakpoint for this case appears to work fine.

The use of length==3 for this case is mentioned in a few places:
https://sourceware.org/gdb/onlinedocs/gdb/ARM-Breakpoint-Kinds.html
http://sourceforge.net/p/openocd/mailman/message/30012280/

Change-Id: I59cd69ba4d1bc9a37b86569738c6bb2a67c3eb7a
Signed-off-by: Jon Burgess <jburgess777@gmail.com>
Reviewed-on: http://openocd.zylin.com/2312
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-09-29 20:06:41 +00:00
Simon Qian
b4f6338738 vsllink: improve the performance when using swd
Versaloon firmware has been updated for reporting
errors if fail on swd transactions.

Change-Id: I49ac0ad034cc9ad83cc4e43953579811d1243063
Signed-off-by: Simon Qian <openocd@versaloon.com>
Reviewed-on: http://openocd.zylin.com/2302
Reviewed-by: Fatih Aşıcı <fatih.asici@gmail.com>
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-09-29 20:06:20 +00:00
Andreas Fritiofson
c0b8e605f7 command: Fix confusing syntax error message
If the user executes a command with an invalid subcommand, the error
message is extremely unhelpful:

> flash write test.elf
flash write test.elf: command requires more arguments

This is because any command line that starts with a valid command group is
classified as a group, triggering ocd_bouncer to print the confusing
message.

Fix by requiring that to be a command group, the command line must not
contain any unknown tokens after the last valid (sub-)command group. That
is OK because command groups don't have handlers defined and thus can't
take any parameters.

Also fix the error message for "unknown" type to be similar to the error
message that is printed (by Jim) for non-existent primary commands.

Change-Id: I26950349f0909fd3961c4f9ab9b198c221cea9fc
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/2285
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-09-22 19:40:38 +00:00
Andreas Fritiofson
1c021ed0af target: Remove "-variant" argument
Remove this underutilized feature. Despite the fact that a lot of configs
specifies a arbitrary "variant", only the xscale target actually defines
any.

In the case of xscale, the use of -variant is dubious since

1) it's used as a redundant irlen specifier,
2) it carries a comment that it doesn't really need it and
3) only two xscale configs even specify it.

If there's a future target that needs a variant set, a target specific
option could be added when needed.

Change-Id: I1ba25a946f0d80872cbd96ddcc48f92695c4ae20
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/2283
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-09-22 19:39:24 +00:00
Joakim Gebart
b2973be9cc mpsse: Display libusb error names instead of numbers
Added calls to libusb_error_name() where applicable in order to easier
understand the error messages.

Change-Id: I3fe3d4b5624ae0de37c36e54a371eba5535ccaa1
Signed-off-by: Joakim Gebart <joakim.gebart@eistec.se>
Reviewed-on: http://openocd.zylin.com/2289
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-09-22 19:39:09 +00:00
Andrey Smirnov
9a42454c2b flash/nor/tcl.c: Do not double probe banks
Previous to this version the code of handle_flash_probe_command would
probe a bank twice: first time by auto-probe through a call to
flash_command_get_bank and second time by calling the probe function
directly. This change adds a flash_command_get_bank_maybe_probe wich
is a more generic version of the flash_command_get_bank, that would
allow commands to decide whether auto-probing should be performed or
not.

Change-Id: If150ca9c169ffe05e8c7eba36338d333360811e3
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Reviewed-on: http://openocd.zylin.com/2093
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-09-22 19:38:37 +00:00
Paul Fertser
e77b7447f7 target/arm_dpm: prevent endless loop in arm_dpm_full_context()
The code treats registers that are shadowed in FIQ mode in a special
way: to read them out the target is first switches to USR mode. But
since USR != ANY the current implementation later skips register read,
and the loop becomes endless in case any !valid ARM_MODE_ANY is
present at the moment arm_dpm_full_context() is called. This was
reported in https://sourceforge.net/p/openocd/tickets/76/. The issue
surfaced because 2efb1f14f6 added two
ARM_MODE_ANY registers ("sp" and "lr") which were not normally read,
so at the time a user was calling "arm reg" they were not valid.

Fix this by changing the mode appropriately while keeping the "mode"
variable state intact so it would later match register's mode.

Compile-tested only.

Change-Id: I01840e8fa20ec392220138a3f1497ac25deb080a
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2278
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-09-22 19:38:01 +00:00
Mahavir Jain
447fb25324 flash/nor: add mrvlqspi flash controller driver
This patch adds support for QSPI flash controller driver for
Marvell's Wireless Microcontroller platform.
For more information please refer,
https://origin-www.marvell.com/microcontrollers/wi-fi-microcontroller-platform/

Following things have been tested on 88MC200 (Winbond W25Q80BV flash chip):
1. Flash sector level erase
2. Flash chip erase
3. Flash write in normal SPI mode
4. Flash fill (write and verify) in normal SPI mode

Change-Id: If4414ae3f77ff170b84e426a35b66c44590c5e06
Signed-off-by: Mahavir Jain <mjain@marvell.com>
Reviewed-on: http://openocd.zylin.com/2280
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-09-22 19:37:09 +00:00
Mahavir Jain
e921c69e0e flash/nor/spi: Add Winbond w25q32fv flash support
Change-Id: I2919d462e04b489cc793b82ec347838a08cb8c48
Signed-off-by: Mahavir Jain <mjain@marvell.com>
Reviewed-on: http://openocd.zylin.com/2273
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-09-22 19:36:59 +00:00
Austin Phillips
7568a91c8e Support hla_serial command for ST-LINK adapters.
The hla_serial command allows for a programming device serial number to be
specified in addition to USB VID/PID.  This allows for multiple ST-LINK/V2
programmers to be attached to a single machine and operated using openocd.

Change-Id: I350654bf676eb26ba3a90450acfa55d2a5d2d791
Signed-off-by: Austin Phillips <austin_phillips@hotmail.com>
Reviewed-on: http://openocd.zylin.com/2198
Tested-by: jenkins
Reviewed-by: Martin Glunz <mg@wunderkis.de>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-09-22 19:36:05 +00:00
Andrey Skvortsov
3a4ec66b24 jtag: drivers: stlink: remove unnecessary '\n' in LOG_* entries
Change-Id: Ia2dc3efc27b53334af4d85f9807abba0463c291b
Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
Reviewed-on: http://openocd.zylin.com/2220
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-09-15 08:39:16 +00:00
Anders
dd93e0662e flash: added new Spansion S25FL116K, S25FL132K, and S25FL164K devices
The new FL1-K family is replacing the FL-K family. The data from all
three was based on the datasheet. In addition the 8MB S25FL164K was
tested successfully with OpenOCD on a custom board.

Change-Id: Idafeed86da12a481c0db92cc0de7ba28f50c2252
Signed-off-by: Anders <anders@openpuma.org>
Reviewed-on: http://openocd.zylin.com/2281
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-09-15 08:23:44 +00:00
Andrey Yurovsky
4efb3ebb76 stm32lx: don't allow part_info to be uninitialized
It's possible for us to fail to read the part ID code so make sure that
part_info is initialized to NULL before attempting to do so, otherwise
we could proceed and use it uninitialized and then segfault.

Change-Id: I0a3f3d3947690b66f0981b5046340449521e0b33
Signed-off-by: Jack Peel <jack.peel@synapse.com>
Signed-off-by: Andrey Yurovsky <yurovsky@gmail.com>
Reviewed-on: http://openocd.zylin.com/2276
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-09-15 08:23:12 +00:00
Andreas Fritiofson
45f01e0a12 cortex_m: Check return value from cortex_m_dcc_read.
Caught by clang.

Change-Id: I26d2b845aca431612862ef432b217ca397d9b893
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/2279
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-09-15 08:22:56 +00:00
Nemui Trinomius
de16280e02 stm32f2x: added STM32F411xx series support.
Added STM32F411xx series to flash driver.

Tested on NUCLEO-F411RE board(STM32F411RET6).

Change-Id: Id7d1f2858c09815a013e0590e65ad193fb039157
Signed-off-by: Nemui Trinomius <nemuisan_kawausogasuki@live.jp>
Reviewed-on: http://openocd.zylin.com/2258
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-09-08 21:34:25 +00:00
Paul Fertser
5774894a64 flash/nor/stellaris: add all Tiva C parts IDs
Luckily, TI's website has predictable URLs for the datasheets, so it
was trivial to download all the pdfs corresponding to the currently
available 71 TivaC devices. Then they were processed with pdftotext
and parsed by this script:

BEGIN { capture = -1 }
/^Device Identification 0 \(DID0\)$/ { state = "waitingclass0" }
/^Device Identification 1 \(DID1\)$/ { state = "waitingpartno0" }
/^CLASS$/ { if (state == "waitingclass0") state = "waitingclass"
    else if (state == "waitingclass") capture = 4 }
/^PARTNO$/ { if (state == "waitingpartno0") state = "waitingpartno"
    else if (state == "waitingpartno") capture = 4 }
(FNR == 3) { family = $2 }

{
    if (capture >= 0) {
	if (capture == 0) {
	    if (state == "waitingclass")
		class = $0
	    else if (state == "waitingpartno")
		partno = $0
	}
	capture--
    }
}

END { print "{" class ", " partno ", \"" family "\"}," }

Change-Id: I6820c409fe535f08394c203276b5af4406fe8b92
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2262
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-09-08 20:31:55 +00:00
Paul Fertser
76cabfc311 flash/nor/stellaris: improve support for Tiva C (Blizzard and Snowflake)
This should make current Tiva C parts usable apart from the protection.

Runtime tested on TM4C123GXL (Blizzard) and TM4C1294XL (Snowflake).

Change-Id: Ia64e9d39fbd2b7049578bbfade72435e5203ddf5
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2257
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-09-08 20:29:29 +00:00
Paul Fertser
96549bf012 jtag/drivers/libusb0_common: fix FTBFS (libusb_device_descriptor error)
This struct and libusb_get_device_descriptor() method are not present
in libusb-0.1 API, so when libusb-1.0 is unavailable, this code breaks
the build. Fix by using the appropriate struct (which is apparently
filled automatically on device initialisation).

While at it, change return values for consistency with the callers.

Change-Id: I7d85ab9a70401a155a65122397008ae4d81382fe
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2252
Tested-by: jenkins
Reviewed-by: Austin Phillips <austin_phillips@hotmail.com>
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-09-08 20:23:15 +00:00
Paul Fertser
f8318d1b0d target/adi_v5_swd: fix segfault when calling jtag_to_swd
When SWD mode is not supported by the target adapter, the call should
return an error instead of segfaulting.

Change-Id: I1626097deb93ecfbe78a6e82d812c7a673dbbde5
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2256
Tested-by: jenkins
2014-09-08 20:18:51 +00:00
Paul Fertser
bd0409aa93 jtag: always configure enabled tap parameter appropriately
Commit f701c0cb seems to have introduced a regression for non-JTAG
transports as the newly created "tap" (DAP actually) ended up being
disabled, thus resulting in total lack of functionality.

This was exposed by a debug log demonstrating ftdi SWD transport
connection to mdr32f9q2i, the target wasn't examined on init and
couldn't be reset.

Change-Id: If53cbe800d4adc177aa3ac3219860e7fa15b3e49
Reported-by: Хайруллин Эльдар <eldar.khayrullin@mail.ru>
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2261
Tested-by: jenkins
Reviewed-by: Angus Gratton <gus@projectgus.com>
Reviewed-by: Nemui Trinomius <nemuisan_kawausogasuki@live.jp>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-08-22 07:38:42 +00:00
Angus Gratton
f0dfa136ad target async loader: add offset to debug lines
This was very helpful when debugging programs during async loading.

Change-Id: Ia2eacc3e105403f70f51b1242b675e2ffe86e8ca
Signed-off-by: Angus Gratton <gus@projectgus.com>
Reviewed-on: http://openocd.zylin.com/2203
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-08-19 20:32:45 +00:00
Andrey Yurovsky
3751214b9c stm32lx: refactor and add support for STM32L0xx
This adds initial support for the STM32L0 family, specifically the ID
code 417 variant.  The 'L0 has 128B rather than 256B pages as well as a
different number of pages per sector.  It also has several key registers
and register sets in different locations from the STM32L1xx parts.

This change therefore takes the opportunity to reorganize part information into
a const table (it was previously determined by a set of control statements) and
abstracts away some of the low-level details to make them generic for L1 and
L0 parts.

We also include the first bank's size (for dual bank parts) in the new
device information table (and correct that size for the 0x437 variant
which is 256 rather than 192KB).

The 'L0 parts will not use the built-in loader/helper for Flash writing.

Tested on STM32L053 (dicovery board and Nucleo board) and STM32L152
(discovery board).

Change-Id: I57f7a8ab02caee266de71b31ae82a50d85728a0b
Signed-off-by: Andrey Yurovsky <yurovsky@gmail.com>
Reviewed-on: http://openocd.zylin.com/2200
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-08-19 20:32:07 +00:00
Angus Gratton
d50cc1bfea jtag/drivers/ftdi: Use adapter_khz value for initial clock speed (was default 1kHz)
nrf51822 doesn't like a 1kHz initial clock rate, puts the DAP into a bad state.

Mailing list discussion thread: http://sourceforge.net/p/openocd/mailman/openocd-devel/thread/20140718081528.GA5554%40ex2.lan/#msg32621853

Change-Id: I71aa75505cc1b41ee80c7b9db415f6ac738c2916
Signed-off-by: Angus Gratton <gus@projectgus.com>
Reviewed-on: http://openocd.zylin.com/2223
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-08-19 20:26:26 +00:00
Andrey Yurovsky
32e0fa6bcb flash: samd: add missing ID for SAMD20E18A
This was somehow missed in the chip ID table and of course that's
exactly the one on my board (as such, tested on hardware).

Change-Id: I212d7c729d979e0357f1d4635f40935e25fe6ff3
Signed-off-by: Andrey Yurovsky <yurovsky@gmail.com>
Reviewed-on: http://openocd.zylin.com/2260
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-08-19 20:24:02 +00:00
Spencer Oliver
47eceaa229 jlink: Constantify string arrays
Change-Id: Ib63f4c32e6d5a7dad21567521d938142ea40b308
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/2245
Tested-by: jenkins
2014-08-19 20:23:18 +00:00
Spencer Oliver
83265a4c70 jlink: add variant "J-Link Lite-ADI"
Fitted to various Analog Devices ADuCM36x dev boards.

Change-Id: Ib3691704c0ecd2f8cba1abba284aee695d6bc135
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/2244
Tested-by: jenkins
2014-08-19 20:23:15 +00:00
Spencer Oliver
c1c613bdbb jlink: fix typo
Change-Id: If495b819c0532a97447ec7208c13d8a66a3ad47d
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/2243
Tested-by: jenkins
2014-08-19 20:23:12 +00:00
Paul Fertser
0c4e991b76 flash/nor/stm32f1x: add STM32F302x6/8 IDs, clarify STM32F302xB/C
Change-Id: I22afbe30f32b0ea9b59c3de8d15ce14bdc4763cc
Reported-by: Luis Rodrigues <lfrodrigues@gmail.com>
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2249
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-08-19 20:21:34 +00:00
Robert Jarzmik
73123ccc57 jtag: usb_blaster: fix initialization regression
As Daniel pointed out, since the rewrite of the USB Blaster driver, the
initialization behaviour has change. The initial flush of the FIFOs is
not longer done with a specific USB setup packet, but with a write
filling up the blaster queues.

The problem is, quoting Daniel :

    When the CPLD is in bit banging mode (as is usually the case), the
    first 0x00 byte sets all pins to low and disables the output
    driver. Disabling the output drivers is a few nanoseconds slower
    than changing a pin from high to low, so I see a spike towards GND
    on my reset line when that byte is sent over USB. The spike is too
    short to have an effect on the board.

    When the 4096 0x00 bytes are processed and the TMS=1 is to be
    generated, all I see is several microseconds of low level on all
    pins, resetting my board.

This patch changes the way the initialization is done :
 - at driver init, nothing is sent towards the usb-blaster
   This gives time for init script to setup PIN6 and PIN8 (resets)
 - at the very first driver command, the initialization is done :
   - the output is in bit bigbang mode
   - the PIN6 and PIN8 are computed according to init script
   - the 4096 computed output is sent

Change-Id: If7ceee957f6b59bcb27c8f912f1cfdd0f94f75ed
Reported-by: Daniel Glöckner <daniel-gl@gmx.net>
Cc: Franck Jullien <franck.jullien@gmail.com>
Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
Reviewed-on: http://openocd.zylin.com/2229
Tested-by: jenkins
Reviewed-by: Franck Jullien <franck.jullien@gmail.com>
Reviewed-by: Daniel Glöckner <daniel-gl@gmx.net>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-08-19 20:21:02 +00:00
Paul Fertser
80ea805332 transport: emit a warning when a user tries to reselect a transport
Even though changing transport is impossible, reselecting it should be
harmless.

Change-Id: I6c1c2786134e826f47f848b590e6d712b6fd2206
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2251
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-08-19 20:19:58 +00:00
Oleksij Rempel
9402f8dc4e mips_m4k.c: EJTAGBOOT and NORMALBOOT are not supported on EJTAG 2.0
Change-Id: I8157c19e9d8aed5c2376a2c54c32c1ddac1ad5af
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Reviewed-on: http://openocd.zylin.com/1934
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-08-19 20:18:16 +00:00
Oleksij Rempel
ecb6f8c23e mips_m4k.c: D or I breaks only if they supported.
For example Realtek RTL8186 (Lexra LX5280 core) don't
support break- and watchpoints.

Change-Id: Ie00102da4bf13a8c42a9ad05910c66884f297cfd
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Reviewed-on: http://openocd.zylin.com/1933
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-08-19 20:18:09 +00:00
Oleksij Rempel
02ac60b000 mips32.c: cache debug caps and support EJTAG 2.0 specific changes
EJTAG v2.0 indicated some debug caps in IMP register.
V2.6 moved them to DCR register. To make it more universal,
convert this values and store them for later use.

Change-Id: Id6b9f47c9c2ea94d37281ebfcae5acf357261ddf
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Reviewed-on: http://openocd.zylin.com/1932
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-08-19 20:18:02 +00:00
Oleksij Rempel
c13ca4de40 mips32.c: fix IB and DB bits check for EJTAG v2.0
Change-Id: I4e28dddc1d5d9c2b923ae17beacdd7f73591b1d0
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Reviewed-on: http://openocd.zylin.com/1931
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-08-19 20:17:55 +00:00
Oleksij Rempel
91bfd9dbf2 mips_ejtag.c: do not set v2.6 ECR bits on v2.0 devices
Change-Id: I894abbb923282d5f84daf8e0bca69190c07567de
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Reviewed-on: http://openocd.zylin.com/1930
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-08-19 20:17:43 +00:00
Oleksij Rempel
ed085f379e mips_ejtag.c|h: use version specific IMPs
and make version specific debug log

Change-Id: I17f7ff757cfa1264a1dadbfe20c5e21de62ef87a
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Reviewed-on: http://openocd.zylin.com/1929
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-08-19 20:17:30 +00:00
Cristian Maglie
1fa24ebe39 Removed limit on lenght of command line options.
In particular -f and -s options may contains paths that can easily
exceed the (old) 128 bytes buffer.

Change-Id: Ifc198536549f50663e8e588519bb9ef75dcd172c
Signed-off-by: Cristian Maglie <c.maglie@bug.st>
Reviewed-on: http://openocd.zylin.com/2241
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-08-12 21:04:27 +00:00
Angus Gratton
9fce8a21ca stlink_usb: Fix swallowed error on read/write operations, add retries on SWD WAIT, clean up error debug output.
- stlink_usb_get_rw_status() had a bug where FAULT or WAIT responses
  in read/write operations were ignored, leading to incomplete data.

- Added wrapper stlink_cmd_allow_retry to handle
  SWD_AP_WAIT/SWD_DP_WAIT statuses in most commands. These statuses
  appear if an SWD read or write received a WAIT ACK response from the
  target more than 4 times in a row. The driver retries the operation
  (with exponential backoff) before failing outright (in testing 1
  retry was always enough.)

- As part of the implementation of stlink_cmd_allow_retry a large
  number of lines of boilerplate were refactored.

- Fleshed out stlink_usb_error_check and added it to some more code
  paths so WAIT or FAULT responses are logged to debug. WAIT responses
  will be logged even if they are subsequently retried, which should
  help in case the retries have subtle side effects (none
  anticipated.)

Tested with two targets: STLINK F0 Discovery, Nordic NRF51822. Only
tested with STLINK V2 programmers.

Change-Id: I9af24e8f0121b035356dbb9978d6bbf4feb2e4d3
Signed-off-by: Angus Gratton <gus@projectgus.com>
Reviewed-on: http://openocd.zylin.com/2201
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-08-11 22:34:52 +00:00
Paul Fertser
c7384117c6 Allow transports to override the selected target (hla configs unification)
This should allow to share common configs for both regular access and
high-level adapters.

Use the newly-added functionality in stlink and icdi drivers, amend
the configs accordingly.

Runtime-tested with a TI tm4c123g board.

Change-Id: Ibb88266a4ca25f06f6c073e916c963f017447bad
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
[gus@projectgus.com: context-specific deprecation warnings]
Signed-off-by: Angus Gratton <gus@projectgus.com>
[andrew.smirnov@gmail.com: additional nrf51.cfg mods]
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Tested-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
Reviewed-on: http://openocd.zylin.com/1664
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-08-11 21:25:56 +00:00
Angus Gratton
f701c0cbeb newdap: Ignore -irlen/-irmask/etc newdap params on SWD or CMSIS-DAP
Previously the -irlen parameter was required even though it is not
a part of the SWD or CMSIS-DAP transports.

This may eventually need to be changed for CMSIS-DAP once that
supports JTAG as well.

Change-Id: Ia02b67840c19c7cf1c7a75063648c0174176a311
Signed-off-by: Angus Gratton <gus@projectgus.com>
Reviewed-on: http://openocd.zylin.com/2226
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-08-11 20:49:05 +00:00
Andreas Fritiofson
f75345b915 drivers/jlink: Revert old workaround
This workaround broke usage with at least the I.MX6Q.

The comment implies that talking to the J-Link dongle itself should
fail if the target isn't reset, which sounds really strange. I'm
guessing it just triggered another bug in OpenOCD or Segger FW which
might have been fixed since. Revert and wait and see if there are any
failure reports.

Tested with Kwikstik (J-Link + Kinetis K40), not with the mentioned
adapter.

Change-Id: I97f555efe079bd99c098bf483491d9509b2363ad
Signed-off-by: Roy Spliet <rspliet@mpi-sws.org>
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/2147
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2014-08-02 13:54:39 +00:00
Paul Fertser
66e20117e8 drivers/jlink: fix SWD speed config, and set it before sending anything
During the initialisation a driver might need to communicate with the
target (e.g. sending jtag2swd sequence), so when doing so it should
honour the user-specified speed.

Change-Id: If84fea6057fda9edcf2c0a653edfbab2500e3cdd
[andrew.smirnov@gmail.com: fix khz/hz confusion]
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2224
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-08-02 13:53:59 +00:00
Paul Fertser
6733253219 drivers/jtag/jlink: support SWD mode
Quick attempt at SWD support, closely modelled after ftdi.

Change-Id: I25140d80c5be7b2f8f0e2ef722a4ba4df0da4cf3
Signed-off-by: Brian Campbell <Brian.Campbell@ed.ac.uk>
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2141
Tested-by: jenkins
Reviewed-by: Nemui Trinomius <nemuisan_kawausogasuki@live.jp>
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-08-02 13:53:33 +00:00
Andreas Fritiofson
91e47f3ab8 Fix some problems with the bin2char utility
Don't hardcode the type for the array, just output the array initializer
so the includer can choose the type and storage class, zero-terminate at
will and so on.

Change-Id: I6d5e0710eaaba0a218b3eb32f6569177356f4462
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/2176
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2014-08-02 09:01:32 +00:00
Paul Fertser
f1b04a20dc Provide od+sed replacement for the bin2char helper
Using custom build-time tools is always more problematic, especially
for cross-compiling.

This alternative implementation assumes "od" (IEEE Std 1003.1-2001)
and sed are available which should be the case for any reasonably
modern system.

Change-Id: I0208f475648c78e7dca127ff4bab60d314b2bf53
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2139
Tested-by: jenkins
Reviewed-by: Fatih Aşıcı <fatih.asici@gmail.com>
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-08-02 09:00:28 +00:00
Thomas Schmid
48d2431968 Adding support for the Atmel SAMR21.
The Atmel SAMR21 is a Atmel SAMD21 with an Atmel RF233 in one package (two
dies). Tested with the SAMR21 Xplained Pro eval kit.

Change-Id: I1d79ea05834b925d7ec810527206fe86854e684b
Signed-off-by: Thomas Schmid <thomas@rfranging.com>
Reviewed-on: http://openocd.zylin.com/2194
Tested-by: jenkins
Reviewed-by: Andrey Yurovsky <yurovsky@gmail.com>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-07-10 21:18:30 +00:00
Masaki Muranaka
11274d2283 drivers/cmsis_dap_usb: Return with ERROR_FAIL if no CMSIS-DAP device is found.
Even if it does not return, the initialization will be failed.
But it is better to show why the error is caused.

Change-Id: I399c7c94a7156be22723a9715e594061bb414a7e
Signed-off-by: Masaki Muranaka <monaka@monami-ya.com>
Reviewed-on: http://openocd.zylin.com/2189
Tested-by: jenkins
Reviewed-by: Andrey Yurovsky <yurovsky@gmail.com>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-07-10 21:18:08 +00:00
Oleksij Rempel
915e06b3f0 mips_m4k.c: make sure fast_data_area is safe
If load_image address overlap with fast_data_area,
it will caouse different mysterius issues. This patch
should prevent it.

Change-Id: Ibc95e5aa3ac002a59755029496b6a72616e9287f
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Reviewed-on: http://openocd.zylin.com/1854
Tested-by: jenkins
Reviewed-by: Salvador Arroyo <sarroyofdez@yahoo.es>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-07-10 20:00:22 +00:00
Nemui Trinomius
287d6e033a kinetis : Added Kinetis-K Series MDM-AP ID.
Kinetis-K series has ID:0x001C0000 on MDM-AP IDR register.
Other Kinetis(L/M/V/E) series have ID:0x001C0020.

Change-Id: Iada37038cd239f7331ba80a3673b36bf7e18c555
Signed-off-by: Nemui Trinomius <nemuisan_kawausogasuki@live.jp>
Reviewed-on: http://openocd.zylin.com/2195
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-07-04 10:06:01 +00:00
Kamal Dasu
59c2239bfd cortex_a: target implementation renames cortex_a8 to cortex_a
A previous commit changes the target name used by tcl scripts.
commit d9ba56c295
target: rename cortex_a8 to cortex_a

The current change renames target functions and definitions in the
implementation from cortex_a8 to cortex_a.
This prepares the implementation to support Cortex-A8, A9, A15-MPCore
in one place.

Change-Id: I73b5a38a92c12ba5bd3b806fbbb664817575a6d7
Signed-off-by: Kamal Dasu <kdasu.kdev@gmail.com>
Reviewed-on: http://openocd.zylin.com/1599
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-07-03 21:45:04 +00:00
Fatih Aşıcı
84281d711e vsllink: Port to libusb-1.0 API
Change-Id: I8a9a4dace8e7e8152947094b27b86f9a0d90fa61
Signed-off-by: Fatih Aşıcı <fatih.asici@gmail.com>
Reviewed-on: http://openocd.zylin.com/1952
Tested-by: jenkins
Reviewed-by: Nemui Trinomius <nemuisan_kawausogasuki@live.jp>
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-07-03 19:43:16 +00:00
Fatih Aşıcı
5f9c59409b vsllink: Add SWD support
Tested with stm32f1x, stm32f4x and kl25 targets using SWD transport.

Change-Id: I118d07371b53f402ea9ac73f874460a309c05100
Signed-off-by: Fatih Aşıcı <fatih.asici@gmail.com>
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/1947
Tested-by: jenkins
2014-07-03 19:43:01 +00:00
Paul Fertser
d48b47e432 jtag/drivers/opendous: remove ftime() calls
ftime() is deprecated by POSIX.1-2008 and causes a warning on
FreeBSD.

The generic OpenOCD LOG_DEBUG implementation already outputs time of
an event with a millisecond precision.

Change-Id: Ic8e4ea27c268f07554ba519768b9bdfc4343f3e9
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2187
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-07-03 18:41:39 +00:00
Paul Fertser
3039f01aaf drivers/cmsis_dap_usb: restructure init sequence a bit
This fixes the issue of improper initialisation sequence and in
particular makes "cmsis_dap_vid_pid" config specification functional.

Not really elegant but it's in line with the ftdi driver and so can be
reworked in a uniform way later when the internal API is changed.

Change-Id: Ief9fc64ad0ac24e1c66727153f383e4f30a830c7
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2192
Reviewed-by: Andrey Yurovsky <yurovsky@gmail.com>
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-07-03 18:40:59 +00:00
Paul Fertser
aa79f7b7e0 jtag/drivers/cmsis_dap: fix check for hardcoded vids/pids
This is intended to fix cmsis_dap_vid_pid command but it doesn't
because cmsis-dap has only one transport and it's auto-selected from
"interface" command handler (before any other commands are run) and as
the result cmsis_dap_usb_open() is called too early.

Change-Id: Idaade73797d8df67a6439d096f6abc9736495599
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2191
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-07-03 18:40:49 +00:00
Kamal Dasu
a74b5687a7 Openocd: svf: Add ability to ignore svf_check_tdo errors
Added Openocd commandline argument to ignore_error when the
read back TDO does not match to expected value specified with
TDO after masking with what is specified in MASK. This allows
to continue to play entire SVF file ignoring errors.
Error logs clearly show the failure reason and prints
read back TDO value.

Change-Id: I324f476fc16a003b35e6f2c5b63976431f49d54a
Signed-off-by: Kamal Dasu <kdasu.kdev@gmail.com>
Reviewed-on: http://openocd.zylin.com/2129
Tested-by: jenkins
Reviewed-by: Franck Jullien <franck.jullien@gmail.com>
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-07-03 18:08:48 +00:00
Mathias K
7c101b9e31 Add error handling and remove double readout.
Remove double readout of DCB_DHCSR in target poll. The return value
of the endreset event is handled and not ignored in target poll.

Change-Id: I8fe026418dadcf0b0dcbb09acee871ad950937a2
Signed-off-by: Mathias K <kesmtp@freenet.de>
Reviewed-on: http://openocd.zylin.com/1181
Tested-by: jenkins
Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
2014-06-28 18:50:53 +00:00
Paul Fertser
52b80fbd82 jtag/drivers/ftdi: do not touch unavailable reset signals
If the current reset_config doesn't specify availability of nTRST or
nSRST, just leave them alone, do not try to deassert them ever
(asserting would be prevented by the upper layer).

Change-Id: I90123c666e05a1c26f1e164625e82d766a3e3744
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2186
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-06-28 16:52:08 +00:00
Paul Fertser
bf96df255e jtag/drivers/ftdi: require defining SWD_EN signal for SWD mode
Use a special signal instead of a dedicated swd mask. Amend
jtag-lock-pick_tiny_2 config accordingly.

Change-Id: Ifb007a0b5434b590c52f936efd5f5458e913e2e4
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2183
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Tested-by: jenkins
2014-06-28 09:36:53 +00:00
Paul Fertser
64d02ccf82 jtag/drivers/ftdi: declare standard JTAG signals on SWD init
Unfortunately, this means they're available for config files only
after selecting swd transport.

Change-Id: Ia2afc1f3bfdba8d81efbb8ab964b174c0f7e2811
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2182
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-06-28 09:36:17 +00:00
Paul Fertser
a87e699edf jtag/drivers/ftdi: add option to declare signal aliases
This adds -alias|-nalias options to ftdi_layout_signal command that
allow to declare a new signal based on an already defined one.

Change-Id: I552578ebcd12ae21957a1c0d3b7e878adeff6df0
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2181
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-06-28 09:36:02 +00:00
Paul Fertser
335bafbb25 Auto-select JTAG transport when appropriate
I looked through all the target configs after stripping comments and
such from them with sed to see what jtag-specific commands can appear
first, and it looks like all the meaningful combinations should be
covered.

Change-Id: I8d543407b7f4ac8aca7354ecd50e841c8a04d5f3
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2179
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-06-28 09:35:38 +00:00
Andreas Fritiofson
12e9f6292b Relax polling check if not in JTAG mode
Polling was disabled based on global variables jtag_trst and jtag_srst
which were never touched in non-JTAG mode. Modify the check and remove
the ugly workaround to avoid calls to a possibly uninitialized JTAG
subsystem.

Change-Id: I3b18c81e0fba7aaf35afe6f08c3fe8fa6f8443fd
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/2143
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2014-06-28 09:34:55 +00:00
Andreas Fritiofson
cdd8928a56 Add FTDI SWD driver
This is usable on most or all FTDI adapters using a small hardware tweak.

TCK goes to SWCLK as expected. TDO should be wired to SWDIO. For TDI there
are two options:

Either add a 74HC126 or similar tri-state buffer between TDI and SWDIO,
with OE controlled by a signal named SWDIO_OE. Or simply connect TDI and
SWDIO together via a suitable resistor (220-470 ohms or so depending on
the drive capability of the target and adapter).

nSRST (and of course Vcc, GND) may be connected too but all other signals
should be NC.

Change-Id: Id36cf4577439be96bd4e5955c3026236e1cabced
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/1958
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2014-06-28 09:34:26 +00:00
Andreas Fritiofson
cc99e57b0e transport: Constify the transports vector
Change-Id: I0c874b5d4c97cf781d83bd381d701f770e069f72
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/2135
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2014-06-28 09:33:31 +00:00
Andreas Fritiofson
ae3bcd05f8 swd: Add frequency setting and special/switching sequences to the API
Change-Id: I6f3950374f2525a18bbcb9cbd340c447c20fb704
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/2134
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2014-06-28 09:33:12 +00:00
Andreas Fritiofson
003f8a1d04 adi_v5: Make sure all bit masks are unsigned and wide enough.
Also align them with spaces instead of tabs.

Change-Id: I1c01412a3ea77b29e8e133f5c92d05ed79d7c0f3
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/2133
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2014-06-28 09:32:41 +00:00
Andreas Fritiofson
5a7eae940b swd: Remove support for turnaround periods other than 1
ARM deprecated other trn periods in ADIv5.1 and one cycle is the only
setting that is guaranteed to be implemented, as well as being the reset
value in ADIv5.0.

Thus it makes no sense supporting anything else.

Change-Id: Iffa16bb0ce74788bca88fd3ace8a026148013d00
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/2132
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2014-06-28 09:32:21 +00:00
Andreas Fritiofson
bc91cdad3c swd: Fix park bit polarity according to ADIv5.1 Supplement
Change-Id: I27293defd3f3c3bf37c9662f88689e85ba593d86
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/2131
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2014-06-28 09:31:55 +00:00
Andreas Fritiofson
d2bb14e36a swd: Convert API to asynchronous
Change-Id: I859568dbb2ad4e92411980751c3f747bd70638b8
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/1959
Tested-by: jenkins
Reviewed-by: Andrey Yurovsky <yurovsky@gmail.com>
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2014-06-28 09:31:38 +00:00
Andrey Smirnov
2268b77142 adi_v5_cmsis_dap.c: Simplify debugging output
Name of the function is already a part of the LOG_DEBUG macro, so
there's no need to include it in the string itself.

Change-Id: I18c3d5b746e9106d55104e490ccf5bc5e85cc380
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/2138
Tested-by: jenkins
2014-06-28 09:31:10 +00:00
Andrey Smirnov
ccf4d6d648 cortex_m: Do additional initialization during reset
SAM4L requires additional steps to be taken right after SYSRESETREQ is
issued in order to function robustly:

       - CMSIS-DAP DAP driver needs to explicitly check for sticky bit
         errors since it is possible for adapter to perform successful
         write opration, report no errors and then, under the hood, do
         some other things that will result in sticky bit being set.

       - Debugger needs to wait for security system to finish
         intialization and assert CDBGPWRUPACK before proceeding

This change is related to commit http://openocd.zylin.com/#/c/1995/

Change-Id: I741c95a809bfd60d930cec9482239e4796a62326
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Reviewed-on: http://openocd.zylin.com/2088
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-by: Andrey Yurovsky <yurovsky@gmail.com>
2014-06-28 09:30:09 +00:00
Andrey Smirnov
d6fd5d0f9b adi_v5_cmisis_dap: Separate ABORT from clearing sticky errors
We don't need to do full blown AP ABORT in case of CMSIS-DAP errors,
and the code that was in place was not doing that(issuing AP ABORT)
anyway.

Change-Id: Ide83b1f8875d725da6cb0d53aae8229f8c6316b3
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/2112
Tested-by: jenkins
Reviewed-by: Andrey Yurovsky <yurovsky@gmail.com>
2014-06-28 09:29:36 +00:00
Paul Fertser
6db70bc89b drivers/cmsis_dap_usb: remove jtag reset hacks
This should no longer be needed after tcl scripts are fixed to avoid
calling jtag subcommands when jtag is not used.

Barely tested with an frdm board.

Change-Id: I75f02b088e6134562ae634417d97c48e377df6e9
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2130
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-06-28 09:28:36 +00:00
Paul Fertser
f8a6a07149 tcl: introduce using_(jtag|swd|hla) helpers and use them in reset handler
Barely tested with plain SWD transport.

Change-Id: I48b59136bf4294ffed737dba01f1b30ef83aa86b
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2003
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2014-06-28 09:28:12 +00:00
Andreas Fritiofson
36772a7ed0 swd: Improve parity calculation and move it to types.h
It could be reused by SWD drivers and in other places.

Change-Id: Ieed0cf70c111a73d3a42ed59f46a0cdd177a73d5
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/1957
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2014-06-28 09:27:19 +00:00
Andreas Fritiofson
0e95ec4070 adi_v5_swd: Separate sticky error clearing from AP abort
Swd_queue_ap_abort should set DAPABORT, not only clear sticky errors.
However, DAPABORT should not be set as soon as there is a single
FAULT/WAIT response. It's an "emergency only" operations for use only when
the AP have stalled the transfer for a long time. So these need to be
separate functions.

Change-Id: I37618447884faad54d846c2b07fa668ad505919d
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/1956
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2014-06-28 09:26:54 +00:00
Andreas Fritiofson
677b02b475 adi_v5: Remove unused features of the DAP and SWD interfaces
These features are not currently used so remove or disable them before
something starts to. Not having them around simplifies redesign of the
APIs.

Change-Id: Iad25cc71c48b68a1fa71558141bf14d5ab20d659
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/1955
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2014-06-28 09:26:36 +00:00