mcuboot CONFIG_MCUBOOT_ACTION_HOOKS functions

Greeting Nordic Expert ! 

I would like to override the following hook in MCUboot:

int boot_perform_update_hook(int img_index,
struct image_header *img_head,
const struct flash_area *area);

My goal is to dynamically enable/disable signature verification in MCUboot.
From reading the source code, it seems that implementing this hook is the right approach.

However, I cannot find any working examples or tutorials on how to properly provide my own implementation of this function and ensure it is compiled into the MCUboot child image in NCS (v3.0.1).

Could you please clarify:
1. Is there an official example or sample project that demonstrates overriding `boot_perform_update_hook`?
2. What is the recommended way to add such a file into the MCUboot child image?

Thank you for your support!

Parents
  • Hello,

    The easiest approach to maintain a patch for the MCUBoot sources file but I understand if that is not desirable. Another approach can be to create a new zephyr module as explained here:  RE: Image upload over MCUBoot serial recovery not bootable 

    Best regards,

    Vidar

  • Yeh , the problem with that is compiler won't recongize the libray MCUBoot is using 

    #include <bootutil/boot_hooks.h>
    #include <bootutil/image.h>
    #include <flash_map/flash_map.h>
    #include <zephyr/logging/log.h>
    
    LOG_MODULE_REGISTER(my_hooks, LOG_LEVEL_INF);
    
    int boot_perform_update_hook(int image_index,
                                 const struct image_header *img_head,
                                 const struct flash_area *fap_primary,
                                 const struct flash_area *fap_secondary)
    {
        ARG_UNUSED(img_head);
        ARG_UNUSED(fap_primary);
        ARG_UNUSED(fap_secondary);
    
        LOG_INF("MCUBoot update hook called for image %d", image_index);
    
        /* Example: return BOOT_HOOK_REGULAR to continue normal flow */
        return BOOT_HOOK_REGULAR;
    }
    

    any thought on how do i compile a Mcuboot hook ? 

  • The module does not include the neccessary include paths. You can make a copy of this header and include it in your module or specify the include path with target_include_directories the module's cmakelist file.

  • Did you try to specify the missing include paths as I suggested? 

Reply Children
No Data
Related