Replace direct LOG_* calls with XSPI_LOG_* conditional macros that are
silenced when CONFIG_FLASH_STM32_XSPI_XIP_RELOCATE is enabled.
This avoids executing log code in Flash while
the memory map is under relocation.
Signed-off-by: Julien Racki <julien.racki-ext@st.com>
Allow abort and restore operations to run write or erase commands when
the code is relocated. In that configuration, the Flash is
memory-mapped by the bootloader and the XSPI driver needs to abort it
to run write or erase commands.
Signed-off-by: Julien Racki <julien.racki-ext@st.com>
This allows to relocate the XSPI driver code to RAM for the STM32N6
and the STM32H7RS series.
Code relocation is done when CONFIG_FLASH_STM32_XSPI_XIP_RELOCATE is
enabled.
Signed-off-by: Julien Racki <julien.racki-ext@st.com>
When no erase type is found, the erase exponent remains zero.
Applying BIT(0) produces an incorrect one-byte erase size and prevents
the fallback to SPI_NOR_SECTOR_SIZE.
Signed-off-by: Julien Racki <julien.racki-ext@st.com>
Move the semaphore init and IRQ config so it is initialized and
configured when running the app in external flash in XIP
Signed-off-by: Julien Racki <julien.racki-ext@st.com>
off_t is a POSIX type used for sizes of files. Zephyr uses it for the
position of objects within flash storage.
It assumes that off_t is equivalent to 'long' when printing offset values
as well as being the same size as a pointer when converting offsets to
addresses for in-memory flash regions.
Neither of these assumptions hold when off_t is 64-bits on 32-bit targets.
When used as a pointer offset, cast values to ptrdiff_t. To print them
use the 't' length specifier.
When used as a memory address, cast values to uintptr_t, including before
casting to a pointer. To print them, cast to long and use a 'l' length
specifier.
Signed-off-by: Keith Packard <keithp@keithp.com>
The new dma_stm32_zcfg_to_halcfg() relies heavily on default STM32
configuration. Document it in order not to loose the DMA consumer
drivers into wrong configuration.
Signed-off-by: Raphaël Gallais-Pou <raphael.gallais-pou@foss.st.com>
Use the private STM32 DMA helper in HAL-managed DMA setup paths instead
of open-coding common DMA_InitTypeDef fields in each consumer.
Keep peripheral-specific settings such as request lines, instances,
channel attributes, bursts, and port allocation local to each driver.
This reduces duplicated HAL DMA setup in flash, MSPI, SAI, SDMMC, and
DCMI STM32 drivers.
Assisted-by: Copilot:gpt-5.5
Signed-off-by: Raphaël Gallais-Pou <raphael.gallais-pou@foss.st.com>
Right now JEDEC ID verification is done before switching IO mode; so,
abstract the verification part into it's own function and call it twice,
once at the start and second after switching.
Signed-off-by: Amneesh Singh <amneesh@ti.com>
- Add support for Infineon Semper S28HX512T NOR flash. This supports SPI
mode (1S-1S-1S), 8S-8S-8S and 8D-8D-8D.
- Expose set_up_xfer_with_addr, read_jedec_id and soft_reset_66_99
function declarations to the vendor specific quirks.
- Add more macros to the spi_nor_s28hx512t.h header that can be used in
addition to the already present macros.
- Add a specific quirk that is only used when the parent controller for
this flash is Cadence MSPI (OSPI). This involves calibrating a delay for
capturing data on the controller by reading JEDEC IDs on different
configurations.
- Add DT binding for the flash to allow convenient Kconfig symbols that
depend on the presence of the compatible flash node in the DT.
- Move FLASH_MSPI_QUIRKS_GET to the bottom of file in
flash_mspi_nor_quirks.h header.
Signed-off-by: Amneesh Singh <amneesh@ti.com>
Use DT for initial endianness configuration since it should be the
same as the target endian configuration.
The initial MSPI dev_config() call applied MSPI_DEVICE_CONFIG_ALL. Use
NON_XIP_DEV_CFG_MASK instead, which excludes parameters that do not need
configuration.
Signed-off-by: Amneesh Singh <amneesh@ti.com>
DDR Octal SPI configurations require reading an even number of bytes at a
time. This includes commands such as RDSR (Status Register) and RDID
(JEDEC ID). Currently this can cause timing issues, hence use an even
number of bytes for the both aforementioned commands if the data rate is
dual.
Signed-off-by: Amneesh Singh <amneesh@ti.com>
Rename CONFIG_FLASH_INFINEON_PSOC4 to CONFIG_FLASH_INFINEON_PDL to
support both PSoC4 and PSC3 families. Replace SoC-series ifdefs with
devicetree properties (infineon,explicit-erase, infineon,
cache-invalidate, erase-value) to describe hardware capabilities.
Add explicit erase support for PSC3, per-instance mutex for thread safety,
and cache invalidation after flash operations. Update Kconfig to select
appropriate erase flags. PSoC4 hardware auto-erases on write, while PSC3
requires explicit erase.
Signed-off-by: Dharun krithik k <dharunkrithik@aerlync.com>
Add a warning to recommend to move the stm32h5 devices
to the mspi stm32 controller with the mspi stm32 xspi driver.
The flash stm32 xspi driver will be deprecated v4.5.0
Signed-off-by: Francois Ramu <francois.ramu@st.com>
Extend the stm32 flash driver config to the MSPI st,nor compatible
device to enable the external flash in MemoryMapped mode.
This commit checks the KconfigFormat correctly.
Signed-off-by: Francois Ramu <francois.ramu@st.com>
Instead of including the header containing the generic implementation of
certain arch services, include the top-level <zephyr/arch/cpu.h> header
which will provide the correct implementation for the target arch.
Notably important for `sys_io.h` which has memory barriers on Cortex-A.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
The ONFI parameter page stores all fields in little endian byte order.
The driver read them directly from the packed struct, which only yields
the correct values on a little-endian host and would return byte-swapped
geometry and CRC values on a big-endian target.
Convert every multi-byte field on access with sys_le16_to_cpu() and
sys_le32_to_cpu().
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
The previous parameter page definition described only ONFI revision 5.2
and folded every field that does not exist in 5.2 into opaque reserved
gaps and an electrical_parameters blob. Many NAND flashes in the field
still implement ONFI 1.0, whose parameter page places different
information at those offsets, so those bytes could not be interpreted.
Cover the full range from ONFI 1.0 to 6.0. Replace the opaque reserved
and blob members of struct spi_nand_onfi_parameter_page with the
individual fields defined across all revisions, such as the partial page
geometry and timing parameters. Annotate each field with the ONFI
revision range in which it is valid so that users can tell which
members a device of a given revision actually populates.
The field offsets and the overall 256 byte layout are unchanged, so the
existing BUILD_ASSERT still holds and no reader is affected.
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
Build the STM32WB0 flash driver for STM32WL3x, whose flash
controller IP is compatible with STM32WB0.
Signed-off-by: Fabrice DJIATSA <fabrice.djiatsa-ext@st.com>
When dividing the writes into multiple block the driver doesn't sleep
after the last block write which causes a wrong throttling delay.
Fix this by removing an unnecessary check of len in the nrf_write
function.
FIXES: #118218
Signed-off-by: Riadh Ghaddab <riadh.ghaddab@nordicsemi.no>
Update Renesas Flash-HP for mapped-partition migration
Remove extend operation for Flash-HP since the block protect belong to
OFS setting
Signed-off-by: Khoa Nguyen <khoa.nguyen.xh@renesas.com>
The CH32V series has between 16 KiB and 480 KiB of in-place
programmable program flash. Add a driver that implements the Zephyr
flash API, the appropriate Devicetree nodes, and overlays for the
`flash_shell` sample.
For the sample, trim back the default settings to fit within the ~64
KiB of flash and 8 to 20 K of RAM and add test partitions.
Use Devicetree to define the erase value. For the 003 and 006, this is
the common 0xFF but for the 20x/30x this is 0xE339. The flash API
works correctly on the 20x/30x but systems that require the erase
value to be a single byte, or assume that it is 0xFF, will not. This
can be addressed in future PRs.
Tested on the ch32v00x_core and bluepillplus_ch32v203 board by loading
the sample and running `flash test ...`. The
tests/drivers/flash/common test passes on the bluepillplus except for
the erase test which fails due to the ch32v203's half word erase
pattern.
Signed-off-by: Michael Hope <michaelh@juju.nz>
Use controller/peripheral and SDO/SDI terminology in the remaining
SPI-using drivers (audio, auxdisplay, bluetooth HCI, dac, eeprom,
ethernet, flash, fpga, gpio, haptics, hdlc_rcp_if, ieee802154,
input, led, led_strip, lora, mfd, misc, mux, rtc, sdhc, stepper,
video, watchdog, wifi) and the ec_host_cmd SPI STM32 backend,
following coding guideline rule A.2: switch to
SPI_OP_MODE_CONTROLLER/PERIPHERAL and SPI_SDO_OVERRUN_DT, rename
Zephyr-owned identifiers (the HCI SPI header buffers, the winc1500
bus wrapper transfer parameters), and update comments, log messages
and Kconfig help prose.
Vendor and out-of-scope identifiers keep their names: STM32
LL_SPI_MODE_SLAVE in the ec_host_cmd backend, the ATWINC1500 SDK I2C
SLAVE_ADDRESS definition, and the I2S codec clock-role variable in
tlv320aic26.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Make rram_write() a non-sleeping single-block primitive so it is safe to
call from interrupt context.
The throttling delay is now realized by the callers: k_usleep() between
blocks on the thread path.
Add as well a new nrf_flash_sync_set_delay() function that spaces
timeslots on the radio-sync path.
This allows SOC_FLASH_NRF_THROTTLING and SOC_FLASH_NRF_RADIO_SYNC_MPSL
to be enabled at the same time.
Signed-off-by: Riadh Ghaddab <riadh.ghaddab@nordicsemi.no>
Two-line copyright notices were wrapped in the SPDX "<text>...</text>"
construct, which is only valid in an SPDX document, not a file header.
The REUSE tool then folds the literal "<text>" into the holder name
and drops the second line from the SBOM.
Remove the markers and tag the continuation line. Holder, year and
e-mail are left unchanged; only the syntax is fixed.
Signed-off-by: Parthiban Nallathambi <parthiban@linumiz.com>
RDJDID (9Fh) on this part returns 9d 60 1a, so the existing 0x20609d
case never matched and the driver fell through to the SFDP path. Add
the ID the part reports, keeping 0x20609d alongside it.
Signed-off-by: Emilio Bottoni <emilio.bottoni@edge.ufal.br>
The flash_stm32h7x driver makes several accesses to properties of the
st,stm32-nv-flash child. Make sure said child exists.
Signed-off-by: Vilhelm Engström <vilhelm.engstrom@tuta.io>
The bank2-flash-size property was introduced as a workaround for the
Cortex-M4 of dual core MCUs cannot access the flash size register. As of
0e41b07309 (drivers : flash: update way to get flash size), this
register is no longer used by the driver. Instead, the size of the
entire flash is derived from the size cell of the corresponding
devicetree node. As this works just as well on the Cortex-M4 as it does
on the Cortex-M7, the bank2-flash-size property is no longer needed.
Signed-off-by: Vilhelm Engström <vilhelm.engstrom@tuta.io>
The changeset in which the removal of LL_GetFLashSize was accounted for
failed to consider that the size cell of the flash nodes on the dual
core MCUs - i.e. the STM32H747, STM32H757, STM32H745 and STM32H755 -
contains the size of a single bank rather than that of the entire flash.
As a result, the driver mistakes the flash mapped at
0x08008000-0x80fffff for a gap between two discontinuous memory banks
rather than a part of bank 1, thereby rendering sectors 4 through 7 of
the latter inaccessible.
Since both banks on the affected MCUs are the same size, simply
multiply said size by 2 to attain the correct total flash size.
Fixes: 0e41b07309 (drivers : flash: update way to get flash size)
Signed-off-by: Vilhelm Engström <vilhelm.engstrom@tuta.io>
MSPI is read as an initialism, so it takes "an", not "a". Fix the
remaining occurrences across the MSPI headers, the JEDEC NOR flash
driver and the MSPI samples.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Add page-size to the JEDEC MSPI NOR property allow list and honor
it in FLASH_PAGE_SIZE_INST(): when the property is present, it
overrides the SFDP-derived or default page size.
Signed-off-by: Scott Worley <scott.worley@microchip.com>
Since supports-2bit, supports-4bit and supports-dtr-4bit DT properties
are of boolean type, use of dt_compat_any_has_prop() without an
explicit value argument of True makes that function to always return
true. Set function argument value to True to get the expected behavior.
Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
Add support for enabling the volatile SR write.
It gives more flexibility how to deal with the flash chip.
Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
The FlexSPI controller configuration (LUT, per-device FLSHCR/DLLCR)
is lost when the controller power domain is powered down. On
PM_DEVICE_ACTION_TURN_ON, reset the memc per-port LUT bookkeeping so
the probe re-allocates LUT slots from zero, then re-run the flash
probe to rebuild the device configuration and LUT from the chip.
Re-running the controller init or wiping the whole LUT is not
possible while the CPU executes XIP from the NOR, so the restore
relies on the ROM FCB controller-level state and replaces (not
clears) the LUT entries the driver owns.
Add memc_flexspi_reset_lut_alloc() to reset the per-port LUT
bookkeeping after a power-domain power-down.
Signed-off-by: Albort Xue <yao.xue@nxp.com>
flash_size/erase-block-size/write-block-size now live on the
soc-nv-flash child instead of the controller node. Update
flash_renesas_rz_qspi.c/flash_renesas_rza2m_qspi.c and the
bindings to match.
Signed-off-by: Tien Nguyen <tien.nguyen.zg@renesas.com>
Add a driver for the Aesc Silicon SPI XIP controller, exposing the
execute-in-place mapped SPI NOR flash as a Zephyr flash device. The
flash region is a soc-nv-flash child of the "aesc,spi-flash-controller"
node.
Reads are served from the memory-mapped XIP window. Programming is not
supported yet, so write() and erase() return -ENOSYS.
When the "aesc,quad-mode" property is set, the driver switches the
controller and flash to quad read mode at init, skipping the
reconfigure when a bootloader already enabled it.
Signed-off-by: Daniel Schultz <dnltz@aesc-silicon.de>
Override FM_MutexTake and FM_MutexRelease function definitions to comply
with the changes introduced in STM32CubeWBA v1.10.0.
Signed-off-by: Ali Hozhabri <ali.hozhabri@st.com>
flash_mspi_nor unconditionally required erase offset and size to be
aligned to SPI_NOR_SECTOR_SIZE (4 KiB), even though some MSPI NOR and
EEPROM devices support finer-grained erase.
Add an optional erase-block-size DT property to the jedec,nor-mspi
binding, defaulting to SPI_NOR_SECTOR_SIZE to preserve existing
behavior for devices that do not set it, and use it in api_erase()
for the address and size alignment checks.
Signed-off-by: Mohammad Odeh <zephyr@exalt.ps>
With PR #112952 the FLASH_NODE logic was unified to use a common
handler.
Use the same logic in flash_infineon_qspi now that the memory map has
been updated to remove the fixed partition compatible.
Additionallly clean up the KConfing to only check for mapped partition
and remove the fixed partition check.
Signed-off-by: Laura Carlesso <laura.carlesso@infineon.com>
The asynchronous read/write/erase handlers passed
K_TIMEOUT_ABS_SEC(CONFIG_ESP_FLASH_ASYNC_TIMEOUT) to k_mutex_lock().
That macro builds an absolute deadline measured from system boot
rather than a relative timeout. Once the system uptime exceeds
CONFIG_ESP_FLASH_ASYNC_TIMEOUT seconds the deadline always lies in
the past, k_mutex_lock() fails immediately and every flash operation
returns -ETIMEDOUT without ever being submitted.
Use K_SECONDS() so that the configured value is honoured as a
relative timeout, matching the Kconfig help text.
Signed-off-by: Shuai Ma <malin719426@gmail.com>
Writes/erases use the indirect interface and don't update the D-cache, so
memory-mapped reads returned stale data once the cache was enabled.
Invalidate the affected range on write/erase completion.
Assisted-by: GPT-5.3-Codex
Signed-off-by: Fabrice DJIATSA <fabrice.djiatsa-ext@st.com>