Commit graph

1299 commits

Author SHA1 Message Date
Thomas Altenbach
c4afaaacf6 drivers: flash: stm32_qspi: Fix status register access for dual-flash
When dual-flash mode is enabled, two identical flash memories are
connected to the QUADSPI peripheral, each having its own set of
registers. This means that when reading or writing a flash register,
this has to be made for both flash memories.

For example, when reading a status register (1 byte), the QUADSPI
peripheral must be configured to read two bytes of data, which
correspond respectively to the value of the register in the first and
second flash memory. Same thing when writing.

Before this commit, when dual-flash mode was enabled, only the register
of the first flash memory was considered, which means the second flash
memory could be incorrectly configured and that any write/erase
operation could be considered as completed too early, if the operation
takes more time to complete for the second flash memory.

Signed-off-by: Thomas Altenbach <altenbach.thomas@gmail.com>
2025-07-23 09:32:22 +02:00
Thomas Altenbach
f9f6b24166 drivers: flash: stm32_qspi: Factorize all status register reads
The 'qspi_read_status_register' routine implements the reading of a
flash memory's status register. This routine is used anytime reading a
status register is needed, except in 'qspi_wait_until_ready'. This
commit moves the read routine to be able to use it in
'qspi_wait_until_ready'. The 'qspi_write_status_register' is also moved
to keep it close to the read routine.

Signed-off-by: Thomas Altenbach <altenbach.thomas@gmail.com>
2025-07-23 09:32:22 +02:00
Thomas Altenbach
20beb3eb74 drivers: flash: stm32_qspi: Simplify #ifdef for dual-flash
In multiple places, "#if DT_PROP(DT_NODELABEL(quadspi), dual_flash) &&
defined(QUADSPI_CR_DFM)" was used to guard sections specific to
the dual-flash feature. This is quite long and "#ifdef
STM32_QSPI_DOUBLE_FLASH" is now used instead.

Note the presence of QUADSPI_CR_DFM is no more checked. This is not
considered as an issue since when QUADSPI_CR_DFM is not available, the
QSPI hardware doesn't support dual-flash mode so this mode must not be
enabled in the devicetree. With that change, enabling dual-flash mode
when not available causes a compile-time error.

Signed-off-by: Thomas Altenbach <altenbach.thomas@gmail.com>
2025-07-23 09:32:22 +02:00
Dawid Niedzwiecki
6d5cdbb13e drivers: flash: add andes qspi xip flash driver
Add a flash driver that is used to perform flash operations on a flash
chip that is connected to an Andes QSPI controller and is used for XIP
mode.

The driver is as small as possible, because necessary code has to be
placed in RAM. It is not possible to fetch code from flash while
performing erase/write operations.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2025-07-23 09:30:33 +02:00
Travis Lam
f94a45c276 drivers: flash: nordic: Introduce nrf_mramc driver
Add SHIM layer for nrfx_mramc driver for zephyr

Signed-off-by: Travis Lam <travis.lam@nordicsemi.no>
2025-07-21 09:19:45 -04:00
Declan Snyder
efdd8580ca soc: nxp: Flatten MCX SOCs
Turn MCX series into families.

Reasoning:
 1. The MCX SOCs are quite different from each other and having them all
    under one family in the HWMv2 hierarchy is fruitless because there
    are so many differences that it is confusing to try to introduce
    family-level code and configs since they would each only apply to a
    subset of the series. There is almost nothing that can be shared
    between all of them. Which is why there are comments in the MCX
    family files saying not to put anything in them. This is a technical
    waste.
 2. Therefore, turning all of them into families is almost 0 effort and
    makes sense. It will allow these different types of MCX to be
    further subdivided into series in the future as the MCX portfolio
    expands and such division will be necessary as new SOCs within each
    letter family are released.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-07-19 13:25:29 -04:00
Pete Johanson
02fa84565a drivers: flash: Enable static/runtime SFDP data for SPIXF driver
Add a new flash for toggling runtime SFDP data fetching, and use static
devicetree properties by default. Clean up various minor items from review.

Signed-off-by: Pete Johanson <pete.johanson@analog.com>
2025-07-19 10:08:46 +02:00
Pete Johanson
3821e5db62 drivers: flash: Support XIP for MAX32 SPIXF flash
Properly configure the MAX32 SPIXF peripheral to use the SPIXF controller
for transparent memory mapped reads, and enable the SPIXF main controller
and use it for writes.

Add support for testing XIP support to the nocopy sample, which requires
flashing with OpenOCD with MAX32690 QSPI flash support.

Signed-off-by: Pete Johanson <pete.johanson@analog.com>
2025-07-19 10:08:46 +02:00
Pete Johanson
ecf7f846ae drivers: flash: Add MAX32 SPIXF NOR flash driver
Implement support for NOR flash on the SPIXF peripheral found
on MAX32 devices.

Signed-off-by: Pete Johanson <pete.johanson@analog.com>
2025-07-19 10:08:46 +02:00
Francois Ramu
2345bc996a drivers: flash: stm32 xspi flash driver skip init when executing in place
The flash_stm32_xspi driver should not initialize the xspi,
if this one is being use to execute in Place : the init is skipped.
This mode is identified with the CONFIG_STM32_APP_IN_EXT_FLASH.
Checking the memory mapped mode bit is possible when the xspi
peripheral clock is not off (stm32h5 has no clock_control_get_status API)

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2025-07-19 09:49:44 +02:00
Alberto Escolar Piedras
e7d228a2b1 drivers/flash: Remove NATIVE_APPLICATION support
It is not possible to build anymore in that mode, so we do not
need to support it in this driver cmake files.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2025-07-19 09:38:15 +02:00
Thomas Altenbach
6aeb12d558 drivers: flash: stm32_qspi: Fix flash not reset when in QPI mode
The reset commands were sent only in SPI mode, causing the device not to
be properly reset when in QPI mode. On the STM32H747I-DISCO boards, this
was causing the driver initialization to fail due to a bad SFDP magic
after flashing the external memory using STM32CubeProgrammer since the
external loader is configuring the flash memory in QPI mode.

The commands are sent in QPI mode first, then in SPI mode:
- If the flash memory was in QPI mode, the two first reset commands are
  processed and after reset, the flash memory is in SPI mode and
  correctly handles the SPI mode reset commands.
- If the flash memory was in SPI mode, for each QPI command the chip
  select signal will be released before the flash memory had the
  opportunity to receive a whole command (1 byte), so the partially
  received commands will be ignored and won't cause any harm. Then, the
  chip is reset by the commands sent in SPI mode.

Signed-off-by: Thomas Altenbach <altenbach.thomas@gmail.com>
2025-07-11 09:41:38 -05:00
Thomas Altenbach
81f95f15fa drivers: flash: stm32_qspi: Fix flash configuration in dual flash mode
When the QSPI is used in dual flash mode, e.g. on the STM32H747I-DISCO
board, only the first flash memory was reset and configured in 4-byte
addressing mode. This was in particular causing data to be incorrectly
read from the second flash memory and only even bytes were valid during
a read.

The dual flash mode was only enabled after reading the SFDP table since
it is desired to read the table of only one flash memory, not both.

This commit changes the driver to only disable the dual mode temporarily
while reading the SFDP table, ensuring all other commands and in
particular configuration commands are sent to both flash memories.

Signed-off-by: Thomas Altenbach <altenbach.thomas@gmail.com>
2025-07-10 10:13:06 -05:00
Raymond Lei
a93a80be82 drivers: nxp: flexspi: fix hyper flash hang issue
CS hold time parameter is not correct which may cause bus fault
randomly.
System hang during status register reading after flash progromming which
is caused by parameter accessing in XIP mode.
Add dummy delay for READ command according the flash datasheet which is
required for SDR mode.
Use FlexSPI internal divider for clock updating instead of register in
CCM to avoid potential risk caused by flash access during clock updating
procedure.

Signed-off-by: Raymond Lei <raymond.lei@nxp.com>
2025-06-26 22:14:38 -05:00
Qiang Zhao
0337527e74 drivers: flash: flexspi: Add octal mode support for MT35 family
MT35 flashes could run in octal mode, Now the driver doesn't support
octal mode, add octal mode support for MT35 flashes.

Signed-off-by: Qiang Zhao <qiang.zhao@nxp.com>
2025-06-26 22:11:04 -05:00
Andrzej Głąbek
9207a21c0e drivers: flash_util: Issue error log message when flash_fill write fails
Use LOG_ERR() instead of LOG_DBG() in flash_fill() when this function
fails to perform the write operation, so that the failure is better
visible and its cause is easier to identify.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2025-06-25 14:06:07 +02:00
Eric Mechin
62a1b8a306 drivers: flash: STM32WBA flash_stm32wba_fm.c: fix sector erase error
The STM32WBA Flash Manager driver is failing to erase a sector, instead of
erasing one sector, two sectors are erased.
Fix it by correctly calculating the number of sectors to erase

Signed-off-by: Eric Mechin <eric.mechin@st.com>
2025-06-24 15:37:41 -05:00
John Barbero Unenge
f7f73bd0c3 driver: flash: mcux_flexspi_nor: Second attempt to fix is25lpXXX chips
This commit changes the implementation to distinguish between is25lpXXX
and is25lpXXXd. Using RDERP as in the original solution didn't work for
is25wpXXX chips and would cause a halt. This new implementation reads
the AutoBoot register instead, which is not present in is25lpXXX but
present in is25lpXXXd, is25wpXXX and is25wpXXXd.

Tested on:
- mimxrt1020-evk
- mimxrt1170-evk rev. A
- custom board with mimxrt1170 and is25lp128d

Signed-off-by: John Barbero Unenge <git@lsrkttn.com>
2025-06-24 09:16:04 +02:00
Francois Ramu
6e5d1393b6 drivers: flash: stm32 qspi driver size and address of the external NOR
New property of the st,stm32-qspi-nor compatible gives
the external NOR flash in bits.
The property of the st,stm32-qspi compatible gives
the external NOR flash base address

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2025-06-24 09:13:33 +02:00
Francois Ramu
958087f49d drivers: flash: stm32 ospi driver size and address of the external NOR
New property of the st,stm32-ospi-nor compatible gives
the external NOR flash in bits.
The property of the st,stm32-ospi compatible gives
the external NOR flash base address

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2025-06-20 14:41:41 -05:00
Andrzej Głąbek
8415f7f7a7 drivers: flash_mspi_nor: Omit quad_enable_set() when QER is set to NONE
When the quad-enable-requirements property is set to "NONE" or is not
present, no Quad Enable operation should be performed.
This fixes an issue with the mx25uw6345g flash chip that is present
on the nRF54h20 DK and supports the Single I/O mode, but cannot be
used in that mode.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2025-06-20 16:22:58 +02:00
Joakim Andersson
e5093f41b2 drivers: flash: Fix timeout handling in STM32 flash driver
Fix timeout error that can occur in rare case.
When the thread writing to flash is pre-emptive it can be scheduled
out after reading the status register, but before checking if timeout
has expired. In this case it will report timeout without re-checking
the status register.

When writing a lot to flash, for example a firmware update process
then this situation is very likely to occur.

Signed-off-by: Joakim Andersson <joerchan@gmail.com>
2025-06-19 14:02:32 +02:00
Federico Di Gregorio
3d720bcb73 drivers: flash: stm32: add "generic read/write" ex op to QSPI driver
Some external flash modules have extra commands to support, for example,
reading/writing an OTP zone. Given that the commands are highly specific
and difficult to generalize, we add two ex ops that can be used to
transmit a custom command (in the form of a full QSPI_CommandTypeDef) and
then read or write a user-provided buffer.

Signed-off-by: Federico Di Gregorio <fog@dndg.it>
2025-06-18 07:37:00 +02:00
Swift Tian
cc5c142535 drivers: mspi: add mspi is25xx0xx device driver
This device driver supports ISSI is25w/lx032/64 series flash.
Only extended SPI mode(1s-1s-1s, 1s-8s-8s, 1s-1s-8s) is implemented.

Signed-off-by: Swift Tian <swift.tian@ambiq.com>
2025-06-18 07:36:26 +02:00
Keith Packard
87029f7422 drivers/flash: Fix #if condition for is_area_readable for mcux
is_area_readable is used for SOCS other than LPC55XXX chips, not just
chips other than LPC55S36. Change the condition which elides this code
to avoid a GCC 14.3 warning.

Signed-off-by: Keith Packard <keithp@keithp.com>
2025-06-17 16:06:21 +02:00
Khaoula Bidani
70ebb0a6a3 drivers: flash: add stm32u3 devices
Introduce the stm32u3 serie to the the existing flash driver
It is based on the stm32l5 model.

Signed-off-by: Khaoula Bidani <khaoula.bidani-ext@st.com>
2025-06-16 13:59:38 -04:00
Martin Gysel
812d33b7ab drivers: flash_stm32_qspi: fix conditional to assing jedec_id property
the jedec_id field is only available if CONFIG_FLASH_JESD216_API is set

Signed-off-by: Martin Gysel <me@bearsh.org>
2025-06-13 10:21:00 -07:00
Andrzej Głąbek
2d9ede3852 drivers: flash: nrf_qspi_nor: Handle properly multiple XIP users
Add reference counting in nrf_qspi_nor_xip_enable() so that XIP is
kept enabled as long as there is at least one user that needs it
(boot time enabling done with CONFIG_NORDIC_QSPI_NOR_XIP also counts).

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2025-06-12 11:45:10 +02:00
Alessandro Manganaro
bbef47fc56 drivers: flash: stm32wba: fix build issue when BLE enabled
Specific flash driver is used for stm32wbax when ble is
enabled. A simple typo error was fixed to properly build
all the samples where flash and ble are enabled,
such as the peripheral one.

Signed-off-by: Alessandro Manganaro <alessandro.manganaro@st.com>
2025-06-09 14:39:34 -07:00
Benjamin Cabé
998ee87635 drivers: flash: use negative errno in Renesas RA HP
fixed an incorrect "return EINVAL" where it should
be -EINVAL.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-06-09 08:56:19 +02:00
Mahesh Mahadevan
c5787e8809 drivers: flash: Fix unused function warning on LPC55S69
is_area_readable() function is no longer used for the LPC55XXX
series.

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2025-06-06 14:49:45 +01:00
Francois Ramu
cbe3e18396 drivers: flash: stm32h7RS flash size is fixed to 64KBytes
Fix the flash size to 64KB for the stm32H7RS series.
Restore the get_size API function for that series.
This is a specificity of this stm32 mcu (RefMan RM0477).

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2025-06-06 10:11:07 +02:00
Tri Nguyen
1005cd9fa2 drivers: flash: Initial support OSPI flash driver on RA8 boards
Support OSPI flash driver on EK-RA8M1 and EK-RA8D1 with ospi_b
and S28HL512T flash.

Signed-off-by: Tri Nguyen <tri.nguyen.wj@bp.renesas.com>
Signed-off-by: Thao Luong <thao.luong.uw@renesas.com>
2025-06-06 08:41:46 +02:00
Wilkins White
00ee4a5887 drivers: flash: mcux: fix read for LPC55XXX
The LPC55XXX SoC series requires the use of a HAL function to read
from uninitialized flash without triggering a hardfault. This
broadens an existing #ifdef clause so that it is triggered for all
chips in the series instead of only the LPC55S36.

Signed-off-by: Wilkins White <ww@novadynamics.com>
2025-06-04 08:45:56 +02:00
David Leach
c0c1b0af44 drivers: flash: Align NXP flash drivers on parameter checking
Parameter checking of flash read API expects checking for len == 0
before checking dest buffer validation.

Fixes #87021

Signed-off-by: David Leach <david.leach@nxp.com>
2025-05-30 10:27:26 +02:00
Benson Huang
3e8ec3aaf2 driver: flash: Add Set/ Get write protect function
Add Set_WP function to set SPI flash WP line to low
Add Get_WP function to obtain status of the SPI flash WP line

Signed-off-by: Benson Huang <benson7633769@gmail.com>
2025-05-28 08:14:27 +02:00
Luca Burelli
8151dd9c6c drivers: flash_stm32h7: fix flash size detection
Commit 0e41b07309 ("drivers : flash:
update way to get flash size") changed the way to get flash size from
the LL_FLASH_GetSize() HAL function to the current DT_REG_SIZE() macro.

However, they are not equivalent:

- With LL_FLASH_GetSize(), REAL_FLASH_SIZE_KB returned the *total* size
  of the Flash memory, reading it from a ROM register of the CPU. For
  example, it was 2048 (2MB) for a STM32H747xI.

- The current DT_REG_SIZE() applies to a flash *bank*, therefore it only
  returns half of the total Flash size on dual bank devices.

This mismatch causes issues with the DISCONTINUOUS_BANKS logic below,
incorrectly matching partitions close to the end of the first bank as
appearing to span both and triggering the "range overlaps discontinuity"
check later.

Fix it by doubling the size when appropriate, in the same way it is
already done for the M4 core.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2025-05-23 11:04:15 +02:00
Stoyan Bogdanov
bdca32d88f drivers: flash: Remove VIMS calls for cc23x0
Remove VIMS calls for flash operations, since they are not needed.

Signed-off-by: Stoyan Bogdanov <sbogdanov@baylibre.com>
2025-05-21 19:57:28 +02:00
Francois Ramu
e13722bc38 drivers: flash: stm32 xspi flash driver set the DelayBlock if exists
The stm32H7RS serie has no DelayBlock Bypass control in its DCR1 register.
For other stm32 devices with DelayBlock bypass control, set the value
directly in the structure.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2025-05-21 17:35:06 +02:00
Francois Ramu
93b983d578 drivers: flash: stm32 xspi drivers supporting the stm32h7r/s mcu
Add the support of the stm32h7rs serie to the
drivers/flash/flash_stm32_xspi driver.
The stm32h7rs has no delayblock

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2025-05-21 17:35:06 +02:00
Francois Ramu
8cb8017038 drivers: flash: stm32 xspi driver supports clock domain config
Add the clock domain configuration for the xspi nodes
Where the DTS defines main clock and peripheral clock sel
plus a XSPIM clock

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2025-05-21 17:35:06 +02:00
Mark O'Donovan
d33da4db35 drivers: flash_stm32_qspi: add st,read-id-dummy-cycles
Add new device tree property specifying the number of
dummy-cycles required when reading the JEDEC ID.

The Arduino Opta has an at25sf128a with JEDEC ID 1F 89 01.
The PR below adds support for this, but the id read is 01 1F 89.
Changing DummyCycles to 16 causes the correct value to be read.

https://github.com/zephyrproject-rtos/zephyr/pull/89539

Signed-off-by: Mark O'Donovan <shiftee@posteo.net>
2025-05-21 14:04:09 +02:00
Erwan Gouriou
cec116c83f drivers: flash: xspi: Put delay block config under specific bit
On some series, use of Delay Block could be possible on OSPI device but
not on HSPI one (which uses this drivers).
As a quick fix check the presence of XSPI Delay Block by-pass
configuration bit instead of the Delay Block presence.

Note: This fix works because we don't have cases today where this driver
is used for OSPI and HSPI instances with mixed DLYB compatibility.
This may have to be reviewed one day and may require a more complex fix
with instantiable configuration, but this day may never come as well.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
2025-05-16 19:07:23 +02:00
Yonas Alizadeh
c186bffab8 drivers: flash: flash_stm32g4x: Fix STM32G4 unaligned read access
Due to source data pointer having no alignment constraint,
extra care needs to be taken when reading source data
as dword

Signed-off-by: Yonas Alizadeh <yonas.alizadeh@alfalaval.com>
2025-05-16 16:12:10 +02:00
Anas Nashif
5fe84d5b69 arch: nios2: remove arch
Remove architecture and dependencies.
Remove altera HAL supporting nios2

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-05-15 20:01:05 -04:00
Jhan BoChao
7450a5249d driver: flash: add flash driver for rts5912
add flash driver for rts5912.

Signed-off-by: Jhan BoChao <jhan_bo_chao@realtek.com>
2025-05-15 11:18:22 +02:00
Hao Luo
4bc2de23a9 drivers: flash: Add support for Apollo510 flash controller
This commit adds support for Apollo510 SoC in ambiq flash driver

Signed-off-by: Hao Luo <hluo@ambiq.com>
2025-05-14 09:11:17 +02:00
Robert Hancock
3a2639a9de drivers: flash: spi_nor: Add fast read support
Most SPI NOR flash devices support a "fast read" command which uses
dummy bits between the address and the start of the data transfer. In
many cases, the maximum SPI clock speed of the device is lower for the
regular read command due to the limited time between the address and
data phases, so using the fast read command will remove this restriction
and allow for faster transfers.

Add a device tree flag to indicate that fast reads should be used for
the device.

Signed-off-by: Robert Hancock <robert.hancock@calian.com>
2025-05-13 12:09:06 +02:00
Robert Hancock
ecacf3d5e3 drivers: flash: spi_nor: Added flag status register support
Some Micron (and possibly other) SPI NOR devices implement a flag status
register which provides more information on the success/failure of erase
and program operations. In addition to better error checking, some of
these devices actually don't function properly if the flag status
register is not read after a program operation (subsequent reads will
only return 0xFF bytes).

Add a device tree parameter to indicate that the flag status register is
supported. When specified, the flag status register will be used for
ready/error checks rather than the standard status register.

Signed-off-by: Robert Hancock <robert.hancock@calian.com>
2025-05-13 12:09:06 +02:00
Robert Hancock
1fdb43cf27 drivers: flash: spi_nor: optimize SPI buffer usage
This driver was providing SPI buffers for both TX and RX on the data
payload portion of read transfers, even though the TX buffer is not
meaningful in these cases. As well as being less efficient, this also
caused likely uninitialized data to be transferred to the device, which
is possibly problematic.

Update to not include the TX buffer for the read data payload SPI
transfer, so that the SPI driver can generate dummy TX data internally.

Signed-off-by: Robert Hancock <robert.hancock@calian.com>
2025-05-13 12:09:06 +02:00