Compare commits

..

98 Commits

Author SHA1 Message Date
Antonio Borneo
fcb40f49b1 The openocd-0.12.0-rc3 release candidate
Change-Id: Id7ddf232593e1aa7cb36f2b30fe832ebf79c1535
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-12-20 13:50:45 +03:00
Antonio Borneo
77c281d2df cortex_m: handle armv8m cores without security extension
Cores armv8m, e.g. Cortex-M33, can be instantiated without the
optional Security Extension.
In this case, the secure registers are not present and when GDB
try accessing them it triggers a set of errors.

For armv8m cores without security extension, don't provide to GDB
the description of the secure registers.

Change-Id: I254478a4cf883e85b786df3f62c726b2f40d88d9
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reported-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7402
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2022-12-18 21:52:41 +00:00
Antonio Borneo
c913e4d5a6 jtag: fix build with configure --enable-verbose
With flag --enable-verbose, configure enables compiling some
conditional code that with new gcc triggers an error:
	error: '%04x' directive output may be truncated writing
	between 4 and 8 bytes into a region of size 5
	[-Werror=format-truncation=]

Extend the buffer to contain the full 8 bytes of %04x on a 'int'
and change the limit in snprintf.
Skip the intermediate buffer 's[4]'.
Align the code to the coding style.

Change-Id: Ifc8a6e4686555578a7355a1f6049471fd5e31913
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reported-by: Karl Hammar <karl@aspodata.se>
Reported-by: Tommy Murphy <tommy_murphy@hotmail.com>
Fixes: https://sourceforge.net/p/openocd/tickets/376/
Reviewed-on: https://review.openocd.org/c/openocd/+/7403
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2022-12-18 21:50:17 +00:00
Dan Stahlke
77c7abe4e7 at91samd: wait for nvm ready
Flashing a SAMD21J17D was failing during NVM erase.  The samd21
datasheet specifies that one cause of error conditions is executing an
NVM command while the previous command is still running.  The solution
is to wait for INTFLAG.READY after a command is issued.

SAMD21J17A was not exhibiting this problem.  Perhaps the later silicon
revision has slower NVM erase times.

Signed-off-by: Dan Stahlke <dan@stahlke.org>
Change-Id: I19745dae4d3fc6e3a7611dcac628e067cb41e0f0
Reviewed-on: https://review.openocd.org/c/openocd/+/7391
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2022-12-17 09:33:40 +00:00
Antonio Borneo
0a829efda5 driver: vdebug: fix mode of cmd 'vdebug mem_path'
The command 'vdebug mem_path' is reported in the documentation as
'{Config Command}', but the code sets mode = COMMAND_ANY.
The code of the commands sets some value that is only used during
the init phase, so the documentation is correct.

Change mode of command 'vdebug mem_path' to COMMAND_CONFIG.

Change-Id: Icb940fe382cbc75015273b35dcc8a88fc2a7d0ac
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7395
Tested-by: jenkins
Reviewed-by: Jacek Wuwer <jacekmw8@gmail.com>
2022-12-17 09:33:06 +00:00
Antonio Borneo
2b6fe8f1ab target: fix assert in 'monitor profile' on constant PC
When target is stopped in WFI/WFE or is in an infinite loop, the
sampled PC will always return the same value.
Command 'profile' requires that distance between min and max PC
should be at least 2, which is not the case for constant PC, and
incorrectly enforces the check through as assert().

Move the code that reads the optional parameters 'start' and 'end'
and check the gap 'end - start' before running the profile.
For self-computed min and max, increase max (or decrease min) to
match the required constraint.
Drop the assert().

Change-Id: I2be8df8568ce8c889923888c492e4f7ce354b16b
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Fixes: https://sourceforge.net/p/openocd/tickets/370/
Reviewed-on: https://review.openocd.org/c/openocd/+/7400
Tested-by: jenkins
2022-12-17 09:32:34 +00:00
Antonio Borneo
a51ac964c6 target: fix unsigned computation in 'monitor profile'
The implementation of command 'monitor profile' has few
issues:
- the address_space is a signed int, so cannot wrap-around on
  space over INT_MAX;
- max address is incremented without check for overflow;
- assert() used on errors instead of returning error codes;
- only handles 32 bits PC;
- output file created and left empty on error.

This patch fixes the first two issues, as a wider fix would be too
invasive and should be postponed in a following series.

Change-Id: Id8ead3f6db0fd5730682a0d1638f11836d06a632
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Fixes: https://sourceforge.net/p/openocd/tickets/370/
Reviewed-on: https://review.openocd.org/c/openocd/+/7394
Tested-by: jenkins
2022-12-17 09:32:09 +00:00
Antonio Borneo
a6b0221952 target: cortex_a: fix clang error core.CallAndMessage
Clang complains about the variable 'orig_dfsr' that can be used
uninitialized both in cortex_a_read_cpu_memory() and in
cortex_a_write_cpu_memory().

The issue is caused by an incorrect error path that used to jump
through 'goto out'. The code after the label 'out' is specific to
handle the case of an error during memory R/W; it is incorrect to
jump there to handle an error during the initialization that
precedes the memory R/W.

Replace the 'goto out' with 'return retval'.
Remove the label 'out' that is now unused.

Change-Id: Ib4b140221d1c1b63419de109579bde8b63fc2e8c
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7393
Tested-by: jenkins
2022-12-17 09:31:29 +00:00
Antonio Borneo
c6fe10de75 arm_adi_v5: fix SIGSEGV due to failing re-examine
Commit 35a503b08d ("arm_adi_v5: add ap refcount and add get/put
around ap use") modifies the examine functions of mem_ap, cortex_m,
cortex_a and aarch64 by calling dap_put_ap() and then looking again
for the mem-ap and calling dap_get_ap().
This causes an issue if the system is irresponsive and the examine
fails and left the AP pointer to NULL. If the system was already
examined the NULL pointer will cause a SIGSEGV.

Commit b6dad912b8 ("target/cortex_m: prevent segmentation fault
in cortex_m_poll()") proposes a fix for one specific case and only
on cortex_m.

Modify all the examine functions by skipping look-up for the AP if
it was already set in a previous examine; the target's AP is not
supposed to change during runtime.

Remove the partial fix for cortex_m as it is not needed anymore.

Change-Id: I806ec3b1b02fcc76e141c8dd3a65044febbf0a8c
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Fixes: 35a503b08d ("arm_adi_v5: add ap refcount and add get/put around ap use")
Reviewed-on: https://review.openocd.org/c/openocd/+/7392
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2022-12-17 09:30:45 +00:00
Nima Palizban
2278878a05 src/target/mips_m4k.c: set missing flag in set_watchpoint
Without the fix, will see "Can not find free FP Comparator" error log

Change-Id: Id0d91cc02b7055e44d27507f9c05ccd48ff49838
Signed-off-by: Nima Palizban <n.palizban@gmail.com>
Fixes: fb43f1ff4e (target: Rework 'set' variable of break-/watchpoints)
Reviewed-on: https://review.openocd.org/c/openocd/+/7389
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-12-17 09:29:32 +00:00
Karl Palsson
9501b263e0 doc: describe tcl port consistently.
One place described the tcl port as 5555, which was changed in 163bd86071
Reported on IRC.

Change-Id: If740a29443793d6a4d4f8c9db54f0fc8344a6c1c
Signed-off-by: Karl Palsson <karlp@tweak.net.au>
Reviewed-on: https://review.openocd.org/c/openocd/+/7385
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-12-03 09:27:27 +00:00
Evgeniy Naydanov
04887d3b68 Fix jim_target_smp for smp rtos target
If multiple targets are specified as -rtos <rtos_type>, the
rtos_update_threads was called only if the last target was specified as
rtos, which is inconsistent with other checks of whether or not smp target
is an rtos one.

Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
Change-Id: Ie52bc6b6c8f841d31b9590fcbc44e985d3cba0eb
Reviewed-on: https://review.openocd.org/c/openocd/+/7244
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-12-03 09:27:00 +00:00
Koudai Iwahori
4fe3997294 hwthread: Restore current_threadid in hwthread_update_threads
When OpenOCD receives a step-execution command from GDB and the target
is configured as rtos=hwthread, OpenOCD reconstructs the thread-info.
However, OpenOCD does not restore the thread id which is currently
selected by GDB. Due to this issue, OpenOCD sends the information of
wrong thread to GDB after the step execution.
This commit fixes the above issue by adding a code to save/restore the
thread id selected by GDB.

Signed-off-by: Koudai Iwahori <koudai@google.com>
Change-Id: I761a1141c04d48f1290e4f09baa7c7024f86f36a
Reviewed-on: https://review.openocd.org/c/openocd/+/7358
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-12-03 09:26:29 +00:00
Koudai Iwahori
a9d7428535 hwthread: Add register validity check in get_thread_reg_list
When OpenOCD receives 'g' packet (read general registers) from GDB and
target is configured as rtos=hwthread, hwthread_get_thread_reg_list is
called. However, it does not check if the register valid or not. Due to
this issue, OpenOCD returns invalid register values to GDB.
This commit adds a validity check to hwthread_get_thread_reg_list. If
the register is not valid, it tries to read the register from the
target.

Signed-off-by: Koudai Iwahori <koudai@google.com>
Change-Id: Iad6424b62124271ec411b1dfc044b57dfc460280
Reviewed-on: https://review.openocd.org/c/openocd/+/7357
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-12-03 09:26:04 +00:00
Antonio Borneo
3ea1bfce4f jtag: xds110: fix clang error core.StackAddressEscape
Clang ignores that xds110_swd_write_reg() is always called with
bit SWD_CMD_RNW in 'cmd' set to zero.
It then complains that the local variable 'value' gets passed by
address to xds110_swd_queue_cmd() and in case of 'read request'
such stack address get stored for later use:
	src/jtag/drivers/xds110.c:1363:1: warning: Address of
	 stack memory associated with local variable 'value' is
	 still referred to by the global variable 'xds110' upon
	 returning to the caller. This will be a dangling
	 reference [core.StackAddressEscape]

To both xds110_swd_write_reg() and xds110_swd_read_reg(), add an
assert() to inform Clang about the state of bit SWD_CMD_RNW.

Change-Id: I7687c055ec71424b642e152f478723a930966e3a
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7380
Tested-by: jenkins
2022-12-03 09:25:27 +00:00
Antonio Borneo
0f034868f2 flash: lpc2900: fix clang error 'dead assignment'
The variable retval is assigned a value that is never used.
Scan-build reports:
	Although the value stored to 'retval' is used in the
	enclosing expression, the value is never actually read
	from 'retval'.

Drop the dead assignment.

Change-Id: I11588dee748a55d52aa7f35bc1967b7df55af7fc
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7379
Tested-by: jenkins
2022-12-03 09:24:59 +00:00
Marc Schink
6ea1ccf3e6 flash/nor/stm32lx: Add revision '1, X' for Cat.2 devices
Change-Id: I0ff1e2102175ee952b066b325c9acbcb598b3af7
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/7378
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-11-28 22:23:47 +00:00
Rocco Marco Guglielmi
5193f61cf5 tcl: max326xx: fix target scripts for latest version of OpenOCD
Change-Id: Iec5aba3a082f2e25f21d7ca173ed710894b370a4

Signed-off-by: Rocco Marco Guglielmi <roccomarco.guglielmi@gmail.com>
Change-Id: Ia83850e326661c8acb0712a280fdf961258322a4
Reviewed-on: https://review.openocd.org/c/openocd/+/7373
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-11-28 22:23:30 +00:00
Nick Kraus
e345cefabd jtag/drivers/cmsis_dap.c: Fix Length of SWO Baudrate Command
The command should now send the full 5 byte command length, which
includes the command tag (0x19) and the 4-byte baudrate word, instead
of only the last 3 bytes of the baudrate.

Signed-off-by: Nick Kraus <nick@nckraus.com>
Change-Id: Idd6e084efd7492489aa900cdbf08f540944041cb
Reviewed-on: https://review.openocd.org/c/openocd/+/7370
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-11-28 22:23:03 +00:00
Tomas Vanek
9d925776b4 target/armv7m: fix feature name of ARMv8M security extension regs
gdb requires this feature to enable stack unwinding of secure/nonsecure
interstate calls and exceptions on an ARMv8M target with
the security extension.

Tested on STM32L5 (Cortex-M33).

Change-Id: Ib09780c011afbc095b352074068597559ad14fcd
Link: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=ae7e2f45aa4798be449f282bbf75ad41e73f055e
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/7265
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-11-15 21:39:19 +00:00
Giulio Fieramosca
2e9f04c11a rtos/ThreadX: added check for NULL-named tasks
Thread name loading was not correctly handled if a ThreadX task has a NULL
name.

Signed-off-by: Giulio Fieramosca <giulio@glgprograms.it>
Change-Id: I03071930182bc2585b61ce5d8c67491710883dd6
Reviewed-on: https://review.openocd.org/c/openocd/+/7328
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-11-15 21:35:12 +00:00
Andreas Bolsch
2bad55bf83 Fix for segfault and some clang reported problems in stmqspi
Change-Id: Id003adb574085cdd603cc13aeb6f2efec73593f1
Signed-off-by: Andreas Bolsch <hyphen0break@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7345
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-11-15 21:34:40 +00:00
Antonio Borneo
1762aa04ce jep106: update to revision JEP106BF.01 Oct 2022
Change-Id: Ia1f19dcce48da997c036ccffa65e76e179de2eb9
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7341
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2022-11-15 21:34:22 +00:00
Simon Smiganovski
0d055602c3 flash/nor/stm32f1x: adjust size of the flash loader buffer
target_run_flash_async_algorithm expects the source_buffer to have
at least 2 words reserved for read and write pointers in addition to the
FIFO buffer. If the size of the data to be flashed is <= 8 bytes then
the flash function will fail with "corrupted fifo read pointer" error.

Ensure the allocated buffer is big enough to hold both FIFO buffer and
read/write pointers.

Change-Id: I09c22eaac517b8cfea8e0b463f5deb6b98afd267
Signed-off-by: Simon Smiganovski <simon.smiganovski@fruitcore.de>
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7342
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-11-15 21:33:53 +00:00
Tomas Vanek
6939187853 target/armv7m: prevent saving and restoring non existent regs
armv7m_start_algorithm() saves register values to arch_info->context.
armv7m_wait_algorithm() restores register values from arch_info->context.
Exclude registers with flag exist = false from both loops.

While on it refactor the register restore: introduce 'struct reg' pointer
and dereference it instead of numerous accesses by a full path
from armv7m pointer.

Change-Id: I1600084db84809ee13bcf8e7828b79f8c9ff9077
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/7276
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-11-15 21:30:07 +00:00
Tomas Vanek
1d04ef3e55 tcl/interface: fix raspberrypi2-native.cfg speed coefficient
The speed coefficient for Raspberry Pi 2 was probably calibrated
for a scaled down clock frequency.

To prevent JTAG/SWD overclocking, use the value corresponding
to the 'official' maximum CPU clock.

Change-Id: Iaff58b092198dce6d6552c9d31d6a3ba4aaaa2d5
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/7305
Tested-by: jenkins
Reviewed-by: Jonathan Bell <jonathan@raspberrypi.com>
2022-11-15 09:54:06 +00:00
George Voicu
4e077fddad tcl/cpld/xilinx-xcu: fix typo
Fix typo in comments

Signed-off-by: George Voicu <razvanvg@hotmail.com>
Change-Id: Icc2d770e73f896e20dd347de324328030544bdb9
Reviewed-on: https://review.openocd.org/c/openocd/+/7333
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-11-11 20:24:16 +00:00
Daniel Anselmi
d3e79c1eaf pld/virtex2: small doc extension
Change-Id: I174cd702388be04268b38178fbfacb90db452f72
Signed-off-by: Daniel Anselmi <danselmi@gmx.ch>
Reviewed-on: https://review.openocd.org/c/openocd/+/7303
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-11-11 20:23:49 +00:00
Antonio Borneo
fb23c9c10b rtos: hwthread: fix clang error core.NullDereference
Clang spots a potential NULL pointer dereferencing that is instead
an incorrect use of an array of pointers:

	src/rtos/hwthread.c:254:32: warning: Dereference of null pointer
	  [core.NullDereference]
		(*rtos_reg_list)[j].number = (*reg_list)[i].number;
		                             ^~~~~~~~~~~~~~~~~~~~~
The error has not been spotted before because:
- this function is not called for the first core of the SMP node,
- for the other cores on Cortex-A it still returns valid register
  value for the first 12 ARM registers, then it diverges.

Also Valgrind does not spot any issue at runtime.

Address the array correctly.

While there, use DIV_ROUND_UP() macro for the computation.

Change-Id: Ib87e60e0edfd9671091f5dcfa9aedaf1aed800d1
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7337
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2022-11-11 20:23:13 +00:00
Tomas Vanek
09731b69a6 Revert "Remove duplicate of a counter in hwthread_update_threads"
Commit 0cedf10f8f ("Remove duplicate of a counter in
hwthread_update_threads") introduced a code bug.

In the second foreach_smp_target() loop, variable "threads_found"
gets passed to routine hwthread_fill_thread(). By removing the
counting of threads_found from the second loop, the
incorrect thread counter value gets passed to hwthread_fill_thread().

Change-Id: Ie89e53ccd28bb72b6838ef2f12106a1fe8d00994
Suggested-by: Daniel Goehring <dgoehrin@os.amperecomputing.com>
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/7307
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-11-11 20:22:53 +00:00
Tomas Vanek
3da0c2504c jtag/drivers/cmsis_dap: prevent CDC missdetect as CMSIS-DAP bulk
The autodetection of CMSIS-DAP v2 bulk interface is tricky
as not all adapters conform CMSIS-DAP specs.

If an interface has a string descriptor containing CMSIS-DAP,
then OpenOCD did not insisted on the correct interface class
LIBUSB_CLASS_VENDOR_SPEC.

However the relaxed test caused false autodetection of v2 bulk
interface on some CMSIS-DAP v1 adapters with an additional serial
interface with the string descriptor stupidly containing
CMSIS-DAP text.

Make the test less relaxed, refuse autodetection of the interfaces
with the class number of well known functions including CDC and MSC.

Link: https://sourceforge.net/p/openocd/tickets/368/
Change-Id: I917cb257eb42aab93560cc39c61ec35a60ce52e3
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/7279
Tested-by: jenkins
Reviewed-by: SilverFox <yyjdelete@126.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-11-11 20:22:25 +00:00
Antonio Borneo
1dea9ab41f flash: stmqspi: fix clang error 'dead assignment'
The variable retval is assigned a value that is never used, as it
is reassigned few lines below.

Drop the dead assignment.

Change-Id: Id4e9134408fab3e04936d36e95724bf8d3ab55aa
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7304
Tested-by: jenkins
2022-11-11 20:12:48 +00:00
Antonio Borneo
5fc4882b80 dsp5680xx: fix clang error core.UndefinedBinaryOperatorResult
Clang get confused by initializing the array uint16_t lock_word[],
casting it to (uint8_t *), then accessing the second element of
the uint8_t pointer.

  src/target/dsp5680xx.c:2046:41: warning: The left operand of '<<'
    is a garbage value [core.UndefinedBinaryOperatorResult]
        uint16_t tmp = (buffer[0] | (buffer[1] << 8));
                                     ~~~~~~~~~ ^
Fix it by replacing the array with a single uint16_t.

The code is still depending on host endianness; no fix for this is
proposed.

Change-Id: I16dfd60cab117dd145aeecf10d9593574ff233a2
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7302
Tested-by: jenkins
2022-11-11 20:11:22 +00:00
Antonio Borneo
0946e80407 esirisc_jtag: fix clang error core.VLASize
The function esirisc_jtag_recv() can be called with argument
num_in_fields = 0, for example as consequence of calling
esirisc_jtag_continue().
In this case, num_in_bytes is zero and the allocation of the
variable-length array 'r' requires size zero.

  src/target/esirisc_jtag.c:133:2: warning: Declared variable-length
    array (VLA) has zero size [core.VLASize]
        uint8_t r[num_in_bytes * 2];
        ^~~~~~~~~ ~~~~~~~~~~~~~~~~

Fix it by forcing size one when num_in_bytes is zero.

Change-Id: Id764c7b5ec4f5b3c18c7da650bbff39fc98ed049
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7301
Tested-by: jenkins
2022-11-11 20:11:03 +00:00
Antonio Borneo
7a09635735 openrisc: fix clang error core.CallAndMessage
Clang assumes that size could assume a value that is not 1 nor 2
nor 4. In such condition the buffer in t is allocated (size != 1)
and not initialized. This triggers an error:
  src/target/openrisc/or1k_du_adv.c:655:14: warning: 2nd function
    call argument is an uninitialized value [core.CallAndMessage]
                crc_calc = adbg_compute_crc(crc_calc, data[i], 8);
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Add the default case to cover other values of size.

After this fix, clang still complains on the same line, this time
misunderstanding the limits of the loop and considering that
buf_bswap16() only swaps the first 16 bits, thus passing not
initialized value data[2] to adbg_compute_crc()

Replace malloc() with calloc() to silent it.

Change-Id: I358d7fb2ebefd69255670641bd435b770762a301
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7300
Tested-by: jenkins
2022-11-11 20:10:41 +00:00
Antonio Borneo
aca3707bd8 helper/types: use unsigned type for all h_u64_to_le() and similar
All the converters functions:
	h_u64_to_le()
	h_u64_to_be()
	h_u32_to_le()
	h_u32_to_be()
	h_u24_to_le()
	h_u24_to_be()
	h_u16_to_le()
	h_u16_to_be()
have signed type in their prototype, while the function name and
all the current use cases pass an unsigned value.

Change the prototypes to use unsigned types.

Change-Id: I76dcfdd7912b81f60902184712b2907eae9843f7
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7299
Tested-by: jenkins
2022-11-11 20:10:05 +00:00
Ben McMorran
3ca7bc7354 ThreadX: set current_thread for kernel execution
If we just invented thread 1 to represent the current execution, we
need to make sure the RTOS object also claims it's the current thread
so that threadx_get_thread_reg_list() doesn't attempt to read a
thread control block at 0x00000001.

Signed-off-by: Ben McMorran <bemcmorr@microsoft.com>
Change-Id: I7f71e730d047858898297e4cb31db8e47e0c371c
Reviewed-on: https://review.openocd.org/c/openocd/+/7280
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-11-04 21:49:03 +00:00
Paul Fertser
12ce170945 Restore +dev suffix
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
2022-10-26 16:43:49 +03:00
Paul Fertser
62cdf7a1df The openocd-0.12.0-rc2 release candidate
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
2022-10-26 13:45:09 +03:00
Tomas Vanek
92169e9f55 tcl/target: add basic RP2040 target config
The existing rp2040-core0.cfg configuration file was intended
for a special adapter which selects a SWD multidrop target on its own.
This means that rp2040-core0.cfg is totally unusable with a standard SWD
adapter.

To fix the problem, mark rp2040-core0.cfg as deprecated and
add rp2040.cfg, a basic config file with multidrop target selection.

Change-Id: I5194e42f529a2d9645481424b7c66ab61efa44ee
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/7275
Tested-by: jenkins
Reviewed-by: Jonathan Bell <jonathan@raspberrypi.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-10-21 18:24:36 +00:00
Tarek BOCHKATI
fada2c001f doc: fix semihosting_redirect command documentation
Change-Id: I78c82a21e4160851a5c0b58394ac7897479808ff
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@st.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7278
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-10-21 18:22:53 +00:00
Tarek BOCHKATI
c4f88aeb4d tcl/stm32l5x|u5x: support HLA adapters in non-secure mode only
instrument "target/stm32x5x_common.cfg" used by both STM32L5x/U5x
to support HLA adapters like "interface/stlink.cfg" in non-secure mode

if the device switches to secure mode, the debug session will be
stopped immediately (with an explanatory message).

Change-Id: I645fdd55e3448ef82d0ddcc396f42fd7b2f39ac3
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reported-by: Patrik Bachan <diggit@users.sourceforge.net>
Fixes: https://sourceforge.net/p/openocd/tickets/317/
Reviewed-on: https://review.openocd.org/c/openocd/+/6546
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2022-10-21 18:19:41 +00:00
Erhan Kurubas
535de48ca6 target/xtensa: remove redundant call for TARGET_EVENT_HALTED
`xtensa_do_step` is invoked from `xtensa_prepare_resume` to silently
step over BP/WP before resuming.
For example; in the case of WPs (DEBUGCAUSE_DB), in the current
implementation `xtensa_do_step` will generate one more
`TARGET_EVENT_HALTED` after the original one caused by WP itself.

This patch moves the halted event cb call after
the step is done successfully.

Signed-off-by: Erhan Kurubas <erhan.kurubas@espressif.com>
Change-Id: I9048e14fb316dc124847a42cfaefb1f76b5ce53e
Reviewed-on: https://review.openocd.org/c/openocd/+/7274
Tested-by: jenkins
Reviewed-by: Ian Thompson <ianst@cadence.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-10-21 18:16:23 +00:00
Antonio Borneo
b8735bbf7e doc: fix riscv commands
- Fix the declaration of riscv command 'set_mem_access'.
- Remove non existing riscv command 'set_scratch_ram'.
- Add riscv commands 'info', 'reset_delays'; copy the description
  from the 'help' text.
- Don't add riscv commands 'set_prefer_sba' and 'test_sba_config_reg'
  as they are marked as deprecated.
- Ensure that 'test_sba_config_reg' prints a deprecation warning
  when used.

Change-Id: I39dc3aec4e7f13b69ac19685f1b593790acdde83
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Signed-off-by: Jan Matyas <matyas@codasip.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7268
Reviewed-by: Tim Newsome <tim@sifive.com>
Tested-by: jenkins
2022-10-21 18:14:46 +00:00
Antonio Borneo
1f7d58daee doc: remove unreferenced anchors
Remove the @anchor{} tags that are not referenced in the
documentation.

Change-Id: Ia8e9f75afb08e08ef99d0c8fd82115d689e4a267
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7270
Tested-by: jenkins
2022-10-21 18:07:49 +00:00
Antonio Borneo
28ad1a1454 doc: fix espusbjtag commands type
Exec commands should be reported as {Command}.

Change-Id: Iacb50d77b354617ecd24b0f1c2ec24e240179698
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7267
Tested-by: jenkins
Reviewed-by: Erhan Kurubas <erhan.kurubas@espressif.com>
2022-10-21 18:07:14 +00:00
Antonio Borneo
f0a9b66d13 doc: fix xtensa commands type
Config commands should be reported as {Config Command}

Change-Id: Ic778df31bb1dc9aefdbe3d8006b06bb370d25e6f
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7266
Tested-by: jenkins
Reviewed-by: Ian Thompson <ianst@cadence.com>
Reviewed-by: Erhan Kurubas <erhan.kurubas@espressif.com>
2022-10-21 18:06:52 +00:00
Jonathan Bell
ee87f2b4a9 jtag/drivers: bcm2835gpio: implement memory barriers when bitbashing
This GPIO driver is common to SoCs that have in-order ARM cores
(BCM2835) as well as superscalar (BCM2836-7) and speculative
out-of-order cores (BCM2711).

For BCM2837 and BCM2711, the processor can dual-issue stores and
is free to merge writes to peripheral memory for pages mapped
MT_NORMAL_NC, which is the default provided by /dev/[gpio]mem.

This can cause glitches (or missing edges) on GPIO pins when
toggled with no delay, as pipelined writes to the same address
can get arbitrarily squelched.

To prevent this happening, make sure the preceding write ops are
flushed outside the shareable domain by using a memory barrier.

Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
Change-Id: I8805cc0911667bcb9b7f4ca340d7f4f1cb25d096
Reviewed-on: https://review.openocd.org/c/openocd/+/7258
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-10-21 18:05:41 +00:00
Antonio Borneo
a7ea1ef0aa README: update build dependency list
Add info on what is optional,

Change-Id: Iedfa969243d95736aaf1b236caa2c2b33f563fe7
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7256
Tested-by: jenkins
2022-10-15 15:59:20 +00:00
Antonio Borneo
1c5c1d1782 README: cleanup requirements for pkg-config
FreeBSD fully supports pkg-config; the .pc files for the internal
libusb has been added with
	https://cgit.freebsd.org/src/commit/?id=041d3f3f09b8
and became part of FreeBSD 10.0 in 2014-01-16.

Remove the obsoleted requirements for adding .pc files.

While there, add pkgconf as an alternative to pkg-config.

Change-Id: I16aea735c44107cb71945f225a979682c8c92d0a
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7255
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
Tested-by: jenkins
2022-10-15 15:59:00 +00:00
Erhan Kurubas
3b8333bd3f target/xtensa: fill register number field in the cache
Currently 'number' field is zero in the register cache and
this causes an issue on `rtos get_thread_reg_list` calls.

Signed-off-by: Erhan Kurubas <erhan.kurubas@espressif.com>
Change-Id: Iaef11e01f55d012969bbc1933f82847d5e02fec5
Reviewed-on: https://review.openocd.org/c/openocd/+/7246
Tested-by: jenkins
Reviewed-by: Ian Thompson <ianst@cadence.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-10-15 15:58:44 +00:00
Erhan Kurubas
2d5d8a5a62 target/esp32s2: check xtensa_poll return value
Although scan build couldn't catch, return value overwritten
without checking.

Signed-off-by: Erhan Kurubas <erhan.kurubas@espressif.com>
Change-Id: I02b10002b03640604315047e8a8a639824724c16
Reviewed-on: https://review.openocd.org/c/openocd/+/7247
Tested-by: jenkins
Reviewed-by: Ian Thompson <ianst@cadence.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-10-15 15:57:57 +00:00
Erhan Kurubas
45c9e1e8c0 tcl/xtensa: some fixes at xtensa-core-esp32s3.cfg
Some config changes required to run ESP32-S3 with full feature set

Signed-off-by: Erhan Kurubas <erhan.kurubas@espressif.com>
Change-Id: I38022bb5ff5830e1cf9d11d6fe795ea99d91e9db
Reviewed-on: https://review.openocd.org/c/openocd/+/7254
Tested-by: jenkins
Reviewed-by: Ian Thompson <ianst@cadence.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-10-15 15:57:36 +00:00
Erhan Kurubas
48317d86d3 tcl/xtensa: some fixes at xtensa-core-esp32s2.cfg
Some config changes required to run ESP32-S2 with full feature set

Signed-off-by: Erhan Kurubas <erhan.kurubas@espressif.com>
Change-Id: Ie0a742442254ec6e95d4e05be40213b079a94dab
Reviewed-on: https://review.openocd.org/c/openocd/+/7253
Tested-by: jenkins
Reviewed-by: Ian Thompson <ianst@cadence.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-10-15 15:57:12 +00:00
Erhan Kurubas
46a61ea7ab tcl/xtensa: some fixes at xtensa-core-esp32.cfg
Some config changes required to run ESP32 with full feature set

Signed-off-by: Erhan Kurubas <erhan.kurubas@espressif.com>
Change-Id: I484324f8497ec7934bb73164c638fc5f6460fcc4
Reviewed-on: https://review.openocd.org/c/openocd/+/7252
Tested-by: jenkins
Reviewed-by: Ian Thompson <ianst@cadence.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-10-15 15:56:54 +00:00
Tomas Vanek
9d5f833fbd tcl/target: fix rp2040-core0.cfg work area backup.
The work area should be backed up.
The flash probe runs an algorithm on the target CPU.
The flash is probed during gdb connect if gdb_memory_map is enabled
(is enabled by default).
Without backup the target memory gets corrupted on gdb connect.

Change-Id: I3344b9dc6cbf904d49f3b05ab104b541d1d63422
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/7257
Tested-by: jenkins
Reviewed-by: Jonathan Bell <jonathan@raspberrypi.com>
2022-10-12 11:12:09 +00:00
Tomas Vanek
dc6cad855d target: re-examine before arp_waitstate in ocd_process_reset_inner
arp_waitstate will not work on not-examined state

Change-Id: I56c3e1c7e63af108e4ed1dbacebb567f9bf46264
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/7230
Tested-by: jenkins
Reviewed-by: Erwan Gouriou
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-10-08 08:53:51 +00:00
Tomas Vanek
1f84f34850 target/hla_target: try to re-examine under reset in hl_assert_reset()
An application often idling in real sleep mode may make a Cortex-M target
hard to access as CPU clock are gated and debug requests are responded
by WAIT ack.

Try to examine the target under reset as the last resort.

Change-Id: I7c3de39fb1e6c23b76e2a0a85ab75f23aac94c4d
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/7229
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-10-08 08:52:45 +00:00
Tomas Vanek
f65d1da013 target/cortex_m: try to re-examine under reset in cortex_m_assert_reset()
An application often idling in real sleep mode may make a Cortex-M target
hard to access as CPU clock are gated and debug requests are responded
by WAIT ack.

Try to examine the target under reset as the last resort.

Change-Id: Ife875a966a838c37dde987bc584ad0a1f4d020d6
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/7228
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-10-08 08:49:52 +00:00
Tomas Vanek
b991c416b7 target/cortex_m: make reset robust again
After merging [1] 'reset halt' does not work on not responding Cortex-M.

Relax the examined tests and try to set vector catch VC_CORERESET
if debug_ap is available.

While on it add an info about examination state to debug logs.

Fixes: [1] commit 98d9f1168c ("target: reset target examined flag if target::examine() fails")
Change-Id: Ie2e018610026180af5997d70231061a275f05c76
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/6745
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-10-08 08:46:12 +00:00
Antonio Borneo
978c115dac openocd: fix build with 'configure --without-capstone'
When configure option --without-capstone is used, the macro
HAVE_CAPSTONE is not defined in config.h, and the following lines
are instead present:
	/* 1 if you have Capstone disassembly framework. */
	/* #undef HAVE_CAPSTONE */

This cause compile error with message:
	arm_disassembler.h:190:5: error: "HAVE_CAPSTONE" is not
		defined, evaluates to 0 [-Werror=undef]
	  190 | #if HAVE_CAPSTONE
	      |     ^~~~~~~~~~~~~

This is caused by configure.ac that does not call AC_DEFINE when
--without-capstone option is present.

Fix configure.ac to always provide the autoconf macro
HAVE_CAPSTONE, with either value 0 or 1.

Change-Id: Ie5ac98b2c25746dd721812c91baaac61ec877ecd
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7224
Tested-by: jenkins
2022-10-08 07:59:44 +00:00
Daniel Goehring
a69b382efd target/adiv5: 64-bit TAR setup bugfix
For 64-bit TAR setup, if 'tar_valid == false' perform the upper 32-bit
write even if the cached copy matches the upper TAR value to be written.

Signed-off-by: Daniel Goehring <dgoehrin@os.amperecomputing.com>
Change-Id: I320377dc90a9d1d7b64cbb281b2527e56c7621ee
Reviewed-on: https://review.openocd.org/c/openocd/+/7245
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2022-10-08 07:55:35 +00:00
Nishanth Menon
8bf5482754 tcl/target/ti_k3: Handle swd vs jtag
Since all the device definition when accessing device from jtag is also
valid when accessing from swd, lets make sure the configuration can
handle the same.

Signed-off-by: Nishanth Menon <nm@ti.com>
Change-Id: I5af071137fd8c3b52cc4ef72401f8eba952f9cad
Reviewed-on: https://review.openocd.org/c/openocd/+/7090
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-10-08 07:55:08 +00:00
Daniel Anselmi
d6ae732f6e fix leaky file-handle in virtex2 driver
Change-Id: I2784a66c42be71f2982dff7746f9fb2eb1dc8ca6
Signed-off-by: Daniel Anselmi <danselmi@gmx.ch>
Reviewed-on: https://review.openocd.org/c/openocd/+/7243
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-10-08 07:54:49 +00:00
Daniel Anselmi
d983114855 don't return ERROR_OK in error cases
Change-Id: I7e046df85838692c9044fe9c9d67e8b2c821eb0f
Signed-off-by: Daniel Anselmi <danselmi@gmx.ch>
Reviewed-on: https://review.openocd.org/c/openocd/+/7236
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2022-10-08 07:54:39 +00:00
Daniel Anselmi
0a7e172420 fix memory leak in virtex2 driver
Change-Id: Ia08f7aaad25631132885acd5898477c1106f0ec4
Signed-off-by: Daniel Anselmi <danselmi@gmx.ch>
Reviewed-on: https://review.openocd.org/c/openocd/+/7235
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-10-08 07:54:02 +00:00
Erhan Kurubas
cff2cf373f target/xtensa: pass correct buffer on read memory retry
Read values must be at albuff so that can be copied to buffer
on function exit.

Signed-off-by: Erhan Kurubas <erhan.kurubas@espressif.com>
Change-Id: I74a533e8f12f1002ca06a98a7c7cd928552b4cc5
Reviewed-on: https://review.openocd.org/c/openocd/+/7226
Tested-by: jenkins
Reviewed-by: Ian Thompson <ianst@cadence.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-10-08 07:53:12 +00:00
Erhan Kurubas
10b08d5ac5 target/xtensa: rename pc and ps macro names
Actually they are the base of epc and eps

Signed-off-by: Erhan Kurubas <erhan.kurubas@espressif.com>
Change-Id: I4f43b9609a9929399fb5d3fa0203efc8a98e94c9
Reviewed-on: https://review.openocd.org/c/openocd/+/7227
Tested-by: jenkins
Reviewed-by: Ian Thompson <ianst@cadence.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-10-08 07:52:49 +00:00
Keith Packard
af75d70dc5 flash/nor/at91samd: Use 32-bit register writes for ST-Link compat
ST-Link v2 dongles can be used with many cortex-m parts, but they have
one limitation -- they can only perform 8-bit and 32-bit writes to the
target. 16-bit writes are done using a pair of 8-bit writes. While not
usually an issue, in the case of the at91samd flash driver, the 16-bit
'command' register must have both halves written in the same
operation.

Fortunately, this register has two pad bytes above it in the address
space, making it safe to always access with 32-bit operations.

Change-Id: I44b0db9406982a8db5818c0533d3101618741db2
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7234
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-10-08 07:52:28 +00:00
Evgeniy Naydanov
0cedf10f8f Remove duplicate of a counter in hwthread_update_threads
There is no need to count number of examined threads twice.

Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
Change-Id: Id32ead853d1ddcd4e67062d6f795700feb20cb4b
Reviewed-on: https://review.openocd.org/c/openocd/+/7223
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2022-10-08 07:52:12 +00:00
Tomas Vanek
759d581fde jtag/drivers/bitbang: reduce debug verbosity
The bitbang driver floods the log by many messages with very
little informational value.

Remove some LOG_DEBUGs, convert some others to LOG_DEBUG_IO.

Change-Id: I0c7539467b45543e12932c67dc71e86d58c8c6cd
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/7220
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Jonathan Bell <jonathan@raspberrypi.com>
Tested-by: jenkins
2022-10-08 07:51:46 +00:00
Tomas Vanek
1d77fc74e1 jtag/drivers/cmsis_dap: add LOG_DEBUG_IO to cmsis_dap_metacmd_targetsel
Make write to DP_TARGETSEL is logged the similar way as other DP register
read/writes.

While on it fix checkpatch message
'Concatenated strings should use spaces between elements'

Change-Id: I98f724c984e8c4610cc461340f4c4a7cc9627ed9
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/7219
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Jonathan Bell <jonathan@raspberrypi.com>
Tested-by: jenkins
2022-10-08 07:48:19 +00:00
Tomas Vanek
48507e3b10 target/armv7m: show target name in 'halted' message
Change-Id: I13e9a33677632d52122585203252fc4ef0c52a2a
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/7237
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-10-08 07:47:09 +00:00
Tomas Vanek
bced97cce9 target/armv7m: prevent storing invalid register
armv7m_start_algorithm() stored all non-debug execution
registers from register cache without checking validity.

Check if the register cache is valid.
Try to read from CPU if not valid.
Issue a warning if register read fails.

Change-Id: I365f86d65243230cf521b13909575e5986a87a50
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/7240
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Jonathan Bell <jonathan@raspberrypi.com>
2022-10-08 07:46:16 +00:00
Tomas Vanek
dce9a03cb2 flash/nor/rp2040: fix setting sp
The num_reg_params parameter of target_run_algorithm() was not
updated when setting "sp" was introduced. Therefore "sp" as the last
register parameter was not passed to a target algo.

Introduce a new helper variable with correct count of register parameters
and use it everywhere needed.

Change-Id: I934a71380783d98917167f1569145808ef23540f
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/7225
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Jonathan Bell <jonathan@raspberrypi.com>
2022-10-08 07:45:18 +00:00
Tomas Vanek
ae937791d3 flash/nor/rp2040: remove new line from error message
Change-Id: Idf3bce842b4507c1f12692b5fbcd6730637de9db
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/7216
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Jonathan Bell <jonathan@raspberrypi.com>
Tested-by: jenkins
2022-09-27 08:49:08 +00:00
Tomas Vanek
3fdd3249b5 flash/nor/rp2040: use LOG_TARGET_xxx to show core name
Change-Id: Ic76e1c6306ece18b3590beaad4d5b224d4449aa0
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/7188
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2022-09-27 08:48:52 +00:00
Tomas Vanek
931b357466 flash/nor/rp2040: check target halted before flash operation
Flash read_id/erase/write operation on running target failed
in target_run_algorithm() anyway. It generated lot of error messages.

Check the target state and bail out early if target is running.

Change-Id: I903f5f38c8e61016e5002b235e5f07803bd2ec4e
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/7215
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Jonathan Bell <jonathan@raspberrypi.com>
2022-09-27 08:47:52 +00:00
Tomas Vanek
53611d8055 flash/nor/rp2040: fix flash erase timeout
SPI flash erase often takes longer than the fixed timeout 3 seconds.

Introduce a configurable timeout_ms parameter to rp2040_call_rom_func().
Compute the erase timeout from the number of blocks to be erased.

While on it make the timeouts shorter for connect flash, flush cache and
enter/exit xip (1 second is enough).

Change-Id: I552bfa317ee17064de3a54ec2f0c63e84ba87222
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/7214
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Jonathan Bell <jonathan@raspberrypi.com>
2022-09-27 08:41:54 +00:00
Tomas Vanek
84d73d0225 flash/nor/rp2040: fix size of flash write buffer
The size of the flash write buffer should be rounded
down to the multiply of flash page size.
Using write chunks of unadjusted size results in write of chunks
unaligned to flash pages.

Change-Id: If7931362ee193dff4dc2df7ec78f13530658cf08
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/7187
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-09-27 08:39:58 +00:00
Tomas Vanek
47ed1c1eab flash/nor/rp2040: fix memory leak of target stack workarea
While on it restore memory-mapped mode also after flash erase
(originally was restored after flash write only).

Change-Id: I5e153b79ac27a8439f57239ce90ce8a79c0bb8a1
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/7186
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-09-27 08:38:57 +00:00
Tomas Vanek
d25f0ae263 flash/nor/rp2040: preparatory refactoring
Prepend stack_grab_and_prep() function name by rp2040_ prefix.

Introduce target helper variable in rp2040_stack_grab_and_prep()
and use it instead of dereferencing bank->target several times.

Move flash ID reading code to the new rp2040_spi_read_flash_id()
function.

Change-Id: I9d6e51e17e36e6230155a586065499f2f260089a
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/7185
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-09-27 08:33:05 +00:00
Tomas Vanek
5f14140953 target/adi_v5_swd: suppress reconnect in swd_multidrop_select()
swd_multidrop_select() uses its own retry loop.
If select fails, do_reconnect flag remains set on exit and causes
useless reconnect.

Clear do_reconnect flag in retry loop.

Change-Id: Ie06d6967d7f4a977774c8530bb8d4b3e5ab4f62c
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/7217
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Jonathan Bell <jonathan@raspberrypi.com>
Tested-by: jenkins
2022-09-27 08:29:00 +00:00
Tomas Vanek
b2f6b23117 target/adi_v5_swd: fix SWD multidrop
Implementation of ADI v6 introduced banking of DP reg 0.
The accompanying change preventing DP SELECT write before
DP IDR read during connect was added to swd_connect_single() only.
Unchanged swd_connect_multidrop() / swd_multidrop_select_inner()
was broken as it emited DP SELECT and put DP to protocol error state.

Copy dap->select handling to swd_multidrop_select_inner().

Fixes: 72fb88613f (adiv6: add low level swd transport)

Change-Id: I514cd6d9ae2ba97ce3657b459df22638c278a0b1
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/7213
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Jonathan Bell <jonathan@raspberrypi.com>
2022-09-27 08:28:44 +00:00
Tomas Vanek
60abbda8bc target/stm32l5x,stm32u5x: fix trace settings
The STM32L5 and U5 devices have DBGMCU_CR trace related bits changed
wrt other STM32 devices.
Fix the setting in configuration script.

Change-Id: I0bbc48e7b1290b603c6966cf5ddd42df389e6ede
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/7117
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-09-23 21:27:34 +00:00
Daniel Goehring
1293ddd657 target/target: read_memory 64-bit bugfix
Increase "value_buf" size so it can hold a 64-bit number represented
as a string. Previous size could only hold a 32-bit number string.

Signed-off-by: Daniel Goehring <dgoehrin@os.amperecomputing.com>
Change-Id: If6fbc875236e6ddc59522fbc25db0129eb60ee27
Reviewed-on: https://review.openocd.org/c/openocd/+/7221
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-09-23 21:26:44 +00:00
Ian Thompson
53d17e7901 target/xtensa: fix final clang analyzer warning
Reworked xtensa_read_memory() logic to always allocate
and initialize working buffer with sufficient padding.

Signed-off-by: Ian Thompson <ianst@cadence.com>
Change-Id: Ia9ab53336537adebf99f8156f481ca8279a7cd5d
Reviewed-on: https://review.openocd.org/c/openocd/+/7211
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Erhan Kurubas <erhan.kurubas@espressif.com>
2022-09-23 21:25:34 +00:00
Antonio Borneo
44ed26a1db target/riscv: fix use of uninitialized value
Scan-build reports:
	Logic error: Uninitialized argument value
	riscv.c:2688 2nd function call argument is an uninitialized value

This is a real error cause by running the command "riscv
authdata_write" without arguments. In such case 'value' is not
initialized and is passed to and used by r->authdata_write().

Reorganize the code to:
- detect the correct amount or command's arguments;
- drop the LOG_ERROR() on ERROR_COMMAND_SYNTAX_ERROR;
- drop the 'else' after 'return'.

Change-Id: I62e031220593b8308bc674b753e15d16d4c5c9ac
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7210
Tested-by: jenkins
Reviewed-by: Jan Matyas <matyas@codasip.com>
Reviewed-by: Tim Newsome <tim@sifive.com>
2022-09-23 21:25:08 +00:00
Antonio Borneo
fd2a44ab55 target/riscv: fix undefined operation
Scan-build reports:
	Logic error: Result of operation is garbage or undefined
	riscv.c:1614 The result of the left shift is undefined due
		to shifting by '4294967281', which is greater or
		equal to the width of type 'target_addr_t'

This is a false warning due to clang that considers the impossible
case of 32 bits hart (xlen = 32) in SATP_MODE_SV48 mode
(info->va_bits = 48).
Under such case:
	riscv.c:1614 ... ((target_addr_t)1 << (xlen - (info->va_bits - 1))) ...
the shift amount wraps around the unsigned type and assumes the
value 4294967281 (0xfffffff1).

Use assert() to prevent clang from complaining.

Change-Id: I08fdd2a806c350d061641e28cf15a51b397db099
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7209
Reviewed-by: Tim Newsome <tim@sifive.com>
Reviewed-by: Jan Matyas <matyas@codasip.com>
Tested-by: jenkins
2022-09-23 21:24:49 +00:00
Antonio Borneo
aff48a6a31 target/riscv: fix dead assignment
Scan-build reports:
	Unused code: Dead nested assignment
	riscv.c:459 Although the value stored to 'ir_user4_raw' is
		used in the enclosing expression, the value is
		never actually read from 'ir_user4_raw'

This is caused by the value reassigned in 'ir_user4_raw':
	riscv.c:459 ir_user4[3] = (uint8_t)(ir_user4_raw >>= 8);
but never used.

Drop the DIY conversion in favor of h_u32_to_le() that does not
reassign the input value.

Change-Id: Ifad29f4c46d4a2d0a2f5a5c4104d768cc3db2794
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7208
Reviewed-by: Tim Newsome <tim@sifive.com>
Reviewed-by: Jan Matyas <matyas@codasip.com>
Tested-by: jenkins
2022-09-23 21:24:41 +00:00
Antonio Borneo
ea9089944e target/riscv: fix unused initialization
Scan-build reports:
	Unused code: Dead assignment
	riscv.c:716 Value stored to 'result' is never read

Remove the initialization of variable 'result'.

Change-Id: Ied67bb4fcfa5bace186522074247ead43a5d5cd5
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7207
Reviewed-by: Tim Newsome <tim@sifive.com>
Reviewed-by: Jan Matyas <matyas@codasip.com>
Tested-by: jenkins
2022-09-23 21:24:34 +00:00
Antonio Borneo
aa57890554 target/riscv-013: fix unused initialization
Scan-build reports:
	Unused code: Dead initialization
	riscv-013.c:2362 Value stored to 'control' during its
		initialization is never read

Remove the initialization of variable 'control'.

Change-Id: I548f8175530b9a2aa4c1788549d6467bf9824584
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7206
Reviewed-by: Tim Newsome <tim@sifive.com>
Reviewed-by: Jan Matyas <matyas@codasip.com>
Tested-by: jenkins
2022-09-23 21:22:42 +00:00
Antonio Borneo
8db6dff333 target/riscv-013: fix unchecked return code
Scan-build complains about variable 'sbcs_orig' that can be used
not initialized.
	Logic error: Assigned value is garbage or undefined
	riscv-013.c:4468 Assigned value is garbage or undefined
This is caused by not checking the return value of the call
	riscv-013.c:4466 dmi_read(target, &sbcs_orig, DM_SBCS);
In fact when dmi_read() returns error, the variable 'sbcs_orig' is
not assigned.

Check the returned value.

Change-Id: Ia9032a0229aa243138f95f4e13f765726a4ceae9
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7205
Reviewed-by: Tim Newsome <tim@sifive.com>
Reviewed-by: Jan Matyas <matyas@codasip.com>
Tested-by: jenkins
2022-09-23 21:22:31 +00:00
Antonio Borneo
8683526af7 target/dsp563xx: fix scan-build warning
Scan-build triggers a warning:
	Unix API: Allocator sizeof operand mismatch
	dsp563xx.c:2143 Result of 'calloc' is converted to a pointer
		of type 'uint8_t', which is incompatible with sizeof
		 operand type 'uint32_t'

It's a false positive because calloc() is properly used in this
case, as the uint8_t array is used in blocks of 4 elements to read
or write uint32_t values.

Either
	calloc(sizeof(uint32_t), count);
and
	malloc(count * sizeof(uint32_t));
keep triggering the same warning.

Drop the warning by using the constant '4' as size of uint32_t, as
already used few lines below.

Change-Id: I5bb1ece177774eefdc5d9cd049338f8f2be87cd7
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7203
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2022-09-23 21:22:09 +00:00
Antonio Borneo
cde944fd8b jtag/adapter: fix doxygen warning
Doxygen complains about:
	adapter.h:120: warning: Unsupported xml/html tag <signal_name> found

Move the text in double quote to remove the warning.

Change-Id: Ia4ead5caa83c84e10ee2b2359048c282892170b0
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Fixes: 82fd400542 ("jtag/adapter: Add command 'adapter gpio'")
Reviewed-on: https://review.openocd.org/c/openocd/+/7202
Tested-by: jenkins
2022-09-23 21:20:41 +00:00
Antonio Borneo
eb3d5c1a94 doc: fix copyright dates
The copyright date for OpenOCD project has never been updated.

Add the range till current year.

Change-Id: I42c7e3b2bf2e3a486bf836d063460dfa7b40d24d
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7201
Tested-by: jenkins
2022-09-23 21:20:24 +00:00
Antonio Borneo
bb8d37ddf1 checkpatch: fix for flag --no-tree
When checkpatch is run with command line flag --no-tree, it cannot
find local 'companion' files and has to skip loading them.

This has caused issues with change https://review.openocd.org/7211
on jenkins.

Skip loading 'tools/scripts/camelcase.txt' with flag --no-tree.
While there, rewrite the associated error message.

Change-Id: I6ede7b16f9ccd77b9118fd9be7ada07a1ac96952
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7212
Tested-by: jenkins
2022-09-23 21:19:44 +00:00
Paul Fertser
b89cf71e2b Restore +dev suffix
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
2022-09-18 20:40:13 +03:00
59 changed files with 1022 additions and 588 deletions

4
NEWS
View File

@@ -111,7 +111,7 @@ Build and Release:
* Drop repository repo.or.cz for submodules
* Move gerrit to https://review.openocd.org/
* Require autoconf 2.69 or newer
* Update jep106 to revision JEP106BE
* Update jep106 to revision JEP106BF.01
* Update jimtcl to version 0.81
* Update libjaylink to version 0.3.1
* New configure flag '--enable-jimtcl-maintainer' for jimtcl build
@@ -121,7 +121,7 @@ This release also contains a number of other important functional and
cosmetic bugfixes. For more details about what has changed since the
last release, see the git repository history:
http://sourceforge.net/p/openocd/code/ci/v0.12.0-rc1/log/?path=
http://sourceforge.net/p/openocd/code/ci/v0.12.0-rc3/log/?path=
For older NEWS, see the NEWS files associated with each release

25
README
View File

@@ -219,7 +219,10 @@ You'll also need:
- make
- libtool
- pkg-config >= 0.23 (or compatible)
- pkg-config >= 0.23 or pkgconf
OpenOCD uses jimtcl library; build from git can retrieve jimtcl as git
submodule.
Additionally, for building from git:
@@ -227,14 +230,26 @@ Additionally, for building from git:
- automake >= 1.14
- texinfo >= 5.0
USB-based adapters depend on libusb-1.0. A compatible implementation, such as
FreeBSD's, additionally needs the corresponding .pc files.
Optional USB-based adapter drivers need libusb-1.0.
USB-Blaster, ASIX Presto and OpenJTAG interface adapter
Optional USB-Blaster, ASIX Presto and OpenJTAG interface adapter
drivers need:
- libftdi: http://www.intra2net.com/en/developer/libftdi/index.php
CMSIS-DAP support needs HIDAPI library.
Optional CMSIS-DAP adapter driver needs HIDAPI library.
Optional linuxgpiod adapter driver needs libgpiod library.
Optional JLink adapter driver needs libjaylink; build from git can
retrieve libjaylink as git submodule.
Optional ARM disassembly needs capstone library.
Optional development script checkpatch needs:
- perl
- python
- python-ply
Permissions delegation
----------------------

View File

@@ -1,7 +1,7 @@
# SPDX-License-Identifier: GPL-2.0-or-later
AC_PREREQ([2.69])
AC_INIT([openocd], [0.12.0-rc1],
AC_INIT([openocd], [0.12.0-rc3],
[OpenOCD Mailing List <openocd-devel@lists.sourceforge.net>])
AC_CONFIG_SRCDIR([src/openocd.c])
AC_CONFIG_AUX_DIR([build-aux])
@@ -631,7 +631,6 @@ AS_IF([test "x$enable_capstone" != xno], [
PKG_CHECK_MODULES([CAPSTONE], [capstone], [
AC_DEFINE([HAVE_CAPSTONE], [1], [1 if you have Capstone disassembly framework.])
], [
AC_DEFINE([HAVE_CAPSTONE], [0], [0 if you don't have Capstone disassembly framework.])
if test "x$enable_capstone" != xauto; then
AC_MSG_ERROR([--with-capstone was given, but test for Capstone failed])
fi
@@ -639,6 +638,10 @@ AS_IF([test "x$enable_capstone" != xno], [
])
])
AS_IF([test "x$enable_capstone" == xno], [
AC_DEFINE([HAVE_CAPSTONE], [0], [0 if you don't have Capstone disassembly framework.])
])
for hidapi_lib in hidapi hidapi-hidraw hidapi-libusb; do
PKG_CHECK_MODULES([HIDAPI],[$hidapi_lib],[
use_hidapi=yes

View File

@@ -19,7 +19,7 @@ dated @value{UPDATED},
of the Open On-Chip Debugger (OpenOCD).
@itemize @bullet
@item Copyright @copyright{} 2008 The OpenOCD Project
@item Copyright @copyright{} 2008-2022 The OpenOCD Project
@item Copyright @copyright{} 2007-2008 Spencer Oliver @email{spen@@spen-soft.co.uk}
@item Copyright @copyright{} 2008-2010 Oyvind Harboe @email{oyvind.harboe@@zylin.com}
@item Copyright @copyright{} 2008 Duane Ellis @email{openocd@@duaneellis.com}
@@ -1785,7 +1785,6 @@ $_TARGETNAME configure -work-area-phys 0x00200000 \
-work-area-size 0x4000 -work-area-backup 0
@end example
@anchor{definecputargetsworkinginsmp}
@subsection Define CPU targets working in SMP
@cindex SMP
After setting targets, you can define a list of targets working in SMP.
@@ -1939,7 +1938,6 @@ For an example of this scheme see LPC2000 target config files.
The @code{init_boards} procedure is a similar concept concerning board config files
(@xref{theinitboardprocedure,,The init_board procedure}.)
@anchor{theinittargeteventsprocedure}
@subsection The init_target_events procedure
@cindex init_target_events procedure
@@ -2468,7 +2466,6 @@ the generic mapping may not support all of the listed options.
Returns the name of the debug adapter driver being used.
@end deffn
@anchor{adapter_usb_location}
@deffn {Config Command} {adapter usb location} [<bus>-<port>[.<port>]...]
Displays or specifies the physical USB port of the adapter to use. The path
roots at @var{bus} and walks down the physical ports, with each
@@ -3504,11 +3501,11 @@ Espressif JTAG driver to communicate with ESP32-C3, ESP32-S3 chips and ESP USB B
These chips have built-in JTAG circuitry and can be debugged without any additional hardware.
Only an USB cable connected to the D+/D- pins is necessary.
@deffn {Config Command} {espusbjtag tdo}
@deffn {Command} {espusbjtag tdo}
Returns the current state of the TDO line
@end deffn
@deffn {Config Command} {espusbjtag setio} setio
@deffn {Command} {espusbjtag setio} setio
Manually set the status of the output lines with the order of (tdi tms tck trst srst)
@example
espusbjtag setio 0 1 0 1 0
@@ -6205,7 +6202,6 @@ the flash.
@end deffn
@end deffn
@anchor{at91samd}
@deffn {Flash Driver} {at91samd}
@cindex at91samd
All members of the ATSAM D2x, D1x, D0x, ATSAMR, ATSAML and ATSAMC microcontroller
@@ -8482,12 +8478,20 @@ that particular type of PLD.
@deffn {FPGA Driver} {virtex2} [no_jstart]
Virtex-II is a family of FPGAs sold by Xilinx.
This driver can also be used to load Series3, Series6, Series7 and Zynq 7000 devices.
It supports the IEEE 1532 standard for In-System Configuration (ISC).
If @var{no_jstart} is non-zero, the JSTART instruction is not used after
loading the bitstream. While required for Series2, Series3, and Series6, it
breaks bitstream loading on Series7.
@example
openocd -f board/digilent_zedboard.cfg -c "init" \
-c "pld load 0 zedboard_bitstream.bit"
@end example
@deffn {Command} {virtex2 read_stat} num
Reads and displays the Virtex-II status register (STAT)
for FPGA @var{num}.
@@ -8519,7 +8523,7 @@ command. All output is relayed through the GDB session.
@item @b{Machine Interface}
The Tcl interface's intent is to be a machine interface. The default Tcl
port is 5555.
port is 6666.
@end itemize
@@ -9502,14 +9506,14 @@ requests by using a special SVC instruction that is trapped at the
Supervisor Call vector by OpenOCD.
@end deffn
@deffn {Command} {arm semihosting_redirect} (@option{disable} | @option{tcp} <port>
[@option{debug}|@option{stdio}|@option{all})
@deffn {Command} {arm semihosting_redirect} (@option{disable} | @option{tcp} <port> [@option{debug}|@option{stdio}|@option{all}])
@cindex ARM semihosting
Redirect semihosting messages to a specified TCP port.
This command redirects debug (READC, WRITEC and WRITE0) and stdio (READ, WRITE)
semihosting operations to the specified TCP port.
The command allows to select which type of operations to redirect (debug, stdio, all (default)).
Note: for stdio operations, only I/O from/to ':tt' file descriptors are redirected.
@end deffn
@@ -10653,6 +10657,16 @@ $_TARGETNAME expose_custom 32=myregister
@end example
@end deffn
@deffn {Command} {riscv info}
Displays some information OpenOCD detected about the target.
@end deffn
@deffn {Command} {riscv reset_delays} [wait]
OpenOCD learns how many Run-Test/Idle cycles are required between scans to avoid
encountering the target being busy. This command resets those learned values
after `wait` scans. It's only useful for testing OpenOCD itself.
@end deffn
@deffn {Command} {riscv set_command_timeout_sec} [seconds]
Set the wall-clock timeout (in seconds) for individual commands. The default
should work fine for all but the slowest targets (eg. simulators).
@@ -10663,12 +10677,7 @@ Set the maximum time to wait for a hart to come out of reset after reset is
deasserted.
@end deffn
@deffn {Command} {riscv set_scratch_ram} none|[address]
Set the address of 16 bytes of scratch RAM the debugger can use, or 'none'.
This is used to access 64-bit floating point registers on 32-bit targets.
@end deffn
@deffn Command {riscv set_mem_access} method1 [method2] [method3]
@deffn {Command} {riscv set_mem_access} method1 [method2] [method3]
Specify which RISC-V memory access method(s) shall be used, and in which order
of priority. At least one method must be specified.
@@ -10976,12 +10985,12 @@ NXP}.
@subsection Xtensa Configuration Commands
@deffn {Command} {xtensa xtdef} (@option{LX}|@option{NX})
@deffn {Config Command} {xtensa xtdef} (@option{LX}|@option{NX})
Configure the Xtensa target architecture. Currently, Xtensa support is limited
to LX6, LX7, and NX cores.
@end deffn
@deffn {Command} {xtensa xtopt} option value
@deffn {Config Command} {xtensa xtopt} option value
Configure Xtensa target options that are relevant to the debug subsystem.
@var{option} is one of: @option{arnum}, @option{windowed},
@option{cpenable}, @option{exceptions}, @option{intnum}, @option{hipriints},
@@ -10993,35 +11002,35 @@ NOTE: Some options are specific to Xtensa LX or Xtensa NX architecture, while
others may be common to both but have different valid ranges.
@end deffn
@deffn {Command} {xtensa xtmem} (@option{iram}|@option{dram}|@option{sram}|@option{irom}|@option{drom}|@option{srom}) baseaddr bytes
@deffn {Config Command} {xtensa xtmem} (@option{iram}|@option{dram}|@option{sram}|@option{irom}|@option{drom}|@option{srom}) baseaddr bytes
Configure Xtensa target memory. Memory type determines access rights,
where RAMs are read/write while ROMs are read-only. @var{baseaddr} and
@var{bytes} are both integers, typically hexadecimal and decimal, respectively.
@end deffn
@deffn {Command} {xtensa xtmem} (@option{icache}|@option{dcache}) linebytes cachebytes ways [writeback]
@deffn {Config Command} {xtensa xtmem} (@option{icache}|@option{dcache}) linebytes cachebytes ways [writeback]
Configure Xtensa processor cache. All parameters are required except for
the optional @option{writeback} parameter; all are integers.
@end deffn
@deffn {Command} {xtensa xtmpu} numfgseg minsegsz lockable execonly
@deffn {Config Command} {xtensa xtmpu} numfgseg minsegsz lockable execonly
Configure an Xtensa Memory Protection Unit (MPU). MPUs can restrict access
and/or control cacheability of specific address ranges, but are lighter-weight
than a full traditional MMU. All parameters are required; all are integers.
@end deffn
@deffn {Command} {xtensa xtmmu} numirefillentries numdrefillentries
@deffn {Config Command} {xtensa xtmmu} numirefillentries numdrefillentries
(Xtensa-LX only) Configure an Xtensa Memory Management Unit (MMU). Both
parameters are required; both are integers.
@end deffn
@deffn {Command} {xtensa xtregs} numregs
@deffn {Config Command} {xtensa xtregs} numregs
Configure the total number of registers for the Xtensa core. Configuration
logic expects to subsequently process this number of @code{xtensa xtreg}
definitions. @var{numregs} is an integer.
@end deffn
@deffn {Command} {xtensa xtregfmt} (@option{sparse}|@option{contiguous}) [general]
@deffn {Config Command} {xtensa xtregfmt} (@option{sparse}|@option{contiguous}) [general]
Configure the type of register map used by GDB to access the Xtensa core.
Generic Xtensa tools (e.g. xt-gdb) require @option{sparse} mapping (default) while
Espressif tools expect @option{contiguous} mapping. Contiguous mapping takes an
@@ -11029,7 +11038,7 @@ additional, optional integer parameter @option{numgregs}, which specifies the nu
of general registers used in handling g/G packets.
@end deffn
@deffn {Command} {xtensa xtreg} name offset
@deffn {Config Command} {xtensa xtreg} name offset
Configure an Xtensa core register. All core registers are 32 bits wide,
while TIE and user registers may have variable widths. @var{name} is a
character string identifier while @var{offset} is a hexadecimal integer.

View File

@@ -12,6 +12,7 @@
#include "imp.h"
#include "helper/binarybuffer.h"
#include <helper/time_support.h>
#include <jtag/jtag.h>
#include <target/cortex_m.h>
@@ -31,7 +32,7 @@
#define SAMD_NVMCTRL_CTRLA 0x00 /* NVM control A register */
#define SAMD_NVMCTRL_CTRLB 0x04 /* NVM control B register */
#define SAMD_NVMCTRL_PARAM 0x08 /* NVM parameters register */
#define SAMD_NVMCTRL_INTFLAG 0x18 /* NVM Interrupt Flag Status & Clear */
#define SAMD_NVMCTRL_INTFLAG 0x14 /* NVM Interrupt Flag Status & Clear */
#define SAMD_NVMCTRL_STATUS 0x18 /* NVM status register */
#define SAMD_NVMCTRL_ADDR 0x1C /* NVM address register */
#define SAMD_NVMCTRL_LOCK 0x20 /* NVM Lock section register */
@@ -55,6 +56,9 @@
/* NVMCTRL bits */
#define SAMD_NVM_CTRLB_MANW 0x80
/* NVMCTRL_INTFLAG bits */
#define SAMD_NVM_INTFLAG_READY 0x01
/* Known identifiers */
#define SAMD_PROCESSOR_M0 0x01
#define SAMD_FAMILY_D 0x00
@@ -497,7 +501,27 @@ static int samd_probe(struct flash_bank *bank)
static int samd_check_error(struct target *target)
{
int ret, ret2;
uint8_t intflag;
uint16_t status;
int timeout_ms = 1000;
int64_t ts_start = timeval_ms();
do {
ret = target_read_u8(target,
SAMD_NVMCTRL + SAMD_NVMCTRL_INTFLAG, &intflag);
if (ret != ERROR_OK) {
LOG_ERROR("Can't read NVM intflag");
return ret;
}
if (intflag & SAMD_NVM_INTFLAG_READY)
break;
keep_alive();
} while (timeval_ms() - ts_start < timeout_ms);
if (!(intflag & SAMD_NVM_INTFLAG_READY)) {
LOG_ERROR("SAMD: NVM programming timed out");
return ERROR_FLASH_OPERATION_FAILED;
}
ret = target_read_u16(target,
SAMD_NVMCTRL + SAMD_NVMCTRL_STATUS, &status);
@@ -543,7 +567,8 @@ static int samd_issue_nvmctrl_command(struct target *target, uint16_t cmd)
}
/* Issue the NVM command */
res = target_write_u16(target,
/* 32-bit write is used to ensure atomic operation on ST-Link */
res = target_write_u32(target,
SAMD_NVMCTRL + SAMD_NVMCTRL_CTRLA, SAMD_NVM_CMD(cmd));
if (res != ERROR_OK)
return res;

View File

@@ -1132,9 +1132,9 @@ static int lpc2900_write(struct flash_bank *bank, const uint8_t *buffer,
* reduced size if that fails. */
struct working_area *warea;
uint32_t buffer_size = lpc2900_info->max_ram_block - 1 * KiB;
while ((retval = target_alloc_working_area_try(target,
while (target_alloc_working_area_try(target,
buffer_size + target_code_size,
&warea)) != ERROR_OK) {
&warea) != ERROR_OK) {
/* Try a smaller buffer now, and stop if it's too small. */
buffer_size -= 1 * KiB;
if (buffer_size < 2 * KiB) {

View File

@@ -87,7 +87,7 @@ static uint32_t rp2040_lookup_symbol(struct target *target, uint32_t tag, uint16
}
static int rp2040_call_rom_func(struct target *target, struct rp2040_flash_bank *priv,
uint16_t func_offset, uint32_t argdata[], unsigned int n_args)
uint16_t func_offset, uint32_t argdata[], unsigned int n_args, int timeout_ms)
{
char *regnames[4] = { "r0", "r1", "r2", "r3" };
@@ -99,8 +99,7 @@ static int rp2040_call_rom_func(struct target *target, struct rp2040_flash_bank
}
target_addr_t stacktop = priv->stack->address + priv->stack->size;
LOG_DEBUG("Calling ROM func @0x%" PRIx16 " with %d arguments", func_offset, n_args);
LOG_DEBUG("Calling on core \"%s\"", target->cmd_name);
LOG_TARGET_DEBUG(target, "Calling ROM func @0x%" PRIx16 " with %u arguments", func_offset, n_args);
struct reg_param args[ARRAY_SIZE(regnames) + 2];
struct armv7m_algorithm alg_info;
@@ -112,11 +111,12 @@ static int rp2040_call_rom_func(struct target *target, struct rp2040_flash_bank
/* Pass function pointer in r7 */
init_reg_param(&args[n_args], "r7", 32, PARAM_OUT);
buf_set_u32(args[n_args].value, 0, 32, func_offset);
/* Setup stack */
init_reg_param(&args[n_args + 1], "sp", 32, PARAM_OUT);
buf_set_u32(args[n_args + 1].value, 0, 32, stacktop);
unsigned int n_reg_params = n_args + 2; /* User arguments + r7 + sp */
for (unsigned int i = 0; i < n_args + 2; ++i)
for (unsigned int i = 0; i < n_reg_params; ++i)
LOG_DEBUG("Set %s = 0x%" PRIx32, args[i].reg_name, buf_get_u32(args[i].value, 0, 32));
/* Actually call the function */
@@ -125,42 +125,82 @@ static int rp2040_call_rom_func(struct target *target, struct rp2040_flash_bank
int err = target_run_algorithm(
target,
0, NULL, /* No memory arguments */
n_args + 1, args, /* User arguments + r7 */
n_reg_params, args, /* User arguments + r7 + sp */
priv->jump_debug_trampoline, priv->jump_debug_trampoline_end,
3000, /* 3s timeout */
timeout_ms,
&alg_info
);
for (unsigned int i = 0; i < n_args + 2; ++i)
destroy_reg_param(&args[i]);
if (err != ERROR_OK)
LOG_ERROR("Failed to invoke ROM function @0x%" PRIx16 "\n", func_offset);
return err;
for (unsigned int i = 0; i < n_reg_params; ++i)
destroy_reg_param(&args[i]);
if (err != ERROR_OK)
LOG_ERROR("Failed to invoke ROM function @0x%" PRIx16, func_offset);
return err;
}
static int stack_grab_and_prep(struct flash_bank *bank)
/* Finalize flash write/erase/read ID
* - flush cache
* - enters memory-mapped (XIP) mode to make flash data visible
* - deallocates target ROM func stack if previously allocated
*/
static int rp2040_finalize_stack_free(struct flash_bank *bank)
{
struct rp2040_flash_bank *priv = bank->driver_priv;
struct target *target = bank->target;
/* Always flush before returning to execute-in-place, to invalidate stale
* cache contents. The flush call also restores regular hardware-controlled
* chip select following a rp2040_flash_exit_xip().
*/
LOG_DEBUG("Flushing flash cache after write behind");
int err = rp2040_call_rom_func(target, priv, priv->jump_flush_cache, NULL, 0, 1000);
if (err != ERROR_OK) {
LOG_ERROR("Failed to flush flash cache");
/* Intentionally continue after error and try to setup xip anyway */
}
LOG_DEBUG("Configuring SSI for execute-in-place");
err = rp2040_call_rom_func(target, priv, priv->jump_enter_cmd_xip, NULL, 0, 1000);
if (err != ERROR_OK)
LOG_ERROR("Failed to set SSI to XIP mode");
target_free_working_area(target, priv->stack);
priv->stack = NULL;
return err;
}
/* Prepare flash write/erase/read ID
* - allocates a stack for target ROM func
* - switches the SPI interface from memory-mapped mode to direct command mode
* Always pair with a call of rp2040_finalize_stack_free()
* after flash operation finishes or fails.
*/
static int rp2040_stack_grab_and_prep(struct flash_bank *bank)
{
struct rp2040_flash_bank *priv = bank->driver_priv;
struct target *target = bank->target;
/* target_alloc_working_area always allocates multiples of 4 bytes, so no worry about alignment */
const int STACK_SIZE = 256;
int err = target_alloc_working_area(bank->target, STACK_SIZE, &priv->stack);
int err = target_alloc_working_area(target, STACK_SIZE, &priv->stack);
if (err != ERROR_OK) {
LOG_ERROR("Could not allocate stack for flash programming code");
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
}
LOG_DEBUG("Connecting internal flash");
err = rp2040_call_rom_func(bank->target, priv, priv->jump_connect_internal_flash, NULL, 0);
err = rp2040_call_rom_func(target, priv, priv->jump_connect_internal_flash, NULL, 0, 1000);
if (err != ERROR_OK) {
LOG_ERROR("RP2040 erase: failed to connect internal flash");
LOG_ERROR("Failed to connect internal flash");
return err;
}
LOG_DEBUG("Kicking flash out of XIP mode");
err = rp2040_call_rom_func(bank->target, priv, priv->jump_flash_exit_xip, NULL, 0);
err = rp2040_call_rom_func(target, priv, priv->jump_flash_exit_xip, NULL, 0, 1000);
if (err != ERROR_OK) {
LOG_ERROR("RP2040 erase: failed to exit flash XIP mode");
LOG_ERROR("Failed to exit flash XIP mode");
return err;
}
@@ -173,16 +213,27 @@ static int rp2040_flash_write(struct flash_bank *bank, const uint8_t *buffer, ui
struct rp2040_flash_bank *priv = bank->driver_priv;
struct target *target = bank->target;
struct working_area *bounce;
int err = stack_grab_and_prep(bank);
if (target->state != TARGET_HALTED) {
LOG_ERROR("Target not halted");
return ERROR_TARGET_NOT_HALTED;
}
struct working_area *bounce = NULL;
int err = rp2040_stack_grab_and_prep(bank);
if (err != ERROR_OK)
return err;
goto cleanup;
const unsigned int chunk_size = target_get_working_area_avail(target);
if (target_alloc_working_area(target, chunk_size, &bounce) != ERROR_OK) {
unsigned int avail_pages = target_get_working_area_avail(target) / priv->dev->pagesize;
/* We try to allocate working area rounded down to device page size,
* al least 1 page, at most the write data size
*/
unsigned int chunk_size = MIN(MAX(avail_pages, 1) * priv->dev->pagesize, count);
err = target_alloc_working_area(target, chunk_size, &bounce);
if (err != ERROR_OK) {
LOG_ERROR("Could not allocate bounce buffer for flash programming. Can't continue");
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
goto cleanup;
}
LOG_DEBUG("Allocated flash bounce buffer @" TARGET_ADDR_FMT, bounce->address);
@@ -200,7 +251,8 @@ static int rp2040_flash_write(struct flash_bank *bank, const uint8_t *buffer, ui
bounce->address, /* data */
write_size /* count */
};
err = rp2040_call_rom_func(target, priv, priv->jump_flash_range_program, args, ARRAY_SIZE(args));
err = rp2040_call_rom_func(target, priv, priv->jump_flash_range_program,
args, ARRAY_SIZE(args), 3000);
if (err != ERROR_OK) {
LOG_ERROR("Failed to invoke flash programming code on target");
break;
@@ -210,36 +262,32 @@ static int rp2040_flash_write(struct flash_bank *bank, const uint8_t *buffer, ui
offset += write_size;
count -= write_size;
}
cleanup:
target_free_working_area(target, bounce);
if (err != ERROR_OK)
return err;
rp2040_finalize_stack_free(bank);
/* Flash is successfully programmed. We can now do a bit of poking to make the flash
contents visible to us via memory-mapped (XIP) interface in the 0x1... memory region */
LOG_DEBUG("Flushing flash cache after write behind");
err = rp2040_call_rom_func(bank->target, priv, priv->jump_flush_cache, NULL, 0);
if (err != ERROR_OK) {
LOG_ERROR("RP2040 write: failed to flush flash cache");
return err;
}
LOG_DEBUG("Configuring SSI for execute-in-place");
err = rp2040_call_rom_func(bank->target, priv, priv->jump_enter_cmd_xip, NULL, 0);
if (err != ERROR_OK)
LOG_ERROR("RP2040 write: failed to flush flash cache");
return err;
}
static int rp2040_flash_erase(struct flash_bank *bank, unsigned int first, unsigned int last)
{
struct rp2040_flash_bank *priv = bank->driver_priv;
struct target *target = bank->target;
if (target->state != TARGET_HALTED) {
LOG_ERROR("Target not halted");
return ERROR_TARGET_NOT_HALTED;
}
uint32_t start_addr = bank->sectors[first].offset;
uint32_t length = bank->sectors[last].offset + bank->sectors[last].size - start_addr;
LOG_DEBUG("RP2040 erase %d bytes starting at 0x%" PRIx32, length, start_addr);
int err = stack_grab_and_prep(bank);
int err = rp2040_stack_grab_and_prep(bank);
if (err != ERROR_OK)
return err;
goto cleanup;
LOG_DEBUG("Remote call flash_range_erase");
@@ -257,10 +305,15 @@ static int rp2040_flash_erase(struct flash_bank *bank, unsigned int first, unsig
https://github.com/raspberrypi/pico-bootrom/blob/master/bootrom/program_flash_generic.c
In theory, the function algorithm provides for erasing both a smaller "sector" (4096 bytes) and
an optional larger "block" (size and command provided in args). OpenOCD's spi.c only uses "block" sizes.
an optional larger "block" (size and command provided in args).
*/
err = rp2040_call_rom_func(bank->target, priv, priv->jump_flash_range_erase, args, ARRAY_SIZE(args));
int timeout_ms = 2000 * (last - first) + 1000;
err = rp2040_call_rom_func(target, priv, priv->jump_flash_range_erase,
args, ARRAY_SIZE(args), timeout_ms);
cleanup:
rp2040_finalize_stack_free(bank);
return err;
}
@@ -289,11 +342,46 @@ static int rp2040_ssel_active(struct target *target, bool active)
return ERROR_OK;
}
static int rp2040_spi_read_flash_id(struct target *target, uint32_t *devid)
{
uint32_t device_id = 0;
const target_addr_t ssi_dr0 = 0x18000060;
int err = rp2040_ssel_active(target, true);
/* write RDID request into SPI peripheral's FIFO */
for (int count = 0; (count < 4) && (err == ERROR_OK); count++)
err = target_write_u32(target, ssi_dr0, SPIFLASH_READ_ID);
/* by this time, there is a receive FIFO entry for every write */
for (int count = 0; (count < 4) && (err == ERROR_OK); count++) {
uint32_t status;
err = target_read_u32(target, ssi_dr0, &status);
device_id >>= 8;
device_id |= (status & 0xFF) << 24;
}
if (err == ERROR_OK)
*devid = device_id >> 8;
int err2 = rp2040_ssel_active(target, false);
if (err2 != ERROR_OK)
LOG_ERROR("SSEL inactive failed");
return err;
}
static int rp2040_flash_probe(struct flash_bank *bank)
{
struct rp2040_flash_bank *priv = bank->driver_priv;
struct target *target = bank->target;
if (target->state != TARGET_HALTED) {
LOG_ERROR("Target not halted");
return ERROR_TARGET_NOT_HALTED;
}
int err = rp2040_lookup_symbol(target, FUNC_DEBUG_TRAMPOLINE, &priv->jump_debug_trampoline);
if (err != ERROR_OK) {
LOG_ERROR("Debug trampoline not found in RP2040 ROM.");
@@ -344,34 +432,16 @@ static int rp2040_flash_probe(struct flash_bank *bank)
return err;
}
err = stack_grab_and_prep(bank);
if (err != ERROR_OK)
return err;
err = rp2040_stack_grab_and_prep(bank);
uint32_t device_id = 0;
const target_addr_t ssi_dr0 = 0x18000060;
if (err == ERROR_OK)
err = rp2040_spi_read_flash_id(target, &device_id);
err = rp2040_ssel_active(target, true);
rp2040_finalize_stack_free(bank);
/* write RDID request into SPI peripheral's FIFO */
for (int count = 0; (count < 4) && (err == ERROR_OK); count++)
err = target_write_u32(target, ssi_dr0, SPIFLASH_READ_ID);
/* by this time, there is a receive FIFO entry for every write */
for (int count = 0; (count < 4) && (err == ERROR_OK); count++) {
uint32_t status;
err = target_read_u32(target, ssi_dr0, &status);
device_id >>= 8;
device_id |= (status & 0xFF) << 24;
}
device_id >>= 8;
err = rp2040_ssel_active(target, false);
if (err != ERROR_OK) {
LOG_ERROR("SSEL inactive failed");
if (err != ERROR_OK)
return err;
}
/* search for a SPI flash Device ID match */
priv->dev = NULL;

View File

@@ -473,7 +473,7 @@ static int stm32x_write_block_async(struct flash_bank *bank, const uint8_t *buff
/* memory buffer */
buffer_size = target_get_working_area_avail(target);
buffer_size = MIN(hwords_count * 2, MAX(buffer_size, 256));
buffer_size = MIN(hwords_count * 2 + 8, MAX(buffer_size, 256));
/* Normally we allocate all available working area.
* MIN shrinks buffer_size if the size of the written block is smaller.
* MAX prevents using async algo if the available working area is smaller

View File

@@ -132,7 +132,7 @@ static const struct stm32lx_rev stm32_417_revs[] = {
{ 0x1000, "A" }, { 0x1008, "Z" }, { 0x1018, "Y" }, { 0x1038, "X" }
};
static const struct stm32lx_rev stm32_425_revs[] = {
{ 0x1000, "A" }, { 0x2000, "B" }, { 0x2008, "Y" },
{ 0x1000, "A" }, { 0x2000, "B" }, { 0x2008, "Y" }, { 0x2018, "1, X" },
};
static const struct stm32lx_rev stm32_427_revs[] = {
{ 0x1000, "A" }, { 0x1018, "Y" }, { 0x1038, "X" }, { 0x10f8, "V" },

View File

@@ -616,8 +616,6 @@ COMMAND_HANDLER(stmqspi_handle_set)
LOG_DEBUG("%s", __func__);
dual = (stmqspi_info->saved_cr & BIT(SPI_DUAL_FLASH)) ? 1 : 0;
/* chip_erase_cmd, sectorsize and erase_cmd are optional */
if ((CMD_ARGC < 7) || (CMD_ARGC > 10))
return ERROR_COMMAND_SYNTAX_ERROR;
@@ -628,8 +626,9 @@ COMMAND_HANDLER(stmqspi_handle_set)
target = bank->target;
stmqspi_info = bank->driver_priv;
dual = (stmqspi_info->saved_cr & BIT(SPI_DUAL_FLASH)) ? 1 : 0;
/* invalidate all old info */
/* invalidate all flash device info */
if (stmqspi_info->probed)
free(bank->sectors);
bank->size = 0;
@@ -721,10 +720,8 @@ COMMAND_HANDLER(stmqspi_handle_set)
uint32_t dcr;
retval = target_read_u32(target, io_base + SPI_DCR, &dcr);
if (retval != ERROR_OK)
return retval;
fsize = (dcr >> SPI_FSIZE_POS) & (BIT(SPI_FSIZE_LEN) - 1);
LOG_DEBUG("FSIZE = 0x%04x", fsize);
@@ -1799,7 +1796,6 @@ static int find_sfdp_dummy(struct flash_bank *bank, int len)
}
}
retval = ERROR_FAIL;
LOG_DEBUG("no start of SFDP header even after %u dummy bytes", count);
err:
@@ -2081,16 +2077,17 @@ static int stmqspi_probe(struct flash_bank *bank)
bool octal_dtr;
int retval;
if (stmqspi_info->probed) {
bank->size = 0;
bank->num_sectors = 0;
/* invalidate all flash device info */
if (stmqspi_info->probed)
free(bank->sectors);
bank->sectors = NULL;
memset(&stmqspi_info->dev, 0, sizeof(stmqspi_info->dev));
stmqspi_info->sfdp_dummy1 = 0;
stmqspi_info->sfdp_dummy2 = 0;
stmqspi_info->probed = false;
}
bank->size = 0;
bank->num_sectors = 0;
bank->sectors = NULL;
stmqspi_info->sfdp_dummy1 = 0;
stmqspi_info->sfdp_dummy2 = 0;
stmqspi_info->probed = false;
memset(&stmqspi_info->dev, 0, sizeof(stmqspi_info->dev));
stmqspi_info->dev.name = "unknown";
/* Abort any previous operation */
retval = stmqspi_abort(bank);
@@ -2105,8 +2102,8 @@ static int stmqspi_probe(struct flash_bank *bank)
/* check whether QSPI_ABR is writeable and readback returns the value written */
retval = target_write_u32(target, io_base + QSPI_ABR, magic);
if (retval == ERROR_OK) {
retval = target_read_u32(target, io_base + QSPI_ABR, &data);
retval = target_write_u32(target, io_base + QSPI_ABR, 0);
(void)target_read_u32(target, io_base + QSPI_ABR, &data);
(void)target_write_u32(target, io_base + QSPI_ABR, 0);
}
if (data == magic) {

View File

@@ -8,7 +8,7 @@
* identification code list, please visit the JEDEC website at www.jedec.org .
*/
/* This file is aligned to revision JEP106BE January 2022. */
/* This file is aligned to revision JEP106BF.01 October 2022. */
[0][0x01 - 1] = "AMD",
[0][0x02 - 1] = "AMI",
@@ -149,7 +149,7 @@
[1][0x0b - 1] = "Bestlink Systems",
[1][0x0c - 1] = "Graychip",
[1][0x0d - 1] = "GENNUM",
[1][0x0e - 1] = "VideoLogic",
[1][0x0e - 1] = "Imagination Technologies Limited",
[1][0x0f - 1] = "Robert Bosch",
[1][0x10 - 1] = "Chip Express",
[1][0x11 - 1] = "DATARAM",
@@ -1501,7 +1501,7 @@
[11][0x67 - 1] = "Guangzhou Shuvrwine Technology Co",
[11][0x68 - 1] = "Shenzhen Hangshun Chip Technology",
[11][0x69 - 1] = "Chengboliwei Electronic Business",
[11][0x6a - 1] = "Kowin Memory Technology Co Ltd",
[11][0x6a - 1] = "Kowin Technology HK Limited",
[11][0x6b - 1] = "Euronet Technology Inc",
[11][0x6c - 1] = "SCY",
[11][0x6d - 1] = "Shenzhen Xinhongyusheng Electrical",
@@ -1705,4 +1705,85 @@
[13][0x37 - 1] = "ORICO Technologies Co. Ltd.",
[13][0x38 - 1] = "Space Exploration Technologies Corp",
[13][0x39 - 1] = "AONDEVICES Inc",
[13][0x3a - 1] = "Shenzhen Netforward Micro Electronic",
[13][0x3b - 1] = "Syntacore Ltd",
[13][0x3c - 1] = "Shenzhen Secmem Microelectronics Co",
[13][0x3d - 1] = "ONiO As",
[13][0x3e - 1] = "Shenzhen Peladn Technology Co Ltd",
[13][0x3f - 1] = "O-Cubes Shanghai Microelectronics",
[13][0x40 - 1] = "ASTC",
[13][0x41 - 1] = "UMIS",
[13][0x42 - 1] = "Paradromics",
[13][0x43 - 1] = "Sinh Micro Co Ltd",
[13][0x44 - 1] = "Metorage Semiconductor Technology Co",
[13][0x45 - 1] = "Aeva Inc",
[13][0x46 - 1] = "HongKong Hyunion Electronics Co Ltd",
[13][0x47 - 1] = "China Flash Co Ltd",
[13][0x48 - 1] = "Sunplus Technology Co Ltd",
[13][0x49 - 1] = "Idaho Scientific",
[13][0x4a - 1] = "Suzhou SF Micro Electronics Co Ltd",
[13][0x4b - 1] = "IMEX Cap AG",
[13][0x4c - 1] = "Fitipower Integrated Technology Co Ltd",
[13][0x4d - 1] = "ShenzhenWooacme Technology Co Ltd",
[13][0x4e - 1] = "KeepData Original Chips",
[13][0x4f - 1] = "Rivos Inc",
[13][0x50 - 1] = "Big Innovation Company Limited",
[13][0x51 - 1] = "Wuhan YuXin Semiconductor Co Ltd",
[13][0x52 - 1] = "United Memory Technology (Jiangsu)",
[13][0x53 - 1] = "PQShield Ltd",
[13][0x54 - 1] = "ArchiTek Corporation",
[13][0x55 - 1] = "ShenZhen AZW Technology Co Ltd",
[13][0x56 - 1] = "Hengchi Zhixin (Dongguan) Technology",
[13][0x57 - 1] = "Eggtronic Engineering Spa",
[13][0x58 - 1] = "Fusontai Technology",
[13][0x59 - 1] = "PULP Platform",
[13][0x5a - 1] = "Koitek Electronic Technology (Shenzhen) Co",
[13][0x5b - 1] = "Shenzhen Jiteng Network Technology Co",
[13][0x5c - 1] = "Aviva Links Inc",
[13][0x5d - 1] = "Trilinear Technologies Inc",
[13][0x5e - 1] = "Shenzhen Developer Microelectronics Co",
[13][0x5f - 1] = "Guangdong OPPO Mobile Telecommunication",
[13][0x60 - 1] = "Akeana",
[13][0x61 - 1] = "Lyczar",
[13][0x62 - 1] = "Shenzhen Qiji Technology Co Ltd",
[13][0x63 - 1] = "Shenzhen Shangzhaoyuan Technology",
[13][0x64 - 1] = "Han Stor",
[13][0x65 - 1] = "China Micro Semicon Co., Ltd.",
[13][0x66 - 1] = "Shenzhen Zhuqin Technology Co Ltd",
[13][0x67 - 1] = "Shanghai Ningyuan Electronic Technology",
[13][0x68 - 1] = "Auradine",
[13][0x69 - 1] = "Suzhou Yishuo Electronics Co Ltd",
[13][0x6a - 1] = "Faurecia Clarion Electronics",
[13][0x6b - 1] = "SiMa Technologies",
[13][0x6c - 1] = "CFD Sales Inc",
[13][0x6d - 1] = "Suzhou Comay Information Co Ltd",
[13][0x6e - 1] = "Yentek",
[13][0x6f - 1] = "Qorvo Inc",
[13][0x70 - 1] = "Shenzhen Youzhi Computer Technology",
[13][0x71 - 1] = "Sychw Technology (Shenzhen) Co Ltd",
[13][0x72 - 1] = "MK Founder Technology Co Ltd",
[13][0x73 - 1] = "Siliconwaves Technologies Co Ltd",
[13][0x74 - 1] = "Hongkong Hyunion Electronics Co Ltd",
[13][0x75 - 1] = "Shenzhen Xinxinzhitao Electronics Business",
[13][0x76 - 1] = "Shenzhen HenQi Electronic Commerce Co",
[13][0x77 - 1] = "Shenzhen Jingyi Technology Co Ltd",
[13][0x78 - 1] = "Xiaohua Semiconductor Co. Ltd.",
[13][0x79 - 1] = "Shenzhen Dalu Semiconductor Technology",
[13][0x7a - 1] = "Shenzhen Ninespeed Electronics Co Ltd",
[13][0x7b - 1] = "ICYC Semiconductor Co Ltd",
[13][0x7c - 1] = "Shenzhen Jaguar Microsystems Co Ltd",
[13][0x7d - 1] = "Beijing EC-Founder Co Ltd",
[13][0x7e - 1] = "Shenzhen Taike Industrial Automation Co",
[14][0x01 - 1] = "Kalray SA",
[14][0x02 - 1] = "Shanghai Iluvatar CoreX Semiconductor Co",
[14][0x03 - 1] = "Fungible Inc",
[14][0x04 - 1] = "Song Industria E Comercio de Eletronicos",
[14][0x05 - 1] = "DreamBig Semiconductor Inc",
[14][0x06 - 1] = "ChampTek Electronics Corp",
[14][0x07 - 1] = "Fusontai Technology",
[14][0x08 - 1] = "Endress Hauser AG",
[14][0x09 - 1] = "altec ComputerSysteme GmbH",
[14][0x0a - 1] = "UltraRISC Technology (Shanghai) Co Ltd",
[14][0x0b - 1] = "Shenzhen Jing Da Kang Technology Co Ltd",
[14][0x0c - 1] = "Hangzhou Hongjun Microelectronics Co Ltd",
/* EOF */

View File

@@ -151,7 +151,7 @@ static inline uint16_t be_to_h_u16(const uint8_t *buf)
return (uint16_t)((uint16_t)buf[1] | (uint16_t)buf[0] << 8);
}
static inline void h_u64_to_le(uint8_t *buf, int64_t val)
static inline void h_u64_to_le(uint8_t *buf, uint64_t val)
{
buf[7] = (uint8_t) (val >> 56);
buf[6] = (uint8_t) (val >> 48);
@@ -163,7 +163,7 @@ static inline void h_u64_to_le(uint8_t *buf, int64_t val)
buf[0] = (uint8_t) (val >> 0);
}
static inline void h_u64_to_be(uint8_t *buf, int64_t val)
static inline void h_u64_to_be(uint8_t *buf, uint64_t val)
{
buf[0] = (uint8_t) (val >> 56);
buf[1] = (uint8_t) (val >> 48);
@@ -175,7 +175,7 @@ static inline void h_u64_to_be(uint8_t *buf, int64_t val)
buf[7] = (uint8_t) (val >> 0);
}
static inline void h_u32_to_le(uint8_t *buf, int val)
static inline void h_u32_to_le(uint8_t *buf, uint32_t val)
{
buf[3] = (uint8_t) (val >> 24);
buf[2] = (uint8_t) (val >> 16);
@@ -183,7 +183,7 @@ static inline void h_u32_to_le(uint8_t *buf, int val)
buf[0] = (uint8_t) (val >> 0);
}
static inline void h_u32_to_be(uint8_t *buf, int val)
static inline void h_u32_to_be(uint8_t *buf, uint32_t val)
{
buf[0] = (uint8_t) (val >> 24);
buf[1] = (uint8_t) (val >> 16);
@@ -191,27 +191,27 @@ static inline void h_u32_to_be(uint8_t *buf, int val)
buf[3] = (uint8_t) (val >> 0);
}
static inline void h_u24_to_le(uint8_t *buf, int val)
static inline void h_u24_to_le(uint8_t *buf, unsigned int val)
{
buf[2] = (uint8_t) (val >> 16);
buf[1] = (uint8_t) (val >> 8);
buf[0] = (uint8_t) (val >> 0);
}
static inline void h_u24_to_be(uint8_t *buf, int val)
static inline void h_u24_to_be(uint8_t *buf, unsigned int val)
{
buf[0] = (uint8_t) (val >> 16);
buf[1] = (uint8_t) (val >> 8);
buf[2] = (uint8_t) (val >> 0);
}
static inline void h_u16_to_le(uint8_t *buf, int val)
static inline void h_u16_to_le(uint8_t *buf, uint16_t val)
{
buf[1] = (uint8_t) (val >> 8);
buf[0] = (uint8_t) (val >> 0);
}
static inline void h_u16_to_be(uint8_t *buf, int val)
static inline void h_u16_to_be(uint8_t *buf, uint16_t val)
{
buf[0] = (uint8_t) (val >> 8);
buf[1] = (uint8_t) (val >> 0);

View File

@@ -117,7 +117,7 @@ const char *adapter_get_required_serial(void);
const char *adapter_gpio_get_name(enum adapter_gpio_config_index idx);
/**
* Retrieves gpio configuration set with command 'adapter gpio <signal_name>'
* Retrieves gpio configuration set with command "adapter gpio <signal_name>"
*/
const struct adapter_gpio_config *adapter_gpio_get_config(void);

View File

@@ -776,17 +776,12 @@ static int armjtagew_usb_read(struct armjtagew *armjtagew, int exp_in_length)
static void armjtagew_debug_buffer(uint8_t *buffer, int length)
{
char line[81];
char s[4];
int i;
int j;
char line[8 + 3 * BYTES_PER_LINE + 1];
for (i = 0; i < length; i += BYTES_PER_LINE) {
snprintf(line, 5, "%04x", i);
for (j = i; j < i + BYTES_PER_LINE && j < length; j++) {
snprintf(s, 4, " %02x", buffer[j]);
strcat(line, s);
}
for (int i = 0; i < length; i += BYTES_PER_LINE) {
int n = snprintf(line, 9, "%04x", i);
for (int j = i; j < i + BYTES_PER_LINE && j < length; j++)
n += snprintf(line + n, 4, " %02x", buffer[j]);
LOG_DEBUG("%s", line);
/* Prevent GDB timeout (writing to log might take some time) */

View File

@@ -57,6 +57,15 @@ static struct initial_gpio_state {
} initial_gpio_state[ADAPTER_GPIO_IDX_NUM];
static uint32_t initial_drive_strength_etc;
static inline void bcm2835_gpio_synchronize(void)
{
/* Ensure that previous writes to GPIO registers are flushed out of
* the inner shareable domain to prevent pipelined writes to the
* same address being merged.
*/
__sync_synchronize();
}
static bool is_gpio_config_valid(enum adapter_gpio_config_index idx)
{
/* Only chip 0 is supported, accept unset value (-1) too */
@@ -96,6 +105,7 @@ static void set_gpio_value(const struct adapter_gpio_config *gpio_config, int va
}
break;
}
bcm2835_gpio_synchronize();
}
static void restore_gpio(enum adapter_gpio_config_index idx)
@@ -109,6 +119,7 @@ static void restore_gpio(enum adapter_gpio_config_index idx)
GPIO_CLR = 1 << adapter_gpio_config[idx].gpio_num;
}
}
bcm2835_gpio_synchronize();
}
static void initialize_gpio(enum adapter_gpio_config_index idx)
@@ -143,6 +154,7 @@ static void initialize_gpio(enum adapter_gpio_config_index idx)
/* Direction for non push-pull is already set by set_gpio_value() */
if (adapter_gpio_config[idx].drive == ADAPTER_GPIO_DRIVE_MODE_PUSH_PULL)
OUT_GPIO(adapter_gpio_config[idx].gpio_num);
bcm2835_gpio_synchronize();
}
static bb_value_t bcm2835gpio_read(void)
@@ -164,6 +176,7 @@ static int bcm2835gpio_write(int tck, int tms, int tdi)
GPIO_SET = set;
GPIO_CLR = clear;
bcm2835_gpio_synchronize();
for (unsigned int i = 0; i < jtag_delay; i++)
asm volatile ("");
@@ -184,6 +197,7 @@ static int bcm2835gpio_swd_write_fast(int swclk, int swdio)
GPIO_SET = set;
GPIO_CLR = clear;
bcm2835_gpio_synchronize();
for (unsigned int i = 0; i < jtag_delay; i++)
asm volatile ("");
@@ -234,6 +248,7 @@ static void bcm2835_swdio_drive(bool is_output)
if (is_gpio_config_valid(ADAPTER_GPIO_IDX_SWDIO_DIR))
set_gpio_value(&adapter_gpio_config[ADAPTER_GPIO_IDX_SWDIO_DIR], 0);
}
bcm2835_gpio_synchronize();
}
static int bcm2835_swdio_read(void)

View File

@@ -380,8 +380,6 @@ static int bitbang_swd_init(void)
static void bitbang_swd_exchange(bool rnw, uint8_t buf[], unsigned int offset, unsigned int bit_cnt)
{
LOG_DEBUG("bitbang_swd_exchange");
if (bitbang_interface->blink) {
/* FIXME: we should manage errors */
bitbang_interface->blink(1);
@@ -412,11 +410,9 @@ static void bitbang_swd_exchange(bool rnw, uint8_t buf[], unsigned int offset, u
static int bitbang_swd_switch_seq(enum swd_special_seq seq)
{
LOG_DEBUG("bitbang_swd_switch_seq");
switch (seq) {
case LINE_RESET:
LOG_DEBUG("SWD line reset");
LOG_DEBUG_IO("SWD line reset");
bitbang_swd_exchange(false, (uint8_t *)swd_seq_line_reset, 0, swd_seq_line_reset_len);
break;
case JTAG_TO_SWD:
@@ -459,7 +455,6 @@ static void swd_clear_sticky_errors(void)
static void bitbang_swd_read_reg(uint8_t cmd, uint32_t *value, uint32_t ap_delay_clk)
{
LOG_DEBUG("bitbang_swd_read_reg");
assert(cmd & SWD_CMD_RNW);
if (queued_retval != ERROR_OK) {
@@ -481,7 +476,7 @@ static void bitbang_swd_read_reg(uint8_t cmd, uint32_t *value, uint32_t ap_delay
uint32_t data = buf_get_u32(trn_ack_data_parity_trn, 1 + 3, 32);
int parity = buf_get_u32(trn_ack_data_parity_trn, 1 + 3 + 32, 1);
LOG_DEBUG("%s %s read reg %X = %08"PRIx32,
LOG_DEBUG_IO("%s %s read reg %X = %08" PRIx32,
ack == SWD_ACK_OK ? "OK" : ack == SWD_ACK_WAIT ? "WAIT" : ack == SWD_ACK_FAULT ? "FAULT" : "JUNK",
cmd & SWD_CMD_APNDP ? "AP" : "DP",
(cmd & SWD_CMD_A32) >> 1,
@@ -510,7 +505,6 @@ static void bitbang_swd_read_reg(uint8_t cmd, uint32_t *value, uint32_t ap_delay
static void bitbang_swd_write_reg(uint8_t cmd, uint32_t value, uint32_t ap_delay_clk)
{
LOG_DEBUG("bitbang_swd_write_reg");
assert(!(cmd & SWD_CMD_RNW));
if (queued_retval != ERROR_OK) {
@@ -537,7 +531,7 @@ static void bitbang_swd_write_reg(uint8_t cmd, uint32_t value, uint32_t ap_delay
int ack = buf_get_u32(trn_ack_data_parity_trn, 1, 3);
LOG_DEBUG("%s%s %s write reg %X = %08"PRIx32,
LOG_DEBUG_IO("%s%s %s write reg %X = %08" PRIx32,
check_ack ? "" : "ack ignored ",
ack == SWD_ACK_OK ? "OK" : ack == SWD_ACK_WAIT ? "WAIT" : ack == SWD_ACK_FAULT ? "FAULT" : "JUNK",
cmd & SWD_CMD_APNDP ? "AP" : "DP",
@@ -562,14 +556,13 @@ static void bitbang_swd_write_reg(uint8_t cmd, uint32_t value, uint32_t ap_delay
static int bitbang_swd_run_queue(void)
{
LOG_DEBUG("bitbang_swd_run_queue");
/* A transaction must be followed by another transaction or at least 8 idle cycles to
* ensure that data is clocked through the AP. */
bitbang_swd_exchange(true, NULL, 0, 8);
int retval = queued_retval;
queued_retval = ERROR_OK;
LOG_DEBUG("SWD queue return value: %02x", retval);
LOG_DEBUG_IO("SWD queue return value: %02x", retval);
return retval;
}

View File

@@ -573,6 +573,8 @@ static int cmsis_dap_metacmd_targetsel(uint32_t instance_id)
The purpose of this operation is to select the target
corresponding to the instance_id that is written */
LOG_DEBUG_IO("DP write reg TARGETSEL %" PRIx32, instance_id);
size_t idx = 0;
command[idx++] = CMD_DAP_SWD_SEQUENCE;
command[idx++] = 3; /* sequence count */
@@ -658,7 +660,7 @@ static int cmsis_dap_cmd_dap_swo_baudrate(
command[0] = CMD_DAP_SWO_BAUDRATE;
h_u32_to_le(&command[1], in_baudrate);
int retval = cmsis_dap_xfer(cmsis_dap_handle, 4);
int retval = cmsis_dap_xfer(cmsis_dap_handle, 5);
uint32_t rvbr = le_to_h_u32(&cmsis_dap_handle->response[1]);
if (retval != ERROR_OK || rvbr == 0) {
LOG_ERROR("CMSIS-DAP: command CMD_SWO_Baudrate(%u) -> %u failed.", in_baudrate, rvbr);
@@ -783,7 +785,7 @@ static void cmsis_dap_swd_write_from_queue(struct cmsis_dap *dap)
uint8_t cmd = transfer->cmd;
uint32_t data = transfer->data;
LOG_DEBUG_IO("%s %s reg %x %"PRIx32,
LOG_DEBUG_IO("%s %s reg %x %" PRIx32,
cmd & SWD_CMD_APNDP ? "AP" : "DP",
cmd & SWD_CMD_RNW ? "read" : "write",
(cmd & SWD_CMD_A32) >> 1, data);
@@ -889,7 +891,7 @@ static void cmsis_dap_swd_read_process(struct cmsis_dap *dap, int timeout_ms)
uint32_t tmp = data;
idx += 4;
LOG_DEBUG_IO("Read result: %"PRIx32, data);
LOG_DEBUG_IO("Read result: %" PRIx32, data);
/* Imitate posted AP reads */
if ((transfer->cmd & SWD_CMD_APNDP) ||

View File

@@ -262,8 +262,10 @@ static int cmsis_dap_usb_open(struct cmsis_dap *dap, uint16_t vids[], uint16_t p
/* If the interface is reliably identified
* then we need not insist on setting USB class, subclass and protocol
* exactly as the specification requires.
* Just filter out the well known classes, mainly CDC and MSC.
* At least KitProg3 uses class 0 contrary to the specification */
if (intf_identified_reliably) {
if (intf_identified_reliably &&
(intf_desc->bInterfaceClass == 0 || intf_desc->bInterfaceClass > 0x12)) {
LOG_WARNING("Using CMSIS-DAPv2 interface %d with wrong class %" PRId8
" subclass %" PRId8 " or protocol %" PRId8,
interface_num,

View File

@@ -796,17 +796,12 @@ int opendous_usb_read(struct opendous_jtag *opendous_jtag)
void opendous_debug_buffer(uint8_t *buffer, int length)
{
char line[81];
char s[4];
int i;
int j;
char line[8 + 3 * BYTES_PER_LINE + 1];
for (i = 0; i < length; i += BYTES_PER_LINE) {
snprintf(line, 5, "%04x", i);
for (j = i; j < i + BYTES_PER_LINE && j < length; j++) {
snprintf(s, 4, " %02x", buffer[j]);
strcat(line, s);
}
for (int i = 0; i < length; i += BYTES_PER_LINE) {
int n = snprintf(line, 9, "%04x", i);
for (int j = i; j < i + BYTES_PER_LINE && j < length; j++)
n += snprintf(line + n, 4, " %02x", buffer[j]);
LOG_DEBUG("%s", line);
}
}

View File

@@ -1246,7 +1246,7 @@ static const struct command_registration vdebug_command_handlers[] = {
{
.name = "mem_path",
.handler = &vdebug_set_mem,
.mode = COMMAND_ANY,
.mode = COMMAND_CONFIG,
.help = "set the design memory for the code load",
.usage = "<path> <base_address> <size>",
},

View File

@@ -1354,11 +1354,13 @@ static void xds110_swd_queue_cmd(uint8_t cmd, uint32_t *value)
static void xds110_swd_read_reg(uint8_t cmd, uint32_t *value,
uint32_t ap_delay_clk)
{
assert(cmd & SWD_CMD_RNW);
xds110_swd_queue_cmd(cmd, value);
}
static void xds110_swd_write_reg(uint8_t cmd, uint32_t value,
uint32_t ap_delay_clk)
{
assert(!(cmd & SWD_CMD_RNW));
xds110_swd_queue_cmd(cmd, &value);
}

View File

@@ -157,6 +157,8 @@ static int virtex2_load(struct pld_device *pld_device, const char *filename)
virtex2_set_instr(virtex2_info->tap, 0x3f); /* BYPASS */
jtag_execute_queue();
xilinx_free_bit_file(&bit_file);
return ERROR_OK;
}
@@ -173,7 +175,7 @@ COMMAND_HANDLER(virtex2_handle_read_stat_command)
device = get_pld_device_by_num(dev_id);
if (!device) {
command_print(CMD, "pld device '#%s' is out of bounds", CMD_ARGV[0]);
return ERROR_OK;
return ERROR_FAIL;
}
virtex2_read_stat(device, &status);
@@ -195,7 +197,7 @@ PLD_DEVICE_COMMAND_HANDLER(virtex2_pld_device_command)
tap = jtag_tap_by_string(CMD_ARGV[1]);
if (!tap) {
command_print(CMD, "Tap: %s does not exist", CMD_ARGV[1]);
return ERROR_OK;
return ERROR_FAIL;
}
virtex2_info = malloc(sizeof(struct virtex2_pld_device));

View File

@@ -87,26 +87,48 @@ int xilinx_read_bit_file(struct xilinx_bit_file *bit_file, const char *filename)
return ERROR_PLD_FILE_LOAD_FAILED;
}
bit_file->source_file = NULL;
bit_file->part_name = NULL;
bit_file->date = NULL;
bit_file->time = NULL;
bit_file->data = NULL;
read_count = fread(bit_file->unknown_header, 1, 13, input_file);
if (read_count != 13) {
LOG_ERROR("couldn't read unknown_header from file '%s'", filename);
fclose(input_file);
return ERROR_PLD_FILE_LOAD_FAILED;
}
if (read_section(input_file, 2, 'a', NULL, &bit_file->source_file) != ERROR_OK)
if (read_section(input_file, 2, 'a', NULL, &bit_file->source_file) != ERROR_OK) {
xilinx_free_bit_file(bit_file);
fclose(input_file);
return ERROR_PLD_FILE_LOAD_FAILED;
}
if (read_section(input_file, 2, 'b', NULL, &bit_file->part_name) != ERROR_OK)
if (read_section(input_file, 2, 'b', NULL, &bit_file->part_name) != ERROR_OK) {
xilinx_free_bit_file(bit_file);
fclose(input_file);
return ERROR_PLD_FILE_LOAD_FAILED;
}
if (read_section(input_file, 2, 'c', NULL, &bit_file->date) != ERROR_OK)
if (read_section(input_file, 2, 'c', NULL, &bit_file->date) != ERROR_OK) {
xilinx_free_bit_file(bit_file);
fclose(input_file);
return ERROR_PLD_FILE_LOAD_FAILED;
}
if (read_section(input_file, 2, 'd', NULL, &bit_file->time) != ERROR_OK)
if (read_section(input_file, 2, 'd', NULL, &bit_file->time) != ERROR_OK) {
xilinx_free_bit_file(bit_file);
fclose(input_file);
return ERROR_PLD_FILE_LOAD_FAILED;
}
if (read_section(input_file, 4, 'e', &bit_file->length, &bit_file->data) != ERROR_OK)
if (read_section(input_file, 4, 'e', &bit_file->length, &bit_file->data) != ERROR_OK) {
xilinx_free_bit_file(bit_file);
fclose(input_file);
return ERROR_PLD_FILE_LOAD_FAILED;
}
LOG_DEBUG("bit_file: %s %s %s,%s %" PRIu32 "", bit_file->source_file, bit_file->part_name,
bit_file->date, bit_file->time, bit_file->length);
@@ -115,3 +137,12 @@ int xilinx_read_bit_file(struct xilinx_bit_file *bit_file, const char *filename)
return ERROR_OK;
}
void xilinx_free_bit_file(struct xilinx_bit_file *bit_file)
{
free(bit_file->source_file);
free(bit_file->part_name);
free(bit_file->date);
free(bit_file->time);
free(bit_file->data);
}

View File

@@ -22,4 +22,6 @@ struct xilinx_bit_file {
int xilinx_read_bit_file(struct xilinx_bit_file *bit_file, const char *filename);
void xilinx_free_bit_file(struct xilinx_bit_file *bit_file);
#endif /* OPENOCD_PLD_XILINX_BIT_H */

View File

@@ -320,6 +320,12 @@ static int threadx_update_threads(struct rtos *rtos)
rtos->thread_details->thread_name_str = malloc(sizeof(tmp_str));
strcpy(rtos->thread_details->thread_name_str, tmp_str);
/* If we just invented thread 1 to represent the current execution, we
* need to make sure the RTOS object also claims it's the current thread
* so that threadx_get_thread_reg_list() doesn't attempt to read a
* thread control block at 0x00000001. */
rtos->current_thread = 1;
if (thread_list_size == 0) {
rtos->thread_count = 1;
return ERROR_OK;
@@ -364,16 +370,21 @@ static int threadx_update_threads(struct rtos *rtos)
}
/* Read the thread name */
retval =
target_read_buffer(rtos->target,
name_ptr,
THREADX_THREAD_NAME_STR_SIZE,
(uint8_t *)&tmp_str);
if (retval != ERROR_OK) {
LOG_ERROR("Error reading thread name from ThreadX target");
return retval;
tmp_str[0] = '\x00';
/* Check if thread has a valid name */
if (name_ptr != 0) {
retval =
target_read_buffer(rtos->target,
name_ptr,
THREADX_THREAD_NAME_STR_SIZE,
(uint8_t *)&tmp_str);
if (retval != ERROR_OK) {
LOG_ERROR("Error reading thread name from ThreadX target");
return retval;
}
tmp_str[THREADX_THREAD_NAME_STR_SIZE - 1] = '\x00';
}
tmp_str[THREADX_THREAD_NAME_STR_SIZE-1] = '\x00';
if (tmp_str[0] == '\x00')
strcpy(tmp_str, "No Name");

View File

@@ -82,6 +82,7 @@ static int hwthread_update_threads(struct rtos *rtos)
struct target_list *head;
struct target *target;
int64_t current_thread = 0;
int64_t current_threadid = rtos->current_threadid; /* thread selected by GDB */
enum target_debug_reason current_reason = DBG_REASON_UNDEFINED;
if (!rtos)
@@ -105,6 +106,15 @@ static int hwthread_update_threads(struct rtos *rtos)
} else
thread_list_size = 1;
/* restore the threadid which is currently selected by GDB
* because rtos_free_threadlist() wipes out it
* (GDB thread id is 1-based indexing) */
if (current_threadid <= thread_list_size)
rtos->current_threadid = current_threadid;
else
LOG_WARNING("SMP node change, disconnect GDB from core/thread %" PRId64,
current_threadid);
/* create space for new thread details */
rtos->thread_details = malloc(sizeof(struct thread_detail) * thread_list_size);
@@ -255,10 +265,19 @@ static int hwthread_get_thread_reg_list(struct rtos *rtos, int64_t thread_id,
for (int i = 0; i < reg_list_size; i++) {
if (!reg_list[i] || reg_list[i]->exist == false || reg_list[i]->hidden)
continue;
(*rtos_reg_list)[j].number = (*reg_list)[i].number;
(*rtos_reg_list)[j].size = (*reg_list)[i].size;
memcpy((*rtos_reg_list)[j].value, (*reg_list)[i].value,
((*reg_list)[i].size + 7) / 8);
if (!reg_list[i]->valid) {
retval = reg_list[i]->type->get(reg_list[i]);
if (retval != ERROR_OK) {
LOG_ERROR("Couldn't get register %s.", reg_list[i]->name);
free(reg_list);
free(*rtos_reg_list);
return retval;
}
}
(*rtos_reg_list)[j].number = reg_list[i]->number;
(*rtos_reg_list)[j].size = reg_list[i]->size;
memcpy((*rtos_reg_list)[j].value, reg_list[i]->value,
DIV_ROUND_UP(reg_list[i]->size, 8));
j++;
}
free(reg_list);

View File

@@ -2546,23 +2546,20 @@ static int aarch64_examine_first(struct target *target)
if (!pc)
return ERROR_FAIL;
if (armv8->debug_ap) {
dap_put_ap(armv8->debug_ap);
armv8->debug_ap = NULL;
}
if (pc->adiv5_config.ap_num == DP_APSEL_INVALID) {
/* Search for the APB-AB */
retval = dap_find_get_ap(swjdp, AP_TYPE_APB_AP, &armv8->debug_ap);
if (retval != ERROR_OK) {
LOG_ERROR("Could not find APB-AP for debug access");
return retval;
}
} else {
armv8->debug_ap = dap_get_ap(swjdp, pc->adiv5_config.ap_num);
if (!armv8->debug_ap) {
LOG_ERROR("Cannot get AP");
return ERROR_FAIL;
if (!armv8->debug_ap) {
if (pc->adiv5_config.ap_num == DP_APSEL_INVALID) {
/* Search for the APB-AB */
retval = dap_find_get_ap(swjdp, AP_TYPE_APB_AP, &armv8->debug_ap);
if (retval != ERROR_OK) {
LOG_ERROR("Could not find APB-AP for debug access");
return retval;
}
} else {
armv8->debug_ap = dap_get_ap(swjdp, pc->adiv5_config.ap_num);
if (!armv8->debug_ap) {
LOG_ERROR("Cannot get AP");
return ERROR_FAIL;
}
}
}

View File

@@ -177,6 +177,19 @@ static int swd_multidrop_select_inner(struct adiv5_dap *dap, uint32_t *dpidr_ptr
assert(dap_is_multidrop(dap));
swd_send_sequence(dap, LINE_RESET);
/* From ARM IHI 0074C ADIv6.0, chapter B4.3.3 "Connection and line reset
* sequence":
* - line reset sets DP_SELECT_DPBANK to zero;
* - read of DP_DPIDR takes the connection out of reset;
* - write of DP_TARGETSEL keeps the connection in reset;
* - other accesses return protocol error (SWDIO not driven by target).
*
* Read DP_DPIDR to get out of reset. Initialize dap->select to zero to
* skip the write to DP_SELECT, avoiding the protocol error. Set again
* dap->select to DP_SELECT_INVALID because the rest of the register is
* unknown after line reset.
*/
dap->select = 0;
retval = swd_queue_dp_write_inner(dap, DP_TARGETSEL, dap->multidrop_targetsel);
if (retval != ERROR_OK)
@@ -196,6 +209,8 @@ static int swd_multidrop_select_inner(struct adiv5_dap *dap, uint32_t *dpidr_ptr
return retval;
}
dap->select = DP_SELECT_INVALID;
retval = swd_queue_dp_read_inner(dap, DP_DLPIDR, &dlpidr);
if (retval != ERROR_OK)
return retval;
@@ -257,6 +272,8 @@ static int swd_multidrop_select(struct adiv5_dap *dap)
LOG_DEBUG("Failed to select multidrop %s, retrying...",
adiv5_dap_name(dap));
/* we going to retry localy, do not ask for full reconnect */
dap->do_reconnect = false;
}
return retval;
@@ -342,6 +359,7 @@ static int swd_connect_single(struct adiv5_dap *dap)
dap->switch_through_dormant = !dap->switch_through_dormant;
} while (timeval_ms() < timeout);
dap->select = DP_SELECT_INVALID;
if (retval != ERROR_OK) {

View File

@@ -113,7 +113,7 @@ static int mem_ap_setup_tar(struct adiv5_ap *ap, target_addr_t tar)
int retval = dap_queue_ap_write(ap, MEM_AP_REG_TAR(ap->dap), (uint32_t)(tar & 0xffffffffUL));
if (retval == ERROR_OK && is_64bit_ap(ap)) {
/* See if bits 63:32 of tar is different from last setting */
if ((ap->tar_value >> 32) != (tar >> 32))
if (!ap->tar_valid || (ap->tar_value >> 32) != (tar >> 32))
retval = dap_queue_ap_write(ap, MEM_AP_REG_TAR64(ap->dap), (uint32_t)(tar >> 32));
}
if (retval != ERROR_OK) {

View File

@@ -116,27 +116,27 @@ static const struct {
{ ARMV7M_FAULTMASK, "faultmask", 1, REG_TYPE_INT8, "system", "org.gnu.gdb.arm.m-system" },
{ ARMV7M_CONTROL, "control", 3, REG_TYPE_INT8, "system", "org.gnu.gdb.arm.m-system" },
/* ARMv8-M specific registers */
{ ARMV8M_MSP_NS, "msp_ns", 32, REG_TYPE_DATA_PTR, "stack", "v8-m.sp" },
{ ARMV8M_PSP_NS, "psp_ns", 32, REG_TYPE_DATA_PTR, "stack", "v8-m.sp" },
{ ARMV8M_MSP_S, "msp_s", 32, REG_TYPE_DATA_PTR, "stack", "v8-m.sp" },
{ ARMV8M_PSP_S, "psp_s", 32, REG_TYPE_DATA_PTR, "stack", "v8-m.sp" },
{ ARMV8M_MSPLIM_S, "msplim_s", 32, REG_TYPE_DATA_PTR, "stack", "v8-m.sp" },
{ ARMV8M_PSPLIM_S, "psplim_s", 32, REG_TYPE_DATA_PTR, "stack", "v8-m.sp" },
{ ARMV8M_MSPLIM_NS, "msplim_ns", 32, REG_TYPE_DATA_PTR, "stack", "v8-m.sp" },
{ ARMV8M_PSPLIM_NS, "psplim_ns", 32, REG_TYPE_DATA_PTR, "stack", "v8-m.sp" },
/* ARMv8-M security extension (TrustZone) specific registers */
{ ARMV8M_MSP_NS, "msp_ns", 32, REG_TYPE_DATA_PTR, "stack", "org.gnu.gdb.arm.secext" },
{ ARMV8M_PSP_NS, "psp_ns", 32, REG_TYPE_DATA_PTR, "stack", "org.gnu.gdb.arm.secext" },
{ ARMV8M_MSP_S, "msp_s", 32, REG_TYPE_DATA_PTR, "stack", "org.gnu.gdb.arm.secext" },
{ ARMV8M_PSP_S, "psp_s", 32, REG_TYPE_DATA_PTR, "stack", "org.gnu.gdb.arm.secext" },
{ ARMV8M_MSPLIM_S, "msplim_s", 32, REG_TYPE_DATA_PTR, "stack", "org.gnu.gdb.arm.secext" },
{ ARMV8M_PSPLIM_S, "psplim_s", 32, REG_TYPE_DATA_PTR, "stack", "org.gnu.gdb.arm.secext" },
{ ARMV8M_MSPLIM_NS, "msplim_ns", 32, REG_TYPE_DATA_PTR, "stack", "org.gnu.gdb.arm.secext" },
{ ARMV8M_PSPLIM_NS, "psplim_ns", 32, REG_TYPE_DATA_PTR, "stack", "org.gnu.gdb.arm.secext" },
{ ARMV8M_PMSK_BPRI_FLTMSK_CTRL_S, "pmsk_bpri_fltmsk_ctrl_s", 32, REG_TYPE_INT, NULL, NULL },
{ ARMV8M_PRIMASK_S, "primask_s", 1, REG_TYPE_INT8, "system", "org.gnu.gdb.arm.m-system" },
{ ARMV8M_BASEPRI_S, "basepri_s", 8, REG_TYPE_INT8, "system", "org.gnu.gdb.arm.m-system" },
{ ARMV8M_FAULTMASK_S, "faultmask_s", 1, REG_TYPE_INT8, "system", "org.gnu.gdb.arm.m-system" },
{ ARMV8M_CONTROL_S, "control_s", 3, REG_TYPE_INT8, "system", "org.gnu.gdb.arm.m-system" },
{ ARMV8M_PRIMASK_S, "primask_s", 1, REG_TYPE_INT8, "system", "org.gnu.gdb.arm.secext" },
{ ARMV8M_BASEPRI_S, "basepri_s", 8, REG_TYPE_INT8, "system", "org.gnu.gdb.arm.secext" },
{ ARMV8M_FAULTMASK_S, "faultmask_s", 1, REG_TYPE_INT8, "system", "org.gnu.gdb.arm.secext" },
{ ARMV8M_CONTROL_S, "control_s", 3, REG_TYPE_INT8, "system", "org.gnu.gdb.arm.secext" },
{ ARMV8M_PMSK_BPRI_FLTMSK_CTRL_NS, "pmsk_bpri_fltmsk_ctrl_ns", 32, REG_TYPE_INT, NULL, NULL },
{ ARMV8M_PRIMASK_NS, "primask_ns", 1, REG_TYPE_INT8, "system", "org.gnu.gdb.arm.m-system" },
{ ARMV8M_BASEPRI_NS, "basepri_ns", 8, REG_TYPE_INT8, "system", "org.gnu.gdb.arm.m-system" },
{ ARMV8M_FAULTMASK_NS, "faultmask_ns", 1, REG_TYPE_INT8, "system", "org.gnu.gdb.arm.m-system" },
{ ARMV8M_CONTROL_NS, "control_ns", 3, REG_TYPE_INT8, "system", "org.gnu.gdb.arm.m-system" },
{ ARMV8M_PRIMASK_NS, "primask_ns", 1, REG_TYPE_INT8, "system", "org.gnu.gdb.arm.secext" },
{ ARMV8M_BASEPRI_NS, "basepri_ns", 8, REG_TYPE_INT8, "system", "org.gnu.gdb.arm.secext" },
{ ARMV8M_FAULTMASK_NS, "faultmask_ns", 1, REG_TYPE_INT8, "system", "org.gnu.gdb.arm.secext" },
{ ARMV8M_CONTROL_NS, "control_ns", 3, REG_TYPE_INT8, "system", "org.gnu.gdb.arm.secext" },
/* FPU registers */
{ ARMV7M_D0, "d0", 64, REG_TYPE_IEEE_DOUBLE, "float", "org.gnu.gdb.arm.vfp" },
@@ -528,11 +528,17 @@ int armv7m_start_algorithm(struct target *target,
/* Store all non-debug execution registers to armv7m_algorithm_info context */
for (unsigned i = 0; i < armv7m->arm.core_cache->num_regs; i++) {
struct reg *reg = &armv7m->arm.core_cache->reg_list[i];
if (!reg->exist)
continue;
armv7m_algorithm_info->context[i] = buf_get_u32(
armv7m->arm.core_cache->reg_list[i].value,
0,
32);
if (!reg->valid)
armv7m_get_core_reg(reg);
if (!reg->valid)
LOG_TARGET_WARNING(target, "Storing invalid register %s", reg->name);
armv7m_algorithm_info->context[i] = buf_get_u32(reg->value, 0, 32);
}
for (int i = 0; i < num_mem_params; i++) {
@@ -685,16 +691,19 @@ int armv7m_wait_algorithm(struct target *target,
}
for (int i = armv7m->arm.core_cache->num_regs - 1; i >= 0; i--) {
struct reg *reg = &armv7m->arm.core_cache->reg_list[i];
if (!reg->exist)
continue;
uint32_t regvalue;
regvalue = buf_get_u32(armv7m->arm.core_cache->reg_list[i].value, 0, 32);
regvalue = buf_get_u32(reg->value, 0, 32);
if (regvalue != armv7m_algorithm_info->context[i]) {
LOG_DEBUG("restoring register %s with value 0x%8.8" PRIx32,
armv7m->arm.core_cache->reg_list[i].name,
armv7m_algorithm_info->context[i]);
buf_set_u32(armv7m->arm.core_cache->reg_list[i].value,
reg->name, armv7m_algorithm_info->context[i]);
buf_set_u32(reg->value,
0, 32, armv7m_algorithm_info->context[i]);
armv7m->arm.core_cache->reg_list[i].valid = true;
armv7m->arm.core_cache->reg_list[i].dirty = true;
reg->valid = true;
reg->dirty = true;
}
}
@@ -726,8 +735,9 @@ int armv7m_arch_state(struct target *target)
ctrl = buf_get_u32(arm->core_cache->reg_list[ARMV7M_CONTROL].value, 0, 32);
sp = buf_get_u32(arm->core_cache->reg_list[ARMV7M_R13].value, 0, 32);
LOG_USER("target halted due to %s, current mode: %s %s\n"
LOG_USER("[%s] halted due to %s, current mode: %s %s\n"
"xPSR: %#8.8" PRIx32 " pc: %#8.8" PRIx32 " %csp: %#8.8" PRIx32 "%s%s",
target_name(target),
debug_reason_name(target),
arm_mode_name(arm->core_mode),
armv7m_exception_string(armv7m->exception_number),

View File

@@ -2246,7 +2246,7 @@ static int cortex_a_write_cpu_memory(struct target *target,
/* Switch to non-blocking mode if not already in that mode. */
retval = cortex_a_set_dcc_mode(target, DSCR_EXT_DCC_NON_BLOCKING, &dscr);
if (retval != ERROR_OK)
goto out;
return retval;
/* Mark R0 as dirty. */
arm_reg_current(arm, 0)->dirty = true;
@@ -2254,16 +2254,16 @@ static int cortex_a_write_cpu_memory(struct target *target,
/* Read DFAR and DFSR, as they will be modified in the event of a fault. */
retval = cortex_a_read_dfar_dfsr(target, &orig_dfar, &orig_dfsr, &dscr);
if (retval != ERROR_OK)
goto out;
return retval;
/* Get the memory address into R0. */
retval = mem_ap_write_atomic_u32(armv7a->debug_ap,
armv7a->debug_base + CPUDBG_DTRRX, address);
if (retval != ERROR_OK)
goto out;
return retval;
retval = cortex_a_exec_opcode(target, ARMV4_5_MRC(14, 0, 0, 0, 5, 0), &dscr);
if (retval != ERROR_OK)
goto out;
return retval;
if (size == 4 && (address % 4) == 0) {
/* We are doing a word-aligned transfer, so use fast mode. */
@@ -2288,7 +2288,6 @@ static int cortex_a_write_cpu_memory(struct target *target,
retval = cortex_a_write_cpu_memory_slow(target, size, count, buffer, &dscr);
}
out:
final_retval = retval;
/* Switch to non-blocking mode if not already in that mode. */
@@ -2564,7 +2563,7 @@ static int cortex_a_read_cpu_memory(struct target *target,
/* Switch to non-blocking mode if not already in that mode. */
retval = cortex_a_set_dcc_mode(target, DSCR_EXT_DCC_NON_BLOCKING, &dscr);
if (retval != ERROR_OK)
goto out;
return retval;
/* Mark R0 as dirty. */
arm_reg_current(arm, 0)->dirty = true;
@@ -2572,16 +2571,16 @@ static int cortex_a_read_cpu_memory(struct target *target,
/* Read DFAR and DFSR, as they will be modified in the event of a fault. */
retval = cortex_a_read_dfar_dfsr(target, &orig_dfar, &orig_dfsr, &dscr);
if (retval != ERROR_OK)
goto out;
return retval;
/* Get the memory address into R0. */
retval = mem_ap_write_atomic_u32(armv7a->debug_ap,
armv7a->debug_base + CPUDBG_DTRRX, address);
if (retval != ERROR_OK)
goto out;
return retval;
retval = cortex_a_exec_opcode(target, ARMV4_5_MRC(14, 0, 0, 0, 5, 0), &dscr);
if (retval != ERROR_OK)
goto out;
return retval;
if (size == 4 && (address % 4) == 0) {
/* We are doing a word-aligned transfer, so use fast mode. */
@@ -2607,7 +2606,6 @@ static int cortex_a_read_cpu_memory(struct target *target,
retval = cortex_a_read_cpu_memory_slow(target, size, count, buffer, &dscr);
}
out:
final_retval = retval;
/* Switch to non-blocking mode if not already in that mode. */
@@ -2874,23 +2872,20 @@ static int cortex_a_examine_first(struct target *target)
int retval = ERROR_OK;
uint32_t didr, cpuid, dbg_osreg, dbg_idpfr1;
if (armv7a->debug_ap) {
dap_put_ap(armv7a->debug_ap);
armv7a->debug_ap = NULL;
}
if (pc->ap_num == DP_APSEL_INVALID) {
/* Search for the APB-AP - it is needed for access to debug registers */
retval = dap_find_get_ap(swjdp, AP_TYPE_APB_AP, &armv7a->debug_ap);
if (retval != ERROR_OK) {
LOG_ERROR("Could not find APB-AP for debug access");
return retval;
}
} else {
armv7a->debug_ap = dap_get_ap(swjdp, pc->ap_num);
if (!armv7a->debug_ap) {
LOG_ERROR("Cannot get AP");
return ERROR_FAIL;
if (!armv7a->debug_ap) {
if (pc->ap_num == DP_APSEL_INVALID) {
/* Search for the APB-AP - it is needed for access to debug registers */
retval = dap_find_get_ap(swjdp, AP_TYPE_APB_AP, &armv7a->debug_ap);
if (retval != ERROR_OK) {
LOG_ERROR("Could not find APB-AP for debug access");
return retval;
}
} else {
armv7a->debug_ap = dap_get_ap(swjdp, pc->ap_num);
if (!armv7a->debug_ap) {
LOG_ERROR("Cannot get AP");
return ERROR_FAIL;
}
}
}

View File

@@ -879,16 +879,6 @@ static int cortex_m_poll(struct target *target)
struct cortex_m_common *cortex_m = target_to_cm(target);
struct armv7m_common *armv7m = &cortex_m->armv7m;
/* Check if debug_ap is available to prevent segmentation fault.
* If the re-examination after an error does not find a MEM-AP
* (e.g. the target stopped communicating), debug_ap pointer
* can suddenly become NULL.
*/
if (!armv7m->debug_ap) {
target->state = TARGET_UNKNOWN;
return ERROR_TARGET_NOT_EXAMINED;
}
/* Read from Debug Halting Control and Status Register */
retval = cortex_m_read_dhcsr_atomic_sticky(target);
if (retval != ERROR_OK) {
@@ -1408,8 +1398,9 @@ static int cortex_m_assert_reset(struct target *target)
struct armv7m_common *armv7m = &cortex_m->armv7m;
enum cortex_m_soft_reset_config reset_config = cortex_m->soft_reset_config;
LOG_TARGET_DEBUG(target, "target->state: %s",
target_state_name(target));
LOG_TARGET_DEBUG(target, "target->state: %s,%s examined",
target_state_name(target),
target_was_examined(target) ? "" : " not");
enum reset_types jtag_reset_config = jtag_get_reset_config();
@@ -1428,24 +1419,40 @@ static int cortex_m_assert_reset(struct target *target)
bool srst_asserted = false;
if (!target_was_examined(target)) {
if (jtag_reset_config & RESET_HAS_SRST) {
adapter_assert_reset();
if (target->reset_halt)
LOG_TARGET_ERROR(target, "Target not examined, will not halt after reset!");
return ERROR_OK;
} else {
LOG_TARGET_ERROR(target, "Target not examined, reset NOT asserted!");
return ERROR_FAIL;
}
}
if ((jtag_reset_config & RESET_HAS_SRST) &&
(jtag_reset_config & RESET_SRST_NO_GATING)) {
((jtag_reset_config & RESET_SRST_NO_GATING) || !armv7m->debug_ap)) {
/* If we have no debug_ap, asserting SRST is the only thing
* we can do now */
adapter_assert_reset();
srst_asserted = true;
}
/* TODO: replace the hack calling target_examine_one()
* as soon as a better reset framework is available */
if (!target_was_examined(target) && !target->defer_examine
&& srst_asserted && (jtag_reset_config & RESET_SRST_NO_GATING)) {
LOG_TARGET_DEBUG(target, "Trying to re-examine under reset");
target_examine_one(target);
}
/* We need at least debug_ap to go further.
* Inform user and bail out if we don't have one. */
if (!armv7m->debug_ap) {
if (srst_asserted) {
if (target->reset_halt)
LOG_TARGET_ERROR(target, "Debug AP not available, will not halt after reset!");
/* Do not propagate error: reset was asserted, proceed to deassert! */
target->state = TARGET_RESET;
register_cache_invalidate(cortex_m->armv7m.arm.core_cache);
return ERROR_OK;
} else {
LOG_TARGET_ERROR(target, "Debug AP not available, reset NOT asserted!");
return ERROR_FAIL;
}
}
/* Enable debug requests */
int retval = cortex_m_read_dhcsr_atomic_sticky(target);
@@ -1546,7 +1553,7 @@ static int cortex_m_assert_reset(struct target *target)
if (retval != ERROR_OK)
return retval;
if (target->reset_halt) {
if (target->reset_halt && target_was_examined(target)) {
retval = target_halt(target);
if (retval != ERROR_OK)
return retval;
@@ -1559,8 +1566,9 @@ static int cortex_m_deassert_reset(struct target *target)
{
struct armv7m_common *armv7m = &target_to_cm(target)->armv7m;
LOG_TARGET_DEBUG(target, "target->state: %s",
target_state_name(target));
LOG_TARGET_DEBUG(target, "target->state: %s,%s examined",
target_state_name(target),
target_was_examined(target) ? "" : " not");
/* deassert reset lines */
adapter_deassert_reset();
@@ -1568,8 +1576,8 @@ static int cortex_m_deassert_reset(struct target *target)
enum reset_types jtag_reset_config = jtag_get_reset_config();
if ((jtag_reset_config & RESET_HAS_SRST) &&
!(jtag_reset_config & RESET_SRST_NO_GATING) &&
target_was_examined(target)) {
!(jtag_reset_config & RESET_SRST_NO_GATING) &&
armv7m->debug_ap) {
int retval = dap_dp_init_or_reconnect(armv7m->debug_ap->dap);
if (retval != ERROR_OK) {
@@ -2262,6 +2270,22 @@ static void cortex_m_dwt_free(struct target *target)
cm->dwt_cache = NULL;
}
static bool cortex_m_has_tz(struct target *target)
{
struct armv7m_common *armv7m = target_to_armv7m(target);
uint32_t dauthstatus;
if (armv7m->arm.arch != ARM_ARCH_V8M)
return false;
int retval = target_read_u32(target, DAUTHSTATUS, &dauthstatus);
if (retval != ERROR_OK) {
LOG_WARNING("Error reading DAUTHSTATUS register");
return false;
}
return (dauthstatus & DAUTHSTATUS_SID_MASK) != 0;
}
#define MVFR0 0xe000ef40
#define MVFR1 0xe000ef44
@@ -2293,23 +2317,20 @@ int cortex_m_examine(struct target *target)
/* hla_target shares the examine handler but does not support
* all its calls */
if (!armv7m->is_hla_target) {
if (armv7m->debug_ap) {
dap_put_ap(armv7m->debug_ap);
armv7m->debug_ap = NULL;
}
if (cortex_m->apsel == DP_APSEL_INVALID) {
/* Search for the MEM-AP */
retval = cortex_m_find_mem_ap(swjdp, &armv7m->debug_ap);
if (retval != ERROR_OK) {
LOG_TARGET_ERROR(target, "Could not find MEM-AP to control the core");
return retval;
}
} else {
armv7m->debug_ap = dap_get_ap(swjdp, cortex_m->apsel);
if (!armv7m->debug_ap) {
LOG_ERROR("Cannot get AP");
return ERROR_FAIL;
if (!armv7m->debug_ap) {
if (cortex_m->apsel == DP_APSEL_INVALID) {
/* Search for the MEM-AP */
retval = cortex_m_find_mem_ap(swjdp, &armv7m->debug_ap);
if (retval != ERROR_OK) {
LOG_TARGET_ERROR(target, "Could not find MEM-AP to control the core");
return retval;
}
} else {
armv7m->debug_ap = dap_get_ap(swjdp, cortex_m->apsel);
if (!armv7m->debug_ap) {
LOG_ERROR("Cannot get AP");
return ERROR_FAIL;
}
}
}
@@ -2393,7 +2414,7 @@ int cortex_m_examine(struct target *target)
for (size_t idx = ARMV7M_FPU_FIRST_REG; idx <= ARMV7M_FPU_LAST_REG; idx++)
armv7m->arm.core_cache->reg_list[idx].exist = false;
if (armv7m->arm.arch != ARM_ARCH_V8M)
if (!cortex_m_has_tz(target))
for (size_t idx = ARMV8M_FIRST_REG; idx <= ARMV8M_LAST_REG; idx++)
armv7m->arm.core_cache->reg_list[idx].exist = false;

View File

@@ -68,6 +68,9 @@ struct cortex_m_part_info {
#define DCB_DEMCR 0xE000EDFC
#define DCB_DSCSR 0xE000EE08
#define DAUTHSTATUS 0xE000EFB8
#define DAUTHSTATUS_SID_MASK 0x00000030
#define DCRSR_WNR BIT(16)
#define DWT_CTRL 0xE0001000

View File

@@ -2140,7 +2140,7 @@ COMMAND_HANDLER(dsp563xx_mem_command)
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], count);
}
buffer = calloc(count, sizeof(uint32_t));
buffer = calloc(count, 4);
if (read_mem == 1) {
err = dsp563xx_read_memory(target, mem_type, address, sizeof(uint32_t),

View File

@@ -2200,8 +2200,8 @@ int dsp5680xx_f_lock(struct target *target)
struct jtag_tap *tap_chp;
struct jtag_tap *tap_cpu;
uint16_t lock_word[] = { HFM_LOCK_FLASH };
retval = dsp5680xx_f_wr(target, (uint8_t *) (lock_word), HFM_LOCK_ADDR_L, 2, 1);
uint16_t lock_word = HFM_LOCK_FLASH;
retval = dsp5680xx_f_wr(target, (uint8_t *)&lock_word, HFM_LOCK_ADDR_L, 2, 1);
err_check_propagate(retval);
jtag_add_reset(0, 1);

View File

@@ -130,7 +130,9 @@ static int esirisc_jtag_recv(struct esirisc_jtag *jtag_info,
int num_in_bytes = DIV_ROUND_UP(num_in_bits, 8);
struct scan_field fields[3];
uint8_t r[num_in_bytes * 2];
/* prevent zero-size variable length array */
int r_size = num_in_bytes ? num_in_bytes * 2 : 1;
uint8_t r[r_size];
esirisc_jtag_set_instr(jtag_info, INSTR_DEBUG);

View File

@@ -402,6 +402,8 @@ static int esp32s2_poll(struct target *target)
{
enum target_state old_state = target->state;
int ret = esp_xtensa_poll(target);
if (ret != ERROR_OK)
return ret;
if (old_state != TARGET_HALTED && target->state == TARGET_HALTED) {
/* Call any event callbacks that are applicable */

View File

@@ -347,6 +347,13 @@ static int hl_assert_reset(struct target *target)
adapter->layout->api->write_debug_reg(adapter->handle, DCB_DHCSR, DBGKEY|C_DEBUGEN);
if (!target_was_examined(target) && !target->defer_examine
&& srst_asserted && res == ERROR_OK) {
/* If the target is not examined, now under reset it is good time to retry examination */
LOG_TARGET_DEBUG(target, "Trying to re-examine under reset");
target_examine_one(target);
}
/* only set vector catch if halt is requested */
if (target->reset_halt)
adapter->layout->api->write_debug_reg(adapter->handle, DCB_DEMCR, TRCENA|VC_CORERESET);

View File

@@ -136,15 +136,12 @@ static int mem_ap_examine(struct target *target)
struct mem_ap *mem_ap = target->arch_info;
if (!target_was_examined(target)) {
if (mem_ap->ap) {
dap_put_ap(mem_ap->ap);
mem_ap->ap = NULL;
}
mem_ap->ap = dap_get_ap(mem_ap->dap, mem_ap->ap_num);
if (!mem_ap->ap) {
LOG_ERROR("Cannot get AP");
return ERROR_FAIL;
mem_ap->ap = dap_get_ap(mem_ap->dap, mem_ap->ap_num);
if (!mem_ap->ap) {
LOG_ERROR("Cannot get AP");
return ERROR_FAIL;
}
}
target_set_examined(target);
target->state = TARGET_UNKNOWN;

View File

@@ -900,7 +900,7 @@ static int mips_m4k_set_watchpoint(struct target *target,
LOG_ERROR("BUG: watchpoint->rw neither read, write nor access");
}
watchpoint->number = wp_num;
watchpoint_set(watchpoint, wp_num);
comparator_list[wp_num].used = 1;
comparator_list[wp_num].bp_value = watchpoint->address;

View File

@@ -934,7 +934,7 @@ static int or1k_adv_jtag_write_memory(struct or1k_jtag *jtag_info,
void *t = NULL;
struct target *target = jtag_info->target;
if ((target->endianness == TARGET_BIG_ENDIAN) && (size != 1)) {
t = malloc(count * size * sizeof(uint8_t));
t = calloc(count * size, sizeof(uint8_t));
if (!t) {
LOG_ERROR("Out of memory");
return ERROR_FAIL;
@@ -947,6 +947,9 @@ static int or1k_adv_jtag_write_memory(struct or1k_jtag *jtag_info,
case 2:
buf_bswap16(t, buffer, size * count);
break;
default:
free(t);
return ERROR_TARGET_FAILURE;
}
buffer = t;
}

View File

@@ -2359,9 +2359,7 @@ static int assert_reset(struct target *target)
/* TODO: Try to use hasel in dmcontrol */
/* Set haltreq for each hart. */
uint32_t control = control_base;
control = set_hartsel(control_base, target->coreid);
uint32_t control = set_hartsel(control_base, target->coreid);
control = set_field(control, DM_DMCONTROL_HALTREQ,
target->reset_halt ? 1 : 0);
dmi_write(target, DM_DMCONTROL, control);
@@ -4463,7 +4461,9 @@ static int riscv013_test_sba_config_reg(struct target *target,
uint32_t rd_val;
uint32_t sbcs_orig;
dmi_read(target, &sbcs_orig, DM_SBCS);
int retval = dmi_read(target, &sbcs_orig, DM_SBCS);
if (retval != ERROR_OK)
return retval;
uint32_t sbcs = sbcs_orig;
bool test_passed;

View File

@@ -453,10 +453,7 @@ static int riscv_init_target(struct command_context *cmd_ctx,
if (bscan_tunnel_ir_width != 0) {
assert(target->tap->ir_length >= 6);
uint32_t ir_user4_raw = 0x23 << (target->tap->ir_length - 6);
ir_user4[0] = (uint8_t)ir_user4_raw;
ir_user4[1] = (uint8_t)(ir_user4_raw >>= 8);
ir_user4[2] = (uint8_t)(ir_user4_raw >>= 8);
ir_user4[3] = (uint8_t)(ir_user4_raw >>= 8);
h_u32_to_le(ir_user4, ir_user4_raw);
select_user4.num_bits = target->tap->ir_length;
bscan_tunneled_ir_width[0] = bscan_tunnel_ir_width;
if (bscan_tunnel_type == BSCAN_TUNNEL_DATA_REGISTER)
@@ -713,7 +710,6 @@ static int add_trigger(struct target *target, struct trigger *trigger)
return result;
int type = get_field(tdata1, MCONTROL_TYPE(riscv_xlen(target)));
result = ERROR_OK;
switch (type) {
case 1:
result = maybe_add_trigger_t1(target, trigger, tdata1);
@@ -1611,6 +1607,7 @@ static int riscv_address_translate(struct target *target,
LOG_DEBUG("virtual=0x%" TARGET_PRIxADDR "; mode=%s", virtual, info->name);
/* verify bits xlen-1:va_bits-1 are all equal */
assert(xlen >= info->va_bits);
target_addr_t mask = ((target_addr_t)1 << (xlen - (info->va_bits - 1))) - 1;
target_addr_t masked_msbs = (virtual >> (info->va_bits - 1)) & mask;
if (masked_msbs != 0 && masked_msbs != mask) {
@@ -2669,27 +2666,25 @@ COMMAND_HANDLER(riscv_authdata_write)
uint32_t value;
unsigned int index = 0;
if (CMD_ARGC == 0) {
/* nop */
} else if (CMD_ARGC == 1) {
if (CMD_ARGC == 0 || CMD_ARGC > 2)
return ERROR_COMMAND_SYNTAX_ERROR;
if (CMD_ARGC == 1) {
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], value);
} else if (CMD_ARGC == 2) {
} else {
COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], index);
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], value);
} else {
LOG_ERROR("Command takes at most 2 arguments");
return ERROR_COMMAND_SYNTAX_ERROR;
}
struct target *target = get_current_target(CMD_CTX);
RISCV_INFO(r);
if (r->authdata_write) {
return r->authdata_write(target, value, index);
} else {
if (!r->authdata_write) {
LOG_ERROR("authdata_write is not implemented for this target.");
return ERROR_FAIL;
}
return r->authdata_write(target, value, index);
}
COMMAND_HANDLER(riscv_dmi_read)
@@ -2749,6 +2744,9 @@ COMMAND_HANDLER(riscv_dmi_write)
COMMAND_HANDLER(riscv_test_sba_config_reg)
{
LOG_WARNING("Command \"riscv test_sba_config_reg\" is deprecated. "
"It will be removed in a future OpenOCD version.");
if (CMD_ARGC != 4) {
LOG_ERROR("Command takes exactly 4 arguments");
return ERROR_COMMAND_SYNTAX_ERROR;

View File

@@ -114,10 +114,21 @@ proc ocd_process_reset_inner { MODE } {
continue
}
# don't wait for targets where examination is deferred
# they can not be halted anyway at this point
if { ![$t was_examined] && [$t examine_deferred] } {
continue
if { ![$t was_examined] } {
# don't wait for targets where examination is deferred
# they can not be halted anyway at this point
if { [$t examine_deferred] } {
continue
}
# try to re-examine or target state will be unknown
$t invoke-event examine-start
set err [catch "$t arp_examine allow-defer"]
if { $err } {
$t invoke-event examine-fail
return -code error [format "TARGET: %s - Not examined" $t]
} else {
$t invoke-event examine-end
}
}
# Wait up to 1 second for target to halt. Why 1sec? Cause

View File

@@ -4251,11 +4251,19 @@ static void write_gmon(uint32_t *samples, uint32_t sample_num, const char *filen
/* max should be (largest sample + 1)
* Refer to binutils/gprof/hist.c (find_histogram_for_pc) */
max++;
if (max < UINT32_MAX)
max++;
/* gprof requires (max - min) >= 2 */
while ((max - min) < 2) {
if (max < UINT32_MAX)
max++;
else
min--;
}
}
int address_space = max - min;
assert(address_space >= 2);
uint32_t address_space = max - min;
/* FIXME: What is the reasonable number of buckets?
* The profiling result will be more accurate if there are enough buckets. */
@@ -4331,6 +4339,19 @@ COMMAND_HANDLER(handle_profile_command)
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], offset);
uint32_t start_address = 0;
uint32_t end_address = 0;
bool with_range = false;
if (CMD_ARGC == 4) {
with_range = true;
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], start_address);
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[3], end_address);
if (start_address > end_address || (end_address - start_address) < 2) {
command_print(CMD, "Error: end - start < 2");
return ERROR_COMMAND_ARGUMENT_INVALID;
}
}
uint32_t *samples = malloc(sizeof(uint32_t) * MAX_PROFILE_SAMPLE_NUM);
if (!samples) {
LOG_ERROR("No memory to store samples.");
@@ -4383,15 +4404,6 @@ COMMAND_HANDLER(handle_profile_command)
return retval;
}
uint32_t start_address = 0;
uint32_t end_address = 0;
bool with_range = false;
if (CMD_ARGC == 4) {
with_range = true;
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], start_address);
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[3], end_address);
}
write_gmon(samples, num_of_samples, CMD_ARGV[1],
with_range, start_address, end_address, target, duration_ms);
command_print(CMD, "Wrote %s", CMD_ARGV[1]);
@@ -4717,7 +4729,7 @@ static int target_jim_read_memory(Jim_Interp *interp, int argc,
break;
}
char value_buf[11];
char value_buf[19];
snprintf(value_buf, sizeof(value_buf), "0x%" PRIx64, v);
Jim_ListAppendElement(interp, result_list,
@@ -6433,16 +6445,52 @@ static int jim_target_names(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
return JIM_OK;
}
static struct target_list *
__attribute__((warn_unused_result))
create_target_list_node(Jim_Obj *const name) {
int len;
const char *targetname = Jim_GetString(name, &len);
struct target *target = get_target(targetname);
LOG_DEBUG("%s ", targetname);
if (!target)
return NULL;
struct target_list *new = malloc(sizeof(struct target_list));
if (!new) {
LOG_ERROR("Out of memory");
return new;
}
new->target = target;
return new;
}
static int get_target_with_common_rtos_type(struct list_head *lh, struct target **result)
{
struct target *target = NULL;
struct target_list *curr;
foreach_smp_target(curr, lh) {
struct rtos *curr_rtos = curr->target->rtos;
if (curr_rtos) {
if (target && target->rtos && target->rtos->type != curr_rtos->type) {
LOG_ERROR("Different rtos types in members of one smp target!");
return JIM_ERR;
}
target = curr->target;
}
}
*result = target;
return JIM_OK;
}
static int jim_target_smp(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
int i;
const char *targetname;
int retval, len;
static int smp_group = 1;
struct target *target = NULL;
struct target_list *head, *new;
retval = 0;
if (argc == 1) {
LOG_DEBUG("Empty SMP target");
return JIM_OK;
}
LOG_DEBUG("%d", argc);
/* argv[1] = target to associate in smp
* argv[2] = target to associate in smp
@@ -6456,27 +6504,24 @@ static int jim_target_smp(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
}
INIT_LIST_HEAD(lh);
for (i = 1; i < argc; i++) {
targetname = Jim_GetString(argv[i], &len);
target = get_target(targetname);
LOG_DEBUG("%s ", targetname);
if (target) {
new = malloc(sizeof(struct target_list));
new->target = target;
for (int i = 1; i < argc; i++) {
struct target_list *new = create_target_list_node(argv[i]);
if (new)
list_add_tail(&new->lh, lh);
}
}
/* now parse the list of cpu and put the target in smp mode*/
foreach_smp_target(head, lh) {
target = head->target;
struct target_list *curr;
foreach_smp_target(curr, lh) {
struct target *target = curr->target;
target->smp = smp_group;
target->smp_targets = lh;
}
smp_group++;
if (target && target->rtos)
retval = rtos_smp_init(target);
struct target *rtos_target;
int retval = get_target_with_common_rtos_type(lh, &rtos_target);
if (retval == JIM_OK && rtos_target)
retval = rtos_smp_init(rtos_target);
return retval;
}

View File

@@ -168,8 +168,9 @@
#define XT_REG_A3 (xtensa_regs[XT_REG_IDX_AR3].reg_num)
#define XT_REG_A4 (xtensa_regs[XT_REG_IDX_AR4].reg_num)
#define XT_PS_REG_NUM_BASE (0xc0U) /* (EPS2 - 2), for adding DBGLEVEL */
#define XT_PC_REG_NUM_BASE (0xb0U) /* (EPC1 - 1), for adding DBGLEVEL */
#define XT_PS_REG_NUM (0xe6U)
#define XT_EPS_REG_NUM_BASE (0xc0U) /* (EPS2 - 2), for adding DBGLEVEL */
#define XT_EPC_REG_NUM_BASE (0xb0U) /* (EPC1 - 1), for adding DBGLEVEL */
#define XT_PC_REG_NUM_VIRTUAL (0xffU) /* Marker for computing PC (EPC[DBGLEVEL) */
#define XT_PC_DBREG_NUM_BASE (0x20U) /* External (i.e., GDB) access */
@@ -245,7 +246,7 @@ struct xtensa_reg_desc xtensa_regs[XT_NUM_REGS] = {
XT_MK_REG_DESC("ar63", 0x3F, XT_REG_GENERAL, 0),
XT_MK_REG_DESC("windowbase", 0x48, XT_REG_SPECIAL, 0),
XT_MK_REG_DESC("windowstart", 0x49, XT_REG_SPECIAL, 0),
XT_MK_REG_DESC("ps", 0xE6, XT_REG_SPECIAL, 0), /* PS (not mapped through EPS[]) */
XT_MK_REG_DESC("ps", XT_PS_REG_NUM, XT_REG_SPECIAL, 0), /* PS (not mapped through EPS[]) */
XT_MK_REG_DESC("ibreakenable", 0x60, XT_REG_SPECIAL, 0),
XT_MK_REG_DESC("ddr", 0x68, XT_REG_DEBUG, XT_REGF_NOREAD),
XT_MK_REG_DESC("ibreaka0", 0x80, XT_REG_SPECIAL, 0),
@@ -630,7 +631,7 @@ static int xtensa_write_dirty_registers(struct target *target)
/* reg number of PC for debug interrupt depends on NDEBUGLEVEL
**/
reg_num =
(XT_PC_REG_NUM_BASE +
(XT_EPC_REG_NUM_BASE +
xtensa->core_config->debug.irq_level);
xtensa_queue_exec_ins(xtensa, XT_INS_WSR(xtensa, reg_num, XT_REG_A3));
}
@@ -1105,10 +1106,10 @@ int xtensa_fetch_all_regs(struct target *target)
case XT_REG_SPECIAL:
if (reg_num == XT_PC_REG_NUM_VIRTUAL) {
/* reg number of PC for debug interrupt depends on NDEBUGLEVEL */
reg_num = (XT_PC_REG_NUM_BASE + xtensa->core_config->debug.irq_level);
reg_num = XT_EPC_REG_NUM_BASE + xtensa->core_config->debug.irq_level;
} else if (reg_num == xtensa_regs[XT_REG_IDX_PS].reg_num) {
/* reg number of PS for debug interrupt depends on NDEBUGLEVEL */
reg_num = (XT_PS_REG_NUM_BASE + xtensa->core_config->debug.irq_level);
reg_num = XT_EPS_REG_NUM_BASE + xtensa->core_config->debug.irq_level;
} else if (reg_num == xtensa_regs[XT_REG_IDX_CPENABLE].reg_num) {
/* CPENABLE already read/updated; don't re-read */
reg_fetched = false;
@@ -1629,7 +1630,6 @@ int xtensa_do_step(struct target *target, int current, target_addr_t address, in
target->debug_reason = DBG_REASON_SINGLESTEP;
target->state = TARGET_HALTED;
target_call_event_callbacks(target, TARGET_EVENT_HALTED);
LOG_DEBUG("Done stepping, PC=%" PRIX32, cur_pc);
if (cause & DEBUGCAUSE_DB) {
@@ -1657,7 +1657,12 @@ int xtensa_do_step(struct target *target, int current, target_addr_t address, in
int xtensa_step(struct target *target, int current, target_addr_t address, int handle_breakpoints)
{
return xtensa_do_step(target, current, address, handle_breakpoints);
int retval = xtensa_do_step(target, current, address, handle_breakpoints);
if (retval != ERROR_OK)
return retval;
target_call_event_callbacks(target, TARGET_EVENT_HALTED);
return ERROR_OK;
}
/**
@@ -1738,15 +1743,12 @@ int xtensa_read_memory(struct target *target, target_addr_t address, uint32_t si
}
}
if (addrstart_al == address && addrend_al == address + (size * count)) {
albuff = buffer;
} else {
albuff = malloc(addrend_al - addrstart_al);
if (!albuff) {
LOG_TARGET_ERROR(target, "Out of memory allocating %" TARGET_PRIdADDR " bytes!",
addrend_al - addrstart_al);
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
}
unsigned int alloc_bytes = ALIGN_UP(addrend_al - addrstart_al, sizeof(uint32_t));
albuff = calloc(alloc_bytes, 1);
if (!albuff) {
LOG_TARGET_ERROR(target, "Out of memory allocating %" PRId64 " bytes!",
addrend_al - addrstart_al);
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
}
/* We're going to use A3 here */
@@ -1783,9 +1785,9 @@ int xtensa_read_memory(struct target *target, target_addr_t address, uint32_t si
if (res != ERROR_OK) {
if (xtensa->probe_lsddr32p != 0) {
/* Disable fast memory access instructions and retry before reporting an error */
LOG_TARGET_INFO(target, "Disabling LDDR32.P/SDDR32.P");
LOG_TARGET_DEBUG(target, "Disabling LDDR32.P/SDDR32.P");
xtensa->probe_lsddr32p = 0;
res = xtensa_read_memory(target, address, size, count, buffer);
res = xtensa_read_memory(target, address, size, count, albuff);
bswap = false;
} else {
LOG_TARGET_WARNING(target, "Failed reading %d bytes at address "TARGET_ADDR_FMT,
@@ -1795,11 +1797,8 @@ int xtensa_read_memory(struct target *target, target_addr_t address, uint32_t si
if (bswap)
buf_bswap32(albuff, albuff, addrend_al - addrstart_al);
if (albuff != buffer) {
memcpy(buffer, albuff + (address & 3), (size * count));
free(albuff);
}
memcpy(buffer, albuff + (address & 3), (size * count));
free(albuff);
return res;
}
@@ -1855,7 +1854,7 @@ int xtensa_write_memory(struct target *target,
albuff = malloc(addrend_al - addrstart_al);
}
if (!albuff) {
LOG_TARGET_ERROR(target, "Out of memory allocating %" TARGET_PRIdADDR " bytes!",
LOG_TARGET_ERROR(target, "Out of memory allocating %" PRId64 " bytes!",
addrend_al - addrstart_al);
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
}
@@ -2508,6 +2507,12 @@ static int xtensa_build_reg_cache(struct target *target)
unsigned int j;
for (j = 0; j < reg_cache->num_regs; j++) {
if (!strcmp(reg_cache->reg_list[j].name, xtensa->contiguous_regs_desc[i]->name)) {
/* Register number field is not filled above.
Here we are assigning the corresponding index from the contiguous reg list.
These indexes are in the same order with gdb g-packet request/response.
Some more changes may be required for sparse reg lists.
*/
reg_cache->reg_list[j].number = i;
xtensa->contiguous_regs_list[i] = &(reg_cache->reg_list[j]);
LOG_TARGET_DEBUG(target,
"POPULATE contiguous regs list: %-16s, dbreg_num 0x%04x",
@@ -3447,8 +3452,8 @@ COMMAND_HELPER(xtensa_cmd_xtreg_do, struct xtensa *xtensa)
else
rptr->flags = 0;
if ((rptr->reg_num == (XT_PS_REG_NUM_BASE + xtensa->core_config->debug.irq_level)) &&
(xtensa->core_config->core_type == XT_LX) && (rptr->type == XT_REG_SPECIAL)) {
if (rptr->reg_num == (XT_EPS_REG_NUM_BASE + xtensa->core_config->debug.irq_level) &&
xtensa->core_config->core_type == XT_LX && rptr->type == XT_REG_SPECIAL) {
xtensa->eps_dbglevel_idx = XT_NUM_REGS + xtensa->num_optregs - 1;
LOG_DEBUG("Setting PS (%s) index to %d", rptr->name, xtensa->eps_dbglevel_idx);
}

View File

@@ -9,7 +9,7 @@ if { [info exists CHIPNAME] } {
set _CHIPNAME xcu
}
# The cvarious chips in the Ultrascale family have different IR length.
# The various chips in the Ultrascale family have different IR length.
# Set $CHIP before including this file to determine the device.
array set _XCU_DATA {
XCKU025 {0x03824093 6}

View File

@@ -15,9 +15,9 @@ adapter driver bcm2835gpio
bcm2835gpio peripheral_base 0x3F000000
# Transition delay calculation: SPEED_COEFF/khz - SPEED_OFFSET
# These depend on system clock, calibrated for stock 700MHz
# These depend on system clock, calibrated for scaling_max_freq 900MHz
# bcm2835gpio speed SPEED_COEFF SPEED_OFFSET
bcm2835gpio speed_coeffs 146203 36
bcm2835gpio speed_coeffs 225000 36
# Each of the JTAG lines need a gpio number set: tck tms tdi tdo
# Header pin numbers: 23 22 19 21

View File

@@ -16,8 +16,10 @@ if {[using_jtag]} {
swd newdap max32620 cpu -irlen 4 -irmask 0xf -expected-id 0x2ba01477 -ignore-version
}
dap create max32620.dap -chain-position max32620.cpu
# target configuration
target create max32620.cpu cortex_m -chain-position max32620.cpu
target create max32620.cpu cortex_m -dap max32620.dap
max32620.cpu configure -work-area-phys 0x20005000 -work-area-size 0x2000
# Config Command: flash bank name driver base size chip_width bus_width target [driver_options]

View File

@@ -16,8 +16,10 @@ if {[using_jtag]} {
swd newdap max32625 cpu -irlen 4 -irmask 0xf -expected-id 0x2ba01477 -ignore-version
}
dap create max32625.dap -chain-position max32625.cpu
# target configuration
target create max32625.cpu cortex_m -chain-position max32625.cpu
target create max32625.cpu cortex_m -dap max32625.dap
max32625.cpu configure -work-area-phys 0x20005000 -work-area-size 0x2000
# Config Command: flash bank name driver base size chip_width bus_width target [driver_options]

View File

@@ -16,8 +16,10 @@ if {[using_jtag]} {
swd newdap max3263x cpu -irlen 4 -irmask 0xf -expected-id 0x2ba01477 -ignore-version
}
dap create max3263x.dap -chain-position max3263x.cpu
# target configuration
target create max3263x.cpu cortex_m -chain-position max3263x.cpu
target create max3263x.cpu cortex_m -dap max3263x.dap
max3263x.cpu configure -work-area-phys 0x20005000 -work-area-size 0x2000
# Config Command: flash bank name driver base size chip_width bus_width target [driver_options]

View File

@@ -1,5 +1,17 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# RP2040 is a microcontroller with dual Cortex-M0+ core.
# https://www.raspberrypi.com/documentation/microcontrollers/rp2040.html
# The device requires multidrop SWD for debug.
# This configuration file is intended for a special adapter
# which selects a multidrop target on its own.
# Cannot be used with a standard SWD adapter!
echo "Warn : rp2040-core0.cfg configuration file is deprecated and will be"
echo " removed in the next release. Use following parameters instead:"
echo " -c 'set USE_CORE 0' -f target/rp2040.cfg"
transport select swd
source [find target/swj-dp.tcl]
@@ -26,7 +38,10 @@ swj_newdap $_CHIPNAME cpu -expected-id $_CPUTAPID
dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.cpu
set _TARGETNAME $_CHIPNAME.cpu
target create $_TARGETNAME cortex_m -dap $_CHIPNAME.dap
$_TARGETNAME configure -work-area-phys 0x20010000 -work-area-size $_WORKAREASIZE
# Backup the work area. The flash probe runs an algorithm on the target CPU.
# The flash is probed during gdb connect if gdb_memory_map is enabled (by default).
$_TARGETNAME configure -work-area-phys 0x20010000 -work-area-size $_WORKAREASIZE -work-area-backup 1
set _FLASHNAME $_CHIPNAME.flash
set _FLASHSIZE 0x200000

74
tcl/target/rp2040.cfg Normal file
View File

@@ -0,0 +1,74 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# RP2040 is a microcontroller with dual Cortex-M0+ core.
# https://www.raspberrypi.com/documentation/microcontrollers/rp2040.html
# The device requires multidrop SWD for debug.
transport select swd
source [find target/swj-dp.tcl]
if { [info exists CHIPNAME] } {
set _CHIPNAME $CHIPNAME
} else {
set _CHIPNAME rp2040
}
if { [info exists WORKAREASIZE] } {
set _WORKAREASIZE $WORKAREASIZE
} else {
set _WORKAREASIZE 0x10000
}
if { [info exists CPUTAPID] } {
set _CPUTAPID $CPUTAPID
} else {
set _CPUTAPID 0x01002927
}
# Set to '0' or '1' for single core configuration,
# anything else for isolated debugging of both cores
if { [info exists USE_CORE] } {
set _USE_CORE $USE_CORE
} else {
set _USE_CORE { 0 1 }
}
set _BOTH_CORES [expr { $_USE_CORE != 0 && $_USE_CORE != 1 }]
swj_newdap $_CHIPNAME cpu -expected-id $_CPUTAPID
# core 0
if { $_USE_CORE != 1 } {
dap create $_CHIPNAME.dap0 -chain-position $_CHIPNAME.cpu -dp-id $_CPUTAPID -instance-id 0
set _TARGETNAME_0 $_CHIPNAME.core0
target create $_TARGETNAME_0 cortex_m -dap $_CHIPNAME.dap0 -coreid 0
# srst does not exist; use SYSRESETREQ to perform a soft reset
$_TARGETNAME_0 cortex_m reset_config sysresetreq
}
# core 1
if { $_USE_CORE != 0 } {
dap create $_CHIPNAME.dap1 -chain-position $_CHIPNAME.cpu -dp-id $_CPUTAPID -instance-id 1
set _TARGETNAME_1 $_CHIPNAME.core1
target create $_TARGETNAME_1 cortex_m -dap $_CHIPNAME.dap1 -coreid 1
$_TARGETNAME_1 cortex_m reset_config sysresetreq
}
if { $_USE_CORE == 1 } {
set _FLASH_TARGET $_TARGETNAME_1
} else {
set _FLASH_TARGET $_TARGETNAME_0
}
# Backup the work area. The flash probe runs an algorithm on the target CPU.
# The flash is probed during gdb connect if gdb_memory_map is enabled (by default).
$_FLASH_TARGET configure -work-area-phys 0x20010000 -work-area-size $_WORKAREASIZE -work-area-backup 1
set _FLASHNAME $_CHIPNAME.flash
flash bank $_FLASHNAME rp2040_flash 0x10000000 0 0 0 $_FLASH_TARGET
if { $_BOTH_CORES } {
# Alias to ensure gdb connecting to core 1 gets the correct memory map
flash bank $_CHIPNAME.alias virtual 0x10000000 0 0 0 $_TARGETNAME_1 $_FLASHNAME
# Select core 0
targets $_TARGETNAME_0
}

View File

@@ -58,7 +58,9 @@ if {[using_jtag]} {
reset_config srst_nogate
if {![using_hla]} {
if {[using_hla]} {
echo "Warn : The selected adapter does not support debugging this device in secure mode"
} else {
# if srst is not fitted use SYSRESETREQ to
# perform a soft reset
cortex_m reset_config sysresetreq
@@ -71,13 +73,18 @@ proc stm32x5x_is_secure {} {
}
proc stm32x5x_ahb_ap_non_secure_access {} {
# SPROT=1=Non Secure access, Priv=1
[[target current] cget -dap] apcsw 0x4B000000 0x4F000000
# in HLA mode, non-secure debugging is possible without changing the AP CSW
if {![using_hla]} {
# SPROT=1=Non Secure access, Priv=1
[[target current] cget -dap] apcsw 0x4B000000 0x4F000000
}
}
proc stm32x5x_ahb_ap_secure_access {} {
# SPROT=0=Secure access, Priv=1
[[target current] cget -dap] apcsw 0x0B000000 0x4F000000
if {![using_hla]} {
# SPROT=0=Secure access, Priv=1
[[target current] cget -dap] apcsw 0x0B000000 0x4F000000
}
}
$_TARGETNAME configure -event reset-start {
@@ -152,10 +159,11 @@ lappend _telnet_autocomplete_skip _proc_pre_enable_$_CHIPNAME.tpiu
proc _proc_pre_enable_$_CHIPNAME.tpiu {_targetname} {
targets $_targetname
# Set TRACE_IOEN; TRACE_MODE is set to async; when using sync
# change this value accordingly to configure trace pins
# Set TRACE_EN and TRACE_IOEN in DBGMCU_CR
# Leave TRACE_MODE untouched (defaults to async).
# When using sync change this value accordingly to configure trace pins
# assignment
mmw 0xE0044004 0x00000020 0
mmw 0xE0044004 0x00000030 0
}
$_CHIPNAME.tpiu configure -event pre-enable "_proc_pre_enable_$_CHIPNAME.tpiu $_TARGETNAME"

View File

@@ -12,6 +12,8 @@
# Has 2 ARMV8 Cores and 4 R5 Cores, M4F and an M3
#
source [find target/swj-dp.tcl]
if { [info exists SOC] } {
set _soc $SOC
} else {
@@ -164,7 +166,8 @@ switch $_soc {
}
}
jtag newtap $_CHIPNAME cpu -irlen 4 -expected-id $_K3_DAP_TAPID -ignore-version
swj_newdap $_CHIPNAME cpu -irlen 4 -expected-id $_K3_DAP_TAPID -ignore-version
dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.cpu
set _TARGETNAME $_CHIPNAME.cpu

View File

@@ -22,6 +22,7 @@ xtensa xtmem irom 0x40000000 0x64F00
xtensa xtmem iram 0x40070000 0x30000
xtensa xtmem iram 0x400C0000 0x2000
xtensa xtmem drom 0x3F400000 0x800000
xtensa xtmem drom 0x3FF90000 0x10000
xtensa xtmem dram 0x3FFAE000 0x52000
xtensa xtmem dram 0x3FF80000 0x2000
xtensa xtmem dram 0x3F800000 0x400000
@@ -35,7 +36,7 @@ xtensa xtmem dram 0x60000000 0x20000000
xtensa xtopt debuglevel 6
xtensa xtopt ibreaknum 2
xtensa xtopt dbreaknum 2
xtensa xtopt tracemem 8192
xtensa xtopt tracemem 0x4000
xtensa xtopt tracememrev 1
xtensa xtopt perfcount 2
@@ -46,7 +47,7 @@ xtensa xtopt perfcount 2
# in "Read General Registers" (g-packet) requests.
# NOTE: For contiguous format, registers listed in GDB order.
# xtregs: Total number of Xtensa registers in the system
xtensa xtregs 205
xtensa xtregs 173
xtensa xtregfmt contiguous 105
xtensa xtreg pc 0x0020
xtensa xtreg ar0 0x0100
@@ -123,8 +124,6 @@ xtensa xtreg configid0 0x02b0
xtensa xtreg configid1 0x02d0
xtensa xtreg ps 0x02e6
xtensa xtreg threadptr 0x03e7
# added by hand for esp32
xtensa xtreg br 0x0204
xtensa xtreg scompare1 0x020c
xtensa xtreg acclo 0x0210
@@ -155,13 +154,10 @@ xtensa xtreg f14 0x003e
xtensa xtreg f15 0x003f
xtensa xtreg fcr 0x03e8
xtensa xtreg fsr 0x03e9
xtensa xtreg mmid 0x0259
xtensa xtreg ibreakenable 0x0260
xtensa xtreg memctl 0x0261
xtensa xtreg atomctl 0x0263
xtensa xtreg ddr 0x0268
xtensa xtreg ibreaka0 0x0280
xtensa xtreg ibreaka1 0x0281
@@ -226,35 +222,3 @@ xtensa xtreg a12 0x000c
xtensa xtreg a13 0x000d
xtensa xtreg a14 0x000e
xtensa xtreg a15 0x000f
xtensa xtreg pwrctl 0x2028
xtensa xtreg pwrstat 0x2029
xtensa xtreg eristat 0x202a
xtensa xtreg cs_itctrl 0x202b
xtensa xtreg cs_claimset 0x202c
xtensa xtreg cs_claimclr 0x202d
xtensa xtreg cs_lockaccess 0x202e
xtensa xtreg cs_lockstatus 0x202f
xtensa xtreg cs_authstatus 0x2030
xtensa xtreg fault_info 0x203f
xtensa xtreg trax_id 0x2040
xtensa xtreg trax_control 0x2041
xtensa xtreg trax_status 0x2042
xtensa xtreg trax_data 0x2043
xtensa xtreg trax_address 0x2044
xtensa xtreg trax_pctrigger 0x2045
xtensa xtreg trax_pcmatch 0x2046
xtensa xtreg trax_delay 0x2047
xtensa xtreg trax_memstart 0x2048
xtensa xtreg trax_memend 0x2049
xtensa xtreg pmg 0x2057
xtensa xtreg pmpc 0x2058
xtensa xtreg pm0 0x2059
xtensa xtreg pm1 0x205a
xtensa xtreg pmctrl0 0x2061
xtensa xtreg pmctrl1 0x2062
xtensa xtreg pmstat0 0x2069
xtensa xtreg pmstat1 0x206a
xtensa xtreg ocdid 0x2071
xtensa xtreg ocd_dcrclr 0x2072
xtensa xtreg ocd_dcrset 0x2073
xtensa xtreg ocd_dsr 0x2074

View File

@@ -23,6 +23,7 @@ xtensa xtmem iram 0x40020000 0x50000
xtensa xtmem iram 0x40070000 0x2000
xtensa xtmem drom 0x3F000000 0x400000
xtensa xtmem drom 0x3F4D3FFC 0xAAC004
xtensa xtmem drom 0x3FFA0000 0x10000
xtensa xtmem dram 0x3FFB0000 0x50000
xtensa xtmem dram 0x3FF9E000 0x2000
xtensa xtmem dram 0x50000000 0x2000
@@ -36,8 +37,8 @@ xtensa xtmem dram 0x60000000 0x20000000
xtensa xtopt debuglevel 6
xtensa xtopt ibreaknum 2
xtensa xtopt dbreaknum 2
xtensa xtopt tracemem 8192
xtensa xtopt tracememrev 1
xtensa xtopt tracemem 0x4000
xtensa xtopt tracememrev 0
xtensa xtopt perfcount 2
# Core Registers
@@ -48,7 +49,7 @@ xtensa xtopt perfcount 2
# NOTE: For contiguous format, registers listed in GDB order.
# xtregs: Total number of Xtensa registers in the system
xtensa xtregs 171
xtensa xtregfmt contiguous 72
xtensa xtregfmt contiguous 73
xtensa xtreg pc 0x0020
xtensa xtreg ar0 0x0100
xtensa xtreg ar1 0x0101
@@ -121,8 +122,7 @@ xtensa xtreg configid0 0x02b0
xtensa xtreg configid1 0x02d0
xtensa xtreg ps 0x02e6
xtensa xtreg threadptr 0x03e7
# gpio_out should be 0x0300? Hits an exception on wrover
xtensa xtreg gpio_out 0x0268
xtensa xtreg gpio_out 0x0300
xtensa xtreg mmid 0x0259
xtensa xtreg ibreakenable 0x0260
xtensa xtreg ddr 0x0268
@@ -173,6 +173,38 @@ xtensa xtreg misc0 0x02f4
xtensa xtreg misc1 0x02f5
xtensa xtreg misc2 0x02f6
xtensa xtreg misc3 0x02f7
xtensa xtreg pwrctl 0x2014
xtensa xtreg pwrstat 0x2015
xtensa xtreg eristat 0x2016
xtensa xtreg cs_itctrl 0x2017
xtensa xtreg cs_claimset 0x2018
xtensa xtreg cs_claimclr 0x2019
xtensa xtreg cs_lockaccess 0x201a
xtensa xtreg cs_lockstatus 0x201b
xtensa xtreg cs_authstatus 0x201c
xtensa xtreg fault_info 0x202b
xtensa xtreg trax_id 0x202c
xtensa xtreg trax_control 0x202d
xtensa xtreg trax_status 0x202e
xtensa xtreg trax_data 0x202f
xtensa xtreg trax_address 0x2030
xtensa xtreg trax_pctrigger 0x2031
xtensa xtreg trax_pcmatch 0x2032
xtensa xtreg trax_delay 0x2033
xtensa xtreg trax_memstart 0x2034
xtensa xtreg trax_memend 0x2035
xtensa xtreg pmg 0x2043
xtensa xtreg pmpc 0x2044
xtensa xtreg pm0 0x2045
xtensa xtreg pm1 0x2046
xtensa xtreg pmctrl0 0x2047
xtensa xtreg pmctrl1 0x2048
xtensa xtreg pmstat0 0x2049
xtensa xtreg pmstat1 0x204a
xtensa xtreg ocdid 0x204b
xtensa xtreg ocd_dcrclr 0x204c
xtensa xtreg ocd_dcrset 0x204d
xtensa xtreg ocd_dsr 0x204e
xtensa xtreg a0 0x0000
xtensa xtreg a1 0x0001
xtensa xtreg a2 0x0002
@@ -189,35 +221,3 @@ xtensa xtreg a12 0x000c
xtensa xtreg a13 0x000d
xtensa xtreg a14 0x000e
xtensa xtreg a15 0x000f
xtensa xtreg pwrctl 0x2028
xtensa xtreg pwrstat 0x2029
xtensa xtreg eristat 0x202a
xtensa xtreg cs_itctrl 0x202b
xtensa xtreg cs_claimset 0x202c
xtensa xtreg cs_claimclr 0x202d
xtensa xtreg cs_lockaccess 0x202e
xtensa xtreg cs_lockstatus 0x202f
xtensa xtreg cs_authstatus 0x2030
xtensa xtreg fault_info 0x203f
xtensa xtreg trax_id 0x2040
xtensa xtreg trax_control 0x2041
xtensa xtreg trax_status 0x2042
xtensa xtreg trax_data 0x2043
xtensa xtreg trax_address 0x2044
xtensa xtreg trax_pctrigger 0x2045
xtensa xtreg trax_pcmatch 0x2046
xtensa xtreg trax_delay 0x2047
xtensa xtreg trax_memstart 0x2048
xtensa xtreg trax_memend 0x2049
xtensa xtreg pmg 0x2057
xtensa xtreg pmpc 0x2058
xtensa xtreg pm0 0x2059
xtensa xtreg pm1 0x205a
xtensa xtreg pmctrl0 0x2061
xtensa xtreg pmctrl1 0x2062
xtensa xtreg pmstat0 0x2069
xtensa xtreg pmstat1 0x206a
xtensa xtreg ocdid 0x2071
xtensa xtreg ocd_dcrclr 0x2072
xtensa xtreg ocd_dcrset 0x2073
xtensa xtreg ocd_dsr 0x2074

View File

@@ -20,6 +20,7 @@ xtensa xtmem irom 0x40000000 0x60000
xtensa xtmem iram 0x40370000 0x70000
xtensa xtmem iram 0x600FE000 0x2000
xtensa xtmem drom 0x3C000000 0x1000000
xtensa xtmem drom 0x3FF00000 0x20000
xtensa xtmem dram 0x3FC88000 0x78000
xtensa xtmem dram 0x600FE000 0x2000
xtensa xtmem dram 0x50000000 0x2000
@@ -31,8 +32,8 @@ xtensa xtmem dram 0x60000000 0x10000000
xtensa xtopt debuglevel 6
xtensa xtopt ibreaknum 2
xtensa xtopt dbreaknum 2
xtensa xtopt tracemem 16384
xtensa xtopt tracememrev 1
xtensa xtopt tracemem 0x4000
xtensa xtopt tracememrev 0
xtensa xtopt perfcount 2
@@ -43,7 +44,7 @@ xtensa xtopt perfcount 2
# in "Read General Registers" (g-packet) requests.
# NOTE: For contiguous format, registers listed in GDB order.
# xtregs: Total number of Xtensa registers in the system
xtensa xtregs 244
xtensa xtregs 228
xtensa xtregfmt contiguous 128
xtensa xtreg pc 0x0020
xtensa xtreg ar0 0x0100
@@ -128,10 +129,7 @@ xtensa xtreg m0 0x0220
xtensa xtreg m1 0x0221
xtensa xtreg m2 0x0222
xtensa xtreg m3 0x0223
# TODO: update gpioout address while testing on S3 HW
xtensa xtreg gpioout 0x02f4
xtensa xtreg gpio_out 0x030c
xtensa xtreg f0 0x0030
xtensa xtreg f1 0x0031
xtensa xtreg f2 0x0032
@@ -150,35 +148,32 @@ xtensa xtreg f14 0x003e
xtensa xtreg f15 0x003f
xtensa xtreg fcr 0x03e8
xtensa xtreg fsr 0x03e9
# TODO: update TIE state
xtensa xtreg accx_0 0x02f4
xtensa xtreg accx_1 0x02f4
xtensa xtreg qacc_h_0 0x02f4
xtensa xtreg qacc_h_1 0x02f4
xtensa xtreg qacc_h_2 0x02f4
xtensa xtreg qacc_h_3 0x02f4
xtensa xtreg qacc_h_4 0x02f4
xtensa xtreg qacc_l_0 0x02f4
xtensa xtreg qacc_l_1 0x02f4
xtensa xtreg qacc_l_2 0x02f4
xtensa xtreg qacc_l_3 0x02f4
xtensa xtreg qacc_l_4 0x02f4
xtensa xtreg sar_byte 0x02f4
xtensa xtreg fft_bit_width 0x02f4
xtensa xtreg ua_state_0 0x02f4
xtensa xtreg ua_state_1 0x02f4
xtensa xtreg ua_state_2 0x02f4
xtensa xtreg ua_state_3 0x02f4
xtensa xtreg q0 0x02f4
xtensa xtreg q1 0x02f4
xtensa xtreg q2 0x02f4
xtensa xtreg q3 0x02f4
xtensa xtreg q4 0x02f4
xtensa xtreg q5 0x02f4
xtensa xtreg q6 0x02f4
xtensa xtreg q7 0x02f4
xtensa xtreg accx_0 0x0300
xtensa xtreg accx_1 0x0301
xtensa xtreg qacc_h_0 0x0302
xtensa xtreg qacc_h_1 0x0303
xtensa xtreg qacc_h_2 0x0304
xtensa xtreg qacc_h_3 0x0305
xtensa xtreg qacc_h_4 0x0306
xtensa xtreg qacc_l_0 0x0307
xtensa xtreg qacc_l_1 0x0308
xtensa xtreg qacc_l_2 0x0309
xtensa xtreg qacc_l_3 0x030a
xtensa xtreg qacc_l_4 0x030b
xtensa xtreg sar_byte 0x030d
xtensa xtreg fft_bit_width 0x030e
xtensa xtreg ua_state_0 0x030f
xtensa xtreg ua_state_1 0x0310
xtensa xtreg ua_state_2 0x0311
xtensa xtreg ua_state_3 0x0312
xtensa xtreg q0 0x1008
xtensa xtreg q1 0x1009
xtensa xtreg q2 0x100a
xtensa xtreg q3 0x100b
xtensa xtreg q4 0x100c
xtensa xtreg q5 0x100d
xtensa xtreg q6 0x100e
xtensa xtreg q7 0x100f
xtensa xtreg mmid 0x0259
xtensa xtreg ibreakenable 0x0260
xtensa xtreg memctl 0x0261
@@ -231,38 +226,38 @@ xtensa xtreg misc0 0x02f4
xtensa xtreg misc1 0x02f5
xtensa xtreg misc2 0x02f6
xtensa xtreg misc3 0x02f7
xtensa xtreg pwrctl 0x2025
xtensa xtreg pwrstat 0x2026
xtensa xtreg eristat 0x2027
xtensa xtreg cs_itctrl 0x2028
xtensa xtreg cs_claimset 0x2029
xtensa xtreg cs_claimclr 0x202a
xtensa xtreg cs_lockaccess 0x202b
xtensa xtreg cs_lockstatus 0x202c
xtensa xtreg cs_authstatus 0x202d
xtensa xtreg fault_info 0x203c
xtensa xtreg trax_id 0x203d
xtensa xtreg trax_control 0x203e
xtensa xtreg trax_status 0x203f
xtensa xtreg trax_data 0x2040
xtensa xtreg trax_address 0x2041
xtensa xtreg trax_pctrigger 0x2042
xtensa xtreg trax_pcmatch 0x2043
xtensa xtreg trax_delay 0x2044
xtensa xtreg trax_memstart 0x2045
xtensa xtreg trax_memend 0x2046
xtensa xtreg pmg 0x2054
xtensa xtreg pmpc 0x2055
xtensa xtreg pm0 0x2056
xtensa xtreg pm1 0x2057
xtensa xtreg pmctrl0 0x2058
xtensa xtreg pmctrl1 0x2059
xtensa xtreg pmstat0 0x205a
xtensa xtreg pmstat1 0x205b
xtensa xtreg ocdid 0x205c
xtensa xtreg ocd_dcrclr 0x205d
xtensa xtreg ocd_dcrset 0x205e
xtensa xtreg ocd_dsr 0x205f
xtensa xtreg pwrctl 0x2028
xtensa xtreg pwrstat 0x2029
xtensa xtreg eristat 0x202a
xtensa xtreg cs_itctrl 0x202b
xtensa xtreg cs_claimset 0x202c
xtensa xtreg cs_claimclr 0x202d
xtensa xtreg cs_lockaccess 0x202e
xtensa xtreg cs_lockstatus 0x202f
xtensa xtreg cs_authstatus 0x2030
xtensa xtreg fault_info 0x203f
xtensa xtreg trax_id 0x2040
xtensa xtreg trax_control 0x2041
xtensa xtreg trax_status 0x2042
xtensa xtreg trax_data 0x2043
xtensa xtreg trax_address 0x2044
xtensa xtreg trax_pctrigger 0x2045
xtensa xtreg trax_pcmatch 0x2046
xtensa xtreg trax_delay 0x2047
xtensa xtreg trax_memstart 0x2048
xtensa xtreg trax_memend 0x2049
xtensa xtreg pmg 0x2057
xtensa xtreg pmpc 0x2058
xtensa xtreg pm0 0x2059
xtensa xtreg pm1 0x205a
xtensa xtreg pmctrl0 0x205b
xtensa xtreg pmctrl1 0x205c
xtensa xtreg pmstat0 0x205d
xtensa xtreg pmstat1 0x205e
xtensa xtreg ocdid 0x205f
xtensa xtreg ocd_dcrclr 0x2060
xtensa xtreg ocd_dcrset 0x2061
xtensa xtreg ocd_dsr 0x2062
xtensa xtreg a0 0x0000
xtensa xtreg a1 0x0001
xtensa xtreg a2 0x0002
@@ -279,19 +274,3 @@ xtensa xtreg a12 0x000c
xtensa xtreg a13 0x000d
xtensa xtreg a14 0x000e
xtensa xtreg a15 0x000f
xtensa xtreg b0 0x0010
xtensa xtreg b1 0x0011
xtensa xtreg b2 0x0012
xtensa xtreg b3 0x0013
xtensa xtreg b4 0x0014
xtensa xtreg b5 0x0015
xtensa xtreg b6 0x0016
xtensa xtreg b7 0x0017
xtensa xtreg b8 0x0018
xtensa xtreg b9 0x0019
xtensa xtreg b10 0x001a
xtensa xtreg b11 0x001b
xtensa xtreg b12 0x001c
xtensa xtreg b13 0x001d
xtensa xtreg b14 0x001e
xtensa xtreg b15 0x001f

View File

@@ -995,8 +995,10 @@ sub read_words {
# OpenOCD specific: Begin: Load list of allowed CamelCase symbols
if (show_type("CAMELCASE")) {
my $allowed_camelcase_file = "$root/tools/scripts/camelcase.txt";
if (open(my $words, '<', $allowed_camelcase_file)) {
my $allowed_camelcase_file = "tools/scripts/camelcase.txt";
if (!$root) {
warn "Ignore list of allowed camelcase symbols.\n";
} elsif (open(my $words, '<', "$root/$allowed_camelcase_file")) {
while (<$words>) {
my $line = $_;
@@ -1012,9 +1014,9 @@ if (show_type("CAMELCASE")) {
$camelcase{$line} = 1;
}
close($allowed_camelcase_file);
close("$root/$allowed_camelcase_file");
} else {
warn "No camelcase symbols to ignore - file '$allowed_camelcase_file': $!\n";
warn "Failed opening file '$root/$allowed_camelcase_file': $!\n";
}
}
# OpenOCD specific: End