openocd/src/flash
Tomas Vanek 13cd75b6ec flash/nor/stm32xx: fix segfault accessing Cortex-M part number
Some of STM32 flash drivers read Cortex-M part number from
cortex_m->core_info.
In corner cases the core_info pointer was observed uninitialised
even if target_was_examined() returned true. See also [1]

Use the new and safe helper to get Cortex-M part number.

While on it switch also target_to_cm()/target_to_armv7m() to the safe
versions. This prevents a crash when the flash bank is misconfigured
with non-Cortex-M target.

Add missing checks for target_was_examined() to flash probes.

[1] 6545: fix crash in case cortex_m->core_info is not set
    https://review.openocd.org/c/openocd/+/6545

Change-Id: If2471af74ebfe22f14442f48ae109b2e1bb5fa3b
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Fixes: f5898bd93f (flash/stm32fxx.c: do not read CPUID as this info is stored in cortex_m_common)
Reviewed-on: https://review.openocd.org/c/openocd/+/6752
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2022-02-25 20:28:02 +00:00
..
nand openocd: use single line for register_commands*() 2021-11-23 11:03:38 +00:00
nor flash/nor/stm32xx: fix segfault accessing Cortex-M part number 2022-02-25 20:28:02 +00:00
common.c openocd: fix simple cases of NULL comparison 2021-07-24 10:37:49 +01:00
common.h Cleanup of config/includes. 2021-05-01 14:35:09 +01:00
Makefile.am mflash: Remove this broken flash driver 2019-07-28 21:17:47 +01:00
startup.tcl flash/nor/stm32f1x: Add support for GD32E23x 2021-11-15 15:35:50 +00:00