Open rw-wep opened 3 months ago
Hi @rw-wep! We appreciate you submitting your first issue for our open-source project. 🌟
Even though I'm a bot, I can assure you that the whole community is genuinely grateful for your time and effort. 🤖💙
This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time.
Describe the bug https://github.com/zephyrproject-rtos/zephyr/commit/adedf14c42594d167cb8f12855f7ae6097e285f1 added flags for
struct spi_nor_config
to check if among other things "requires_ulbpr" is enabled in the devicetree:https://github.com/zephyrproject-rtos/zephyr/commit/adedf14c42594d167cb8f12855f7ae6097e285f1#diff-68c9be8932318c5396390b7264802c5e6f4e495f60a136d01a2c7bdac9c08d5aR154-R162
As far as I see it, these flags are set with the macro
GENERATE_CONFIG_STRUCT()
and ifCONFIG_SPI_NOR_SFDP_RUNTIME=y
is configured, these flags are not initialized: https://github.com/zephyrproject-rtos/zephyr/commit/adedf14c42594d167cb8f12855f7ae6097e285f1#diff-68c9be8932318c5396390b7264802c5e6f4e495f60a136d01a2c7bdac9c08d5aR1688-R1691Before this change the check if "requires_ulbpr" is set in the devicetree was read out directly with the devicetree macros at the corresponding location (and it did not depend on
CONFIG_SPI_NOR_SFDP_RUNTIME
): https://github.com/zephyrproject-rtos/zephyr/commit/adedf14c42594d167cb8f12855f7ae6097e285f1#diff-68c9be8932318c5396390b7264802c5e6f4e495f60a136d01a2c7bdac9c08d5aR970-R975So to summarize:
CONFIG_SPI_NOR_SFDP_RUNTIME=y
could be used and "requires-ulbpr" defined in the device tree was used correctly to unlock the write protection of the SPI-NOR-Flash. Writing to the SPI-NOR-Flash was possible.CONFIG_SPI_NOR_SFDP_RUNTIME=y
is used writing to flash does not seem to be possible if the ULBPR command is required by the flash, because therequires_ulbpr_exist
flag in the config struct is no set if "requires-ulbpr" is defined in the devicetree.CONFIG_SPI_NOR_SFDP_DEVICETREE=y
(and adding the SFDP parameter to device tree) with this change therequires_ulbpr_exist
flag in the config struc flag is set if "requires-ulbpr" is defined in the devicetree. Writing to the SPI-NOR-Flash is possible.To Reproduce
CONFIG_SPI_NOR_SFDP_RUNTIME=y
for a hardware that has SPI-NOR-Flash that "requires-ulbpr".spi_nor.c
to check ifrequires_ulbpr_exist
flag in the config struct is set if "requires-ulbpr" defined in the device tree, when writing to SPI-NOR-Flash.Expected behavior That flags in the config struct are initialized independently if SFDP information is retrieved at runtime (
CONFIG_SPI_NOR_SFDP_RUNTIME=y
) or not.Impact I switched from reading out SFDP at runtime to configuring SFDP in the devicetree so right now there is no impact. But I had to invest some time to find out why the behaviour is different after switching to a new Zeyphr version.
Additional context I am using NCS v2.7.0 which contains this change in their used Zephyr version. As spi_nor is a Zephyr driver I created this issue here.