Skip to content

Suggestion on the framework of Flash driverΒ #46399

@rogeryou

Description

@rogeryou

As a Flash manufacturer, we hope to integrate various types of Flash drivers in Zephyr, such as SPI NOR Flash ,QSPI NOR Flash, Octal NOR Flash, SPI NAND Flash and ONFI NAND Flash.

We found that the framework of the existing Flash driver is shown in the following figure.
1

In the Flash folder there are various drivers, even for the same type of Flash, such as flash_stm32_qspi.c, nrf_qspi_nor.c. Each MCU manufacturer maintains a separate driver, which we think is inconvenient to maintain.

Therefore, we propose to modify the framework structure of the Flash driver. We divide the drivers of QSPI NOR Flash and OSPI NOR Flash into two layers, just like the drivers of SPI NOR Flash. The upper layer is a pure Flash driver. Each type of Flash has only one driver file. This layer has nothing to do with which MCU is used.

The lower layer is about the drivers of the Flash controllers of various MCU manufacturers. For example, the QSPI controller of ST corresponds to qspi_ll_stm32.c, the OSPI controller of ST corresponds to ospi_ll_stm32.c, and other manufacturers implement the corresponding ospi_xx. c. Each program in this layer needs to provide several APIs for the upper layer to call, such as ospi_read() and ospi_write() and so on.

We provide the following two solutions, as shown in the figure below:
2

We consider SPI NAND Flash and ONFI NAND Flash, and the expansion of the above picture is as follows:
3

We consider that there are already definitions for QSPI and OSPI modes in spi.h, and some drivers use these definitions, we provide solution 2:
4

At present, we have implemented the modification of the OSPI related program of solution 2, and passed the test on the STM32L562E-DK development board. A PR will be submitted later.

Metadata

Metadata

Assignees

Labels

RFCRequest For Comments: want input from the communityarea: Flash

Type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions