1# ST Microelectronics STM32 MCUs Flash driver config
2
3# Copyright (c) 2016 RnDity Sp. z o.o.
4# Copyright (c) 2017 BayLibre, SAS
5# Copyright (c) 2022 Linaro Limited
6# Copyright (c) 2023 Google Inc
7# SPDX-License-Identifier: Apache-2.0
8
9config STM32_MEMMAP
10	bool "NOR Flash in MemoryMapped for XiP"
11	depends on XIP && \
12		    (DT_HAS_ST_STM32_OSPI_NOR_ENABLED || \
13		     DT_HAS_ST_STM32_QSPI_NOR_ENABLED || \
14		     DT_HAS_ST_STM32_XSPI_NOR_ENABLED)
15	help
16	  This option enables the XIP mode for the external NOR flash
17	  mounted on STM32 boards.
18
19config SOC_FLASH_STM32
20	bool "STM32 flash driver"
21	depends on DT_HAS_ST_STM32_FLASH_CONTROLLER_ENABLED
22	select FLASH_HAS_DRIVER_ENABLED
23	default y
24	select FLASH_HAS_PAGE_LAYOUT
25	select FLASH_HAS_EXPLICIT_ERASE
26	select MPU_ALLOW_FLASH_WRITE if ARM_MPU
27	select USE_STM32_HAL_FLASH if BT_STM32WBA
28	select USE_STM32_HAL_FLASH_EX if BT_STM32WBA
29	help
30	  Enable flash driver for STM32 series
31
32if SOC_FLASH_STM32
33
34config FLASH_STM32_WRITE_PROTECT
35	bool "Extended operation for flash write protection control"
36	depends on SOC_SERIES_STM32F4X
37	select FLASH_HAS_EX_OP
38	default n
39	help
40	  Enables flash extended operation for enabling/disabling flash write
41	  protection.
42
43config FLASH_STM32_WRITE_PROTECT_DISABLE_PREVENTION
44	bool "Prevent from disabling flash write protection"
45	depends on FLASH_STM32_WRITE_PROTECT
46	default n
47	help
48	  If enabled, all requests to disable flash write protection will be
49	  blocked.
50
51config FLASH_STM32_READOUT_PROTECTION
52	bool "Extended operation for flash readout protection control"
53	depends on SOC_SERIES_STM32F4X || SOC_SERIES_STM32L4X || SOC_SERIES_STM32G4X
54	select FLASH_HAS_EX_OP
55	default n
56	help
57	  Enables flash extended operation for enabling/disabling flash readout
58	  protection.
59
60config FLASH_STM32_READOUT_PROTECTION_DISABLE_ALLOW
61	bool "Allow disabling readout protection"
62	depends on FLASH_STM32_READOUT_PROTECTION
63	default n
64	help
65	  With this option enabled it will be possible to disable readout
66	  protection. On STM32 devices it will trigger flash mass erase!
67
68config FLASH_STM32_READOUT_PROTECTION_PERMANENT_ALLOW
69	bool "Allow enabling readout protection permanently"
70	depends on FLASH_STM32_READOUT_PROTECTION
71	default n
72	help
73	  With this option enabled it will be possible to enable readout
74	  protection permanently.
75
76config FLASH_STM32_BLOCK_REGISTERS
77	bool "Extended operation for blocking option and control registers"
78	select FLASH_HAS_EX_OP
79	default n
80	help
81	  Enables flash extended operations that can be used to disable access
82	  to option and control registers until reset. Disabling access to these
83	  registers improves system security, because flash content (or
84	  protection settings) can't be changed even when exploit was found.
85
86endif # SOC_FLASH_STM32
87