aboutsummaryrefslogtreecommitdiff
path: root/src/target/target.c
AgeCommit message (Collapse)AuthorFilesLines
2021-05-14Remote enable_rtos_riscv command.Tim Newsome1-19/+0
I'd missed this when that functionality was removed. Change-Id: If5b697d9dbac517a077d9c1826c747fc95b19f1f Signed-off-by: Tim Newsome <tim@sifive.com>
2021-05-03Merge branch 'master' into from_upstreamTim Newsome1-19/+42
I may have broken memory sampling with this merge. Conflicts: doc/openocd.texi src/helper/command.c src/jtag/drivers/ftdi.c src/rtos/FreeRTOS.c Change-Id: I2b7e09b2d3b244db546c5212532e6b48fb66dca4
2021-04-18helper/command: register full-name commands in jimAntonio Borneo1-1/+2
While still keeping the tree of struct command, stop registering commands in jim by the root "word" only. Register the full-name of the command and pass as private data the struct command of the command itself. Still use the tree of struct command to un-register the commands. Some "native" commands (.jim_handler) share the same handler, then the handler checks the command name to run the right code. Now argv[0] returns the full-name of the command, so check the name by looking in the struct command passed as private data. Change-Id: I5623c61cceee8a75f5d5a551ef3fbf5a303af6be Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5671 Tested-by: jenkins Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2021-04-18helper/command: override target only on target prefixed cmdsAntonio Borneo1-5/+1
In current code the current target is overridden whenever jim_handler_data is not NULL. This happens not only with target prefixed commands, but also with cti, dap and swo/tpiu prefixed commands. While this is not causing any run-time issue, by now, the behaviour is tricky and makes the code cryptic. Add a specific field to struct command for the target override so the content of jim_handler_data can be restricted to command specific data only (today only cti, dap and swo/tpiu). Extend the API register_commands() to specify the presence of either the command data or the override target. The new API makes obsolete calling command_set_handler_data() to set jim_handler_data, so remove it. Change-Id: Icc323faf754b0546a72208f90abd9e68ff2ef52f Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5667 Tested-by: jenkins Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2021-04-18helper/command: get current target from dedicated APIAntonio Borneo1-26/+39
Now that target override is uniformly implemented for all types of commands, there is no need for target-prefixed "native" commands (.jim_handler) to sneakily extract the overridden target from the struct command. Modify the commands to use the standard API get_current_target(). Change-Id: I732a09c3261e56524edd5217634fa409eb97a8c6 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5666 Tested-by: jenkins Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2021-04-18helper/command: always pass struct command as jim private dataAntonio Borneo1-13/+26
While registering a new command, jim accepts a pointer to command's private data that will be accessible during the command execution. Today openocd is not consistent and passes different private data depending on the command, and then even overwrites it: - "simple" commands (.handler) are registered with their own struct command pointer as command private data; - "native" commands (.jim_handler) at root level are registered with NULL command private data; - "native" commands (.jim_handler) not at root level are registered with the struct command pointer of their root command as command private data but, when executed, the command private data is overwritten by the value in field jim_handler_data taken from their struct command. Uniform the usage of command private data by always set it to the struct command pointer while registering the new commands. Note: for multi-word commands only the root command is registered, so command private data will be set to the struct command of the root command. This will change later in this series when the full- name of the command will be registered. Don't overwrite the command private data, but let the commands that needs jim_handler_data to get it directly through struct command. For sake of uniformity, let function command_set_handler_data() to set the field jim_handler_data also for "group" commands, even if such value will not be used. Now Jim_CmdPrivData() always returns a struct command pointer, so wrap it in the inline function jim_to_command() to gain compile time check on the returned type. While there, uniform the code to use the macro Jim_CmdPrivData() to access the command's private data pointer. Change-Id: Idba16242ba1f6769341b4030a49cdf35a5278695 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5664 Tested-by: jenkins Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2021-04-13Merge branch 'master' into from_upstreamTim Newsome1-16/+20
Conflicts: .github/workflows/snapshot.yml NEWS configure.ac contrib/loaders/checksum/riscv_crc.c jimtcl src/helper/time_support.h src/jtag/drivers/arm-jtag-ew.c src/rtos/FreeRTOS.c src/target/image.c src/target/riscv/riscv.c Change-Id: I043624ba540d4672fc123dddb2066bcb9c6b5a05
2021-03-19target: remove handling of target's deprecated_nameAntonio Borneo1-9/+0
We do not have anymore any deprecated target name. Drop the code to handle deprecated target names and the placehold in struct target_type. This patch is separated from the patch that drops the remaining deprecated target names to be ready to revert this if there is any need in the future. Change-Id: I96fca7ffa39d8292f81e79f115ea45c4a30035d7 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6087 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2021-03-10armv7m_trace: get rid of the old tpiu codeAntonio Borneo1-0/+5
Remove all the old tpiu code and replace it with a wrapper that uses the new commands, prints-out the new commands and informs about the deprecation. All the code that handles the deprecated tpiu commands is enclosed between the comments /* START_DEPRECATED_TPIU */ and /* END_DEPRECATED_TPIU */ so will be easy to remove it in the future. Change-Id: I70b0486770128203b923346382d9a90b8ec08439 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6030 Tested-by: jenkins Reviewed-by: Adrian M Negreanu <adrian.negreanu@nxp.com>
2021-03-10target: Remove redundant initialization of endiannessYasushi SHOJI1-3/+0
target->endianness is initialized to TARGET_ENDIAN_UNKNOWN at 34 lines below, before calling target_configure. This initialization is redundant and not needed. Change-Id: Iea2d5e17a13c1a8b0b209ba7c20043736b520ef6 Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com> Reviewed-on: http://openocd.zylin.com/6039 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2021-03-04target: avoid polling during 'resumed' event handlerAntonio Borneo1-0/+11
OpenOCD is based on a single main loop that schedules all the activities. At the execution of a TCL command, the timestamp is checked to eventually trigger the polling of the targets. This means that by executing a TCL command the polling can be triggered and detect a change of target's state. When openocd 'resumes' a target, the target can halt again by hitting a breakpoint. The 'resumed' event handler is started just after the target has been resumed, but it triggers a polling before the execution of its very first instruction. If the polling finds the target halted, it will run the 'halted' event handler, that will then be executed 'before' the pending 'resumed' handler. In case of gdb, a 'continue' command will restart the target but, polling (and halt detection) executed before the end of the resume process will hide the halt. As a consequence, the gdb will not be informed of the halt and will remains waiting as if the target is still running without showing the prompt. This can be verified by running on the target a firmware with a loop, run openocd with a dummy 'resumed' event, and let gdb to set a breakpoint in the loop. A 'continue' command will cause the target to halt again by hitting the breakpoint at the next loop iteration, but gdb will loose it and will not return the prompt. openocd -f board/st_nucleo_f4.cfg -c \ 'stm32f4x.cpu configure -event resumed {echo hello}' arm-none-eabi-gdb -ex 'target remote :3333' -ex 'b *$pc' -ex c Disable the polling while executing target's resume(). Document it and provide hints to developers to cope with future implementation. Change-Id: I3be830a8e7c2ef6278617cb4547a4d676b0ddeb5 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reported-by: Габитов Александр Фаритович <gabitov@planarchel.ru> Reviewed-on: http://openocd.zylin.com/6074 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
2021-02-13target: use proper macro for parsing watchpoint addressPeter Mamonov1-4/+4
Currently wp/rwp commands fail on 64-bit targets: > wp 0xffffffff80001400 4 addr option value ('0xffffffff80001400') is not valid Change-Id: I94d4af906b02b7bd463c8d79a6235a3646dfc434 Signed-off-by: Peter Mamonov <pmamonov@gmail.com> Reviewed-on: http://openocd.zylin.com/6058 Tested-by: jenkins Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2021-02-11From upstream (#580)Tim Newsome1-0/+21
* configure: do not make Capstone dependency automagic This adds regular ./configure options to control dependency on the Capstone disassembly engine. See [0] for the rationale. [0] https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Automagic_dependencies Change-Id: I3e16dc5255d650aa1949ccf896b26dc96e522a75 Signed-off-by: Paul Fertser <fercerpav@gmail.com> Reviewed-on: http://openocd.zylin.com/5985 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> * configure.ac: fix build with libusb0 and without libusb1 Driver 'openjtag' requires both libftdi and libusb1. The current check is incorrect and the driver is built when libftdi is present with libusb0 and without libusb1, which causes the linker to fail resolving the required libusb1 symbols. Remove the check for libusb0 on driver 'openjtag'. Create a new adapters group LIBFTDI_USB1_ADAPTERS to hold the driver 'openjtag'. Change-Id: I1f5e554b519e51c829d116ede894639cb55a26aa Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5989 Tested-by: jenkins * doc: fix over/underfull hboxes in PDF This adds some cosmetic changes to make the PDF User Manual look proper. Building it now requires Texinfo 5.0 which shouldn't be problematic according to [0]. Commit 79fdeb37f486f74658f1eaf658abac8efb3eba6a is effectively reverted. [0] https://repology.org/project/texinfo/versions Change-Id: I990bc23bdb53d24c302b26d74fd770ea738e4096 Signed-off-by: Paul Fertser <fercerpav@gmail.com> Reviewed-on: http://openocd.zylin.com/5995 Reviewed-by: Jonathan McDowell <noodles-openocd@earth.li> Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> * contrib: rpc_examples: haskell: fix ftbs with current libraries And get rid of some warnings along the way. Change-Id: I8fdbe1fa304276be6b0f25249b902b3576aa3793 Signed-off-by: Paul Fertser <fercerpav@gmail.com> Reviewed-on: http://openocd.zylin.com/5987 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> * Makefile.am: fix override of target 'check-recursive' To prevent executing the Jim Tcl tests, the makefile's target 'check-recursive' has been overridden in commit 56d163ce7951 ("jimtcl: update to 0.77, the current version, enable only specific modules"). This causes a runtime warning during build: Makefile:6332: warning: overriding recipe for target 'check-recursive' Makefile:5098: warning: ignoring old recipe for target 'check-recursive' Instead of override the makefile's target 'check-recursive', prevent the recursion by re-assigning as empty the variable SUBDIRS for this specific target only. Change-Id: I03d1c467eba42316a59aeed4612d6bdbe6211282 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Fixes: 56d163ce7951 ("jimtcl: update to 0.77, the current version, enable only specific modules") Reviewed-on: http://openocd.zylin.com/5986 Tested-by: jenkins * contrib: udev file for Cypress SuperSpeed Explorer kit lsusb output: Bus 003 Device 011: ID 04b4:0007 Cypress Semiconductor Corp. Couldn't open device, some information will be missing Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 0 (Defined at Interface level) bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 8 idVendor 0x04b4 Cypress Semiconductor Corp. idProduct 0x0007 bcdDevice 0.00 iManufacturer 1 iProduct 2 iSerial 0 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 114 bNumInterfaces 4 bConfigurationValue 1 iConfiguration 0 bmAttributes 0xa0 (Bus Powered) Remote Wakeup MaxPower 100mA Interface Association: bLength 8 bDescriptorType 11 bFirstInterface 0 bInterfaceCount 2 bFunctionClass 2 Communications bFunctionSubClass 2 Abstract (modem) bFunctionProtocol 1 AT-commands (v.25ter) iFunction 0 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 1 bInterfaceClass 2 Communications bInterfaceSubClass 2 Abstract (modem) bInterfaceProtocol 1 AT-commands (v.25ter) iInterface 0 CDC Header: bcdCDC 1.10 CDC ACM: bmCapabilities 0x02 line coding and serial state CDC Union: bMasterInterface 0 bSlaveInterface 1 CDC Call Management: bmCapabilities 0x00 bDataInterface 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x83 EP 3 IN bmAttributes 3 Transfer Type Interrupt Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 10 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 0 bNumEndpoints 2 bInterfaceClass 10 CDC Data bInterfaceSubClass 0 Unused bInterfaceProtocol 0 iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x01 EP 1 OUT bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x82 EP 2 IN bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 0 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 2 bAlternateSetting 0 bNumEndpoints 3 bInterfaceClass 255 Vendor Specific Class bInterfaceSubClass 4 bInterfaceProtocol 0 iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x04 EP 4 OUT bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x85 EP 5 IN bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x86 EP 6 IN bmAttributes 3 Transfer Type Interrupt Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 10 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 3 bAlternateSetting 0 bNumEndpoints 0 bInterfaceClass 255 Vendor Specific Class bInterfaceSubClass 5 bInterfaceProtocol 0 iInterface 0 Change-Id: I62f0300199da3551c8774a4a5a4cd106a3ab2904 Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Signed-off-by: Jiri Kastner <cz172638@gmail.com> Reviewed-on: http://openocd.zylin.com/3611 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> * target: fix memory leak on multiple '-gdb-port' flag In the odd case of multiple flags '-gdb-port' during 'target create' or following 'configure', the new strdup()'ed value will replace the old one without freeing it. Free the old value (if it exists) before replacing it. Change-Id: I1673346613ce7023880046e3a9ba473e75f18b8a Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6005 Tested-by: jenkins * udev: fix permission for Ambiq Micro EVK's Commit 68e204f1e91a ("udev: Add rules for Ambiq Micro EVK's.") was initially proposed as http://openocd.zylin.com/3429/ then replaced by http://openocd.zylin.com/3980/ The initial proposal was for file '99-openocd.rules', in which MODE="664" was the norm. After merge of http://openocd.zylin.com/2804/ the new udev rules in '60-openocd.rules' switched to MODE="660", but the evolution of the above patch missed this change. Switch udev rules of Ambiq Micro EVK's to MODE="660" and uniform them to the rest of the file. Change-Id: I4b4eea535184ee8569da3264bff4f1fafb5bce4d Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Fixes: 68e204f1e91a ("udev: Add rules for Ambiq Micro EVK's.") Reviewed-on: http://openocd.zylin.com/6004 Tested-by: jenkins * doc/style: fix doxygen error Doxygen complains about non-closed nested comments: doc/manual/style.txt:423: warning: Reached end of file while still inside a (nested) comment. Nesting level 1 (probable line reference: 149) This is caused by the string '/**' that is interpreted as the beginning of a comment. Escape the string to not let doxygen consider it as a comment While there, replace @code/@endcode with @verbatim/@endverbatim to properly render the line. Change-Id: If2a27c4cf659326e317cc4ac8c0b313e97e40432 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5996 Tested-by: jenkins * flash/nor/max32xxx: fix path of include file The relative path should have three times '..'. Issue identified by doxygen: src/flash/nor/max32xxx.c:85: warning: include file ../../contrib/loaders/flash/max32xxx/max32xxx.inc not found, perhaps you forgot to add its directory to INCLUDE_PATH? Change-Id: Ie7b4948c6770b8acb9eff26e08eea32945ebb219 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5997 Tested-by: jenkins * Doxyfile.in: fix build out-of-tree When doxygen is built out-of-tree, it fails to find the generated file startup_tcl.inc: src/openocd.c:59: warning: include file startup_tcl.inc not found, perhaps you forgot to add its directory to INCLUDE_PATH? Add '@builddir@/src' to INCLUDE_PATH. Change-Id: I51f2f6fe7224bba0f8b3db7219f9831de4e67139 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5998 Tested-by: jenkins * doc/manual/primer/jtag.txt: remove duplicated section name The section name 'primerjtag' is used twice, causing doxygen to complain: warning: multiple use of section label 'primerjtag', (first occurrence: doc/manual/primer/jtag.txt, line 107) Rename one of them. Change-Id: Id307915dbc51a7f647fab4fb28ab431e65344d61 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5999 Tested-by: jenkins * Doxyfile.in: exclude libjaylink from doxygen When build using libjaylink as git submodule, doxygen includes the libjaylink files and complains for multiple 'mainpage' comment block, one in OpenOCD and the other in libjaylink: src/jtag/drivers/libjaylink/libjaylink/core.c:37: warning: found more than one \mainpage comment block! (first occurrence: doc/manual/main.txt, line 1), Skipping current block! Exclude libjaylink submodule from doxygen. Change-Id: I5e856817344c9f21f8c26f077a23c00b83cfbcb5 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6000 Tested-by: jenkins * openocd: fix incorrect doxygen comments Use '@param' in front of function's parameters and '@a' when the parameter is recalled in the description. This fixes doxygen complains: warning: Found unknown command '@buff16' While there, fix a minor typo s/occured/occurred/ in a comment and the typo s/@apram/@param/ in a doxygen comment. Change-Id: I5cd86a80adef552331310a21c55ec5d11354be21 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6001 Tested-by: jenkins * openocd: fix doxygen parameters of functions Add to doxygen comment the missing parameters. Remove from doxygen comment any non-existing parameter. Fix the parameter names in doxygen comment to match the one in the function prototype. Where the parameter name in the doxygen description seems better than the one in the code, change the code. Escape the character '<' to prevent doxygen to interpret it as an xml tag. Change-Id: I22da723339ac7d7a7a64ac4c1cc4336e2416c2cc Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6002 Tested-by: jenkins * doc/manual/primer/autotools.txt: fix doxygen warning Commit ab90b8777855 ("configure: remove AM_MAINTAINER_MODE, effectively always enabling all the rules") removes the configure flag '--enable-maintainer-mode' and its documentation, but have left a reference to the removed subsection 'primermaintainermode' and this triggers a warning in doxygen: doc/manual/primer/autotools.txt:21: warning: unable to resolve reference to 'primermaintainermode' for \ref command Remove the obsoleted paragraph. Change-Id: I56e69ef033d546d159745bed1b47c6105827e7ae Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Fixes: ab90b8777855 ("configure: remove AM_MAINTAINER_MODE, effectively always enabling all the rules") Reviewed-on: http://openocd.zylin.com/6003 Tested-by: jenkins * flash/stmqspi: fix build error with -Werror=maybe-uninitialized using gcc 9.3 on ubuntu focal fossa with -Werror=maybe-uninitialized we get this error: /src/flash/nor/stmqspi.c: In function ‘read_flash_id’: /src/flash/nor/stmqspi.c:1948:6: error: ‘retval’ may be used uninitialized Change-Id: Ifd8ae60df847fc61e22ca100c008e3914c9af79b Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@st.com> Reviewed-on: http://openocd.zylin.com/6012 Tested-by: jenkins Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> * target/riscv: fix build error with -Werror=maybe-uninitialized using gcc 9.3 on ubuntu focal fossa with -Werror=maybe-uninitialized we get this error: /src/target/riscv/riscv.c: In function ‘riscv_address_translate’: /src/target/riscv/riscv.c:1536:13: error: ‘pte’ may be used uninitialized Change-Id: I51e180b43f9b6996e4e4058db49c179b9f81bcdc Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@st.com> Reviewed-on: http://openocd.zylin.com/6013 Tested-by: jenkins Reviewed-by: Tim Newsome <tim@sifive.com> Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> * cortex_m: [FIX] ARMv8-M does not support VECTRESET ref: Arm®v8-M Architecture Reference Manual (DDI0553B.m) D1.2.3: AIRCR, Application Interrupt and Reset Control Register Bit [0] is RES0 Change-Id: I6ef451b2c114487e2732852a60e86c292ffa6a50 Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@st.com> Reviewed-on: http://openocd.zylin.com/6014 Tested-by: jenkins Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> * driver/ftdi: skip trst in swd mode When using the adapter olimex arm-jtag-swd (to convert to SWD a JTAG-only FTDI adapter), the pin trst on JTAG side is re-used to control the direction of pin SWDIO on SWD side. There is a single reset API at adapter driver to assert/deassert either srst and/or trst. A request to assert/deassert srst can cause also trst to change value, hanging the SWD communication. In SWD mode, ignore the value passed to trst. Change-Id: I5fe1eed851177d405d77ae6079da9642dc1a08f1 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6006 Tested-by: jenkins * configure.ac: drop macro 'AC_PROG_CC_C99' from autoconf 2.70 The macro AC_PROG_CC_C99 has been obsoleted by autoconf 2.70 and triggers a set of warnings from both 'aclocal' and 'autoconf'. The test of AC_PROG_CC_C99 is now included in AC_PROG_CC. For autoconf 2.69 and earlier the macro is still required, so cannot be simply dropped. Use a conditional test to avoid the warning on autoconf 2.70 but still use AC_PROG_CC_C99 on older autoconf. Change-Id: I5e8437f5a826fb63be6d07bcb5bb824f94683020 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6009 Tested-by: jenkins Reviewed-by: Marc Schink <dev@zapb.de> * configure: drop macro 'AC_HEADER_TIME' The macro AC_HEADER_TIME has been obsoleted by autoconf 2.70. Not all systems provide 'sys/time.h', plus some old system didn't allowed to include both 'time.h' and 'sys/time.h' because 'time.h' was included by 'sys/time.h' and was not properly protected to allow multiple inclusion. The macro AC_HEADER_TIME helps to detect such odd case. Nowadays all the systems properly protect 'time.h', so its safe to unconditionally include 'time.h', even if it is also included by 'sys/time.h'. The case of systems without 'sys/time.h' is already covered by configure.ac through the directive AC_CHECK_HEADERS([sys/time.h]) Remove the obsoleted autoconf macro and simplify the code by including 'time.h' unconditionally and check HAVE_SYS_TIME_H to include 'sys/time.h'. Change-Id: Iddb3f3f1d90c22668b97f8e756e1b4f733367a7d Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6010 Tested-by: jenkins Reviewed-by: Marc Schink <dev@zapb.de> * README.macOS: explain how to install suitable Texinfo Change-Id: Ic5906111f412eebd906a9be3fd0e133484def3eb Signed-off-by: Paul Fertser <fercerpav@gmail.com> Reviewed-on: http://openocd.zylin.com/6026 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> * jlink: fix device discovery when network is off If user specifies a serial number for the jlink device, openocd extends the search to network jlink devices too, without checking if the host has a valid and functional network connection. If the network is not functional, libjaylink returns error. This error invalidates the discovery on USB, even if it was successful. Factor-out parts of the jlink_init into separate jlink_open_device function, use that function to firstly discover and match USB devices and, if matching device was not found on the USB bus and serial number was specified, repeat discovery and matching via TCP. Fixes: https://sourceforge.net/p/openocd/tickets/294/ Change-Id: Iea0de1640d4e5b21ecc7e9c1dd6d36f214d647c2 Signed-off-by: Bohdan Tymkiv <bohdan200@gmail.com> Reviewed-on: http://openocd.zylin.com/6025 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins Reviewed-by: Marc Schink <dev@zapb.de> * README: add missing items for 0.11 JTAG adapters Cadence DPI, Cypress Kitpro, FTDI FT232R, Linux GPIOD, Mellanox rshim, Nuvoton Nu-Link, Nu-Link2, NXP IMX GPIO, Remote Bitbang, TI XDS110, Xilinx XVC/PCIe Debug targets AArch64, Cortex-M (ARMv8-M), ARCv2, MIPS64, RISC-V, ST-STM8 Flash Drivers ATmega128RFA1, Atmel SAM, eSi-RISC, EZR32HG, MAX32, MXC, nRF52, PSoC6, Renesas RPC HF and SH QSPI, SiFive Freedom E, ST BlueNRG, STM32 QUAD/OCTO-SPI for Flash/FRAM/EEPROM, SWM050, TI CC13xx, TI CC26xx, TI CC32xx, TI MSP432, Winner Micro w600, Xilinx XCF Change-Id: I341618ac5d7189e4f98268cecd66c99447b72af8 Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@st.com> Reviewed-on: http://openocd.zylin.com/6027 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Paul Fertser <fercerpav@gmail.com> * The openocd-0.11.0-rc2 release candidate Signed-off-by: Paul Fertser <fercerpav@gmail.com> * Restore +dev suffix Signed-off-by: Paul Fertser <fercerpav@gmail.com> * steppenprobe: fix file permission Commit 895d4a599585 ("tcl/interface/ftdi: Add Steppenprobe open hardware interface") erroneously set the execution permission to the configuration file. Strip the execution permission. Change-Id: I556451d5e6fee4aee385451e8c90216a25b6ef46 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Fixes: http://openocd.zylin.com/5653 Reviewed-on: http://openocd.zylin.com/6038 Reviewed-by: Paul Fertser <fercerpav@gmail.com> Tested-by: Paul Fertser <fercerpav@gmail.com> * github: fix github wokflow while pushing a tag this fix permits to add correctly the generated artifact (windows binaries) into the release section. Change-Id: Ia982370d3a1e08c623ebcabb5ac97e9fb49d00e0 Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: http://openocd.zylin.com/6047 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> * doc: Fix type in Hooking up the JTAG Adapter We are talking about adapter connectivity in this chapter. It should be "dongles" instead of "cables". Change-Id: I7bd4307765517375caa2af86dfc929d0ef66c3e6 Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com> Reviewed-on: http://openocd.zylin.com/6040 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins * doc/manual: Fix @subpage handling The subpage "thelist" used to have a title "Pending and Open Tasks" but the commit c41db358a0100ab changed it to "The List". With @subpage, it now renders: "The List of The List enumerates opportunities for" instead of "The List of Pending and Open Tasks enumerates opportunities for" This commit fix it to "The List enumerates opportunities for" Change-Id: Ifee0dcd9b3c9f7e651a8748a7afda99eedea3c5c Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com> Reviewed-on: http://openocd.zylin.com/6041 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> * doc/manual: Fix function name typo We have both the singular form, register_command(), and the plural form register_commands(). Change-Id: I905ea83988b8ac70dd809b02d53b646aa4d66697 Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com> Reviewed-on: http://openocd.zylin.com/6042 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins Co-authored-by: Paul Fertser <fercerpav@gmail.com> Co-authored-by: Antonio Borneo <borneo.antonio@gmail.com> Co-authored-by: Jiri Kastner <cz172638@gmail.com> Co-authored-by: Tarek BOCHKATI <tarek.bouchkati@st.com> Co-authored-by: Bohdan Tymkiv <bohdan200@gmail.com> Co-authored-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Co-authored-by: Yasushi SHOJI <yashi@spacecubics.com>
2021-01-13openocd: fix doxygen parameters of functionsAntonio Borneo1-0/+20
Add to doxygen comment the missing parameters. Remove from doxygen comment any non-existing parameter. Fix the parameter names in doxygen comment to match the one in the function prototype. Where the parameter name in the doxygen description seems better than the one in the code, change the code. Escape the character '<' to prevent doxygen to interpret it as an xml tag. Change-Id: I22da723339ac7d7a7a64ac4c1cc4336e2416c2cc Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6002 Tested-by: jenkins
2021-01-13target: fix memory leak on multiple '-gdb-port' flagAntonio Borneo1-0/+1
In the odd case of multiple flags '-gdb-port' during 'target create' or following 'configure', the new strdup()'ed value will replace the old one without freeing it. Free the old value (if it exists) before replacing it. Change-Id: I1673346613ce7023880046e3a9ba473e75f18b8a Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6005 Tested-by: jenkins
2020-12-31Merge branch 'master' into from_upstreamTim Newsome1-35/+218
Conflicts: .github/workflows/snapshot.yml .gitmodules src/flash/nor/drivers.c src/helper/jep106.inc src/rtos/hwthread.c src/target/riscv/riscv.c src/target/target.c Change-Id: I62f65e10d15dcda4c405d4042cce1d96f8e1680a
2020-11-15target, register: allow a register hidden from gdb and 'reg' cmdTomas Vanek1-1/+1
Introduce a 'hidden' flag in struct reg to support a register cache containing different views of same data: e.g. Cortex-M has primask, basepri, faultmask and control registers accessed as one word. With the hidden flag we can add an reg_list item corresponding to hw access without exposing the register to user level. All the struct reg are allocated with calloc() but one in xscale.c allocated by malloc(). Change this one to use calloc() as well to guarantee initial value hidden=false Change-Id: I8da9f5a5a60777ae7ef943a841307487bd80fc6f Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: http://openocd.zylin.com/5325 Tested-by: jenkins Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-11-15flash/stmqspi: minor fixes on coding styleAntonio Borneo1-1/+1
Add space around operators; use BIT() macro in place of left shifting constant 1; remove space between cast operator and value; do not check a pointer before free() it; add parenthesis around parameters in macros; fix indentation using only TABs; remove line continuation '\' at code lines out of macros. Change-Id: I809e8ee72d7bfe49d0edf10afb36efe2458de77c Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Fixes: e44539d66c89 ("Flash, FRAM and EEPROM driver for STM32 QUAD-/OCTOSPI interface") Reviewed-on: http://openocd.zylin.com/5932 Tested-by: jenkins Reviewed-by: Christopher Head <chead@zaber.com>
2020-11-08Flash, FRAM and EEPROM driver for STM32 QUAD-/OCTOSPI interfaceAndreas Bolsch1-2/+156
- write speed up to 150 kByte/s on STM32F469I-disco (due to SWD clock and USB connection), up to 1 MByte/s on Nucleo-F767ZI with external STLink-V3 or Nucleo-G474RE with two W25Q256FV in dual 4-line mode or STM32H73BI-Disco in octal mode - tested with STM32L476G-disco (64MBit flash, 3-byte addr), STM32F412G-Disco, STM32F469I-Disco, STM32F746G-Disco, and STM32L476G-Disco (all 128Mbit flash, 3-byte addr), STM32F723E-Disco, STM32F769I-Disco (512Mbit flash, 4-byte addr) STM32L4R9I-Disco, STM32L4P5G-Disco (512MBit octo-flash, DTR, 4-byte addr) STM32H745I-Disco, STM32H747I-Disco (two 512MBit flash, 4-byte addr) STM32H73BI-Disco, STM32H735G-Disco (512MBit octo-flash, DTR, 4-byte addr) - suitable cfg for Discovery boards included - limited parsing of SFDP data if flash device not hardcoded (tested only in single/quad mode as most devices either don't support SFDP at all or have empty(!) SFDP memory) - 'set' command for auto detection override (e. g. for EEPROMs) - 'cmd' command for arbitrary SPI commands (reconfiguration, testing etc.) - makefile for creation of binary loader files - tcl/board/stm32f469discovery.cfg superseded by stm32f469i-disco.cfg - tcl/board/stm32f7discovery.cfg removed as name is ambiguous (superseded by stm32f746g-disco.cfg vs. stm32f769i-disco.cfg) - dual 4-line mode tested on Nucleo-F767ZI, Nucleo-H743ZI and Nucleo-H7A3ZI-Q with two W25Q256FV, and on Nucleo-L496ZP-P and Nucleo-L4R5ZI with two W25Q128FV, sample cfg files included and on STM32H745I-Disco, STM32H747I-Disco, STM32H750B-Disco - read/verify/erase_check uses indirect read mode to work around silicon bug in H7, L4+ and MP1 memory mapped mode (last bytes not readable, accessing last bytes causes debug interface to hang) - octospi supported only in single/dual 1-line, 2-line, 4-line and single 8-line modes, (not in hyper flash mode) Requirements: GPIOs must be initialized appropriately, and SPI flash chip be configured appropriately (1-line ..., QPI, 4-byte addresses ...). This is board/chip specific, cf. included cfg files. The driver infers most parameters from current setting in CR, CCR, ... registers. Change-Id: I54858fbbe8758c3a5fe58812e93f5f39514704f8 Signed-off-by: Andreas Bolsch <hyphen0break@gmail.com> Reviewed-on: http://openocd.zylin.com/4321 Tested-by: jenkins Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-by: Christopher Head <chead@zaber.com>
2020-11-07target: Examine subsequent targets after failureKevin Yang1-3/+5
When a target examination fails, continue to examine subsequent targets. Return the number of targets that failed to examine. Change-Id: I883a0c445edc7eb00f496b79271d773771ec6b66 Signed-off-by: Kevin Yang <kangyang@google.com> Reviewed-on: http://openocd.zylin.com/5855 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-11-07target/image: Use proper data typesMarc Schink1-14/+11
While at it, fix some coding style issues. Change-Id: Id521394d89e0bf787a6f812701c2cc0fe7e4e63f Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: http://openocd.zylin.com/5919 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-11-04target: declare local symbols as staticAntonio Borneo1-3/+3
Functions and variables that are not used outside the file should be declared as static. Change-Id: I9f97571a528f0cb3c3c26f873577ab16fdec3cdc Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5895 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2020-11-04target: handle command 'target current' when no target is presentAntonio Borneo1-1/+3
Is it possible to run OpenOCD without any target, for example to only dump the rom-tables of an arm dap, or to perform low level jtag operations. But without any target created, the command 'target current' causes OpenOCD to abruptly exit. Handle in command 'target current' the case of no targets. Change-Id: Ide15cb13bec84b88ccc3e7126523c04a6d70e636 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5881 Tested-by: jenkins
2020-11-04gdb_server: allow multiple GDB connections to selected targetsAntonio Borneo1-3/+25
The default way of working is to have a single GDB attached to one target, so OpenOCD accepts only one connection to the GDB port of each targets and rejects any further connection. There are some barely safe use cases in which it could get useful having a second GDB connection to the same target. One such use case is while using GDB as a 'non-intrusive memory inspector', as explained in the OpenOCD documentation. One GDB can be left running an infinite loop to dump some memory area, or even analysing the content, while keeping a second GDB ready for user interaction or spot memory check. Add a target configure option to specify the maximum number of GDB connections allowed for that target, keeping the default to 1. Change-Id: I4985a602e61588df0b527d2f2aa5b955c93e125e Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5865 Tested-by: jenkins Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2020-10-30target: restore last run state after profilingChristopher Head1-1/+13
Now that it’s possible to start profiling from either a running or a halted state, rather than unconditionally halting after profiling finishes, it makes more sense to restore the processor to whatever state (running or halted) it was in before profiling started. Change-Id: If6f6e70a1a365c1ce3b348a306c435c220b8bf12 Signed-off-by: Christopher Head <chead@zaber.com> Reviewed-on: http://openocd.zylin.com/5237 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-10-30target/cortex_m: reduce duplication in profilingChristopher Head1-3/+1
The Cortex-M implementation of profiling contains a bunch of conditionals and checks to handle both chips which have PCSR and chips which do not. However, the net effect of the non-PCSR branches is actually exactly the same as what target_profiling_default does. Rather than duplicating this code, just detect the situation where PCSR isn’t available and delegate to target_profiling_default. Change-Id: I1be57ac77f983816ab6bf644a3cfca77b67d6f70 Signed-off-by: Christopher Head <chead@zaber.com> Reviewed-on: http://openocd.zylin.com/5236 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-10-30target: allow profiling from runningChristopher Head1-4/+0
There are a handful of implementations of profiling. There is the default implementation, which repeatedly halts and resumes the target, sampling PC each time. There is the Cortex-M implementation, which uses PCSR if available, otherwise falling back to halting and resuming and sampling PC. There is the OR1K implementation, which reads NPC repeatedly. Finally, there is the NDS32 implementation which uses some kind of AICE commands with which I am unfamiliar. None of these (with the possible exception of the NDS32 implementation) actually require the target to be halted when starting profiling. The Cortex-M and OR1K actually resume the target as pretty much their first action. The default implementation doesn’t do this, but is written in such a way that the target just flips back and forth between halted and running, and the code will do the right thing from either initial state. The NDS32 implementation I don’t know about. As such, for everything except NDS32, it is not really necessary that the target be halted to start profiling. For the non-PCSR Cortex-M and default implementations, there is no real harm in such a requirement, because profiling is intrusive anyway, but there is no benefit. For the PCSR-based Cortex-M and the OR1K, requiring that the target is halted is annoying because it makes profiling more intrusive. Remove the must-be-halted check from the target_profiling function. Add it to the NDS32 implementation because I am not sure if that will break when invoked with a running target. Do not add it to any of the other implementations because they don’t need it. Change-Id: I479dce999a80eccccfd3be4fa192c904f0a45709 Signed-off-by: Christopher Head <chead@zaber.com> Reviewed-on: http://openocd.zylin.com/5235 Tested-by: jenkins Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-10-15Merge branch 'master' into from_upstream_histogramTim Newsome1-72/+117
Used histogram diff strategy, which was much better than the default. Conflicts: doc/openocd.texi src/flash/nor/fespi.c src/jtag/drivers/libjaylink src/rtos/rtos.c src/target/riscv/batch.c src/target/riscv/encoding.h src/target/riscv/riscv-011.c src/target/riscv/riscv-013.c src/target/riscv/riscv.c src/target/riscv/riscv.h src/target/target.c tcl/target/gd32vf103.cfg Change-Id: I1321f62ba719419e58f93b2195f2540bd62f50d2
2020-10-07Add memory sample feature (#541)Tim Newsome1-16/+22
* Add memory sampling feature. Currently only gets 10 samples per second, but the overall scaffolding looks like it works. Change-Id: I25a2bbcba322f2101c3de598c225f83c902680fa * Basic memory sample speed-ups. 977 samples/second. Change-Id: I6ea874f25051aca1cbe3aa2918567a4ee316c4be * Add base64 dumping of sample buffer. We can't just dump raw data, because the API we use to get data to the "user" uses NULL-terminated strings. Change-Id: I3f33faaa485a74735c13cdaad685e336c1e2095f * WIP on optimizing PC sampling. 1k samples per second on my laptop, which is roughly double what it was. Change-Id: I6a77df8aa53118e44928f96d22210df84be45eda * WIP Change-Id: I4300692355cb0cf997ec59ab5ca71543b295abb0 * Use small batch to sample memory. 5k samples/second. No error checking. Change-Id: I8a7f08e49cb153699021e27f8006beb0e6db70ee * Collect memory samples near continuously. Rewrite OpenOCD's core loop to get rid of the fixed 100ms delay. Now collecting 15k samples/second. Change-Id: Iba5e73e96e8d226a0b5777ecac19453c152dc634 * Fix build. Change-Id: If2fe7a0c77e0d6545c93fa0d4a013c50a9b9d896 * Fix the mess I left after resolving conflicts. Change-Id: I96abd47a7834bf8f5e005ba63020f0a0cc429548 * Support 64-bit address in memory sampling. * Support sampling 64-bit values. * Better error reporting. WIP on 64-bit support. * Speed up single 32-bit memory sample. 21k samples/second. * WIP on review feedback. Change-Id: I00e453fd685d173b0206d925090beb06c1f057ca * Make memory sample buffers/config per-target. Change-Id: I5c2f5997795c7a434e71b36ca4c712623daf993c * Document, and add bucket clear option. Change-Id: I922b883adfa787fb4f5a894db872d04fda126cbd Signed-off-by: Tim Newsome <tim@sifive.com> * Fix whitespace. Change-Id: Iabfeb0068d7138d9b252ac127d1b1f949cf19632 Signed-off-by: Tim Newsome <tim@sifive.com> * Document sample buffer full behavior. Change-Id: Ib3c30d34b1f9f30cf403afda8fdccb850bc8b4df Signed-off-by: Tim Newsome <tim@sifive.com> * Actually clear the sample buffer in dump_sample_buf. Change-Id: Ifda22643f1e58f69a6382abc90474659d7330ac5 Signed-off-by: Tim Newsome <tim@sifive.com> * Use compatible string formatting. Change-Id: Ia5e5333e036c1dbe457bc977fcee41983b9a9b77 Signed-off-by: Tim Newsome <tim@sifive.com>
2020-09-05target: avoid checking for non NULL pointer to free itAntonio Borneo1-17/+8
The function free() can be called with a NULL pointer as argument, no need to check the argument before. If the pointer is NULL, no operation is performed by free(). Remove the occurrences of pattern: if (ptr) free(ptr); In target/openrisc/jsp_server.c, an error is logged if the ptr was already NULL. This cannot happen since the pointer was already referenced few lines before and openocd would have been already SIGSEGV in that case, so remove the log. Change-Id: I290a32e6d4deab167676af4ddc83523c830ae49e Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5809 Tested-by: jenkins
2020-09-05target: use proper format with uint32_tAntonio Borneo1-7/+7
Modify the format strings to properly handle uint32_t data types. While there, fix prototype mismatch between header and C file of the function armv7a_l1_d_cache_inval_virt(). Change-Id: I434bd241fa5c38e0c15d22cda2295097050067f5 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5818 Tested-by: jenkins
2020-09-05Fix debug prints when loading to flashSamuel Obuch1-6/+6
While loading to flash with debug level at least 3, OpenOCD tries to print the whole loaded bitstream. This will be very-very-slow due to implementation of conversion from buffer to string. * fix condition on selected debug level in jtag/core.c * replace slow buf_to_str function from helper/binarybuffer.c with faster but_to_hex_str function Change-Id: I3dc01d5846941ca80736f2ed12e3a54114d2b6dd Signed-off-by: Samuel Obuch <sobuch@codasip.com> Reviewed-on: http://openocd.zylin.com/5800 Tested-by: jenkins Reviewed-by: Jan Matyas <matyas@codasip.com> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-08-18Create `riscv repeat_read` command (#510)Tim Newsome1-3/+4
* WIP, apply stash with conflicts. Change-Id: Ia794bde419aa29161c68898d20e30527e69f5a31 * Fix conflict resolution problems. Change-Id: I4cedc348cf613f98cc5a36886f37c568ca644238 * Add repeat_read command. Only implemented for sba v1 right now, and poorly tested at that. Change-Id: I1d9ff63e1dea14b3f6a9f8ba4dad53668bf8038b * Hide bogus address in repeat_read Change-Id: Ib66c1fa60df9c7fc7cc87880b0fddc52825b48aa * WIP make repeat read work with progbuf. Change-Id: I555f8b880c8bf0d1ed0f3f90c7987a5b516a7a79 * WIP Change-Id: Ic567cea68355ae907e94bd25185a2c9be6fd798d * Fix error handling when increment is non-zero. Change-Id: I5a2f3f2ee948fd4e12c0443a542e85b7b5c5791a * Correctly(?) handle failures when increment is 0. I'm not 100% convinced that this ensures every read value shows up in the output, but it ought to work. Change-Id: I1af3e7174cf9d5e6f293456fb5ead629e17faaaa * Don't crash when asked to read no data. Change-Id: I4061b5c720a43a4f828384ab9eacc89557adfa05 * Remove unnecessary comment. Change-Id: I1be3d699b86299339b3a830ca1ef13c9f5b9fe0f * Document `riscv repeat_read`. Change-Id: I4a0f071f38784b2de034f8c1b0ce75d6d2d326b2
2020-08-08target: fix memory leaks on target_create() failAntonio Borneo1-14/+55
There are failure cases of target_create() that are not checked. Plus, in case of failure the memory allocated in not properly released before returning error. Check all the possible failure in target_create(). Change current_target only when target is successfully created. Add the new target to all_targets list only when target is successfully created. Release all the allocated memory before quit on failure. Use malloc() instead of calloc() for target->type, because the struct will be fully populated with memcpy(). Change-Id: Ib6f91cbb50c28878e7c73dc070b17b8d7d4e902f Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5776 Tested-by: jenkins
2020-08-08target: fix registers reading from non examined targetMikhail Rasputin1-1/+10
If a target is not examined when the debugger tries to connect to it then it can lead to undesired/undefined behavior. In particular it leads to a zero pointer dereference on the aarch64. Change-Id: I67f2b714ab8b2727fd36f3de16d7f9017b4c55fe Signed-off-by: Mikhail Rasputin <mikhail.godlike.rasputin@yandex.ru> Reviewed-on: http://openocd.zylin.com/5727 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-07-26target: fix minor typos and duplicated wordsAntonio Borneo1-6/+6
Change-Id: I8deb0017dc66a243e3dd51e285aa086db500decd Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5766 Tested-by: jenkins
2020-07-17Further deprecate `-rtos riscv`. (#499)Tim Newsome1-0/+19
* Further deprecate `-rtos riscv`. Now using `-rtos riscv` will result in a failure, which you can (until the end of this year) bypass by adding `enable_rtos_riscv` to the configuration. Change-Id: Ic714c303dc1b00c19e8956609730c0f83c845cb6 * Make checkpatch happy. Change-Id: I0469ec37d38ad2eadf25efb5b2b7ac88391c0f51
2020-07-08coding style: fix space separationAntonio Borneo1-20/+20
The checkpatch script from Linux kernel v5.1 complains about using space before comma, before semicolon and between function name and open parenthesis. Fix them! Issue identified using the command find src/ -type f -exec ./tools/scripts/checkpatch.pl \ -q --types SPACING -f {} \; The patch only changes amount and position of whitespace, thus the following commands show empty diff git diff -w git log -w -p git log -w --stat Change-Id: I1062051d7f97d59922847f5061c6d6811742d30e Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5627 Tested-by: jenkins
2020-06-27target: do not print an error on shutdown in target eventsAntonio Borneo1-2/+6
Before commit b3ce5a0ae545 ("target: use LOG_USER to print errors in events") an error in an event handler was silently lost, while now the associated message is printed out. A "shutdown" command in a target event (e.g. in gdb-detach) causes the event to end with error code ERROR_COMMAND_CLOSE_CONNECTION, that triggers the error message: shutdown command invoked Error executing event <event-name> on target <target-name>: The error code returned by the command "shutdown" is required to stop the execution in a script/proc and avoid executing any further command in the script/proc. It is then normal to get an error code from the "shutdown" command and it should not be printed out. Intercept the return code of the event in case of "shutdown", then skip scheduling other target events and return without printing the incorrect error message. Change-Id: Ia3085fb46beacb90a5e4bf0abf7c6e28bb9e6a9b Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reported-by: Laurent Lemele <laurent.lemele@st.com> Reviewed-on: http://openocd.zylin.com/5710 Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Tested-by: jenkins
2020-06-23Merge branch 'master' into from_upstreamTim Newsome1-26/+44
Conflicts: .gitmodules .travis.yml jimtcl src/jtag/core.c src/jtag/drivers/ftdi.c src/jtag/drivers/libjaylink src/jtag/drivers/mpsse.c src/jtag/drivers/stlink_usb.c src/rtos/hwthread.c src/target/riscv/riscv-013.c src/target/riscv/riscv.c tcl/board/sifive-hifive1-revb.cfg Change-Id: I2d26ebeffb4c1374730d2e20e6e2a7710403657c
2020-05-24openocd: properly use jim data typesAntonio Borneo1-1/+1
The jim library exports all the data types through typedef, so there is no need to use the internal struct types. Fix the few remaining inconsistencies in the code. Change-Id: Id4ae0083563ea7a371833374e7b39f17158f66a4 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5662 Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com> Tested-by: jenkins
2020-05-14Make mem2array work with 64-bit addresses. (#475)Tim Newsome1-5/+6
Change-Id: I805389dc9934db5affe3c8059d9630acede956c1
2020-05-09coding style: add missing space when split stringsAntonio Borneo1-2/+2
Long strings are split across few lines; usually split occurs at the white space between two words. Check that the space between the two words is still present. While there, adjust the amount of space between words. Issue identified by checkpatch script from Linux kernel v5.1 using the command find src/ -type f -exec ./tools/scripts/checkpatch.pl \ -q --types MISSING_SPACE -f {} \; Change-Id: I28b9a65564195ba967051add53d1c848c7b8fb30 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5620 Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com> Tested-by: jenkins
2020-04-21Remove BUILD_TARGET64Florian Fainelli1-2/+0
BUILD_TARGET64 creates a larger test matrix and mostly gates the building of the aarch64/armv8 target, make that unconditional, which would help fixing any issues with 64-bit address types anyway. Rebased by Antonio Borneo after commit 1fbe8450a9dd ("mips: Add MIPS64 support") Change-Id: I219f62b744d540d9dde9a42e6b63fd7d91df3dbb Suggested-by: Matthias Welwarsky <matthias@welwarsky.de> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5240 Tested-by: jenkins
2020-04-09target: added events TARGET_EVENT_STEP_START and _ENDJan Matyas1-2/+14
Events TARGET_EVENT_STEP_START and TARGET_EVENT_STEP_END have been added - analogous to already existing events TARGET_EVENT_RESUME_*. This is an example of a concrete use case where having these events is important: In RISC-V processors without Debug Program Buffer, OpenOCD cannot execute fence/fence.i when resuming or single- stepping. With these events implemented, the user can instead provide custom operations to achieve that same effect prior to resuming the processor. Change-Id: I786348ff08940759d99b0f24e9e0ed5a44581094 Signed-off-by: Jan Matyas <matyas@codasip.com> Reviewed-on: http://openocd.zylin.com/5551 Tested-by: jenkins Reviewed-by: Tim Newsome <tim@sifive.com>
2020-03-26target: Add possibility to remove all breakpointsMarc Schink1-5/+10
Change-Id: I46acd57956846d66bef974e0538452462b197cd0 Signed-off-by: Marc Schink <openocd-dev@marcschink.de> Reviewed-on: http://openocd.zylin.com/4916 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2020-03-17rtos: Destroy RTOS and fix memory leakMarc Schink1-0/+2
The memory leak can be reproduced by using an arbitrary RTOS and valgrind: $ valgrind --leak-check=full --show-leak-kinds=all [...] ==9656== 224 (80 direct, 144 indirect) bytes in 1 blocks are definitely lost in loss record 3 of 3 ==9656== at 0x483CD99: calloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) ==9656== by 0x1C541A: os_alloc (rtos.c:79) ==9656== by 0x1C569E: os_alloc_create (rtos.c:111) ==9656== by 0x1C569E: rtos_create (rtos.c:153) ==9656== by 0x1AE332: target_configure (target.c:4899) ==9656== by 0x1AF228: jim_target_configure (target.c:4952) ==9656== by 0x1C9EF9: command_unknown (command.c:1066) ==9656== by 0x313284: JimInvokeCommand (jim.c:10364) ==9656== by 0x313FB6: Jim_EvalObj (jim.c:10814) ==9656== by 0x3154A3: Jim_EvalFile (jim.c:11207) ==9656== by 0x316015: Jim_SourceCoreCommand (jim.c:15230) ==9656== by 0x313284: JimInvokeCommand (jim.c:10364) ==9656== by 0x313B8B: JimEvalObjList (jim.c:10605) [...] Change-Id: I2cd41a154fb8570842601ff4e3e76502f5908f49 Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: http://openocd.zylin.com/5479 Tested-by: jenkins Reviewed-by: Moritz Fischer <moritzf@google.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2020-03-12target: fix crash with jimtcl 0.78Antonio Borneo1-1/+0
The jimtcl commit 41c5ff1809f5 ("jim.c: Fix Object leak in zlib support") https://repo.or.cz/jimtcl.git/commit/41c5ff1809f5 makes Jim_SetResultFormatted() freeing the parameters that have zero refcount. OpenOCD commit 559d08c19ed8 ("jim tests: use installed") adds the only code instance in OpenOCD that first passes a zero refcount object to Jim_SetResultFormatted() and then frees it. By switching jimtcl version to 0.78 or newer this causes a crash of OpenOCD. To trigger the crash in a telnet session, check that the current target is running and type: [target current] arp_waitstate halted 1 Remove the call to Jim_FreeNewObj() after the call to Jim_SetResultFormatted(). Change-Id: I5f5a8bca96a0e8466ff7b789fe578ea9785fa550 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5453 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2020-03-12target: add examine-fail eventTomas Vanek1-1/+6
A configuration script may want to check the reason why examine fails e.g. device has security lock engaged. tcl/target/kx.cfg and klx.cfg is modified to use the new event for testing of the security lock of Kinetis MCU Change-Id: Id1d3a79d24e84b513f4ea35586cd2ab0437ff9b3 Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: http://openocd.zylin.com/4289 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-02-27Introduce ARCv2 architecture related codeEvgeniy Didin1-0/+2
This patch is an initial bump of ARC-specific code which implements the ARCv2 target(EMSK board) initializing routine and some basic remote connection/load/continue functionality. Changes: 03.12.2019: -Add return value checks. -Using static code analizer next fixes were made: Mem leak in functions: arc_jtag_read_memory,arc_jtag_read_memory, arc_jtag_write_registers, arc_jtag_read_registers, jim_arc_add_reg_type_flags, jim_arc_add_reg_type_struct, arc_build_reg_cache, arc_mem_read. Dead code in "arc_mem_read"; In arc_save_context, arc_restore_context correct arguments in"memset" calls. In "build_bcr_reg_cache", "arc_build_reg_cache" check if list is not empty. 29.12.2019 -Moved code from arc_v2.c to arc.c -Added checks of the result of calloc/malloc calls -Reworked arc_cmd.c: replaced spagetty code with functions -Moved to one style in if statements - to "if(!bla)" -Changed Licence headers 22.01.2020 -Removed unused variables in arc_common -Renamed register operation functions -Introduced arc_deinit_target function -Fixed interrupt handling in halt/resume: * add irq_state field in arc_common * fix irq enable/disable calls ( now STATUS32 register is used) -Switched from buf_set(get)_us32() usage to target_buffer_set(get)_u32() -Made some cleanup 30.01.2020 -Removed redundant arc_register struct, moved target link to arc_reg_desc -Introduced link to BCR reg cache in arc_common for freeing memory. -Now arc_deinit_target frees all arc-related allocated memory. Valgrind shows no memory leaks. -Inroduced arch description in arc.c 01.02.2020 -Remove small memory allocations in arc_init_reg. Instead created reg_value and feature fields in arc_reg_desc. -Add return value for arc_init_reg() func. -Replaced some integer constants(61,62,63) with defines. -Removed redundant conversions in arc_reg_get_field(). -Moved iccm/dccm configuration code from arc_configure() to separate functions. 19.02.2020 -Change sizeof(struct) to sizeof(*ptr) in allocations -Changed if/while(ptr != NULL) to if/while(ptr) -Removed unused variables from struct arc_jtag -Add additional structs to arc_reg_data_type to reduce amount of memory allocations calls and simplifying memory freeing. -Add helper arc_reg_bitfield_t struct which includes reg_data_type_bitfield object and char[] name. Reduces memory allocations calls. -Add limit for reg_type/reg_type_field names(20 symbols). -Add in jim_arc_add_reg_type*() functions additional argnument checks(amount of field/name size). -In jim_arc_add_reg_type*() reduced amount of memory allocations. -Cleanup of jim_arc_add_reg_type*() functions. -For commands update ".usage" fields according docopt. -Cleanup in arc_jtag.c -Renamed functions which require jtag_exeutre_queue() to arc_jtag_enque_*() -Add arc_jtag_enque_register_rw() function, which r/w to jtag ir/dr regs during regiter r/w. 24.02: -Change include guards in arc* files according coding style -Remove _t suffix in struct arc_reg_bitfield_t -Some cleanup Change-Id: I6ab0e82b12e6ddb683c9d13dfb7dd6f49a30cb9f Signed-off-by: Evgeniy Didin <didin@synopsys.com> Cc: Alexey Brodkin <abrodkin@synopsys.com> Reviewed-on: http://openocd.zylin.com/5332 Tested-by: jenkins Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>