Commit graph zephyr/drivers/flash
Author SHA1 Message Date
Sylvio Alves
25f062f8a5 soc: espressif: add hidden appcpu target kconfig symbol
Add SOC_ESP32_APPCPU_TARGET, a hidden symbol set whenever the
build targets the APPCPU image of a dual-core SoC. Replace all
places that checked SOC_ESP32_APPCPU and SOC_ESP32S3_APPCPU
together with the new symbol.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2026-07-30 17:40:08 -04:00
Etienne Carriere
aa3187f793 drivers: Include include/zephyr/sys/clock.h
Header file include/zephyr/sys_clock.h is deprecated and will be removed
someday. Update the whole file tree to include zephyr/sys/clock.h
straight instead of zephyr/sys_clock.h.

This change was made running the sed shell command below:
$ sed -i 's/zephyr\/sys_clock\.h/zephyr\/sys\/clock\.h/' \
      `grep -rsl "zephyr/sys_clock\.h" drivers/`

Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
2026-07-30 07:45:05 -05:00
Benjamin Cabé
82b36fc2cc drivers: flash: stm32h7: Use bank2 ECC flags for bank2 status
The dual-bank error check read SR2 but tested the bank1 ECC error
flags, so bank2 ECC errors were reported based on bank1 bits. Use
the bank2 flags like the rest of the bank2 block.

Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-07-29 08:14:16 -07:00
Laura Carlesso
48ba390762 drivers: flash: Add get_size to infineon serial memory
The driver did not implement the get_size api, added
the function to the device api.

Signed-off-by: Laura Carlesso <laura.carlesso@infineon.com>
2026-07-29 10:47:24 +02:00
Laura Carlesso
7d36c5231f drivers: flash: Impose alignment on Infineon RRAM operations
The RRAM driver was allowing unaligned operations for erase
and write because the underlying PDL driver would correct the
operation doing read-modify-write. Rather than relying on the
lower level implementation to correct the alignements and due
to the fact that the flash apis specifically state that alignment
must be checked, added the check and returned error for
unaligned operations.

Signed-off-by: Laura Carlesso <laura.carlesso@infineon.com>
2026-07-29 10:47:24 +02:00
Old Ding
e4765c6ae1 drivers: flash: free Cadence NAND read page buffers
cadence_nand_read_page() allocates main and spare buffers before
submitting the read-page command. Free both buffers on every exit path so
repeated reads do not leak host memory.

Signed-off-by: Old Ding <ai.neo.ae86@gmail.com>
2026-07-29 10:42:43 +02:00
Tim Lin
dbc5448bcb drivers/flash: it51xxx: Retrieve flash info based on the selected flash
Previously, flash parameters (size, erase/write block size) were
hardcoded for internal flash only.

Introduce struct flash_info and update_flash_info() to dynamically
resolve flash parameters based on the active flash target (internal,
external CS0/CS1).

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2026-07-23 21:03:57 -07:00
Travis Lam
208748bd0b driver: flash: nrf_mramc driver allow to read tfm secure memory
Implement soc_secure_mem_read for flash driver to read secure memory,
access to the range of secure memory from non secure side should be
governed by tfm_platform allow list, implementation aligns to nrf_rram
driver secure memory read.

Signed-off-by: Travis Lam <travis.lam@nordicsemi.no>
2026-07-23 18:15:41 +02:00
Benjamin Santon
0ee70dc677 drivers: flash: max32: spixf: fix 4-byte address mode
Use flag_access_32bit from device data to select
MXC_SPIXF_Set4ByteAddr() or MXC_SPIXF_Set3ByteAddr() accordingly.

Signed-off-by: Benjamin Santon <benjamin.santon@analog.com>
2026-07-22 19:07:28 +01:00
Benjamin Cabé
0a5bbe5524 drivers: flash: si32: Fix alignment check return values
flash_si32_valid_range() returns bool, but the write alignment
checks returned -EINVAL, which converts to true and marks
misaligned writes as valid. An odd size then made the write loop
read one byte past the source buffer. Return false as the other
checks do.

Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-07-22 11:12:10 +01:00
Dhanoo Surasarang
390259c1cd drivers: flash: nrf_mramc: Resolve MRAM node from DT instance
The driver hardcodes DT_NODELABEL(cpuapp_mram) which does not exist
when building for cpuflpr since the node is deleted in the cpuflpr
dtsi. Use DT_INST(0, soc_nv_flash) to resolve whichever soc-nv-flash
child is present under the controller, matching the RRAM driver.

Signed-off-by: Dhanoo Surasarang <dhanoo.surasarang@nordicsemi.no>
2026-07-21 14:09:29 -04:00
Richard Wheatley
24ac9afbd6 drivers: mspi: rename MSPI_XIP to MSPI_MEMMAP
XIP in Zephyr is a software configuration concept (CONFIG_XIP). The MSPI
feature gated by MSPI_XIP only memory-maps the device into the SoC
address space; the mapped region can be used for plain data access as
well as code execution. Rename the feature to MEMMAP to reflect what it
actually does:

- CONFIG_MSPI_XIP -> CONFIG_MSPI_MEMMAP
- CONFIG_FLASH_MSPI_XIP_READ -> CONFIG_FLASH_MSPI_MEMMAP_READ
- struct mspi_xip_cfg -> struct mspi_memmap_cfg
- enum mspi_xip_permit / MSPI_XIP_READ_* -> mspi_memmap_permit /
  MSPI_MEMMAP_READ_*
- mspi_xip_config() -> mspi_memmap_config(), driver API entry
  xip_config -> memmap_config
- MSPI_XIP_CONFIG_DT{,_INST,_NO_CHECK} -> MSPI_MEMMAP_CONFIG_DT{,...}
- MSPI_XIP_CFG_STRUCT_DECLARE / MSPI_XIP_BASE_ADDR_{DECLARE,INIT} ->
  MSPI_MEMMAP_*
- devicetree property xip-config -> memmap-config

Vendor HAL symbols (am_hal_mspi_xip_*) and DesignWare register names,
where XIP is the hardware documentation terminology, are unchanged.

The MSPI API is experimental, so no deprecated aliases are provided;
a migration guide entry is added in a separate commit. Add missing
Doxygen comments on new API symbols. Add missing SPDX header to the
nrf54h20dk code_relocation_nocopy overlay touched by this rename.

Fixes #104657

Signed-off-by: Richard Wheatley <richard.wheatley@ambiq.com>
2026-07-18 10:26:30 -04:00
Keith Short
65dec3dbd3 drivers: flash: ite_it8xxx2: add delay in status polling loop
In ramcode_flash_cmd_read_status, the status polling loop continuously
reads SMFI_ECINDDR in RAM without any delay cycles. During flash erase
operations, tight polling can cause bus contention or premature register
evaluation on fast silicon and at higher compiler optimization levels,
resulting in intermittent erase failures (rc=-2).

Add a small delay loop inside the status polling loop to throttle
register reads.

Tested on board with it8xxx2 EC.

Signed-off-by: Keith Short <keithshort@google.com>
2026-07-16 18:10:38 +01:00
Ren Chen
b5fb5c845b drivers: flash: it51xxx_m1k: support write/read protect op-code
Add op-code write/read protect support for it51xxx m1k driver.

Signed-off-by: Ren Chen <Ren.Chen@ite.com.tw>
2026-07-16 10:45:54 -04:00
David Jewsbury
9f5ea9a85e drivers: flash: nrf_mramc: validate against devicetree MRAM size
Previously, the MRAMC uses the NRFX driver which
used the INFO.MRAM register to get the size of
the MRAM. In other parts of the driver, the size
is taken from the devicetree. Also, if running tf-m
the size would be taken from the devicetree. This
commit ensures there's only 1 source of truth so
we only ever use the devicetree. This will also
allow the user to select a smaller MRAM size if
they wanted.

Signed-off-by: David Jewsbury <david.jewsbury@nordicsemi.no>
2026-07-16 10:44:33 -04:00
Daniel DeGrasse
baf2260f63 drivers: flash: add flash driver for pflash with intel command set
Add a basic flash driver for intel pflash. This flash implements a CFI
interface, and is available as "pflash" within QEMU targets.

Assisted-by: Claude:Haiku 4.5
Signed-off-by: Daniel DeGrasse <daniel.degrasse@analog.com>
2026-07-16 14:33:34 +02:00
Flavio Ceolin
58c4e48622 flash: Remove redundant casts in syscall handlers
The syscall handler functions forward parameters with identical casts
that are redundant since the variables already have those types.  Drop
the casts to let the compiler type-check the arguments unobstructed.

Signed-off-by: Flavio Ceolin <flavio@hubble.com>
2026-07-15 19:04:12 -04:00
Abderrahmane JARMOUNI
7cca4bda59 drivers: flash: stm32: rename STM32_MEMMAP to FLASH_STM32_NOR_MEMMAP
Rename CONFIG_STM32_MEMMAP to CONFIG_FLASH_STM32_NOR_MEMMAP for clarity
since it only concerns STM32 Flash drivers.
Same change is applied on MCUboot side upstream.

Signed-off-by: Abderrahmane JARMOUNI <git@jarmouni.me>
2026-07-15 14:45:00 -05:00
Mathieu Choplain
1f1e182ce0 drivers: flash: stm32_*: enable GPIO when reset-gpios are used
Enable the GPIO subsystem when reset-gpios are used on any STM32 QSPI,
OSPI or XSPI flash node and the corresponding driver is enabled.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2026-07-15 15:26:33 +02:00
Michael Zimmermann
e256db718d drivers: flash: gecko: support CONFIG_MULTITHREADING=n
This is useful to reduce the size of mcuboot builds, so it can fit into the
16K bootloader flash area outside of the main flash, which many Silabs SoCs
have.

Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
2026-07-14 20:08:08 -04:00
Anas Nashif
2b0713959e drivers: flash: fix flash_sim memory-region section name
Use LINKER_DT_NODE_REGION_NAME_TOKEN() when assigning the flash simulator
backing array section.

Using LINKER_DT_NODE_REGION_NAME() passes a quoted string into
Z_GENERIC_SECTION(), which produces a literal section named "FlashSim"
instead of FlashSim. The linker memory-region section matcher expects the
token form, so the array was not placed in the configured RAM region.

This is needed to be able to build with zephyr/llvm on some platforms.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-07-14 17:58:51 +02:00
Daniel DeGrasse
d4a941962d drivers: flash: soc_flash_rv32m1: use legacy method to get flash node
Use legacy method to get the SOC flash node for the rv32m1 flash driver,
because users of this flash driver define multiple child nodes with the
soc-nv-flash compatible. This prevents use of the
SOC_NV_FLASH_CHILD_NODE helper macro, which relies on one compatible
with the child being present.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@analog.com>
2026-07-13 11:36:19 -07:00
Daniel DeGrasse
7acfb6145f drivers: flash: unify SOC_NV_FLASH_NODE logic
Many drivers in tree use a similar pattern to find their child node with
the compatible "soc-nv-flash". Rather than continuing to duplicate this
logic, define a common handler that is instance based in the flash_priv
header file, and include this from each flash driver.

Assisted-by: Claude: claude-opus-4-6
Signed-off-by: Daniel DeGrasse <daniel.degrasse@analog.com>
2026-07-13 16:42:32 +02:00
Laura Carlesso
dc3af391c5 drivers: flash: Correct secure/nonsecure alias for registers
The flash_controller node is defined using the non secure
alias regster. Add a macro to switch between the secure
and non secure one correctly.
Also properly call the serial_memory_setup function to
init the object.

Signed-off-by: Laura Carlesso <laura.carlesso@infineon.com>
2026-07-10 08:52:54 -05:00
Swift Tian
ed16d687b5 drivers: mspi: update compat string in device drivers
The compat string is updated in device drivers to align with
changes in binding files.
Added depends on $(dt_compat_on_bus,$(DT_COMPAT_[DEVICE]),mspi)
to device Kconfig.

Signed-off-by: Swift Tian <swift.tian@ambiq.com>
2026-07-10 08:51:14 -05:00
Richard Wheatley
3a3a9c1d7e drivers: flash: ambiq: rework locking and add multi-SoC support
Switch from a binary semaphore to a mutex with priority inheritance.
Write in chunks (~128 B) so ISRs can run between chunks. Add per-operation
retry logic (up to 3 attempts) to handle transient voltage drops. Add cache
invalidation after write/erase on SoCs with D-cache. Extend HAL dispatch
to cover Apollo2x/3x (am_hal_flash), Apollo4x, and Apollo5x (MRAM).

Signed-off-by: Richard Wheatley <richard.wheatley@ambiq.com>
2026-07-09 07:58:28 +02:00
Camille BAUD
a0473c3a2f drivers: bflb: extend shared drivers with BL616CL support
Add support for BL616CL in shared drivers

Signed-off-by: Camille BAUD <mail@massdriver.space>
2026-07-08 10:01:48 +02:00
Josuah Demangeon
94d2ebbab1 drivers: flash: bflb: tune comment
Adjust comment QO -> QIO.

Signed-off-by: Josuah Demangeon <me@josuah.net>
2026-07-06 14:49:59 +01:00
Josuah Demangeon
86c195b2a1 drivers: flash: bflb: make flash_bflb_set_sahb() return void
The return value of flash_bflb_set_sahb() is not used so make it return
void instead.

Signed-off-by: Josuah Demangeon <me@josuah.net>
2026-07-06 14:49:59 +01:00
Jamie McCrae
e450f93551 soc: ambiq: kconfig: Fix invalid use of Kconfig defaults
If a SoC has defaults, it should apply them, not using weird
variable substitution

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-07-02 13:06:40 +01:00
Laura Carlesso
4fbf56d6cb drivers: flash: update infineon SMIF driver
Correct serial memory qspi init to skip serial memory setup
when not explicitly needed, to avoid SMIF init in XIP mode.
The full fix for this issue will be finalized with issue 112066.

Signed-off-by: Laura Carlesso <laura.carlesso@infineon.com>
Signed-off-by: Davide Di Lello <Davide.Dilello@Infineon.com>
2026-06-30 18:21:29 -04:00
Laura Carlesso
a00c17fbfd drivers: flash: add infineon RRAM driver
Added RRAM driver support.

Signed-off-by: Davide Di Lello <Davide.Dilello@Infineon.com>
Signed-off-by: Laura Carlesso <laura.carlesso@infineon.com>
2026-06-30 18:21:29 -04:00
Etienne Carriere
b0b25c35c9 drivers: use <> to include Zephyr headers instead of ""
Use <> operator to include a Zephyr header file instead of "" that
is intended to local header files, not header files relative to
specifically defined search paths.

This change was made running the sed shell command below:
$ sed -i -E 's/#include "zephyr\/([^"]+)\.h"/#include <zephyr\/\1.h>/g' \
    `grep -rsl "#include \"zephyr/" drivers/`

Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
2026-06-30 06:49:18 -04:00
Jordan Yates
deb92718cc flash: remove select FLASH_PAGE_LAYOUT from drivers
Remove `select FLASH_PAGE_LAYOUT` from any flash drivers doing so, as
this is an option to enable an API into the flash driver, not something
the flash driver itself needs.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2026-06-29 22:18:24 -04:00
Jakub Zymelka
3cbb7c0e39 drivers: nrf_rram: hoist RRAMC write-mode programming to nrf_write()
Move the configure/de-configure pair from rram_write() up to nrf_write(),
where SYNC_LOCK guarantees exclusive access for the duration of the
whole API call. The hardware write mode is then programmed exactly
once per flash_write()/flash_erase() in the standalone (non-radio-sync)
path, regardless of how many chunks the throttling loop produces.

Behaviour for non-secure (TF-M) builds is unchanged: RRAMC config is
still programmed by TF-M at boot and never touched here.

Signed-off-by: Jakub Zymelka <jakub.zymelka@nordicsemi.no>
2026-06-29 09:16:40 +02:00
Jakub Zymelka
f223f34607 drivers: flash: nrf_rram: don't advance data pointer in erase emulation
When CONFIG_SOC_FLASH_NRF_THROTTLING is enabled, the chunking loop in
rram_write() unconditionally advances the source pointer by chunk_len
at the end of every iteration. This turns the originally-NULL pointer
into chunk_len, then 2*chunk_len, ... by the start of subsequent
iterations.

The bug only triggers when:

  - CONFIG_SOC_FLASH_NRF_THROTTLING=y
  - the erase length is greater than
    CONFIG_NRF_RRAM_THROTTLING_DATA_BLOCK * 16 (default 256 B)

Guard the data pointer advance with an explicit data != NULL check so
the erase emulation path stays on the memset() branch for every
chunk.

Signed-off-by: Jakub Zymelka <jakub.zymelka@nordicsemi.no>
2026-06-29 09:16:40 +02:00
Jakub Zymelka
47cf797517 drivers: flash: nrf_rram: fix commit_changes() with throttling enabled
When CONFIG_SOC_FLASH_NRF_THROTTLING is enabled, the inner chunking
loop in rram_write() decrements `len` to 0 and advances `addr` past
the end of the user buffer. The commit_changes() call that follows
then always sees `len == 0`, so the modulo-WRITE_BUFFER_MAX_SIZE
check at the top of commit_changes() returns early and the explicit
NRF_RRAMC_TASK_COMMIT_WRITEBUF is never triggered.

For sub-buffer writes (e.g. flash_write of 32 B with a 512 B buffer)
the partially-filled write buffer is then only flushed by the
READYNEXTTIMEOUT auto-commit (~4 us), which means data is not yet in
physical RRAM when the API returns. That breaks callers that rely on
write persistence on return.

Capture the original `addr` and `len` once before the throttling loop
mutates them and pass those values to commit_changes(), matching the
behaviour the non-throttled path always had.

Signed-off-by: Jakub Zymelka <jakub.zymelka@nordicsemi.no>
2026-06-29 09:16:40 +02:00
Dilip Raman
35cb4e769b drivers: flash: soc_flash_lpc84x_iap: enable support for lpc84x IAP
Add support for LPC84x IAP Flash driver to soc_flash_lpc84x_iap.c

Signed-off-by: Dilip Raman <dilipr@aerlync.com>
Signed-off-by: Sayooj K Karun <sayooj@aerlync.com>
2026-06-26 14:23:10 +01:00
David Jewsbury
601d436820 drivers: flash: mramc: Add singlethreaded support
Adds conditional usage of mutex's to allow building
when CONFIG_MULTITHREADING=n

Signed-off-by: David Jewsbury <david.jewsbury@nordicsemi.no>
2026-06-25 10:26:58 -07:00
Tim Pambor
4254b8041c flash: spi_nand: add bad block cache
Add a bad block cache by keeping a bad block table in memory.
This will speed up bad block checking at the cost of slightly
increased memory usage of 1 bit per erase block.

Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
2026-06-25 10:24:35 -07:00
Eli Hughes
123c5082f8 flash: mcux flexspi nor: add IS25LP512M support
Add explicit JEDEC handling for the ISSI IS25LP512M. Configure the
FlexSPI LUT for 4-byte Quad I/O reads plus 4-byte page program, sector
erase, and block erase commands.

The IS25LP512M uses nonvolatile SR1 bit 6 as the QE bit, so enable quad
mode with the existing S1B6 helper before using the 1-4-4 read path.

Hardware was verified by clearing SR1 QE from 0x40 to 0x00, setting it
back to 0x40, and passing quad erase/program/readback.

Fixes #111686

Signed-off-by: Eli Hughes <eli.hughes@nxp.com>
2026-06-25 06:18:28 -04:00
Andrzej Głąbek
81e4918804 drivers: flash_mspi_nor: Fix definition of NON_XIP_DEV_CFG_MASK
This is a follow-up to commit d7d1a64e27.

The above commit added `MSPI_DEVICE_CONFIG_IO_MODE` to `XIP_DEV_CFG_MASK`,
but in consequence it removed that bit from `NON_XIP_DEV_CFG_MASK` since
the latter is defined with `& ~XIP_DEV_CFG_MASK`. And that bit must be
present in `NON_XIP_DEV_CFG_MASK`, otherwise the driver will not configure
IO mode as expected in `switch_to_target_io_mode()` and `_acquire()`.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2026-06-25 06:17:32 -04:00
Andrzej Głąbek
ed42a9faf3 Revert "drivers: flash_mspi_nor: fix io mode used by mspi_xip_config()"
This reverts commit 97bfea46a0.

Contrary to what the above commit description says, the change it brings
does not in fact cause IO mode to be switched in the MSPI controller.
That is because `switch_to_target_io_mode()` uses `NON_XIP_DEV_CFG_MASK`
in its call to `mspi_dev_config()` and after recent changes (see commit
d7d1a64e27) that mask does not actually
include the `MSPI_DEVICE_CONFIG_IO_MODE` bit.
Revert the commit as it unnecessarily doubles the operations related to
switching the flash chip to desired IO mode (like the `post_switch_mode`
quirk), without fixing the actual problem with IO mode incorrectly set
in the MSPI controller.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2026-06-25 06:17:32 -04:00
Zhiyuan Tang
115dc1fb1c drivers: flash: add Realtek Bee nor flash driver
Add nor flash drivers for Realtek Bee family SoCs (RTL8752H and RTL87x2G).
Supports read, write, erase operations with page layout support.

Signed-off-by: Zhiyuan Tang <zhiyuan_tang@realsil.com.cn>
2026-06-25 06:15:22 -04:00
Robert Robinson
37ac7aa565 drivers: flash: Add missing header to soc_flash_nrf_mramc.c
kernel.h must be included now that .c file is making use of mutex.

Signed-off-by: Robert Robinson <robert.robinson@nordicsemi.no>
2026-06-24 07:39:39 -04:00
Filip Stojanovic
ae65bef02d drivers: flash: stm32_xspi: guard jedec_id init with JESD216_API
The XSPI_NOR_STM32_INIT macro initialized the jedec_id field
unconditionally when the DT node has a jedec-id property, but
the field in flash_stm32_xspi_data is only declared when
CONFIG_FLASH_JESD216_API is enabled. Guard the initialization
accordingly to fix build failures when jedec-id is present in
DT but CONFIG_FLASH_JESD216_API is not set.

Signed-off-by: Filip Stojanovic <filipembedded@gmail.com>
2026-06-24 11:43:43 +02:00
Camille BAUD
4d7dd3a130 soc: bflb: Atomize code relocation
Handle necessary code relocation better,
clearly delimiting what is required and what is not
Also group RAM together

Signed-off-by: Camille BAUD <mail@massdriver.space>
2026-06-23 17:36:21 -04:00
Camille BAUD
7fed7f6f79 drivers: flash: Update BFLB flash driver
BFLB flash driver is updated:
- Add support for bank 2
- Add support for SFDP
- Add ability to use writable devices (MRAM, PSRAM, FRAM) via bank2 mapping
- Improve overall organization
- Add QPI and continous read support

Signed-off-by: Camille BAUD <mail@massdriver.space>
2026-06-23 17:36:21 -04:00
Etienne Carriere
f23332025f drivers: flash: stm32: report failure on option byte locking error
Correct FLASH_STM32_EX_OP_OPTB_WRITE private flash operation for
stm32 internal flash drivers when unlocking or locking option bytes
fails. flash_stm32_option_bytes_lock() returns non-zero negative error
when so, not a positive error, fix flash_stm32_ex_op() accordingly,
using a comparison against zero, for consistency with other
calls to flash_stm32_option_bytes_lock().

Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
2026-06-22 14:27:50 +02:00
Etienne Carriere
4bc8115568 drivers: flash: stm32: report failure to set RDP level
Change flash_stm32_set_rdp_level() to return an error code when
failing.

Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
2026-06-22 14:27:50 +02:00