Skip to content

Commit 417368e

Browse files
duda-patrykfabiobaltieri
authored andcommitted
drivers: flash: Add support for defining custom RDP1 byte value
This patch makes possible to choose custom byte which should be used to enable non-permanent readout protection (RDP1). Actually, any byte except 0xAA and 0xCC (which are used by RDP0 and RDP2 respectively) can be used to enable RDP1 but in multi-image environment, some other image could check if RDP1 is enabled by comparing it to some hardcoded value. If property is not defined, 0x55 will be used to enable RDP1. The default value comes from STM32 HAL. Signed-off-by: Patryk Duda <[email protected]>
1 parent d652da5 commit 417368e

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

drivers/flash/flash_stm32.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,13 @@ struct flash_stm32_priv {
226226
FLASH_STM32_SR_PGPERR)
227227

228228
#define FLASH_STM32_RDP0 0xAA
229-
#define FLASH_STM32_RDP1 0x55
230229
#define FLASH_STM32_RDP2 0xCC
230+
#define FLASH_STM32_RDP1 \
231+
DT_PROP(DT_INST(0, st_stm32_flash_controller), st_rdp1_enable_byte)
232+
233+
#if FLASH_STM32_RDP1 == FLASH_STM32_RDP0 || FLASH_STM32_RDP1 == FLASH_STM32_RDP2
234+
#error RDP1 byte has to be different than RDP0 and RDP2 byte
235+
#endif
231236

232237
#ifdef CONFIG_FLASH_PAGE_LAYOUT
233238
static inline bool flash_stm32_range_exists(const struct device *dev,

dts/bindings/flash_controller/st,stm32-flash-controller.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,15 @@ description: STM32 Family flash controller
33
compatible: "st,stm32-flash-controller"
44

55
include: flash-controller.yaml
6+
7+
properties:
8+
st,rdp1-enable-byte:
9+
type: int
10+
default: 0x55
11+
description: |
12+
This property provides a byte which should used to enable non-permanent
13+
readout protection (RDP1). Actually, any byte except 0xAA and 0xCC
14+
(which are used by RDP0 and RDP2 respectively) can be used to enable
15+
RDP1 but in multi-image environment, some other image could check if
16+
RDP1 is enabled by comparing it to some hardcoded value. The byte has to
17+
be different than 0xAA and 0xCC.

0 commit comments

Comments
 (0)