`PM_PROVISION_ADDRESS` undeclared when using secure boot

Hello there!

I'm trying to enable secure boot via CONFIG_SECURE_BOOT and am currently getting the following error:

In file included from /../nrf/samples/bootloader/src/main.c:13:
/../nrf/include/bl_storage.h: In function 'read_implementation_id_from_otp':
/../nrf/include/bl_storage.h:77:63: error: 'PM_PROVISION_ADDRESS' undeclared (first use in this function)
   77 | #define BL_STORAGE ((const volatile struct bl_storage_data *)(PM_PROVISION_ADDRESS))
      |                                                               ^~~~~~~~~~~~~~~~~~~~
/../nrf/include/bl_storage.h:223:38: note: in expansion of macro 'BL_STORAGE'
  223 |         otp_copy32(buf, (uint32_t *)&BL_STORAGE->implementation_id,
      |                                      ^~~~~~~~~~
/../nrf/include/bl_storage.h:77:63: note: each undeclared identifier is reported only once for each function it appears in
   77 | #define BL_STORAGE ((const volatile struct bl_storage_data *)(PM_PROVISION_ADDRESS))
      |                                                               ^~~~~~~~~~~~~~~~~~~~
/../nrf/include/bl_storage.h:223:38: note: in expansion of macro 'BL_STORAGE'
  223 |         otp_copy32(buf, (uint32_t *)&BL_STORAGE->implementation_id,
      |                                      ^~~~~~~~~~
/../nrf/include/bl_storage.h: In function 'read_life_cycle_state':
/../nrf/include/bl_storage.h:77:63: error: 'PM_PROVISION_ADDRESS' undeclared (first use in this function)
   77 | #define BL_STORAGE ((const volatile struct bl_storage_data *)(PM_PROVISION_ADDRESS))
      |                                                               ^~~~~~~~~~~~~~~~~~~~
/../nrf/include/bl_storage.h:256:29: note: in expansion of macro 'BL_STORAGE'
  256 |                 (uint32_t) &BL_STORAGE->lcs.provisioning);
      |                             ^~~~~~~~~~
/../nrf/include/bl_storage.h: In function 'update_life_cycle_state':
/../nrf/include/bl_storage.h:77:63: error: 'PM_PROVISION_ADDRESS' undeclared (first use in this function)
   77 | #define BL_STORAGE ((const volatile struct bl_storage_data *)(PM_PROVISION_ADDRESS))
      |                                                               ^~~~~~~~~~~~~~~~~~~~
/../nrf/include/bl_storage.h:321:53: note: in expansion of macro 'BL_STORAGE'
  321 |                 nrfx_nvmc_halfword_write((uint32_t)&BL_STORAGE->lcs.provisioning, STATE_ENTERED);
      |                                                     ^~~~~~~~~~
/../nrf/samples/bootloader/src/main.c: At top level:
/../nrf/samples/bootloader/src/main.c:14:10: fatal error: bl_boot.h: No such file or directory
   14 | #include <bl_boot.h>

I'm using zephyr via sdk-nrf v2.6.1

Searching the sdk-nrf repo on github for `PM_PROVISION_ADDRESS` yields few results of interest. I did manage to find this commit which removes the definition at some point, but couldn't figure out the issue past this. 

Thank you very much for your time,

Take care,

V

  • Hi,

    I am not able to find other similar issues. Can you share your project configuration and how you enabled secure boot (where did. you put CONFIG_SECURE_BOOT=y and what are your other configs, etc)?

  • Hey Einar,

    So I've dug into this a little bit more and here is what I found:

    You can reproduce it quite easily if you add CONFIG_SECURE_BOOT=y to prj.conf in the hello_world example AND define an empty b0 child_image board overlay config in child_image/b0/boards/<board_name>.conf .

    I'm using the VS Code NRF extension and if you do this, you'll get the following 2 extra cmake arguments added : b0_CONF_FILE pointing to child_image/b0/boards/<board_name>.conf and a b0_OVERLAY_CONFIG pointing to nrf/subsys/partition_manager/partition_manager_enabled.conf . When you do this, samples/bootloader/prj.conf (which enables the CONFIG_SECURE_BOOT_STORAGE flag that adds the provision partition to the otp region by partion manager, defining PM_PROVISION_ADDRESS in the process ), doesn't get added.

    If, on the other hand, you define a global child_image overlay for b0 in child_image/b0.conf , you only get a b0_OVERLAY_CONFIG pointing to child_image/b0.conf and the samples/bootloader/prj.conf gets processed as expected.

    For me, it's a bit confusing that child_image/b0.conf is processed as an overlay while the child_image/b0/boards/<board>.conf does not and takes down samples/bootloader/prj.conf .

    Is there any logical reason for this behaviour?

    Thank you for following up,

    Take care,

    V

  • Hi,

    That is a good find. While not obvious, what you are seeing is intentional and documented here.

  • Found the actual reference to this behaviour in your link here:

    Thank you very much, Einar.

    We can close this ticket.

Related