aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2020-01-14jtag: print an errmsg on using jtag API for non jtag transportAntonio Borneo
After the cleanup of swd and hla, there should be no more calls to jtag_execute_queue() or to queue jtag commands if current transport is not jtag. Thus we can start removing the jtag specific code from adapters that do not support jtag. To prevent some remaining call to jtag_execute_queue() to crash openocd, verify the transport, print an error message if the transport is not jtag, call the adapter's jtag_execute_queue() only if it exist. To identify code that still add commands in the jtag queue even if transport is not jtag, print an error message in the function jtag_queue_command(). For the moment, still queue the message, even if will cause a memory leak if there is no following call to jtag_execute_queue(); the target is to identify the issue and cleanup the code, thus solving also the leak. Change-Id: I8fc85f754aa057aad1df05ff0448c8619897da23 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4897 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2020-01-14hla: use the new system_reset APIAntonio Borneo
HLA uses its own internal driver's API to control the adapter's system reset, but at the same time it calls jtag_add_reset() to avoid breaking the internal logic of OpenOCD. This implicitly forces HLA to rely on jtag queue mechanism, even if HLA has no link with JTAG state machine. It requires HLA to implement an empty execute_queue() to comply with the JTAG queue. Modify the HLA framework and the HLA targets to use the new adapter API for system_reset and decouple HLA from JTAG queue. Rename the HLA static functions adapter_assert_reset() and adapter_deassert_reset() to avoid overlap with the global functions with same name. While there, fix a minor typo in a comment s/incase/in case/. Do not remove from HLA the JTAG specific API execute_queue(), even if not required anymore, because OpenOCD code still has calls to jtag_execute_queue() in case of non JTAG transport. Change-Id: I0e65e3e557bd665bd3d3aeaa84ea609b55a05e48 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4896 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2020-01-14bitbang: jtag-only drivers: switch to new reset APIAntonio Borneo
Remove the JTAG_RESET command from the bitbang execute queue now that all bitbang drivers have moved away from old reset method. Remove also the internal reset API in struct bitbang_interface. Tested parport only. Change-Id: I12b157ef442f4c9912406b19b7a4d32ba6ec0b53 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5300 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2020-01-14swd: get rid of jtag queue to assert/deassert srstAntonio Borneo
The transport SWD uses the JTAG queue to assert/deassert the system reset srst. This is the major inconsistency that has to be removed to properly split JTAG and SWD. Introduce a new driver API, reset(), to controls both the signals trst and srst in the driver, skipping the JTAG queue. Put the new API in struct jtag_interface, even if in this patch it's used for SWD only; the goal is to get it reused by the other transports. Add the implementation of the API in all the drivers that implement SWD. Such implementation is almost the same of the old code in JTAG queue. Create a wrapper adapter_system_reset() to use the new API and remove the SWD specific swd_add_reset(). In the wrapper replace jtag_add_sleep() with jtag_sleep(), because the former uses the JTAG queue too. Rename the old jtag_add_reset() as legacy_jtag_add_reset() with the target to remove it when all drivers would be ported to the new reset API. Create a new jtag_add_reset() that calls the legacy function for drivers still on the old reset API. Use the new API also on JTAG transport for the drivers that can support both SWD and JTAG. For the moment, do not modify the implementation of JTAG-only drivers, which will continue using the usual method. This should be cleaned-up in future commits. Change-Id: I32331c88313f6059b25e12c6bb0156aebc1c074f Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4895 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2020-01-05flash/nor: Factor out CFI memory read/write functionsMarek Vasut
Create separate memory read/write functions which facilitate access to the CFI NOR, so that they can be replaced by controller-specific functions if necessary. This would become necessary when implementing support for e.g. HyperFlash controllers, which do not directly map the HyperFlash into the address space. Change-Id: I1bba1edfd397cb37bfedb43efe2dd03feb26a375 Signed-off-by: Marek Vasut <marek.vasut@gmail.com> Reviewed-on: http://openocd.zylin.com/5145 Tested-by: jenkins Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2020-01-05flash/nor: Factor out cfi_spansion_unlock_seq()Marek Vasut
Factor out the spansion unlock sequence to deduplicate the code. Change-Id: Id78522e9a2f0e701870ef816772289d08257476a Signed-off-by: Marek Vasut <marek.vasut@gmail.com> Reviewed-on: http://openocd.zylin.com/5144 Tested-by: jenkins Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2020-01-03flash/nor/stm32f2x: Support value line chips with trimmed flashKeir Fraser
The current code assumes an STM32's flash bank is laid-out in either of two configurations: - 4 x 16kB + 1 x 64kB + n x 128kB - 4 x 32kB + 1 x 128kB + n x 256kB This is quite ad-hoc but works fine in practice, as long as there are at least 5 sectors (if n=0). Unfortunately, some newer STM32s are shipping with only 64 kB of flash (4 x 16kB sectors). This patch still assumes the same sector layout, but only keeps adding sectors to the bank if the bank's capacity has not been reached. This prevents openocd from crashing on some newer STM32s. Change-Id: If00e5d7a328d11b399babc0bb2111e3ad8a3217e Signed-off-by: Romain Goyet <romain.goyet@numworks.com> Signed-off-by: Keir Fraser <keir.xen@gmail.com> Reviewed-on: http://openocd.zylin.com/4926 Tested-by: jenkins Reviewed-by: Andreas Bolsch <hyphen0break@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2020-01-02arm_adi_v5: add API send_sequence() and use itAntonio Borneo
The method to send an arbitrary sequence to DAP depends on the transport and is thus different on JTAG and SWD. This is already coded in dap_to_jtag() and dap_to_swd(). Add a new API send_sequence() in struct dap_ops. Add the implementations of send_sequence() in adi_v5_jtag.c and adi_v5_swd.c Rewrite dap_to_jtag() and dap_to_swd() using the new API. Move the enum swd_special_seq in arm_adi_v5.h to solve a circular dependencies among swd.h and arm_adi_v5.h Change-Id: I9db13a00f129761eab283783c094cfff2dd92610 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/4902 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2020-01-02tcl: update scripts after "jtag_reset" got deprecatedAntonio Borneo
Avoid annoying "deprecated" messages in the scripts distributed with OpenOCD code. Change-Id: I82d27cd420db30f0653efbd286a627ef56a8c1fd Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5287 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2020-01-02jtag: replace command "jtag_reset" with "adapter [de]assert"Antonio Borneo
Replace the JTAG transport specific command with a more generic one. Deprecate "jtag_reset" and update the documentation. While there, fix an error in the documentation, where the command "jtag_reset" was used in place of command "reset_config". Change-Id: I41a988d37ce69f7b35a960cbaf5306aab0299b99 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5286 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2020-01-02adapter: add command "adapter [de]assert srst|trst [[de]assert srst|trst]"Antonio Borneo
Inspired from http://openocd.zylin.com/#/c/3720/1 Add commands to control the adapter's signals srst and trst. Add macros for the flag's values assert/deassert to make clear what they mean and to propose a uniform set of values across the code. Change-Id: Ia8b13f4ded892942916cad7bda49540a896e7218 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: http://openocd.zylin.com/5277 Tested-by: jenkins
2020-01-02jtag_vpi: multiple improvementsJan Matyas
- Fix: Proper handling of read_socket() and write_socket() in case of "partial" read/write. - Added low-level JTAG IO debug capability (_DEBUG_JTAG_IO_) - Zero-fill packet buffers, avoid sending pieces of uninitialized memory over the network (memset struct vpi_cmd) - Use close_socket() instead of close() - needed for Win32 - Fixed usage messages of jtag_vpi_command_handlers Change-Id: I8bd19bc5c9512fe8e798600212e8a95213f50f5b Signed-off-by: Jan Matyas <matyas@codasip.com> Reviewed-on: http://openocd.zylin.com/5177 Tested-by: jenkins Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2020-01-02flash/nor/stm32f1x: fix options reading from locked chipOleksandr Redchuk
In commit cea40152f82f52bfc718c7bda9fa4a9d70bf9cfd option bytes reading was changed to direct access to option bytes area. While there are no problems with stm32f0xx and stm32f3xx chips, option block (0x1ffff800..0x1ffff80F) is unreadable from locked stm32f10x chips. As a result, stm32f1x unlock command writes dirty values to user options, user data and write protection bits. Option bytes reading reverted from direct access to option bytes area to reading currently loaded bytes from FLASH_OBR/FLASH_WRPR registers. Tested on stm32f100, stm32f103, stm32f107 as well as on stm32f030 and stm32f303. Change-Id: Iad476351ffdaca5ace12e02272dacea7f3d08f52 Signed-off-by: Oleksandr Redchuk <real@real.kiev.ua> Reviewed-on: http://openocd.zylin.com/4940 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2020-01-02contrib/rpc_examples: Add (dis)connect methodsMarc Schink
Add these methods such that the OpenOcd class can also be used outside of a 'with' statement. Change-Id: I927c93fff2dc05cc74daa56360a7262e736a639f Signed-off-by: Marc Schink <openocd-dev@marcschink.de> Reviewed-on: http://openocd.zylin.com/5189 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2020-01-02rtos/FreeRTOS: Fix FreeRTOS thread list readingRahul Masurkar
Change-Id: I749ae94ec7279907b1905c02ecc1e9661f43ef70 Signed-off-by: Rahul Masurkar <rahulgm@marvell.com> Reviewed-on: http://openocd.zylin.com/5273 Tested-by: jenkins Reviewed-by: Karl Palsson <karlp@tweak.net.au> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2020-01-02flash/nor/kinetis: fix clang static analyzer warningsTomas Vanek
Use assert to remove "Dereference of null pointer" warnings. Change-Id: Ie204c234a71758e6470351e1d9f22da3dd887f56 Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: http://openocd.zylin.com/5357 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2020-01-02target/arm_cti: add new 'ack' and 'channel' commandsTarek BOCHKATI
these commands have been introduced to ease the manipulation of CTI trough script files, these commands are: - $cti_name ack $event : to acknowledge a CTI event - $cti_name channel $channel_number $operation: to perform an operation on a specific channel, the possible operations are: gate, ungate, set, clear and pulse Change-Id: I35463867a3c85072f3776c3aeb1e5788953ec435 Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: http://openocd.zylin.com/5315 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
2020-01-02flash/nor/stm32h7: (minor) use proper variable names and enhance loggingTarek BOCHKATI
-fsize_base should be fsize_addr as it is the address of FLASH_SIZE register -flash_base should be flash_regs_base to avoid confusion with flash block start -add LOG_ERROR to functions stm32x_[read|write]_flash_reg(...) Change-Id: I86f035314bcd616fc0bdf445692d945a85c15481 Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: http://openocd.zylin.com/5362 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2020-01-02tcl/target: swm050: fix to allow to use with ST-LinkIcenowy Zheng
Currently the code assumes the adapter uses raw SWD, and the expected ID code of the CPU is even wrong. An adapter speed is also not specified. All these prevents the config file to be used with ST-Link. Fix the config file, to allow it to be used with ST-Link. Change-Id: I1244320fabfe8ee23da5a56a592dbeddc72cc8d5 Signed-off-by: Icenowy Zheng <icenowy@aosc.io> Reviewed-on: http://openocd.zylin.com/5297 Tested-by: jenkins Reviewed-by: Caleb Szalacinski <contact@skiboy.net> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-12-21target/armv7m_trace: Improve SWO frequency auto-detectionMarc Schink
The SWO frequency auto-detection with J-Link adapters does not work properly in the current implementation. This is because the trace layer has only information about the highest possible SWO frequency supported by the adapter. With that the trace layer calculates the SWO prescaler which usually leads to a frequency deviation greater than what is permitted by J-Link adapters. Move the calculation of the SWO prescaler from the trace layer into the trace configuration of the adapter to overcome this problem. The adapter has the necessary information to choose a suitable SWO frequency and calculate the corresponding prescaler that complies with the maximum allowed frequency deviation. Tested with: - STM32L152RC Discovery Kit (ST-Link) - EFM32GG-STK3700 (J-Link) Change-Id: I38ff2b89d32f0a92c597989b590afe5c75cf4902 Signed-off-by: Marc Schink <openocd-dev@marcschink.de> Reviewed-on: http://openocd.zylin.com/3903 Tested-by: jenkins Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2019-12-19helper/command: remove unused field in struct command_registrationAntonio Borneo
The field jim_handler_data in struct command_registration is never assigned, thus has always value NULL. It was added in commit 17a9dea53a71 ("add jim_handler to command_registration") on Nov 23 2009, together with the homonym field jim_handler_data in struct command, but never used since then. Only the field jim_handler_data in struct command is used. Remove the field from struct command_registration and use NULL where it was referenced (or remove the assignment if the recipient is already zero, e.g. allocated with calloc()). Removing the field decreases the total size of OpenOCD binary by only 4944 byte on a 64 bit x86. Not a significant improvement from this point of view. Change-Id: I9f1d281e3de6b2eb398e2d883c5e9ff92628aecd Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5225 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-12-19target/armv4_5: use c99 array designator to init arm_core_regs[]Antonio Borneo
During code analysis and development, counting again and again the lines to find the index of the register is a boring error-prone brain-damaging activity. Use the c99 syntax and add once forever the array designators to specify the index values. The code behavior is not changed. Change-Id: I2c70f70794475679efb91a8dfadc00f50715bd3f Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5256 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-12-19sysfsgpio: give time to udev to change gpio permissionAntonio Borneo
When a gpio is exported by writing in /sys/class/gpio/export, the corresponding gpio control files appear immediately in sysfs but with default access permission for root user only. The daemon udev requires some time to get notified of the new files before it can change the permissions to allow access to unprivileged users. Due to this race condition, sysfsgpio can fail with EACCES error if OpenOCD is executed by any unprivileged user. Give 0.5 seconds to udev to identify the new files and change the permission. Tested with udev rules: SUBSYSTEM=="gpio*", PROGRAM="/bin/sh -c 'find -L /sys/class/gpio/ -maxdepth 2 -exec chown root:uucp {} \; -exec chmod g=u {} \; || true'" Change-Id: I1316c66ff103ffe23e5e4720f33372dc272a3766 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5302 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-12-19gdb_server: fix extended_protocol for multi-targetAntonio Borneo
The flag extended_protocol is currently a single static variable thus, in case of multiple targets, it is shared among all the gdb connections. This is an issue if the gdb connections are not all using extended protocol, but also when one connection get closed because the code sets the flag to zero impacting the other connections still open. Move the flag extended_protocol in the per-connection struct gdb_connection. Change-Id: I19d565f925df6a31767fd8d392242f60867109f2 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5310 Tested-by: jenkins Reviewed-by: Moritz Fischer <moritzf@google.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-12-19gdb_server: fix string length with semihosting_fileioAntonio Borneo
The GDB file-I/O remote protocol extension, used for implementing the semihosting file I/O, requires the length of strings to include the trailing zero character, as explicitly stated inside a comment in GDB source code [1]: /* 1. Parameter: Ptr to pathname / length incl. trailing zero. */ ARM specification for semihosting [2] requires the string length to not include the trailing zero character, e.g. in SYS_OPEN specifications: "field 3: An integer that gives the length of the string pointed to by field 1. The length does not include the terminating null character that must be present." The mismatch above requires OpenOCD to add "one" to the string length before passing it to GDB. Such conversion is missing either in the generic semihosting provider of the data, the function semihosting_common(), and in the consumer of the data, the gdb_server function gdb_fileio_reply(). The conversion is already implemented in the target specific function nds32_get_gdb_fileio_info(), but it's not the preferred place for such GDB specific requirement. This issue affects the semihosting calls "open", "unlink", "rename" and "system". Remove the "+1" conversion from nds32_get_gdb_fileio_info(). Add the "+1" conversion in gdb_fileio_reply(). [1] http://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;f=gdb/remote-fileio.c;h=11c141e42c4d#l381 [2] "Semihosting for AArch32 and AArch64, Release 2.0" https://static.docs.arm.com/100863/0200/semihosting.pdf Change-Id: I35461bcb30f734fe2d51f7f0d418e3d04b4af506 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5322 Tested-by: jenkins Reviewed-by: Steven Stallion <sstallion@gmail.com> Reviewed-by: Muhammad Omair Javaid <omair.javaid@linaro.org> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-12-17flash/nor/stm32f2x: fix clang static analyzer warningTomas Vanek
Using a signed variable as a parameter of FLASH_SNB() macro generated "warning: The result of the left shift is undefined because the left operand is negative" Change-Id: I8b3fe840f9308962460906097df6ddd848c07b25 Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: http://openocd.zylin.com/5356 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2019-12-16jtag_vpi: ensured constant packet size & endiannessJan Matyas
Made sure that size and endianness of jtag_vpi structures sent over the network is the same, regardless of the platform. Little endian chosen to maintain as much compatibility with existing OpenOCD builds as possible. Matching change in the original jtag_vpi server: https://github.com/fjullien/jtag_vpi/pull/4 Change-Id: Ib839fea9bb2d5190b5643c970b89333b286dce71 Signed-off-by: Jan Matyas <matyas@codasip.com> Reviewed-on: http://openocd.zylin.com/5152 Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com> Tested-by: jenkins
2019-12-12flash/nor/nrf5: remove check for protected sectorTomas Vanek
The new "Access control list" flash protection scheme used in nRF52840 is not yet supported. Do not prevent sector erase if protection state is unknown. Change-Id: Iae9a869a54ffbdc888fb3ec478dafb5c942d9ea0 Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: http://openocd.zylin.com/5348 Tested-by: jenkins
2019-12-12server/tcl_server.c: Fix buffer overrunJimmy
The input buffer size is checked only after writing past its end. Change-Id: I6a9651c5b7d82efe338468d67bf6caca41004b01 Signed-off-by: Jimmy <nhminus@gmail.com> Reviewed-on: http://openocd.zylin.com/5352 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-12-10server: gdb_server: fix memory map generation on a 32-bit BE hostPaul Fertser
Due to lack of printf format check wrong specifier was used and it actually broke operation on a 32-bit BE host. So fix this and add the necessary function attributes so that the bugs like that can be uncovered automaticaly. Reported and pinpointed by Karl Palsson on IRC. Change-Id: I254ec28fcd9bb30594d607f74a6dba5456c2c7a1 Tested-by: Karl Palsson <karlp@tweak.net.au> Signed-off-by: Paul Fertser <fercerpav@gmail.com> Reviewed-on: http://openocd.zylin.com/5342 Tested-by: jenkins Reviewed-by: Karl Palsson <karlp@tweak.net.au> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2019-12-07target/stm32h7x: add support of dual core variant of STM32H7Tarek BOCHKATI
STM32H7x7 and STM32H7x5 devices contains two cores : CM7 + CM4 The second core creation is only done when * DUAL_CORE variable is set to true * non HLA interface is used A second check for the second core existence is done in cpu1 examine-end Once the second core is detected it gets examined. Furthermore, the script provides a configurable CTI usage in order to halt the cores simultaneously. Tested on Rev X and V devices. PS: the indentation was a mix of spaces and tabs, all changed to tabs. Change-Id: Iad9c30826965ddb9be5dee628bc2e63f953bbcb8 Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: http://openocd.zylin.com/5130 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-11-28mips64: Add generic mips64 target supportPeter Mamonov
Change-Id: I2bdd2573f23e65652686d18031698f423eec77c0 Signed-off-by: Konstantin Kostyukhin <kost@niisi.msk.ru> Signed-off-by: Aleksey Kuleshov <rndfax@yandex.ru> Signed-off-by: Peter Mamonov <pmamonov@gmail.com> Signed-off-by: Oleksij Rempel <linux@rempel-privat.de> CC: Dongxue Zhang <elta.era@gmail.com> CC: Paul Fertser <fercerpav@gmail.com> CC: Salvador Arroyo <sarroyofdez@yahoo.es> CC: Spencer Oliver <spen@spen-soft.co.uk> Reviewed-on: http://openocd.zylin.com/2322 Tested-by: jenkins Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2019-11-28mips: Add MIPS64 supportPeter Mamonov
The patch adds support for processors implementing MIPS64 instruction set. Change-Id: I79a983dfdead81553457a0f3e9e739a9785afaac Signed-off-by: Konstantin Kostyukhin <kost@niisi.msk.ru> Signed-off-by: Andrey Sidorov <anysidorov@gmail.com> Signed-off-by: Aleksey Kuleshov <rndfax@yandex.ru> Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Peter Mamonov <pmamonov@gmail.com> Signed-off-by: Oleksij Rempel <linux@rempel-privat.de> CC: Dongxue Zhang <elta.era@gmail.com> CC: Paul Fertser <fercerpav@gmail.com> CC: Salvador Arroyo <sarroyofdez@yahoo.es> CC: Spencer Oliver <spen@spen-soft.co.uk> Reviewed-on: http://openocd.zylin.com/2321 Tested-by: jenkins Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2019-11-27target/stm32h7x: Use AP2 to access DBGMCU when non HLA adapter is usedChristopher Head
The STM32H7 has three access ports. The DBGMCU component is available through AP0 at 0x5C001000 and through AP2 at 0xE00E1000. Using the latter is preferable for early configuration because it works in all power states and while SRST is asserted, whereas the former does not. Change-Id: Iaf8f01d769efb6655040060a8e1e951e1f7e50ab Signed-off-by: Christopher Head <chead@zaber.com> Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: http://openocd.zylin.com/4742 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-11-27flash/nor/stm32h7x: remove options cache and some driver enhancementsTarek BOCHKATI
functions managing option bytes cache (stm32x_read/write_options) have bee removed, and a new functions to modify a single option byte have been introduced (stm32x_write/modify_option). by the way, some helpers have been introduced to access flash registers: - stm32x_read_flash_reg(bank, offset, *value): int - stm32x_write_flash_reg(bank, offset, value): int and a new commands to read and write a single flash option register: - stm32h7x option_read <bank> <option_reg offset> - stm32h7x option_write <bank> <option_reg offset> <value> [mask] also lock and unlock handlers' have been reduced by using the same routine (stm32x_set_rdp) and have been optimized to not write options unless there is a change in RDP level. finally, several functions have been fixed to lock flash / options in case of failure. Change-Id: I75057949ab9f5b4e0f602bafb76f9f80d53a522b Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: http://openocd.zylin.com/5293 Tested-by: jenkins Reviewed-by: Christopher Head <chead@zaber.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-11-27flash/nor/stm32h7x: fix option bytes handling to work with both banksTarek BOCHKATI
To achieve that we need to avoid using FLASH_REG_BASE_B0, and use bank registers instead: For dual bank devices, each option register is mapped in 2 addresses at the same offset from flash_bank_reg_base. This is true for OPTCR, OPTKEYR, OPTSR_CUR/PRG, OPTCCR according to RM0433 Rev6 (refer to section 3.9: FLASH registers) In stm32x_write_options, according to RM0433 Rev6, after OBL launch we should wait for OPTSR_CUR.BSY bit instead of FLASH_SR.QW Change-Id: Ie24a91f069d03c9233797390fc2e925c737dad90 Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: http://openocd.zylin.com/5291 Tested-by: jenkins Reviewed-by: Christopher Head <chead@zaber.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-11-27flash/nor/stm32h7x: remove stm32x_options.protection2Tarek BOCHKATI
Each bank had to store its options only, there is no need for bank1 to sneak into bank2 options. Furthermore, some variants do not have a second bank. Change-Id: I9229eb8ab4b5860ba2b0c5dbe626a54a84bca4d6 Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: http://openocd.zylin.com/5290 Tested-by: jenkins Reviewed-by: Christopher Head <chead@zaber.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-11-26flash/nor/nrf5: fix allocation of driver_priv and sector arrayTomas Vanek
Drop static pointer to allocated struct nrf5_info, iterate over the flash bank list to find previously allocated nrf5 instances. nrf5 is swd only device, so static allocation makes no harm, but we should avoid copying the wrong code to other flash drivers. Free sector array before allocating it to avoid memory leak on re-probing device. Change-Id: I781d8f4418a91c043f2393e5ecc5278fc6df3566 Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: http://openocd.zylin.com/4910 Tested-by: jenkins
2019-11-26flash/nor/nrf5: show RAM size on old nRF51 devices (rev 1, 2)Tomas Vanek
Change-Id: I2452c084b9bd9e401bd49e15791428a53df1cd1d Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: http://openocd.zylin.com/4868 Tested-by: jenkins
2019-11-26flash/nor/nrf5: do not check FICR PPFC on nRF52Tomas Vanek
Change-Id: I6beee9b85a542040f2495513b5ba51bd8e1389db Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: http://openocd.zylin.com/4867 Tested-by: jenkins
2019-11-26flash/nor/nrf5: rename registers by nRF seriesTomas Vanek
Change-Id: I70af671c52665b27a28508e06e7d3e5e40a621f7 Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: http://openocd.zylin.com/4866 Tested-by: jenkins
2019-11-26flash/nor/nrf5: refactor sector allocation to use alloc_block_array()Tomas Vanek
Change-Id: Ied8ea917cec492fc6bb8836a92d8c4ceaf3b499b Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: http://openocd.zylin.com/4865 Tested-by: jenkins
2019-11-26flash/nor/nrf5: implement BPROT protection check for nRF52810,832Tomas Vanek
Also refuse 'flash protect' on any nRF52. Fail protection check on nRF52840 until ACL protection is implemented. Change-Id: I84fcf117427e4894147c3ad92e2a3597566b4fcf Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: http://openocd.zylin.com/4864 Tested-by: jenkins
2019-11-26flash/nor/nrf5: detect newer devices without HWID tableTomas Vanek
nrf5 flash driver detected devices by looking up the HWID in the table of known devices. Unfortunately chips are produced with many different HWIDs for each type. All nRF52 devices have FICR INFO field suitable for device identification without need of HWID lookup. Some newer nRF51 devices have FICR INFO too although undocumented. Use this information to identify the device. nrf5_info() is reworked to show just concise info. Decoding FICR and UICR registers was moved from nrf5_info() to a new command 'nrf5 info' without functional changes. The flash bank for UICR page has the same size as program flash sector. Change-Id: I900095b9ae23ee995f8e2bef8539b75d00300da5 Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: http://openocd.zylin.com/4848 Tested-by: jenkins
2019-11-26flash/nor/nrf5: remove useless page padding and UICR autoeraseTomas Vanek
nRF5 flash controller can write a word at a time. Ask flash infrastructure to handle alignment and padding. Fix mixing of offset and address in nrf5_ll_flash_write() - the original code worked just because NRF5_FLASH_BASE is 0 Change-Id: Ibe8bdf899a1764cf4117b2deda1a4618eeb16697 Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: http://openocd.zylin.com/4819 Tested-by: jenkins
2019-11-23helper: skip including sys/sysctl.h on LinuxAntonio Borneo
Starting from glibc 2.30, the header file sys/sysctl.h gets deprecated on Linux, after the commit 744e82963716 ("Linux: Deprecate <sys/sysctl.h> and sysctl") https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=744e82963716 The associated NEWS reports The Linux-specific <sys/sysctl.h> header and the sysctl function have been deprecated and will be removed from a future version of glibc. Latest automake 1.16.1 still does not handle this case. Current OpenOCD build fails with warning and requires configure with "--disable-werror" to build. Prevent including sys/sysctl.h on Linux build. Change-Id: I5310976573352a96e5aef123352f73475f0c35fe Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5317 Tested-by: jenkins Reviewed-by: Moritz Fischer <moritz.fischer.private@gmail.com> Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2019-11-22CVE-2018-5704: Prevent some forms of Cross Protocol Scripting attacksAndreas Fritiofson
OpenOCD can be targeted by a Cross Protocol Scripting attack from a web browser running malicious code, such as the following PoC: var x = new XMLHttpRequest(); x.open("POST", "http://127.0.0.1:4444", true); x.send("exec xcalc\r\n"); This mitigation should provide some protection from browser-based attacks and is based on the corresponding fix in Redis: https://github.com/antirez/redis/blob/8075572207b5aebb1385c4f233f5302544439325/src/networking.c#L1758 Change-Id: Ia96ebe19b74b5805dc228bf7364c7971a90a4581 Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com> Reported-by: Josef Gajdusek <atx@atx.name> Reviewed-on: http://openocd.zylin.com/4335 Tested-by: jenkins Reviewed-by: Jonathan McDowell <noodles-openocd@earth.li> Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2019-11-07STM8 Target relicensing to GPLv2 and laterAke Rehnman
Change-Id: I21126945c0475399aaf12239b8972fde5fddd845 Signed-off-by: Ake Rehnman <ake.rehnman@gmail.com> Reviewed-on: http://openocd.zylin.com/5331 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2019-11-07jtag: usb_blaster: Add missing 'default' to switch statementAlexandru Gagniuc
If a new JTAG command is added, then GCC will complain that enumeration value not handled in switch. This is the only driver not to have a default case, so add it. Change-Id: Icb838087bb7525d057a911bd256300e256da1668 Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Reviewed-on: http://openocd.zylin.com/5333 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-11-07jtag: jtag_vpi: Add missing 'default' to switch statementAlexandru Gagniuc
If a new JTAG command is added, then GCC will complain that enumeration value not handled in switch. Make this consistent with other drivers, and add a 'default' case. Change-Id: I66d6d0db3fcae93ea246f2d4882ffff5dec14693 Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Reviewed-on: http://openocd.zylin.com/5340 Tested-by: jenkins Reviewed-by: Jan Matyas <matyas@codasip.com> Reviewed-by: Franck Jullien <franck.jullien@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>