mcu-tools / mcuboot

Secure boot for 32-bit Microcontrollers!
Apache License 2.0
1.25k stars 648 forks source link

zephyr: Compilation fails when CONFIG_FLASH_PAGE_LAYOUT is disabled #1565

Open de-nordic opened 1 year ago

de-nordic commented 1 year ago

The MCUboot support code provides the flash_area_get_sectors implementation in https://github.com/mcu-tools/mcuboot/blob/main/boot/zephyr/flash_map_legacy.c for devices that does not have support for "flash pages layout", Devices that provide support for pages layout select CONFIG_FLASH_HAS_PAGE_LAYOUT that enables option CONFIG_FLASH_PAGE_LAYOUT; this option is selected (enforced) when available by the CONFIG_MCUBOOT_DEVICE_SETTINGS, so to test this a device that does not select CONFIG_FLASH_HAS_PAGE_LAYOUT needs to be selected or https://github.com/mcu-tools/mcuboot/blob/46e554e7c080936fbcbbcae38be84995e8165d0d/boot/zephyr/Kconfig#L612-L621 has to be modified in line 613 to not select the option. After such configuration is prepared, the below command executed from Zephyr root:

west build -d voot -b nrf52840dk_nrf52840 bootloader/mcuboot/boot/zephyr/ -DCONFIG_FLASH_PAGE_LAYOUT=n

causes following warnings and errors (and a lot more):

...
<redacted>mcuboot-fixes/bootloader/mcuboot/boot/zephyr/flash_map_legacy.c:49:38: note: each undeclared identifier is reported only once for each function it appears in
   49 | #define FLASH_AREA_IMAGE_SECTOR_SIZE FLASH_AREA_IMAGE_SCRATCH_SIZE
      |                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<redacted>mcuboot-fixes/bootloader/mcuboot/boot/zephyr/flash_map_legacy.c:81:23: note: in expansion of macro 'FLASH_AREA_IMAGE_SECTOR_SIZE'
   81 |         if (rem_len < FLASH_AREA_IMAGE_SECTOR_SIZE) {
      |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from <redacted>mcuboot-fixes/zephyr/include/zephyr/sys/util_macro.h:34,
                 from <redacted>mcuboot-fixes/zephyr/include/zephyr/sys/util.h:17,
                 from <redacted>mcuboot-fixes/zephyr/include/zephyr/devicetree.h:21,
                 from <redacted>mcuboot-fixes/bootloader/mcuboot/boot/zephyr/include/mcuboot_config/mcuboot_config.h:12,
                 from <redacted>mcuboot-fixes/bootloader/mcuboot/boot/bootutil/include/bootutil/bootutil_log.h:28:
<redacted>mcuboot-fixes/zephyr/include/zephyr/logging/log_msg.h:442:65: error: '_v3' undeclared (first use in this function); did you mean '_v2'?
  442 | #define Z_LOG_LOCAL_ARG_NAME(idx, arg) COND_CODE_0(idx, (arg), (_v##idx))
      |                                                                 ^~
<redacted>mcuboot-fixes/zephyr/include/zephyr/sys/util_internal.h:72:26: note: in definition of macro '__DEBRACKET'
   72 | #define __DEBRACKET(...) __VA_ARGS__
      |                          ^~~~~~~~~~~
<redacted>mcuboot-fixes/zephyr/include/zephyr/sys/util_internal.h:64:9: note: in expansion of macro '__GET_ARG2_DEBRACKET'
...
redacted>mcuboot-fixes/bootloader/mcuboot/boot/bootutil/include/bootutil/bootutil_log.h:33:27: note: in expansion of macro 'MCUBOOT_LOG_ERR'
   33 | #define BOOT_LOG_ERR(...) MCUBOOT_LOG_ERR(__VA_ARGS__)
      |                           ^~~~~~~~~~~~~~~
<redacted>mcuboot-fixes/bootloader/mcuboot/boot/zephyr/flash_map_legacy.c:82:13: note: in expansion of macro 'BOOT_LOG_ERR'
   82 |             BOOT_LOG_ERR("area %d size 0x%x not divisible by sector size 0x%x",
      |             ^~~~~~~~~~~~
In file included from <redacted>mcuboot-fixes/zephyr/include/zephyr/toolchain.h:50,
                 from <redacted>mcuboot-fixes/zephyr/include/zephyr/sys/__assert.h:11,
                 from <redacted>mcuboot-fixes/zephyr/modules/hal_nordic/nrfx/./nrfx_glue.h:10,
                 from <redacted>mcuboot-fixes/modules/hal/nordic/nrfx/nrfx.h:39,
                 from <redacted>mcuboot-fixes/modules/hal/nordic/nrfx/drivers/include/nrfx_wdt.h:37,
                 from <redacted>mcuboot-fixes/bootloader/mcuboot/boot/zephyr/include/mcuboot_config/mcuboot_config.h:262:
<redacted>mcuboot-fixes/zephyr/include/zephyr/sys/cbprintf_internal.h:300:22: error: expression in static assertion is not an integer
  300 |         BUILD_ASSERT(!((sizeof(double) < VA_STACK_ALIGN(long double)) && \
      |                      ^
<redacted>mcuboot-fixes/zephyr/include/zephyr/toolchain/gcc.h:78:51: note: in definition of macro 'BUILD_ASSERT'
   78 | #define BUILD_ASSERT(EXPR, MSG...) _Static_assert(EXPR, "" MSG)
      |                                                   ^~~~
<redacted>mcuboot-fixes/zephyr/include/zephyr/sys/cbprintf_internal.h:345:9: note: in expansion of macro 'Z_CBPRINTF_PACK_ARG2'
...
github-actions[bot] commented 1 year ago

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.

github-actions[bot] commented 6 months ago

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.

github-actions[bot] commented 2 days ago

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.