Edge devices have multiple addresses for the external memory.
SAHB (0x60.., 0x70.. for ns and s access respectively) which
are uncached but programmable and CBUS (0x08.. and 0x18..
for ns and s access respectively) which are cached and improve
performance.
Additionally, cm33 can use both SAHB aliases and CBUS alises
but cm55 can only use SAHB aliases.
Therefore this commit redefines entirely the memory map to
use mapped partitions are offsets from the base region and
selecting the base region accordingly for
the three use cases. (cm33s, cm33ns - for eval board, cm55).
To this selected set USE_DT_CODE_PARTITION
to yes for all cores in defconfig.
Additionally cleaned up config BUILD_OUTPUT_ADJUST_LMA to be
more clear in its use.
Updated the custom linker script with the mapped partitions
updates that were added to the base linker ascript in arm.
Updated the metadata function to handle the addresses
gymnastics.
Signed-off-by: Laura Carlesso <laura.carlesso@infineon.com>
Introduce Kconfig symbol to add mutex lock protection to the driver API.
Prevent multi-threaded access from a pre-emptive thread.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Set the OSPI memory mapped timeout period to avoid keeping the chip
select line asserted indefinitely after memory mapped accesses.
This is needed when OSPI1 and OSPI2 operate simultaneously with shared
IO0-IO3 and CLK lines, and both instances use memory mapped mode.
The timeout period follows the recommendation from the STM32U575xx and
STM32U585xx device errata, ES0499 section 2.6.4.
Allow dqs-port to be set to 0. The STM32 HAL uses value 0 to indicate
that the DQS port is not used.
Update the debug log printed when CONFIG_STM32_MEMMAP is not enabled,
because stm32_ospi_set_memorymap() is not called in that case.
Signed-off-by: Kirill Shypachov <kshypachov@outlook.com>
Fix the test on the number of arguments in the erase command
to get the optional size argument that was mistakenly increased by
cb2382d25b ("drivers: flash: flash_shell.c: Requires device on
destructive ops") and made the argument never considered.
Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
Even though compat "st,stm32f1-flash-controller" is also used by stm32f0,
stm32f3, stm32l0 and stm32l1 series, these series don't share exactly
the same members of FLASH_TypeDef and OB_TypeDef structures.
For example, the CR member is available on F1 but not on the L0 series.
There is also issue with missing variables or naming conventions :
- FLASH_OBR_RDPRT (F1) vs FLASH_OBR_RDPRT1 (F0)
- RDP_KEY present in F1 series and not in others.
Signed-off-by: Fabrice DJIATSA <fabrice.djiatsa-ext@st.com>
Instead of performing series check, use the new common Kconfig option
CONFIG_HAS_STM32_UNCACHED_ACCESS_ONLY_OTP in drivers which access the
internal NVM's OTP/read-only area.
While at it, use the public `sys_cache_xxx()` API in flash_stm32 instead
of the internal `cache_xxx()` API.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
During read operations, the same buffer was previously used for both TX
and RX, causing arbitrary data from the RX buffer to be transmitted on
MOSI. This could lead to unintended signaling on the bus and unreliable
device behavior, including corrupted reads (e.g. incorrect JEDEC ID).
Fix this by separating TX and RX buffers:
- Do not drive MOSI during read transactions (TX buffer set to NULL)
- Initialize the RX buffer to 0 before use
This ensures clean read operations without spurious data on MOSI.
During SPI operation, the TX buffer supports a maximum length of
6 bytes. It was set to 5 bytes, which could lead to a potential
overflow.
Signed-off-by: Flavien Carvalho <flavien.carvalho@wiifor.com>
When flash_stm32_xspi_init() returns early in the XIP fast path it
leaves layout.pages_size unset. This causes problems for code that
relies on the page layout being available, even in XIP mode. This
commit adds a fallback to ensure a valid page layout is always
available.
Signed-off-by: Julien Racki <julien.racki-ext@st.com>
Add soc-nv-flash child nodes to the six NXP FlexSPI boards
not yet converted: mimxrt595_evk, mimxrt685_evk, vmu_rt1170
(mx25um51345g), and mimxrt1050_evk, mimxrt1060_evk,
mimxrt1062_fmurt6 (hyperflash).
Update FlexSPI NOR and HyperFlash drivers to read
write_block_size from the soc-nv-flash node. Remove
soc-nv-flash.yaml from hyperflash and mx25um51345g
bindings.
Signed-off-by: Ofir Shemesh <ofirshemesh777@gmail.com>
Add JEDEC IDs 0x19609D (IS25LP256) and 0x19709D (IS25WP256) to the
IS25 family switch. Like other IS25 variants, dummy cycles are reset
before SFDP probe, which handles the full LUT configuration.
Signed-off-by: Albort Xue <yao.xue@nxp.com>
Extend flash and I2C drivers to support BL808 register base addresses
and SoC-specific configuration guards.
Signed-off-by: William Markezana <william.markezana@gmail.com>
While other lines of the STM32 family have their flash controllers with
option bytes driver support, the STM32F1 line was missing it.
(Which might have something to do with the rather complex handling that
it needs to program them.) This patch adds support for modifying the
option bytes as they are represented in FLASH/OBR, which involves erasing
all option bytes (including the write protection bytes), then writing
back the new values for each (restoring the write protection to its
previous value).
Signed-off-by: Benedek Kupper <kupper.benedek@gmail.com>
SF32LB DMA cleared its software busy bit on half-complete.
The QSPI NOR write path polled that bit while holding the flash lock.
Clear the DMA status bit only on completion or error.
Derive busy from the active state plus pending_length.
Poll pending_length until the flash DMA transfer reaches zero.
Signed-off-by: Haoran Jiang <halfsweet@halfsweet.cn>
The SF32LB MPI QSPI NOR erase path issued WREN only once before
entering the erase loop. On SPI NOR devices the write-enable latch
is typically cleared after each erase command, so a multi-block erase
can fail after the first block.
Move WREN into the loop and issue it while holding the driver lock,
immediately before the selected erase command. This matches the write
path and aligns the driver with Zephyr's generic SPI NOR erase flow.
Signed-off-by: Haoran Jiang <halfsweet@halfsweet.cn>
Initialize the 32-bit DR temporary at declaration before copying a
partial tail chunk in qspi_nor_write_fifo(). Without this, 1-3 byte
writes can leave the upper bytes unchanged and push stale bits into
MPI_DR.
Signed-off-by: Haoran Jiang <halfsweet@halfsweet.cn>
Add support for multiple plane devices to the SPI NAND driver.
This includes adding a new plane-bytes property to the device
tree bindings, which indicates the size of each plane in the
flash device. For devices with a single plane, this should be
set to the same value as size-bytes.
Some devices require the plane address as part of read and/or
program commands. For these devices, the new has-read-plane-select
and has-program-plane-select properties can be set to indicate
that the driver should include the plane address in read and
program commands.
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
CONFIG_NRF_RRAM_WRITE_BUFFER_SIZE sets how many line buffers
should be used for the driver. When ther is no need to synchronize
the buffering default value should be maximal
(optimized write performance).
Whe ther is need for synchronize - value should be minimal
buffering - x1 (optimized radio firmware execution).
By mistake the default values were mixed eatch other.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Currently the stm32g4x flash driver only works in dual bank for devices
that support it. This is inconvenient when using mcuboot on a device with
less than the maximum 512k of flash, as it creates an unaddressable "hole"
between the two banks, artificially constraining the partition layout for
the bootloader, primary, and upgrade slots. Update the flash driver to add
a runtime check to see if the device is configured in single bank or dual
bank mode and adjust the page size accordingly. Note that the driver must
do both a compile time and runtime check for dual bank configuration as
dual bank mode is only supported on some devices in the family, and for
those that do support dual bank mode, they may or may not be configured as
such.
Signed-off-by: Michael Estes <michael.estes@byteserv.io>
Add a SPI-NAND flash driver for NXP FlexSPI controller. The driver
probes device geometry (page size, OOB size, pages per block, total
capacity) from the ONFI parameter page at runtime and supports read,
write, and block erase operations. Bad-block detection and marking
are exposed through the flash_ex_op interface, including the
FLASH_EX_OP_IS_BAD_BLOCK and FLASH_EX_OP_MARK_BAD_BLOCK operations.
Signed-off-by: Ruijia Wang <ruijia.wang@nxp.com>
Add support for the base DT property "supply-gpios" and related
"t-reset-recovery", as in the flash_mspi_nor driver.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
Fixes zephyrproject-rtos/zephyr#106597
The current driver for the NXP C40 flash controller instantiates two
drivers, one for the controller (which has no real code -- it's just
a device with no API, config, or data), and one for the flash bank.
This breaks the various partition APIs because they expect the flash
driver API to be attached to the "grandparent" of the partitions
object -- but in the current C40 driver, it is attached to the parent.
I was worried this fix was going to be more complicated, but it
appears to have been quite simple. All I needed to do was to
instantiate a single device with the the API, config and data.
The fix requires the "soc-nv-flash" compatibility to be added to
device trees which reference this driver (see previous commit).
This fix addresses the bug report I filed a few days ago:
NXP C40 flash driver incompatibility with partitions macro APIs #106597
Signed-off-by: Rob Newberry <rob@zenomoto.com>
Signed-off-by: rob-zeno <rob@zenomoto.com>
Kinetis ke1xf (twr_ke18f/mke18f16) and k8x (frdm_k82f) select
CONFIG_HAS_MCUX_CACHE but previously fell through to the no-op
clear_flash_caches() path, meaning caches were not invalidated
after flash erase or write operations.
After the FTFE controller completes an erase or write, stale data
may remain in the instruction cache and (on some parts) the system
bus cache. Subsequent reads can return outdated values instead of
updated flash contents. This causes test_flash_erase,
test_flash_fill, and test_flash_flatten in
tests/drivers/flash/common to fail, with data read back as stale
values (e.g. 0xAA from a prior fill).
Rebased on top of #105918 and updated to use Zephyr's generic cache
API (sys_cache_instr_invd_all() / sys_cache_data_invd_all()) for
cache invalidation. This keeps the flash driver SoC-agnostic and
relies on the cache driver (e.g. LMEM) for hardware-specific
handling.
Fixes#98487
Signed-off-by: Mohit Talwar <talwarmohit2005@gmail.com>
NXP FlexSPI NOR flash nodes were missing the soc-nv-flash child
node expected by Zephyr's flash map API.
Without this child node, DT_MTD_FROM_FIXED_PARTITION resolved to
the FlexSPI memory controller instead of the flash device. Since
the controller has api = NULL, MCUboot could hit a NULL pointer
dereference during boot on Zephyr 4.4.
Fix this by updating the DTS structure to match the soc-nv-flash
convention used by the flash map infrastructure.
Changes:
- add a soc-nv-flash child under each nxp,imx-flexspi-nor node
- move erase-block-size, write-block-size, and partitions into it
- add ranges to flash controller nodes for address translation
- update zephyr,flash to point to the soc-nv-flash child
- add zephyr,flash-controller chosen for the flash driver node
- remove soc-nv-flash.yaml from nxp,imx-flexspi-nor.yaml
- use zephyr,flash-controller in flash CMake XIP decisions
- update FlexSPI XIP Kconfig logic to walk to the grandparent
This keeps the controller and flash device roles separate and
restores correct flash map resolution for MCUboot and XIP logic.
Signed-off-by: Ofir Shemesh <ofirshemesh777@gmail.com>
In driver file flash_stm32wba_fm.c, rename ble_ctrl_work_q
to ble_ctle_work_q and make ble_ctle_work_q non-static
in SoC code
Signed-off-by: Vincent Tardy <vincent.tardy@st.com>
Add support for bad block management in SPI NAND flash devices.
This includes functions to check if a block is bad and to mark
a block as bad. The bad block marker is stored in the OOB area of
the first page of each block.
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
Add Kconfig option to accept unaligned addresses and/or lengths for
flash_write for stm32 devices. Use with caution after understanding
target platform flash implementation details. Op may fault if used
without forethought
Signed-off-by: Sudarshan Jagannathan <sudarshan.jagannathan@st.com>
Fixes:
zephyrproject/zephyr/drivers/flash/flash_stm32_ex_op.c:348:3: warning:
label followed by a declaration is a C23 extension [-Wc23-extensions]
348 | int rv2;
| ^
when compiling with llvm.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Previously, nv-flash nodes were used as the flash controller and
contained APIs. But currently, to support mapped-partitions
and allow MCUboot to run on RA8x2 devices, this MRAM driver need
to correct the node that used for flash controller.
Signed-off-by: Khoa Nguyen <khoa.nguyen.xh@renesas.com>
The nrf_rram_write() and nrf_rram_erase() functions were missing
input validation for address and length alignment.
nrf_rram_write() did not verify that addr and len are multiples of
WRITE_LINE_SIZE (16 bytes), allowing unaligned writes to succeed
when they should return -EINVAL.
nrf_rram_erase() did not verify that addr and len are multiples of
PAGE_SIZE (4096 bytes), allowing unaligned erases to succeed when
they should return -EINVAL.
Add alignment checks to both functions to correctly reject invalid
operations as required by the flash API contract.
Assisted-by: Claude:claude-sonnet-4-6
Fixes#102511
Signed-off-by: Mohit Talwar <talwarmohit2005@gmail.com>
Implement a device driver for XSPI manager.
This allows to define the xspi controllers configuration that should
be applied towards the xspi IO ports:
- Muxed
- Swapped
- ...
Since its configuration has impact on final application location and
implies the deactivation of xspi clocks, it should be run only at fsbl
stage and not later.
Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
There is no such thing as XSPIM1/XSPIM2 and not all XSPIM compatible
devices declare HAL_XSPIM_IOPORT_1/2.
Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
The PSOC4 flash driver accepted unaligned write offsets and sizes,
using a read-modify-write path to handle sub-row writes. This
violated the flash API contract, as the driver advertises
write_block_size=256 via devicetree.
Additionally, the Infineon HAL function Cy_Flash_WriteRow() requires
row-aligned addresses and exactly CY_FLASH_SIZEOF_ROW bytes of data.
The R-M-W path was passing unaligned addresses to the HAL, which
would reject them, but the driver was not checking the return value
and silently reported success after failed writes.
Add write alignment validation for both offset and size. Remove the
dead read-modify-write code path. Add missing error checking on
Cy_Flash_WriteRow() return value in the write loop, consistent with
the erase function.
Handle caller-provided data buffers that are not 4-byte aligned by
staging each row through a local aligned buffer before calling
Cy_Flash_WriteRow(), which requires a uint32_t-aligned source
pointer. When the source is already aligned, it is passed directly
with no copy overhead.
Signed-off-by: Braeden Lane <Braeden.Lane@infineon.com>
Memory W25Q256 support added into flash driver. If someone
uses this memory, the driver will configured into 4-bytes
address mode which will cause issues with the bootROM for
some NXP's RTs/RW microcontrollers.
Signed-off-by: Missael Maciel <davidmissael.maciel@nxp.com>
Name the XSPI 1/2 depending on the stm32 series. It could be mixed between
XSPI or OCTOSPI depending on the module HAL.
Signed-off-by: Francois Ramu <francois.ramu@st.com>
On mcxw70, the flash cache is managed by the underlying driver from
hal_nxp. The method used in the soc_flash_mcux driver is not suitable
for this platform, and should be disabled.
Signed-off-by: Axel Le Bourhis <axel.lebourhis@nxp.com>
NAND flash translation layers require the flash extended operations API
for bad block management. Add it here without implementation to test an
FTL on the flash simulator.
Signed-off-by: Pascal Linder <pascal.linder@zuehlke.com>
Add extended operations to the flash API to support marking blocks
as bad and checking if a block is bad. This is necessary for
NAND flash devices, which can have bad blocks that need to be managed.
Signed-off-by: Pascal Linder <pascal.linder@zuehlke.com>
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
Replaces usage of these deprecated macros with ones that support
fixed and mapped partition compatibles. Also includes an update to
hal_espressif which also (rightly or wrongly) has zephyr specific
code in it
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>