Project is not compile with SB_CONFIG_MCUBOOT_SIGNATURE_USING_KMU

We are building project with this config parameters:

SB_CONFIG_BOOTLOADER_MCUBOOT=y
SB_CONFIG_MCUBOOT_SIGNATURE_USING_KMU=y
SB_CONFIG_BOOT_SIGNATURE_TYPE_ED25519=y
SB_CONFIG_BOOT_ENCRYPTION=y

But we get this error messages while compile:
c:/ncs/toolchains/b620d30767/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: app/libapp.a(encrypted_psa.c.obj): in function `bootutil_aes_ctr_init':
C:/ncs/v2.9.1/bootloader/mcuboot/boot/bootutil/src/encrypted_psa.c:103: undefined reference to `log_const_mcuboot_psa_enc'
c:/ncs/toolchains/b620d30767/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: app/libapp.a(encrypted_psa.c.obj): in function `boot_decrypt_key':
C:/ncs/v2.9.1/bootloader/mcuboot/boot/bootutil/src/encrypted_psa.c:268: undefined reference to `log_const_mcuboot_psa_enc'
c:/ncs/toolchains/b620d30767/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: C:/ncs/v2.9.1/bootloader/mcuboot/boot/bootutil/src/encrypted_psa.c:289: undefined reference to `log_const_mcuboot_psa_enc'
c:/ncs/toolchains/b620d30767/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: app/libapp.a(encrypted_psa.c.obj): in function `bootutil_aes_ctr_encrypt':
C:/ncs/v2.9.1/bootloader/mcuboot/boot/bootutil/src/encrypted_psa.c:354: undefined reference to `log_const_mcuboot_psa_enc'
c:/ncs/toolchains/b620d30767/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: app/libapp.a(encrypted_psa.c.obj): in function `bootutil_aes_ctr_decrypt':
C:/ncs/v2.9.1/bootloader/mcuboot/boot/bootutil/src/encrypted_psa.c:434: undefined reference to `log_const_mcuboot_psa_enc'
If we use CONFIG_LOG=n for mcuboot, then project compiles normally. Also we get this warnings:
C:/ncs/v2.9.1/bootloader/mcuboot/boot/bootutil/include/bootutil/crypto/aes_ctr.h: In function 'bootutil_aes_ctr_drop':
C:/ncs/v2.9.1/bootloader/mcuboot/boot/bootutil/include/bootutil/crypto/aes_ctr.h:65:26: warning: argument to 'sizeof' in 'memset' call is the same expression as the destination; did you mean to dereference it? [-Wsizeof-pointer-memaccess]
   65 |     memset(ctx, 0, sizeof(ctx));

Is there any way to fix that?

Parents Reply Children
  • Hi,

     

    Thank you so much for sharing.

    The issue is that it is the incorrect define that was originally used for the log declaration.

    It shall be declared with BOOT_LOG_MODULE_REGISTER, and not +BOOT_LOG_MODULE_DECLARE.

     

    Here's a patch for v2.9.x with the proposed fixes:

    diff --git a/boot/bootutil/include/bootutil/crypto/aes_ctr.h b/boot/bootutil/include/bootutil/crypto/aes_ctr.h
    index 44190361..92c8e2a7 100644
    --- a/boot/bootutil/include/bootutil/crypto/aes_ctr.h
    +++ b/boot/bootutil/include/bootutil/crypto/aes_ctr.h
    @@ -62,7 +62,7 @@ void bootutil_aes_ctr_init(bootutil_aes_ctr_context *ctx);
     
     static inline void bootutil_aes_ctr_drop(bootutil_aes_ctr_context *ctx)
     {
    -    memset(ctx, 0, sizeof(ctx));
    +    memset(ctx, 0, sizeof(*ctx));
     }
     
     static inline int bootutil_aes_ctr_set_key(bootutil_aes_ctr_context *ctx, const uint8_t *k)
    diff --git a/boot/bootutil/src/encrypted_psa.c b/boot/bootutil/src/encrypted_psa.c
    index c3f72884..38ed3c6e 100644
    --- a/boot/bootutil/src/encrypted_psa.c
    +++ b/boot/bootutil/src/encrypted_psa.c
    @@ -25,7 +25,7 @@
     #include "bootutil_priv.h"
     #include "bootutil/bootutil_log.h"
     
    -BOOT_LOG_MODULE_DECLARE(mcuboot_psa_enc);
    +BOOT_LOG_MODULE_REGISTER(mcuboot_psa_enc);
     
     #define EXPECTED_ENC_LEN    BOOT_ENC_TLV_SIZE
     #define EXPECTED_ENC_TLV    IMAGE_TLV_ENC_X25519

     

    I will ofcourse bring this up internally.

     

    Kind regards,

    Håkon

Related