Skip to content
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

feat(spi_nand_flash): Add Kconfig option to verify write operations #436

Merged

Conversation

RathiSonika
Copy link
Collaborator

@RathiSonika RathiSonika commented Oct 22, 2024

Change description

  1. Added an Kconfig option to verify write operations which will be useful when debugging hardware issues or issues with the driver itself.
  2. Fixed an issue in the spi_nand_erase_chip() API where the mutex was not released, leading to a deadlock if another API attempted to acquire the mutex after calling spi_nand_erase_chip(). Updated test case for the same.
  3. Added spi_nand_flash_copy_sector() API in nand.c and test case for the same.

@RathiSonika RathiSonika marked this pull request as draft October 22, 2024 09:43
@RathiSonika RathiSonika force-pushed the feat/nand_flash_write_verify branch 2 times, most recently from f4d2a95 to 0ac8c3c Compare October 23, 2024 07:13
@RathiSonika RathiSonika marked this pull request as ready for review October 23, 2024 07:19
@RathiSonika RathiSonika marked this pull request as draft October 23, 2024 07:26
@RathiSonika RathiSonika force-pushed the feat/nand_flash_write_verify branch 2 times, most recently from be53084 to 01fe332 Compare October 23, 2024 07:49
@RathiSonika RathiSonika requested a review from igrr October 23, 2024 07:51
@RathiSonika RathiSonika marked this pull request as ready for review October 23, 2024 12:59
Copy link
Member

@igrr igrr 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 the PR @RathiSonika.

I left a few minor comments. The major one is whether we should indeed verify writes above Dhara layer, like you did, or below it, in nand.c dhara_glue.c.

To me it seems that verifying writes at lower layer achieves the goal of making sure our Flash operations work correctly, while verifying at upper layer doesn't.

We do writes to Flash in dhara_nand_prog, dhara_nand_copy, dhara_nand_mark_bad. If we fail to perform the write in dhara_nand_mark_bad correctly, we might not get the verification error in spi_nand_flash_write_sector. Dhara will consider the page as "bad" until next reset, but after reset we will mistakenly detect the page as not "bad" because the bad block marker wasn't written correctly.

spi_nand_flash/src/nand.c Outdated Show resolved Hide resolved
spi_nand_flash/src/nand.c Outdated Show resolved Hide resolved
spi_nand_flash/src/nand.c Outdated Show resolved Hide resolved
spi_nand_flash/src/nand.c Outdated Show resolved Hide resolved
spi_nand_flash/idf_component.yml Outdated Show resolved Hide resolved
@RathiSonika
Copy link
Collaborator Author

The major one is whether we should indeed verify writes above Dhara layer, like you did, or below it, in nand.c.

I had the same thought to add it in below Dhara layer. Currently added it to nand.c. I wasn’t entirely sure if it should go in dhara_glue.c, given its tight coupling with the Dhara library. However, you’re right; we should verify the write operation below Dhara layer. So, for the current structure, it makes sense to add this in dhara_glue.c. We could consider refactoring this in the future.

@RathiSonika RathiSonika force-pushed the feat/nand_flash_write_verify branch 4 times, most recently from a7220f2 to 33f6ef4 Compare October 31, 2024 08:58
@RathiSonika RathiSonika requested a review from igrr October 31, 2024 15:04
spi_nand_flash/src/dhara_glue.c Show resolved Hide resolved
@RathiSonika RathiSonika force-pushed the feat/nand_flash_write_verify branch from 33f6ef4 to 4e8026d Compare November 1, 2024 13:53
spi_nand_flash/src/nand.c Dismissed Show dismissed Hide dismissed
@RathiSonika RathiSonika force-pushed the feat/nand_flash_write_verify branch from 4e8026d to 794a352 Compare November 1, 2024 13:59
@RathiSonika RathiSonika force-pushed the feat/nand_flash_write_verify branch from 794a352 to c45d3aa Compare November 4, 2024 06:59
@RathiSonika RathiSonika merged commit 3987e36 into espressif:master Nov 4, 2024
48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants