-
Notifications
You must be signed in to change notification settings - Fork 8.2k
drivers: flash: bug fix stm32 ospi flash erase #53598
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
drivers: flash: bug fix stm32 ospi flash erase #53598
Conversation
|
Hit the wrong button. Not reviewed yet. |
2d5b22b to
c949c35
Compare
c949c35 to
0a66516
Compare
DhruvaG2000
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my humble opinion the commit message need not have,
Tested with: west build -b b_u585i_iot02a samples/drivers/spi_flash
In general commit message dont have tested with ... Commit should explain just what the change is doing and that should be enough.
samples/drivers/spi_flash is updated to check for this condition.
We can see with git stat which file is being edited, I think this too can be dropped.
Otherwise the commit message is fine. I am yet to review the code changes.
DhruvaG2000
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels like you are doing one-too many things as part of a single commit, please see if you can split up these changes.
In my humble opinion we can split up the changes in sample and driver into 2 commits.
I would even split the sample changes because you are doing multiple things in the sample itself, reading, erasing and writing the flash.
I would strongly suggest splitting up these changes into 2-3 commit messages suiting each change.
Also note that each commit should independently build and be functional, so split it keeping this in mind. I dont see much new additions like change of API's so this should not be too difficult a task.
drivers/flash/flash_stm32_ospi.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the code of the flash_stm32_ospi_write() function fits here :
| if (stm32_ospi_write_enable(&dev_data->hospi, | |
| ret = stm32_ospi_write_enable(&dev_data->hospi, | |
| dev_cfg->data_mode, dev_cfg->data_rate); | |
| if (ret != 0) { | |
| LOG_ERR("Erase failed : write enable"); | |
| break; | |
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I will update this
drivers/flash/flash_stm32_ospi.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it really needed ?
when breaking the
ospi_unlock_thread(dev); comes just before the return ret; out of the while loop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will fix this
0a66516 to
f67f6ba
Compare
erwango
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
samples/drivers/spi_flash is updated to check for this condition.
Samples are mainly meant to demonstrate use of subsystems (flash drivers in this case).
If you want to test specific conditions, modify tests/drivers/flash.
f67f6ba to
6d15777
Compare
The tests in 'tests/drivers/flash' tests the internal flash of the MCU. I really don't want to change this - but at the same time have an option to test my modifications |
Then we might need dedicated "SPI Flash" tests. But I stand on the position that samples should not be used for extensive testing. |
|
I respect your position. That being said, creating a new testsuite for an otherwise totally untested driver is imo way out of scope for submitting a bugfix. My objective with this PR was is to fix a bug that we spent quite some time to narrow down, so that others would not have to spent the same effort. I tried to be a nice guy and updated the sample to prove that the change I did worked. I have already spent way much more time on submitting this issue than I can afford, so I now see 3 options:
Option 3 would nor really improve the quality of of zephyr going forward. Please let me know which option you chose. |
|
@tu-brian The real issue in current case is that there is no real spi flash test suite. |
6d15777 to
cdacb84
Compare
I am willing to accept the sample test, although I am not fine with making multi-sector test dependent on the CONFIG_FLASH_STM32_OSPI, because the sample should have generic behaviour for all SPI boards. @erwango Regarding lack of SPI flash tests I will log an Issue with Zephyr for the flash subsystem, as an enhancement, and will make it 3.4 target to have SPI flash test available. This sample is already unfortunate to use "test" in some of the messages, so it's could be misunderstood to serve dual purpose. |
|
What Can I do to move this issue forward? |
One question, why the flash tests, that are here https://github.com/zephyrproject-rtos/zephyr/tree/main/tests/drivers/flash, can not be altered to do the testing here? |
|
I tried to enable the tests https://github.com/zephyrproject-rtos/zephyr/tree/main/tests/drivers/flash for the board in question - only to find that the only test present failed, due to unaligned access not being support for the flash device in question. I have already spent way much more time on submitting this issue than I can afford, so I now see 3 options:
Option 3 would nor really improve the quality of of zephyr going forward. Please let me know which option you chose. |
de-nordic
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks OK.
Approving with sample used to test the fix. I will log an issue for flash drivers/tests to extend tests to cover more scenarios including the one tested by sample.
|
Hey there's a couple of missing CI tests, can't submit without those, I'm kicking a rebase to retrigger them. |
This commit fixes a bug in the STM32 ospi flash driver when attempting to erase an area that spans more than one erase sector. Without this fix, only the first sector is actually erased, the rest silently fails the erase. Issue is that the write enable latch command is only sent for the first erase command. Signed-off-by: Brian Juel Folkmann <[email protected]>
Add tests for erase of multiple consequtive sectors. Signed-off-by: Brian Juel Folkmann <[email protected]>
cdacb84 to
c6e50ed
Compare
c6e50ed
| } else { | ||
| /* Sector erase */ | ||
| LOG_DBG("Sector Erase"); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor : why blank line here and not also @ 960
This commit fixes a bug in the STM32 ospi flash driver when attempting to erase an area that spans more than one erase sector. Without this fix, only the first sector is actually erased, the rest silently fails the erase.
Issue is that the write enable latch command is only sent for the first erase command.
samples/drivers/spi_flash is updated to check for this condition.
Tested with: west build -b b_u585i_iot02a samples/drivers/spi_flash
Signed-off-by: Brian Juel Folkmann [email protected]