aboutsummaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)AuthorFilesLines
2022-05-29flash/nor/core, target: don't ask for working mem if no target algoTomas Vanek2-2/+6
The command 'flash erase_check' showed the message 'Running slow fallback erase check - add working memory' even in the case the target didn't implement blank_check_memory. Change return code of target_blank_check_memory() in this case and sense it in default_flash_blank_check() and show a message without a request for working memory. Change-Id: I7cf9bf77742964b4f377c9ce48ca689e57d0882f Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: https://review.openocd.org/c/openocd/+/6765 Tested-by: jenkins Reviewed-by: Tim Newsome <tim@sifive.com>
2022-05-27Give each SMP group a unique number.Tim Newsome2-2/+4
This helps e.g. if there are 8 cores, and cores 0--3 are in one SMP group while 4--7 are in another group. (And there are 2 gdb instances connected, one debugging the first group, and one the second.) Signed-off-by: Tim Newsome <tim@sifive.com> Change-Id: I7b6c9382eadf964529105eaf0411a42d48768668 Reviewed-on: https://review.openocd.org/c/openocd/+/6979 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-05-21semihosting: add semihosting_basedir commandErhan Kurubas3-3/+59
This command allows users to set base working directory for the semihosting I/O operations.Default is the current OpenOCD directory. Signed-off-by: Erhan Kurubas <erhan.kurubas@espressif.com> Change-Id: I80c5979e4c96d66cccdd12cc6fcd5f353e5c6b4d Reviewed-on: https://review.openocd.org/c/openocd/+/6888 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-05-21flash: fix clang static analyzer build errorsErhan Kurubas2-5/+0
Fixes "variable set but not used" errors. Tested with Homebrew clang version 13.0.1 Signed-off-by: Erhan Kurubas <erhan.kurubas@espressif.com> Change-Id: Ia90baf5b4857db2b5569ebe6adbbb832de772aad Reviewed-on: https://review.openocd.org/c/openocd/+/6971 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-05-21target: fix clang static analyzer warningTomas Vanek1-1/+1
Removes Warning: line 6482, column 12 1st function call argument is an uninitialized value Use target ptr directly as checked in previous lines instead of dereferencing head->target Change-Id: I6804b776fd493af71f3098d702f9cdc7acb50151 Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: https://review.openocd.org/c/openocd/+/6970 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-05-18target/riscv: fix 'reset run' after 'reset halt'Tomas Vanek1-5/+5
'reset halt' does not clear DM_DMCONTROL_HALTREQ at deassert_reset(). If hw reset line is configured e.g. 'reset_config srst_only' the folowing 'reset run' halts: > gd32v.cpu curstate running > reset halt JTAG tap: gd32v.cpu tap/device found: 0x1000563d (mfg: 0x31e ... > gd32v.cpu curstate halted > reset JTAG tap: gd32v.cpu tap/device found: 0x1000563d (mfg: 0x31e ... > gd32v.cpu curstate halted <<<<---- wrong!!! > reset JTAG tap: gd32v.cpu tap/device found: 0x1000563d (mfg: 0x31e ... > gd32v.cpu curstate running Clear DM_DMCONTROL_HALTREQ when acking reset. Change-Id: Iae0454b425e81e64774b9785bb5ba1d4564d940b Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: https://review.openocd.org/c/openocd/+/6961 Tested-by: jenkins Reviewed-by: Tim Newsome <tim@sifive.com>
2022-05-14drivers/am335xgpio: Add AM335x driver for bitbang support on BeagleBonesSteve Marple3-0/+742
Change-Id: Iac1c9f3d380e2474c8b77407c89c2aad96fbf2ea Signed-off-by: Steve Marple <stevemarple@googlemail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6941 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-05-14bcm2835gpio: Fix incorrect GPIO validationSteve Marple1-14/+14
Incorrect validation prevented GPIO0 from controlling the direction of the SWDIO buffer or operating TRST/SRST. Have all GPIO number validation checks performed by is_gpio_valid(). Change-Id: Ib8fb704ab588a618ac41c111f6168d658891d92c Signed-off-by: Steve Marple <stevemarple@googlemail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6938 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2022-05-14openocd: add post-init and pre-shutdown helpersAntonio Borneo3-0/+27
It is a common requirement to automatically execute some command after "init". This can be achieved, either in scripts or through OpenOCD command line, by explicitly calling "init" followed by the commands. But this approach fails if the request for post-init commands is spread across configuration files; only one of the files can split pre-init and post-init status by calling "init". The common workaround is to "rename" the command "init" and replace it with a TCL proc that calls the original "init" and the post-init commands. E.g. in Zephyr script [1]. To simplify and formalize the post-init execution, use a TCL list that contains the list of commands to be executed. Every script can contribute adding new commands, e.g. using "lappend". In the same way, formalize the pre-shutdown execution with a TCL list of user commands to be executed before OpenOCD exit. Document them and add trivial examples. Drop from documentation the suggestion to rename "shutdown". Change-Id: I9464fb40ccede3e7760d425873adca363b49a64f Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Link: [1] https://github.com/zephyrproject-rtos/zephyr/blob/zephyr-v2.7.1/boards/arm/nucleo_h743zi/support/openocd.cfg#L15 Reviewed-on: https://review.openocd.org/c/openocd/+/6851 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
2022-05-14aarch64: don't wait for smp targets halted in deassert resetAntonio Borneo1-3/+7
The function target_type::deassert_reset() is called for every target after reset is deasserted. If the target fails to get halted, we log a warning and issue a halt request for the target itself. Current code calls the generic target_halt() that: - extends the halt to all the targets in the SMP node; - waits for targets to halt. This breaks the logic of running target_type::deassert_reset() per target. Plus, waiting for targets to halt delays the call of target_type::deassert_reset() for the next targets. Replace the call to target_halt() with the aarch64 specific function to halt the single target. Pass the parameter HALT_LAZY to prevent the wait for target halted. Similar solution is already implemented for cortex_a. Change-Id: I446dc03cb91524c6d388db485bc2388177af77b6 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6947 Tested-by: jenkins
2022-05-14arm_adi_v5: add support for 64bit Class 0x9 ROM tablesAntonio Borneo1-11/+32
Arm documentation does not explicitly report the order of the two 32bit words that compose the 64bit value. But both ADIv5 and ADIv6 specify that only little-endian is supported (ADIv5.2 obsoletes the big-endian support). This change reads the 64bit value in little-endian. Detect the 64bit content and use it. Change-Id: I723ec099c7e8c70c1f9a568e32ea867fcbf1f1db Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6465 Tested-by: jenkins
2022-05-14arm_adi_v5: replace dap_lookup_cs_component()Antonio Borneo2-76/+85
With the generic function for ROM table walk-through, reimplement dap_lookup_cs_component(). Catch the code CORESIGHT_COMPONENT_FOUND and halt the search. While there, drop two macros in arm_coresight.h, now unused. Change-Id: I589ef7ae8a651d0c422ce7d0b4ed913713a8217e Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6824 Tested-by: jenkins
2022-05-14arm_adi_v5: let dap_lookup_cs_component() to get AP dbgbaseAntonio Borneo4-28/+24
Simplify the code in cortex_a and aarch64 by moving the call to dap_get_debugbase() inside dap_lookup_cs_component(). This has the further effects: - dap_get_debugbase() is not referenced outside arm_adi_v5.c and becomes static; - dap_lookup_cs_component() looses one parameter; - the coreid parameter 'idx' is passed as value; - the caller in aarch64 don't have and don't print the irrelevant value of AP register APID; - fixes the debug message in the caller in aarch64 to print the coreid value instead of always zero. Change-Id: Ic7f0f643fdf067c059c8f2455a02ff18a3fed054 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6823 Tested-by: jenkins
2022-05-14arm_adi_v5: abstract actions during ROM table parsingAntonio Borneo1-30/+123
Now all the actions (build command output) of command "dap info" are decoupled from the ROM walk-through. Pass the actions as a generic parameter to ROM walk-through code. Put as private data every information that is only required by the actions and not by the ROM walk-through. Change-Id: I3b6ad112ea21296458c94aebbf91bf65bf6657a7 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6822 Tested-by: jenkins
2022-05-14arm_adi_v5: separate ROM table parsing from command output [3/3]Antonio Borneo1-17/+41
This change only targets the output of rtp_rom_loop(). Change-Id: If9ac013798923428c3b897a969887e98b6935a2b Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6821 Tested-by: jenkins
2022-05-14arm_adi_v5: separate ROM table parsing from command output [2/3]Antonio Borneo2-65/+107
This change only targets the output of rtp_cs_component(). To easily propagate the coordinates of the CoreSight component, add them in the struct that holds the register values. While there, define a macro for the max depth of ROM tables. Change-Id: I75e5ef4f9419da3192123aebcd61471c2af9374f Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6820 Tested-by: jenkins
2022-05-14arm_adi_v5: separate ROM table parsing from command output [1/3]Antonio Borneo1-6/+44
In OpenOCD arm_adi_v5 we have already two implementations of code for parsing the ADIv5 ROM table: - in the commands "dap info" and "$dap_name info"; - in the function dap_lookup_cs_component(). Adding support for ADIv6 requires extending both implementations. Moreover, current code does not handle few aspects of the ROM parsing, e.g. the "Power Domain IDs". To add such extensions both implementations should be touched. I plan to add a command to parses (again) the ROM table and dump a simple prototype of a configuration script for the target, useful while analysing a new target. Keeping aligned all these implementation would be too complex. With focus to "dap info" command, decouple the part of code to walk-through the ROM table from the code that creates the command output. The idea is to keep a single implementation for the walk-through code, while parametrizing the output code to handle the generation of a configuration script or the result of the function dap_lookup_cs_component(). This change only targets the output of MEM-AP header Further changes will target other parts of the code. While there, add a message if MEM-AP is not accessible. Change-Id: I112f637edfdb8688afb4e631297f6536da9604f1 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6819 Tested-by: jenkins
2022-05-14arm_adi_v5: handle faulting entry in ROM tableAntonio Borneo1-2/+5
ARM IHI0031F "Arm Debug Interface Architecture Specification" chapter C2.6.1 "BASE, Debug Base Address register" reports: A debugger must handle the following situations as non-fatal errors: - ... - An entry in the ROM Table points to a faulting location. - ... Typically, a debugger issues a warning if it encounters one of these situations. However, Arm recommends that it continues operating. An example of an implementation that might cause errors of this type is a system with static base address or ROM Table entries that enable entire subsystems to be disabled, for example by a tie-off input, packaging choice, fuse, or similar. Don't halt ROM table parsing if one entry causes an error; log the error condition and continue to next entry. Not sure if we have to send an ABORT before continuing. Change-Id: I94fdb5b175bfb07dde378149421582b7e7cd5b09 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6818 Tested-by: jenkins Reviewed-by: Daniel Goehring <dgoehrin@os.amperecomputing.com>
2022-05-14arm_adi_v5: report sysmem on class 0x9 ROM tablesAntonio Borneo1-1/+10
As Class 0x1 ROM table, also Class 0x9 ROM tables encodes a flag for system memory access. Detect the flag in rtp_cs_component() and dump the same message for both type of ROM tables. Extend rtp_read_cs_regs() to read ARM_CS_C9_DEVID. Change-Id: Ic85d1ea068ed706ceedfd65076ff4c96d04e9792 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6817 Tested-by: jenkins Reviewed-by: Daniel Goehring <dgoehrin@os.amperecomputing.com>
2022-05-14arm_adi_v5: split ROM table loop from generic coresightAntonio Borneo1-36/+66
During ROM table parsing, each ROM table entry points to a CoreSight component that can, in turn, be another ROM table. Split the specific code for ROM table handling from the generic CoreSight code. Log an error if a ROM table entry cannot be read. Change-Id: I5ad106a99b9c21ddb48b5b162ae87101e4f49878 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6816 Tested-by: jenkins
2022-05-14arm_adi_v5: rework dap_read_part_id()Antonio Borneo1-69/+80
Rework dap_read_part_id() while preparing for reorganizing the 'ROM Table Parsing' (RTP): - rename it with 'rtp' prefix; - extends it to read other CoreSight registers, thus improving the overall speed by queuing more reads; - reduce the list of arguments by using a struct; - reorder the reads by increasing offset, potentially gaining speed using MEM_AP_REG_BDx and/or auto-increment; - log a debug message in case of read error. Change-Id: I6544ac7740b808a6c0fbacf97ac00b97f5bd3832 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6815 Tested-by: jenkins
2022-05-14arm_adi_v5: add support for display Class 0x9 ROM tablesFlorian Fainelli1-22/+47
ADI v5.1 and v6.0 permit the definition of CoreSight components (class 9 ROM entries). dap_rom_display() is refactored a bit such that we always end up with attempting to parse the ROM contents using the appropriate upper limit for class 1 and 9 ROM types. Change-Id: I4ba497b3807f1f11f06186eb6e61959ea3540c59 Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6359 Tested-by: jenkins
2022-05-14arm_adi_v5: describe Class 0x9 Device Architecture registerAntonio Borneo1-0/+49
Use the list of values from ARM IHI0029E to decode and print the Device Architecture register. Add attribute 'unused' to the function, not used yet. Change-Id: I7b1dd204bd1db671578c588372b667e23611876c Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6463 Tested-by: jenkins Reviewed-by: Daniel Goehring <dgoehrin@os.amperecomputing.com>
2022-05-14adi_v5_jtag: reduce verbosity on persistent WAITAntonio Borneo1-2/+2
In case of AP not responding, e.g. not clocked, the first WAIT reply is logged as: DAP transaction stalled (WAIT) - slowing down then OpenOCD retries the transaction few times, until it timeouts. At each retry it prints the message: DAP transaction stalled during replay (WAIT) - resending Depending on JTAG speed and transport latency, the amount of log messages can be quite annoying and not relevant. The last printed line is at timeout: Timeout during WAIT recovery Reduce the verbosity. Change-Id: I5a7a337527c98b2450de59066b13713511c2894f Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6814 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-by: Daniel Goehring <dgoehrin@os.amperecomputing.com>
2022-05-14arm_coresight: define ARM_CS_CIDR_CLASS()Antonio Borneo2-2/+2
Right now it has a single use but it will soon be used more. Change-Id: I9a819c65df467fc859e4b5251035a17ed33daa35 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6813 Tested-by: jenkins Reviewed-by: Daniel Goehring <dgoehrin@os.amperecomputing.com>
2022-05-07target: document possibly unreachable target in deinit_target()Tomas Vanek1-0/+11
Change-Id: I95ff3d200bb2c8f5bc43a34c92726d9c47f8c172 Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: https://review.openocd.org/c/openocd/+/6953 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-05-07target: fix build with jimtcl 0.79Antonio Borneo1-0/+8
In jimtcl 0.80 the prototype of Jim_DictPairs() has changed. The only code in OpenOCD that uses Jim_DictPairs() has been merged recently and it only uses the current jimtcl syntax. To allow compiling OpenOCD master branch with older versions of jimtcl, detect the version of jimtcl and use the appropriate syntax. Change-Id: I6fc78303b6a4db064a97f326c46119f4568e88f3 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reported-by: dullfire@yahoo.com Reviewed-on: https://review.openocd.org/c/openocd/+/6948 Tested-by: jenkins
2022-05-07bluenrg: add support for bluenrg-lps device and boardSalvatore Giorgio PECORINO1-3/+16
Added bluenrg-lps support Added file for the board steval-idb012v1 Fixed size_info information using a mask Changed the if condition in bluenrg-x.cfg to be valid only for bluenrg-1 and bluenrg-2 Signed-off-by: Salvatore Giorgio PECORINO <salvatore-giorgio.pecorino@st.com> Change-Id: Ic0777ec0811ee6fac7d5e1d065c4629e47d84a1f Reviewed-on: https://review.openocd.org/c/openocd/+/6928 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-05-07server/gdb: fix gdb remote monitor cmd on multi-targetAntonio Borneo1-4/+16
Commit 5ebb1bdea1df ("server/gdb: fix return of gdb remote monitor command") replaces the call to command_run_line() with call to Jim_EvalObj() but does not properly set the "context". In multi-target environment, his can cause the erroneously execution of the command on the wrong target. Copy from the code in command_run_line() the proper setup before executing Jim_EvalObj(). Change-Id: I56738c80779082ca146a06c01bc30e28bc835fd3 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reported-by: Bohdan Tymkiv <bohdan200@gmail.com> Fixes: 5ebb1bdea1df ("server/gdb: fix return of gdb remote monitor command") Reviewed-on: https://review.openocd.org/c/openocd/+/6966 Tested-by: jenkins Reviewed-by: Bohdan Tymkiv <bohdan200@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-by: Tim Newsome <tim@sifive.com>
2022-05-07smp: deprecate legacy SMP core switching supportAntonio Borneo3-0/+11
The deprecation was already in the documentation since v0.11.0 through commit 85ba2dc4c6ab ("rtos/hwthread: add hardware-thread pseudo rtos") but OpenOCD was not informing the user printing a runtime message. Remove the deprecated method from the documentation and print a deprecated message at runtime. There is no reliable way to print the same message in GDB console, so we have to rely on user noticing it in the OpenOCD log. Target is to remove the functionality after v0.12.0. Change-Id: Idd2d9e3b6eccc92dcf0432c3c7de2f8a0fcabe9f Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6862 Tested-by: jenkins
2022-05-01drivers/cmsis-dap: Correct the DAP protocol parameter parsing errorjihongbin1-7/+7
Fixes: 01030fb89354 (drivers/cmsis-dap: tidy up buffer access) Change-Id: Id192d3930a89980d641058b6444d12caec19ce6f Signed-off-by: Hongbin Ji <longma@orbbec.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6954 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: jihongbin <jhb_ee@163.com>
2022-04-30target/disassembler: update capstone include path to <capstone.h>fatalc2-2/+2
on macos (homebrew base) `pkg-config --cflags capstone` output with `-I/opt/homebrew/Cellar/capstone/4.0.2/include/capstone` gcc not find headers on parent "include" path, causes build error `fatal error: 'capstone/capstone.h' file not found` it's ok to change to <capstone.h> for all platforms. Signed-off-by: fatalc <cnfatal@gmail.com> Change-Id: Ia2e2058024d4fc1a57a8b4ea847c664d74f67efb Reviewed-on: https://review.openocd.org/c/openocd/+/6946 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-04-30target/arm_cti: Fix error handling in 'cti create'Marc Schink1-1/+6
Handle JIM_CONTINUE return value of adiv5_jim_mem_ap_spot_configure(), otherwise OpenOCD silently quits when an unknown option is provided. Change-Id: I9b1351c0911e74999d8dd1260ede9760088510d7 Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: https://review.openocd.org/c/openocd/+/6944 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-04-30bcm2835gpio: Make buffer an output before the GPIO connected to itSteve Marple1-6/+7
The correct ordering is required to prevent two outputs connected together. Change-Id: I634a9ca7e0ccf337d1723011b8aee1f2d81efbcf Signed-off-by: Steve Marple <stevemarple@googlemail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6937 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-04-30linuxgpiod: add SWDIO bufferSteve Marple1-0/+47
The SWDIO buffer requires a direction pin to select input or output direction. Output is selected by a high logic level (matches bcm2835gpio driver). Change-Id: I240cb99a5dfea08121bb33d4b5e2108ce7597468 Signed-off-by: Steve Marple <stevemarple@googlemail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6936 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-04-24flash/nor/stm32f1x: add can_load_options flag for GD32F1x0, F3x0 and E23xTomas Vanek1-0/+3
According to GigaDevice user manuals the devices have OBRLD bit in FMC_CTL register which is functionally compatible with OBL_LAUNCH @ FLASH_CR of STM32 counterparts. Change-Id: I84d231b38815fcb6452fd73b9153b269cce3b737 Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: https://review.openocd.org/c/openocd/+/6759 Tested-by: jenkins Reviewed-by: Andrzej Sierżęga <asier70@gmail.com>
2022-04-24flash/stm32f1x: add support for RISC-V GigaDevice GD32VF103Tomas Vanek1-44/+161
The device has compatible flash macro with STM32F1 family, reuse stm32f1x driver code. Detect non-ARM target - for simplicy test target type name 'riscv' and the address has 32 bits. In case of RISC-V CPU use simple chunked write algo - async algo cannot be used as the core implemented in this device doesn't allow memory access while running. Change-Id: Ie3886fbd8573652691f91a02335812a7300689f7 Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: https://review.openocd.org/c/openocd/+/6704 Tested-by: jenkins Reviewed-by: Tim Newsome <tim@sifive.com>
2022-04-23rtos: zephyr: do not use deprecated symbols nameJulien Massot1-3/+3
Zephyr plan to remove openocd specific symbols in favour of more generic one. These generic symbols has been introduced in Zephyr 2.6. Signed-off-by: Julien Massot <julien.massot@iot.bzh> Change-Id: I89418c9c378fb8b8baa29763fc6f1b6e652dc7ef Reviewed-on: https://review.openocd.org/c/openocd/+/6844 Tested-by: jenkins Reviewed-by: Stephanos Ioannidis <root@stephanos.io> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-04-23target/image: fix - p_flags field in ELF64 segment headers is 64 bits wideJan Matyas2-4/+4
Fixed the reading of p_flags in ELF64 segment headers - that field is 64 bits wide. Change-Id: I053ca57d36efb54b7c638484acd6c7a2fbcbd05a Signed-off-by: Jan Matyas <matyas@codasip.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6927 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-04-23server/gdb: fix return of gdb remote monitor commandAntonio Borneo1-1/+42
Current implementation for gdb remote monitor command uses the command_run_line() to execute the command. While command_run_line() has several advantages, it unfortunately hides the error codes and outputs the result of the command through LOG_USER(), which is not what gdb requires. See 'qRcmd' in https://sourceware.org/gdb/onlinedocs/gdb/General-Query-Packets.html Replace command_run_line() with Jim_EvalObj() and parse the output to provide the proper result to gdb. Can be tested by defining in OpenOCD: proc a {} {return hello} proc b {} {return -code 4} proc c {} {return -code 4 "This is an error!"} then by executing in gdb console: monitor a monitor b monitor c monitor foo Change-Id: I1b85554d59221560e97861a499e16764e70c1172 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reported-by: Torbjorn Svensson <torbjorn.svensson@st.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6886 Tested-by: jenkins
2022-04-13flash/nor/stm32f1x: lock flash in case of errorTomas Vanek1-39/+46
The current code locks the flash controller in case of error during flash write only. An error in other flash operations may cause the flash is left unlocked. Implement locking also after error in erase, mass erase, options write and erase. Change-Id: I26c2ed7914e7847122306f29b777b9eefd1dc580 Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: https://review.openocd.org/c/openocd/+/6710 Tested-by: jenkins Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2022-04-13flash/nor/stm32f1x: unify flash error reportingTomas Vanek1-17/+15
stm32x_wait_status_busy() has two side effects in case of flash programming error: - reports error - clears error bit in status register Use stm32x_wait_status_busy() to report also flash error during target algo flash write. While on it use more descriptive error codes in stm32x_wait_status_busy(). Change-Id: I6e1cffc2aa5411b918a23ed62d5194910888a9d1 Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: https://review.openocd.org/c/openocd/+/6709 Tested-by: jenkins Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2022-04-13flash/nor/stm32f1x: tidy up async algo supporting codeTomas Vanek1-21/+26
Use target_get_working_area_avail() instead of try-fail iteration. Call destroy_reg_param() in a for cycle. Change-Id: I1891d1ffdea99010c6ab66b9578400b9d7922e20 Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: https://review.openocd.org/c/openocd/+/6708 Tested-by: jenkins Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2022-04-13flash/nor/stm32f1x: remove write alignment codeTomas Vanek1-23/+14
Use flash infrastructure to ensure writes are halfword aligned. Change-Id: Iddca3a256ace3486a23e1a9cb6a31c7a91ee58bf Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: https://review.openocd.org/c/openocd/+/6707 Tested-by: jenkins Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2022-04-13flash/nor/stm32f1x: allow write fallback for flash optionsTomas Vanek1-34/+50
Mostly refactoring. Rename original stm32x_write_block() to stm32x_write_block_async() as it uses target async algo. Introduce new stm32x_write_block() and move slow, host controlled fallback flash write there. The change allows stm32x_write_options() to use slow flash write fallback. While on it rename variables where halfword count is stored. Change-Id: I386ae15cf052b1490461ed8f7eea5b4403d466f7 Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: https://review.openocd.org/c/openocd/+/6706 Tested-by: jenkins Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2022-04-03drivers/cmsis-dap: Remove stray whitespaceMarc Schink1-1/+1
Change-Id: I7b60f9e87af2f582864ce94198d0343acf7d45f2 Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: https://review.openocd.org/c/openocd/+/6883 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
2022-04-03libusb_helper.h: Increase USB timeoutGabor Csapo7-36/+46
When we debug a target that works as a USB device, halting the target causes the USB communication with the USB host to become unresponsive. The host will try to reconnect/reset/setup the unresponsive device during which communication with other devices on the same USB bus can get stalled for several seconds. If the JTAG adapter is on the same bus, we need to make sure openOCD will wait for packets at least as long as the host USB stack. Otherwise the USB stack might deliver a valid packet, but openOCD would ignore it due to the timeout. The xHCI spec uses 5 sec timeouts, so let's use that in openOCD with some margin. Use this value in all libusb calls. HID API might have a libusb backend and would probably be victim to the same bug, so it should use this timeout, too. Ticket: https://sourceforge.net/p/openocd/tickets/343/ Signed-off-by: Gabor Csapo <gaborcsapo@google.com> Change-Id: Ia3dc1356e676fe550f57a4c72f7a24ba296b6af2 Reviewed-on: https://review.openocd.org/c/openocd/+/6882 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-04-03gdb_server: Improve logging of GDB-remote packetsJan Matyas1-14/+31
- Print also the target name, not just the packet contents. This is important when there are more GDB servers (more debug-able targets) active in one OpenOCD session. - Log also the received Ctrl-C requests coming from GDB (one byte 0x3), ACKs ("+") and NACKs ("-"). - Do not print zero-length incoming packets (this occurred when Ctrl-C packets were received). - Removed a stray apostrophe "'" that got printed in gdb_log_outgoing_packet() Signed-off-by: Jan Matyas <matyas@codasip.com> Change-Id: If68fe0a8aa635165d0bbe6fa0e48a4645a02da67 Reviewed-on: https://review.openocd.org/c/openocd/+/6879 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-03-26helper/bits: add BIT_ULL and GENMASK macrosAntonio Borneo2-1/+5
To support 64 bits bit and masks Replace local definition of BIT in rtos/chromium-ec Change-Id: I1f268d6e8790f1b07bf798680b797878ce81064b Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6857 Tested-by: jenkins
2022-03-26openocd: include config.h in every file .cAntonio Borneo6-0/+24
Including config.h as first is required for every C file. Add it to the C files that still miss it. Change-Id: I1a210e7d3a854958a85a290b086ad8a9f5176425 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6856 Tested-by: jenkins