flash/stm32l4x: enhance protect handler to use efficiently all WRP areas 07/6107/5
authorTarek BOCHKATI <tarek.bouchkati@gmail.com>
Mon, 2 Nov 2020 23:50:24 +0000 (00:50 +0100)
committerTomas Vanek <vanekt@fbl.cz>
Wed, 24 Mar 2021 17:18:04 +0000 (17:18 +0000)
commit03e2bc0f3b12c45f9b537bece1fef0520c2298bd
treefd00d90e2d3b2021929c4cfaab9dcc4bb8478592
parentb8fd9aecb12a5d930cf3e3e09cede4cd6787e847
flash/stm32l4x: enhance protect handler to use efficiently all WRP areas

stm32l4_protect: was using one WRP area per bank, without checking
if it is already protecting some sectors.
protection algo is more complicated than that, before using a WRP area
we should check if it is already used, then either reuse it for extension
(or reduction) or use a free area.

introduce a new command: stm32l4x wrp_info bank_num ['bank1'|'bank2']
this command lists the protected areas using WRP.

Note: for some devices like STM32L4R/S in single bank mode, all 4 WRP areas
are usable for that bank, to manage this case an attribute 'use_all_wrpxx'
was introduced into stm32l4_part_info and used later in protection handlers

example usage:
$ telnet localhost 4444
> flash probe 0
  device idcode = 0x10036470 (STM32L4R/L4Sxx - Rev: Y)
  flash size = 2048kbytes
  flash mode : dual-bank
  flash 'stm32l4x' found at 0x08000000
> stm32l4x wrp_info 0
  no protected areas
> flash protect 0 0 4 on
  set protection for sectors 0 through 4 on flash bank 0
> flash protect 0 8 9 on
  set protection for sectors 8 through 9 on flash bank 0
> stm32l4x wrp_info 0
  protected areas: [0,4][8,9]
> flash protect 0 6 6 on
  the device WRPxy are not enough to set the requested protection
  failed setting protection for blocks 6 to 6
> flash protect 0 3 5 on
  set protection for sectors 3 through 5 on flash bank 0
> stm32l4x wrp_info 0
  protected areas: [0,5][8,9]
> flash protect 0 6 7 on
  set protection for sectors 6 through 7 on flash bank 0
> stm32l4x wrp_info 0
  protected areas: [0,9]
> flash protect 0 5 6 off
  cleared protection for sectors 5 through 6 on flash bank 0
> stm32l4x wrp_info 0
  protected areas: [0,4][7,9]

Change-Id: I42bd84fa66edd93406e18c6d89310faa5267ffa7
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/6107
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
doc/openocd.texi
src/flash/nor/stm32l4x.c

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)