Add JDEC case for Macronix MX25U12832FM2I02 to skip SFDP auto-parsing.
This forces 24-bit addressing instead of 32-bit addressing.
32-bit addressing resulted in hard faults where to board was not able
to start normally.
Tested on: phyCORE-RT1170
Signed-off-by: Mateo Ivankovic <mateo.ivankovic@inovex.de>
When running XIP, flash_flexspi_nor_write() locks interrupts before
programming the flash. In OPI DTR mode, which is the default, the
check for an even offset and length runs after irq_lock() and returns
-EINVAL without calling irq_unlock(). A single misaligned flash_write()
call therefore leaves interrupts disabled and hangs the system.
Do the alignment check before entering the critical section. While
moving it, fix the comment, which called the offset "write size", and
compare the masked values explicitly.
The check was added after irq_lock() in
commit daf6de7b99 ("drivers: flash: flexspi_mx25um513: enforce write
size limit in DTR mode").
Build-tested for mimxrt595_evk/mimxrt595s/cm33 with the default OPI DTR
mode; not tested on hardware.
Signed-off-by: Yuho Choi <oss.patchbox@gmail.com>
Fixes a Kconfig appearing outside of the flash menu and even being
selectable when the flash Kconfig was not enabled
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
The switch to 4-byte address mode was done while parsing the BFP, so the
remaining SFDP tables were read in 4-byte mode with a 3-byte address.
Enter 4-byte mode once all the tables have been read, and fail init if
the switch fails.
Signed-off-by: Julien Racki <julien.racki-ext@st.com>
With four-byte-opcodes set, only the read and program opcodes were
converted. The SFDP erase opcodes (0x20, 0x52, 0xD8) were sent with a
32-bit address while the flash was in 3-byte mode, so the erase did not
execute. Convert them to 0x21, 0x5C and 0xDC too.
Signed-off-by: Julien Racki <julien.racki-ext@st.com>
System-managed PM resume leaves deep power-down from the idle
thread while wake interrupts are still masked. k_sleep() cannot
elapse there: it needs the system timer interrupt and must not
suspend the idle thread.
Keep the millisecond delay, but busy-wait when the caller cannot
yield. Initialization and other thread contexts still sleep.
Signed-off-by: Leo Li <leo.li@rakwireless.com>
The boot ROM can leave the flash in octal mode. Read the ID in octal
mode first and only send the SPI sequence that enables octal mode when
the flash does not answer with the Macronix manufacturer ID.
READ_ID_OPI was always the DTR sequence, which does not work in STR
mode. Add an STR sequence, selected like the other octal commands.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jaro Van Landschoot <jaro.vanlandschoot@basalte.be>
Add an option of reading the SFDP data from flash chips and processing
it at runtime instead of requiring it to be provided in dts arrays.
Selection of the MSPI NOR flash instances for which the runtime SFDP
processing should be performed is done by setting the `use-runtime-sfdp`
property in their devicetree nodes.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
This is a follow up to commit c696414f8f.
When specific IO modes are configured in dts for read and/or write
operations, they should be used, instead of the `mspi-io-mode` value,
also in macros that prepare the default content for the command info
structure.
On this occassion, the used data rate enumeration values are corrected.
For example for the 1S-8D-8D mode now `MSPI_DATA_RATE_S_D_D` is used
instead of incorrect `MSPI_DATA_RATE_DUAL`.
Finally, as commit 8dd7b20f84 introduced
definitions for octal page program commands, those are also applied.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
Add FLASH_RPI_PICO_LOCK_IRQS, on by default under XIP, which locks
interrupts around the pico-sdk write and erase calls only when it is
set. An application linked to run entirely from RAM has no interrupt
handler executing from flash, so the IRQ lock blocks all interrupts for
the entire write/erase operation unnecessarily.
The IRQ lock was the driver's only mutual exclusion, so this change also
takes a semaphore in read, write and erase to allow only one flash
operation at a time. The semaphore compiles out under
CONFIG_MULTITHREADING=n.
Tested with an XIP app and an in-RAM app, and with CONFIG_MULTITHREADING
on and off.
Signed-off-by: James Smith <james@loopj.com>
FLASH_SIZE and the read base come from CONFIG_FLASH_SIZE and
CONFIG_FLASH_BASE_ADDRESS, which arch/Kconfig defaults to 0 when XIP is
disabled. An application linked to run entirely from RAM therefore
reports a zero-sized flash, and rejects every read/write/erase.
RP2350 can already be linked this way.
This commit takes those values from the controller's soc-nv-flash node
in the devicetree instead. Values are unchanged under XIP.
Signed-off-by: James Smith <james@loopj.com>
The current STM32 flash driver extended operations implementation does
not comply with the API documentation and returns non-zero values on
success. Align the RDP update function to return negative error code
on failure and 0 on success, following flash_ex_op() documentation.
Signed-off-by: Jędrzej Ciupis <jciupis@google.com>
The previous DT_CHILD(DT_DRV_INST(0), flash_0) requires every
flash controller to have its soc-nv-flash child at unit address 0.
Controllers whose flash child uses a different unit address (e.g.
flash@10000000 on kv5x) need DTS changes to satisfy this constraint.
Use COND_CODE_1 with DT_NODE_EXISTS to try DT_CHILD first; when
flash@0 does not exist, fall back to SOC_NV_FLASH_CHILD_NODE which
iterates status-okay children filtered by the soc-nv-flash
compatible. This handles both multi-child controllers such as
mcxw70 (where flash@0 exists alongside flw@800000) and single-child
controllers with a non-zero unit address.
Fixes: #121282
Signed-off-by: Jason Yu <zejiang.yu@nxp.com>
In case of BLE usage, flash driver initialization requires kernel
services to setup workqueue resources hence it must be executed
after kernel is alive.
OTP_STM32_NVM_PROGRAMMING_SUPPORT is disabled for STM32WBAX series
since it currently requires the flash driver to be initialized at
PRE_KENREL_1 initcall level.
Fixes: #120988
Signed-off-by: Alessandro Manganaro <alessandro.manganaro@st.com>
BL616CL limits were flipped
Robustness against libc/libgcc call in XIP
Fix one busy bit mode
IRQ lock when change offset
JEDEC ID algorithm
Signed-off-by: Camille BAUD <mail@massdriver.space>
Normal write mode corrupts a word that isn't erased first, even if
the write only clears bits. Erase non-erased words with the hardware
erase before writing. One ERASEWORD write erases the whole 16 byte
word.
Non-secure builds can't reach the MRAMC erase, so they write in
direct write mode instead.
Signed-off-by: David Jewsbury <david.jewsbury@nordicsemi.no>
Wire the flash driver get_size callback for the SiWx91x SoC flash
driver. The value is cfg->size from devicetree, matching the bounds
used for read, write, and erase and consistent with other Silicon
Labs SoC flash drivers.
Signed-off-by: Arun Padakanti <arpadaka@silabs.com>
FLASH_RENESAS_RA_HP_CHECK_BEFORE_READING took its default from
erase-value-undefined on the flash1 node. The mapped-partition DTS
rework removed the flash1 label and moved the property to
data_flash_ctrl, so the option silently became n. Erased data flash then
reads back as undefined values instead of 0xff, and NVS fails to mount
with -EDEADLK. Read the property from data_flash_ctrl instead.
Tested by building on 11 RA boards; not run on RA hardware.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Dimitrios Kafetzis <dimitrioskafetzis@gmail.com>
The CAT1 PDL requires program data to be in SRAM, but the write path
passed aligned sources straight to the PDL and only staged misaligned
ones. An aligned buffer that lives in flash/rodata could therefore bypass
the copy and violate that requirement.
Always memcpy each row into the SRAM row_buf before programming, so the
PDL always gets a buffer that is in SRAM and aligned.
Signed-off-by: Dharun krithik k <dharunkrithik@aerlync.com>
This is a follow-up to commit eb318914c2.
SFDP reads are not just short control or configuration transfers
and may actually involve transferring significant amounts of data,
so they should use the same transfer mode as normal data reads.
And this is not only a question of efficiency of the transfers.
For example, for the Synopsys DW SSI controller, if a fairly long
transfer is performed in single IO mode without using DMA, it may be
interrupted by the controller when the CPU won't cope with refilling
the controller's TX FIFO on time.
Use then `data_xfer_mode` instead of `control_xfer_mode` for SFDP
transfers.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
Add hardening rules for the shell command modules that give raw read
and write access to persistent storage. These are base profile rules:
unlike CONFIG_SHELL itself, which only the strict profile flags, dumping or
rewriting flash, EEPROM, settings and files is not appropriate even for
products that deliberately ship a shell.
- CONFIG_EEPROM_SHELL: n (base)
- CONFIG_FILE_SYSTEM_SHELL: n (base)
- CONFIG_FLASH_SHELL: n (base)
- CONFIG_SETTINGS_SHELL: n (base)
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Since the previous update removed the QSPI ex_op enumeration,
this commit reverts that update to fix the QSPI build failure
when ex_op is enabled
Signed-off-by: Khoa Nguyen <khoa.nguyen.xh@renesas.com>
commit 7acfb6145f ("drivers: flash: unify SOC_NV_FLASH_NODE logic")
switched this driver to SOC_NV_FLASH_CHILD_NODE(), which only handles a
controller with one soc-nv-flash child. cc23x0 has two, the main sector
and the CCFG sector whose compatible list also carries soc-nv-flash, so
the macro expands to two juxtaposed node ids and nothing with flash
enabled compiles.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:opus-5
Long runs of erase and write operations keep the flash cache
disabled, and on multi-core SoCs the other core parked, for the
whole run unless the driver yields between windows. Add the
options that size that yield: whether to yield at all, the
cumulative cache-off budget, the yield length and the write
window size. The flash layer reads them through its port.
Assisted-by: Claude:opus-5
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
Initialize p_reg with the register base address from devicetree.
Signed-off-by: Duc Bui <duc.bui.vt@bp.renesas.com>
Signed-off-by: Tien Nguyen <tien.nguyen.zg@renesas.com>
DT_INST(0, soc_nv_flash) enumerates soc-nv-flash nodes across the
whole devicetree, ordered by dependency ordinal, not scoped to the
flash controller this driver instance actually owns. On boards with
more than one soc-nv-flash node (e.g. frdm_mcxa577, which has both
the internal MCXA577 flash and an external W25Q64 SPI NOR flash),
instance 0 can resolve to either node depending on their relative
position in the tree, so SOC_NV_FLASH_NODE silently picks up the
wrong node's write-block-size and erase-block-size.
This was hit after moving the fmu node out from under &peripheral:
the reordering flipped DT_INST(0, soc_nv_flash) from the internal
flash to the external SPI NOR flash, so the flash page layout
reported an erase-block-size of 0x1000 (the SPI NOR's) instead of
the internal flash's actual 0x2000. Erasing with that wrong size
triggers kStatus_FLASH_AlignmentError from the ROM API on real
hardware.
Use DT_CHILD(DT_DRV_INST(0), flash_0) instead, which looks up the
flash_0 child of this driver's own instance instead of searching the
whole tree. flash_0 is the child node name used by every soc-nv-flash
node under the compatibles this file matches.
Verified on frdm_mcxa577 hardware via CMSIS-DAP/MCU-Link:
tests/drivers/flash/common now reports the correct 8K erase-block-size
and the full suite passes (SUITE PASS - 100.00%, 6 passed, 3 skipped).
Build-only checked frdm_k64f and lpcxpresso55s69 (single soc-nv-flash
instance each) to confirm no regression.
Signed-off-by: Peter Wang <chaoyi.wang@nxp.com>
1. The NOR and NAND in the MCXN947 board are mutually exclusive,
add memc include for CONFIG_FLASH_MCUX_FLEXSPI_NAND.
2. Add Quad I/O enable, otherwise MX35LF1GE4AB write normal
but read fail
Signed-off-by: Neil Chen <cheng.chen_1@nxp.com>
Refactor Renesas OSPI_B driver to support multiple 8D-8D-8D,
1S-4S-4S, 4S-4S-4S
SPI NOR flash devices:
- Update init flow to get command value from the SFDP tables
- Update API function to support multiple protocol modes
Signed-off-by: Khoa Nguyen <khoa.nguyen.xh@renesas.com>
When CONFIG_STM32_APP_IN_EXT_FLASH and CONFIG_XIP are enabled, XSPI
initialization is skipped because the bootloader
has already configured it.
Therefore in this fast path HAL_XSPI_Init() is not called and the
timeout value stays at 0.
This PR fixes the fast path and initialize the timeout to
HAL_XSPI_TIMEOUT_DEFAULT_VALUE.
Signed-off-by: Julien Racki <julien.racki-ext@st.com>
The build warning caused twister error on stm32h5 boards
It can now be removed as all the stm32h5 boards have the MSPI
controller compatible.
Simply add a comment in the flash xspi driver to notify that
the flash stm32 xspi driver will be deprecated v4.5.0
Signed-off-by: Francois Ramu <francois.ramu@st.com>
Typically Zephyr device tree macros that take a node_id as argument
start with DT_ and those that take an inst start with DT_INST_.
For the STM32 clock driver we currently have two macros named
STM32_DT_INST_CLOCK_INFO_BY_NAME and STM32_CLOCK_INFO_BY_NAME.
For consistency, the latter is renamed STM32_DT_CLOCK_INFO_BY_NAME.
Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
File was missing a semicolon, without which it didn't compile if
CONFIG_FLASH_RENESAS_RA_HP_CHECK_BEFORE_READING was set
Signed-off-by: Paolo Bazzanella <pbazzanella@qubicaamf.com>
Fixes various issues with Kconfigs, including:
- Using the wrong indentation
- Not having [EXPERIMENTAL] in the prompt, or not having it at
the end
- Wrongly stating the CONFIG_EXPERIMENTAL is needed to enable
an experimental Kconfig
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Add a semihosted flash driver, which utilizes the semihosting interface
to write to a flash file on the host. The flash file will be created if
it does not exist, but otherwise an existing flash file is used. This
driver can therefore be used for testing flash in cases where the
contents need to be set before application startup (such as mcuboot)
Assisted-by: Claude:claude-haiku-4-5
Signed-off-by: Daniel DeGrasse <daniel.degrasse@analog.com>
Add driver for Silicon Labs Series 3 EXTMEM flash controlled by
the SE. The initial version of the driver supports reading from
and getting the layout of the entire flash, but only writing
and erasing data regions.
Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
The SFDP configuration path programmed ERASE_SECTOR/ERASE_BLOCK with the
classic 0x20/0xD8 opcodes and strode range erases by an assumed 64 KiB
block size, regardless of what the flash declares. On parts whose block
erase is larger (e.g. the ISSI IS25WX01G declares 128 KiB for 0xD8),
each block-erase step wipes 64 KiB more than the loop accounts for,
erasing past the end of the requested range.
Select the erase opcodes from the BFP erase types (DW8-DW9) instead: the
type matching the driver's 4 KiB sector size for ERASE_SECTOR, and the
largest declared type for ERASE_BLOCK, with the block erase stride taken
from that type's actual size. Erase types beyond the advertised BFP
table length are skipped, as are types declaring a nonsensical size.
Vendor-specific and default LUT paths keep the 64 KiB assumption they
hard-code today.
Assisted-by: Claude:claude-fable-5
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Choose the per-chip config at build time from the node compatible
instead of matching device-name at runtime.
Signed-off-by: Ruijia Wang <ruijia.wang@nxp.com>
Generalise the octal-only driver to a per-chip config and LUT table
so it can also drive the on-board Winbond W25Q512NW quad SPI NOR on
RT700 XSPI0. The octal path is unchanged.
Signed-off-by: Ruijia Wang <ruijia.wang@nxp.com>
Restore memory mapping between chunks to limit the time interrupts
are masked to a single chunk instead of the entire operation.
Signed-off-by: Julien Racki <julien.racki-ext@st.com>
When CONFIG_FLASH_STM32_XSPI_XIP_RELOCATE is enabled, ISR handlers
are in flash. Lock IRQs for the entire write/erase operation while
memmap is off to prevent executing code from flash.
Signed-off-by: Julien Racki <julien.racki-ext@st.com>
When the device is already in memory-mapped XIP mode at boot, the full
init sequence is skipped. Set address_width and write_opcode to valid
defaults based on device config so that write and erase operations have
correct parameters without requiring a full re-init.
Signed-off-by: Julien Racki <julien.racki-ext@st.com>
Refactor internal helpers to take dev_data directly instead of struct
device, removing dev->data and dev->config calls that cause flash
accesses while executing from RAM.
Also zero-initialize XSPI_RegularCmdTypeDef to avoid implicit memset
calls from flash.
Signed-off-by: Julien Racki <julien.racki-ext@st.com>