Skip to content

add spi nand driver #50690

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rogeryou
Copy link

This PR is updated for #43915.

Add SPI NAND block device driver for using SPI NAND Flash like Macronix Flash MX31LF4GE4BC.
This driver is tested on STM32L562E-DK.

The license of BCH code is updated.

Copy link
Member

@erwango erwango left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this contribution.
Some clean up required.
My main request would be to remove STM32 mentions, since there is nothing STM32 specific here aside from the board used for test.

@erwango erwango removed the platform: STM32 ST Micro STM32 label Sep 27, 2022
@carlescufi
Copy link
Member

@rogeryou can you please format your commits as described here:
https://docs.zephyrproject.org/latest/contribute/guidelines.html#commit-guidelines

@rogeryou rogeryou force-pushed the macronix_spi_nand_v1 branch from 9755c14 to 901b863 Compare September 28, 2022 03:16
@rogeryou
Copy link
Author

@rogeryou can you please format your commits as described here: https://docs.zephyrproject.org/latest/contribute/guidelines.html#commit-guidelines

I have formated my commits.

@Laczen
Copy link
Collaborator

Laczen commented Sep 29, 2022

@rogeryou, thank you for this contribution. It would be very nice to have nand flash support in zephyr.

Regarding the PR, I have seen that the ecc is hidden for the user as to be able to use the standard flash interface. This is a good thing, but doesn't this also make any other part of the oob data unavailable ? IMHO it would be good to extend the flash driver for nand flashes with read/write possibilities of the oob data. This would allow adding bad block info to the oob area.

@RyKolb
Copy link

RyKolb commented Nov 1, 2022

@rogeryou
It seems as though part of this driver is written for either a 2048 or 4096 page size NAND flash, and yet other parts use the defined page/block offset/mask. Is there reasoning behind this?

@carlescufi carlescufi requested review from Laczen and removed request for GeorgeCGV, gmarull and mbolivar-nordic November 2, 2022 14:12
erwango
erwango previously requested changes Nov 8, 2022
@rogeryou
Copy link
Author

@rogeryou, thank you for this contribution. It would be very nice to have nand flash support in zephyr.

Regarding the PR, I have seen that the ecc is hidden for the user as to be able to use the standard flash interface. This is a good thing, but doesn't this also make any other part of the oob data unavailable ? IMHO it would be good to extend the flash driver for nand flashes with read/write possibilities of the oob data. This would allow adding bad block info to the oob area.

Thank you for your suggestion. We will add APIs that operate OOB later.

@rogeryou rogeryou closed this Nov 23, 2022
@rogeryou
Copy link
Author

@rogeryou It seems as though part of this driver is written for either a 2048 or 4096 page size NAND flash, and yet other parts use the defined page/block offset/mask. Is there reasoning behind this?

Could you tell me which part of the program you mentioned?

@rogeryou rogeryou reopened this Nov 23, 2022
@zephyrbot zephyrbot added the area: Devicetree Binding PR modifies or adds a Device Tree binding label Nov 23, 2022
@daniel-0723 daniel-0723 force-pushed the macronix_spi_nand_v1 branch 3 times, most recently from 555fd5d to eaf79f9 Compare May 28, 2025 01:57
Comment on lines 1041 to 1052
DEVICE_DT_INST_DEFINE(0, &spi_nand_init, NULL,
&spi_nand_data_0, &spi_nand_config_0,
POST_KERNEL, CONFIG_SPI_NAND_INIT_PRIORITY,
&spi_nand_api);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it would be possible to have multiple instances use, DT_INST_FOREACH_STATUS_OKAY

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I may, I think that we can do that later, I would really like to focus on having even one instance driver working at this point.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but this isn't difficult to do really?

Copy link
Collaborator

@de-nordic de-nordic May 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it is not, it is just few more lines. But these are another few lines to review before we get this thing in. Something we can easily get done later.
I doubt that you will have immediate need to connect N devices, if you have not been able to connect one for so long.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want driver specific samples? Can't you re-use the existing flash driver sample?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SPI NAND Flash is a page-program type device and does not support 4-byte data programming. We also plan to add some software ECC test cases later.

@daniel-0723 daniel-0723 force-pushed the macronix_spi_nand_v1 branch 3 times, most recently from 3d4d13d to ad279f4 Compare June 2, 2025 02:07
Copy link
Collaborator

@pdgendt pdgendt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commit should be split in two, one for the driver and another for the sample.

@daniel-0723 daniel-0723 force-pushed the macronix_spi_nand_v1 branch 5 times, most recently from 381b034 to ead3591 Compare June 3, 2025 06:55
@daniel-0723 daniel-0723 force-pushed the macronix_spi_nand_v1 branch from ead3591 to 4236599 Compare June 4, 2025 06:05
@daniel-0723
Copy link

@de-nordic @pdgendt Please review again.

Copy link
Collaborator

@pdgendt pdgendt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please run clang-format on the new .c/.h files.

@daniel-0723 daniel-0723 force-pushed the macronix_spi_nand_v1 branch from 4236599 to 11f2630 Compare June 4, 2025 12:35
@daniel-0723 daniel-0723 force-pushed the macronix_spi_nand_v1 branch from 11f2630 to d580172 Compare June 9, 2025 02:45
@daniel-0723 daniel-0723 force-pushed the macronix_spi_nand_v1 branch from d580172 to 90e3228 Compare June 9, 2025 11:48
@pdgendt pdgendt dismissed their stale review June 9, 2025 12:01

Unblock the PR

@daniel-0723 daniel-0723 force-pushed the macronix_spi_nand_v1 branch 2 times, most recently from f5bd58e to e352357 Compare June 9, 2025 12:34
Add SPI NAND Flash driver support

Signed-off-by: Daniel Zhang <[email protected]>
@daniel-0723 daniel-0723 force-pushed the macronix_spi_nand_v1 branch from e352357 to 84f8da1 Compare June 9, 2025 13:51
Copy link

sonarqubecloud bot commented Jun 9, 2025

@daniel-0723
Copy link

@de-nordic Please review again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.