]> git.sur5r.net Git - openocd/log
openocd
6 years agoaarch64: add cpsr bitfields to target description
Matthias Welwarsky [Wed, 7 Mar 2018 20:14:24 +0000 (21:14 +0100)]
aarch64: add cpsr bitfields to target description

provide meta information for the cpsr so gdb can display the status
flags and not only a hexadecimal number

Change-Id: I9d3fb29153780adbea389d7e4175d5e19bddc256
Signed-off-by: Matthias Welwarsky <matthias.welwarsky@sysgo.com>
Reviewed-on: http://openocd.zylin.com/4460
Tested-by: jenkins
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
6 years agotdesc: bitfields may carry a type
Matthias Welwarsky [Thu, 8 Mar 2018 13:40:10 +0000 (14:40 +0100)]
tdesc: bitfields may carry a type

a bitfield may carry a type (bool or int), add support for that.

Change-Id: Ic831a9b8eac8579e8fdd7d0f01b7f1c9259e6739
Signed-off-by: Matthias Welwarsky <matthias.welwarsky@sysgo.com>
Reviewed-on: http://openocd.zylin.com/4459
Tested-by: jenkins
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
6 years agotransport: add transport_is_hla()
Tomas Vanek [Thu, 15 Mar 2018 19:02:10 +0000 (20:02 +0100)]
transport: add transport_is_hla()

and move declaration of all transport_is_xxx() functions to transport.h

Change-Id: Ib229115b5017507b49655bc43b517ab6fb32f7a6
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4469
Tested-by: jenkins
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
6 years agoserver: bind to IPv4 localhost by default
Paul Fertser [Sat, 13 Jan 2018 13:22:10 +0000 (16:22 +0300)]
server: bind to IPv4 localhost by default

Since OpenOCD basically allows to perform arbitrary actions on behalf of
the running user, it makes sense to restrict the exposure by default.

If you need network connectivity and your environment is safe enough,
use "bindto 0.0.0.0" to switch to the old behaviour.

Change-Id: I4a4044b90d0ecb30118cea96fc92a7bcff0924e0
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/4331
Reviewed-by: Jonathan McDowell <noodles-openocd@earth.li>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
6 years agoaarch64: fix debug entry from EL0
Matthias Welwarsky [Mon, 12 Mar 2018 15:56:05 +0000 (16:56 +0100)]
aarch64: fix debug entry from EL0

If we enter debug state from EL0, some registers are not accessible.
Temporarily move to EL1H and back to gain access. Also, fix
armv8_dpm_modeswitch() to not immediately restore the previous state
on elevating the privilege level.

Change-Id: Ic2a92109230ff4eb6834c00ef544397a5b7ad56a
Signed-off-by: Matthias Welwarsky <matthias.welwarsky@sysgo.com>
Reviewed-on: http://openocd.zylin.com/4461
Tested-by: jenkins
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
6 years agogdb_server: fake step if thread is not current rtos thread
Matthias Welwarsky [Mon, 5 Mar 2018 13:50:51 +0000 (14:50 +0100)]
gdb_server: fake step if thread is not current rtos thread

gdb assumes that a rtos can make any thread active at will in response
to a 'Hg' packet. It further assumes that it needs to step-over after
setting a breakpoint on frame #0 of any non-current thread. Both
assumptions are not valid for an actual rtos. We fake the step-over to
not trigger an internal error in gdb. See
https://sourceware.org/bugzilla/show_bug.cgi?id=22925 for details.

Change-Id: Ida60cd134033c1d58ada77b87fe664a58f61e2c0
Signed-off-by: Matthias Welwarsky <matthias.welwarsky@sysgo.com>
Reviewed-on: http://openocd.zylin.com/4448
Tested-by: jenkins
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
6 years agogdb_server: fix ignored interrupt request from gdb during stepping
Matthias Welwarsky [Sun, 4 Mar 2018 17:52:14 +0000 (18:52 +0100)]
gdb_server: fix ignored interrupt request from gdb during stepping

Normally, when a ctrl-c is received from gdb, a SIGINT is reported back
unconditionally to tell gdb that the target has stopped in response.
However when a rtos support was configured, the rtos awareness overwrote
the signal with an actual thread state, which gdb then ignored and got
stuck without the user able to interrupt.

Change-Id: I40fd62333e020a8c4d9df0079270e84df9c77f88
Signed-off-by: Matthias Welwarsky <matthias.welwarsky@sysgo.com>
Reviewed-on: http://openocd.zylin.com/4445
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
6 years agogdb_server: prevent false positive valgrind report
Tomas Vanek [Fri, 16 Feb 2018 10:58:10 +0000 (11:58 +0100)]
gdb_server: prevent false positive valgrind report

Change-Id: Ia59fdf8a23043889840122859b0c5bdb5f757703
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4420
Tested-by: jenkins
6 years agodrivers/ftdi: free allocated memory
Tomas Vanek [Fri, 16 Feb 2018 08:13:36 +0000 (09:13 +0100)]
drivers/ftdi: free allocated memory

Also uses calloc() for mpsse_ctx->write_buffer to prevent a false
positive valgrind report
"Syscall param ioctl(USBDEVFS_SUBMITURB).buffer points to uninitialised bytes(s)"

Change-Id: I91963371d15c21ea0fee4c40c1da86174db44520
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4418
Tested-by: jenkins
6 years agosrc/jtag/hla: free allocated memory in hl_interface_quit()
Tomas Vanek [Thu, 15 Feb 2018 09:24:15 +0000 (10:24 +0100)]
src/jtag/hla: free allocated memory in hl_interface_quit()

Change-Id: If6ead00e47021c88e4c106b4aeaf038db87ff50b
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4413
Tested-by: jenkins
6 years agotarget/target: free what leaked in target_destroy()
Tomas Vanek [Thu, 15 Feb 2018 00:24:50 +0000 (01:24 +0100)]
target/target: free what leaked in target_destroy()

Free event_action, fileio_info and working area.

Change-Id: Iac81230423e92304b8e2c971d0ec71a96b693fc4
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4412
Tested-by: jenkins
6 years agojtag/core: free all taps and daps in adapter_quit()
Tomas Vanek [Wed, 14 Feb 2018 23:56:44 +0000 (00:56 +0100)]
jtag/core: free all taps and daps in adapter_quit()

Change-Id: I74496f6ddfb0a72b2933e8d682a73a694b8d107b
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4411
Tested-by: jenkins
6 years agoserver: free strduped port numbers
Tomas Vanek [Wed, 14 Feb 2018 23:22:42 +0000 (00:22 +0100)]
server: free strduped port numbers

Although the leak is negligible, the clean heap on exit will ease
valgrind testing.

Change-Id: I3a7a9c8e8dc7557aa51d0b9caa244537e5e7007d
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4410
Tested-by: jenkins
6 years agoopenocd.c: call server_quit() for cmd line with -c shutdown
Tomas Vanek [Wed, 14 Feb 2018 21:53:14 +0000 (22:53 +0100)]
openocd.c: call server_quit() for cmd line with -c shutdown

If OpenOCD command line contains -c shutdown, server_quit() is not called.
Though if -c init is also on command line, gdb_server is already initialized.

Call server_quit() on both successful and failure exit from command line.

Change-Id: I6df41c5df045b61d84a5515d1abaa5dc96bc30ac
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4409
Tested-by: jenkins
6 years agotcl/target: warn if a Kinetis MCU is connected to a high level adapter
Tomas Vanek [Sat, 10 Feb 2018 17:51:40 +0000 (18:51 +0100)]
tcl/target: warn if a Kinetis MCU is connected to a high level adapter

Make sure the user is aware he can lock the device though unlock is not
possible without access to MDM-AP.

Change-Id: I92676530e95d19489c6739748a99c2895849f90f
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4403
Tested-by: jenkins
6 years agodoc: fix xref texinfo warning
Paul Fertser [Tue, 13 Mar 2018 10:48:25 +0000 (13:48 +0300)]
doc: fix xref texinfo warning

Change-Id: Iff1ba5836e3a4f352903c3a5ae73c7d992306d42
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/4466
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
6 years agodoc: make gdb-attach description understandable
Tomas Vanek [Tue, 13 Mar 2018 09:30:59 +0000 (10:30 +0100)]
doc: make gdb-attach description understandable

Change-Id: I31babf4e3bbe7c94f26818d938699562a4a26d48
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4465
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
6 years agojtag: drivers: add support for FT232R sync bitbang JTAG interfaces
Matej Kogovsek [Sun, 3 Sep 2017 10:19:41 +0000 (12:19 +0200)]
jtag: drivers: add support for FT232R sync bitbang JTAG interfaces

Change-Id: Ib88a9e270f5c2a50902a137bcc97fdefd5aad1c6
Signed-off-by: Matej Kogovsek <matej@hamradio.si>
Reviewed-on: http://openocd.zylin.com/4215
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
6 years agotarget: hla: check return value of hl_dcc_read
Paul Fertser [Sat, 13 Jan 2018 14:15:29 +0000 (17:15 +0300)]
target: hla: check return value of hl_dcc_read

This should fix "Assigned value is garbage or undefined" warning
reported by clang:
http://build.openocd.org/job/openocd-clang/doclinks/1/report-391318.html

Change-Id: Ib9488fadca871814328501e415f88822291e0c96
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/4332
Tested-by: jenkins
6 years agotarget: arm: disassembler: fix Thumb2 BLX decoding address
Paul Fertser [Sun, 28 Jan 2018 12:48:46 +0000 (15:48 +0300)]
target: arm: disassembler: fix Thumb2 BLX decoding address

Since BLX in Thumb2 always switches mode to ARM, the PC needs to be
4-bytes aligned.

Change-Id: I4f4c194fe21093cecfd9872e1d30588f4adc7257
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/4382
Reviewed-by: Philipp Guehring <pg@futureware.at>
Tested-by: jenkins
Reviewed-by: Paul Sokolovsky <pfalcon@users.sourceforge.net>
6 years agotcl: interface: usb blaster I: specify driver explicitly
Paul Fertser [Sat, 27 Jan 2018 17:23:24 +0000 (20:23 +0300)]
tcl: interface: usb blaster I: specify driver explicitly

When a user asks for blaster I, he or she should either get it, or get
an error, not blaster II driver.

Change-Id: Ibc7683676ce42773e2b14ea5ccb3d119d1e6acea
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/4381
Tested-by: jenkins
6 years agosvf: improve robustness when processing invalid SVF files
Paul Fertser [Thu, 18 Jan 2018 08:59:10 +0000 (11:59 +0300)]
svf: improve robustness when processing invalid SVF files

Uninitialized argument value warnings reported by clang static
analizer.

Change-Id: I30af4900f517ffc0a7282689b58c7a224cdc080a
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/4356
Tested-by: jenkins
6 years agoHACKING: clarify linking identities procedure
Paul Fertser [Thu, 18 Jan 2018 08:39:52 +0000 (11:39 +0300)]
HACKING: clarify linking identities procedure

Change-Id: I89e93002181926eec5fc5a339765b773559a8ff1
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/4354
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
6 years agojtag: drivers: buspirate: fix abuse of "char" type
Paul Fertser [Mon, 12 Mar 2018 17:09:50 +0000 (20:09 +0300)]
jtag: drivers: buspirate: fix abuse of "char" type

Change occurrences of char to uint8_t where appropriate as a binary
protocol is used to talk to this adapter.

This fixes a build issue with modern clang.

Change-Id: I21cc82c8cad148bd0977533c12c74a9d6ba2faff
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/4462
Tested-by: jenkins
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
6 years agoAdd SWD protocol support to buspirate (2nd try)
Mateusz Manowiecki [Thu, 26 Jan 2017 00:12:18 +0000 (01:12 +0100)]
Add SWD protocol support to buspirate (2nd try)

This is a second try for this patch. I removed the queues from the
previous version. I made it compatible with SRST reset and added
support for those features that could be supported in raw binary
mode.

Change-Id: I96fc06abbea9873e98b414f34afd9043fd9c2a41
Signed-off-by: Mateusz Manowiecki <segmentation@fault.pl>
Reviewed-on: http://openocd.zylin.com/3960
Tested-by: jenkins
Reviewed-by: Eric Work <work.eric@gmail.com>
Reviewed-by: Thomas Jarosch <thomas.jarosch@intra2net.com>
Reviewed-by: Jacob Alexander <haata@kiibohd.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
6 years agonds32: Add jtag scan_chain command
Hellosun Wu [Fri, 12 May 2017 06:37:21 +0000 (14:37 +0800)]
nds32: Add jtag scan_chain command

Create new command to refresh idcode list during runtime
and update Tap idcode.

Change-Id: Ie889a39a6f57cea207b2b9c9e42c51c97cfe4d8e
Signed-off-by: Hellosun Wu <wujiheng.tw@gmail.com>
Reviewed-on: http://openocd.zylin.com/4133
Tested-by: jenkins
Reviewed-by: Hsiangkai Wang <hsiangkai@gmail.com>
Reviewed-by: penny chen <penny6610231@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
6 years agodoc: update openocd.texi after change of gdb-attach default value
Tomas Vanek [Sun, 4 Mar 2018 11:05:15 +0000 (12:05 +0100)]
doc: update openocd.texi after change of gdb-attach default value

While on it
- change some occurrences of gdb to GDB if it refers GDB software
  (as oposed to a gdb command)
- add some xrefs
- give more meaningful example of target event definition
- remove obsoleted example of GDB hook-step

Change-Id: Ia2e26021d57f675acfa1de704f6c3e81c22bb8bf
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4444
Tested-by: jenkins
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
6 years agohelper/types: cast to uint32_t,uint16_t to avoid UB by shifting int too far
Cody P Schafer [Wed, 7 Mar 2018 16:27:02 +0000 (11:27 -0500)]
helper/types: cast to uint32_t,uint16_t to avoid UB by shifting int too far

Without this, we have some types promoted to `int` when they need to be
`unsigned int`.

Here's some ubsan output hitting this:

Unfortunately, what happens is that things get promoted to `int`, but
need to be `unsigned int`. Here's the ubsan output:

src/helper/types.h:126:65: runtime error: left shift of 255 by 24 places cannot be represented in type 'int'
    #0 0x55978a612060 in le_to_h_u32 src/helper/types.h:126
    #1 0x55978a61ff9e in stlink_usb_read_reg src/jtag/drivers/stlink_usb.c:1539
    #2 0x55978a8cfd45 in adapter_load_core_reg_u32 src/target/hla_target.c:67
    #3 0x55978a9f48e3 in armv7m_read_core_reg src/target/armv7m.c:236
    #4 0x55978a8d24fc in adapter_load_context src/target/hla_target.c:372
    #5 0x55978a8d261b in adapter_debug_entry src/target/hla_target.c:396
    #6 0x55978a8d3123 in adapter_poll src/target/hla_target.c:457
    #7 0x55978a528357 in target_poll src/target/target.c:535
    #8 0x55978a539fd4 in target_wait_state src/target/target.c:2914
    #9 0x55978a556e20 in jim_target_wait_state src/target/target.c:5256
    #10 0x55978a5cca62 in command_unknown src/helper/command.c:1030
    #11 0x55978aaed894 in JimInvokeCommand /home/cody/d/openocd-code/jimtcl/jim.c:10364

Change-Id: I24f6abfd26b6980100657397d69c84f2b80a005a
Signed-off-by: Cody P Schafer <openocd@codyps.com>
Reviewed-on: http://openocd.zylin.com/4455
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
Reviewed-by: Christopher Head <chead@zaber.com>
6 years agojtag: hla: tcl: fix inconsistent expected_id handling
Paul Fertser [Sat, 13 Jan 2018 14:24:37 +0000 (17:24 +0300)]
jtag: hla: tcl: fix inconsistent expected_id handling

Copy from 20fcd0729e7187e8fe6a38ce53b0a1b95ea647fb.
Should fix
http://build.openocd.org/job/openocd-clang/doclinks/1/report-1e9b08.html

Change-Id: I1a83387b4d745134acc38eeba08aa869d9895573
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/4333
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
6 years agoarmv7a: cache ttbcr and ttb0/1 on debug state entry
Matthias Welwarsky [Sun, 15 Nov 2015 08:18:57 +0000 (09:18 +0100)]
armv7a: cache ttbcr and ttb0/1 on debug state entry

Instead of re-reading ttbcr and ttb0/1 whenever a virt2phys translation
is done, cache the values once when entering debug state. Use the cached
values in armv7a_mmu_translate_va().

Change-Id: I1bc5349ad2f19b2dd75bdd48468a2c1f1e028699
Signed-off-by: Matthias Welwarsky <matthias@welwarsky.de>
Reviewed-on: http://openocd.zylin.com/3112
Tested-by: jenkins
6 years agoSupport for Arm VFP v3 registers read/write
Omair Javaid [Thu, 15 Feb 2018 22:08:51 +0000 (03:08 +0500)]
Support for Arm VFP v3 registers read/write

This patch adds support in openOCD to read/write Arm vector/floating
point registers. This is compatible with Arm vfp v3 target xml in GDB.
Please refer to binutils-gdb/gdb/features/arm/arm-vfpv3.xml

Change-Id: Id4dd1bddef51c558f1a86300c1a876d159463f18
Signed-off-by: Omair Javaid <omair.javaid@linaro.org>
Reviewed-on: http://openocd.zylin.com/4421
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
Tested-by: jenkins
6 years agoSupport for AArch32 SIMD/Floating-point registers
Omair Javaid [Mon, 5 Mar 2018 11:25:21 +0000 (16:25 +0500)]
Support for AArch32 SIMD/Floating-point registers

This patch adds support for read/write of SIMD and floating-point register in AArch32 mode.
This patch is tested using Raspberry Pi3 halted in AArch32 mode with FP/SIMD enabled.
Software need to make sure floating-point and SIMD unit is enabled.

Change-Id: I2b3b8af02257c6420e5a70c6f4c91f839c1f5ee5
Signed-off-by: Omair Javaid <omair.javaid@linaro.org>
Reviewed-on: http://openocd.zylin.com/4446
Tested-by: jenkins
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
6 years agoSupport AArch64 SIMD/FP registers read/write
Omair Javaid [Sun, 21 Jan 2018 22:26:01 +0000 (03:26 +0500)]
Support AArch64 SIMD/FP registers read/write

This patch adds support in openOCD to read/write AArch64 SIMD/FP registers.
This patch depends on a previous patch which adds support to generation
of target xml by openOCD with nested architecture defined types. AArch64
SIMD/FP registers assumes various types and to support all types we
implement them as architecture defined type aarch64v which in turn
consists of various architecture defined types. This is compatible with
AArch64-FPU target xml in GDB. Please refer to
binutils-gdb/gdb/features/aarch64-fpu.xml

Change-Id: I7ffb0c21b3c2e08f13720b765408b30aab2a9808
Signed-off-by: Omair Javaid <omair.javaid@linaro.org>
Reviewed-on: http://openocd.zylin.com/4373
Tested-by: jenkins
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
6 years agoAllow generation of nested target defined types in gdb target xml
Omair Javaid [Sun, 21 Jan 2018 21:57:19 +0000 (02:57 +0500)]
Allow generation of nested target defined types in gdb target xml

This patch adds support to generate multiple nested architecture defined
data types in gdb target xml generated by openOCD. Architecture defined
structs, unions, vectors nested in one or more architecture defined
types can be generated now.

Example:

  <vector id="v2d" type="ieee_double" count="2"/>
  <vector id="v2u" type="uint64" count="2"/>
  <vector id="v2i" type="int64" count="2"/>

  <union id="vnd">
    <field name="f" type="v2d"/>
    <field name="u" type="v2u"/>
    <field name="s" type="v2i"/>
  </union>

Change-Id: I0f3c5c6daf3d22cde7e4b7b4165d2e97e25872f7
Signed-off-by: Omair Javaid <omair.javaid@linaro.org>
Reviewed-on: http://openocd.zylin.com/4372
Tested-by: jenkins
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
6 years agoCortex-R : Remove commands which are not relevant to Cortex-R
Evan Hunter [Fri, 17 Jul 2015 11:44:11 +0000 (12:44 +0100)]
Cortex-R : Remove commands which are not relevant to Cortex-R

Change-Id: I8dec85150386c149ffdb7bf4e7e533f16bb63b84
Signed-off-by: Evan Hunter <ehunter@broadcom.com>
Reviewed-on: http://openocd.zylin.com/2877
Tested-by: jenkins
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
6 years agohelper/configuration: free script_search_dirs and config_file_names
Tomas Vanek [Wed, 14 Feb 2018 21:38:13 +0000 (22:38 +0100)]
helper/configuration: free script_search_dirs and config_file_names

Although the leak is negligible, the clean heap on exit will ease
valgrind testing.

Change-Id: If43f02fe594c30ceb1bea3259ea3e098d4b2d239
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4408
Tested-by: jenkins
Reviewed-by: Marc Schink <openocd-dev@marcschink.de>
6 years agohelper/command.h: Add missing #include for target_addr_t
Marc Schink [Sun, 12 Feb 2017 21:46:20 +0000 (22:46 +0100)]
helper/command.h: Add missing #include for target_addr_t

Change-Id: Ic406257c0da6e1889d4434cc98cf59c2b97aa30c
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/4052
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
6 years agoserver/server.h: Add missing #include
Marc Schink [Fri, 16 Dec 2016 15:37:19 +0000 (16:37 +0100)]
server/server.h: Add missing #include

Change-Id: I9d0615f9218470d190223f7f6b5b406e5c7f2b11
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/4051
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
6 years agohelper/types.h: Add missing #includes
Marc Schink [Thu, 15 Dec 2016 09:44:21 +0000 (10:44 +0100)]
helper/types.h: Add missing #includes

Change-Id: I02ae0fb9527c4b87308da9c2cab66c80d84579eb
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/4050
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
6 years agohelper/command.h: Add missing #includes
Marc Schink [Thu, 15 Dec 2016 08:40:49 +0000 (09:40 +0100)]
helper/command.h: Add missing #includes

Change-Id: I84650a51cdb015f5e8ae933a3288f6e87f9fb80b
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/4049
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
6 years agohelper/replacements.h: Add missing #include
Marc Schink [Tue, 7 Mar 2017 23:06:35 +0000 (00:06 +0100)]
helper/replacements.h: Add missing #include

Change-Id: Ic6c47f7fbc999d00ef3211c1fa44867e3aabc321
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/4057
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
6 years agoserver/server: Remove all connections on shutdown
Marc Schink [Sat, 7 Jan 2017 16:43:49 +0000 (17:43 +0100)]
server/server: Remove all connections on shutdown

This patch fixes a memory leak in the internal server. Steps for
reproduction:

 * valgrind --leak-check=full --show-reachable=yes ./build/src/openocd
 * Establish more than one connection to OpenOCD (e.g. telnet)
 * Shutdown OpenOCD
 * Check for memory leaks in add_connection()

Change-Id: I0ae6fcf2918fd9bdec350446d3e26742d08ff698
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/4053
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
6 years agopipistrello: decrease jtag speed to 10 MHz
Robert Jordens [Thu, 5 Oct 2017 13:44:58 +0000 (15:44 +0200)]
pipistrello: decrease jtag speed to 10 MHz

30 MHz is not working reliably here

Change-Id: I38f5f8c7153fc64e313ee911b1629fb5f1114c39
Signed-off-by: Robert Jordens <jordens@gmail.com>
Reviewed-on: http://openocd.zylin.com/4242
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
6 years agoFix ChibiOS FPU detection.
Luca Dariz [Fri, 9 Feb 2018 15:58:25 +0000 (16:58 +0100)]
Fix ChibiOS FPU detection.

This is needed for Cortex-M7 devices, which have newer FPU.
This issue caused the registry integrity check to fail if FPU was enabled.
Currently the code must use FPUv4_SP anyway, since other configurations are not
supported by ChibiOS.

Change-Id: Ie8a2cb8282ccff6c2a3eb0ffeaddaf149d55d685
Signed-off-by: Luca Dariz <luca.dariz@gmail.com>
Reviewed-on: http://openocd.zylin.com/4398
Tested-by: jenkins
Reviewed-by: Karl Palsson <karlp@tweak.net.au>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
6 years agoAdded support for STMicroelectronics BlueNRG-1 and BlueNRG-2 SoC
Michele Sardo [Tue, 12 Sep 2017 06:51:29 +0000 (08:51 +0200)]
Added support for STMicroelectronics BlueNRG-1 and BlueNRG-2 SoC

Added configuration files and flash loaders.

Change-Id: I768eb3626f4e0eadb206bef90a867cc146fe8c75
Signed-off-by: Michele Sardo <msmttchr@gmail.com>
Reviewed-on: http://openocd.zylin.com/4226
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
6 years agoflash/nor/psoc4: fix protection on devices with 256k flash
Tomas Vanek [Wed, 21 Feb 2018 12:54:44 +0000 (13:54 +0100)]
flash/nor/psoc4: fix protection on devices with 256k flash

Protection read and setting of the second flash macro did not work.
Tested on CY8CKIT-046

Change-Id: I67789399ad1e89bbfc23a95547ecca7753130701
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4425
Tested-by: jenkins
6 years agoflash/nor/psoc4: fix warnings
Tomas Vanek [Wed, 14 Feb 2018 18:47:06 +0000 (19:47 +0100)]
flash/nor/psoc4: fix warnings

Reported by Clang static analyzer.

Change-Id: I1118f303f468b6a78ec6cba692762aee565bdf9e
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4407
Tested-by: jenkins
6 years agoflash/nor/core: fix warning in flash_iterate_address_range_inner
Tomas Vanek [Thu, 18 Jan 2018 08:42:41 +0000 (09:42 +0100)]
flash/nor/core: fix warning in flash_iterate_address_range_inner

Refactor the code to improve readability.

Reported by Clang static analyzer.

Change-Id: I671447050e93c6f067917c4456b36ac11abb4663
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4355
Tested-by: jenkins
6 years agoflash/nor/psoc4: adjust flash size limited by wounding
Tomas Vanek [Sat, 6 Jan 2018 11:10:12 +0000 (12:10 +0100)]
flash/nor/psoc4: adjust flash size limited by wounding

All credit goes to Dmitry Grinberg
http://dmitry.gr/index.php?r=05.Projects&proj=24.%20PSoC4%20confidential

Change-Id: Iae8fd6f11a7f62e8ffe970473688f6fac5a0a261
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4324
Tested-by: jenkins
6 years agotarget: use correct target in target-prefixed commands and event handlers
Tomas Vanek [Tue, 21 Nov 2017 21:57:39 +0000 (22:57 +0100)]
target: use correct target in target-prefixed commands and event handlers

This change contains an alternative to Matthias Welwarsky's #4130
(target-prefixed commands) and to #4293 (event handlers).

get_current_target() must retrieve the target associated to the current
command. If no target associated, the current target of the command
context is used as a fallback.

Many Tcl event handlers work with the current target as if it were
the target issuing the event.

current_target in command_context is a number and has to be converted
to a pointer in every get_current_target() call.

The solution:
- Replace current_target in command_context by a target pointer
- Add another target pointer current_target_override
- get_current_target() returns current_target_override if set, otherwise
current_target
- Save, set and restore current_target_override to the current prefix
in run_command()
- Save, set and restore current_target_override to the event invoking
target in target_handle_event()

While on it use calloc when allocating a new command_context.

Change-Id: I9a82102e94dcac063743834a1d28da861b2e74ea
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Suggested-by: Matthias Welwarsky <matthias.welwarsky@sysgo.com>
Reviewed-on: http://openocd.zylin.com/4295
Tested-by: jenkins
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
6 years agortos: fix rtos no-auto configuration
Matthias Welwarsky [Thu, 1 Mar 2018 16:43:25 +0000 (17:43 +0100)]
rtos: fix rtos no-auto configuration

A previous fix avoiding multiple calls to the
rtos_create function had a side effect if rtos
support was configured explicitly. It affected
all rtos' that rely on symbol resolution from
gdb.

Change-Id: Id7f17c6ec5ce2450322d2748a4b2369aaa524a7b
Fixes: 3aa8bd2d1704118ad9bbee2f21cbc15a848c8c5b
Signed-off-by: Matthias Welwarsky <matthias.welwarsky@sysgo.com>
Reviewed-on: http://openocd.zylin.com/4438
Tested-by: jenkins
Reviewed-by: Richard Braun <rbraun@sceen.net>
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
6 years agogdb_server: run control fixes for vCont
Tomas Vanek [Fri, 23 Feb 2018 18:27:28 +0000 (19:27 +0100)]
gdb_server: run control fixes for vCont

this patch contains several changes to run control and state
handling together with gdb:
- graceful handling of target/gdb desync on resume, step and halt
- a default gdb-attach event executing the "halt" command, to meet gdb
  expectation of target state when it attaches
- call target_poll() after Ctrl-C command from gdb
- call target_poll() after resume and step through a vCont packet
- fix log message forwarding on vCont stepping, also move an aarch64
  log message from INFO to DEBUG level to prevent messing up the gdb
  console during source-line stepping
- fix oversight in vCont support that messes up breakpoint handling
  during stepping

Change-Id: Ic79db7c2b798a35283ff752e9b12475486a1f31a
Fixes: d301d8b42f0bfe67d76d6f340db6570cc71c876e
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Signed-off-by: Matthias Welwarsky <matthias.welwarsky@sysgo.com>
Reviewed-on: http://openocd.zylin.com/4432
Tested-by: jenkins
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
6 years agoFix incorrect comment
Christopher Head [Mon, 26 Feb 2018 22:51:35 +0000 (14:51 -0800)]
Fix incorrect comment

target_start_algorithm does not download the algorithm. It only starts
it. It expects someone else to have already written the algorithm code
into the proper location before calling it.

Change-Id: I5e04406eed0ebb1c23e550dbf8d9f1204c432603
Signed-off-by: Christopher Head <chead@zaber.com>
Reviewed-on: http://openocd.zylin.com/4435
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
6 years agoExpand target_run_flash_async_algorithm() doc comment.
Girts Folkmanis [Mon, 8 May 2017 22:31:31 +0000 (15:31 -0700)]
Expand target_run_flash_async_algorithm() doc comment.

Change-Id: I5d1e8401cbcf0e116a233a2839a06d2c9dbc85ce
Signed-off-by: Girts Folkmanis <opensource@girts.me>
Reviewed-on: http://openocd.zylin.com/4127
Tested-by: jenkins
Reviewed-by: Christopher Head <headch@gmail.com>
Reviewed-by: Andreas Bolsch <hyphen0break@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
6 years agoefm32: Add JTAG definitions to EFM32 target file
Jonas Norling [Tue, 17 Oct 2017 09:38:16 +0000 (11:38 +0200)]
efm32: Add JTAG definitions to EFM32 target file

This makes it possible to program newer EFM32 and EFR32 chips with
JTAG, as opposed to SWD.

Change-Id: Ia3e8c1bbc66fc1f33e8cf2087ccf0d1b4dfd74e1
Signed-off-by: Jonas Norling <jonas.norling@cyanconnode.com>
Reviewed-on: http://openocd.zylin.com/4262
Tested-by: jenkins
Reviewed-by: Fredrik Hederstierna <fredrik@hederstierna.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
6 years agostm8: fix compilation warning
Ake Rehnman [Tue, 23 Jan 2018 10:10:19 +0000 (11:10 +0100)]
stm8: fix compilation warning

Change-Id: Iedad040384316356442ec87769855fa2960893c5
Signed-off-by: Ake Rehnman <ake.rehnman@gmail.com>
Reviewed-on: http://openocd.zylin.com/4377
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
6 years agoflash/nor/core: fix Segmentation fault during flash write of bad formed img
Tomas Vanek [Thu, 8 Feb 2018 13:44:10 +0000 (14:44 +0100)]
flash/nor/core: fix Segmentation fault during flash write of bad formed img

flash_write_unlock() sorts sections by base address but does not check
if they overlap. In case of overlapped sections an item of padding[]
array can get negative and padding loop writes out of allocated buffer.

How to replicate: cat two copies of an ihex file to one file and try
to flash it.

Check for overlapped sections and abort write in such case.

Change-Id: I43eee7dc290a8d18faa59567b2118b88ad4bedca
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4397
Tested-by: jenkins
Reviewed-by: Andreas Bolsch <hyphen0break@gmail.com>
6 years agotarget: fix target.working_area type
Peter Mamonov [Wed, 15 Feb 2017 10:03:15 +0000 (13:03 +0300)]
target: fix target.working_area type

Change-Id: I15cfbe6984656fb0b48d2af5a7e1afa10d47b6ab
Signed-off-by: Peter Mamonov <pmamonov@gmail.com>
Reviewed-on: http://openocd.zylin.com/3977
Tested-by: jenkins
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
6 years agogdb_server: update rtos threads on new connection
Matthias Welwarsky [Fri, 17 Feb 2017 15:18:09 +0000 (16:18 +0100)]
gdb_server: update rtos threads on new connection

make sure the RTOS thread database is updated early on a new
gdb connection.

Change-Id: I4da9ef30f8634263d697116cefc47976cd1970ad
Signed-off-by: Matthias Welwarsky <matthias.welwarsky@sysgo.com>
Reviewed-on: http://openocd.zylin.com/4000
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
Tested-by: jenkins
6 years agortos: run rtos create hook only once on autodetect
Matthias Welwarsky [Fri, 17 Feb 2017 15:12:07 +0000 (16:12 +0100)]
rtos: run rtos create hook only once on autodetect

Whenever a "qSymbol" from gdb is received, the rtos "create"
function was called. Make sure this happens only once and only
if rtos autodetection is used.

Change-Id: Ie5f8632cfce2d64a38dbdb63468302c4e8a784f4
Signed-off-by: Matthias Welwarsky <matthias.welwarsky@sysgo.com>
Reviewed-on: http://openocd.zylin.com/3998
Tested-by: jenkins
Reviewed-by: Sergey A. Borshch <sb-sf@users.sourceforge.net>
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
6 years agortos: facilitate RTOS SMP handling
Matthias Welwarsky [Fri, 17 Feb 2017 13:45:00 +0000 (14:45 +0100)]
rtos: facilitate RTOS SMP handling

The RTOS handlers present OS threads to gdb but the openocd
target layer only knows about CPU cores (hardware threads).
This patch allows closing this gap inside the RTOS handler.

The default implementation just returns the current core, but
a RTOS handler can provide its own function that associates a
an OS thread with a core.

Change-Id: I12cafe50b38a38b28057bc5d3a708aa20bf60515
Signed-off-by: Matthias Welwarsky <matthias.welwarsky@sysgo.com>
Reviewed-on: http://openocd.zylin.com/3997
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
Tested-by: jenkins
6 years agogdb_server: add support for vCont
Matthias Welwarsky [Wed, 20 Sep 2017 10:02:08 +0000 (12:02 +0200)]
gdb_server: add support for vCont

Make gdb use target support for single-stepping if available.

Change-Id: Ie72345a1e749aefba7cd175ccbf5cf51d4f1a632
Signed-off-by: Matthias Welwarsky <matthias.welwarsky@sysgo.com>
Reviewed-on: http://openocd.zylin.com/3833
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
6 years agocortex_a: fix handling of Thumb-2 32bit breakpoints
Matthias Welwarsky [Thu, 5 Oct 2017 12:50:16 +0000 (14:50 +0200)]
cortex_a: fix handling of Thumb-2 32bit breakpoints

When debugging Thumb-2 code, Gdb will at times send a
breakpoint packet 'Z0,<addr>,3', the number 3 denoting that
the instruction to break on is 32 bits long. Handle this by
replacing it with two consecutive 16bit Thumb BKPTs and make
sure to save and restore the full, original 32bit
instruction.

Note that this fix is only applicable if you debug a bare-metal program
(like the linux kernel) with the 'wrong' gdb, e.g. use an
"arm-linux" gdb instead of an "arm-eabi" gdb. But since most people
may not know about the subtle differences between gdb configurations
regarding thumb2 breakpoints it's still valid.

Change-Id: Ib93025faf35b11f0dba747a8c1fc36fd09a4c0f8
Signed-off-by: Matthias Welwarsky <matthias.welwarsky@sysgo.com>
Reviewed-on: http://openocd.zylin.com/4241
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
Tested-by: jenkins
6 years agoicepick-d: extend access to core control register
Matthias Welwarsky [Sun, 26 Mar 2017 08:24:59 +0000 (10:24 +0200)]
icepick-d: extend access to core control register

The ICEPick-D jtag router has core control registers
that provide the same (or similar) functionality as
the tap control register, for individual cores
accessible through the same tap (e.g. through a DAP).

Core control registers are located at address "0x60 +
core-id" of the ROUTER address space (IR=ROUTER).

It is sometimes helpful or even necessary to modify the
core control register. This patch renames the
"icepick_d_coreid" function to the more appropriate
"icepick_d_core_control" and adds a "value" argument
that allows writing of arbitrary value.
"icepick_d_tapenable" is extended by an optional value
argument so that core control can be written as the tap
is enabled.

Change-Id: I0e7f91b596cb5075364c6c233348508f58e0a901
Signed-off-by: Matthias Welwarsky <matthias.welwarsky@sysgo.com>
Reviewed-on: http://openocd.zylin.com/4141
Tested-by: jenkins
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
6 years agoarmv7a: forward error value in armv7a_cache_auto_flush_all_data
Oleksij Rempel [Tue, 30 Jan 2018 09:37:51 +0000 (10:37 +0100)]
armv7a: forward error value in armv7a_cache_auto_flush_all_data

if armv7a_l1_d_cache_clean_inval_all will fail, error value is never
forwarded. So make sure we do it from now.

Change-Id: I02acfaa938ec09f58df77191d13d8f4bb3308720
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Reviewed-on: http://openocd.zylin.com/4384
Tested-by: jenkins
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
6 years agoefm32: Refactor EFM32 chip family data, add more chips
Jonas Norling [Tue, 17 Oct 2017 06:57:06 +0000 (08:57 +0200)]
efm32: Refactor EFM32 chip family data, add more chips

Add support for more EFM32/EFR32 Series 1 families. The family IDs
come from the DEVICE_FAMILY list in the EFM32GG11 reference manual,
which is the most up to date source I could find. Register locations
have been checked against SiLab's header files.

No datasheets or headers were available for EFR32MG2, EFR32xG14 and
EFM32TG11B, so they are just assumed to follow the pattern. EFM32GG11B
has the MSC registers on a different address compared to other chips.

This commit attempts not to change current behavior when detecting
chips. One detail that has changed is that PAGE_SIZE is read before
applying the workaround for old Giant and Leopard Gecko revisions, but
this is believed to be OK because the register exists but just has an
invalid value in it.

The manuals disagree on which of 120 and 121 is WG, so this commit
leaves it as is.

Change-Id: Ia152b0b9e323defc5158cb02d9a6b04a27008f2a
Signed-off-by: Jonas Norling <jonas.norling@cyanconnode.com>
Reviewed-on: http://openocd.zylin.com/4263
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Fredrik Hederstierna <fredrik@hederstierna.com>
6 years agoAdd support for Cypress PSoC6 family of devices
Bohdan Tymkiv [Mon, 25 Sep 2017 11:25:22 +0000 (14:25 +0300)]
Add support for Cypress PSoC6 family of devices

* Tested on CY8CKIT-001 kit with PSoC6 daughter board.
* Tested with several J-Link adapters (Ultra+, Basic)

Change-Id: I0a818c231e5f0b270c7774037b38d23221d59417
Signed-off-by: Bohdan Tymkiv <bhdt@cypress.com>
Reviewed-on: http://openocd.zylin.com/4233
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
6 years agoHandle improperly build image files gracefully
Andreas Bolsch [Sat, 28 Oct 2017 17:39:35 +0000 (19:39 +0200)]
Handle improperly build image files gracefully

Images build improperly (by simply concatenating separate images) were accepted,
but anything after the first end-of-file record *silently* ignored. Now emit warning
for intel and motorola images upon non-whitespace after first end-of-file record but
continue reading anyway.
ST ships some images broken that way in their CubeMX packages ...

Change-Id: I0c5d08fa90070fed11fb805c5f0dc39817048176
Signed-off-by: Andreas Bolsch <hyphen0break@gmail.com>
Reviewed-on: http://openocd.zylin.com/4281
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
6 years agopsoc4: update for 4x00BLE, L, M, S and PRoC BLE devices
Tomas Vanek [Fri, 26 Aug 2016 19:03:27 +0000 (21:03 +0200)]
psoc4: update for 4x00BLE, L, M, S and PRoC BLE devices

Flash ROM API command PSOC4_CMD_SET_IMO48 is now optional on new devices.
Also code tidy up:
- improved system ROM call error detection
- probe does not require the target to be halted
- default_padded_value and erased_value set to 0
- fixed endianess problem in flash write and protection setting
- removed fancy chip detection table as it would be updated too often
- psoc4 flash_autoerase is now on by default to ease programming

psoc4.cfg distinguishes chip family and uses either proprietary acquire
function of a KitProg adapter or TEST_MODE workaround to "reset halt"

Change-Id: I2c75ec46ed0a95e09274fad70b62d6eed7b9ecdf
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/3807
Tested-by: jenkins
Reviewed-by: David Girault <david.f.girault@gmail.com>
6 years agoflash/nor/at91samd: add SAM R30 family
Tomas Vanek [Mon, 30 Oct 2017 16:59:06 +0000 (17:59 +0100)]
flash/nor/at91samd: add SAM R30 family

Microchip SAM R30 consist of a MCU SAM L21 and a radio.
Similarly SAM R21 = SAM D21 + radio. Therefore SAM R devices
was incorporated into SAM D21 and L21 device groups.

Change-Id: I3448d784cae888070b57c2f504583760ddffc97f
Suggested-by: Martin Deicke <martin.deicke@an-solutions.de>
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4282
Tested-by: jenkins
6 years agocortex_a: faster debug init
Matthias Welwarsky [Thu, 6 Apr 2017 06:47:03 +0000 (08:47 +0200)]
cortex_a: faster debug init

Don't use atomic dap operations when not necessary

Change-Id: Idc6dcd2bda95f7994852df4ae2a588976f4c9010
Signed-off-by: Matthias Welwarsky <matthias.welwarsky@sysgo.com>
Reviewed-on: http://openocd.zylin.com/4142
Tested-by: jenkins
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
6 years agoflash/nor/kinetis_ke: fix warning retval set but not used
Tomas Vanek [Sun, 21 Jan 2018 09:47:32 +0000 (10:47 +0100)]
flash/nor/kinetis_ke: fix warning retval set but not used

I see no reason for not returning error from target_run_algorithm()
to higher level.

Reported by Clang static analyzer.

Change-Id: Iaaa8b66e487ecae88c0cf4ae2addba63341c032c
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4391
Tested-by: jenkins
Reviewed-by: Ivan Meleca <ivan@artekit.eu>
6 years agojtag: drivers: stlink: ignore write verify error
Paul Fertser [Sat, 20 Jan 2018 18:05:46 +0000 (21:05 +0300)]
jtag: drivers: stlink: ignore write verify error

This looks like some inappropriate stlink (mis-)feature and it messes
operations for writing to certain memory-mapped registers.

Discussed at https://forum.sparkfun.com/viewtopic.php?f=18&t=44949 .
Also known to be problematic for working with Kinetis parts.

Reported by robertfoss_ on IRC.

Change-Id: I8633aed13346c596000ba6c377758e1bb96db73f
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/4368
Tested-by: jenkins
Reviewed-by: Robert Foss <robert.foss@memcpy.io>
Reviewed-by: Andreas Bolsch <hyphen0break@gmail.com>
Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
6 years agoKinetis_ke: add KEAx family to texi and cfg comment
Tomas Vanek [Fri, 22 Sep 2017 22:24:19 +0000 (00:24 +0200)]
Kinetis_ke: add KEAx family to texi and cfg comment

Change-Id: Id8f676b027f57fc540473c1a3a01bdd2ec49a200
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4232
Tested-by: jenkins
Reviewed-by: Joakim Nohlgård <joakim.nohlgard@eistec.se>
6 years agotcl: interface: harmonise RPi configs
Paul Fertser [Sat, 31 Dec 2016 13:05:55 +0000 (16:05 +0300)]
tcl: interface: harmonise RPi configs

Make all configs specify same JTAG and SWD GPIO numbers.

Change-Id: I65b09c1671c97f253f0aab88e511de7409d91e0a
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/3932
Tested-by: jenkins
6 years agoflash: nor: jtagspi: fix jtagspi_read_status() warning
Paul Fertser [Sun, 14 Jan 2018 16:28:20 +0000 (19:28 +0300)]
flash: nor: jtagspi: fix jtagspi_read_status() warning

Clang static analyzer says that in certain cases "Assigned value is
garbage or undefined" there.

Change-Id: Ib35a4cf7a553ba9461270a0dc4c4b9b205091e73
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/4338
Tested-by: jenkins
6 years agodoxygen: fix issues with recent Doxygen versions
Paul Fertser [Tue, 16 Jan 2018 12:08:34 +0000 (15:08 +0300)]
doxygen: fix issues with recent Doxygen versions

This fixes parsing of several documentation files which do not have
dot in the filename.

style.txt change fixes doxygen warnings and ensures proper display of
comment begin/end instructions in HTML.

Tested with Doxygen 1.8.13.

Change-Id: I9fd9ac3b51b47076b8fdbd3e93b90c3eba9b9631
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/4342
Tested-by: jenkins
6 years agox86_32_common: fix some warnings
Paul Fertser [Wed, 17 Jan 2018 19:00:42 +0000 (22:00 +0300)]
x86_32_common: fix some warnings

Mostly "Dead assignment" reported by Clang static analyzer.

Change-Id: Ibf81d2ba2462570ee3a40e57a60c55a1d1fa0c00
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/4351
Tested-by: jenkins
6 years agoarm_adi_v5: fix return value of mem_ap_read/write for size 0
Tomas Vanek [Thu, 18 Jan 2018 08:58:55 +0000 (09:58 +0100)]
arm_adi_v5: fix return value of mem_ap_read/write for size 0

Unhandled marginal case produced a warning in Clang static analyzer.

Change-Id: I3e2fc4182fa4f863acfb972b1e7a512fce5bf33a
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Suggested-by: Matthias Welwarsky <matthias@welwarsky.de>
Reviewed-on: http://openocd.zylin.com/4357
Tested-by: jenkins
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
6 years agoaarch64: clean up scan-build errors
Matthias Welwarsky [Tue, 16 Jan 2018 12:05:04 +0000 (13:05 +0100)]
aarch64: clean up scan-build errors

scan-build reported a couple of problems with code in aarch64.c,
this patch cleans them up. No functional changes.

Change-Id: Ie210237ddc840a8bbcd535f86a3a5faf473132f2
Signed-off-by: Matthias Welwarsky <matthias.welwarsky@sysgo.com>
Reviewed-on: http://openocd.zylin.com/4346
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
6 years agojtag: drivers: usb_blaster: clarify lowlevel driver selection code
Paul Fertser [Fri, 30 Dec 2016 21:04:48 +0000 (00:04 +0300)]
jtag: drivers: usb_blaster: clarify lowlevel driver selection code

This patch should make the code logic more transparent and user
notifications more useful.

It also fixes a warning "array subscript is below array bounds" that
leads to FTBFS on Raspbian GNU/Linux 8 (jessie).

Change-Id: I626b6a5bc013dfee7d36cf196f0abab981d30675
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/3931
Tested-by: jenkins
6 years agonor/nrf5: added nrf51822 QFAAH2
Daniel Kucera [Sat, 13 Jan 2018 15:37:19 +0000 (16:37 +0100)]
nor/nrf5: added nrf51822 QFAAH2

Change-Id: I59725e098371c63ec3e6aa1d91bfed36b824a182
Signed-off-by: Daniel Kucera <daniel.kucera@gmail.com>
Reviewed-on: http://openocd.zylin.com/4334
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
6 years agoaarch64: implement mmu on/off for aarch32
Matthias Welwarsky [Mon, 22 Jan 2018 11:28:37 +0000 (12:28 +0100)]
aarch64: implement mmu on/off for aarch32

add decoding of aarch32 core modes (register layout is compatible)

Change-Id: I34c3146a7b1f836d3006be2b76b036da055b3d3e
Signed-off-by: Matthias Welwarsky <matthias.welwarsky@sysgo.com>
Reviewed-on: http://openocd.zylin.com/4374
Tested-by: jenkins
Reviewed-by: Forest Crossman <cyrozap@gmail.com>
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
6 years agoAdd read buffer to bitbang, improving performance.
Tim Newsome [Wed, 13 Dec 2017 21:13:22 +0000 (13:13 -0800)]
Add read buffer to bitbang, improving performance.

Previously for every bit scanned OpenOCD would write the bit, wait for
that bit to be scanned, and then read the result. This involves at least
2 context switches. Most of the time the next bit scanned does not
depend on the last bit we read, so with a buffer we now write a bunch of
bits to be scanned all at once, and then we wait for them all to be
scanned and have a result.

This reduces the time for one testcase where OpenOCD connects to a
simulator from 12.30s to 5.35s!

Running all our tests went from 13m13s to 3m55s.

Change-Id: Ie9fcea043ac1d7877a521125334ed47d4b3e1615
Signed-off-by: Tim Newsome <tim@sifive.com>
Reviewed-on: http://openocd.zylin.com/4312
Tested-by: jenkins
Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
6 years agoUse timeval helpers
Christopher Head [Wed, 24 Jan 2018 22:35:40 +0000 (14:35 -0800)]
Use timeval helpers

Some of these changes actually fix broken comparisons which could
occasionally fail. Others just clean up the code and make it more clear.

Change-Id: I6c398bdc45fa0d2716f48a74822457d1351f81a5
Signed-off-by: Christopher Head <chead@zaber.com>
Reviewed-on: http://openocd.zylin.com/4380
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
6 years agoAdd timeval_compare helper function
Christopher Head [Wed, 24 Jan 2018 22:22:37 +0000 (14:22 -0800)]
Add timeval_compare helper function

Change-Id: Id75727a150912ff778a4fa32ad56467da33a6324
Signed-off-by: Christopher Head <chead@zaber.com>
Reviewed-on: http://openocd.zylin.com/4379
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
6 years agotcl: target: klx: use 1KiB for working area
Paul Fertser [Sat, 20 Jan 2018 18:10:39 +0000 (21:10 +0300)]
tcl: target: klx: use 1KiB for working area

Some parts have only that much. Reported by robertfoos_ on IRC.

Change-Id: I684fdccfa62cf726466ddc467543a990fd88c4dc
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/4369
Reviewed-by: Robert Foss <robert.foss@memcpy.io>
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
6 years agoflash Kinetis: add K27 and K28 devices
Tomas Vanek [Sun, 15 Oct 2017 08:34:27 +0000 (10:34 +0200)]
flash Kinetis: add K27 and K28 devices

Tested on FRDM-K28F. Thanks to Thomas Varghese for donating the kit.

Change-Id: Idcdd8bcf992acebd19e5335f7f833356500c45dd
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4255
Tested-by: jenkins
Reviewed-by: Joakim Nohlgård <joakim.nohlgard@eistec.se>
Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
6 years agoflash Kinetis: make FCF protection more user friendly
Tomas Vanek [Wed, 6 Sep 2017 20:34:14 +0000 (22:34 +0200)]
flash Kinetis: make FCF protection more user friendly

The Flash Configuration Field on Kinetis devices requires protection
because it is located in program flash space (at 0x400) and writing
an improper data to it may permanently lock the device. Even an erased
flash sector containing FCF engages security lock (not permanent one)
on the next reset or power cycle.

'kinetis fcf_source protection' mode was introduced in the change #3562.
Flash driver in this mode sets FCF immediately after sector erase to
prevent unintentional security lock. To do so the driver needs to know
FCF values before flash image data is actually processed. Flash
protection bits are available in bank structure, FOPT can be set by
'kinetis fopt' command and securing device by FSEC is not supported.

Nevertheless an inexperienced user flashed the device using an image
with FCF values different from those set in OpenOCD config and
concluded programming did not work as some verify errors showed.

This change tries to write maximum possible from image data
retaining FCF protection.

Check FCF in programmed data and report if some field differs from
values set by OpenOCD flash block protection and 'kinetis fopt' command.
Warn user about verify errors caused by FCF protection.

On devices with ECC flash (K26, K66 and KV5x) it is impossible to change
already programmed FCF - it would result in an ECC error. As FCF was
written just after erase in 'kinetis fcf_source protection' mode
the warning issued during flash write is the only possible action.

On non-ECC flash devices use cumulative flash programming to
set FCF values requested in programmed image data.
Use FSEC from programmed data only if it does not request a secure
mode. Device can be secured only in 'kinetis fcf_source write' mode.
Use FOPT from programmed data if its value was not configured
in OpenOCD config by 'kinetis fopt' command.

Change-Id: If65fbbd7700069f57e4ae32234dce371bff93674
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4228
Tested-by: jenkins
Reviewed-by: Robert Foss <robert.foss@memcpy.io>
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
6 years agoflash: nor: stm32l4x: fix warning in probe
Paul Fertser [Wed, 17 Jan 2018 21:07:29 +0000 (00:07 +0300)]
flash: nor: stm32l4x: fix warning in probe

Reading options word can fail, so this needs to be handled.

Reported by Clang static analyzer.

Change-Id: I9754cab9c4446fa2b20d4b44b0e20724d1bc1beb
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/4352
Tested-by: jenkins
Reviewed-by: Tim "mithro" Ansell <mithro@mithis.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
6 years agoserver: add safeguards against printing bogus port number
Paul Fertser [Wed, 17 Jan 2018 14:31:58 +0000 (17:31 +0300)]
server: add safeguards against printing bogus port number

Clang static checker emits "Assigned value is garbage or undefined"
warning there as it can't prove that when the socket descriptor is
AF_INET/SOCK_STREAM and getsockname doesn't return an error, sin_port
is guaranteed to be filled in.

Pacify it by obvious means.

Change-Id: I43b5e5ceb41c07d523a81b34a25490c4c5f49a70
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/4350
Tested-by: jenkins
Reviewed-by: Tim Newsome <tim@sifive.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
6 years agotarget, arm_adi_v5: catch two allocation errors
Tomas Vanek [Sun, 14 Jan 2018 22:33:44 +0000 (23:33 +0100)]
target, arm_adi_v5: catch two allocation errors

Command
mdw 0 0x40000000
triggers Segmentation fault on an arm.
Size parameter is a nonsence that may happen e.g. if you
mistype mdw instead of mww.

Add checking for calloc() NULL return in mdb/h/w.

Use calloc() instead of malloc() as multiplication
count * sizeof(uint32_t) overflows for size >= 0x40000000.

Change-Id: I968c944d863d1173ef932a7077d526fccb9381ae
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4349
Tested-by: jenkins
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
6 years agoFix Jim interpreter memory leak
Marc Schink [Wed, 10 Jan 2018 11:45:52 +0000 (12:45 +0100)]
Fix Jim interpreter memory leak

Change-Id: I71d7d97e7dc315c42fc43b65cb5fcecd7bdfb581
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/2959
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
6 years agotarget: add initial imx7.cfg
Oleksij Rempel [Wed, 14 Jun 2017 08:06:38 +0000 (10:06 +0200)]
target: add initial imx7.cfg

Change-Id: I899a215049ff0bc8840463c71018867ef71b5b90
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Reviewed-on: http://openocd.zylin.com/4190
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
Tested-by: jenkins
6 years agoaarch64: speed up first examination
Matthias Welwarsky [Thu, 6 Apr 2017 07:49:37 +0000 (09:49 +0200)]
aarch64: speed up first examination

Don't use atomic dap operations when not necessary. Also remove
loop trying to set core power request, didn't find a platform
where it actually worked and it's slowing examination down.

Change-Id: I44e5c2f289f951b8f4579f08a841172404a52053
Signed-off-by: Matthias Welwarsky <matthias.welwarsky@sysgo.com>
Reviewed-on: http://openocd.zylin.com/4143
Tested-by: jenkins
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
6 years agoaarch64: simplify mode and state handling
Matthias Welwarsky [Thu, 6 Apr 2017 09:06:20 +0000 (11:06 +0200)]
aarch64: simplify mode and state handling

Aarch32 and Aarch64 modes don't conflict in CPSR, no need to deconflict
ARMv7-M profile modes either.

Change-Id: I4c437dfa657f9e8a1da3687bc9f21435384b7881
Signed-off-by: Matthias Welwarsky <matthias.welwarsky@sysgo.com>
Reviewed-on: http://openocd.zylin.com/4144
Tested-by: jenkins
Reviewed-by: Yao Qi <qiyaoltc@gmail.com>
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
6 years agoaarch64: add 'maskisr' command
Matthias Welwarsky [Mon, 27 Feb 2017 16:10:19 +0000 (17:10 +0100)]
aarch64: add 'maskisr' command

Allow to configure ISR masking during single-step and add
handling for stepping over WFI with ISR masked.

Change-Id: I7918be7bcda6a1d9badac44fc36c59b52f662fef
Signed-off-by: Matthias Welwarsky <matthias.welwarsky@sysgo.com>
Reviewed-on: http://openocd.zylin.com/4023
Tested-by: jenkins
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
6 years agoarm_adi_v5: added some partnumbers found in tegra 186 and tegra 210
Jiri Kastner [Mon, 12 Jun 2017 13:26:02 +0000 (15:26 +0200)]
arm_adi_v5: added some partnumbers found in tegra 186 and tegra 210

Change-Id: Icd4137f3e266364d9728672bd2359fbd9a6c8ce9
Signed-off-by: Jiri Kastner <cz172638@gmail.com>
Signed-off-by: Forest Crossman <cyrozap@gmail.com>
Reviewed-on: http://openocd.zylin.com/4160
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
6 years agojtagspi: new protocol that includes transfer length
Robert Jordens [Tue, 8 Aug 2017 16:16:35 +0000 (18:16 +0200)]
jtagspi: new protocol that includes transfer length

This commit contains a rewrite of the jtagspi protocol and covers both
changes in the jtagspi.c openocd driver and the bscan_spi
(xilinx_bscan_spi) proxy bitstreams. The changes are as follows:

1. Always perform IR scan to ensure proper clearing of BYPASSed DRs.
2. Insert alignment cycles for all BYPASSed TAPs:

  The previous logic was erroneous. The delay in clock cyles from a bit
  written to the jtag interface to a bit read by the jtag interface is:

  * The number of BYPASSed TAPs before this (jtagspi) tap
  * The length of the jtagspi data register (1)
  * The number of BYPASSed TAPs before this one.

  I.e. it is just the number of enabled TAPs. This also gets rid of the
  configuration parameter DR_LENGTH.

3. Use marker bit to start spi transfer

  If there are TAPs ahead of this one on the JTAG chain, and we are in
  DR-SHIFT, there will be old bits toggled through first before the first
  valid bit destined for the flash.
  This delays the begin of the JTAGSPI transaction until the first high bit.

4. New jtagspi protocol

  A JTAGSPI transfer now consists of:

  * an arbitrary number of 0 bits (from BYPASS registers in front of the
    JTAG2SPI DR)
  * a marker bit (1) indicating the start of the JTAG2SPI transaction
  * 32 bits (big endian) describing the length of the SPI transaction
  * a number of SPI clock cycles (corresponding to 3.) with CS_N asserted
  * an arbitrary number of cycles (to shift MISO/TDO data through
    subsequent BYPASS registers)

5. xilinx_bscan_spi: clean up, add ultrascale

This is tested on the following configurations:

* KC705: XC7K325T
* Sayma AMC: XCKU040
* Sayma AMC + RTM): XCKU040 + XC7A15T, a board with integrated FTDI JTAG
  adapter, SCANSTA JTAG router, a Xilinx Ultrascale XCKU040 and a Xilinx
  Artix 7 15T. https://github.com/m-labs/sinara/wiki/Sayma
* Custom board with Lattice FPGA + XC7A35T
* CUstom board with 3x XCKU115-2FLVA1517E

Change-Id: I7361e9fb284ebb916302941735eebef3612aa103
Signed-off-by: Robert Jordens <jordens@gmail.com>
Reviewed-on: http://openocd.zylin.com/4236
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
6 years agoserver/telnet: Use proper data types
Marc Schink [Wed, 13 Apr 2016 09:00:19 +0000 (11:00 +0200)]
server/telnet: Use proper data types

Change-Id: Ie7588e311fa5155d5ee73148dee3d0d931bfc7f5
Signed-off-by: Marc Schink <openocd-dev@marcschink.de>
Reviewed-on: http://openocd.zylin.com/3413
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>