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
19menuconfig 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 || \
54			   SOC_SERIES_STM32G4X || SOC_SERIES_STM32F7X || \
55			   SOC_SERIES_STM32H7X
56	select FLASH_HAS_EX_OP
57	default n
58	help
59	  Enables flash extended operation for enabling/disabling flash readout
60	  protection.
61
62config FLASH_STM32_READOUT_PROTECTION_DISABLE_ALLOW
63	bool "Allow disabling readout protection"
64	depends on FLASH_STM32_READOUT_PROTECTION
65	default n
66	help
67	  With this option enabled it will be possible to disable readout
68	  protection. On STM32 devices it will trigger flash mass erase!
69
70config FLASH_STM32_READOUT_PROTECTION_PERMANENT_ALLOW
71	bool "Allow enabling readout protection permanently"
72	depends on FLASH_STM32_READOUT_PROTECTION
73	default n
74	help
75	  With this option enabled it will be possible to enable readout
76	  protection permanently.
77
78config FLASH_STM32_BLOCK_REGISTERS
79	bool "Extended operation for blocking option and control registers"
80	select FLASH_HAS_EX_OP
81	default n
82	help
83	  Enables flash extended operations that can be used to disable access
84	  to option and control registers until reset. Disabling access to these
85	  registers improves system security, because flash content (or
86	  protection settings) can't be changed even when exploit was found.
87
88config FLASH_STM32_OPTION_BYTES
89	bool "Extended operation for option bytes access"
90	select FLASH_HAS_EX_OP
91	default n
92	help
93	  Enables flash extended operations that can be used to read and write
94	  STM32 option bytes.
95
96config USE_MICROCHIP_QSPI_FLASH_WITH_STM32
97	bool "Include patch for Microchip qspi flash when running with stm32"
98	depends on DT_HAS_ST_STM32_QSPI_NOR_ENABLED
99	help
100	  Set to use Microchip qspi flash memories which supports
101	  the Global Block Protection Unlock instruction (ULBPR - 98H),
102	  and write with SPI_NOR_CMD_PP_1_1_4 on 4 lines
103
104endif # SOC_FLASH_STM32
105