aboutsummaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)AuthorFilesLines
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
2022-03-26arm_tpiu_swo: fix autodetection of SWO pin frequencyAntonio Borneo1-4/+13
While the documentation reports that SWO pin frequency can be omitted to let the adapter autodetect the value, the code wrongly drops an error when pin frequency is not specified. Don't require the pin frequency to be set at "enable", but verify that the adapter has properly changes it to a valid value. Change-Id: I3dfbe3256e8887ef4f03512769b06381cdc9db0d Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reported-by: Karl Palsson <karlp@tweak.net.au> Fixes: 184724d14e12 ("arm_tpiu_swo: add support for independent TPIU and SWO") Reviewed-on: https://review.openocd.org/c/openocd/+/6310 Tested-by: jenkins Reviewed-by: zapb <dev@zapb.de>
2022-03-26semihosting: fix mode flags for local host open()Antonio Borneo1-3/+18
Commit dbbac5f11d66 ("semihosting: use open mode flags from GDB, not from sys/stat.h") fixes the conversion of the mode flags from ARM semihosting encoding for SEMIHOSTING_SYS_OPEN to GDB mapping for open(). Doing this, it breaks the conversion to local host's OS mapping for open(). Split the conversion array to one for GDB and one for local host. The local host conversion array is taken directly from the old code. Change-Id: I385321ddd32c3ac5cf6da3f1ce9eff76b05dd527 Fixes: dbbac5f11d66 ("semihosting: use open mode flags from GDB, not from sys/stat.h") Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reported-by: Erhan Kurubas <erhan.kurubas@espressif.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6870 Tested-by: jenkins
2022-03-19breakpoints: fix build on -fno-inlineAntonio Borneo1-2/+2
Some configuration of GCC could default to -fno-inline, causing the build to fail after commit fb43f1ff4e2f ("target: Rework 'set' variable of break-/watchpoints"). Switch the new inline functions to 'static inline', as it's widely used in the rest of the code. Change-Id: I8bf31045a137bd34ed825f4b2a9338eb3c70046d Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Fixes: fb43f1ff4e2f ("target: Rework 'set' variable of break-/watchpoints") Reviewed-on: https://review.openocd.org/c/openocd/+/6881 Tested-by: jenkins
2022-03-19target: Rework 'set' variable of break-/watchpointsMarc Schink21-242/+258
The 'set' variable name suggests a boolean data type which determines whether a breakpoint (or watchpoint) is active. However, it is also used to store the number of the breakpoint. This encoding leads to inconsistent value assignments: boolean and integer values are mixed. Also, associated hardware comparator numbers, which are usually numbered from 0, cannot be used directly. An additional offset is required to store the comparator numbers. In order to make the code more readable and the value assignment more consistent, change the variable name to 'is_set', its data type to 'bool' and introduce a dedicated variable for the break-/watchpoint number. In order to make the review easier, the data types of various related variables (e.g. number of breakpoints) are not changed. While at it, fix a few coding style issues. Change-Id: I2193f5639247cce6b80580d4c1c6afee916aeb82 Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: https://review.openocd.org/c/openocd/+/6319 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-03-19flash/stm32l4x: fix auto-probe when RDP is promoted from 0 to 0.5Tarek BOCHKATI1-2/+13
Considering this use case: (using STM32 L5 or U5) 1- first probe : TZEN enabled, RDP level 0 flash_regs_base |= STM32L5_REGS_SEC_OFFSET => 0x50022000 2- the user promotes the RDP to level 0.5 3- the second probe, fails to read OPTR using secure flags_regs_base: used OPTR address is 0x50022040 Step 3 fails because when RDP is level 0.5, we should use Non-Secure flash registers. To fix this, always use NS flash regs to read OPTR in probe functions. Fixes: 80d323c6e82b (flash/stm32l4x: introduce auto-probe when OPTR is changed) Change-Id: I296aa633972b0c410b927488c999584a07b912d3 Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6864 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
2022-03-19stlink: enable queuing with stlink-server API v3Tarek BOCHKATI1-8/+21
ST-Link Server 2.1.0-1 fixes concurrency issue with RW_MISC command Starting from this version the ST-Link Server API is now v3. In this change we save the ST-Link Server version, and check if the API is greater or equal to 3 to enable the queuing. Change-Id: I239eb81024700514c607a269b66651f457206faa Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6876 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-03-19semihosting: permit redirection of semihosting I/O to TCPTarek BOCHKATI2-17/+332
This command permits the usage of a TCP port to perform debug and stdio operations: - debug : READC, WRITEC and WRITE0 - stdio : READ, WRITE This will permit the separation of semihosting message from OpenOCD log, and separate semihosting messages per core. syntax: arm semihosting_redirect (disable | tcp <port> [debug|stdio|all]) this allows to select which operations to be performed via TCP (debug, stdio or all (default)). Note: for stdio operations, only I/O from/to ':tt' file descriptors are redirected. tested using netcat on ubuntu Change-Id: I37053463667ba109d52429d4f98bc98d0ede298d Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/5562 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-03-19keep-alive: drop link with log frameworkAntonio Borneo4-21/+49
OpenOCD implements the GDB keep-alive by sending empty strings as output for GDB client. This has been implemented as part of the log framework, creating an odd dependency. Move the keep-alive notifications out of log framework. For the moment, keep keep_alive() inside log.c, but it should be moved in server.c This should also fix an old issue with KDE Konsole when tab alert for activity is enabled. The empty strings is sent to all the connections, including telnet, and causes the tab running OpenOCD telnet to continuously show activity even when no new text is printed. Anyway, I cannot replicate this issue anymore. Change-Id: Iebb00b00fb74b3c9665d9e1ddd3c055275bfbd43 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6840 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
2022-03-19gdb_server: simplify logic to enable/disable gdb_log_callback()Antonio Borneo1-13/+29
GDB client cannot always display generic messages from OpenOCD. The callback gdb_log_callback() is continuously added and removed to follow the GDB status and thus enabling/disabling sending the OpenOCD output to GDB. While this is a nice stress test for log_{add,remove}_callback(), it is also a waste of computational resources that could impact the speed of OpenOCD during GDB user interactions. Add a connection-level flag to enable/disable the log callback and simply change the flag instead of adding/removing the callback. Use an enum for the flag instead of a bool. This improves code readability and allows setting other states, e.g. keep-alive through asynchronous notification https://review.openocd.org/4828/ Change-Id: I072d3c6928dedfd0cef0abe7acf9bdd4b89dbf5b Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6839 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
2022-03-19server: change prototype of add_service()Antonio Borneo9-46/+107
To easily add new methods to a service, pass all the methods through a struct. While there, drop the typedef for the methods and add currently unused new methods to support keep-alive and connections during keep-alive. No change in functionality. Change-Id: I2b5e7140db95021f6e7201e9d631ee340c60b453 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6838 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
2022-03-19log: drop global current_timeAntonio Borneo1-4/+2
The value of this variable is not shared across functions, so the variable can be local. Change-Id: I00b0444209e81c07bb57fb732f47052ad0596728 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6837 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
2022-03-19server: fix: remove kept_alive() from server loopAntonio Borneo1-1/+0
The kept_alive() action is specific of a server that enjoyed an unscheduled keep_alive and want to communicate it to the keep alive logic to reschedule next keep_alive(). In server loop we are not expected to call kept_alive(). Remove it! This call was erroneously added in commit 94e75e0c06c4. Later, commit 7442b26d45dc properly added the same call in gdb_put_packet(), but incorrectly left the older in place. Change-Id: If476410f870eebfbdaccdb1366ba2e9254e2fdf6 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6836 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
2022-03-12target: Deprecate 'array2mem' and 'mem2array''Marc Schink2-50/+30
Replace 'mem2array' and 'array2mem' with a Tcl wrapper that internally uses 'read_memory' and 'write_memory'. The target-specific 'mem2array' and 'array2mem' functions remain for now. Change-Id: If24c22a76ac72d4c26916a95f7f17902b41b6d9e Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: https://review.openocd.org/c/openocd/+/6308 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-03-12target/tcl: Add 'read_memory' and 'write_memory'Marc Schink1-0/+321
These functions are meant as replacement for 'mem2array' and 'array2mem'. The main benefits of these new functions are: * They do not use Tcl arrays but lists which makes it easier to parse (generate) the data. See the Python Tcl RPC code in contrib as a negative example. * They do not operate on Tcl variables but instead return (accept) the Tcl list directly. This makes the C and Tcl code base smaller and cleaner. * The code is slightly more performant when reading / writing large amount of data. Tested with a simple Python Tcl RPC benchmark. Change-Id: Ibd6ece3360c0d002abaadc37f078b10a8bb606f8 Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: https://review.openocd.org/c/openocd/+/6307 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-03-12flash/nor/efm32: Use Cortex-M 'core_info' fieldMarc Schink1-11/+7
Change-Id: I5e477036e5cb7518c35df88878d53261311deb40 Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: https://review.openocd.org/c/openocd/+/6868 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-03-12flash/nor/sim3x: Fix typoMarc Schink1-1/+1
Change-Id: I2143c81d44b49bed9585c4aaee2bb6e2165345f2 Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: https://review.openocd.org/c/openocd/+/6869 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2022-03-12flash/stm32h7x: fix FLASH_WPSN_PRG mask used for protectionTarek BOCHKATI1-1/+2
STM32H7Ax/7Bx devices have a different WPSN mask (0xFFFFFFFF), (0xFF for STM32H74x/75x and STM32H72x/73x devices). And when supporting STM32H7Ax/7Bx devices, stm32x_protect() was not updated accordingly. Change-Id: I081217af3e5ed815b67bfdfec7f4ebaa3152a865 Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Fixes: 0b7eca17691a (flash/stm32h7x: add support of STM32H7Ax/H7Bx devices) Reviewed-on: https://review.openocd.org/c/openocd/+/6858 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
2022-03-12jtag_vpi: Minor cleanup in jtag_vpi driverJan Matyas1-20/+21
Multiple smaller items addressed in jtag_vpi: - Several log prints adjusted to make them more clear to the user. - Ensured that command handlers return ERROR_COMMAND_SYNTAX_ERROR on incorrect number of arguments. - Fix in "jtag_vpi set_address": Leave the previously set address intact on error. Do not revert it to default. - Minor update of help messages for the TCL commands. - Updated macro names: SERVER_ADDRESS --> DEFAULT_SERVER_ADDRESS, the same for SERVER_PORT Change-Id: Ibe386403a179adab5edb69c77fa408aef55701bd Signed-off-by: Jan Matyas <matyas@codasip.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6845 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2022-03-12cortex_m: use LOG_TARGET_XXXTarek BOCHKATI1-106/+104
Change-Id: I8be0f67442644031e6e8df3090d81af195caf82b Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6672 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-03-12flash/stm32f1x,f2x: fix endianess in slow fallback flash writeTomas Vanek2-8/+2
Use target_write_memory() instead of target_write_u16() Change-Id: I2389fe7a5fa18c9bc9c1aad8b8ddd64608bf2566 Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: https://review.openocd.org/c/openocd/+/6705 Tested-by: jenkins Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-03-05target/arm_tpiu: Fix usage of 'tpiu create'Marc Schink1-1/+1
Change-Id: I1ffad65a9e6d76f4d7fbbe249d8af3beb7e7692b Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: https://review.openocd.org/c/openocd/+/6860 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-03-05target/arm_tpiu: Fix 'tpiu create' parameter checkMarc Schink1-1/+1
The current implementation crashes when executing 'tpiu create' without an object name due to an invalid memory access. Pass 'argv' instead 'goi.argv' to fix the problem. While at it, match the style of the error message to the style used for other Tcl commands. Especially, make the 'name' parameter mandatory. Change-Id: Ib2b233f8556934af61608ae93d6405585c2c40b7 Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: https://review.openocd.org/c/openocd/+/6329 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
2022-03-05target/arm_tpiu: Make error message easier to understandMarc Schink1-1/+2
Change-Id: Idddc31e34a67641c32d041c89d01fe2126ec5ddb Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: https://review.openocd.org/c/openocd/+/6328 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-03-05target/tcl: Add get_reg functionMarc Schink1-0/+101
Change-Id: Id1be9554d1df2c07cec3161a0fd3a586fdf18246 Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: https://review.openocd.org/c/openocd/+/5312 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-03-05target/tcl: Add set_reg functionMarc Schink1-0/+65
Change-Id: I97a01b93046cb7af289792489f77f5580312585a Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: https://review.openocd.org/c/openocd/+/5313 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-03-01flash/stm32l4x: fix maybe-uninitialized compiler errorTarek BOCHKATI1-1/+1
using gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0 we get: error: ‘retval’ may be used uninitialized in this function fixes: 13cd75b6ecfd (flash/nor/stm32xx: fix segfault accessing Cortex-M part number) Change-Id: I897c40c5d2233f50a5385d251ebfa536023e5cf7 Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6861 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-02-26gdb_server: check target examined while combining reg listAntonio Borneo1-0/+12
Commit 6541233aa78d ("Combine register lists of smp targets.") assumes that all the targets in the SMP cluster are already examined and unconditionally call target_get_gdb_reg_list_noread() that will in turn return error if the target is not examined yet. Skip targets not examined yet. Add an additional check in case the register list cannot be built, e.g. because no target in the SMP cluster is examined. This should never happen, but it's better to play safe. Change-Id: I8609815c3d5144790fb05a870cb0c931540aef8a Fixes: 6541233aa78d ("Combine register lists of smp targets.") Reported-by: Michele Bisogno <michele.bisogno.ct@renesas.com> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6853 Tested-by: jenkins Reviewed-by: Michele Bisogno <michele.bisogno.ct@renesas.com> Reviewed-by: Tim Newsome <tim@sifive.com>
2022-02-26gdb_server: fix double freeAntonio Borneo1-15/+17
Commit 6541233aa78d ("Combine register lists of smp targets.") unconditionally assigns the output pointers of the function smp_reg_list_noread(), even if the function fails and returns error. This causes a double free from the caller, that has assigned NULL to the pointers to simplify the error handling. Use local variables in smp_reg_list_noread() and assign the output pointers only on success. Change-Id: Ic0fd2f26520566cf322f0190780e15637c01cfae Fixes: 6541233aa78d ("Combine register lists of smp targets.") Reported-by: Michele Bisogno <michele.bisogno.ct@renesas.com> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6852 Tested-by: jenkins Reviewed-by: Michele Bisogno <michele.bisogno.ct@renesas.com> Reviewed-by: Tim Newsome <tim@sifive.com>
2022-02-25flash/nor/stm32xx: fix segfault accessing Cortex-M part numberTomas Vanek4-16/+39
Some of STM32 flash drivers read Cortex-M part number from cortex_m->core_info. In corner cases the core_info pointer was observed uninitialised even if target_was_examined() returned true. See also [1] Use the new and safe helper to get Cortex-M part number. While on it switch also target_to_cm()/target_to_armv7m() to the safe versions. This prevents a crash when the flash bank is misconfigured with non-Cortex-M target. Add missing checks for target_was_examined() to flash probes. [1] 6545: fix crash in case cortex_m->core_info is not set https://review.openocd.org/c/openocd/+/6545 Change-Id: If2471af74ebfe22f14442f48ae109b2e1bb5fa3b Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Fixes: f5898bd93ff8 (flash/stm32fxx.c: do not read CPUID as this info is stored in cortex_m_common) Reviewed-on: https://review.openocd.org/c/openocd/+/6752 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2022-02-25target/cortex_m: add Cortex-M part number getterTomas Vanek1-0/+18
The getter checks the magic numbers in arch_info to detect eventual type mismatch. Change-Id: I61134b05310a97ae9831517d0516c7b4240d35a5 Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: https://review.openocd.org/c/openocd/+/6751 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2022-02-25target/armv7m,cortex_m: introduce checked arch_info cast routinesTomas Vanek2-9/+69
target_to_armv7m() and target_to_cm() do not match the magic number so they are not suitable for use outside of target driver code. Add checked versions of pointer getters. Match the magic number to ensure the returned value points to struct of the correct type. Change-Id: If90ef7e969ef04f0f2103e0da29dcbe8e1ac1c0d Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: https://review.openocd.org/c/openocd/+/6750 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-02-25target/cortex_m: fix target_to_cm() helperTomas Vanek1-1/+1
The third parameter of container_of() should point to the same member as target->arch_info points to, struct arm. It worked just because struct arm is the first member in struct armv7m_common. If you move arm member from the first place, OpenOCD fails heavily. Change-Id: I0c0a5221490945563e17a0a34d99a603f1d6c2ff Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: https://review.openocd.org/c/openocd/+/6749 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-02-25flash/nor/stm32f2x: Fix erase of bank 2 sectorsSimon Johansson1-2/+2
This commit corrects the erase function for stm32f2x when dealing with sectors in bank 2, for STM32F42x/43x devices with 1MB flash. On STM32F42x/43x with 1MB flash in dual bank configuration, the sector numbering is not consecutive. The last sector in bank 1 is number 7, and the first sector in bank 2 is number 12. The sector indices used by openocd, however, _are_ consecutive (0 to 15 in this case). The arguments "first" and "last" to stm32x_erase() are of this type, and so the logic surrounding sector numbers needed to be corrected. Since the two banks in dual bank mode have the same number of sectors, a sector index in bank 2 is larger than or equal to half the total number of sectors. Change-Id: I15260f8a86d9002769a1ae1c40ebdf62142dae18 Signed-off-by: Simon Johansson <ampleyfly@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6810 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2022-02-14rtos: threadx: Add hla_target support for ThreadXBen McMorran1-0/+12
Tested with an AZ3166 dev board (which uses the STM32F412ZGT6) running the Azure RTOS ThreadX demonstration system. Signed-off-by: Ben McMorran <bemcmorr@microsoft.com> Change-Id: I44c8f7701d9f1aaa872274166321cd7d34fb1855 Reviewed-on: https://review.openocd.org/c/openocd/+/6829 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-02-14server: remove remaining crust from dropped eCos codeAntonio Borneo4-42/+0
Commit 39650e2273bc ("ecosboard: delete bit-rotted eCos code") has removed eCos code but has left some empty function that was used during non-eCos build to replace eCos mutex. Drop the functions and the file that contain them. Change-Id: I31bc0237ea699c11bd70921660f960ee406ffa80 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6835 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2022-02-14Fix small memory leak.Tim Newsome1-3/+5
See https://github.com/riscv/riscv-openocd/pull/672 Change-Id: Ia11ab9bcf860f770ea64ad867102c74b898f6b66 Signed-off-by: Tim Newsome <tim@sifive.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6831 Tested-by: jenkins Reviewed-by: zapb <dev@zapb.de> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-02-14gdb_server: Include thread name as XML attributeBen McMorran1-2/+8
Explicitly providing a thread name in the "thread" element produces better thread visualizations in downstream tools like IDEs. Signed-off-by: Ben McMorran <bemcmorr@microsoft.com> Change-Id: I102c14ddb8b87757fa474de8e3a3f6a1cfe10d98 Reviewed-on: https://review.openocd.org/c/openocd/+/6828 Tested-by: jenkins Reviewed-by: zapb <dev@zapb.de> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-02-14Cadence virtual debug interface (vdebug) integrationJacek Wuwer3-0/+1085
Change-Id: I1bc105b3addc3f34161c2356c482ff3011e3f2cc Signed-off-by: Jacek Wuwer <jacekmw8@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6097 Tested-by: jenkins Reviewed-by: Oleksij Rempel <linux@rempel-privat.de> Reviewed-by: zapb <dev@zapb.de> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-02-14doxygen: fix some function prototype descriptionAntonio Borneo3-5/+2
Change-Id: I49311a643ea73143839d2f6bde976cfd76f8c67f Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6830 Tested-by: jenkins
2022-02-14target/riscv: revive 'riscv resume_order'Tim Newsome2-3/+9
This functionality was lost in [1], which was merged as commit 615709d14049 ("Upstream a whole host of RISC-V changes."). Now it works as expected again. Add convenience macro foreach_smp_target_direction(). Link: [1] https://github.com/riscv/riscv-openocd/pull/567 Change-Id: I1545fa6b45b8a07e27c8ff9dcdcfa2fc4f950cd1 Signed-off-by: Tim Newsome <tim@sifive.com> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6785 Tested-by: jenkins
2022-02-14helper/list: add list_for_each_entry_direction()Antonio Borneo1-0/+14
Use a bool flag to specify if the list should be forward or backward iterated. Change-Id: Ied19d049f46cdcb7f50137d459cc7c02014526bc Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6784 Tested-by: jenkins
2022-02-14target/smp: use a struct list_head to hold the smp targetsAntonio Borneo16-177/+135
Instead of reinventing a simply linked list, reuse the list helper for the list of targets in a smp cluster. Using the existing helper, that implements a double linked list, makes trivial going through the list in reverse order. Change-Id: Ib36ad2955f15cd2a601b0b9e36ca6d948b12d00f Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6783 Tested-by: jenkins
2022-02-05semihosting: User defined operation, Tcl command exec on hostZoltán Dudás6-4/+135
Enabling a portion (0x100 - 0x107) of the user defined semihosting operation number range (0x100 - 0x1FF) to be processed with the help of the existing target event mechanism, to implement a general-purpose Tcl interface for the target available on the host, via semihosting interface. Example usage: - The user configures a Tcl command as a callback for one of the newly defined events (semihosting-user-cmd-0x10X) in the configuration file. - The target can make a semihosting call with <opnum>, passing optional parameters for the call. If there is no callback registered to the user defined operation number, nothing happens. Example usage: Configure RTT automatically with the exact, linked control block location from target. Signed-off-by: Zoltán Dudás <zedudi@gmail.com> Change-Id: I10e1784b1fecd4e630d78df81cb44bf1aa2fc247 Reviewed-on: https://review.openocd.org/c/openocd/+/6748 Tested-by: jenkins Reviewed-by: Oleksij Rempel <linux@rempel-privat.de> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-01-29semihosting: use open mode flags from GDB, not from sys/stat.hPavel Kirienko1-12/+28
Values defined in sys/stat.h are not guaranteed to match the constants defined by the GDB remote protocol, which are defined in https://sourceware.org/gdb/onlinedocs/gdb/Open-Flags.html#Open-Flags. On my local system (Manjaro 21.2.1 x86_64), for example, O_TRUNC is defined as 0x40, whereas GDB requires it to be 0x400, causing all "w" file open modes to misbehave. This patch has been tested with STM32F446. Change-Id: Ifb2c740fd689e71d6f1a4bde1edaecd76fdca910 Signed-off-by: Pavel Kirienko <pavel.kirienko@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6804 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-01-29Combine register lists of smp targets.Tim Newsome1-2/+104
This is helpful when you want to pretend to gdb that your heterogeneous multicore system is homogeneous, because gdb cannot handle heterogeneous systems. This won't always works, but works fine if e.g. one of the cores has an FPU while the other does not. (Specifically, HiFive Unleashed has 1 core with no FPU, plus 4 cores with an FPU.) Signed-off-by: Tim Newsome <tim@sifive.com> Change-Id: I05ff4c28646778fbc00327bc510be064bfe6c9f0 Reviewed-on: https://review.openocd.org/c/openocd/+/6362 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-01-29aarch64: support for aarch32 ARM_MODE_UNDJulien Massot2-0/+7
Fix: unrecognized psr mode: 0x1b cannot read system control register in this mode: (UNRECOGNIZED : 0x1b) Change-Id: I4dc3e72f90d57e52c0fe63cb59a7529a398757b3 Signed-off-by: Julien Massot <julien.massot@iot.bzh> Change-Id: Ifa5d21ae97492fde9e8c79ee7d99d8a2a871b1b5 Reviewed-on: https://review.openocd.org/c/openocd/+/6808 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>