aboutsummaryrefslogtreecommitdiff
path: root/src/rtos
AgeCommit message (Collapse)AuthorFilesLines
2023-08-29Merge commit 'dfbbfac4d72e247e8094a49c8573b2f49689b6d5' into from_upstreamTim Newsome4-57/+125
Change-Id: I6e7c0866291dd87946a4fd49d9bfe4cddefb3957
2023-07-06rtos/hwthread: Call rtos_free_threadlist() again.Tim Newsome1-0/+3
I think this was incorrectly removed in a merge. Change-Id: I49fce230f35ae7bd368d2ed780c6c1ffe5939fda
2023-06-22rtos/FreeRTOS: solve some conflicting usage of thread id. (#865)Chao Du1-11/+17
* rtos/FreeRTOS: solve some conflicting usage of thread id. 1. There are some RISCV-specific usage of thread_id, which has conflict with upstream. Some adaptions are made in this patch, to make sure OpenOCD is sending a clear thread list to gdb. 2. Use freertos_read_struct_value for xSchedulerRunning. Change-Id: I001a88a0c6d8eac98a389c0217b4897f28124840 Signed-off-by: Chao Du <duchao@eswincomputing.com> * fix typo. Change-Id: Id6546cc74de44bbee7e44b7cb29b769a2f35ec4a * correct the data type. Change-Id: I28c7e111e569d94ba5f6e1ae21745ddb34d4dd12 * changes as per the review comment. Change-Id: Ica4c705a8f2657700dc27e24790287ca802480fd * another macro replacement. Change-Id: Ia9330fed32d917cf87804051ba1b8d6ac42cfb7b --------- Signed-off-by: Chao Du <duchao@eswincomputing.com>
2023-06-14rtos/FreeRTOS: pxCurrentTCB should be used for judgment. (#862)Chao Du1-5/+5
* rtos/FreeRTOS: pxCurrentTCB should be used for judgment. The current TCB is stored in pxCurrentTCB, which is somehow RISC-V-specific, should not be overwritten from upstream (#816). * fix the code style check. Signed-off-by: Chao Du <duchao@eswincomputing.com> Change-Id: I9ffa8947f0cb9e93c7d96866882a5a1e8e69afad * revert some over-changes in last commit. Change-Id: Ie88bd75b59190503db11ee4538281bd13b554e50 Signed-off-by: Chao Du <duchao@eswincomputing.com> --------- Signed-off-by: Chao Du <duchao@eswincomputing.com>
2023-05-04Merge commit '228fe7300c7df7aa05ba2c0bc19edde6d0156401' into from_upstreamTim Newsome7-166/+992
Conflicts: doc/openocd.texi src/jtag/aice/aice_pipe.c src/jtag/aice/aice_usb.c src/rtos/FreeRTOS.c src/rtos/hwthread.c src/rtos/rtos_standard_stackings.c src/target/riscv/riscv.c Change-Id: I0c6228c499d60274325be895fbcd8007ed1699bc
2023-03-16Merge commit '1293ddd65713d6551775b67169387622ada477c1' into from_upstreamTim Newsome32-429/+174
This includes https://sourceforge.net/p/openocd/mailman/message/37710818/, which should fix #814. Conflicts: .travis.yml contrib/loaders/flash/stm32/stm32f1x.S contrib/loaders/flash/stm32/stm32f2x.S doc/openocd.texi src/rtos/FreeRTOS.c src/server/gdb_server.c src/target/riscv/riscv-013.c src/target/riscv/riscv.c src/target/riscv/riscv.h src/target/riscv/riscv_semihosting.c tcl/target/esp_common.cfg tcl/target/gd32vf103.cfg tools/scripts/checkpatch.pl Change-Id: I1986c13298ca0dafbe3aecaf1b0b35626525e4eb
2023-03-08Calculate the FreeRTOS type sizes and offsets more adaptively. (#806)Chao Du1-6/+47
* Calculate the FreeRTOS type sizes and offsets more adaptively. The definition of TickType_t varies between different targets. And it is also related to configUSE_16_BIT_TICKS option. Thus introduce a new command to make sure we are using a correct ticktype size. Change-Id: I9e38b331a9f07b96eb9a2c259e32377fca0106ad Signed-off-by: Chao Du <duchao@eswincomputing.com> * redundant semicolon. Change-Id: Ia21f0537e476099d8fe519ef78b3328d14123a38 * Update after review. Change-Id: I1825185ec9b0557d7e01f34a8f366661b3734aa7 * update doc Change-Id: I24b21c88b02ca3d76f1362f2545e86c068fc0ec6 --------- Signed-off-by: Chao Du <duchao@eswincomputing.com>
2023-02-17Set the current_thread when no FreeRTOS task was created.Chao Du1-0/+1
The 'current thread' was not set when no FreeRTOS task created. Which could lead a wrongly invoking of freertos_get_thread_reg_list. Change-Id: I0e0f8327080ef698d7ed4aae5ac2a630d532ddeb Signed-off-by: Chao Du <duchao@eswincomputing.com>
2023-02-08Improve a debug log in freertos_update_threads()duchao1-1/+1
To make the log more accurate and comprehensible. In case the offset is non-zero. Signed-off-by: Chao Du <duchao@eswincomputing.com>
2023-01-28rtos/nuttx: add riscv stacking infoErhan Kurubas2-0/+47
Tested with Espressif ESP32-C3 MCU Signed-off-by: Erhan Kurubas <erhan.kurubas@espressif.com> Change-Id: Ia71ace4909f2dc93ddc07a2ec5524cf374f1937c Reviewed-on: https://review.openocd.org/c/openocd/+/7251 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2023-01-28rtos/nuttx: move stacking info to the new nuttx stackings fileErhan Kurubas4-57/+78
Other OSes have separate files to keep stack register offsets. Adding them for NuttX as well will provide a clearer way to expand. Signed-off-by: Erhan Kurubas <erhan.kurubas@espressif.com> Change-Id: I1428fefefa199a95431f2073c0279dd7028ad8da Reviewed-on: https://review.openocd.org/c/openocd/+/7250 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2023-01-15src/rtos/eCos : Support per-build configuration specific structure layoutsJames G. Smith2-90/+950
Extended feature. This is a large patch, but is self-contained to the eCos support and does not affect any other openocd functionality. It does NOT affect existing eCos RTOS plugin users where their applications do not provide the extended symbolic helper information. If the helper symbols are not available the rtos support code will behave as before. This "dynamic" functionality is *required* because eCos does NOT have a fixed/hardwired, known, layout for the thread descriptor structure. The per-application build eCos configuration can affect the shape of the thread descriptor structure (field presence, and hence offsets of subsequent fields) such that constant values cannot be used to consistently interpret all possible eCos application configurations. For historical reasons, there is not yet a consistent namespace for the helper symbols across eCos HALs hence the support is currently limited to specific architectures (Cortex-M and ARM/Cortex-A). No new Clang analyser warnings are raised by this changeset. Change-Id: Ib3a36877326eeb56595cbca55e21b9e59a59c98a Signed-off-by: James G. Smith <jsmith@rallysmith.co.uk> Reviewed-on: https://review.openocd.org/c/openocd/+/6275 Reviewed-by: Alex Schuilenburg <alex.schuilenburg@gmail.com> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
2023-01-15nds32: drop it, together with aice adapter driverAntonio Borneo3-62/+0
The target nds32 and its companion adapter aice have not received any real improvement since 2013. It has been hard to keep them aligned during the evolution of OpenOCD code, with no way for maintainers to really check if they are still working. No real documentation is present for them in OpenOCD. The nds32 code triggers ~50 errors/warnings with scan-build. The arch nds32 has been dropped from Linux kernel v5.18-rc1. For all the reasons above, this code has been deprecated with commit 2e5df83de7f2 ("nds32: deprecate it, together with aice adapter driver") and tagged to be dropped before v0.13.0. Let it r.i.p. in OpenOCD git history. While there, drop from checkpatch list the camelcase symbols that where only used in this code. Change-Id: Ide52a217f2228e9da2f1cc5036c48f3536f26952 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7382 Tested-by: jenkins
2022-12-03hwthread: Restore current_threadid in hwthread_update_threadsKoudai Iwahori1-0/+10
When OpenOCD receives a step-execution command from GDB and the target is configured as rtos=hwthread, OpenOCD reconstructs the thread-info. However, OpenOCD does not restore the thread id which is currently selected by GDB. Due to this issue, OpenOCD sends the information of wrong thread to GDB after the step execution. This commit fixes the above issue by adding a code to save/restore the thread id selected by GDB. Signed-off-by: Koudai Iwahori <koudai@google.com> Change-Id: I761a1141c04d48f1290e4f09baa7c7024f86f36a Reviewed-on: https://review.openocd.org/c/openocd/+/7358 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-12-03hwthread: Add register validity check in get_thread_reg_listKoudai Iwahori1-0/+9
When OpenOCD receives 'g' packet (read general registers) from GDB and target is configured as rtos=hwthread, hwthread_get_thread_reg_list is called. However, it does not check if the register valid or not. Due to this issue, OpenOCD returns invalid register values to GDB. This commit adds a validity check to hwthread_get_thread_reg_list. If the register is not valid, it tries to read the register from the target. Signed-off-by: Koudai Iwahori <koudai@google.com> Change-Id: Iad6424b62124271ec411b1dfc044b57dfc460280 Reviewed-on: https://review.openocd.org/c/openocd/+/7357 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-11-22rtos/hwthread: Hide unavailable targets from thread list.Tim Newsome1-2/+4
Change-Id: I53c6e2876d9bab70800a0f080e72a2abe0499120 Signed-off-by: Tim Newsome <tim@sifive.com>
2022-11-15rtos/ThreadX: added check for NULL-named tasksGiulio Fieramosca1-9/+14
Thread name loading was not correctly handled if a ThreadX task has a NULL name. Signed-off-by: Giulio Fieramosca <giulio@glgprograms.it> Change-Id: I03071930182bc2585b61ce5d8c67491710883dd6 Reviewed-on: https://review.openocd.org/c/openocd/+/7328 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-11-11rtos: hwthread: fix clang error core.NullDereferenceAntonio Borneo1-4/+4
Clang spots a potential NULL pointer dereferencing that is instead an incorrect use of an array of pointers: src/rtos/hwthread.c:254:32: warning: Dereference of null pointer [core.NullDereference] (*rtos_reg_list)[j].number = (*reg_list)[i].number; ^~~~~~~~~~~~~~~~~~~~~ The error has not been spotted before because: - this function is not called for the first core of the SMP node, - for the other cores on Cortex-A it still returns valid register value for the first 12 ARM registers, then it diverges. Also Valgrind does not spot any issue at runtime. Address the array correctly. While there, use DIV_ROUND_UP() macro for the computation. Change-Id: Ib87e60e0edfd9671091f5dcfa9aedaf1aed800d1 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7337 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2022-11-11Revert "Remove duplicate of a counter in hwthread_update_threads"Tomas Vanek1-3/+7
Commit 0cedf10f8fd6 ("Remove duplicate of a counter in hwthread_update_threads") introduced a code bug. In the second foreach_smp_target() loop, variable "threads_found" gets passed to routine hwthread_fill_thread(). By removing the counting of threads_found from the second loop, the incorrect thread counter value gets passed to hwthread_fill_thread(). Change-Id: Ie89e53ccd28bb72b6838ef2f12106a1fe8d00994 Suggested-by: Daniel Goehring <dgoehrin@os.amperecomputing.com> Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: https://review.openocd.org/c/openocd/+/7307 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-11-10Improve a couple of user/debug messages. (#763)Tim Newsome1-1/+1
* gdb_server: Improve info message. Add target name and state to "Not running when halt was requested" message. Change-Id: Ic84e9a884b57caa270cfee0ca6fa6a0dd8e5d2bd Signed-off-by: Tim Newsome <tim@sifive.com> * rtos/hwthread: Nicer debug message in hwthread_update_threads() Change-Id: Ia5931a772476a2ae186ed87cd70d7e4be2f196fb Signed-off-by: Tim Newsome <tim@sifive.com> Signed-off-by: Tim Newsome <tim@sifive.com>
2022-11-04ThreadX: set current_thread for kernel executionBen McMorran1-0/+6
If we just invented thread 1 to represent the current execution, we need to make sure the RTOS object also claims it's the current thread so that threadx_get_thread_reg_list() doesn't attempt to read a thread control block at 0x00000001. Signed-off-by: Ben McMorran <bemcmorr@microsoft.com> Change-Id: I7f71e730d047858898297e4cb31db8e47e0c371c Reviewed-on: https://review.openocd.org/c/openocd/+/7280 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-10-08Remove duplicate of a counter in hwthread_update_threadsEvgeniy Naydanov1-7/+3
There is no need to count number of examined threads twice. Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com> Change-Id: Id32ead853d1ddcd4e67062d6f795700feb20cb4b Reviewed-on: https://review.openocd.org/c/openocd/+/7223 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2022-09-29Use LOG_TARGET_FOO() functions in more places. (#731)Tim Newsome1-4/+3
Change-Id: Id2266dbfb6209bf0676f28e7383a12705ce2a70e Signed-off-by: Tim Newsome <tim@sifive.com> Signed-off-by: Tim Newsome <tim@sifive.com>
2022-09-18openocd: fix SPDX tag format for files .cAntonio Borneo21-21/+21
With the old checkpatch we cannot use the correct format for the SPDX tags in the file .c, in fact the C99 comments are not allowed and we had to use the block comment. With the new checkpatch, let's switch to the correct SPDX format. Change created automatically through the command: sed -i \ 's,^/\* *\(SPDX-License-Identifier: .*[^ ]\) *\*/$,// \1,' \ $(find src/ contrib/ -name \*.c) Change-Id: I6da16506baa7af718947562505dd49606d124171 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7153 Tested-by: jenkins
2022-09-17rtos: Support looking up .lto_priv.0 appended to symbol nameTim Nordell1-8/+47
When FreeRTOS (at least) is compiled with -flto, this leaves certain static symbols with .lto_priv.0 appended to their name. Arguably this could be considered to be a gdb or gcc bug, but one place to resolve it for OpenOCD usage is here at symbol lookup time. Note that the ".0" is for the first such instance of the variable as a static; additional ones would end up as ".1", ".2", etc, and are not considered here. Signed-off-by: Tim Nordell <tnordell@airgain.com> Change-Id: I03580b45e8ea364392ef4e05c96276416b390cb0 Reviewed-on: https://review.openocd.org/c/openocd/+/7179 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-09-17rtos: Fold is_symbol_mandatory into rtos_qsymbol(..)Tim Nordell1-20/+15
This is in preparation for a future commit that looks for an optional suffix of .lto_priv.0 on the symbol name. Signed-off-by: Tim Nordell <tnordell@airgain.com> Change-Id: If803332373825b73bc986bd4ea7dfaee9c625c0a Reviewed-on: https://review.openocd.org/c/openocd/+/7178 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-09-17rtos: Create a new helper function find_symbol(...)Tim Nordell1-13/+18
This will be utilized for an upcoming refactorization to support -flto compiled programs. Signed-off-by: Tim Nordell <tnordell@airgain.com> Change-Id: Id523c0b3ac2dad8b248ea0d2cac7b4dd2f83d293 Reviewed-on: https://review.openocd.org/c/openocd/+/7177 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-09-13FreeRTOS: Fix thread reg list for Cortex-M7Frank Dischner1-1/+2
This updates the FreeRTOS module to use the M4F FPU stacking also for the FPV5_SP and FPV5_DP FPUs, which are found on the Cortex-M7. The FPUs are in fact different than the FPV4_SP found on the M4, but the register stacking is the same. Signed-off-by: Frank Dischner <frank.dischner@gmail.com> Change-Id: I74c45d2cfb55f55e6c557f2450068ad3c2fe9497 Reviewed-on: https://review.openocd.org/c/openocd/+/6939 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-09-13openocd: remove CamelCase symbols *xPSR*Antonio Borneo9-14/+14
We have left the camelcase symbols *xPSR* for some time, to avoid any conflict with possibly pending patches in gerrit. With the approaching v0.12.0-rc1, it's time to revisit it. The patches in gerrit that conflict with this rename are all not merge-able due to conflicts or due to negative review. Drop these CamelCase symbols. Change-Id: Ifbac4c1df9cc55994e024971a2aaebeed2ea4ed3 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7155 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2022-09-02Remove rtos.gdb_v_packet. (#722)Tim Newsome2-2/+0
It was a left-over from `-rtos riscv` and isn't used. Change-Id: Ie7e380600cd1331c6d382f654474270efad9f127 Signed-off-by: Tim Newsome <tim@sifive.com> Signed-off-by: Tim Newsome <tim@sifive.com>
2022-08-15rtos: Support for "none" rtosAsier Llano1-1/+4
After a certain RTOS has been configured there is no mechanism to go back to no RTOS support. It may be useful for debugging purposes. With the provided modification, the "none" option of RTOS is provided as a valid option. It has been tested in two different board (Cortex M4 and Cortex M33). Documentation has also been updated. Signed-off-by: Asier Llano <allano@hubbell.com> Change-Id: I602210bff31ccadd41c41e9454c52b5fffa1671e Reviewed-on: https://review.openocd.org/c/openocd/+/7092 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-08-08FreeRTOS: Always show current execution before scheduler is startedFrank Dischner1-1/+16
Previously, if the target was halted before the FreeRTOS scheduler was started but after at least one thread was created, then the current thread would be set to whichever thread had the highest priority. In addition to being misleading, because that thread is not actually running, it can cause issues with gdb. For instance, breaking somewhere before the first thread is created will show the current execution as the current thread, but stepping over a line that creates a thread will cause the current thread to switch to the newly created thread and the current execution to disappear. The sudden disappearance of the current execution thread seems to confuse some versions of gdb. With this change, the value of xSchedulerRunning is checked to determine whether the scheduler has been started. If it hasn't, then a fake 'current execution' thread is always created and made the current thread. Signed-off-by: Frank Dischner <frank.dischner@gmail.com> Change-Id: Ide0fe7d9ffb9fac95cee4c805735f434c7c4934d Reviewed-on: https://review.openocd.org/c/openocd/+/6935 Tested-by: jenkins Reviewed-by: Asier Llano <asierllano@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2022-08-08FreeRTOS: Fix current thread ID when no threads are activeFrank Dischner1-1/+2
When there are no rtos threads or none are active, a fake thread with ID 1 is created for the current execution, but the current thread ID was never set to this new fake ID. This would lead to an incorrect attempt to read stacked registers for this fake thread. Explicitly setting the current thread ID to the fake ID ensures that the registers are read from the core instead of calling freertos_get_thread_reg_list. Signed-off-by: Frank Dischner <frank.dischner@gmail.com> Change-Id: I694509a0e01df089429b20ff1b879fc0592b532d Reviewed-on: https://review.openocd.org/c/openocd/+/6934 Tested-by: jenkins Reviewed-by: Asier Llano <asierllano@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2022-07-23openocd: src/rtos: replace the GPL-2.0-or-later license tagAntonio Borneo28-370/+53
Replace the FSF boilerplate with the SPDX tag. The SPDX tag on files *.c is incorrect, as it should use the C99 single line comment using '//'. But current checkpatch doesn't allow C99 comments, so keep using standard C comments, by now. Change-Id: If0194089baded7f58dc5d87a35d6e0aff9f43785 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7070 Tested-by: jenkins
2022-07-23openocd: src: fix incorrect SPDX tagsAntonio Borneo2-4/+4
The SPDX tag is aimed at machine handling and it's thus expected to be placed in the first line in specific format. Move the SPDX tag to the first line and fix it where needed. The SPDX tag on files *.c is incorrect, as it should use the C99 single line comment using '//'. But current checkpatch doesn't allow C99 comments, so keep using standard C comments, by now. Change-Id: Ie9a05f530009d482a4116eebd147fd7e1ee3d41e Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7066 Tested-by: jenkins
2022-07-23openocd: src: add GPL license tag on files that miss itAntonio Borneo1-0/+2
Some file miss completely the license tag. Add the SPDX tag, using the same GPL-2.0-or-later license of the OpenOCD project. The SPDX tag on files *.c is incorrect, as it should use the C99 single line comment using '//'. But current checkpatch doesn't allow C99 comments, so keep using standard C comments, by now. Change-Id: I1fb51e722232d14f050458a820c3041de3dc9138 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7058 Tested-by: jenkins
2022-07-23openocd: build: add SPDX tagAntonio Borneo1-0/+2
Add the SPDX tag to makefiles, configuration scripts and tcl files present in the folders under src/ Change-Id: I1e4552aafe46ef4893d510da9d732c5f181784a4 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7051 Tested-by: jenkins
2022-05-03Merge branch 'master' into from_upstreamTim Newsome1-3/+3
Conflicts: tcl/target/gd32vf103.cfg I kept our version, except I changed the flash device as happened in mainline. Once this file settles down in mainline, we can copy it wholesale into this fork. Change-Id: I4c5b21fec0734b5e08eba392883e006a46386b1c
2022-04-23rtos: zephyr: do not use deprecated symbols nameJulien Massot1-3/+3
Zephyr plan to remove openocd specific symbols in favour of more generic one. These generic symbols has been introduced in Zephyr 2.6. Signed-off-by: Julien Massot <julien.massot@iot.bzh> Change-Id: I89418c9c378fb8b8baa29763fc6f1b6e652dc7ef Reviewed-on: https://review.openocd.org/c/openocd/+/6844 Tested-by: jenkins Reviewed-by: Stephanos Ioannidis <root@stephanos.io> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-04-11Merge branch 'master' into from_upstreamTim Newsome1-1/+5
Conflicts: src/server/server.c src/target/breakpoints.c src/target/semihosting_common.c src/target/target.c Change-Id: I48bd3608c688c69d8aac0667fc46e2de5466a9f1
2022-03-26helper/bits: add BIT_ULL and GENMASK macrosAntonio Borneo1-1/+1
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 Borneo1-0/+4
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-03From upstream (#684)Tim Newsome4-15/+23
* flash/nor/atsame5: add LAN9255 devices Support Microchip LAN9255 devices with embedded SAME53J MCU. Signed-off-by: Hans-Erik Floryd <hans-erik.floryd@rt-labs.com> Change-Id: Ia811c593bf7cf73e588d32873c68eb67c6fafad7 Reviewed-on: https://review.openocd.org/c/openocd/+/6811 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz> * tcl/board: Add EVB-LAN9255 config Config for EVB-LAN9255, tested using Atmel-ICE debugger on J10 connector. Signed-off-by: Hans-Erik Floryd <hans-erik.floryd@rt-labs.com> Change-Id: I8bcf779e9363499a98aa0b7d10819c53da6a19e7 Reviewed-on: https://review.openocd.org/c/openocd/+/6812 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> * aarch64: support for aarch32 ARM_MODE_UND 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> * Combine register lists of smp targets. 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> * semihosting: use open mode flags from GDB, not from sys/stat.h 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> * semihosting: User defined operation, Tcl command exec on host 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> * target/smp: use a struct list_head to hold the smp targets 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 * helper/list: add list_for_each_entry_direction() 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 * target/riscv: revive 'riscv resume_order' 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 * doxygen: fix some function prototype description Change-Id: I49311a643ea73143839d2f6bde976cfd76f8c67f Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6830 Tested-by: jenkins * Cadence virtual debug interface (vdebug) integration 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> * gdb_server: Include thread name as XML attribute 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> * Fix small memory leak. 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> * server: remove remaining crust from dropped eCos code 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> * rtos: threadx: Add hla_target support for ThreadX 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> * .gitmodules: switch away from repo.or.cz The host repo.or.cz is often offline, creating issues for cloning and building OpenOCD from scratch. Already 'jimtcl' developer has dropped repo.or.cz, triggering the OpenOCD commit 861e75f54efb ("jimtcl: switch to github"). Change also the link of the remaining submodules 'git2cl' and 'libjaylink' to their respective main repository. Change-Id: Ib513237427635359ce36a480a8f2060e2fb12ba4 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6834 Tested-by: jenkins Reviewed-by: zapb <dev@zapb.de> * flash/nor/stm32f2x: Fix erase of bank 2 sectors 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> * target/cortex_m: fix target_to_cm() helper 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> * target/armv7m,cortex_m: introduce checked arch_info cast routines 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> * target/cortex_m: add Cortex-M part number getter 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> * flash/nor/stm32xx: fix segfault accessing Cortex-M part number 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> * cpld: altera-epm240: Add additional IDCODEs This adds some additional IDCODEs from the datasheet. It also adds support for customizing the tap name. Signed-off-by: Sean Anderson <sean.anderson@seco.com> Change-Id: I7cda10b92c229b61836c12cd9ca410de358ede2e Reviewed-on: https://review.openocd.org/c/openocd/+/6846 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> * cpld: altera-epm240: Increase adapter speed According to the datasheet, the minimum clock period with Vccio1 = 1.5V (the lowest voltage supported) is 143ns, or around 6MHz. Set the default adapter speed to 5 MHz. Signed-off-by: Sean Anderson <sean.anderson@seco.com> Change-Id: I21cad33fa7f1e25e81f43b5d2214d1fa4ec924de Reviewed-on: https://review.openocd.org/c/openocd/+/6847 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> * target: Add support for ls1088a The LS1088A is an octo-core aarch64 processor from NXP in the layerscape family. The JTAG is undocumented, but I was able to figure things out from the output of `dap info`. This is the first in-tree example of using the hwthread rtos (as far as I know), so hopefully it can serve as an example to other developers. There are some ETMs, but I was unable to try them out because I got 'invalid command name "etm"' when trying to test things out. Signed-off-by: Sean Anderson <sean.anderson@seco.com> Change-Id: I9b0791d27d8c41170a413a8d86431107a85feba2 Reviewed-on: https://review.openocd.org/c/openocd/+/6848 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> * target: ls1088a: Add service processor Normally the service processor is not necessary for debugging. However, if you are using the hard-coded RCW or your boot source is otherwise corrupt, then the general purpose processors will never be released from hold-off. This will cause GDB to become confused if it tries to attach, since they will appear to be running arm32 processors. To deal with this, we can release the CPUs manually with the BRRL register. This register cannot be written to from the axi target, so we need to do it from the service processor target. This involves halting the service processor, modifying the register, and then resuming it again. We try and determine what state the service processor was in to avoid resuming it if it was already halted. The reset vector for the general purpose processors is determined by the boot logation pointer registers in the device configuration unit. Normally these are set using pre-boot initialization commands, but if they are not set then they default to 0. This will cause the CPU to almost immediately hit an illegal instruction. This is fine because we will almost certainly want to attach to the processor and load a program anyway. I considered adding this as an event handler for either gdb-attach or reset-init. However, this command shouldn't be necessary most of the time, and so I don't think we should run it automatically. Signed-off-by: Sean Anderson <sean.anderson@seco.com> Change-Id: I1b725292d8a11274d03af5313dc83678e10e944c Reviewed-on: https://review.openocd.org/c/openocd/+/6850 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> * board: Add NXP LS1088ARDB This adds a board file for the NXP LS1088ARDB. This only covers the "primary" JTAG header J55, and not the PCIe header (J91). The only oddity is that the LS1088A and CPLD are muxed by adding/removing a jumper from J48. Unfortunately, it doesn't look like OpenOCD supports this CPLD beyond determining the irlen, so it's not very useful. Those who are interested in experimenting can define CWTAP to access the CPLD, but the default is to access the CPU. Signed-off-by: Sean Anderson <sean.anderson@seco.com> Change-Id: Ia07436a534f86bd907aa5fe2a78a326a27855a24 Reviewed-on: https://review.openocd.org/c/openocd/+/6849 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> * gdb_server: fix double free 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> * gdb_server: check target examined while combining reg list 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> * flash/stm32l4x: fix maybe-uninitialized compiler error 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> * Fix build. Change-Id: Ia60246246dd859d75659a43d1c59588dbb274d46 Signed-off-by: Tim Newsome <tim@sifive.com> Co-authored-by: Hans-Erik Floryd <hans-erik.floryd@rt-labs.com> Co-authored-by: Julien Massot <julien.massot@iot.bzh> Co-authored-by: Pavel Kirienko <pavel.kirienko@gmail.com> Co-authored-by: Zoltán Dudás <zedudi@gmail.com> Co-authored-by: Antonio Borneo <borneo.antonio@gmail.com> Co-authored-by: Jacek Wuwer <jacekmw8@gmail.com> Co-authored-by: Ben McMorran <bemcmorr@microsoft.com> Co-authored-by: Simon Johansson <ampleyfly@gmail.com> Co-authored-by: Tomas Vanek <vanekt@fbl.cz> Co-authored-by: Sean Anderson <sean.anderson@seco.com> Co-authored-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-14target/smp: use a struct list_head to hold the smp targetsAntonio Borneo2-14/+10
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-07fix missing thread ID in stop reply when smp-configured hart (but not hart ↵Greg Savin2-2/+23
0) single-stepped (#675)
2022-01-31Ask the RTOS which target to set swbp on. (#673)Tim Newsome3-0/+26
This lets the RTOS pick the "current" target, which matters if address translation differs between threads. Change-Id: I5b5510ab6a06621589c902f42a91562055817dc4 Signed-off-by: Tim Newsome <tim@sifive.com>
2021-11-30Merge branch 'master' into from_upstreamTim Newsome1-2/+2
Merged 1ad6ed38b6da09b1d5d9e56d1344fced2dce12bc Conflicts: src/rtos/rtos_standard_stackings.c Change-Id: Ica8109135de0f9aa87455353a4538b161b844b04
2021-11-05rtos: use struct member names instead of commentsTim Newsome9-90/+82
This is more readable, and as a bonus the compiler will help out if the definition of the struct changes. Change-Id: Ibf660134d9900173f6592407d5cc2203654a4a1b Signed-off-by: Tim Newsome <tim@sifive.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6659 Tested-by: jenkins Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2021-10-06Fix incorrectly resolved conflict.Tim Newsome1-5/+7
Change-Id: I8dde5f2fc1dbc7b4de6091a934cbe160baadb504 Signed-off-by: Tim Newsome <tim@sifive.com>