How Can I Add Custom Application Code To DFU Bootloader?

Platform is SDK v17.1 / 52840 / secure bootloader with BLE.

I would like to add some application logic to the bootloader.

The idea is to periodically poll some spi devices and depending on the result have the bootloader run the application.

Power management would control sleep time until something interesting happens that causes the bootloader to start the application.

Where is the place in the bootloader code that I could hook-up the code described above?

  • I have a strange failure building this bootloader when I add nrf_pwr_mgmt.c to nRF_Libraries.

    After adding the above library file I see:  warning: implicit declaration of function 'nrf_pwr_mgmt_run'

    I added #include "nrf_pwr_mgmt.h" to the file that uses those functions. Then I get this failure:

    fatal error: nrf_pwr_mgmt.h: No such file or directory

    I examined the solution file for the project and c_user_include_directories does not contain a reference to

    sdk/components/libraries/pwr_mgmt.

    Why has the solution not been updated to include pwr_mgmt lib?

  • I also updated sdk_config.h to enable power mgmt.

    // <e> NRF_PWR_MGMT_ENABLED - nrf_pwr_mgmt - Power management module
    //==========================================================
    #ifndef NRF_PWR_MGMT_ENABLED
    #define NRF_PWR_MGMT_ENABLED 1
    #endif

  • Hi,

    davidb said:
    Why has the solution not been updated to include pwr_mgmt lib?

    The example bootloader projects does not use the power management library, so if you want to use it you need to add it to the include path, and add nrf_pwr_mgmt.c to the project. The bootloader is not special in this regard, any components you use needs to be added, so you can just refer to a different project that use it or simply try to add it and look at the build errors and resolve those as you go so that you get everything.

Related