aboutsummaryrefslogtreecommitdiff
path: root/src/helper
AgeCommit message (Collapse)AuthorFilesLines
2025-05-05Merge up to afbd01b0a46f3a81fe6076c002ad66973dcfb64c from upstreamEvgeniy Naydanov2-97/+52
Change-Id: I719167dc34a1a29ae32f8d4f27f2d3cd7a04e47b
2025-04-19list: silent scan-build false positiveAntonio Borneo1-0/+4
With commit c023534e7b6f ("target: use list for target events") scan build incorrectly states that list_add() would be called with the field 'next' of the parameter 'head' (thus 'head->next') set to NULL. Then, list_add() would call linux_list_add() with the parameter 'next' set to NULL that will cause a NULL dereference. While this can really happen with broken code, it's not the case with the code from the change above. Add assert() in linux_list_add() to silent scan build on this false positive and to detect future incorrect use of the list. Change-Id: Iec7f3d70237312b646ac58f76ecaab2fa25eab41 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8824 Tested-by: jenkins
2025-04-19command: rewrite command 'capture' as COMMAND_HANDLERAntonio Borneo1-79/+34
While there, use Jim_EvalObj() to execute the subcommand, so any error will correctly report the TCL file and the line number that have originated the error, instead of the silly: > capture {bogus command} command.c:703: Error: invalid command name "bogus" at file "command.c", line 703 Change-Id: Ic75a6146d6cedf49e808d98501fa1a7d4235b58a Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8587 Tested-by: jenkins
2025-04-19command: rewrite command 'command mode' as COMMAND_HANDLERAntonio Borneo1-18/+14
Another step to drop jim_handler. Change-Id: I85cb567386a5aceb36aa273f8b66cbfd4a637c3f Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8586 Tested-by: jenkins Reviewed-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
2025-04-07Merge up to 6834f022b96fb1c7f5829166578e01a0ac223cb0 from upstreamEvgeniy Naydanov2-44/+39
Change-Id: Idaef3f5911bde237bd47d1d921acc186a06ea8f8
2025-03-29command: factorize jim_command_mode()Antonio Borneo1-42/+36
During 'help' dump, to determine the mode (e.g. COMMAND_CONFIG) of a command, the current code executes the OpenOCD TCL command "command mode", while it could directly call the implementation of the TCL command above. Factorize jim_command_mode() and call the inner implementation instead of executing "command mode". Change-Id: Id8c33d0ed1373b5744dcc3ac354c3e0a88576f75 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8585 Reviewed-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com> Tested-by: jenkins
2025-03-29helper: command: return correct error on command 'echo'Antonio Borneo1-1/+1
In case of incorrect syntax, return ERROR_COMMAND_SYNTAX_ERROR so the command framework will print the usage string. Change-Id: I348debc77f470551d54fa77b4da780a48ff539c0 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8802 Tested-by: jenkins
2025-03-15helper/log: mark `fmt` argument of `alloc_vprintf()` as format stringEvgeniy Naydanov1-1/+2
Building on Ubuntu 22.04 with `-fsanitize=undefined` (GCC 12.3.0) results in an error: Checkpatch-ignore: COMMIT_LOG_LONG_LINE ``` In file included from /usr/include/stdio.h:894, from <openocd>/src/helper/system.h:23, from <openocd>/src/helper/replacements.h:18, from <openocd>/src/helper/log.c:20: In function ‘vsnprintf’, inlined from ‘alloc_vprintf’ at <openocd>/src/helper/log.c:347:8: /usr/include/x86_64-linux-gnu/bits/stdio2.h:85:10: error: null format string [-Werror=format-truncation=] 85 | return __builtin___vsnprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 86 | __glibc_objsize (__s), __fmt, __ap); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors ``` The error mentiones the call site `src/helper/log.c:347`. There `vsnprintf()` is called passing `fmt` as format string. To mitigate this, mark the format string with the corresponding attribute in `alloc_vprintf()` Change-Id: I91011490715998ef5a931c19c3c9d74a1a304e5d Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8764 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
2025-03-05Merge up to a168c634126e9e6bb95c6e68b2db5afbb099abf7 from upstreamEvgeniy Naydanov1-8/+41
There was a bunch of conflicts due to commit 297844cf46c7de5faa9de1c4a9f223b505dc3e9c ("target: Use 'bool' data type in target_{step,resume}") Resolved by updating the corresponding data types throughout the codebase. Change-Id: I9574deeda754b2843b69b4afe80b293d4b357ddd Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
2025-02-22jep106: update to revision JEP106BL Feb 2025Antonio Borneo1-8/+41
Update to latest available document. Change-Id: Ic7f31bf74c25aaebc5a2ecc7d5a0e516321bf862 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8766 Tested-by: jenkins
2025-02-17Merge up to 1f3f635693a1ddc85f362dc324cb49c3e7b75f27 from upstreamEvgeniy Naydanov1-1/+1
Conflict in `src/rtos/hwthread.c` between commit 57dbcb1d02c9a603364d40aebdc5d9bc8c2be2d7 ("Improve a couple of user/debug messages. (#763)") and commit 7f2db80ebc168d74a56dc8b76be5355ee4878be6 ("rtos/hwthread: Use LOG_TARGET_xxx()"). Resolved by using `LOG_TARGET_xxx()` without changing the message. Change-Id: I1c1ab321b54f2ef8267f0dca63e16ca8ed6b4655 Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
2025-02-16options.c: option --help should yield exit code 0R. Diez1-1/+1
--help is supported and there is no reason to signal failure Change-Id: I59fda5336df47ec0b8172541a5fbfe60014bba7e Signed-off-by: R. Diez <rdiezmail-openocd@yahoo.de> Reviewed-on: https://review.openocd.org/c/openocd/+/8723 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2025-01-28Merge up to a510d51a78f14fbb8416037a587ce1bfc6016d24 from upstreamEvgeniy Naydanov2-11/+24
Changed `.github/workflows` due to internall `jimtcl` deprecation. Change-Id: I628922a843a7116955cd6b48c48b0cd104bcaf20 Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
2025-01-25helper/log: Fix build using _DEBUG_FREE_SPACE_Antonio Borneo1-3/+14
The glibc API 'mallinfo' is deprecated and the new 'mallinfo2' should be used from glibc 2.33 (2021-02-01). Throw an error when '--enable-malloc-logging' is used on systems that compile without glibc. Detect the glibc version and, for backward compatibility, define 'mallinfo2' as the old 'mallinfo'. Define a macro for the format of 'fordblks'. Change-Id: I68bff7b1b58f0ec2669db0b911f19c1c5a26ed30 Reported-by: Steven J. Hill <steven.hill@konsulko.com> Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8589 Tested-by: jenkins
2025-01-25helper/options: handle errors in `-l`Evgeniy Naydanov1-1/+5
Before the patch an error in opening the log file (e.g. can't write a file) was ignored when specified via `-l`. E.g.: ``` > touch log > chmod -w log > openocd -l log -c shutdown ... failed to open output log "log" shutdown command invoked > echo $? 0 ``` After the patch: ``` ... > openocd -l log -c shutdown ... failed to open output log "log" > echo $? 1 ``` Change-Id: Ibab45f580dc46a499bf967c4afad071f9c2972a2 Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8666 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2025-01-25helper/options: drop redundant argument checksEvgeniy Naydanov1-4/+2
In case the option is passed with a single `:` in `optstring` argument, the call to `getopt_long()` should return `?`. Therefore the check on `optarg` is redundand in case of `l` and `c`. Change-Id: I1ac176fdae449a34db0a0496b69a9ea65ccd6aec Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com> Reported-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8718 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2025-01-25OpenOCD: fix code indentationAntonio Borneo1-4/+4
Fix checkpatch errors ERROR:SUSPECT_CODE_INDENT: suspect code indent for conditional statements Change-Id: I94d4fa5720c25dd2fb0334a824cd9026babcce4e Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8497 Tested-by: jenkins
2025-01-22Merge up to 26f2df80c3f9ac54fc488ed26f6320904881c0d4 from upstreamEvgeniy Naydanov2-1/+4
Conflicts: * `src/target/target.c` due to commit 4004db5d3a7e767aa4a6b7fddf92ac3370670c79 ("Make polling_interval unsigned.") Change-Id: I0a691dbebe300f3a53fb31bd1097a9aff5551a52
2025-01-12helper: list: rename macro clashing with sys/queue.hAntonio Borneo1-1/+1
The macro named LIST_HEAD() clashed with a macro of same name in the GNU libc file sys/queue.h. This causes a warning in MacOS build due to some other system file including sys/queue.h. Rename LIST_HEAD() as OOCD_LIST_HEAD(). Checkpatch-ignore: MACRO_ARG_REUSE Change-Id: Ic653edec77425a58251d64f56c9f5f6c645ba0cd Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reported-by: Andrew Shelley <ashelley@btinternet.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8683 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-by: Andy <andrewjohnshelley@gmail.com>
2024-12-30helper/log: Add LOG_TARGET_USER()Marc Schink1-0/+3
Add a target-related log function for user messages as it already exists for other log levels. Change-Id: I9076677d6451b900332583e748bab3f83df56d3b Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: https://review.openocd.org/c/openocd/+/8661 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
2024-12-18Merge up to 133dd9d669e5b8beb7c7787b0be677621808e72d from upstreamEvgeniy Naydanov1-1/+2
Change-Id: Iaaf234da839cbed61684f4615135c9a42213c56a
2024-11-23helper/jim-nvp.h: Rework 'isconfigure' variableMarc Schink1-1/+2
Change the variable name to 'is_configure' to be compatible with the coding style and use 'bool' as data type. Change-Id: I8609f9807c8bd14eaf6c93acf63fd51b55c9bbbb Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: https://review.openocd.org/c/openocd/+/8573 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2024-11-12Merge up to fd62626dff25cf503a25040d3040b0a2bb9b2a76 from upstreamEvgeniy Naydanov11-77/+132
Conflicts are related to `unsigned`->`unisgned int` cleanup: * `src/jtag/drivers/ftdi.c` -- between 6749c70a3ae891552296888986e6eeae1e17f11a and a64dc23bf19fb4a7626fbda3c02693523ab5a75b. * `src/rtos/hwthread.c` -- between ef3e61bebc53f619f42bb06cfd194cd547cceb69 and 436e6f1770e4da6ec5b52724cfb637e8916b535a. * `src/target/target.c` and `.h` -- between 53ec10b61da5de553c01f92bddf80c076bd49331 and e72733d59025b5d595bf955b227e95e5db7305c7. * `src/target/riscv/*` -- due to 957eb741a0980408fe4d0682fccb99a183f90998 and fec3b224214e3784b0c00970d2421212402da880. Resolved by: * Changing the return type of `riscv_batch_get_dmi_read_op()` to `uint32_t`. * Using RISC-V OpenOCD's version in other cases. Change-Id: Ia6e2129c6fddb1dec26adcd936506af2539412ef
2024-10-20gdb_server: Improve const correctnessJan Matyas2-2/+2
On several packet-handling functions, add "const" to arguments that represent read-only packet buffers. For instance on GCC 13.2.0, this code: const char *some_packet = "..."; gdb_put_packet(conn, some_packet, strlen(some_packet)); would prior to the fix produce warning: passing argument 2 of ‘gdb_put_packet’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] Change-Id: Idb62f57d37ed323c39de38982e57afdd3882e280 Signed-off-by: Jan Matyas <jan.matyas@codasip.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8517 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
2024-10-05helper/align.h: Fix macro IS_PWR_OF_2Jan Matyas1-1/+1
Zero is not a power of two. All functions that use IS_PWR_OF_2 were checked and the edge case of IS_PWR_OF_2(0) does not occur anywhere at the moment. Therefore the fix is safe. Change-Id: I84d9f9c64c9a7df452ca6e99c2ee4169ccb2b0be Signed-off-by: Jan Matyas <jan.matyas@codasip.com> Fixes: 9544cd653df1 ("helper: add align.h") Reviewed-on: https://review.openocd.org/c/openocd/+/8511 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
2024-10-05openocd: fix build with jimtcl 0.83Antonio Borneo2-0/+2
In jimtcl 0.82, the include file jim.h included in turn stdio.h This made redundant to include the former in openocd source files. Since jimtcl 0.83, jim.h drops the include of stdio.h, causing openocd build to fail. Include stdio.h in the files that need it. Change-Id: Ic81c9b273d7520f4d2d8c32bc3e0a6bcfffb67ed Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8512 Reviewed-by: Jonathan McDowell <noodles-openocd@earth.li> Tested-by: jenkins
2024-10-05openocd: convert 'unsigned' to 'unsigned int'Antonio Borneo7-69/+69
Conversion done with checkpatch --fix-inplace -types UNSPECIFIED_INT Ignore the cast as they could be better addressed. Fix only minor additional checkpatch issue (spacing and line length). Change-Id: I4f936ffc4cedb153afa331cd293b08f4c913dc93 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8482 Tested-by: jenkins
2024-10-05jep106: update to revision JEP106BK Sep 2024Antonio Borneo1-7/+60
Change-Id: Ica84e22b8d2da152cec39fc569c8333677c19490 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8501 Tested-by: jenkins
2024-10-03Merge up to 1173473f662bbdf6d1499654568256257eee6cdd from upstreamEvgeniy Naydanov2-17/+17
1ae6b07b45198618c3f0975fd49de59cf6c04e7a replaced `buf_cmp()` with `buf_eq()`, so a96a0a4e3993de7f7169a306aa0202e0f3e26f4f needs to be adjusted. Change-Id: I97f6a3518db9421dab2ae4dd2312f443e928b114
2024-09-21binarybuffer: Invert buf_cmp* return value and rename to buf_eq*Jessica Clarke2-17/+17
The current semantics are a bit confusing, as the return value looks like memcmp (0/false being equal) but the bool return type means one likely expects true to mean equal. Make this clearer by switching them out for buf_eq* functions that do that instead. Checkpatch-ignore: UNSPECIFIED_INT Change-Id: Iee0c5af794316aab5327cb9c168051fabd3bc1cb Signed-off-by: Jessica Clarke <jrtc27@jrtc27.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8490 Tested-by: jenkins Reviewed-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2024-09-16Merge up to fd7b66c5eb038185b72953821204ec9bb8ce49d1 from upstreamEvgeniy Naydanov4-168/+78
Backports the fix for #1131. Commit 0bf3373 ("target/breakpoints: Use 'unsigned int' for length") introduces a bug. Link: https://review.openocd.org/c/openocd/+/7056/comment/3c4d9185_83614e2a/ Change-Id: I9f5f67050698a83c27f84965f6de031e2cad492d
2024-09-15binarybuffer: Fix inverted return value in buf_cmpJessica Clarke1-1/+1
This is the fast path for when there is a mismatch in the leading whole bytes, which means we should return true to indicate not equal like all the other cases here and in the surrounding functions. Otherwise we'll incorrectly report _buf1 == _buf2 if and only if there are mismatches in the leading whole bytes. This was introduced during the refactor and optimisation referenced below. The only in-tree caller of this is jtag_check_value_inner, which will just fail to catch some errors. However, downstream in riscv-openocd it gets used in the riscv target to determine whether an IR scan is needed to select the debug module, and with an IRLEN >= 8 this breaks resetting if the encoding for the DMI isn't all-ones in its leading whole bytes (to match BYPASS), since it will believe they are the same and not do an IR scan, failing (with "At least one TAP shouldn't be in BYPASS mode") in the subsequent DR scan due to the TAP still being recorded as having bypass set (and really having an instruction of either BYPASS or IDCODE). Fixes: e4ee891759b0 ("improve buf_cmp and buf_cmp_mask helpers") Change-Id: Ic4f7ed094429abc4c06a775eb847a8b3ddf2e2d6 Signed-off-by: Jessica Clarke <jrtc27@jrtc27.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8489 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
2024-09-15binarybuffer: add asserts for the number of requested bits for get/set functionsParshintsev Anatoly1-0/+4
Change-Id: Ieca5b4e690c9713ad60dc9d8c223c2d64822e2f5 Signed-off-by: Parshintsev Anatoly <anatoly.parshintsev@syntacore.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8427 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-by: Jan Matyas <jan.matyas@codasip.com> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2024-09-07binarybuffer: str_to_buf(): align prefix to TCL syntaxAntonio Borneo1-46/+33
Integer values are interpreted by TCL as decimal, binary, octal or hexadecimal if prepended with '0d', '0b', '0o' or '0x' respectively. The case of '0' prefix has been interpreted as octal till TCL 8.6 but is interpreted as part of a decimal number by JimTCL and from TCL 9. Align str_to_buf() to latest TCL syntax by: - addding support for '0d', '0b' and '0o' prefix; - dropping support for '0' prefix. Change-Id: I708ef72146d75b7bf429df329a0269cf48700a44 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8465 Tested-by: jenkins Reviewed-by: Jan Matyas <jan.matyas@codasip.com>
2024-08-25binarybuffer: str_to_buf(): simplify it and fix scan-build errorAntonio Borneo1-73/+26
The function str_to_buf() can be simplified by writing directly the intermediate results in the output buffer. Such simplification improves the readability and also makes scan-build happy, as it does not trigger anymore the warning: src/helper/binarybuffer.c:328:8: warning: Use of memory allocated with size zero [unix.Malloc] if ((b256_buf[(buf_len / 8)] & mask) != 0x0) { Change-Id: I1cef9a1ec5ff0e5841ba582610f273e89e7a81da Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8396 Reviewed-by: Jan Matyas <jan.matyas@codasip.com> Tested-by: jenkins
2024-08-25binarybuffer: str_to_buf(): rename buf_len as buf_bitsizeAntonio Borneo2-9/+9
The name 'buf_len' is misleading, as it usually refers to the byte length of a buffer. Here we use it for the length in bits. Rename it as 'buf_bitsize'. While there, fix checkpatch error by changing the index type to 'unsigned int'. Change-Id: I78855ed79a346d996d9c0100d94d14c64a36b228 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8395 Tested-by: jenkins Reviewed-by: Jan Matyas <jan.matyas@codasip.com>
2024-08-25binarybuffer: simplify the prototype of str_to_buf()Antonio Borneo3-33/+20
With 'radix' always zero and '_detected_radix' always NULL, drop the two parameters and simplify str_to_buf(). While there: - drop some redundant assert(), - drop the re-check for the base prefix, - simplify str_strip_number_prefix_if_present() and rename it, as the prefix MUST be present, - fix a minor typo, - update the doxygen description of str_to_buf(). Change-Id: I1abdc8ec0587b23881953d3094101c04d5bb1c58 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8394 Tested-by: jenkins Reviewed-by: Jan Matyas <jan.matyas@codasip.com>
2024-08-25helper: command: drop radix parameter from command_parse_str_to_buf()Antonio Borneo2-27/+6
Commit 53b94fad58ab ("binarybuffer: Fix str_to_buf() parsing function") introduces the helper command_parse_str_to_buf() to parse as number a string on TCL command-line. The parameter 'radix' can specify the base (decimal, octal, hexadecimal, or auto-detected). TCL is supposed to use decimal numbers by default, while octal and hexadecimal numbers must be prefixed respectively with '0' and '0x' (or '0X'). This would require the helper to always run auto-detection of the base, thus always set the 'radix' parameter to zero. This makes the parameter useless. Keeping the 'radix' parameter can open the door to future abuse of TCL syntax, E.g. a command can require an octal value without the mandatory TCL '0' prefix; the octal value cannot be the result of TCL expression. To prevent any future abuse of the 'radix' parameter, drop it. Change-Id: I88855bd83b4e08e8fdcf86a2fa5ef3269dd4ad57 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8393 Tested-by: jenkins Reviewed-by: Jan Matyas <jan.matyas@codasip.com>
2024-08-20Merge up to ac63cd00d792331914db0b6edd3f427c30eec3fa from upstreamParshintsev Anatoly5-57/+206
- src/jtag/drivers/ftdi.c: ``` ++<<<<<<< HEAD + int i; + static const uint8_t zero; ++======= + uint8_t zero = 0; ++>>>>>>> ocd_upstream ``` Decided to choose the latter. - src/target/riscv/riscv-013.c: ``` ++<<<<<<< HEAD + int abs_chain_position; + /* The base address to access this DM on DMI */ + uint32_t base; ++======= + unsigned int abs_chain_position; + ++>>>>>>> ocd_upstream ``` Decided to choose the latter (abs_chain_position is unsigned now) - src/target/riscv/batch.c: ``` ++<<<<<<< HEAD ++======= + void dump_field(int idle, const struct scan_field *field) + { ... + } ++>>>>>>> ocd_upstream ``` dump_field function is not needed anymore Signed-off-by: Parshintsev Anatoly <anatoly.parshintsev@syntacore.com>
2024-07-28jep106: update to revision JEP106BJ.01 July 2024Antonio Borneo1-6/+31
Change-Id: Iebab3f6a3b1f6d82f955997fd4e691c55d01c767 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8406 Tested-by: jenkins
2024-07-13binarybuffer: Fix str_to_buf() parsing functionJan Matyas4-51/+175
The function str_to_buf() was too benevolent and did not perform sufficient error checking on the input string being parsed. Especially: - Invalid numbers were silently ignored. - Out-of-range numbers were silently truncated. The following commands that use str_to_buf() were affected: - reg (when writing a register value) - set_reg - jtag drscan This pull request fixes that by: - Rewriting str_to_buf() to add the missing checks. - Adding function command_parse_str_to_buf() which can be used in command handlers. It parses the input numbers and provides user-readable error messages in case of parsing errors. Examples: jtag drscan 10 huh10 - Old behavior: The string "huh10" is silently converted to 10 and the command is then executed. No warning error or warning is shown to the user. - New behavior: Error message is shown: "'huh10' is not a valid number" reg pc 0x123456789 Assuming the "pc" is 32 bits wide: - Old behavior: The register value is silently truncated to 0x23456789 and the command is performed. - New behavior: Error message is shown to the user: "Number 0x123456789 exceeds 32 bits" Change-Id: I079e19cd153aec853a3c2eb66953024b8542d0f4 Signed-off-by: Jan Matyas <jan.matyas@codasip.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8315 Tested-by: jenkins Reviewed-by: Marek Vrbka <marek.vrbka@codasip.com> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2024-06-25Merge up to ad87fbd1cf28760795c4e18f3318a2d720e5a8a6 from upstreamEvgeniy Naydanov1-2/+2
Conflicts: * `doc/openocd.texi`: due to d382c95d57c0ad9ed2dcc83c95404babb7647708, resolved by selecting the upstream version. * `src/server/gdb_server.c`: between 944fe66f104e356c5fcd2b5c25200cebef9b389c and 92e8823ebdb6d01b41bb5d79af49501d525acd1d. Resolved by adopting the use of `LOG_TARGET_*`. * `src/target/target.c`: between 639e68a621b7ae8c4a296ca7e45b47075268fded and c5358c84ad0d3e7497498e0457cec7785f72910a, selected the version from `riscv-openocd`. Change-Id: Ic1327f25e147945e0ec82947a82452501e8ee5de
2024-06-08src/helper/startup: fix syntax errorsNoah Moroze1-2/+2
The missing closing brackets were caught by tclint v0.2.5 (https://github.com/nmoroze/tclint): ``` tclint src/helper/startup.tcl | grep "syntax error" ``` The improperly escaped backslash was caught by manual inspection during code review. Change-Id: I8cd44e58040d4627f6b2fc8b88ca8a930cda0ba6 Signed-off-by: Noah Moroze <noahmoroze@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8282 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2024-05-30Merge up to 437dde701c13e707e5fd912ef6403e09052e4d9b from upstreamEvgeniy Naydanov2-2/+2
Conflict in src/rtos/FreeRTOS.c due to fbea7d5d38d0dcbdd71cb574da9bd12c78b568cf -- resolved by replacing `target->type->name` with a call to `target_type_name()`. Change-Id: I56702c6133894458903de7a4d764903004aa8b86
2024-05-26Fix build with clang even if it sets __GNUC__ to >= 4.4Bernhard Rosenkränzer2-2/+2
clang doesn't support the gnu_printf attribute that OpenOCD uses if __GNUC__ and __GNUC_MINOR__ indicates gcc >= 4.4. Most clang builds set __GNUC__/__GNUC_MINOR__ to 4.2 for historical reasons, so they don't trigger this condition; however, some builds set it to something much higher to work around code using __GNUC__ to determine if a feature that does exist in clang (but not gcc 4.2) is available, causing OpenOCD to use attribute gnu_printf. The problem can be reproduced without a special clang build by adding -fgnuc-version=14.1 to CFLAGS. Change-Id: I3c0832d4201578b116c5214203f95b6153dad30e Signed-off-by: Bernhard Rosenkränzer <bero@baylibre.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8258 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2024-03-28Merge up to a35e254c5383008cdacf7838a777f7f17af5eeb1 from upstreamEvgeniy Naydanov4-710/+240
Checkpatch-ignore: MACRO_ARG_REUSE, MACRO_ARG_PRECEDENCE Change-Id: Icd10f44d162054f8f32019a579ccbdda2cee7a91
2024-03-24helper/list: include the correct header fileAntonio Borneo2-2/+3
The file 'list.h', copied from FreeBSD, does not depend from any OpenOCD specific include file, but only needs 'stddef.h' for the type 'size_t'. Let 'list.h' to include the correct header file, then fix the now broken dependencies in the other files that were incorrectly relying on 'list.h' to include 'helper/types.h' Change-Id: Idd31b5bf607e226cac44ef41b2aa335ae4dbf519 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8173 Tested-by: jenkins
2024-03-24helper/list: Replace Linux code with FreeBSD oneAntonio Borneo1-709/+225
The file list.h was originally taken from the Linux kernel code, thus under license GPL-2.0-only. This locks OpenOCD to follow the same license, even if the majority of OpenOCD files are licensed as GPL-2.0-or-later. A similar file is also present in FreeBSD code base under the more permissive license BSD-2-Clause. Drop the code from Linux kernel and replace it with the code from FreeBSD 13.3.0. Adapt the code to OpenOCD coding style by fixing the majority of issues identified by checkpatch. Add the OpenOCD specific macros and comments. Unfortunately this causes the lost of all the doxygen comments. Checkpatch-ignore: MACRO_ARG_REUSE, MACRO_ARG_PRECEDENCE Change-Id: I6d86752c50158f3174c4e8c4add81e9998d01e0e Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8172 Tested-by: jenkins
2024-03-16openocd: dump full command line in the debug logAntonio Borneo1-0/+4
When receiving an OpenOCD debug log to investigate about errors or issues, the first question is often about providing the complete command line to better understand the use context. Plus, when OpenOCD is lunched by an IDE, its command line is kept hidden inside the IDE, adding troubles to the user to recover it. Add the full command line directly inside the debug log. It could have been useful to also search and add in the log the full path of the OpenOCD executable, but this is not an immediate task due to portability among OS's. See, for example: https://stackoverflow.com/questions/933850 This part could be handled in a future change, if really needed. Change-Id: Ia6c5b838b9b7208bf1ecac7f95b5efc319aeabf5 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8170 Tested-by: jenkins Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2024-03-16helper/log: add LOG_CUSTOM_LEVEL() macroTomas Vanek1-0/+9
Allow logging at a changeable level. Add an example of usage in ftdi driver. Log SWD commands with not OK response at debug level (3). For commands which responded OK use debug io level (4) not to flood the log. Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Change-Id: I67a472b293f7ed9ee84cadb7c081803e9eeb1ad0 Reviewed-on: https://review.openocd.org/c/openocd/+/8151 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins