-
Notifications
You must be signed in to change notification settings - Fork 8.2k
drivers/flash: Add flash_get_parameters call to flash API #25947
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: Add flash_get_parameters call to flash API #25947
Conversation
eaaef7e to
5c9169e
Compare
|
All checks passed. Tip: The bot edits this comment instead of posting a new one, so you can check the comment's history to see earlier messages. |
5c9169e to
2560b16
Compare
nvlsianpu
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.
I like how code looks like now.
Is it possible to make erased_val configurable for flash simulator via DTS?
Is it then possible to add test-case with either 0xff and 0x00 erase_value for nvs test (https://github.com/zephyrproject-rtos/zephyr/blob/master/tests/subsys/fs/nvs/testcase.yaml)?
2560b16 to
4932e9a
Compare
4932e9a to
e0dc705
Compare
e0dc705 to
6e12dbd
Compare
Exactly how you are using it. Probably my remark is a result of limited c knowledge, can you assign the |
Yes, |
You want this in the doxygen of the |
I think so, yes, assuming you and others think this is worth making clear. I'd like to have this API raised during the API telecon today for visibility. But also we should confirm that nobody has a use case for the values changing for a given device while the system is running. |
I do not think there is a case for the contents of |
OK, thanks for the clarification |
e76e380 to
e13c9d8
Compare
|
NVS changes looks ok |
drivers/flash/flash_stm32.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.
This doesn't apply to all series.
On a handfull, this should be 0x00.
I'll get back to you with the references
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.
OK, thanks for looking into this.
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.
@utzig has mentioned same thing here: #25947 (comment) though I do not know how does it apply to our stm32 drivers.
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.
@erwango Can you advise me on the stm32 characteristic values for erase_value?
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.
@de-nordic After check, only L0/L1 use 0x00 as erase value (I guess reason is they have an EEPROM and this is easier to use same erase value for both).
Since L0/L1 have no flash driver yet, proposed code is fine. Maybe adding a warning comment in case of L0/L1 future addition would be a nice thing though.
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.
@erwango Thanks for the information. Will add warning information.
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.
There is a PR for an L0 driver (#25245) that will hit this issue. The easiest way to distinguish between the EEPROM and FLASH implementations is probably to check for the FLASH_CR_LOCK (erase value 0xff) or FLASH_PECR_PELOCK (erase value 0x00). It's not exactly pretty, but it avoids hard-coding the SOC family.
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.
There is a PR for an L0 driver (#25245) that will hit this issue. The easiest way to distinguish between the EEPROM and FLASH implementations is probably to check for the FLASH_CR_LOCK (erase value 0xff) or FLASH_PECR_PELOCK (erase value 0x00). It's not exactly pretty, but it avoids hard-coding the SOC family.
@andysan, does this mean that also for L0 the flash erase value is 0xff?
e13c9d8 to
68607a7
Compare
|
@pabigot @nvlsianpu could you take another look please? |
pabigot
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.
OK as is, a couple minor cleanups identified.
drivers/flash/flash_simulator.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.
Placement of this one isn't the same as the others.
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.
Done
include/drivers/flash.h
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.
I'd make this end at "copy its contents." The rest is opinion that isn't good advice for some uses. If you want it anyway just change "if preferred" to "is the preferred".
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.
Done
68607a7 to
eba084c
Compare
eba084c to
051eeaa
Compare
Adds flash_get_parameters call to API that returns pointer to structure describing flash parameters. Currently only erase_value parameter is provided via the structure. Signed-off-by: Dominik Ermel <[email protected]>
With addition of flash_get_parameters API call, it is needed to provide support for the API to flash drivers. Signed-off-by: Dominik Ermel <[email protected]>
Use new flash API call to obtain erase value instead of relaying on hardcoded literals. Signed-off-by: Dominik Ermel <[email protected]>
With addition of flash_parameters structure, and supporting API call to retrieve it, it is no longer needed to store write_block_size as a part of flash_driver_api and it should be part of flash_parameters. Signed-off-by: Dominik Ermel <[email protected]>
Pointer to flash_parameters have been added to nvs_fs structure and it is no longer needed to store write_block_size within the nvs_fs. Signed-off-by: Dominik Ermel <[email protected]>
051eeaa to
a946de6
Compare
Provided call returns const pointer to flash_parameters structure that can be used for passing memory parameters from drivers.
Resolves #22063