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

boot: zephyr: Add check for unexpected flash sector size #2059

Merged
merged 3 commits into from
Sep 27, 2024

Conversation

nordicjm
Copy link
Collaborator

Prints a debug log message if the device has a write block size for a flash device in DTS that is not the same as what the flash driver reports at run-time, this can be used to see if there is a faulty configuration as these compile-time values are used for various calculations

@butok

@nordicjm nordicjm force-pushed the adddbglog branch 2 times, most recently from 41f7c97 to 4cf4f32 Compare September 10, 2024 14:37
@butok
Copy link
Contributor

butok commented Sep 18, 2024

It should also check the program size (not only the sector size).

@nordicjm
Copy link
Collaborator Author

It should also check the program size (not only the sector size).

That's already done at runtime

Prints a debug log message if the device has a write block size
for a flash device in DTS that is not the same as what the flash
driver reports at run-time, this can be used to see if there is
a faulty configuration as these compile-time values are used for
various calculations

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
@nordicjm
Copy link
Collaborator Author

It should also check the program size (not only the sector size).

Right I see what you mean, have added it

Adds write block size checking functionality and includes a
zephyr implementation, this will not throw an error or prevent
upgrade but will emit a debug log with a discrepency message

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Adds notes on these new features

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
@de-nordic
Copy link
Collaborator

This does not support configurations with external mem, right? Because with external mem there is no write-block-size/erase-block-size.

@nordicjm
Copy link
Collaborator Author

This does not support configurations with external mem, right? Because with external mem there is no write-block-size/erase-block-size.

It does, but it is driver dependent, for example one of the nxp ones had a write block size of 8 in dts which was wrong, and something like spi-nor might have a value in dts if it uses static configuration or nothing if it uses sfdp

@de-nordic
Copy link
Collaborator

This does not support configurations with external mem, right? Because with external mem there is no write-block-size/erase-block-size.

It does, but it is driver dependent, for example one of the nxp ones had a write block size of 8 in dts which was wrong, and something like spi-nor might have a value in dts if it uses static configuration or nothing if it uses sfdp

Bindings for spi-nor and qspi-nor does not provide definition of write-block-size, it is provided via Kconfig option, so only via simplified or run-time sfdp. There is though CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE that specifies erase page size for SPI... does not pair well with multi-instance spi-nor driver.

@nordicjm
Copy link
Collaborator Author

This does not support configurations with external mem, right? Because with external mem there is no write-block-size/erase-block-size.

It does, but it is driver dependent, for example one of the nxp ones had a write block size of 8 in dts which was wrong, and something like spi-nor might have a value in dts if it uses static configuration or nothing if it uses sfdp

Bindings for spi-nor and qspi-nor does not provide definition of write-block-size, it is provided via Kconfig option, so only via simplified or run-time sfdp. There is though CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE that specifies erase page size for SPI... does not pair well with multi-instance spi-nor driver.

Bad name, but this spi nor driver is what I mean: https://github.com/zephyrproject-rtos/zephyr/blob/main/boards/nxp/mimxrt1020_evk/mimxrt1020_evk.dts#L104

@de-nordic
Copy link
Collaborator

Bad name, but this spi nor driver is what I mean: https://github.com/zephyrproject-rtos/zephyr/blob/main/boards/nxp/mimxrt1020_evk/mimxrt1020_evk.dts#L104

OK, that is new to me as there is not such definition in dts bindings for the compatible.

@nordicjm nordicjm merged commit 71bccff into mcu-tools:main Sep 27, 2024
58 checks passed
@erwango
Copy link

erwango commented Nov 13, 2024

This change broke mcuboot usage on STM32F2, STM32F4 and STM32F7 series in which use sectors of variable sizes. On these series, erase-block-size depends on sector size and then cannot be defined in flash controller parent.

@nordicjm
Copy link
Collaborator Author

This change broke mcuboot usage on STM32F2, STM32F4 and STM32F7 series in which use sectors of variable sizes. On these series, erase-block-size depends on sector size and then cannot be defined in flash controller parent.

This change specifically? I can configure for nucleo_f401re when building with CONFIG_BOOT_MAX_IMG_SECTORS_AUTO=n, if you don't then you get a math error with this warning a bit before that:

CMake Warning at CMakeLists.txt:441 (message):
  Unable to calculate minimum number of sector sizes, falling back to 128
  sector default.  Please disable CONFIG_BOOT_MAX_IMG_SECTORS_AUTO and set
  CONFIG_BOOT_MAX_IMG_SECTORS to the required value

@erwango
Copy link

erwango commented Nov 13, 2024

This change specifically?

Ok, fair enough. Let me reword: This change is not compatible with bla bla bla

@butok
Copy link
Contributor

butok commented Nov 13, 2024

Probably, CONFIG_BOOT_MAX_IMG_SECTORS_AUTO=n should be set in STM32F2, STM32F4 and STM32F7 configuration files.

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

Successfully merging this pull request may close these issues.

4 participants