openocd.git
2 years agoflash/stm32l4x: fix dual bank support for STM32L552xC devices 38/6538/4
Tarek BOCHKATI [Thu, 2 Sep 2021 11:03:59 +0000 (12:03 +0100)]
flash/stm32l4x: fix dual bank support for STM32L552xC devices

For STM32L552xC devices with 256K flash:
  dual bank mode is activated if DB256 is set
  page size is 2KB if DBANK is set

For parts with 512K (aka STM32L5x2xE):
  DBANK controls both of dual/single bank mode and page size as well.

Change-Id: I8be668d5552fefe81acffaf2e3e35ef5e938162e
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reported-by: Patrik Bachan <diggit@users.sourceforge.net>
Fixes: https://sourceforge.net/p/openocd/tickets/317/
Reviewed-on: https://review.openocd.org/c/openocd/+/6538
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2 years agohelper/command: fix echo return values 49/6549/2
Tarek BOCHKATI [Wed, 11 Aug 2021 00:14:21 +0000 (01:14 +0100)]
helper/command: fix echo return values

the echo command is managed through command handler and not jim_handler
to be consistent rename the handler from jim_echo to handle_echo
and update the return values

Fixes: 4747af362de0 (JIM: document "echo" command)
Change-Id: I5ae87ea802d8430b573fb83daa6b35490b5d5775
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6549
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agojep106.inc: Update to revision JEP106BC 51/6551/4
Florian Zaruba [Tue, 7 Sep 2021 16:22:13 +0000 (18:22 +0200)]
jep106.inc: Update to revision JEP106BC

Signed-off-by: Florian Zaruba <florian@openhwgroup.org>
Change-Id: I566eb331b2884de3df5ad3f02c2ec7961539257b
Reviewed-on: https://review.openocd.org/c/openocd/+/6551
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agostlink: Add PID for V3 device without MSD 55/6555/3
Andreas Sandberg [Wed, 8 Sep 2021 22:09:51 +0000 (23:09 +0100)]
stlink: Add PID for V3 device without MSD

Add the 0x3754 PID used by some STLINK-V3 devices when MSD has been
disabled. This PID has been observed on a Nucleo-G431RB board.

Signed-off-by: Andreas Sandberg <andreas@sandberg.uk>
Change-Id: Idb85874fa5a9dff5940bae7e95426a956693b976
Reviewed-on: https://review.openocd.org/c/openocd/+/6555
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agohla: Increase HLA_MAX_USB_IDS 54/6554/2
Andreas Sandberg [Wed, 8 Sep 2021 22:14:34 +0000 (23:14 +0100)]
hla: Increase HLA_MAX_USB_IDS

We are already at the limit for the number of VID/PID pairs declared
in stlink.cfg and stlink-dap.cfg. Increase the maximum number of pairs
from 8 to 16 to make room for a few more devices.

Signed-off-by: Andreas Sandberg <andreas@sandberg.uk>
Change-Id: Ifad8e7ef67b930edbb5421730f00eb3390812f06
Reviewed-on: https://review.openocd.org/c/openocd/+/6554
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agotarget: do not cast NULL in assignment 40/6540/2
Antonio Borneo [Sat, 4 Sep 2021 21:22:27 +0000 (23:22 +0200)]
target: do not cast NULL in assignment

NULL is defined as 'void *'.
There is no need to cast NULL while assigning it to a pointer.

Change-Id: Ibaf18e5d47329707ec9c1c184cd4bba2e8e702ff
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6540
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Tested-by: jenkins
2 years agoopenocd: remove last NULL comparisons 39/6539/2
Antonio Borneo [Sat, 4 Sep 2021 21:01:09 +0000 (23:01 +0200)]
openocd: remove last NULL comparisons

The NULL pointers preceded by cast where not detected by the
scripting tools looking for NULL pointer comparison.

Remove them and, while there, further simplify the code and apply
the other coding style rules.

Change-Id: Ia7406122e07ef56ef311579ab0ee7ddb22c8e4b5
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6539
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2 years agogerrit url: update the gerrit server address to https://review.openocd.org 81/6481/3
Tarek BOCHKATI [Thu, 26 Aug 2021 09:41:35 +0000 (10:41 +0100)]
gerrit url: update the gerrit server address to https://review.openocd.org

change the gerrit server address from http://openocd.zylin.com to the new
address in order to avoid re-directions.

Change-Id: I76e128c277f63783d1a6f63a6a387aa838f51f80
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6481
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agodoc: add a note to use 'stm32l4x option_load' after changing option bytes 33/6533/2
Tarek BOCHKATI [Thu, 2 Sep 2021 14:56:50 +0000 (15:56 +0100)]
doc: add a note to use 'stm32l4x option_load' after changing option bytes

Change-Id: I502be27da892e393731d11e02203c736e77033d0
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6533
Tested-by: jenkins
Reviewed-by: Karl Palsson <karlp@tweak.net.au>
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2 years agotcl/target/stm32(f7/h7)x: do not assume presence of the reset 06/6506/3
Tarek BOCHKATI [Sun, 29 Aug 2021 21:09:46 +0000 (22:09 +0100)]
tcl/target/stm32(f7/h7)x: do not assume presence of the reset

do not force the presence of the reset line, since some custom boards
may do not contain the reset line.

Change-Id: I031ab34012b34a1b49def9db16461f9de0ae29cc
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reported-by: Fleck <fleckz@users.sourceforge.net>
Fixes: https://sourceforge.net/p/openocd/tickets/316/
Reviewed-on: https://review.openocd.org/c/openocd/+/6506
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
2 years agoflash/stm32l4x: fix flash programming in 64-bit hosts 56/6556/3
Tarek BOCHKATI [Thu, 9 Sep 2021 21:14:36 +0000 (22:14 +0100)]
flash/stm32l4x: fix flash programming in 64-bit hosts

stm32l4_work_area struct is shared between the loader and stm32l4x flash driver

'*wp' and '*rp' pointers' size is 4 bytes each since stm32l4x devices have
32-bit processors.

however when used in openocd code, their size depends on the host
  if the host is 32-bit, then the size is 4 bytes each.
  if the host is 64-bit, then the size is 8 bytes each.

to avoid this size difference, change their types depending on the
usage (pointers for the loader, and 32-bit integers in openocd code).

Change-Id: I0a3df4bb4bf872b01cdb9357eb28307868d7d469
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6556
Tested-by: jenkins
Reviewed-by: Yestin Sun <sunyi0804@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2 years agoIn SMP config, replicate watchpoints on each core 28/6528/4
Tim Newsome [Wed, 1 Sep 2021 21:25:10 +0000 (14:25 -0700)]
In SMP config, replicate watchpoints on each core

This works well with gdb on RISC-V, since hardware breakpoints are
per-core and gdb thinks that targets are really processes on a machine.

Are there targets where this is a bad idea? Should the target definition
specify whether this behavior is desired or not?

Change-Id: Ia32be2707b04347fd8bf2ca6fbb2b0ceaad3704a
Signed-off-by: Tim Newsome <tim@sifive.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6528
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agoflash/stm32l4x: do not use magic number for dual bank option bits 37/6537/3
Tarek BOCHKATI [Sun, 29 Aug 2021 20:48:49 +0000 (21:48 +0100)]
flash/stm32l4x: do not use magic number for dual bank option bits

Change-Id: I27211e7d44b48f65546e31710ec6ae129acb416f
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6537
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2 years agoflash/stm32l4x: introduce is_max_flash_size and use it 36/6536/3
Tarek BOCHKATI [Sun, 29 Aug 2021 19:52:50 +0000 (20:52 +0100)]
flash/stm32l4x: introduce is_max_flash_size and use it

Change-Id: Idb421b9cf737d222baf4dd890032f69dec7a366e
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6536
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2 years agoflash/stm32l4x: fix segmentation fault with HLA adapters and STM32WLx devices 35/6535/3
Tarek BOCHKATI [Sun, 29 Aug 2021 15:33:55 +0000 (16:33 +0100)]
flash/stm32l4x: fix segmentation fault with HLA adapters and STM32WLx devices

CPU2 (Cortex-M0+) is supported only with non-hla adapters because it is on AP1.
Using HLA adapters armv7m.debug_ap is null, and checking ap_num triggers
a segfault.

Change-Id: I501f5b69e629aa8d2836b5194063d74d5bfddb12
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Fixes: https://github.com/STMicroelectronics/OpenOCD/issues/6
Reviewed-on: https://review.openocd.org/c/openocd/+/6535
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2 years agoflash/nor/tcl: 'flash list' command: add the flash bank target 26/6426/3
Tarek BOCHKATI [Tue, 10 Aug 2021 14:32:37 +0000 (15:32 +0100)]
flash/nor/tcl: 'flash list' command: add the flash bank target

add the target assigned to the flash bank at creation
this is useful in daisy chains, to filter out the target banks.

Change-Id: Ic39e44914e34bb62991783762e5a65ef8871e82f
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6426
Tested-by: jenkins
Reviewed-by: zapb <dev@zapb.de>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agoflash/nor/tcl: fix the flash name returned by 'flash list' command 25/6425/2
Tarek BOCHKATI [Thu, 29 Jul 2021 20:44:55 +0000 (21:44 +0100)]
flash/nor/tcl: fix the flash name returned by 'flash list' command

The 'flash list' command returns the driver name as flash name which seems
to be incorrect, the proposal is:
 - to fix this by returning the flash name
 - and add a new item 'driver' in the returned list

example:
before the change
> flash list
  {name stm32l4x base 134217728 size 0 bus_width 0 chip_width 0}
  {name stm32l4x base 201326592 size 0 bus_width 0 chip_width 0}
  {name stm32l4x base 200933376 size 0 bus_width 0 chip_width 0}

after the change
> flash list
  {name stm32l5x.flash_ns driver stm32l4x ...}
  {name stm32l5x.flash_alias_s driver stm32l4x ...}
  {name stm32l5x.otp driver stm32l4x ...}

Change-Id: I6d307b73c457549981a93c260be344378719af82
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6425
Reviewed-by: zapb <dev@zapb.de>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2 years agotcl/board: add st_nucleo_g4.cfg to cover known STM32G4 NUCLEO boards 84/5484/6
Tarek BOCHKATI [Sun, 1 Mar 2020 22:11:10 +0000 (23:11 +0100)]
tcl/board: add st_nucleo_g4.cfg to cover known STM32G4 NUCLEO boards

known boards are NUCLEO-G431KB, NUCLEO-G431RB and NUCLEO-G474RE

note: this work safely with B-G431B-ESC1, B-G474E-DPOW1,
      STM32G474E-EVAL and STM32G484E-EVAL

Change-Id: I132a97e1816620b182983edc8a4b272b52b9241d
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/5484
Reviewed-by: Andreas Bolsch <hyphen0break@gmail.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2 years agotcl/board: add st_nucleo_g0.cfg to cover known STM32G0 NUCLEO boards 83/5483/5
Tarek BOCHKATI [Sun, 1 Mar 2020 22:00:15 +0000 (23:00 +0100)]
tcl/board: add st_nucleo_g0.cfg to cover known STM32G0 NUCLEO boards

known boards are NUCLEO-G031K8, NUCLEO-G070RB, NUCLEO-G071RB

note: this work safely with STM32G0316-DISCO, STM32G071B-DISCO
      and STM32G081B-EVAL

Change-Id: I483b6f44409228cd8c2c97b3c560927d1645c517
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/5483
Reviewed-by: Andreas Bolsch <hyphen0break@gmail.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2 years agotarget: cortex_m: Fix a typo VECTRESET 08/6508/2
Yasushi SHOJI [Sun, 29 Aug 2021 09:27:52 +0000 (18:27 +0900)]
target: cortex_m: Fix a typo VECTRESET

According to ARM Cortex M3 technical reference manual, it's
"VECTRESET" instead of "VECRESET".

Change-Id: Iff5534beac2b313cee6da3252d76d4d44a61eeed
Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6508
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agotcl/board/arty_s7: Fix proc and chip name 09/6509/2
Marc Schink [Mon, 30 Aug 2021 12:20:26 +0000 (14:20 +0200)]
tcl/board/arty_s7: Fix proc and chip name

Tested with Digilent Arty S7 board.

Change-Id: I064f3b6537ae8d765d7f380ad53b922d584fdbe7
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/6509
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agojimtcl: update to master branch 20210715 26/6226/4
Antonio Borneo [Sun, 11 Apr 2021 21:54:44 +0000 (23:54 +0200)]
jimtcl: update to master branch 20210715

This version of jimtcl:
- fixes memory leak in API Jim_CreateCommand();
- fixes 'make distcheck';
- uses single-argument syntax for 'expr'.

With the 'expr' syntax already fixed in all the tcl scripts in
OpenOCD, let's use the latest jimtcl to check it and anticipate
any further issues.
By using this version, the workaround for the memory leak and for
distcheck can be reverted.

Change-Id: I58e1bdc752a728f1b479de1c55067b698e817ef5
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6226
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: zapb <dev@zapb.de>
Tested-by: jenkins
2 years agoopenocd: prepare for jimtcl 0.81 'expr' syntax change 10/6510/2
Antonio Borneo [Sun, 29 Aug 2021 23:01:40 +0000 (01:01 +0200)]
openocd: prepare for jimtcl 0.81 'expr' syntax change

Jimtcl commit 1843b79a03dd ("expr: TIP 526, only support a single
arg") drops the support for multi-argument syntax for the TCL
command 'expr'.
All the scripts distributed with OpenOCD are already compliant
with the new syntax.

To avoid breaking user script, introduce a replacement for 'expr'
command that handles the old syntax while issuing a deprecated
warning.
This change should be part of OpenOCD v0.12.0, then reverted.

Change-Id: Ib08aa8ebcb634c81a3ce9d24fb4938b0418c947c
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6510
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Tested-by: jenkins
2 years agoflash/stm32l4x: avoid using magic numbers for device ids 37/6437/9
Tarek BOCHKATI [Sat, 14 Aug 2021 13:31:17 +0000 (14:31 +0100)]
flash/stm32l4x: avoid using magic numbers for device ids

Change-Id: I54c41f31c16b91904e8cbca823b90caa3807826d
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6437
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2 years agoflash/stm32l4x: add support of STM32WB1x 29/6129/10
Tarek BOCHKATI [Fri, 26 Mar 2021 14:07:41 +0000 (15:07 +0100)]
flash/stm32l4x: add support of STM32WB1x

STM32WB1x devices has a single flash bank up to 320 KB (page 2KB)

note: STM32WB5x/WB3x are single banks as well but do have 4KB as page size.
note: remove the assert that checks if max_mages is power of two, because
      STM32WB1x flash size is not a power of 2

Change-Id: Ib514cf989ecb819d25d1c4a65d641d0a1a3d9f18
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6129
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2 years agoflash/stm32l4x: add support of STM32G05/G06x 28/6128/10
Tarek BOCHKATI [Fri, 26 Mar 2021 12:27:52 +0000 (13:27 +0100)]
flash/stm32l4x: add support of STM32G05/G06x

this device has single bank flash architecture up to 64KB (page 2KB)
reference: RM0444 rev 5

Change-Id: Ia213c01accb950fcbb7519e08057dae11b4443dd
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6128
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2 years agoflash/stm32l4x: switch to to c loader instead of assembly loader 09/6109/21
Tarek BOCHKATI [Sat, 6 Mar 2021 21:46:35 +0000 (22:46 +0100)]
flash/stm32l4x: switch to to c loader instead of assembly loader

switching to C loader instead of the assembly version will enhance readability
will reduce the maintenance effort.

besides the switch to C loader, we added a new parameters to the loader
like flash_word_size and flash_sr_bsy_mask in order to support properly
STM32U5x and STM32G0Bx/G0Cx in dual-bank mode.

Change-Id: I24cafc2ba637a065593a0506eae787b21080a0ba
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6109
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2 years agoflash/nor: add support for Nuvoton NPCX series flash 50/5950/17
Wealian Liao [Thu, 26 Nov 2020 02:25:09 +0000 (10:25 +0800)]
flash/nor: add support for Nuvoton NPCX series flash

Added NPCX flash driver to support the Nuvoton NPCX series
microcontrollers. Add config file for NPCX series.

Change-Id: Ia10b019a3521f59ad1e10ccdc56827ba30c3eac8
Signed-off-by: Wealian Liao <WHLIAO@nuvoton.com>
Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/5950
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2 years agoserver/telnet: add variables auto-completion 42/6442/2
Tarek BOCHKATI [Thu, 19 Aug 2021 00:30:38 +0000 (01:30 +0100)]
server/telnet: add variables auto-completion

Change-Id: Ie690afad18065cde8d754c8af50dacd9f467c8e5
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6442
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agoserver/telnet: simplify telnet_input function 40/6440/4
Tarek BOCHKATI [Wed, 18 Aug 2021 17:41:49 +0000 (18:41 +0100)]
server/telnet: simplify telnet_input function

running complexity on this file tells that:
NOTE: proc telnet_input in file telnet_server.c line 576
nesting depth reached level 8
==> *seriously consider rewriting the procedure*.
Complexity Scores
Score | ln-ct | nc-lns| file-name(line): proc-name
  319     272     226   src/server/telnet_server.c(576): telnet_input
total nc-lns      226

so try to reduce the complexity score of telnet_input function

Change-Id: I64ecb0c54da83c27a343f2a1df99fc8f9484572a
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6440
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agoserver/telnet: enhance telnet_move_cursor 41/6441/2
Tarek BOCHKATI [Wed, 18 Aug 2021 18:55:48 +0000 (19:55 +0100)]
server/telnet: enhance telnet_move_cursor

instrument the telnet_move_cursor to detect when there is no change
of cursor position and if the requested new position is out of bounds.

Change-Id: I24da877e538a458da6d2f8ddc2a681eee404d2cb
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6441
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agoserver/telnet: support 'CTRL+C' 39/6439/2
Tarek BOCHKATI [Tue, 17 Aug 2021 12:29:56 +0000 (13:29 +0100)]
server/telnet: support 'CTRL+C'

like in terminal 'CTRL+C':
 - keeps the line content so the user can refer to it (like copy/paste)
 - marks the line with '^C', as hint that the command was not executed
 - permit the user to write a new command

Change-Id: Ib784c827d64fdc439a35db461d8387a62d3bfbbf
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6439
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2 years agoserver/telnet: cleanup the if statement mixed style 38/6438/2
Tarek BOCHKATI [Tue, 17 Aug 2021 12:24:56 +0000 (13:24 +0100)]
server/telnet: cleanup the if statement mixed style

Change-Id: Ie5f67288511d46fa196bc9f41e6af5504244adaa
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6438
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2 years agoMakefile: drop warning suppression on win build 54/6254/2
Antonio Borneo [Sat, 15 May 2021 21:14:18 +0000 (23:14 +0200)]
Makefile: drop warning suppression on win build

Commit dcdf71c21b99 ("- fix signed/unsigned build errors under
win32. Thanks Zach Welch <zw@superlucidity.net>") in 2009 prevents
gcc warnings on sign/unsigned comparisons while building for Win
on folders 'helper' and 'server'.
In 2011, commit b69119668ed8 ("RTOS Thread awareness support wip")
uses the same method on the new folder 'rtos'.

In mean time, all the incorrect sign/unsigned comparisons has been
fixed and no warning is present with the default -Wextra flag that
implies -Wsign-compare.
The comment:
# FD_* macros are sloppy with their signs on MinGW32 platform
seems linked to some old implementation of MinGW32 include file
that doesn't apply on current versions.

Remove the obsolete hacks to suppress the warnings.

Change-Id: I76dba9e54a647d3b9fbf1b7e9ae1844e3d7adc9a
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6254
Tested-by: jenkins
Reviewed-by: Xiaofan Chen <xiaofanc@gmail.com>
2 years agohelper: remove fix for libusb pre-v1.0.9 53/6253/2
Antonio Borneo [Sat, 15 May 2021 22:48:49 +0000 (00:48 +0200)]
helper: remove fix for libusb pre-v1.0.9

Libusb v1.0.9 has been released on April 2012. We can reasonably
expect that every user has already updated his system to a libusb
newer of equel to v1.0.9.

Remove the fix for older libusb.

Change-Id: I0c40e53d7af85a11b0bb265bbf8035857a2dfce1
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6253
Tested-by: jenkins
Reviewed-by: Xiaofan Chen <xiaofanc@gmail.com>
2 years agoflash/stm32l4x: free write_algorithm work area if no space left for the buffer 86/6486/2
Tarek BOCHKATI [Sun, 29 Aug 2021 15:02:58 +0000 (16:02 +0100)]
flash/stm32l4x: free write_algorithm work area if no space left for the buffer

If the remaining memory for the buffer is less than 256 bytes,
the memory allocated for the write algorithm in the target is not freed.

Fixes: ba131f30a079 (Flash driver for STM32G0xx and STM32G4xx)
Change-Id: Ic649f6c39799d76725b0c69ff3a009a3f510e17f
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6486
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2 years agoflash/stm32l4x: add support of STM32U57x/U58x 08/6108/15
Tarek BOCHKATI [Tue, 16 Mar 2021 15:10:59 +0000 (16:10 +0100)]
flash/stm32l4x: add support of STM32U57x/U58x

this device flash registers are quite similar to STM32L5
with this changes :
 - flash size is up to 2MB
 - 2MB variants are always dual bank
 - 1MB and 512KB variants could be dual bank (contiguous addressing)
   depending on DUALBANK bit(21)
 - flash data width is 16 bytes (quad-word)

Change-Id: Id13c552270ce1071479ad418526e8a39ebe83cb1
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6108
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2 years agoflash/stm32l4x: add support of STM32WL5x dual core 50/6050/16
Tarek BOCHKATI [Thu, 4 Feb 2021 21:43:52 +0000 (22:43 +0100)]
flash/stm32l4x: add support of STM32WL5x dual core

according the RM0453, the second core  have a different Flash CR and SR
registers for flash operations (called C2CR and C2SR).
so we need to a different flash_regs than older L4 devices.
@see stm32wl_cpu2_flash_regs

the C2CR register don't contain LOCK and OPTLOCK bits, and this explain
the addition of new register index called STM32_FLASH_CR_WLK_INDEX to
look-up the CR with lock, to be used in locking/unlocking the flash.

note: DBGMCU_IDCODE cannot be read using CPU1 (Cortex-M0+) at AP1,
to solve this read the UID64 (IEEE 64-bit unique device ID register)

Change-Id: Ifb6e291bf97f814f0b9987b2c40f3037959f7af4
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6050
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2 years agoflash/stm32l4x: prevent undefined behavior warnings caused by signed integer operations 29/6429/5
Sebastiaan de Schaetzen [Sun, 15 Aug 2021 22:26:23 +0000 (23:26 +0100)]
flash/stm32l4x: prevent undefined behavior warnings caused by signed integer operations

When running OpenOCD with -fsanitize=undefined, a warning is emitted
for an bit-shifting operation whose result cannot be stored in a
signed integer.

This is because (1 << 31) overflows a signed integer, which is
undefined behavior. By making each of the bit masks act on an
unsigned number, the warning is avoided.

Whether this warning emitted by UBSan would ever manifest into a real
error is debatable, but fixing this does make UBSan happy.

Change-Id: I0455a26b234cb4f5e239a6ba90023d28380e9464
Signed-off-by: Sebastiaan de Schaetzen <sebastiaan.de.schaetzen@gmail.com>
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6429
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
Tested-by: jenkins
2 years agoflash/stm32l4x: add support of STM32G0Bx/G0Cx devices 36/6036/13
Tarek BOCHKATI [Tue, 19 Jan 2021 12:26:48 +0000 (13:26 +0100)]
flash/stm32l4x: add support of STM32G0Bx/G0Cx devices

this device has a dual bank flash architecture up to 512 KB (page 2KB)
reference: RM0444 Rev 5

notes:
 - 128k variant is always single bank
 - 256k variant flash is contiguous (no gap) in dual bank mode
 - BKER is bit 13 vs bit 11 for other devices
   > added cr_bker_mask in stm32l4_flash_bank struct
 - BSY2 for bank 2 operations
   > added sr_bsy_mask in stm32l4_flash_bank struct
   > proposed optimization: always wait for (BSY1 | BSY2) with
     STM32G0Bx/G0Cx devices only (for L4+ devices BSY2=PEMPTY)

TODO: update flashloader to use the proper BSY bits
      temporarily don't use the loader in dual bank mode

Change-Id: I54b0c93b494e7209da818791d15edd8cd42c2732
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6036
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
Tested-by: jenkins
2 years agoflash/stm32l4x: remove stm32l4_part_info.default_flash_regs 35/6435/4
Tarek BOCHKATI [Fri, 13 Aug 2021 23:09:29 +0000 (00:09 +0100)]
flash/stm32l4x: remove stm32l4_part_info.default_flash_regs

This struct element is replaced by the usage of F_HAS_L5_FLASH_REGS flag:
since over this driver stm32l4_flash_regs is the default register layout,
and the only exception is STM32L5 family,
so it's simpler to manage it using a flag.

Note: the same flag will be used with STM32U5 devices, as they have
the same registers layout, which explains the move of stm32l5_s_flash_regs
before the switch(device_id) in order to not re-write this for STM32U5.

Change-Id: I3b67a6f558d9350f609a22524012b6fceb7de7c2
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6435
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
Tested-by: jenkins
2 years agoflash/stm32l4x: introduce flash programming without loader 73/6273/9
Tarek BOCHKATI [Tue, 25 May 2021 10:54:50 +0000 (11:54 +0100)]
flash/stm32l4x: introduce flash programming without loader

this capability permits to program the flash if we cannot reserve a workarea.

the introduction the command 'stm32l4x flashloader <bank_id> [enable|disable]'
helps to automatically skip using the flashloader if needed.

Change-Id: Id29213c85ee5c7c487cfee21554f5a7ea50db6c9
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6273
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
Tested-by: jenkins
2 years agoflash/stm32l4x: STM32L5 support programming when TZEN=1 and RDP=0x55 35/6035/17
Tarek BOCHKATI [Fri, 22 Jan 2021 12:15:52 +0000 (13:15 +0100)]
flash/stm32l4x: STM32L5 support programming when TZEN=1 and RDP=0x55

when RDP level is 0.5 the provided work-area should reside in non-secure RAM
to ensure that:
 - add a hint in the driver level
 - reduce the usage of secure RAM only when TZEN=1 and RDP is not 0.5
   (check the target configuration file)

Change-Id: Idbf2325e609b84ef8480eefdb49a176fdf7e07c7
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6035
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
Tested-by: jenkins
2 years agoflash/stm32l4x: STM32L5 support programming when TZEN=1 and RDP=0xAA 36/5936/19
Tarek BOCHKATI [Thu, 12 Nov 2020 16:19:40 +0000 (17:19 +0100)]
flash/stm32l4x: STM32L5 support programming when TZEN=1 and RDP=0xAA

STM32L5 flash memory is aliased to 0x0C000000, this address mapping
is used for secure applications. (0x08000000 for non-secure)

this change allows the programming of secure and non-secure flash
when trustzone is enabled and RDP level is 0

Change-Id: I89d1f1b5d493cf01a142ca4dbfef5a3731cab96e
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/5936
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2 years agoflash/stm32l4x: introduce auto-probe when OPTR is changed 35/5935/14
Tarek BOCHKATI [Tue, 10 Nov 2020 18:15:54 +0000 (19:15 +0100)]
flash/stm32l4x: introduce auto-probe when OPTR is changed

auto re-probing is ensured by having optr cache set in the
last probe operation.

this will help to detect if flash options have been modified by the
running application or by the user using direct register access.

Change-Id: I05cd7ab9e83a7fc26ac6cff175b3c11b0efa2eb5
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/5935
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
Tested-by: jenkins
2 years agoflash/stm32l4x: introduce 'stm32l4x trustzone [enable|disable]' command 42/5542/19
Tarek BOCHKATI [Wed, 25 Mar 2020 21:47:08 +0000 (22:47 +0100)]
flash/stm32l4x: introduce 'stm32l4x trustzone [enable|disable]' command

this command will help to enable/disable or display the TrustZone security,
using the TZEN option bit.

Note: This command works only with devices with TrustZone, eg. STM32L5.
Note: This command will perform an OBL_Launch after modifying the TZEN.

Change-Id: I4aef15bf57d09c1658d37858143d23b1d43de1f0
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/5542
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2 years agoflash/stm32l4x: do not report bank mode before probing [FIX] 11/6411/3
Tarek BOCHKATI [Thu, 29 Jul 2021 09:35:26 +0000 (10:35 +0100)]
flash/stm32l4x: do not report bank mode before probing [FIX]

in line 1391, get_stm32l4_bank_type_str(bank) will always output the same
value "Flash single" since the variable stm32l4_info->dual_bank_mode is false
by default, stm32l4_info->dual_bank_mode will be set correctly afterward
in the switch case at line 1467

thus the need to remove the usage of get_stm32l4_bank_type_str(bank) before
stm32l4_info->dual_bank_mode initialization.

Fixes: 64c2e03b23d9 ("flash/nor: improved API of flash_driver.info & fixed buffer overruns")
Change-Id: Ia8dc7e144e0ded6143682eb514c247f27859ff81
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6411
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2 years agotcl: add lattice ECP5 family support 12/6112/6
Oleksij Rempel [Sun, 14 Mar 2021 17:19:06 +0000 (18:19 +0100)]
tcl: add lattice ECP5 family support

Add support for ECP5 FPGA targets and board based on this chips:
Radiona ULX3S and Lambdaconcept ECPIX-5

Change-Id: I932fc6e2458cda7d63ac21579acddea5b53410bc
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/6112
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2 years agotarget/adi_v5_jtag: Add support for 8-bit IR JTAG-DP 85/6285/2
root [Thu, 3 Jun 2021 09:37:37 +0000 (11:37 +0200)]
target/adi_v5_jtag: Add support for 8-bit IR JTAG-DP

As per Arm Debug Interface Architecture Specification (ADIv5.0 to
ADIv5.2), B3.3.1, the JTAG-DP as an IR length of 4 or 8 bits
depending on the ARM implementation. The current code
only support 4-bit and this patch extends the support to 8-bit IR.
Not tested back yet on a 4-bit target.

Change-Id: Ie4f875dc336caf014c6cfced57574b54d0970623
Signed-off-by: Antoine C. <acalando@free.fr>
Reviewed-on: https://review.openocd.org/c/openocd/+/6285
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agocortex_a: use the ap number specified at target create 13/6413/2
Antonio Borneo [Wed, 4 Aug 2021 15:50:02 +0000 (17:50 +0200)]
cortex_a: use the ap number specified at target create

Current implementation ignores the flag '-ap-num' provided to
command 'target create' and searches for the first AP of APB type.

If specified, use the ap number.

Change-Id: If1ac12345220d14a4a60515efe46dc2a2eac079a
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6413
Tested-by: jenkins
2 years agojep106: use packed jedec manufacturer code 18/6418/2
Antonio Borneo [Sun, 8 Aug 2021 11:51:33 +0000 (13:51 +0200)]
jep106: use packed jedec manufacturer code

JEP106 encodes JEDEC-assigned manufacture code as:
a) a sequence of zero or more escape codes 0x7f;
b) an odd-parity bit of the next 7 bits;
c) 7 bits.

The same code is often represented as a single value composed by
the logical OR between:
- the number of escape codes in a), shifted left by 7 positions;
- the 7 bits in c).
This is the preferred packed representation used by this change.

Currently there are only two uses of JEP106 in openocd to get the
manufacturer name:
- to decode the JTAG IDCODE of each TAP, where the JEP106 code is
  already packed as in the preferred representation above in bits
  IDCODE[11:1];
- to decode the ARM CoreSight PIDR register, where the JEP106 code
  is split in 3 parts:
  = PIDR3[3:0], corresponding to bits [10:7] of the packed code;
  = PIDR2[2:0], corresponding to bits [6:4] of the packed code;
  = PIDR1[7:4], corresponding to bits [3:0] of the packed code.

Wrap the existing JEP106 decode function in a simpler API using
the packed code.
Simplify the callers by skipping the bit unpacking.
Change the manufacturer code in CoreSight table dap_partnums[] to
match the packed representation, by removing the always-one bit 7
erroneously taken from PIDR bit JEDEC and included in the former
table.

Change-Id: I63eb4da9e6801fab25e330f1f6b792d2fd619493
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6418
Tested-by: jenkins
2 years agoarm_adi_v5: update coresight class names 31/6431/2
Antonio Borneo [Wed, 11 Aug 2021 15:03:18 +0000 (17:03 +0200)]
arm_adi_v5: update coresight class names

Update the list of ARM coresight classes wrt to latest ARM
documentation.
Use c99 array designator to easily track changes in future.
Add a comment for the entry "OptimoDE DESS". It was added in 2009
by David Brownell, but Google cannot find any reference other than
this line in openocd code its associated commit. It should not be
an issue keeping it as is.

Change-Id: Ia3b646131ee68ca5263095c3a0aeaf75c004b324
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6431
Tested-by: jenkins
2 years agocommand: log the command only when it is executed 36/6436/2
Antonio Borneo [Wed, 11 Aug 2021 22:14:29 +0000 (00:14 +0200)]
command: log the command only when it is executed

In case of multi-word commands, the command dispatcher is nested
called at each word during command name parsing.
The improper position of the call to script_debug() causes the
command line to be logged once at each parsed word.
In the example of command "cpu arm disassemble 0" the full command
is logged three times for "cpu", "arm" and "disassemble":

Debug: 656617 61843 command.c:201 script_debug(): command - cpu arm disassemble 0
Debug: 656618 61843 command.c:201 script_debug(): command - cpu arm disassemble 0
Debug: 656619 61843 command.c:201 script_debug(): command - cpu arm disassemble 0

Call script_debug() only when the parsing is terminated and the
command handler is going to be executed.

Change-Id: Ide4cb01b3b38912e2e24b073c94a9560f92d30bb
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6436
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2 years agocortex_m: fix command 'step address' 34/6434/2
Antonio Borneo [Fri, 13 Aug 2021 16:52:20 +0000 (18:52 +0200)]
cortex_m: fix command 'step address'

The command 'step' accepts an optional parameter 'address' to run
the step-by-step execution from an address different from current
program counter.
When OpenOCD sets the new program counter value in the register
cache, it doesn't flag it as dirty. The following call to function
armv7m_restore_context() does not propagate the new value of the
program counter to the target. This cause the target to continue
from the old program counter value, ignoring the user's request.

It is hard to notice the issue if the target is halted in an idle
loop! In fact the default mode to operate step-by-step is to set a
breakpoint to the following instruction and resume execution. In
the idle loop the CPU will pass through the breakpoint whatever
the resume address is. User will find the target halting at the
instruction following 'address' which is consistent with the
expected behaviour of command 'step address'.

To verify the issue on an STM32F4, use a dummy code in SRAM:
halt
mww 0x20000000 0xbf00bf00
mww 0x20000004 0xbf00bf00
mww 0x20000008 0xe7fcbf00
arm disassemble 0x20000000 6
        0x20000000  bf00    nop
        0x20000002  bf00    nop
        0x20000004  bf00    nop
   +--> 0x20000006  bf00    nop
   |    0x20000008  bf00    nop
   +-<- 0x2000000a  e7fc    b   #0x20000006
resume 0x20000006
halt
step 0x20000000
the target doesn't halt because it is in the loop from 0x20000006
to 0x2000000a. The 'step 0x20000000' did not changed the program
counter so the temporary breakpoint at 0x20000002 is never hit.
Then:
halt
step 0x20000008
target halted ...
... pc: 0x2000000a
gives the feeling that only the instruction at 0x20000008 has been
executed, but actually the whole loop has been executed from the
place 'halt' stopped the execution till the breakpoint at the
instruction following 0x20000008.

Flag the program counter cached value as 'valid' and 'dirty' to
force armv7m_restore_context() to update the target's register.

Change-Id: I49bd8bb95b2f5429ec38ed016f2ad706618ae68a
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6434
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2 years agostlink: fix SWIM mode on stlink-v3 43/6443/2
Antonio Borneo [Thu, 19 Aug 2021 14:07:21 +0000 (16:07 +0200)]
stlink: fix SWIM mode on stlink-v3

Commit 89f07325f2e7 ("stlink: Set speed before entering JTAG/SWD
mode") anticipates setting the adapter speed just before entering
in the JTAG/SWD mode. This to initiate the communication with the
speed selected by the user.
But SWIM doesn't allow setting the speed before entering in SWIM
mode. The resulting error causes OpenOCD to quit.
The problem only happens with stlink-v3, due to the different way
to set the adapter speed on different stlink versions.

Set the speed before entering in the mode only for JTAG and SWD
modes.

Change-Id: Iab42cd9d72ecfac14c7e17bae74e0dee2218b235
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Fixes: 89f07325f2e7 ("stlink: Set speed before entering JTAG/SWD mode")
Reviewed-on: https://review.openocd.org/c/openocd/+/6443
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2 years agortos/riot: fix out-of-bounds writes when target is corrupted 81/6381/5
Sebastiaan de Schaetzen [Tue, 27 Jul 2021 13:06:57 +0000 (15:06 +0200)]
rtos/riot: fix out-of-bounds writes when target is corrupted

This protects against out-of-bounds writes when the memory
of RIOT's scheduler is corrupted.
This memory can be corrupted because of:
 - Programming errors
 - The scheduler not yet having been initialised
 - An incorrect symbol file being used during debugging.

This error can result in OpenOCD segfaulting. Valgrind was
used to find the approximate location of the error.

Change-Id: I60e7d7c245b8c4e38f4c98cb0c0347a9b5ec3177
Signed-off-by: Sebastiaan de Schaetzen <sebastiaan.de.schaetzen@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6381
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agortos/riot: fix out-of-bounds read of optional symbols array 28/6428/4
Sebastiaan de Schaetzen [Wed, 11 Aug 2021 12:51:29 +0000 (14:51 +0200)]
rtos/riot: fix out-of-bounds read of optional symbols array

This fixes an out-of-bounds read of the riot_optional_symbols array.

Change-Id: I172ae182dd0c7dd68edaa66ac030030d9bc65401
Signed-off-by: Sebastiaan de Schaetzen <sebastiaan.de.schaetzen@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6428
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agoflash/atsame5: use COMMAND_PARSE_NUMBER in command handlers 23/6423/2
Tarek BOCHKATI [Thu, 29 Jul 2021 22:46:31 +0000 (23:46 +0100)]
flash/atsame5: use COMMAND_PARSE_NUMBER in command handlers

the usage of COMMAND_PARSE_NUMBER is safer in COMMAND_HANDLERs since it provides
better error checking than strto** functions.

Change-Id: Ia7fe9c4017108616f21676f115f151ac62924205
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6423
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2 years agoflash/kinetis: use COMMAND_PARSE_NUMBER in command handlers 22/6422/2
Tarek BOCHKATI [Thu, 29 Jul 2021 22:46:09 +0000 (23:46 +0100)]
flash/kinetis: use COMMAND_PARSE_NUMBER in command handlers

the usage of COMMAND_PARSE_NUMBER is safer in COMMAND_HANDLERs since it provides
better error checking than strto** functions.

Change-Id: I972da1a75ba7c41c1b714c2429289c3d24594235
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6422
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2 years agoflash/xmc4xxx: use COMMAND_PARSE_NUMBER in command handlers 21/6421/2
Tarek BOCHKATI [Thu, 29 Jul 2021 22:45:38 +0000 (23:45 +0100)]
flash/xmc4xxx: use COMMAND_PARSE_NUMBER in command handlers

the usage of COMMAND_PARSE_NUMBER is safer in COMMAND_HANDLERs since it provides
better error checking than strto** functions.

Change-Id: Ibfe95ce73f147f467de8de23e9573ef0179aed96
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6421
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2 years agoflash/at91samd: use COMMAND_PARSE_NUMBER in command handlers 24/6424/3
Tarek BOCHKATI [Thu, 29 Jul 2021 22:47:07 +0000 (23:47 +0100)]
flash/at91samd: use COMMAND_PARSE_NUMBER in command handlers

the usage of COMMAND_PARSE_NUMBER is safer in COMMAND_HANDLERs since it provides
better error checking than strto** functions.

Change-Id: I14061cb48da6bac13f9d2896190136f5784b8c07
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6424
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agojtag/cmcis_dap: use COMMAND_PARSE_NUMBER in command handlers 20/6420/2
Tarek BOCHKATI [Thu, 29 Jul 2021 22:44:36 +0000 (23:44 +0100)]
jtag/cmcis_dap: use COMMAND_PARSE_NUMBER in command handlers

the usage of COMMAND_PARSE_NUMBER is safer in COMMAND_HANDLERs since it provides
better error checking than strto** functions.

Change-Id: Ife9342c6088a241a0a4b77f9bd21f12c9b9862a0
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6420
Reviewed-by: Adrian M Negreanu <adrian.negreanu@nxp.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
2 years agoflash/stm32l4x: use COMMAND_PARSE_NUMBER in command handlers 19/6419/2
Tarek BOCHKATI [Thu, 29 Jul 2021 21:05:18 +0000 (22:05 +0100)]
flash/stm32l4x: use COMMAND_PARSE_NUMBER in command handlers

the usage of COMMAND_PARSE_NUMBER is safer in COMMAND_HANDLERs since it provides
better error checking than strto** functions.

Change-Id: I7e113b06b74f2d8d9cc4c0ce1957994a1c49c964
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6419
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
Tested-by: jenkins
2 years agogithub/workflow: disable libusb static link for windows build 84/6384/3
Tarek BOCHKATI [Wed, 28 Jul 2021 09:48:59 +0000 (10:48 +0100)]
github/workflow: disable libusb static link for windows build

Current github build for windows is using dynamic libraries,
but libftdi is requiring libusb static libraries.

As a quick solution, just get rid of libftdi till it can be linked without
static libusb.

Change-Id: I9c7cb0b8853459ca48589674498403e255ade5cc
Reported-by: Xiaofan <xiaofanc@gmail.com>
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6384
Reviewed-by: Xiaofan <xiaofanc@gmail.com>
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
Tested-by: jenkins
2 years agotcl/interface: add Ashling Opella-LD FTDI config files 79/6379/5
Ranjith Chandran [Fri, 23 Jul 2021 04:51:05 +0000 (10:21 +0530)]
tcl/interface: add Ashling Opella-LD FTDI config files

Adding Ashling's FTDI based Debug adapter Opella-LD's JTAG and SWD config files

Change-Id: Ie0e82e3b8326de37641901f5c825372cab31de58
Signed-off-by: ranjith.tc@ashling.com
Reviewed-on: http://openocd.zylin.com/6379
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agodrivers/ft232r: Group adapter commands 09/6409/3
Marc Schink [Sun, 1 Aug 2021 12:20:22 +0000 (14:20 +0200)]
drivers/ft232r: Group adapter commands

Use a command group 'ft232r' with subcommands instead of individual
commands with 'ft232r_' prefix.

The old commands are still available for backward compatibility but
marked as deprecated.

Change-Id: I0dbeb4716330c83f8ce89b0d054eb0286b887bdf
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/6409
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agotcl: Adapt config files to new usb_blaster command syntax 08/6408/3
Marc Schink [Sun, 1 Aug 2021 12:15:06 +0000 (14:15 +0200)]
tcl: Adapt config files to new usb_blaster command syntax

Change-Id: I4eb645f74ef31fc0b5882299b3487020aa142dd8
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/6408
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agodrivers/usb_blaster: Group adapter commands 07/6407/3
Marc Schink [Sun, 1 Aug 2021 12:12:23 +0000 (14:12 +0200)]
drivers/usb_blaster: Group adapter commands

Use a command group 'usb_blaster' with subcommands instead of individual
commands with 'usb_blaster_' prefix.

The old commands are still available for backward compatibility but
marked as deprecated.

Change-Id: I2ae3d96ba864c20d7db67c74677781a62bfc4eb5
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/6407
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agodoc/openocd: Fix buspirate example 06/6406/3
Marc Schink [Sun, 1 Aug 2021 12:06:59 +0000 (14:06 +0200)]
doc/openocd: Fix buspirate example

Change-Id: Idcbe73220d7630953cb49e643a58a7ab05c395fa
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/6406
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agotcl/interface/buspirate: Adapt to new buspirate command syntax 05/6405/3
Marc Schink [Sun, 1 Aug 2021 12:05:19 +0000 (14:05 +0200)]
tcl/interface/buspirate: Adapt to new buspirate command syntax

Change-Id: I1a82608532f043054abd22eb5b50ab5c5f58cee4
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/6405
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agodrivers/buspirate: Group adapter commands 04/6404/3
Marc Schink [Sun, 1 Aug 2021 12:04:49 +0000 (14:04 +0200)]
drivers/buspirate: Group adapter commands

Use a command group 'buspirate' with subcommands instead of individual
commands with 'buspirate_' prefix.

The old commands are still available for backward compatibility but
marked as deprecated.

Change-Id: Id999d4ba276af576fb22b76052f3c0a1f3e1b876
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/6404
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agotcl/interface: Adapt config files to new sysfsgpio command syntax 03/6403/3
Marc Schink [Sat, 31 Jul 2021 21:51:56 +0000 (23:51 +0200)]
tcl/interface: Adapt config files to new sysfsgpio command syntax

Change-Id: I8e8dee6e8869d2853a7a73c8d4dc8b4891fb0389
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/6403
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agodrivers/sysfsgpio: Group adapter commands 02/6402/3
Marc Schink [Sat, 31 Jul 2021 21:49:10 +0000 (23:49 +0200)]
drivers/sysfsgpio: Group adapter commands

Use a command group 'sysfsgpio' with subcommands instead of individual
commands with 'sysfsgpio_' prefix.

The old commands are still available for backward compatibility but
marked as deprecated.

Change-Id: I103d8d9b0e3169a916d944a999579746f6f6a59c
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/6402
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agotcl/interface/dln-2-gpiod: Adapt to new linuxgpiod command syntax 01/6401/3
Marc Schink [Sat, 31 Jul 2021 21:45:31 +0000 (23:45 +0200)]
tcl/interface/dln-2-gpiod: Adapt to new linuxgpiod command syntax

Change-Id: Ife1e52fe5da0e0374a606072f1faf7c598cf0e2b
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/6401
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agodrivers/linuxgpiod: Group adapter commands 00/6400/3
Marc Schink [Sat, 31 Jul 2021 21:44:24 +0000 (23:44 +0200)]
drivers/linuxgpiod: Group adapter commands

Use a command group 'linuxgpiod' with subcommands instead of individual
commands with 'linuxgpiod_' prefix.

The old commands are still available for backward compatibility but
marked as deprecated.

Change-Id: Iad9b330363f81128ab1ec1cbc498df28ba2ca152
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/6400
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agotcl/interface/jtag_vpi: Adapt to new jtag_vpi command syntax 99/6399/3
Marc Schink [Fri, 30 Jul 2021 16:40:03 +0000 (18:40 +0200)]
tcl/interface/jtag_vpi: Adapt to new jtag_vpi command syntax

Change-Id: I27eeab5e3dd554af00799104471ee8f30fbd0c51
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/6399
Tested-by: jenkins
Reviewed-by: Jan Matyas <matyas@codasip.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agodrivers/jtag_vpi: Group adapter commands 98/6398/3
Marc Schink [Fri, 30 Jul 2021 16:39:27 +0000 (18:39 +0200)]
drivers/jtag_vpi: Group adapter commands

Use a command group 'jtag_vpi' with subcommands instead of individual
commands with 'jtag_vpi_' prefix.

The old commands are still available for backward compatibility but
marked as deprecated.

Change-Id: Ie1fcc2cc138796d27f1e862692bb9ef8b11bc10d
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/6398
Tested-by: jenkins
Reviewed-by: Jan Matyas <matyas@codasip.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agotcl/interface: Adapt config files to new bcm2835gpio command syntax 97/6397/3
Marc Schink [Fri, 30 Jul 2021 16:31:07 +0000 (18:31 +0200)]
tcl/interface: Adapt config files to new bcm2835gpio command syntax

Change-Id: I2d649117aa8dbdf5484ace068785a1416efa3ecc
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/6397
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agodrivers/bcm2835gpio: Group adapter commands 96/6396/3
Marc Schink [Fri, 30 Jul 2021 16:29:01 +0000 (18:29 +0200)]
drivers/bcm2835gpio: Group adapter commands

Use a command group 'bcm2835gpio' with subcommands instead of individual
commands with 'bcm2835gpio_' prefix.

The old commands are still available for backward compatibility but
marked as deprecated.

Change-Id: I8f7b14273b1b2813ac3c9704605d175fa2053008
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/6396
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agotcl/interface/jtag_dpi: Adapt to new jtag_dpi command syntax 95/6395/3
Marc Schink [Fri, 30 Jul 2021 16:25:41 +0000 (18:25 +0200)]
tcl/interface/jtag_dpi: Adapt to new jtag_dpi command syntax

Change-Id: Icebf6f0a037f4ea9fb450581fcc599417bffc153
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/6395
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agodrivers/jtag_dpi: Group adapter commands 94/6394/3
Marc Schink [Fri, 30 Jul 2021 16:24:03 +0000 (18:24 +0200)]
drivers/jtag_dpi: Group adapter commands

Use a command group 'jtag_dpi' with subcommands instead of individual
commands with 'jtag_dpi_' prefix.

The old commands are still available for backward compatibility but
marked as deprecated.

Change-Id: I19271546235a3c6737f975976a0bf0a2f66cbbe7
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/6394
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agodrivers/vsllink: Group adapter commands 93/6393/4
Marc Schink [Fri, 30 Jul 2021 16:22:41 +0000 (18:22 +0200)]
drivers/vsllink: Group adapter commands

Use a command group 'vsllink' with subcommands instead of individual
commands with 'vsllink_' prefix.

The old commands are still available for backward compatibility but
marked as deprecated.

Change-Id: I59273bd7cd08c9801e4a9b3de7beaa86ca854622
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/6393
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agodrivers/ulink: Group adapter commands 92/6392/4
Marc Schink [Fri, 30 Jul 2021 16:20:39 +0000 (18:20 +0200)]
drivers/ulink: Group adapter commands

Use a command group 'ulink' with subcommands instead of individual
commands with 'ulink_' prefix.

The old commands are still available for backward compatibility but
marked as deprecated.

Change-Id: I600d65de2bbd5fb8107445f7fe93b6b24c572e3e
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/6392
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agodrivers/xlnx-pcie-xvc: Group adapter commands 91/6391/3
Marc Schink [Fri, 30 Jul 2021 16:19:02 +0000 (18:19 +0200)]
drivers/xlnx-pcie-xvc: Group adapter commands

Use a command group 'xlnx_pcie_xvc' with subcommands instead of individual
commands with 'xlnx_pcie_xvc_' prefix.

The old commands are still available for backward compatibility but
marked as deprecated.

Change-Id: I0deaaa14ed14f65bf356f3c248331bfab472f08d
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/6391
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agodrivers/presto: Group adapter commands 90/6390/3
Marc Schink [Fri, 30 Jul 2021 16:11:23 +0000 (18:11 +0200)]
drivers/presto: Group adapter commands

Use a command group 'presto' with subcommands instead of individual
commands with 'presto_' prefix.

The old commands are still available for backward compatibility but
marked as deprecated.

Change-Id: I883d8d87fd457d29cee8d12cd80f2e6c405e8f42
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/6390
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agodrivers/remote_bitbang: Group adapter commands 89/6389/3
Marc Schink [Fri, 30 Jul 2021 16:01:09 +0000 (18:01 +0200)]
drivers/remote_bitbang: Group adapter commands

Use a command group 'remote_bitbang' with subcommands instead of individual
commands with 'remote_bitbang_' prefix.

The old commands are still available for backward compatibility but
marked as deprecated.

Change-Id: I2692320f19c8a357112a365db6ca7e13cd6ad411
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/6389
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agotcl/interface/openjtag: Adapt to new openjtag command syntax 88/6388/3
Marc Schink [Fri, 30 Jul 2021 15:51:04 +0000 (17:51 +0200)]
tcl/interface/openjtag: Adapt to new openjtag command syntax

Change-Id: I3a9d649dd38a913b1ce6d4a2d506bbf44743d529
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/6388
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agodrivers/openjtag: Group adapter commands 87/6387/3
Marc Schink [Fri, 30 Jul 2021 15:50:21 +0000 (17:50 +0200)]
drivers/openjtag: Group adapter commands

Use a command group 'openjtag' with subcommands instead of individual
commands with 'openjtag_' prefix.

The old commands are still available for backward compatibility but
marked as deprecated.

Change-Id: Ie1b1bf0b7c03e7703cfb074e554288384bf7b1b9
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/6387
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agotcl/interface: Adapt config files to new parport command syntax 86/6386/3
Marc Schink [Fri, 30 Jul 2021 15:43:58 +0000 (17:43 +0200)]
tcl/interface: Adapt config files to new parport command syntax

Change-Id: Iffe7a04c36c6ec680497081a99d55b8c69f8f079
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/6386
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agodrivers/parport: Group adapter commands 85/6385/4
Marc Schink [Fri, 30 Jul 2021 15:39:11 +0000 (17:39 +0200)]
drivers/parport: Group adapter commands

Use a command group 'parport' with subcommands instead of individual
commands with 'parport_' prefix.

The old commands are still available for backward compatibility but
marked as deprecated.

Change-Id: I4cb7096a8ba8d6cd7a6dc970862cd73c32b5c0a2
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/6385
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agoflash/nor: Do not update 'is_erased' 79/6279/3
Marc Schink [Fri, 7 May 2021 10:02:23 +0000 (12:02 +0200)]
flash/nor: Do not update 'is_erased'

Remove useless setting of the 'is_erased' flag after a flash
modification. Also, remove code that erroneously depends on
this flag.

Keep the flag for now since it is still used by the
erase_check() functionality.

See commit 07da3b3913dcb6b65564f4fe67c2f26032f180c0

Change-Id: Ia046905bc9e0cb2572145f19251c3e10c4e2d553
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/6279
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agojtag/mpsse: fix SIGSEGV for use after free 17/6417/3
Antonio Borneo [Mon, 9 Aug 2021 13:03:37 +0000 (15:03 +0200)]
jtag/mpsse: fix SIGSEGV for use after free

By pressing CTRL-C on a running openocd with FTDI adapter, it's
possible to generate a segmentation fault that with valgrind is
dumped as a SIGABRT:

^CError: libusb_handle_events() failed with LIBUSB_ERROR_INTERRUPTED
==16594== Invalid read of size 8
==16594==    at 0x48B2472: libusb_submit_transfer
==16594==    by 0x48B4B0F: libusb_control_transfer
==16594==    by 0x1A6B9D: mpsse_purge (mpsse.c:428)
==16594==    by 0x1A7B96: mpsse_flush (mpsse.c:953)
==16594==    by 0x19BA5B: ftdi_execute_queue (ftdi.c:654)
...
==16594==  Address 0x6158568 is 72 bytes inside a block of size 216 free'd
==16594==    at 0x484118B: free (vg_replace_malloc.c:755)
==16594==    by 0x1A7B88: mpsse_flush (mpsse.c:950)
==16594==    by 0x19BA5B: ftdi_execute_queue (ftdi.c:654)
...
==16594==  Block was alloc'd at
==16594==    at 0x48435FF: calloc (vg_replace_malloc.c:1117)
==16594==    by 0x48B2259: libusb_alloc_transfer
==16594==    by 0x1A7A26: mpsse_flush (mpsse.c:880)
==16594==    by 0x19BA5B: ftdi_execute_queue (ftdi.c:654)
...
==16594== Process terminating with default action of signal 6 (SIGABRT):
dumping core
...
Aborted (core dumped)

The error is in mpsse_flush() that, following valgrind dump:
- allocates the buffer at line mpsse.c:880
  read_transfer = libusb_alloc_transfer(0);
- frees the buffer at line mpsse.c:950
  libusb_free_transfer(read_transfer);
- still pretends to use the freed buffer at line mpsse.c:953
  mpsse_purge(ctx);

Move the call to mpsse_purge() right before freeing the buffer.

Change-Id: I47c71ec8c283f4b037fdd7cd72ca2e877cd3a851
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6417
Tested-by: jenkins
2 years agoarm_adi_v5: use macro DP_APSEL_MAX in place of magic number 15/6415/2
Antonio Borneo [Wed, 4 Aug 2021 22:37:32 +0000 (00:37 +0200)]
arm_adi_v5: use macro DP_APSEL_MAX in place of magic number

Commit 11019a824d02 ("adi_v5: enforce check on AP number value")
introduces the macro DP_APSEL_MAX and use it in place of hardcoded
magic numbers for the upper limit of AP selection value.

Fix one more place where the macro should be used.

Change-Id: I6c57f72405c69bbb40924221309d95dfeb5f7540
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Fixes: 11019a824d02 ("adi_v5: enforce check on AP number value")
Reviewed-on: http://openocd.zylin.com/6415
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2 years agoopenocd: fix cleanup order: cti before dap 14/6414/2
Antonio Borneo [Wed, 4 Aug 2021 22:22:06 +0000 (00:22 +0200)]
openocd: fix cleanup order: cti before dap

cti access is based on dap.
During cleanup, drop cti before dropping dap to guarantee that cti
can still access its dap.

Change-Id: I40c7f67d4d4a32f53802c0ce7668a5321a05893c
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6414
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2 years agoarm_adi_v5: fix access to 64-bit MEM-AP 12/6412/2
Antonio Borneo [Thu, 5 Aug 2021 15:08:11 +0000 (17:08 +0200)]
arm_adi_v5: fix access to 64-bit MEM-AP

Commit ac22cdc57322 ("target/adiv5: Large Physical Address
Extension") reads the register MEM_AP_REG_CFG and keeps it in a
new field of struct adiv5_ap. The test on LE bit (Large Extension)
is used to identify if mem_ap addresses are 32 or 64 bits.
But the register MEM_AP_REG_CFG is only read during mem_ap_init(),
that is called only when the AP is used as a target debug AP or if
a target mem_ap is attached to that AP.

The openocd commands '<dapname> baseaddr', '<dapname> info' and
'dap info' can be executed on AP that has not been associated yet
to a target, thus executed without any knowledge of MEM_AP_REG_CFG
value. The initialization to ADI_BAD_CFG causes openocd to always
use 32 bit mode on un-associated APs.

Verify if MEM_AP_REG_CFG has not been read and eventually read it.
In case of 32 bits mode AP, MEM_AP_REG_BASE64 is defined as 'RES0'
(reserved, but readable); the code can queue both the read of
MEM_AP_REG_CFG and MEM_AP_REG_BASE64, before knowing if the former
is required. This speeds-up the operation.
Rename ADI_BAD_CFG as MEM_AP_REG_CFG_INVALID.

Change-Id: If3bbd792b56a483022c37ccc2ce82b5ba5c36caa
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Fixes: ac22cdc57322 ("target/adiv5: Large Physical Address Extension")
Reviewed-on: http://openocd.zylin.com/6412
Tested-by: jenkins
Reviewed-by: Daniel Goehring <dgoehrin@os.amperecomputing.com>
2 years agoarm_adi_v5: fix signed offset in Class 0x1 ROM tables 10/6410/3
Antonio Borneo [Wed, 4 Aug 2021 10:25:18 +0000 (12:25 +0200)]
arm_adi_v5: fix signed offset in Class 0x1 ROM tables

In both arm ADIv5 and ADIv6 documentation, for both Class 0x1 and
Class 0x9 ROM tables, the offset field from ROM tables is supposed
to be a signed value: "Negative values of OFFSET are permitted,
using two’s complement."

The commit ac22cdc57322 ("target/adiv5: Large Physical Address
Extension") extends to 64 bits the addresses while managing the ROM
tables. The offset is read as unsigned and in the former 32 bits
implementation the wrap-around was hiding the need for converting
the offset to signed. The new implementation requires the proper
cast to the offset.

On a STM32F411, without this fix the ROM table dump is incorrectly
reporting addresses out of the 32 bit bus range:
MEM-AP BASE 0xe00ff003
Valid ROM table present
Component base address 0xe00ff000
Peripheral ID 0x00000a0411
Designer is 0x0a0, STMicroelectronics
Part is 0x411, Unrecognized
Component class is 0x1, ROM table
MEMTYPE system memory present on bus
ROMTABLE[0x0] = 0xfff0f003
Component base address 0x1e000e000
                       ^^^^^^^^^^^

Cast the offset before adding it to the base address of the ROM
table.

Change-Id: I8d31fd2b3d657286cb96f8e22fb00842baa728f7
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Fixes: ac22cdc57322 ("target/adiv5: Large Physical Address Extension")
Reviewed-on: http://openocd.zylin.com/6410
Tested-by: jenkins
Reviewed-by: Daniel Goehring <dgoehrin@os.amperecomputing.com>
2 years agohelper/align.h: use it 75/6375/3
Antonio Borneo [Thu, 13 May 2021 22:48:31 +0000 (00:48 +0200)]
helper/align.h: use it

Use the new helper to make the code more readable.

Change-Id: I11b2a79dbc6f93f6cfde382bcc00dd7ff710d908
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6375
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2 years agohelper: add align.h 74/6374/3
Antonio Borneo [Thu, 13 May 2021 17:07:50 +0000 (19:07 +0200)]
helper: add align.h

OpenOCD has to often align values or check for alignment.
Use a dedicated set of macros instead of reinventing the wheel
each time.

Change-Id: Ia58711608aae0801deeaccb5f33148f2073b0bbd
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6374
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2 years agortos: add debug prints for qSymbol lookup 87/6287/3
Jan Matyas [Thu, 3 Jun 2021 14:55:50 +0000 (16:55 +0200)]
rtos: add debug prints for qSymbol lookup

- Added two debug prints that allow to inspect the symbol
  lookup process (carried out via the qSymbol packets).

- Added a check for an edge situation when the debugger
  would send us different symbol than what we asked for
  (avoids NULL dereference).

Change-Id: I84ae1b2b66473eab76a7966c678d2777b6ef48d6
Signed-off-by: Jan Matyas <matyas@codasip.com>
Reviewed-on: http://openocd.zylin.com/6287
Tested-by: jenkins
Reviewed-by: Tim Newsome <tim@sifive.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2 years agoflash/nor/atsamv: fixed "maybe uninitialized" compiler warning 90/6290/2
Jan Matyas [Fri, 4 Jun 2021 08:19:29 +0000 (10:19 +0200)]
flash/nor/atsamv: fixed "maybe uninitialized" compiler warning

This warning about "maybe uninitialized" variable
used to pop up on certain versions of GCC.

Change-Id: I1cf43b9600885d507afc1dc042322a06751fe146
Signed-off-by: Jan Matyas <matyas@codasip.com>
Reviewed-on: http://openocd.zylin.com/6290
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)