aboutsummaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)AuthorFilesLines
2023-07-08pld: give devices a name for referencing in scriptsDaniel Anselmi9-189/+234
Change-Id: I05e8596ffacdb6cd8da4dd8a40bb460183f4930a Signed-off-by: Daniel Anselmi <danselmi@gmx.ch> Reviewed-on: https://review.openocd.org/c/openocd/+/7728 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2023-07-01semihosting: fix handling of errnoMarek Vrbka1-32/+47
This patch fixes the handling of errno by setting the sys_errn only if error has actually occurred during the semihosting call. It also fixes few issues where error was not set in the first place. Change-Id: I2fbe562f3ec5e6220b800de04cd33aa1f409c7a0 Signed-off-by: Marek Vrbka <marek.vrbka@codasip.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7730 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Jan Matyas <jan.matyas@codasip.com>
2023-07-01semihosting: improve semihosting opcode debug messagesMarek Vrbka2-4/+75
This patch introduces function semihosting_opcode_to_str() which converts semihosting opcodes to strings. This function is then used in debug messages to improve log analysis and troubleshooting. Change-Id: Iffea49dae13d6a626ae0db40d379cba3c9ea5bd3 Signed-off-by: Marek Vrbka <marek.vrbka@codasip.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7726 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Jan Matyas <jan.matyas@codasip.com>
2023-06-16riscv/semihosting: Fix ebreak skip on fileio modeMarek Vrbka1-5/+5
This patch fixes skipping the semihosting sequence if the fileio mode is enabled on riscv. This change was tested by me and is in the riscv-openocd fork for a year now. Original merge request: https://github.com/riscv/riscv-openocd/pull/699 Original author: Wu Zhigang zhigang.wu@starfivetech.com https://github.com/wzgpeter Change-Id: Iadaa0a48d1f82d3a7ca168f8a6b656ff6ab78e03 Signed-off-by: Marek Vrbka <marek.vrbka@codasip.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7729 Tested-by: jenkins Reviewed-by: Tim Newsome <tim@sifive.com>
2023-06-10jep106: update to revision JEP106BG May 2023Antonio Borneo1-3/+58
The original document from Jedec does not report the entry for "21 NXP (Philips)", replaced by "c". It's clearly a typo. Keep the line from JEP106BF.01 for "NXP (Philips)". Change-Id: I30215c4ff08d5f112305cde6ab7a3176cdcef948 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7727 Tested-by: jenkins
2023-06-10semihosting: fix non-zero value on Windows isatty()Marek Vrbka1-1/+2
On Windows, isatty() can return any non-zero value if it's an interactive device. Which diverges from the ARM semihosting specification. This patch introduces a fix to make the SYS_ISTTY operation conform to spec. Change-Id: I9bc4f3cb82370812825d52419851910b3e3f35cc Signed-off-by: Marek Vrbka <marek.vrbka@codasip.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7725 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins Reviewed-by: Jan Matyas <jan.matyas@codasip.com>
2023-06-10gdb_server: refactor and unify function gdb_get_char_innerMarek Vrbka1-31/+12
The old implementation of gdb socket error handling in the gdb_get_char_inner() differs between Windows and *nix platforms. This patch simplifies it by using an existing function log_socket_error() which handles most of the platform specific things. It also provides better error messages. Change-Id: Iec871c4965b116dc7cfb03c3565bab66c8b41958 Signed-off-by: Marek Vrbka <marek.vrbka@codasip.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7724 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2023-06-10gdb_server: add debug signal reason printsMarek Vrbka3-2/+35
Added debug prints to show what is the target debug reason. Also added debug print for Ctrl-C response. This is useful for troubleshooting and log analysis. Change-Id: I055936257d989efe7255656198a8d73a367fcd15 Signed-off-by: Marek Vrbka <marek.vrbka@codasip.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7720 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
2023-06-10flash/nor: add support for NXP QN908xiosabi4-0/+1200
This patch adds support for the NXP QN908x family of Bluetooth microcontrollers, such as the QN9080. This chip features a Cortex-M4F with 512 KiB of flash on all the available versions, although the documentation suggests that there might be 256 kB versions as well. The initial support allows to read, erase and write the whole user flash area. Three new sub-commands under the new "qn908x" command are added in this patch as well: disable_wdog to disabled the watchdog, mass_erase to perform a mass erase and allow_brick to allow programming images that disable the SWD interface. Disabling the watchdog is required after a "reset halt" in order to run the CRC algorithm from RAM when verifying the chip. However, this is not done automatically on probing or other initialization since disabling the watchdog might interfere with debugging real applications. The "mass_erase" command allows to erase the whole flash without probing it, since in some scenarios the chip can be locked such that no flash or ram can be accessed from the SWD interface, allowing only to run a mass_erase to be able to flash the program. The flashing process allows to compute a checksum, similar to the lpc2000 driver "calc_checksum" but done over a different region of the memory. This checksum is required to be present for the QN908x bootloader ROM to boot, and otherwise is useless. As with the lpc2000 design, verification when using "calc_checksum" is expected to fail if the checksum was not valid in the image being verified. This was manually tested on a QN9080, including the scan-view, AddressSanitizer/UBSan and test coverage configurations. Change-Id: Ibd6d8f3608654294795085fcaaffb448b77cc58b Co-developed-by: Marian Buschsieweke <marian.buschsieweke@ovgu.de> Signed-off-by: Marian Buschsieweke <marian.buschsieweke@ovgu.de> Signed-off-by: iosabi <iosabi@protonmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/5584 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2023-06-02jtag/vdebug: using tap_stateJacek Wuwer1-5/+5
This change implements the predefined type tap_state instead of generic uint8_t in the driver Change-Id: I3478e8d7b40b961f3ba77711179016cdcc35cd32 Signed-off-by: Jacek Wuwer <jacekmw8@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7722 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
2023-06-02jtag/vdebug: fix endianness supportJacek Wuwer1-2/+2
This change fixes endianness support in the driver. Change-Id: Ida360bb58e988cea0a66fdc79e1610b528846fc4 Signed-off-by: Jacek Wuwer <jacekmw8@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7721 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2023-06-02target/espressif: fix clang scan-build warningErhan Kurubas1-1/+1
Clang reports that 3rd function call argument is an uninitialized value file esp32_apptrace.c line:1270 Signed-off-by: Erhan Kurubas <erhan.kurubas@espressif.com> Change-Id: I73e254d4eb0c6b3152229717d8827d334784ab92 Reviewed-on: https://review.openocd.org/c/openocd/+/7719 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
2023-06-02flash: jtagspi: fix clang build warningAntonio Borneo1-30/+22
Clang is unable to fully track the content of the array write_buffer[] and incorrectly complains that it could contain some uninitialized value. To help clang to track the execution flow, rewrite the handling of the buffer by using simpler indexing and by moving away cmd_byte from the first buffer's element to the variable cmd_byte. While there: - fix the error codes returned while parsing the command line and - use directly command_print_sameline() instead of passing through intermediate buffers. Change-Id: I1969e896887ea3a4abebee057cc04c03005fa57c Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7718 Tested-by: jenkins
2023-06-02flash: psoc4: fix clang errorAntonio Borneo1-1/+1
Clang 15.0.7 complains about snprintf output truncation due to output between 13 and 22 bytes into a destination of size 20. Increase the size of the buffer. Change-Id: I0369255ca1bc02a0cf494f765e91a608c960a0d6 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7717 Tested-by: jenkins
2023-06-02cortex_m: fix reading of DCB_DSCSR registerBohdan Tymkiv1-5/+2
Value in the 'dscsr' variable is garbage until the DAP queue is run. Postpone evaluation of the 'secure_state' variable. Reading the core registers in between will execute the DAP queue. Change-Id: I44959e882dbafb1b9779e813c3d13f3b3dbcd47f Signed-off-by: Bohdan Tymkiv <bohdan200@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7693 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2023-06-02target: armv8: fix support of pointer authenticationAntonio Borneo1-1/+1
The registers pauth_dmask and pauth_cmask are not accessible in AARCH32 mode. Tagging them as 'hidden' is not enough and triggers error: Failed to read pauth_dmask register while halting the core. Tag the pauth registers as not existing, unless required by user. Note: for non existing registers there should be no need to allocate their register cache. Let's keep this for a further improvement. Change-Id: Iaa0d006a3d8ee611ee93333ed49a8615a6c94276 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Fixes: d0436b0cdabb ("armv8: Add support of pointer authentication") Reviewed-on: https://review.openocd.org/c/openocd/+/7712 Tested-by: jenkins Reviewed-by: Koudai Iwahori <koudai@google.com>
2023-05-27flash/jtagspi: sending command and setting parameters without probing.Daniel Anselmi3-12/+34
Change-Id: I6b9d90265ca5112b9ab2aae97bb4c6cf3ebc4112 Signed-off-by: Daniel Anselmi <danselmi@gmx.ch> Reviewed-on: https://review.openocd.org/c/openocd/+/7432 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
2023-05-27target/xtensa: add file-IO supportIan Thompson5-3/+247
- Manual integration of File-IO support from xt0.2 release - Verified with applications linked using gdbio LSP - No new clang static analysis warnings Signed-off-by: Ian Thompson <ianst@cadence.com> Change-Id: Iedc5f885b2548097ef4f11ae1a675b5944f5fdf0 Reviewed-on: https://review.openocd.org/c/openocd/+/7550 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2023-05-27jtag/adapter: Removed unused include of strings.hJan Matyas1-4/+0
Removed an unused include from src/jtag/adapter.c. Signed-off-by: Jan Matyas <jan.matyas@codasip.com> Change-Id: Ia5ea0acdfa1c011d7c88decd0f63e8032aafd699 Reviewed-on: https://review.openocd.org/c/openocd/+/7687 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2023-05-27jtag: rewrite jim_jtag_tap_enabler() as COMMAND_HANDLERAntonio Borneo4-37/+44
The function is used for commands: - jtag tapisenabled - jtag tapenable - jtag tapdisable While there, add the missing .help and .usage fields and fix the incorrect check in jtag_tap_enable() and jtag_tap_disable(). Change-Id: I0e1c9f0b8d9fbad19d09610a97498bec8003c27e Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7554 Tested-by: jenkins
2023-05-27jtag: rewrite commands 'jtag newtap' and 'swd newdap' as COMMAND_HANDLERAntonio Borneo5-190/+175
While there: - fix memory leak in case of error on values tap->chip, tap->tapname, tap->expected_ids; - check for out of memory error; - fix minor coding style issue; - add the missing .usage field; - remove functions not in use anymore. Change-Id: I1c8c3ffeb324e9eacb919c7e0d94fd72122c9a81 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7431 Tested-by: jenkins
2023-05-27target: use unsigned int for timeout_msAntonio Borneo16-38/+38
Change the prototype of functions: - target_run_algorithm() - target_wait_algorithm() - target_wait_state() - struct target_type::run_algorithm() - struct target_type::wait_algorithm() to use unsigned int for timeout_ms instead of int. Change accordingly the variables passed as parameter. Change-Id: I0b8d6e691bb3c749eeb2911dc5a86c38cc0cb65d Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7562 Tested-by: jenkins
2023-05-27target: rewrite command 'arp_waitstate' as COMMAND_HANDLERAntonio Borneo1-42/+27
While there, add the missing .usage field and remove the now unused function jim_target_tap_disabled(). Change-Id: I79afcc5097643fc264354c6c3957786a55f40498 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7561 Tested-by: jenkins
2023-05-27target: rewrite command 'arp_examine' as COMMAND_HANDLERAntonio Borneo1-27/+18
Change-Id: I8f227b219ca39f198e1e39847ddd36bb9880a328 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7560 Tested-by: jenkins
2023-05-27target: espressif: apptrace: declare a local function as staticAntonio Borneo1-1/+1
The function esp32_cmd_apptrace_generic() is not used outside the file. Declare it as static. Detected through 'sparse' tool. Change-Id: I08c6b92fb01594320bc3ae6b16067ac4eb51ca12 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7676 Tested-by: jenkins
2023-05-27target/espressif: add system level tracing featureErhan Kurubas5-17/+954
Produces traces compatible with SEGGER SystemView tool. Signed-off-by: Erhan Kurubas <erhan.kurubas@espressif.com> Change-Id: If1057309edbb91ed2cf1ebf9137c378d3deb9b88 Reviewed-on: https://review.openocd.org/c/openocd/+/7606 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2023-05-27Revert "target/image: zero-initialize ELF segments up to p_memsz"Antonio Borneo1-34/+20
This reverts commit 047b1a8fc237af480e3bab66a9827a358afd7547. Commit 047b1a8fc237 ("target/image: zero-initialize ELF segments up to p_memsz") breaks the backward compatibility introducing some problem: - an empty bss segment with paddr in SRAM gets zero filled at load but does not survive after a reset, causing verify to fail; - an empty bss segment with paddr in FLASH causes excessive flash usage, which can exceed flash size (causing error) and makes flash aging faster. Revert it while looking for a better implementation. Change-Id: Iaaf926dafce46a220a5bbe20c8576eb449996d76 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reported-by: Marian Buschsieweke <marian.buschsieweke@ovgu.de> Reviewed-on: https://review.openocd.org/c/openocd/+/7658 Reviewed-by: Bohdan Tymkiv <bohdan200@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-by: Nemui Trinomius <nemuisan_kawausogasuki@live.jp> Reviewed-by: Peter Collingbourne <pcc@google.com> Tested-by: jenkins
2023-05-25flash/nor/stm32f2x: Show error message when unprotecting OTPMatthijs Kooijman1-1/+3
Trying to disable OTP write protection by running e.g. `flash protect 1 0 1 off` would already be rejected with an error code, but that would result in a generic "failed setting protection for blocks 0 to 1" message. Now a more specific error message is also printed, telling the user why it failed. Change-Id: I6d4974eb0bcd23a0a6cf68ff955d9e59b8b1b06a Signed-off-by: Matthijs Kooijman <matthijs@stdin.nl> Reviewed-on: https://review.openocd.org/c/openocd/+/7615 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2023-05-25flash/nor/stm32f2x: Fix typos in log messagesMatthijs Kooijman1-2/+2
Change-Id: I0f27e1c64972a58ac146c391761008cdca610afe Signed-off-by: Matthijs Kooijman <matthijs@stdin.nl> Reviewed-on: https://review.openocd.org/c/openocd/+/7614 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
2023-05-25target/riscv-013: clear sticky error when DMI operation failsAmaury Pouly1-0/+2
When a DMI operation does not succeed (either because of a timeout or an error), the specification says that the error in the `op` field is sticky and needs to cleared by writing `dmireset` in `dtmcs`. This is already done for timeouts in increase_dmi_busy_delay but not for errors. Change-Id: I7c5f27a5cf145511a1a8b64a45a586521e1cbe41 Signed-off-by: Amaury Pouly <amaury.pouly@lowrisc.org> Reviewed-on: https://review.openocd.org/c/openocd/+/7688 Tested-by: jenkins Reviewed-by: Tim Newsome <tim@sifive.com> Reviewed-by: Jan Matyas <jan.matyas@codasip.com>
2023-05-24flash/stm32l4x: support STM32C0x devicesTarek BOCHKATI2-1/+44
this new STM32 series family introduces 2 devices: STM32C011xx (0x443) and STM32C031xx (0x453) both devices have 32 Kbytes single flash bank. Change-Id: I4e890789e44e3b174c0e9c0e1068383ecdbb865f Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6874 Reviewed-by: Nemui Trinomius <nemuisan_kawausogasuki@live.jp> Tested-by: jenkins Reviewed-by: zapb <dev@zapb.de> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2023-05-24jtag/drivers/bcm2835gpio: add peripheral_mem_dev config commandTomas Vanek1-8/+37
The bcm2835gpio driver preferred /dev/gpiomem for access to memory mapped GPIO control and used /dev/mem as a fallback only if it couldn't open /dev/gpiomem. /dev/mem usually requires elevated rights or specific capabilities of the opening process, so the fallback failed anyway. Although /dev/gpiomem is the strongly preferred option with respect to security, there could be also use cases which require /dev/mem even if /dev/gpiomem is available (e.g. changing the GPIO pad settings is necessary or testing/debugging OpenOCD). It was difficult to handle such cases because they required to block globally the system device /dev/gpiomem (remove, rename or chmod). Drop the fallback feature and select the memory device by 'bcm2835gpio peripheral_mem_dev' configuration command. Use /dev/gpiomem as a default. Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Change-Id: I60e427bda795d7a13d55d61443590dd31d694832 Reviewed-on: https://review.openocd.org/c/openocd/+/7350 Tested-by: jenkins Reviewed-by: Jonathan Bell <jonathan@raspberrypi.com>
2023-05-24jtag/drivers/bcm2835gpio: extend peripheral_base to off_tTomas Vanek1-6/+10
Raspberry Pi 4 with 64-bit kernel and arm_peri_high=1 config.txt parameter needs peripheral_base 0x47e000000, uint32_t is not enough. Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Change-Id: Icedd084e2916657fa4478d452a5eb1e84a45c281 Reviewed-on: https://review.openocd.org/c/openocd/+/7685 Tested-by: jenkins Reviewed-by: Jonathan Bell <jonathan@raspberrypi.com> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2023-05-24jtag/drivers/bcm2835gpio: don't touch pad setting on /dev/gpiomemTomas Vanek1-11/+23
The pads were configured at a wrong memory address if /dev/gpiomem was mapped. The pad setting registers are not accessible in mapped /dev/gpiomem, disable the pads setting if the driver doesn't open /dev/mem. While on it, do not fail the driver initialization if pad mapping fails - just emit a warning and work with unchanged pad setting. Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Change-Id: I0bce76cade8f7efd75efd9087a7d9ba6511a6239 Reviewed-on: https://review.openocd.org/c/openocd/+/7684 Tested-by: jenkins Reviewed-by: Jonathan Bell <jonathan@raspberrypi.com> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2023-05-18flash/jtagspi: handle error return values where neededDaniel Anselmi1-2/+2
Change-Id: Id46c2799f954fb1d4353f652ba3115796c88936d Signed-off-by: Daniel Anselmi <danselmi@gmx.ch> Reviewed-on: https://review.openocd.org/c/openocd/+/7422 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
2023-05-18pld/virtex2: check error propagated by virtex2_read_stat()Antonio Borneo1-2/+6
Commit dd9137dc0e0c ("pld/virtex2: add missing error checks") adds checks on the return value of several functions, allowing also virtex2_read_stat() to propagate such returned values. This triggers an error with clang, as it is now able to identify a possible execution path that makes uninitialized the variable status. Check for the returned value of virtex2_read_stat() before using the variable status and propagate the returned value. While there, drop a useless empty string. Change-Id: I7a23d3f904d4e07cdb6f6dfdf1179889b6b8afb8 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7657 Reviewed-by: Daniel Anselmi <danselmi@gmx.ch> Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2023-05-18rtos: uCOS-III: split struct ucos_iii_paramsAntonio Borneo1-47/+35
The static analyser 'sparse' complains about using sizeof() on a struct that has variable size: src/rtos/uCOS-III.c:267:32: warning: using sizeof on a flexible structure src/rtos/uCOS-III.c:269:41: warning: using sizeof on a flexible structure src/rtos/uCOS-III.c:275:66: warning: using sizeof on a flexible structure The struct ucos_iii_params contains either constants values for different target type and variable fields. The last field is an variable size array, always allocated to UCOS_III_MAX_THREADS items. It's not practical to fix this size because we would get too huge initialization in data segment. Split away from struct ucos_iii_params all the variable fields and put them in struct ucos_iii_private. Add in the new struct a pointer to the selected element of ucos_iii_params_list[] and fix the size of array threads[] to its maximum value; this would be allocated at run-time, avoiding impacts to data segment. Change-Id: I569011a257783d35a8795adbda06e942b4157f2a Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7678 Tested-by: jenkins
2023-05-18rtos: move prototype of rtos_thread_packet() in rtos.hAntonio Borneo4-7/+1
The function rtos_thread_packet() is used across rtos and declared locally as extern. Move the prototype of the function in common include rtos.h Change-Id: I50d311b583148a2de628de0997ef1afc9103a70e Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7677 Tested-by: jenkins
2023-05-18target: arm_adi_v5: move in include file the declaration of dap_opsAntonio Borneo2-2/+3
The struct containing SWD and JTAG operations are declared as extern in the C file. Mode them in include file arm_adi_v5.h to silent 'sparse' error for global variable definition without declaration in an include file. Change-Id: I59088512c052d5a120c38404a882ed512a68ca02 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7675 Tested-by: jenkins
2023-05-18flash: nand: move in include file the declaration of 'nand_devices'Antonio Borneo2-3/+1
The pointer nand_devices is used in two file. Move the extern prototype in code.h Detected through 'sparse' tool. Change-Id: I7237359fd1a008770a624725cd0b3d8632b4166e Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7674 Tested-by: jenkins
2023-05-18server: gdb: export gdb_actual_connections through a functionAntonio Borneo4-12/+17
The internal variable 'gdb_actual_connections' is used by log and by semihosting to determine if there are active GDB connections. Keep the variable local in server's code and only export its value through a dedicated function. This solves the issue detected by 'parse' of the variable defined as global but not declared in any include file. Change-Id: I6e14f4cb1097787404094636f8a2a291340222dd Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7673 Tested-by: jenkins
2023-05-18jtag: move declaration outside functionAntonio Borneo2-5/+3
The function jtag_debug_state_machine_() is only used by a static inline function and declared inside it as private. The static analyser 'sparse' complains that the function is defined as global but not cross checked against a prototype in an include file. Move the declaration outside the inline function so it get visible by interface.c, which already includes interface.h While there, change the argument type from 'unsigned' to 'unsigned int' to pass checkpatch check. Change-Id: Ia5dfb92dc4bc6d52ead4f0cb8c68319c83ff85b0 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7672 Tested-by: jenkins
2023-05-18hello: include hello.hAntonio Borneo1-0/+1
Let source file to include its file .h to validate the exported prototypes. Detected through 'sparse' tool. Change-Id: I6197f21c857833dafc3d6e3b750c764bf4610abd Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7671 Tested-by: jenkins
2023-05-18helper: types: rework h_u32_to_le() and similar for sparseAntonio Borneo1-18/+18
The static analyser 'sparse' complains about values bigger that 255 that gets cast-ed and/or stored in an 8 bit variable. Rework the functions: - h_u32_to_le() - h_u32_to_be() - h_u24_to_le() - h_u24_to_be() - h_u16_to_le() - h_u16_to_be() to avoid all the related warnings, without adding any functional change. Any modern compiler should not be impacted by this. Change-Id: I0b84043600a41c72d0e4ddb3dd195d69e3b2896b Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7670 Tested-by: jenkins
2023-05-18target: arm_dpm: with pointers, use NULL instead of 0Antonio Borneo1-1/+1
Don't assign pointer to 0, use NULL. Detected through 'sparse' tool. Change-Id: I34551112ddab9dedf8537c8111d32356c170e7d5 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7669 Tested-by: jenkins
2023-05-18pld: fix new warnings from sparseAntonio Borneo2-3/+1
The new committed files add some warning from the static analyser 'sparse': - Don't assign pointer to 0, use NULL. - switch with no cases. Fix them. Change-Id: I2c02d629bd80b71c8e42553be5d9388bb9b6bcd0 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7668 Tested-by: jenkins
2023-05-18helper: replacements: rework including replacements.hAntonio Borneo2-8/+11
The static analyser 'sparse' complains that the functions clear_malloc() and fill_malloc() are defined global but not cross checked against a prototype in an include file. Rework replacements.h and replacements.c to let the former be included by the latter. Change-Id: I536393a9c3718dcd7e144cde8f02e169f64c88e0 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7667 Tested-by: jenkins
2023-05-18nand: declare exported function in core.hAntonio Borneo2-2/+2
Don't use 'extern' in a C file, but declare the exported function in a H file. This helps validating the function prototype across declaration and use. Detected through 'sparse' tool. Change-Id: I2c22b084fb513f4b3b1b1db96dfbc8fa4bfe7238 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7666 Tested-by: jenkins
2023-05-18jtag: move in interface.h the adapter_driver's declarationAntonio Borneo2-114/+40
The static analyser 'sparse' complains, while compiling a jtag driver, that the struct adapter_driver is declared in the file as non static, but it is not exposed through an include file. The message is: warning: symbol 'XXX' was not declared. Should it be static? Move the list of adapter_driver's declaration in interface.h Drop the preprocessor #ifdef/#endif around the declaration, as it has no effect when the declaration is not used and/or the symbol does not exist. Change-Id: I5b8f5fe48a89ff0ffce38d547c551cd196379fbf Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7665 Tested-by: jenkins
2023-05-18pld: validate exported functions by including its own .hAntonio Borneo3-0/+3
Let source files to include its file .h to validate the exported prototypes. Detected through 'sparse' tool. Change-Id: I217c2903fdb19e1a2cce39d2536a903c3d72f3f7 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7664 Tested-by: jenkins