openocd.git
6 months agotcl_server: fix minor typo in comment 63/4863/2
Peter Lawrence [Sun, 20 Jan 2019 21:12:22 +0000 (15:12 -0600)]
tcl_server: fix minor typo in comment

ctrl-z usage is incorrectly commented as ctrl-d

Change-Id: I54fe1775760ee984154bbae380baa38bcaffa04e
Signed-off-by: Peter Lawrence <majbthrd@gmail.com>
Reviewed-on: http://openocd.zylin.com/4863
Tested-by: jenkins
Reviewed-by: Christopher Head <chead@zaber.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
6 months agotarget/arm_adi_v5: fix typo 01/5001/2
Mete Balci [Thu, 28 Mar 2019 09:35:30 +0000 (10:35 +0100)]
target/arm_adi_v5: fix typo

Fixed the small typo.

Change-Id: Ia8834b23302d25e92cb2fa0802bebb2a9416595b
Signed-off-by: Mete Balci <metebalci@gmail.com>
Reviewed-on: http://openocd.zylin.com/5001
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
6 months agoflash/nor/core.h: clarify comment flash_sector::is_erased 68/4768/2
Tomas Vanek [Thu, 15 Nov 2018 23:23:10 +0000 (00:23 +0100)]
flash/nor/core.h: clarify comment flash_sector::is_erased

Setting of flash_sector::is_erased in flash erase and mass erase
is popular folklore. Make clear it is useless.

Change-Id: Ide397eb6d24fc8fa38931e6c8a0693d39668a5d2
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4768
Tested-by: jenkins
Reviewed-by: Christopher Head <chead@zaber.com>
6 months agohelper/startup.tcl: remove proc exit 86/4986/2
Antonio Borneo [Mon, 4 Mar 2019 16:27:32 +0000 (17:27 +0100)]
helper/startup.tcl: remove proc exit

The TCL command exit is already replaced by the OpenOCD command
exit in server/telnet_server.c, no need to redefine it in the
script.
Moreover, the implementation is broken because the proc ocd_throw
has been removed in mid 2008 with pre-git-era commit dfbb9f3e89ae
in svn rev 849.

Remove completely the unused proc exit.

Change-Id: I0365d740eccc47631eb459aab77b865b0877c1f7
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/4986
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
6 months agoarmv7a_mmu: Remove warning on va = pa 07/5007/2
Florian Fainelli [Sun, 31 Mar 2019 01:20:07 +0000 (18:20 -0700)]
armv7a_mmu: Remove warning on va = pa

Depending on how the MMU is configured it is possible to have a 1:1
mapping between virtual and physical addresses, thus making this warning
bogus. We already check that the MMU is enabled in the caller:
cortex_a_virt2phys().

Change-Id: I09f4c53ef933c8d1e268da5215a769449be014bc
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-on: http://openocd.zylin.com/5007
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Kamal Dasu <kdasu.kdev@gmail.com>
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
6 months agotarget/cortex_m: remove target halted check when removing a breakpoint 87/4887/2
Tomas Vanek [Wed, 6 Feb 2019 18:07:15 +0000 (19:07 +0100)]
target/cortex_m: remove target halted check when removing a breakpoint

Remove the target halted check from cortex_m_remove_breakpoint()
as there is no such check in cortex_m_set_breakpoint() and bp can be
safely removed from the running target.

While on it return the error code from cortex_m_unset_breakpoint()
to higher level.

Change-Id: I2b358c3661feed84297913e9f589bdf1e4de7e64
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4887
Tested-by: jenkins
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
Reviewed-by: Jānis Skujenieks <janis.skujenieks@gmail.com>
Reviewed-by: Christopher Head <chead@zaber.com>
6 months agotarget/cortex_m: remove fp_code_available counting 70/4870/5
Tomas Vanek [Thu, 24 Jan 2019 12:36:39 +0000 (13:36 +0100)]
target/cortex_m: remove fp_code_available counting

fp_code_available looses sync with the real number of free comparators
as soon as cortex_m_set_breakpoint() returns an error. Remove the counter
and always go through the fp_comparator_list to find a free one.

Change-Id: I9f6e06c36d8a57ad11df5155e8a1a3aff6d833a5
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4870
Tested-by: jenkins
Reviewed-by: Jānis Skujenieks <janis.skujenieks@gmail.com>
Reviewed-by: Christopher Head <chead@zaber.com>
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
6 months agotarget/cortex_m: simplify cortex_m_unset_breakpoint() 89/4889/2
Tomas Vanek [Thu, 7 Feb 2019 13:18:17 +0000 (14:18 +0100)]
target/cortex_m: simplify cortex_m_unset_breakpoint()

Cortex-M uses only 2 byte breakpoint instruction.
cortex_m_unset_breakpoint() does not need to check breakpoint->length,
use the length as the size argument in target_write_memory()

Change-Id: I20bb869f6abce2fc61f0469e34a638bc4dc6f7ce
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4889
Tested-by: jenkins
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
Reviewed-by: Jānis Skujenieks <janis.skujenieks@gmail.com>
Reviewed-by: Christopher Head <chead@zaber.com>
6 months agoConstify struct flash_driver instances 03/4803/3
Christopher Head [Thu, 13 Dec 2018 19:53:59 +0000 (11:53 -0800)]
Constify struct flash_driver instances

Instances of struct flash_driver are never written to at runtime. For a
small amount of memory saving and also robustness (fewer things for
stray pointer writes to hit), mark them const.

Change-Id: Iadbbbc2fac0976d892699200000c5f02856729f3
Signed-off-by: Christopher Head <chead@zaber.com>
Reviewed-on: http://openocd.zylin.com/4803
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
6 months agosmp: move sub-command "smp_gdb" in file smp.c 91/4991/3
Antonio Borneo [Thu, 7 Mar 2019 21:34:29 +0000 (22:34 +0100)]
smp: move sub-command "smp_gdb" in file smp.c

The code for this command is currently replicated in cortex_a and
in mips_m4k and is going to be added again for cortex_m.
Plus, it is going to be obsoleted by the HW thread pseudo RTOS.

Consolidate in smp.c a single instance of the command. This will
simplify both obsoleting it and adding it to cortex_m, whatever
change comes first.

Change-Id: I03cd857e21fa3f7202fdcee36bcbd5aae30a609d
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/4991
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
6 months agosmp: replace commands smp_on/smp_off with "smp [on|off]" 15/4615/3
Antonio Borneo [Thu, 19 Jul 2018 09:50:56 +0000 (11:50 +0200)]
smp: replace commands smp_on/smp_off with "smp [on|off]"

Seams over-engineered having two separate commands to turn SMP
on/off. Plus it is missing the possibility to dump the current
status of SMP and would be weird adding an additional command
for it. Moreover, such commands are replicated in few targets so
it would make sense centralizing them.

- Deprecate the commands "smp_on" and "smp_off".
- Add a new command "smp" that accepts optional parameters
  "[on|off]" and prints the SMP status when run without
  parameters. This replaces the two commands above.
- Put the deprecated and the new command handlers in smp.c
- Update the documentation, except for mips_m4k, since it is not
  available yet.
- Promote the macro foreach_smp_target to global context and use
  it where possible.

Change-Id: Ia72841c1a3bd6edd4db4cc809046322f498617e6
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/4615
Tested-by: jenkins
Reviewed-by: Graham Sanderson <graham.sanderson@gmail.com>
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
6 months agoimx8m: add an m4 target to the imx8m 01/4501/3
Angus Ainslie [Thu, 19 Apr 2018 19:21:55 +0000 (13:21 -0600)]
imx8m: add an m4 target to the imx8m

The imx8m also has a Cortex m4 so add a target for it.

Change-Id: I2abf62b6232c547fe9b12507f459835b11c63a6d
Signed-off-by: Angus Ainslie <angus@akkea.ca>
Reviewed-on: http://openocd.zylin.com/4501
Tested-by: jenkins
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
6 months agoflash/nor/core: adjust flash_iterate_address_range_inner() for 64-bit 85/4985/2
Tomas Vanek [Sat, 2 Mar 2019 08:51:23 +0000 (09:51 +0100)]
flash/nor/core: adjust flash_iterate_address_range_inner() for 64-bit

Use target_addr_t exclusively for comparison of sector boudaries and
address range.

Use the last addres for both address range end and sector end.
It avoids problems with a flash bank mapped at the very end of
target address space.

Change-Id: Idf97c837453d97cbc4cf8a1c76ad799f4142f19e
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4985
Tested-by: jenkins
Reviewed-by: Tim Newsome <tim@sifive.com>
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
6 months agoLots of RISC-V improvements. 22/4922/3
Tim Newsome [Fri, 15 Feb 2019 20:08:51 +0000 (12:08 -0800)]
Lots of RISC-V improvements.

This represents months of continuing RISC-V work, with too many changes
to list individually. Some improvements:
* Fixed memory leaks.
* Better handling of dbus timeouts.
* Add `riscv expose_custom` command.
* Somewhat deal with cache coherency.
* Deal with more timeouts during block memory accesses.
* Basic debug compliance test.
* Tell gdb which watchpoint hit.
* SMP support for use with -rtos hwthread
* Add `riscv set_ir`

Change-Id: Ica507ee2a57eaf51b578ab1d9b7de71512fdf47f
Signed-off-by: Tim Newsome <tim@sifive.com>
Reviewed-on: http://openocd.zylin.com/4922
Tested-by: jenkins
Reviewed-by: Philipp Guehring <pg@futureware.at>
Reviewed-by: Liviu Ionescu <ilg@livius.net>
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
6 months agostlink: Set speed before entering JTAG/SWD mode 18/4818/4
Frans-Willem Hardijzer [Sat, 22 Dec 2018 11:03:43 +0000 (12:03 +0100)]
stlink: Set speed before entering JTAG/SWD mode

Some boards require a slower clock speed because of passive components on the
JTAG/SWD lines. The previous implementation would first try to discover the
chips on the default speed, and only after discovery switch to the requested
adapter_khz speed.

This patch moves the speed change to just before entering the SWD/JTAG mode,
which should alleviate this problem.

Tested on an STLink V2 clone.

Change-Id: I9734452dcc8bb28d6629e64d9a7e32ef92868cf9
Signed-off-by: Frans-Willem Hardijzer <fw@hardijzer.nl>
Reviewed-on: http://openocd.zylin.com/4818
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
6 months agomips32: pracc: Fix indent 95/4995/2
Marek Vasut [Fri, 1 Mar 2019 12:58:19 +0000 (13:58 +0100)]
mips32: pracc: Fix indent

Fix indent of the macros in header file, no functional change.

Change-Id: I4d1dba5725155200148d1543c45bad919f6cd37e
Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
Reviewed-on: http://openocd.zylin.com/4995
Tested-by: jenkins
Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
6 months agomips32: pracc: Fix UPPER/LOWER macros 94/4994/2
Marek Vasut [Fri, 1 Mar 2019 12:56:44 +0000 (13:56 +0100)]
mips32: pracc: Fix UPPER/LOWER macros

These macros are missing parenthesis around the argument, which can
lead to side effects, add them. Replace the argument name to avoid
conflict with uint32_t data type, since the macro can be applied to
other data types as well.

Change-Id: I32d2ffec6c062795d7c8bb23d1dfa3378bfc3a58
Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
Reviewed-on: http://openocd.zylin.com/4994
Tested-by: jenkins
Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
7 months agotarget/mips: Use 'bool' data type 70/4970/3
Marc Schink [Tue, 26 Feb 2019 13:10:48 +0000 (14:10 +0100)]
target/mips: Use 'bool' data type

Change-Id: Ifb114bfc062ed7c0ff6e4f37a1a6d546f5415344
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/4970
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
7 months agotarget/xscale: Use 'bool' data type 68/4968/3
Marc Schink [Tue, 26 Feb 2019 13:09:46 +0000 (14:09 +0100)]
target/xscale: Use 'bool' data type

Change-Id: I4e117f4e6c8c0850f565587f68f41d88da0d6b0b
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/4968
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
7 months agotarget/dsp563xx: Use 'bool' data type 62/4962/3
Marc Schink [Tue, 26 Feb 2019 13:07:20 +0000 (14:07 +0100)]
target/dsp563xx: Use 'bool' data type

Change-Id: Ie7ee82bf04c76ef899ae8b19105158e71b69ae2c
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/4962
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
7 months agoflash/stm32h7x: remove IWDG1_SW separate variable 44/4744/3
Christopher Head [Tue, 30 Oct 2018 21:37:22 +0000 (14:37 -0700)]
flash/stm32h7x: remove IWDG1_SW separate variable

Bit 4 in OPTSR is IWDG1_SW (the code originally called it IWDG1_HW, but
the reference manual refers to it as IWDG1_SW). This is broken out into
a separate variable, independent_watchdog_selection, in stm32x_options.
However, this is not necessary: bit 4 is included in the user_options
field, which includes all of bits 2 through 7, and
independent_watchdog_selection is not referenced anywhere else. Delete
the field and just rely on user_options to transport that bit, along
with all the other bits it contains, between stm32x_read_options and
stm32x_write_options.

Change-Id: I4da63df9272cf091267b956c412b95671ea1d3c9
Signed-off-by: Christopher Head <chead@zaber.com>
Reviewed-on: http://openocd.zylin.com/4744
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
7 months agotarget/adi_v5_swd: improve error check while updating DP_SELECT 80/4980/4
Antonio Borneo [Thu, 28 Feb 2019 11:29:49 +0000 (12:29 +0100)]
target/adi_v5_swd: improve error check while updating DP_SELECT

Write to register DP_SELECT can fail, but both functions
swd_queue_dp_bankselect() and swd_queue_ap_bankselect() return
void and do not propagate the error.

Change the return type of the two functions to int and check the
returned value.
Invalidate the cached value of DP_SELECT if the write fails.

Change-Id: Iba6ef8b0c2332e7f7efb66337d558fb7a4a0d39c
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/4980
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
7 months agotarget/adi_v5_swd: update cached value on write to DP_SELECT 79/4979/2
Antonio Borneo [Thu, 28 Feb 2019 10:31:11 +0000 (11:31 +0100)]
target/adi_v5_swd: update cached value on write to DP_SELECT

When the register DP_SELECT is written directly, e.g. with command
<dap> dpreg 8 <value>
the cached value in OpenOCD is not completely updated with the new
value, thus creating issues in the following AP and DP read/write
that rely on the cached value.

Update the cached value while writing to DP_SELECT.

Change-Id: I8221b10cd6fc1fbe73e6b834b68820b43480e1a2
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/4979
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
7 months agotarget/breakpoints: make internal functions static 88/4888/2
Tomas Vanek [Thu, 7 Feb 2019 13:17:03 +0000 (14:17 +0100)]
target/breakpoints: make internal functions static

While on it add two missing new lines.

Change-Id: I0d54740479bc462b734f91686f0931824796b598
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4888
Tested-by: jenkins
Reviewed-by: Marc Schink <openocd-dev@marcschink.de>
7 months agoflash/nor/tcl.c: use COMMAND_PARSE_ADDRESS 77/4977/2
Tomas Vanek [Wed, 27 Feb 2019 01:31:30 +0000 (02:31 +0100)]
flash/nor/tcl.c: use COMMAND_PARSE_ADDRESS

instead of conditional compilation #if BUILD_TARGET64

Change-Id: I005ae0b3a4ed127c0f59219b1c6b185a2c76c76e
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4977
Tested-by: jenkins
Reviewed-by: Tim Newsome <tim@sifive.com>
7 months agoflash/nor: use target_addr_t for flash bank base 19/4919/8
Tim Newsome [Fri, 15 Feb 2019 01:33:28 +0000 (17:33 -0800)]
flash/nor: use target_addr_t for flash bank base

This should allow users to configure flash at >32-bit addresses.

Change-Id: I7c9d3c5762579011a2d9708e5317e5765349845c
Signed-off-by: Tim Newsome <tim@sifive.com>
Reviewed-on: http://openocd.zylin.com/4919
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
7 months agogdb_server, target: Add target_address_bits() 47/4947/3
Tim Newsome [Mon, 25 Feb 2019 22:02:30 +0000 (14:02 -0800)]
gdb_server, target: Add target_address_bits()

Targets can use this to expose how many address bits there are.
gdb_server uses this to send gdb the appropriate upper limit in the
memory-map. (Before this change the upper limit would only be correct
for 32-bit targets.)

Change-Id: Idb0933255ed53951fcfb05e040674bcdf19441e1
Signed-off-by: Tim Newsome <tim@sifive.com>
Reviewed-on: http://openocd.zylin.com/4947
Tested-by: jenkins
Reviewed-by: Peter Mamonov <pmamonov@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
7 months agortos/hwthread: add hardware-thread pseudo rtos 99/3999/24
Matthias Welwarsky [Fri, 17 Feb 2017 15:16:51 +0000 (16:16 +0100)]
rtos/hwthread: add hardware-thread pseudo rtos

This patch adds "hwthread", a pseudo rtos that represents cpu cores
in an SMP system as threads to gdb. This allows to debug SMP
system kernels in a more sensible manner and removes the current
atrocities of switching gdb manually between CPU cores to update
the context.

Change-Id: Ib781c6c34097689d21d9e02011e4d74a4a742379
Signed-off-by: Matthias Welwarsky <matthias.welwarsky@sysgo.com>
Reviewed-on: http://openocd.zylin.com/3999
Tested-by: jenkins
Reviewed-by: Tim Newsome <tim@sifive.com>
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
Reviewed-by: Graham Sanderson <graham.sanderson@gmail.com>
7 months agodrivers/stlink_usb: use command STLINK_DEBUG_APIV2_READ_IDCODES 26/4826/5
Antonio Borneo [Wed, 19 Dec 2018 23:01:58 +0000 (00:01 +0100)]
drivers/stlink_usb: use command STLINK_DEBUG_APIV2_READ_IDCODES

API v2 deprecates using command STLINK_DEBUG_READCOREID to read
the core ID.
Switch to STLINK_DEBUG_APIV2_READ_IDCODES on new stlink firmware
version.

Change-Id: Iabadfc116c57f2c31f08f2e77baefea0cf90bdc3
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/4826
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
7 months agodrivers/stlink_usb: check error code returned by st-link 25/4825/4
Antonio Borneo [Fri, 7 Dec 2018 11:37:20 +0000 (12:37 +0100)]
drivers/stlink_usb: check error code returned by st-link

Most of ST-Link commands return an error code, but this is almost
never checked.

Check for the error code for every command that returns it.

Change-Id: Ifc4e32f8c73196de23700ba0989bfdfe0f5b46e3
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/4825
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
7 months agodrivers/stlink_usb: fix stlink_usb_read_regs() for API v2 24/4824/3
Antonio Borneo [Fri, 7 Dec 2018 21:11:12 +0000 (22:11 +0100)]
drivers/stlink_usb: fix stlink_usb_read_regs() for API v2

API v2 implementation for command READALLREGS returns the status
in the first two bytes, followed by two bytes of padding.
This makes the reply 4 bytes longer and changes the offset of the
first register value to 4.

Fix it for the case API v2 and clean-up the management of the
return value.

Change-Id: I448c82bcc0baa72d66fdfe7f0c525b94f8a4468b
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/4824
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
7 months agostlink: handle error GET_IDCODE 82/4982/3
Antonio Borneo [Tue, 5 Feb 2019 10:25:19 +0000 (11:25 +0100)]
stlink: handle error GET_IDCODE

When the connection with target is lost on the physical JTAG/SWD
link (either wire disconnected or DAP/TAP in reset), STLINK fail
to connect and returns error STLINK_JTAG_GET_IDCODE_ERROR.

Add it in the list of known errors.

Change-Id: Iabd6e6892111726f614345497d9286554bfe4ac0
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/4982
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
7 months agostlink: handle error bad-AP 81/4981/3
Antonio Borneo [Sun, 3 Feb 2019 20:07:31 +0000 (21:07 +0100)]
stlink: handle error bad-AP

The new firmwares for ST-Link support handling multiple AP, but
are (actually) limited to the AP number in range [0..8].
Any tentative to operate on AP number higher than 8 returns an
error "bad AP".
Add the error code and the related message.

Change-Id: I78a98b2612d10e580d03fc43ed9f2b09619d39d8
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/4981
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
7 months agotarget/openrisc/x86_32_common: Use 'bool' data type 72/4972/2
Marc Schink [Tue, 26 Feb 2019 13:11:46 +0000 (14:11 +0100)]
target/openrisc/x86_32_common: Use 'bool' data type

Change-Id: I395a36ddd7ac7e85bc54f6bb073a93b0c6f24db0
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/4972
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
7 months agotarget/openrisc/or1k: Use 'bool' data type 71/4971/2
Marc Schink [Tue, 26 Feb 2019 13:11:15 +0000 (14:11 +0100)]
target/openrisc/or1k: Use 'bool' data type

Change-Id: I6393bb8503d64947a1f2349e1d14c1552cabf927
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/4971
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
7 months agotarget/lakemont: Use 'bool' data type 69/4969/2
Marc Schink [Tue, 26 Feb 2019 13:10:09 +0000 (14:10 +0100)]
target/lakemont: Use 'bool' data type

Change-Id: I9baaf617c2bfabd07ac3ca195e486893d7950398
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/4969
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
7 months agotarget/feroceon: Use 'bool' data type 67/4967/2
Marc Schink [Tue, 26 Feb 2019 13:09:22 +0000 (14:09 +0100)]
target/feroceon: Use 'bool' data type

Change-Id: I30b8d07ee198e8f67cd98f83c4bec15bcfe8be08
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/4967
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
7 months agotarget/etb: Use 'bool' data type 66/4966/2
Marc Schink [Tue, 26 Feb 2019 13:09:03 +0000 (14:09 +0100)]
target/etb: Use 'bool' data type

Change-Id: I536036b15af10bb1879dbbec84576134fd3dce35
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/4966
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
7 months agotarget/arm_semihosting: Use 'bool' data type 65/4965/2
Marc Schink [Tue, 26 Feb 2019 13:08:42 +0000 (14:08 +0100)]
target/arm_semihosting: Use 'bool' data type

Change-Id: I05245b7dc9c37ea8e0e40672070fb3e87cb7683f
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/4965
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
7 months agotarget/embeddedice: Use 'bool' data type 64/4964/2
Marc Schink [Tue, 26 Feb 2019 13:08:18 +0000 (14:08 +0100)]
target/embeddedice: Use 'bool' data type

Change-Id: I0f237e0769786aa560d1a472a71499d3856ab25c
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/4964
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
7 months agotarget/cortex_a: Use 'bool' data type 63/4963/2
Marc Schink [Tue, 26 Feb 2019 13:08:00 +0000 (14:08 +0100)]
target/cortex_a: Use 'bool' data type

Change-Id: I055767f1c20af539159ee59e35de8dd20b399fa4
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/4963
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
7 months agotarget/avr32_ap7k: Use 'bool' data type 61/4961/2
Marc Schink [Tue, 26 Feb 2019 13:06:44 +0000 (14:06 +0100)]
target/avr32_ap7k: Use 'bool' data type

Change-Id: I49f1a6c6ee6d175935eb40b49abf8ebdf56a0b6e
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/4961
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
7 months agotarget/arm926ejs: Use 'bool' data type 60/4960/2
Marc Schink [Tue, 26 Feb 2019 13:06:06 +0000 (14:06 +0100)]
target/arm926ejs: Use 'bool' data type

Change-Id: I3016a8ba37942d674017c09e4540d9813c832872
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/4960
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
7 months agotarget/arm920t: Use 'bool' data type 59/4959/2
Marc Schink [Tue, 26 Feb 2019 13:05:43 +0000 (14:05 +0100)]
target/arm920t: Use 'bool' data type

Change-Id: I5f2c95d9a4bdb14cc31d72eb026f58710fb07db5
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/4959
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
7 months agotarget/arm720t: Use 'bool' data type 58/4958/2
Marc Schink [Tue, 26 Feb 2019 13:05:22 +0000 (14:05 +0100)]
target/arm720t: Use 'bool' data type

Change-Id: I9838d0d0ba472f029169ab37597ef367a6084fbf
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/4958
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
7 months agotarget/aarch64: Use 'bool' data type 57/4957/2
Marc Schink [Tue, 26 Feb 2019 13:04:46 +0000 (14:04 +0100)]
target/aarch64: Use 'bool' data type

Change-Id: Ibfe4413b88ed0759a556a8777dac40f0c2c64922
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/4957
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
7 months agotarget/armv8: Use 'bool' data type 56/4956/2
Marc Schink [Tue, 26 Feb 2019 13:03:49 +0000 (14:03 +0100)]
target/armv8: Use 'bool' data type

Change-Id: I65def33f24187ab336db5732ce35200ca5cd8f5f
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/4956
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
7 months agotarget/armv7m: Use 'bool' data type 55/4955/2
Marc Schink [Tue, 26 Feb 2019 13:03:27 +0000 (14:03 +0100)]
target/armv7m: Use 'bool' data type

Change-Id: I9cfbba9d81601cc72e2b54ec410e21c7edc4f1c4
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/4955
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
7 months agotarget/arm11: Use 'bool' data type 54/4954/2
Marc Schink [Tue, 26 Feb 2019 13:02:59 +0000 (14:02 +0100)]
target/arm11: Use 'bool' data type

Change-Id: Ia09adeab88eaf66c009f94be25ab82b0b8f88f61
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/4954
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
7 months agotarget/armv7_9_common: Use 'bool' data type 53/4953/2
Marc Schink [Tue, 26 Feb 2019 13:02:33 +0000 (14:02 +0100)]
target/armv7_9_common: Use 'bool' data type

Change-Id: I5af27247f39cf47c925260784e21292f34665471
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/4953
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
7 months agotarget/armv4_5: Use 'bool' data type 52/4952/2
Marc Schink [Tue, 26 Feb 2019 13:01:17 +0000 (14:01 +0100)]
target/armv4_5: Use 'bool' data type

Change-Id: I82e3963ea662844bb96943aee849dab35ea96bb3
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/4952
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
7 months agotarget/register: Use 'bool' data type 51/4951/2
Marc Schink [Tue, 26 Feb 2019 13:00:30 +0000 (14:00 +0100)]
target/register: Use 'bool' data type

Change-Id: I3633ced9cb2bfe6afb0ef49aa42fd1b54f155a66
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/4951
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
7 months agotarget/cortex_m: Use 'bool' instead of 'int' 50/4950/2
Marc Schink [Tue, 26 Feb 2019 12:40:23 +0000 (13:40 +0100)]
target/cortex_m: Use 'bool' instead of 'int'

Change-Id: I273d24997e2c844015e144a15981f8f0af522261
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/4950
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
7 months agotarget: Remove unused variable 'has_percent' 49/4949/2
Marc Schink [Tue, 26 Feb 2019 12:27:23 +0000 (13:27 +0100)]
target: Remove unused variable 'has_percent'

Change-Id: Ib080fc33e8a0305990ee334019547e7643c446ac
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/4949
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
7 months agohelper/command: return proper JIM error code 73/4973/2
Antonio Borneo [Tue, 26 Feb 2019 08:32:04 +0000 (09:32 +0100)]
helper/command: return proper JIM error code

The function command_unknown() is expected to return a value
recognized as JIM error code, as it is correctly done in the
other cases it returns.

Fix the only case in which command_unknown() does not return
a JIM error code, by s/ERROR_FAIL/JIM_ERR/

Change-Id: Ib98b75755ae36870bd68c17f8839ddbfa06c6312
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/4973
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
7 months agostlink: remove unused assignment 45/4945/2
Antonio Borneo [Sun, 24 Feb 2019 17:19:44 +0000 (18:19 +0100)]
stlink: remove unused assignment

Fix a warning identified by clang 7.0.1:
stlink_usb.c:1092:3: warning: Value stored to 'p' is never read
p += sprintf(p, "S%d", swim);
^    ~~~~~~~~~~~~~~~~~~~~~~~

Change-Id: Ic9da57e19ceecb0e3d65d3ea3412a05e1c2c779a
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/4945
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
7 months agogdb_server: fix 'null' pointer passed as 'nonnull' parameter 46/4946/2
Antonio Borneo [Fri, 15 Feb 2019 23:23:25 +0000 (00:23 +0100)]
gdb_server: fix 'null' pointer passed as 'nonnull' parameter

The null pointer used as second parameter to gdb_put_packet() is
passed as second parameter to the memcpy() in line 408 of
gdb_put_packet_inner(). In this case memcpy() does not segfault
because also the parameter length is zero. Nevertheless, the
prototype of memcpy() requires a nonnull pointer.

Fixed by passing an empty string in place of the null pointer.

Issue highlighted by clang 7.0.0 with warning message:
"Null pointer passed as an argument to a 'nonnull' parameter"

Change-Id: Ib3dde95d76fcc5fb245ee2d6669e5535d0e0b127
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/4946
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
7 months agosrc/jtag/drivers/ftdi: fix swd pin comment and links 08/4908/3
Diego Herranz [Wed, 13 Feb 2019 08:33:17 +0000 (08:33 +0000)]
src/jtag/drivers/ftdi: fix swd pin comment and links

- TDI/DO is not pin 2 and in fact, we don't even need to mention which
pin number it is. "TDI/DO pin" is descriptive enough.

- FT2232D link didn't work anymore. It could have been updated to the
current working FT2232D link but changed to link the FT2232H instead
which is the latest generation and the most commonly used these days.

- Taking advantage of the change, link to the MPSSE document updated.
It still worked but through a redirection, so updated just in case the
redirection stops working.

Change-Id: Ia7d01bbcac2158026831edb010a6b50f58351e42
Signed-off-by: Diego Herranz <diegoherranz@diegoherranz.com>
Reviewed-on: http://openocd.zylin.com/4908
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
7 months agogdb_server: remove warning for stepi after gdb_sync 64/4764/2
Antonio Borneo [Wed, 7 Nov 2018 16:55:43 +0000 (17:55 +0100)]
gdb_server: remove warning for stepi after gdb_sync

The command "gdb_sync" is used to resynchronize gdb with OpenOCD.
It is supposed to be follow by the gdb command "stepi" that will
be ignored by OpenOCD.

Don't annoy the user with a warning message when the stepi
command is ignored, but simply log a debug message.

Change-Id: Ie4cffa89e761d7335e5961900b62e31f209d4b1b
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/4764
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
7 months agoarmv8: allow halt on exception 79/4479/10
Matthias Welwarsky [Thu, 5 Apr 2018 11:42:21 +0000 (13:42 +0200)]
armv8: allow halt on exception

add command 'catch_exc' to halt a core on entering any of Secure EL1 or
EL3 or Non-Secure EL1 or EL2.

Change-Id: I0c68e247af68dd96616855a9bc1063c277d222e5
Signed-off-by: Matthias Welwarsky <matthias.welwarsky@sysgo.com>
Reviewed-on: http://openocd.zylin.com/4479
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
7 months agoUse enum for target_register_timer_callback() 21/4921/3
Marc Schink [Fri, 15 Feb 2019 13:36:54 +0000 (14:36 +0100)]
Use enum for target_register_timer_callback()

Change-Id: I268e8c5d783914aa97cbde301448b2c5bc3cb9e6
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/4921
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
7 months agotarget: Use proper data types for timer callback 20/4920/3
Marc Schink [Fri, 15 Feb 2019 13:31:19 +0000 (14:31 +0100)]
target: Use proper data types for timer callback

Change-Id: I5ca6da767f9e96180c43b179b2c682b1b7c98563
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/4920
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
7 months agoflash: stm32f2/f4/f7: Add One-Time-Porgrammable (OTP) support 29/829/9
Moritz Fischer [Mon, 21 Jan 2019 17:24:12 +0000 (09:24 -0800)]
flash: stm32f2/f4/f7: Add One-Time-Porgrammable (OTP) support

The OTP is part of the flash memory. It has 512 (1024 for F7) bytes
and is organized in 16 sectors with 32 (64 for F7) bytes each.
The OTP is exposed as separate flash bank 1 and can be used
with the usual flash commands.

Writing the OTP can be done as follows:

> stm32f2x otp 1 enable
> flash write bank 1 foo.bin 0
> mdw 0x1fff7800 4
> verify_image foo.bin 0x1fff7800
> stm32f2x otp 1 disable

Note: This patch is largely a rebase/cleanup of a patch
from 2012 by Laurent Charpentier and he did most of the work.

No new Clang-Analyzer warnings.

Change-Id: I5e6371f6a7c7a9929c1d7907d6ba4724f9d20d97
Signed-off-by: Moritz Fischer <moritz.fischer@ettus.com>
Reviewed-on: http://openocd.zylin.com/829
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
7 months agojtag: drivers: cmsis-dap: correct vendor request code 55/3855/2
Paul Fertser [Fri, 4 Nov 2016 10:58:05 +0000 (13:58 +0300)]
jtag: drivers: cmsis-dap: correct vendor request code

While at it, change the macro name to make it obvious it's a string,
not some numeric ID. This also matches ARM code that's using

Change-Id: Id35ba5b95cef0ac77657c40985b24c1ae2720748
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/3855
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
7 months agoaarch64: fix a potential memory leak in aarch64_target_create() 24/4924/2
Antonio Borneo [Fri, 15 Feb 2019 20:31:02 +0000 (21:31 +0100)]
aarch64: fix a potential memory leak in aarch64_target_create()

If the function aarch64_target_create() exits for an error, the
value of pointer aarch64 get lost, causing a memory leak.

Move the allocation of aarch64 after the check on the parameters.
While there, add a check on the value returned by calloc().

Issue highlighted by clang 7.0.0.

Change-Id: Ib9ad27f4acd940da308c01fdbf33cfe51ab0c639
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/4924
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
7 months agomem_ap: fix a potential memory leak in mem_ap_target_create() 23/4923/2
Antonio Borneo [Fri, 15 Feb 2019 20:26:27 +0000 (21:26 +0100)]
mem_ap: fix a potential memory leak in mem_ap_target_create()

If the function mem_ap_target_create() exits for an error, the
value of pointer mem_ap get lost, causing a memory leak.

Move the allocation of mem_ap after the check on the parameters.
While there, add a check on the value returned by calloc().

Issue highlighted by clang 7.0.0.

Change-Id: Ia2c11b14fde9694f28bf6efe01d278923db0f0d4
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/4923
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
7 months agocortex_a: fix a potential memory leak in cortex_a_target_create() 25/4925/2
Antonio Borneo [Fri, 15 Feb 2019 20:33:34 +0000 (21:33 +0100)]
cortex_a: fix a potential memory leak in cortex_a_target_create()

If the function cortex_a_target_create() or the function
cortex_r4_target_create() exit for an error, the value of pointer
cortex_a get lost, causing a memory leak.

Move the allocation of cortex_a after the check on the parameters.
While there, add checks on the value returned by calloc().

Issue highlighted by clang 7.0.0.

Change-Id: Ic6eeb9c3b39922d016f6d0319eada1a97a6681f0
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/4925
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
7 months agoserver: fix small mem leak of bindto_name 09/4909/2
Tomas Vanek [Mon, 21 Jan 2019 20:51:04 +0000 (21:51 +0100)]
server: fix small mem leak of bindto_name

Change-Id: Ib9c8003e164a156f1c4d3cde47e4158d867d82c6
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4909
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
7 months agoFix support for single-bank stm32l4 processors 13/4913/3
Armin van der Togt [Thu, 14 Feb 2019 14:35:07 +0000 (15:35 +0100)]
Fix support for single-bank stm32l4 processors

Recent patches for STM32L4+ assumed all STM32L4 processors have a dual-
bank option. This is not the case for STM32L4{3,4,5,6}xx processors and
therefore, these processors (like STM32L433) failed when attempting to
flash the second half of the flash memory. This patch fixed this issue.
Tested on STM32L433xC, STM32L476xG and STM32L471xG.

Change-Id: I8262ba4f05190802c5868d753f3e7af50e581811
Signed-off-by: Armin van der Togt <armin@otheruse.nl>
Reviewed-on: http://openocd.zylin.com/4913
Tested-by: jenkins
Reviewed-by: Peter Tettelaar <peter@float-iot.nl>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Mark Schulte <mschulte@lyft.com>
7 months agoftdi: use "adapter usb location" instead of ftdi_location command 71/4771/10
Oleksij Rempel [Fri, 16 Nov 2018 07:58:58 +0000 (08:58 +0100)]
ftdi: use "adapter usb location" instead of ftdi_location command

Use unified "adapter usb location" instead of driver specific
command.

Change-Id: I568a76b87d09cea0f40f1580cf81f7c51402f6f1
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Reviewed-on: http://openocd.zylin.com/4771
Tested-by: jenkins
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
7 months agotarget, breakpoints: improve error handling 71/4871/4
Tomas Vanek [Thu, 24 Jan 2019 13:33:16 +0000 (14:33 +0100)]
target, breakpoints: improve error handling

handle_bp_command_set() showed the error message
"Failure setting breakpoint, the same address(IVA) is already used"
on any error returned from (xxx_)breakpoint_add().
Paradoxically breakpoint_add() returned ERROR_OK if it detected
duplicated bp address.
context_breakpoint_add() and hybrid_breakpoint_add() returned -1
instead of OpenOCD compatible error if they detected duplicity.

Introduce ERROR_TARGET_DUPLICATE_BREAKPOINT
Unify error handling to LOG_ERROR() any error in (xxx_)breakpoint_add()
Remove misleading error messages from handle_bp_command_set()
handle_bp_command_set() returns error if the target does not implement
add_context_breakpoint or add_hybrid_breakpoint.

Change-Id: If17dfad1756d82a77028ebdc4b305f9c8e1365ba
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4871
Tested-by: jenkins
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
7 months agodoc: fix typo in "adapter usb location" command 07/4907/3
Oleksij Rempel [Mon, 11 Feb 2019 06:14:06 +0000 (07:14 +0100)]
doc: fix typo in "adapter usb location" command

Change-Id: If959c5461904cdf4bcdf1887a9afaa9c2c94282b
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Reviewed-on: http://openocd.zylin.com/4907
Tested-by: jenkins
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
7 months agodoc/openocd.texi: fix xref warning 05/4905/2
Tomas Vanek [Sat, 9 Feb 2019 15:06:22 +0000 (16:06 +0100)]
doc/openocd.texi: fix xref warning

Xref without trailing '.' or ',' was introduced in
deaf3d264123391d8fe5c4cccbf8fb8852e1be23

Change-Id: I99afd40e1ffeddd1298b7b07e4deba3dcc41799f
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4905
Tested-by: jenkins
7 months agotarget/riscv-011: Fix memory leak in handle_halt_routine() 84/4884/2
Marc Schink [Wed, 6 Feb 2019 11:07:10 +0000 (12:07 +0100)]
target/riscv-011: Fix memory leak in handle_halt_routine()

Tested with SiFive HiFive1 development board.

Change-Id: Ie0d9fa0899804d17ccdd84b03ba4028e97b632b8
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/4884
Tested-by: jenkins
Reviewed-by: Tim Newsome <tim@sifive.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
8 months agojlink: Use correct SWD buffer size 78/4878/2
Marc Schink [Tue, 29 Jan 2019 08:23:09 +0000 (09:23 +0100)]
jlink: Use correct SWD buffer size

Currently, the SWD buffer size is adjusted corresponding to the free
device memory. However, the adjusted size is not used.

This fixes SWD operations on devices with small device memory, such as
EFM32PG12 Pearl Gecko STK. It should also fix #184.

Change-Id: I2ec5cf25c62f18bd9e99a2f4aa1aa8d85ed0821b
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/4878
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Tested-by: jenkins
8 months agodrivers/bitbang: remove unused extern declaration of jtag_interface 74/4874/2
Antonio Borneo [Tue, 22 Jan 2019 15:08:22 +0000 (16:08 +0100)]
drivers/bitbang: remove unused extern declaration of jtag_interface

After commit a6c4eb03455f ("swd: Remove DAP from parameter list")
the global variable jtag_interface is not referenced in the driver.

Remove the extern declaration.

Change-Id: I72018a59c9cecaa52d9a49ec0d7816ac0e656314
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/4874
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
8 months agocommand: fix the mode for command "jtag configure" 86/4886/2
Antonio Borneo [Thu, 7 Feb 2019 08:56:10 +0000 (09:56 +0100)]
command: fix the mode for command "jtag configure"

Before commit 877cec20dca6e78f9f029f0f173879cda101a6c2 ("command:
check command mode for native jim commands") all the jim commands
were erroneously treated as they had mode COMMAND_ANY.
The commit above fixes the code in order to check the mode and
permit running the commands only if the mode is respected.

Those jim commands that have incorrect mode were not detected nor
fixes because the wrong mode was masked by the missing mode check.
After the commit above, the wrong mode triggers error in several
existing configuration scripts.
A complete list of commands that now does not run anymore as
CONFIG_ANY is reported in ticket 225, but most of them have the
mode set correctly.
At least two instances of command "jtag configure" have the wrong
mode.

Fix the mode to CONFIG_ANY for command "jtag configure" in files
src/jtag/aice/aice_transport.c and src/jtag/tcl.c

Change-Id: I3f96c5fd24d7d463712cbaf1295284fe0dc56b23
Ticket: https://sourceforge.net/p/openocd/tickets/225/
Reported-by: Bill Paul <wpaul@users.sourceforge.net>
Fixes: 877cec20dca6 ("command: check command mode for native jim commands")
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/4886
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
8 months agodoc: add documentation for "adapter usb location" command 69/4769/7
Oleksij Rempel [Fri, 16 Nov 2018 07:56:25 +0000 (08:56 +0100)]
doc: add documentation for "adapter usb location" command

Change-Id: Ia3fbe0c3894b1b96464bbfda5d4101123827b761
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Reviewed-on: http://openocd.zylin.com/4769
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
8 months agotarget/cortex_m: fix clang static analyzer warning 81/4881/3
Tomas Vanek [Thu, 31 Jan 2019 13:21:56 +0000 (14:21 +0100)]
target/cortex_m: fix clang static analyzer warning

Fix "Potential leak of memory pointed to by 'cortex_m'"
and test for NULL return from calloc in cortex_m_target_create()

Change-Id: I4d2bb5bccc57f0ed60696f3d588297a858b8ea60
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4881
Tested-by: jenkins
Reviewed-by: Moritz Fischer <moritz.fischer@ettus.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
8 months agotarget/hla_target: fix clang static analyzer warning 82/4882/3
Tomas Vanek [Thu, 31 Jan 2019 13:25:28 +0000 (14:25 +0100)]
target/hla_target: fix clang static analyzer warning

Added an error msg in case of no memory

Change-Id: I7a7d266ca4aa1e4a0ff02a2d1cc672a3cd2746c3
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4882
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
8 months agoat91samd: Add flash programming support for SAMC2?N* parts 80/4880/4
Kevin Vermilion [Wed, 30 Jan 2019 19:01:48 +0000 (11:01 -0800)]
at91samd: Add flash programming support for SAMC2?N* parts

Added id, name, flash size and RAM size for following parts to samc20_parts[]:
SAMC20N18A
SAMC20N17A
And the following to samc21_parts[]:
SAMC21N18A
SAMC21N17A

Change-Id: Ie8cf1c531a60bfaed6e814d436d232afb89dae3f
Signed-off-by: Kevin Vermilion <kevin.vermilion@gmail.com>
Reviewed-on: http://openocd.zylin.com/4880
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
8 months agotarget start_algorithm: Don't copy the IN mem_params fix uninitialised value. 11/4811/4
Jean-Christian de Rivaz [Mon, 17 Dec 2018 15:07:29 +0000 (16:07 +0100)]
target start_algorithm: Don't copy the IN mem_params fix uninitialised value.

Fix the write only out params TODO on armv7m.c
Fix conditional move depends on uninitialised value.
It was detected while programming a LPC8Nxx with a FTDI adapter.
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes
[...]
==8696== Conditional jump or move depends on uninitialised value(s)
==8696==    at 0x16E4D3: buf_set_u32 (binarybuffer.h:52)
==8696==    by 0x16E4D3: ftdi_swd_queue_cmd (ftdi.c:1206)
==8696==    by 0x18D76D: swd_queue_ap_write (adi_v5_swd.c:271)
==8696==    by 0x18E33B: dap_queue_ap_write (arm_adi_v5.h:382)
==8696==    by 0x18E33B: mem_ap_write (arm_adi_v5.c:420)
==8696==    by 0x197CD9: target_write_buffer_default (target.c:2176)
==8696==    by 0x2464B3: armv7m_start_algorithm (armv7m.c:383)
==8696==    by 0x246AEB: armv7m_run_algorithm (armv7m.c:330)
==8696==    by 0x19D846: target_run_algorithm (target.c:814)
==8696==    by 0x1DF3A6: lpc2000_iap_call.isra.3 (lpc2000.c:818)
==8696==    by 0x1E0CF6: lpc2000_erase (lpc2000.c:992)
==8696==    by 0x185BDF: flash_driver_erase (core.c:44)
==8696==    by 0x18650D: flash_iterate_address_range_inner (core.c:541)
==8696==    by 0x18650D: flash_iterate_address_range (core.c:567)
==8696==    by 0x18732F: flash_erase_address_range (core.c:584)
==8696==    by 0x18732F: flash_write_unlock (core.c:928)
==8696==  Uninitialised value was created by a heap allocation
==8696==    at 0x4C2BBAF: malloc (vg_replace_malloc.c:299)
==8696==    by 0x220EF9: init_mem_param (algorithm.c:30)
==8696==    by 0x1DF247: lpc2000_iap_call.isra.3 (lpc2000.c:777)
==8696==    by 0x1E0CF6: lpc2000_erase (lpc2000.c:992)
==8696==    by 0x185BDF: flash_driver_erase (core.c:44)
==8696==    by 0x18650D: flash_iterate_address_range_inner (core.c:541)
==8696==    by 0x18650D: flash_iterate_address_range (core.c:567)
==8696==    by 0x18732F: flash_erase_address_range (core.c:584)
==8696==    by 0x18732F: flash_write_unlock (core.c:928)
==8696==    by 0x18ACDF: handle_flash_write_image_command (tcl.c:457)
==8696==    by 0x1B7D99: run_command (command.c:623)
==8696==    by 0x1B7D99: script_command_run (command.c:208)
==8696==    by 0x1B7FD9: command_unknown (command.c:1033)
==8696==    by 0x2E2D37: JimInvokeCommand (jim.c:10364)
==8696==    by 0x2E3865: Jim_EvalObj (jim.c:10814)
==8696==
==8696== Conditional jump or move depends on uninitialised value(s)
==8696==    at 0x16E506: buf_set_u32 (binarybuffer.h:52)
==8696==    by 0x16E506: ftdi_swd_queue_cmd (ftdi.c:1207)
==8696==    by 0x18D76D: swd_queue_ap_write (adi_v5_swd.c:271)
==8696==    by 0x18E33B: dap_queue_ap_write (arm_adi_v5.h:382)
==8696==    by 0x18E33B: mem_ap_write (arm_adi_v5.c:420)
==8696==    by 0x197CD9: target_write_buffer_default (target.c:2176)
==8696==    by 0x2464B3: armv7m_start_algorithm (armv7m.c:383)
==8696==    by 0x246AEB: armv7m_run_algorithm (armv7m.c:330)
==8696==    by 0x19D846: target_run_algorithm (target.c:814)
==8696==    by 0x1DF3A6: lpc2000_iap_call.isra.3 (lpc2000.c:818)
==8696==    by 0x1E0CF6: lpc2000_erase (lpc2000.c:992)
==8696==    by 0x185BDF: flash_driver_erase (core.c:44)
==8696==    by 0x18650D: flash_iterate_address_range_inner (core.c:541)
==8696==    by 0x18650D: flash_iterate_address_range (core.c:567)
==8696==    by 0x18732F: flash_erase_address_range (core.c:584)
==8696==    by 0x18732F: flash_write_unlock (core.c:928)
==8696==  Uninitialised value was created by a heap allocation
==8696==    at 0x4C2BBAF: malloc (vg_replace_malloc.c:299)
==8696==    by 0x220EF9: init_mem_param (algorithm.c:30)
==8696==    by 0x1DF247: lpc2000_iap_call.isra.3 (lpc2000.c:777)
==8696==    by 0x1E0CF6: lpc2000_erase (lpc2000.c:992)
==8696==    by 0x185BDF: flash_driver_erase (core.c:44)
==8696==    by 0x18650D: flash_iterate_address_range_inner (core.c:541)
==8696==    by 0x18650D: flash_iterate_address_range (core.c:567)
==8696==    by 0x18732F: flash_erase_address_range (core.c:584)
==8696==    by 0x18732F: flash_write_unlock (core.c:928)
==8696==    by 0x18ACDF: handle_flash_write_image_command (tcl.c:457)
==8696==    by 0x1B7D99: run_command (command.c:623)
==8696==    by 0x1B7D99: script_command_run (command.c:208)
==8696==    by 0x1B7FD9: command_unknown (command.c:1033)
==8696==    by 0x2E2D37: JimInvokeCommand (jim.c:10364)
==8696==    by 0x2E3865: Jim_EvalObj (jim.c:10814)

Change-Id: I50f9a8c4516b686cf62ac3c76f47c53465e949da
Signed-off-by: Jean-Christian de Rivaz <jcamdr70@gmail.com>
Reviewed-on: http://openocd.zylin.com/4811
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
8 months agoflash/nor/stm32f1x: Ability to change user option bytes. 63/4663/5
Jan Vojtech [Tue, 4 Sep 2018 09:50:09 +0000 (11:50 +0200)]
flash/nor/stm32f1x: Ability to change user option bytes.

Adds ability to change the user data in STM32F1x/STM32F3x MCU's option byte.
Since OpenOCD prints the content of user data in option byte registers, it
is seems logical to also provide a way how to change this data.

Change-Id: Ie6cb756b4f11b5c6dabd34bc89434a358eb758ff
Signed-off-by: Jan Vojtech <honza.vojtech@gmail.com>
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4663
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
8 months agotarget algo: do not write reg_param if direction is PARAM_IN 13/4813/2
Tomas Vanek [Tue, 18 Dec 2018 16:17:33 +0000 (17:17 +0100)]
target algo: do not write reg_param if direction is PARAM_IN

Without this change xxx_start_algorithm() writes all register
parameters no matter of their direction. It usually results
in writing of uninitialized reg_params[].value - possibly
reported by valgrind.

While on it fix the wrong parameter direction in
kinetis_disable_wdog_algo(). This bug did not have any
impact because of unconditional write of reg_params.

Change-Id: Ia9c6a7b37f77d5eb6e5f5463012dddd50471742b
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4813
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
8 months agodrivers/imx_gpio: fix polarity of srst and trst 47/4847/2
Antonio Borneo [Fri, 11 Jan 2019 17:29:38 +0000 (18:29 +0100)]
drivers/imx_gpio: fix polarity of srst and trst

The comment above the function is correct, but the code set
the GPIO with wrong (reversed) polarity.

Change-Id: Ifd09688150d3d2018af73521e0da3926bb1b7f84
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/4847
Tested-by: jenkins
Reviewed-by: Grzegorz Kostka <kostka.grzegorz@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
8 months agojtag: drivers: provide initial support for usb path filtering 80/4580/14
Oleksij Rempel [Wed, 27 Jun 2018 12:54:21 +0000 (14:54 +0200)]
jtag: drivers: provide initial support for usb path filtering

With this patch drivers will be able to use usb path filtering.
The path format is identical to the format provided by linux kernel:
bus-port.port....
With this format it should be easier just to copy and paste
path found in dmesg.

Change-Id: I8bafa6fcb7a66ff68cc961a376f97f4f3dee35aa
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Reviewed-on: http://openocd.zylin.com/4580
Tested-by: jenkins
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
8 months agoflash/nor: flash driver and cfg for SAM E54, E53, E51 and D51 72/4272/6
Tomas Vanek [Fri, 27 Oct 2017 19:43:25 +0000 (21:43 +0200)]
flash/nor: flash driver and cfg for SAM E54, E53, E51 and D51

The new Microchip (former Atmel) series powered by Cortex-M4 looks
very similar to older M0+ powered SAM D2x at the first sight.
Unfortunately the new series differs a lot in important details.
NVMCTRL has different register addresses, moved important bits
and even changed binary command set. An universal driver for all SAM D/E
would be very complicated. That's why a new driver was derived.

Tested on Microchip SAM E54 Xplained Pro kit (board cfg included).

Adjusted for the restructured dap support.
Checked by valgrind and clang static analyzer.

Change-Id: I26c67047a552076f4b207b9b89285a53d69b4ca4
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4272
Tested-by: jenkins
Reviewed-by: Andres Vahter <andres.vahter@gmail.com>
8 months agoflash/nor/stm32f1x: use address instead of offset in stm32x_write_block() 59/4859/3
Tomas Vanek [Sat, 19 Jan 2019 14:04:20 +0000 (15:04 +0100)]
flash/nor/stm32f1x: use address instead of offset in stm32x_write_block()

stm32x_write_options() uses stm32x_write_block() at STM32_OB_RDP address.
The change eliminates subtracting bank->base (and later adding it back).

Change-Id: Icdd24afc7178b814be58e6033d4b93fdfb2d2a16
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4859
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: Christopher Head <chead@zaber.com>
8 months agoflash/nor/stm32f1x: fix minor error messages 58/4858/2
Tomas Vanek [Sat, 19 Jan 2019 13:58:49 +0000 (14:58 +0100)]
flash/nor/stm32f1x: fix minor error messages

Change-Id: I1e9e62979c4629c8ba1d5ae89ca7392259969eb6
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4858
Tested-by: jenkins
Reviewed-by: Christopher Head <chead@zaber.com>
8 months agocortex_m: fix stepping on FPB rev 1 57/4857/2
Tomas Vanek [Sat, 19 Jan 2019 09:26:38 +0000 (10:26 +0100)]
cortex_m: fix stepping on FPB rev 1

Stepping in the maskisr auto mode sets breakpoint to step over interrupt
service tasks. If the device has FPB rev 1, setting hard breakpoint
is impossible on address over 0x1fffffff.

Use soft type breakpoint for adresses over 0x1fffffff if FPB is rev 1.
This may eventually fail if the code memory is not writeable, but there
is nothing to do in such case.

Change-Id: Ibdeeb506903a35d550b64f82c24c37a668de62b3
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4857
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
8 months agoflash/nor/at91samd: add samr34j18. 72/4872/2
Guillaume Revaillot [Mon, 14 Jan 2019 15:09:13 +0000 (16:09 +0100)]
flash/nor/at91samd: add samr34j18.

samr34/r35 combine SAML21 and SX1276 (lora transceiver). This one was found on
xplaned pro evaluation kit. Ids for other r34/r35 chips are apparently not yet
documented.

Change-Id: I4054dd56ea53c9bae8d17abd5a3e4e65e1b9c8b1
Signed-off-by: Guillaume Revaillot <g.revaillot@gmail.com>
Reviewed-on: http://openocd.zylin.com/4872
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
8 months agoarm_adi_v5: rewrite dap_to_jtag and dap_to_swd 52/4852/3
Antonio Borneo [Wed, 29 Aug 2018 09:57:42 +0000 (11:57 +0200)]
arm_adi_v5: rewrite dap_to_jtag and dap_to_swd

The functions dap_to_jtag() and dap_to_swd() have been introduced by
3ef9beb52cd0 ("ADIv5 DAP ops switching to JTAG or SWD modes") in
arm_adi_v5.c by using the JTAG queue only.
Later, in 6f8b8593d63b ("ADIv5 transport support moves to separate
files") the functions has been moved in adi_v5_swd.c and adi_v5_jtag.c
but keeping the dependency from JTAG queue.
The functions does not work if the current transport is not JTAG.

Move back the functions in arm_adi_v5.c, replace the input parameter
"target" with "dap", use the transport to detect if the JTAG queue is
present, in case of SWD transport use the proper method, for other
transports report error.
Reuse the ADI v5 sequences already present in jtag/swd.h.
Also, OpenOCD does not support switching to another transport after
the initial selection, so do not change DAP's ops vector.

Change-Id: Ib681fbaa60cb342f732bc831eb92de25afa4e4db
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/4852
Tested-by: jenkins
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
8 months agoaarch64: support for aarch32 ARM_MODE_SYS 94/4494/3
Matthias Welwarsky [Wed, 18 Apr 2018 08:06:29 +0000 (10:06 +0200)]
aarch64: support for aarch32 ARM_MODE_SYS

Treat ARM_MODE_SYS like all other Aarch32 processor modes,
except for the special case of missing SPSR.

Change-Id: I60b21703659b264f552884cdc0f85fd45f7836de
Signed-off-by: Matthias Welwarsky <matthias.welwarsky@sysgo.com>
Reviewed-on: http://openocd.zylin.com/4494
Tested-by: jenkins
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
8 months agotarget: do not allow 'target create' after init 42/4842/2
Tomas Vanek [Wed, 9 Jan 2019 12:01:50 +0000 (13:01 +0100)]
target: do not allow 'target create' after init

A target created after init lacks target_init_one() call
and is not added to gdb targets.

Steps to reproduce:
- start OpenOCD with a dap target
- connect by telnet
 target create ap0.mem mem_ap -dap $_CHIPNAME.dap -ap-num 0
 reset

Segmentation fault is rised because target->check_reset is NULL.

Change-Id: I2a62f3b450e4db3005c7041a22fb8f952e68c3b6
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4842
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
8 months agocommand: check command mode for native jim commands 41/4841/2
Tomas Vanek [Wed, 9 Jan 2019 11:55:51 +0000 (12:55 +0100)]
command: check command mode for native jim commands

The command mode was checked only for simple type of commands.
Native commands (handled by jim_handler) was treated as
they had mode COMMAND_ANY

Change-Id: Iab1d8cbb0b8c6f6b9f3cf942600432dec9a703ff
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4841
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
8 months agotarget/cortex_m: inform if an external reset occurs 40/4840/3
Tomas Vanek [Wed, 9 Jan 2019 10:59:35 +0000 (11:59 +0100)]
target/cortex_m: inform if an external reset occurs

Change-Id: I873e73012c44aac7af3b21b633bd096d8e299d07
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4840
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
8 months agocommand: Log the failed command by full name 37/4837/3
Tomas Vanek [Mon, 7 Jan 2019 23:26:39 +0000 (00:26 +0100)]
command: Log the failed command by full name

Commit 44009186cfabe77fb260af221ebd6272d1e78f44 added logging
of failed cmd name but it used c->name only. It might be confusing:

Debug: 244 105 command.c:644 run_command(): Command 'init' failed with error
 code -4
User : 245 106 command.c:711 command_run_line():
Debug: 246 107 command.c:644 run_command(): Command 'init' failed with error
 code -4

The command on line 244 is 'dap init'
Use full name of cmd including parents.

Change-Id: Iff131ce6454ef70b353ce1bc6d0a480b92820545
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4837
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
Reviewed-by: Jean-Christian de Rivaz <jcamdr70@gmail.com>
8 months agohla_target: fix adapter_poll() to preserve TARGET_DEBUG_RUNNING state 20/4820/2
Tomas Vanek [Tue, 25 Dec 2018 20:38:23 +0000 (21:38 +0100)]
hla_target: fix adapter_poll() to preserve TARGET_DEBUG_RUNNING state

Without this change TARGET_DEBUG_RUNNING changes to TARGET_RUNNING
after adapter_poll()

Change-Id: I1c965a43527b50fa723d78fb6eae56585a7ede03
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4820
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
8 months agocommand: initialize the command mode for every command 61/4861/2
Antonio Borneo [Sat, 19 Jan 2019 23:52:07 +0000 (00:52 +0100)]
command: initialize the command mode for every command

All the commands in OpenOCD have been inspected and have the
command mode initialize, apart for two of them.
This is not critical, because the uninitialized value (0) is
equivalent to the enum COMMAND_EXEC, that is also the correct
value for the two mentioned commands.

To keep the code consistent, initialize the command mode to
COMMAND_EXEC.

Change-Id: Iaf043364cbd1005418d787ed045a3ec653612382
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/4861
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
8 months agotcl: Support for Analog Devices ADSP-SC58x / ADSP-SC584-EZBRD 55/4855/4
Peter Lawrence [Thu, 17 Jan 2019 00:00:34 +0000 (18:00 -0600)]
tcl: Support for Analog Devices ADSP-SC58x / ADSP-SC584-EZBRD

The original script was broken by changes to the Cortex-A code.  The
recent introduction of the mem_ap target provided a new mechanism to
allow the script to be fixed.  This also adds an example board script
for the ADSP-SC584-EZBRD.

Change-Id: I36bc1ac6b6c036539f4175f1e65223ba10a35355
Signed-off-by: Peter Lawrence <majbthrd@gmail.com>
Reviewed-on: http://openocd.zylin.com/4855
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>