aboutsummaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)AuthorFilesLines
2020-07-08coding style: fix print of hex values as decimalAntonio Borneo2-2/+2
It is an error to prefix with "0x" the print of values in decimal. Replace the incorrect decimal format specifier with PRIx32. Issue identified by checkpatch script from Linux kernel v5.1 using the command find src/ -type f -exec ./tools/scripts/checkpatch.pl \ -q --types PRINTF_0XDECIMAL -f {} \; Change-Id: I2eb867ef654527b2737ba573a405ec8f97c6a739 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5624 Tested-by: jenkins Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2020-07-08target/arm926ejs: fix memory leaksAntonio Borneo7-0/+44
The memory leaks detected and fixed are: - arm register cache; - EmbeddedICE register cache; - arm_jtag_reset_callback internal data; - struct arm926ejs_common. Issue identified with valgrind. Tested on SPEAr320 based on arm926ejs. Change-Id: If2bed02c516051ce4d0eb29b204a3f3337fe5d6a Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5698 Tested-by: jenkins
2020-07-08configure: split build of hla layoutsAntonio Borneo3-3/+9
Current hla driver supports two "layout": stlink and ti-icdi. The configure script allows to independently enable/disable the the two layout. But in reality by selecting only one of them the whole hla driver is built, including both "layouts". This is currently not a big issue because the dependencies of the two layout are the same (libusb), so we are sure that selecting one of them would permit to build both. This is going to change with the merge of a third "layout" for Nuvoton Nu-Link, because it would be based on hidapi. We need, at least, to decouple the build of libusb and hidapi "layouts". A full decouple of each "layout" is also welcome to match the selection done during configure. Introduce a new automake macro for each of the two "layout" and use them to conditionally build the "layout" files. Use the existing autoconf macros to conditionally compile the code that depends by the "layout". Change-Id: Ia20da7a260002a8d2af883425aa401b8920d3f36 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5719 Tested-by: jenkins
2020-07-08flash/nor/w600: Use 'bool' data typeMarc Schink1-4/+4
Change-Id: Ia71ffba82b23ed1860acc5daf6c66fa574a0d797 Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: http://openocd.zylin.com/5751 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-07-08flash/nor/stmsmi: Use 'bool' data typeMarc Schink1-4/+4
Change-Id: I0b9d3eb6fa40cc9fed6491c8f583580fb471bcac Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: http://openocd.zylin.com/5750 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-07-08flash/nor/stm32h7x: Use 'bool' data typeMarc Schink1-1/+1
Change-Id: Ib9c567e2287f2a99172bd3bd35a81e3205cea421 Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: http://openocd.zylin.com/5749 Tested-by: jenkins Reviewed-by: Christopher Head <chead@zaber.com> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-07-08flash/nor/sh_qspi: Use 'bool' data typeMarc Schink1-3/+3
Change-Id: Id5567102013648b1565078310abc27bee4446992 Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: http://openocd.zylin.com/5748 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-07-08flash/nor/pic32mx: Use 'bool' data typeMarc Schink1-4/+4
Change-Id: I9a0b60bc07781401f26df31303b8c04822b7ddc2 Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: http://openocd.zylin.com/5747 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-07-08flash/nor/mrvlqspi: Use 'bool' data typeMarc Schink1-4/+4
Change-Id: Icc64d9ba56841ff6eb96efcbdc9545938ebb7347 Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: http://openocd.zylin.com/5746 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-07-08flash/nor/mdr: Use 'bool' data typeMarc Schink1-3/+3
Change-Id: I1eced61e5cb062445078e05507f6ad1a5a594c8d Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: http://openocd.zylin.com/5745 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-07-08flash/nor/max32xxx: Use 'bool' data typeMarc Schink1-8/+8
Change-Id: I828cdd6d97a59fd0692eb22ba8fc0a5759029432 Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: http://openocd.zylin.com/5744 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-07-08flash/nor/lpcspifi: Use 'bool' data typeMarc Schink1-4/+4
Change-Id: I0485a7885fe154f983c7a7ce84cbedb0ba32ca31 Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: http://openocd.zylin.com/5743 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-07-08flash/nor/jtagspi: Use 'bool' data typeMarc Schink1-4/+4
Change-Id: I0e81dd476c6b3ec7fee6c84ab1bfcf9bca90c532 Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: http://openocd.zylin.com/5742 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-07-08flash/nor/fm3: Use 'bool' data typeMarc Schink1-4/+4
Change-Id: Ic90ab762488063f6958f5e775c1b2fe5f3f1718f Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: http://openocd.zylin.com/5741 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-07-08flash/nor/fespi: Use 'bool' data typeMarc Schink1-4/+4
Change-Id: I4583b4475b2fa2733db0861bfe8f52f0a514c472 Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: http://openocd.zylin.com/5740 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-07-08flash/nor/em357: Use 'bool' data typeMarc Schink1-4/+4
Change-Id: I251b62275d204fdc315cd167685799c15d4e7cf4 Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: http://openocd.zylin.com/5739 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-07-08flash/nor/cfi: Use 'bool' data typeMarc Schink3-17/+17
Change-Id: I25198223175c26aded9ad667b802da09883e94ee Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: http://openocd.zylin.com/5738 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-07-08flash/nor/atsamv: Use 'bool' data typeMarc Schink1-2/+2
Change-Id: Id4ceaf38dc5eba5b0eb62416fc357fdfc7ea21c0 Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: http://openocd.zylin.com/5737 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-07-08flash/nor/ath79: Use 'bool' data typeMarc Schink1-3/+3
Change-Id: Iecd29dcfcc1ae983e4e0828025d2d174944c1e9d Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: http://openocd.zylin.com/5736 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-07-08flash/nor/at91sam4: Use 'bool' data typeMarc Schink1-132/+132
Change-Id: Iade91ac58a995676c412606a63e62b70337427f1 Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: http://openocd.zylin.com/5735 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-07-08flash/nor/at91sam3: Use 'bool' data typeMarc Schink1-88/+88
Change-Id: Ibaf599a4ab88ea36a84b3389e2f704554d465434 Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: http://openocd.zylin.com/5734 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-07-08flash/nor/ambiqmicro: Use 'bool' data typeMarc Schink1-9/+9
Change-Id: Ia8492905dc506d518266343d699c3245efbc1ab1 Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: http://openocd.zylin.com/5733 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-07-08jtag/tcl: fix a double free of jim objectMikhail Rasputin1-2/+4
The Jim_SetResultFormatted() frees jim object earlier and the Jim_FreeNewObj() does it second time. It breaks the memory heap. To avoid it the Jim_IncrRefCount() + Jim_DecrRefCount() should be used instead of the Jim_FreeNewObj() call. Change-Id: Ifa5f38009b2d617624b5f27e916720888a3dbad9 Signed-off-by: Mikhail Rasputin <mikhail.godlike.rasputin@yandex.ru> Reviewed-on: http://openocd.zylin.com/5724 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-07-07flash/nor: Use proper data types in driver APIMarc Schink70-755/+773
Use 'unsigned int' and 'bool' instead of 'int' where appropriate. While at it, fix some coding style issues. No new Clang analyzer warnings. Change-Id: I700802c9ee81c3c7ae73108f0f8f06b15a4345f8 Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: http://openocd.zylin.com/4929 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-07-07flash/nor/atsame5: Fix a timeout when erasingMichael Hope1-6/+16
According to the datasheet, erasing a block can take up to 200 ms. When using a Segger J-Link with a 2 MHz clock the current loop finishes after < 50 ms, ignores the timeout, and then fails when erasing the next block. Switch to a time based check, add an explicit yield, and report an error on timeout. Change-Id: I8255401d1e59f427a08d2cccb8a66143dcdbb324 Signed-off-by: Michael Hope <mlhx@google.com> Reviewed-on: http://openocd.zylin.com/5706 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
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-27jtag: drivers: xlnx-pcie-xvc: Add support for SWD mode.Moritz Fischer1-3/+213
Add support for SWD debug to the Xilinx XVC/PCIe driver. This is possible since the device is essentially a shift-register. So doing SWD vs JTAG is a matter of wiring things correctly on the RTL side (use TMS for SWDI, TDO for SWDO). The clang static checker doesn't find any new problems with this change. Change-Id: I3959e21440cd1036769e8e56a55e601d3e4aee9a Signed-off-by: Moritz Fischer <moritzf@google.com> Reviewed-on: http://openocd.zylin.com/5447 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-06-27target/arc: Introduce L1I,L1D,L2 caches supportEvgeniy Didin4-5/+328
With this commit we introduce L1 and L2 cache flush and invalidate operations which are necessary for getting/setting actual data during memory r/w operations. We introduce L2 cache support, which is not presented on currently support EMSK board. But L2 is presented on HSDK board, which soon will be introduced. Change-Id: I2fda505a47ecb8833cc9f5ffe24f6a4e22ab6eb0 Signed-off-by: Evgeniy Didin <didin@synopsys.com> Reviewed-on: http://openocd.zylin.com/5688 Reviewed-by: Oleksij Rempel <linux@rempel-privat.de> Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-06-27aarch64: Add support for debugging in HYP mode on ARMv8-A coresLucas3-2/+12
When debugging an ARMv8-A/AArch32 target running HYP mode, OpenOCD would throw the following error to GDB on most operations (step, set breakpoint): cannot read system control register in this mode The mode in question is 0x1A, a privilege level 2 mode available on cores that have the virtualization extensions (such as the Raspi 3). Note: this mode is only used when running in AArch32 compatibility mode. Signed-off-by: Lucas Jenss <public@x3ro.de> Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Change-Id: Ia8673ff34c5b3eed60e24d8da57c3ca8197a60c2 Reviewed-on: http://openocd.zylin.com/5255 Tested-by: jenkins Reviewed-by: Lucas Jenß <lucas.jenss@gmail.com> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-06-23libjaylink: Update to latest Git versionMarc Schink1-0/+0
This update is for testing the upcoming 0.2.0 release. Change-Id: I400b09eb3ead4306c83c7980c621124101aaef7e Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: http://openocd.zylin.com/5723 Tested-by: jenkins Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2020-06-18target/armv7m_trace: Calculate prescaler for external capture devicesMarc Schink2-7/+26
This fixes a regression introduced in "2dc88e1479f29ef0141b05bfcd907ad9a3e2d54c" Change-Id: I04dc19ed30118a4c499b83732700b2ee0fdb67b6 Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: http://openocd.zylin.com/5610 Tested-by: jenkins Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2020-06-14flash/nor/stm32l4x: Fix check for number of argumentsMarc Schink1-1/+1
The current version erroneously allows any number of arguments >= 1. Change-Id: I64156c11b48d411c72bebbf866954818cd036ff2 Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: http://openocd.zylin.com/5716 Tested-by: jenkins Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-06-14stlink: code factorization by introducing stlink_usb_exit_modeTarek BOCHKATI1-43/+24
Change-Id: I4abd6432c4ef969e382bfed96cd19a49d9610000 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: http://openocd.zylin.com/5612 Tested-by: jenkins
2020-06-14openocd: fix issue in WIN32 with TCP adaptersTarek BOCHKATI3-2/+22
Issue: server_quit is called before adapter_quit: In WIN32 only in server_quit we do an WSACleanup, which terminates/closes all active sockets. So if the adapter is TCP based, the adapter.quit handler will fail if it will need to send some commands through TCP. Example: close_socket in jtag_vpi_quit will fail in WIN32 because the socket is already closed and the errno is set as "Bad File Descriptor" To fix that we introduced new functions called server_host_os_entry/quit to manage specific OS setup (hence WSA for sockets in WINDOWS) in order to delay WSACleanup after adapter_quit(). Change-Id: Ie4afacafe123857f6ae300e376bdfcf0d8c027ac Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: http://openocd.zylin.com/5456 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-06-14flash: Add the Freedom E310-G002 SPI FlashAlistair Francis1-1/+2
Change-Id: Id9f4a209a6eacf186931b142e70a5b0458517be0 Signed-off-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-on: http://openocd.zylin.com/5679 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Tim Newsome <tim@sifive.com>
2020-06-06coding style: fix multi-line dereferencingAntonio Borneo2-16/+9
Issue identified by checkpatch script from Linux kernel v5.1 using the command find src/ -type f -exec ./tools/scripts/checkpatch.pl \ -q --types MULTILINE_DEREFERENCE -f {} \; Change-Id: Icba05613e22a72ecc3e6a0aad7cb6b479496146f Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5629 Tested-by: jenkins Reviewed-by: Marc Schink <dev@zapb.de>
2020-06-06jtag/tcl: fix memory leak in command 'irscan'Antonio Borneo1-4/+9
If the function parse_u64() fails, we jump to return, thus leaking the memory just allocated in 'v'. Issue identified by clang. Move earlier the call to parse_u64() and the associated test, before memory allocation. While there, fix a possible NULL pointer dereferencing in case the calloc() fails, by testing for allocation failure. Change-Id: I6a77ee17aceb282bbdfefe7cdafeba2e0e7012f1 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5692 Tested-by: jenkins Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2020-06-06target/cortex_a: fix memory leak of register cacheAntonio Borneo4-0/+25
There is no method to free the register cache, allocated in armv4_5, so we get a memory leak. Issue identified by valgrind. Implement the method arm_free_reg_cache() and call it in cortex_a deinit and to exit for error during arm_dpm_setup(). Tested on dual cortex-A stm32mp15x. This change is inspired from similar fix in commit b01b5fe13a67 ("armv7m: Fix memory leak in register caching."). The same allocation is also used by target types "arm7tdmi", "arm9tdmi", "arm11" and "xscale" but they all lack the deinit method and I do not have relevant HW to test the fix. For such reasons they are not addressed in this patch. Change-Id: I4da1e1f12e36ec245d1f3b11a4eafcbd9a1d2e25 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5693 Tested-by: jenkins
2020-06-06target/mem_ap: fix two memory leaksAntonio Borneo1-0/+10
The target mem_ap misses the method 'deinit_target' and does not free the memory allocated during 'target create' and 'configure'. Add the missing method and free the allocated memory. Issue identified with valgrind. Change-Id: If0d0114a75dd76a8b65c2d46d96c6085fd31a09d Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5700 Tested-by: jenkins
2020-06-06libusb_helper: fix memory leak when no adapter is foundAntonio Borneo1-0/+3
When jtag_libusb_open() fails to find the adapter, it returns error but left libusb initialized causing memory leak of libusb internal data. Issue found with valgrind when no adapter or board is connected to the host, e.g. valgrind openocd -f board/st_nucleo_f4.cfg Close the libusb operations if jtag_libusb_open() has to return error. Change-Id: Ieb2f110be15705dafe80c099e7d83c07056c2a41 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5701 Tested-by: jenkins
2020-06-06target/cortex-m: enable C_DEBUGEN during examineAntonio Borneo1-0/+13
Current code for Cortex M does not set C_DEBUGEN as soon as possible, (which means during target examine), but later-on either: 1) at command 'halt' (e.g. for 'gdb-attach' event); 2) at command 'soft_reset_halt'; 3) at commands 'reset', 'reset halt' or 'reset init'; 4) during polling, but only if the target: = enter in 'double fault', or = exit from a reset, or = halts (not possible if C_DEBUGEN is not set) Plus, if commands in 1) or 2) are executed before the very first poll of the target, the value of 'cortex_m->dcb_dhcsr' is used not initialized while writing it back in DCB_DHCSR. Another side effect of this situation is that it's possible to set a HW breakpoint with the target running, while C_DEBUGEN is not set. Accordingly to [1], C1.3.1 "Debug authentication": When DGBEN is LOW and DHCSR.S_HALT == 0: ... FPB breakpoints do not generate an entry to Debug state and, if no DebugMonitor exception is generated, will escalate to HardFault, Lockup, or be ignored. On STM32MP15x I get HW breakpoint ignored, while on STM32F411 I get HardFault. E.g. following these steps: - power-on a pre-flashed board that starts running the firmware; - connect openocd, without halting or resetting the board; - set a HW breakpoint to some address often executed; - wait, but the board doesn't halt ...; - type the command 'halt'; - if the Cortex-M has HardFault it would be visible and the fault is at the breakpoint address; - if no HardFault then type the command 'resume'; - wait and the board will finally halt at the HW breakpoint. A similar issue has been detected on Cortex-A code and fixed by commit bff87a7f28fb ("target/cortex_a: enable DSCR_HALT_DBG_MODE during examine"). Follow the same approach and set C_DEBUGEN during examine. Also, initialize 'cortex_m->dcb_dhcsr' during examine. [1] ARM DDI 0403E "ARM v7-M Architecture Reference Manual" Change-Id: I5b0b23403634f7dfce38f104bba9f59c33eb3e99 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5702 Tested-by: jenkins Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com> Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-by: Moritz Fischer <moritzf@google.com>
2020-06-06log: fix kept_alive() and report expired timeoutAntonio Borneo1-17/+39
The kept_alive() function is called to inform the keep-alive code that a keep-alive as been just kicked through some other path. But kept_alive() erroneously resets the timeout counter without checking if it has already expired, thus masking a potential timeout. Check if timeout counter has expired during kept_alive(). While there, put the timeout values in macros and explicit the units in the timeout messages. Change-Id: Iaf6368b44e5b5352b1cc4e7efbb2368575dcfa08 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5705 Reviewed-by: <jonatan_zeidler@gmx.de> Tested-by: jenkins
2020-06-06nor/kinetis: add keep-alive during flash writeAntonio Borneo1-0/+4
Flashing Kinetis MCU MK22FX512VLH12 takes longer than one second, thus gdb connection can timeout. Before commit 7f260f5009a7 ("helper/command: Handle Tcl return values consistently") the openocd timeout warning was masked by a bug in gdb_put_packet() that resets the timeout counter if any message is logged out. The commit above removes one log message and the timeout warning is now triggered. While the bug in gdb_put_packet() is still to be fixed, the reason of the timeout is the lack of keep_alive() calls in kinetis flash driver. Add keep_alive() call at every iteration in function kinetis_write_sections(), that is reported as core write function in chunks of 1024 bytes in the log from the reporter. Add also a keep_alive() call at every iteration in function kinetis_write_inner(). This part is not present in the log but, by code analysis, it represents another critical loop. Change-Id: I38e631b36c7eb2f1e21cef68710ce47c03d3edda Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reported-by: Jonatan Hatakeyama Zeidler <jonatan.zeidler@medineering.de> Reviewed-on: http://openocd.zylin.com/5703 Tested-by: jenkins Reviewed-by: <jonatan_zeidler@gmx.de>
2020-06-06arm_adi_v5: dap_ti_be_32_quirks_command minor simplificationTarek BOCHKATI1-18/+2
use handle_command_parse_bool within dap_ti_be_32_quirks_command to make it shorter and simpler. Change-Id: Ice179cc477933b27e27235dc2ade23fe655e233d Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: http://openocd.zylin.com/5708 Tested-by: jenkins Reviewed-by: Marc Schink <dev@zapb.de> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-06-06arm_adi_v5: enhance command error reportingTarek BOCHKATI1-17/+32
avoid the usage of ERROR_COMMAND_SYNTAX_ERROR when ERROR_COMMAND_ARGUMENT_INVALID is more adequate. Change-Id: Ic9aaedb93fedd45efee1b39f8ea20185f01af2da Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: http://openocd.zylin.com/5654 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-06-06jtag/drivers/bcm2835gpio: bcm2835gpio_init has been updatedtscn921-1/+5
For jtag/drivers/bcm2835gpio dev_mem_fd has been updated within bcm2835gpio_init with the add on of gpio to mem. This permits the access to memory of GPIO without the need for root access. For failed attempt, a fallback to original memory follows. It should be noted that any printed error is relative to original memory ("dev/mem"). Tested on EFM32GG12B390F board Change-Id: I4540bdf62fb3b91a51221e277881adfae138dcc5 Signed-off-by: tscn92 <tscn@kamstrup.com> Reviewed-on: http://openocd.zylin.com/5568 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-05-24helper/command: remove unused functions and make static local onesAntonio Borneo2-49/+8
The function command_find_in_parent() is never used in OpenOCD, so remove it. The functions command_name() and [un]register_command() are only used internally in command.c, so make them static. Change-Id: Ide9842659796f4884fb6c1fcf5979b3b71b67abb Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5663 Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com> Tested-by: jenkins
2020-05-24openocd: properly use jim data typesAntonio Borneo3-4/+5
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-24helper/command: fix check on value returned by jim APIAntonio Borneo1-2/+2
Either Jim_CreateCommand() and register_command_handler() return the jim error code JIM_OK/JIM_ERR. Fix the check and the initialization of retval. Change-Id: I3073c66764670128706ad979a43bb3edbbeb0ab0 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5661 Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com> Tested-by: jenkins
2020-05-24helper/command: strip replicated command name in logAntonio Borneo3-11/+8
After commit 0840414f0e57 ("helper/command: do not replace new commands with ocd_ prefix"), the command name is present in argv[0], so there is no need to pass it directly. The current code causes the command name to be logged twice, once explicitly and then from the content of argv[0]: openocd -c 'debug_level 3; echo hello; shutdown' <snip> Debug: 13 3 command.c:142 script_debug(): command - echo echo hello <snip> Debug: 16 4 command.c:142 script_debug(): command - shutdown shutdown Remove the command name from the arguments of the function script_debug(). Change-Id: I57860774f450ff717ee71ef9dc07590549a84319 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5660 Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com> Tested-by: jenkins