1# Flash simulator config
2
3# Copyright (c) 2018 Nordic Semiconductor ASA
4# SPDX-License-Identifier: Apache-2.0
5
6menuconfig FLASH_SIMULATOR
7	bool "Flash simulator"
8	default y
9	depends on DT_HAS_ZEPHYR_SIM_FLASH_ENABLED
10	select FLASH_HAS_PAGE_LAYOUT
11	select FLASH_HAS_DRIVER_ENABLED
12	help
13	  Enable the flash simulator.
14
15if FLASH_SIMULATOR
16
17config FLASH_SIMULATOR_UNALIGNED_READ
18	bool "Allow read access to be unaligned"
19	default y
20	help
21	 If selected, the reading operation does not check if access is aligned.
22	 Disable this option only if you want to simulate
23	 a specific FLASH interface that requires aligned read access.
24
25config FLASH_SIMULATOR_EXPLICIT_ERASE
26	bool "Program-erase device"
27	select FLASH_HAS_EXPLICIT_ERASE
28	default y
29	help
30	  Explicit erase (non-erase-on-write) Flash, which is device that requires erase
31	  to erase-value prior to write as it only allows to change bits from erase-value
32	  to the opposite.
33
34config FLASH_SIMULATOR_RAMLIKE
35	bool
36	default y if !FLASH_SIMULATOR_EXPLICIT_ERASE
37	select FLASH_HAS_NO_EXPLICIT_ERASE
38	select FLASH_SIMULATOR_DOUBLE_WRITES
39	help
40	  This is used for setting FLASH_HAS_NO_EXPLICIT_ERASE.
41
42config FLASH_SIMULATOR_DOUBLE_WRITES
43	bool "Allow program units to be programmed more than once"
44	help
45	 If selected, writing to a non-erased program unit will succeed, otherwise, it will return an error.
46	 Keep in mind that write operations can only change value of a bit from erase-value to the
47	 opposite.
48	 This option does not impact FLASH_SIMULATOR_RAMLIKE.
49	 In case when FLASH_SIMULATOR_EXPLICIT_ERASE is selected multiple writes to the same bit
50	 but only change from erase-value to opposite will be registered.
51
52config FLASH_SIMULATOR_SIMULATE_TIMING
53	bool "Hardware timing simulation"
54
55if FLASH_SIMULATOR_SIMULATE_TIMING
56
57config FLASH_SIMULATOR_MIN_READ_TIME_US
58	int "Minimum read time (µS)"
59	default 2
60	range 1 1000000
61
62config FLASH_SIMULATOR_MIN_WRITE_TIME_US
63	int "Minimum write time (µS)"
64	default 100
65	range 1 1000000
66
67config FLASH_SIMULATOR_MIN_ERASE_TIME_US
68	int "Minimum erase time (µS)"
69	default 2000
70	range 1 1000000
71
72endif
73
74config FLASH_SIMULATOR_STATS
75	bool "flash operations statistic"
76	default y
77	select STATS
78	select STATS_NAMES
79	help
80	  Gather statistic measurement for flash simulator operations using the
81	  statistic subsystem.
82
83config FLASH_SIMULATOR_STAT_PAGE_COUNT
84	int "Pages under statistic"
85	depends on FLASH_SIMULATOR_STATS
86	range 1 256
87	default 256
88	help
89	  Only up to this number of beginning pages will be tracked
90	  while catching dedicated flash operations and thresholds.
91	  This number is not automatic because implementation uses
92	  UNTIL_REPEAT() macro, which is limited to take explicitly
93	  number of iterations.
94	  This is why it's not possible to calculate the number of pages with
95	  preprocessor using DT properties.
96
97endif # FLASH_SIMULATOR
98