Skip to content

Commit 03e2bc0

Browse files
tarek-bochkatitom-van
authored andcommitted
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 <[email protected]> Reviewed-on: http://openocd.zylin.com/6107 Tested-by: jenkins Reviewed-by: Tomas Vanek <[email protected]>
1 parent b8fd9ae commit 03e2bc0

File tree

2 files changed

+400
-56
lines changed

2 files changed

+400
-56
lines changed

doc/openocd.texi

+14
Original file line numberDiff line numberDiff line change
@@ -7249,6 +7249,20 @@ Area A for bank 1. The above example set WRP1AR_END=255, WRP1AR_START=0.
72497249
This will effectively write protect all sectors in flash bank 1.
72507250
@end deffn
72517251

7252+
@deffn Command {stm32l4x wrp_info} num [device_bank]
7253+
List the protected areas using WRP.
7254+
The @var{num} parameter is a value shown by @command{flash banks}.
7255+
@var{device_bank} parameter is optional, possible values 'bank1' or 'bank2',
7256+
if not specified, the command will display the whole flash protected areas.
7257+
7258+
@b{Note:} @var{device_bank} is different from banks created using @code{flash bank}.
7259+
Devices supported in this flash driver, can have main flash memory organized
7260+
in single or dual-banks mode.
7261+
Thus the usage of @var{device_bank} is meaningful only in dual-bank mode, to get
7262+
write protected areas in a specific @var{device_bank}
7263+
7264+
@end deffn
7265+
72527266
@deffn Command {stm32l4x option_load} num
72537267
Forces a re-load of the option byte registers. Will cause a system reset of the device.
72547268
The @var{num} parameter is a value shown by @command{flash banks}.

0 commit comments

Comments
 (0)