drivers/mtd: Add W25N SPI NAND flash driver
Build Documentation / build-html (push) Has been cancelled

Add MTD driver for Winbond W25N series SPI NAND flash.

Currently supports W25N01GV (1Gbit/128MB).

Features:
- Standard SPI interface with configurable frequency (up to 104 MHz)
- Hardware ECC enabled by default
- Block erase with sleep-based wait (releases SPI bus)
- Page read/write with busy-wait for fast operations

Limitations:
- No bad block management (BBM). Factory bad blocks and runtime bad
  blocks are not tracked.
- No bad block table (BBT) scanning at initialization.
- No Quad SPI support (standard SPI only).
- No access to spare area (64 bytes/page) or OTP region.

Tested using:
- Board with STM32H743
- W25N01GV on SPI at 96 MHz with DMA enabled
- Flash mounted using littlefs
- Tested using sdbench:
  - Sequential write speed of 1760 KB/s
  - Sequential read speed of 4900 KB/s

Signed-off-by: Julian Oes <julian@oes.ch>
This commit is contained in:
Julian Oes
2025-12-17 13:26:24 +13:00
committed by Xiang Xiao
parent 7003a2c14d
commit 7e46d282eb
5 changed files with 983 additions and 1 deletions
+4
View File
@@ -138,6 +138,10 @@ if(CONFIG_MTD)
list(APPEND SRCS gd5f.c)
endif()
if(CONFIG_MTD_W25N)
list(APPEND SRCS w25n.c)
endif()
if(CONFIG_MTD_AT25)
list(APPEND SRCS at25.c)
endif()
+22
View File
@@ -1441,6 +1441,28 @@ config GD5F_SPIFREQUENCY
endif # MTD_GD5F
config MTD_W25N
bool "SPI-based W25N NAND FLASH"
default n
select SPI
---help---
Enable support for Winbond W25N SPI NAND flash.
Currently only W25N01GV (1Gbit/128MB) is supported.
if MTD_W25N
config W25N_SPIMODE
int "W25N SPI Mode"
default 0
config W25N_SPIFREQUENCY
int "W25N SPI Frequency"
default 20000000
---help---
W25N01GV supports up to 104 MHz.
endif # MTD_W25N
config MTD_DHARA
bool "MTD Nandflash use dhara map"
default n
+4
View File
@@ -141,6 +141,10 @@ ifeq ($(CONFIG_MTD_GD5F),y)
CSRCS += gd5f.c
endif
ifeq ($(CONFIG_MTD_W25N),y)
CSRCS += w25n.c
endif
ifeq ($(CONFIG_MTD_AT25),y)
CSRCS += at25.c
endif
+941
View File
File diff suppressed because it is too large Load Diff
+12 -1
View File
@@ -616,7 +616,7 @@ FAR struct mtd_dev_s *sst39vf_initialize(void);
*
* Description:
* Initializes the driver for SPI-based W25x16, x32, and x64 and W25q16,
* q32, q64, and q128 FLASH
* q32, q64, and q128 NOR FLASH
*
****************************************************************************/
@@ -655,6 +655,17 @@ FAR struct mtd_dev_s *gd55_initialize(FAR struct qspi_dev_s *dev,
FAR struct mtd_dev_s *gd5f_initialize(FAR struct spi_dev_s *dev,
uint32_t spi_devid);
/****************************************************************************
* Name: w25n_initialize
*
* Description:
* Initializes the driver for SPI-based W25N NAND FLASH
*
****************************************************************************/
FAR struct mtd_dev_s *w25n_initialize(FAR struct spi_dev_s *dev,
uint32_t spi_devid);
/****************************************************************************
* Name: s25fl1_initialize
*