WDT & Bootloader: Multiple definitions of `WDT_IRQHandler'

So I'm trying top add a bootloader+DFU to allow f/w updates via UART on my custom  board.

I'm already successfully using WDT in my app. Now I'm looking down the rabbithole of trying to integrate code from docs and/or examples into my own...

Using the example secure_bootloader_uart as my template for DFU, I've added the nRF-Bootloader files & updated the user include directories. But it seems that the bootloader WDT is duplicating driver WDT

nrf_bootloader_wdt.o: In function `WDT_IRQHandler':
nrf_bootloader_wdt.c:73: multiple definition of `WDT_IRQHandler'
\modules\nrfx\drivers\src/nrfx_wdt.c:61: first defined here

I'm not even sure if I need WDT support? Because my custom board has no buttons or LEDs I'll be using sd_power_gpregret_set() followed by a NVIC_SystemReset() - won't that clear the WDT anyway?

Parents
  • Hi Nick, 

    I'm not so sure what you are planning to do.  If you want to add DFU support to your device you don't need to modify the application. 
    Please follow the documentation or you can follow my step by step guide here.
    The bootloader is compiled and flashed as separated application to your application. 

    The bootloader handle WDT automatically, so you don't really need to do anything. (you don't need to integrate the bootloader code into your code)

  • OK, that makes sense.

    As I mentioned, I do need to trigger the DFU from my application though as these will be installed at remote online  locations, so I'll still need to set the gpregret register.

    I may not be able to check out your guide for a few days but I will update this ticket when I do.

    Thanks

    Nick

  • I was following your guide. The ble secure bootloader example didn't compile as it was configured for button operation but no board or buttons were defined. So after changing the config I built & run the bootloader, then tried to load the blinky example by DFU and got the same error. The blinky project is tiny, so I concluded the error message was misleading and I was chasing a red hering down a rabbit hole.

    I gave up after that, deleted the files and decided to try again using the UART DFU which works, at least with the ble_app_uart example application which will get me going for now.

    I *think* in hindsight it was due to a mismatch in softdevices somewhere but I can't say 100% as the test projects I was using have been deleted now.

  • Hi Nick, 

    It's so strange that the bootloader didn't compile. Could you take a screenshot of the error ? 
    Please show how you generate the blink sample and let us know how you update it via BLE DFU. 

    I would assume having OTA DFU is your goal , not UART DFU ? 

  • OK screenshot attached.

    Actually I ultimately need both BLE & UART transports if possible but I would settle for one for the moment...

    Back to BLE (as the uart examples don't include a softdevice)

    After removing the button entry I can compile & load the bootloader secure_bootloader_ble_s112_pca10040e.

    I then can build the project ble_app_uart_pca10040_s112, make zip file and upload it by DFU from nRF Connect. I verify it's advertiisng correctly afterwards so my methofology & keys are working.

    But I still get insufficient resource using my hex file? The hex file is 282kB... I can send it if there is a way to do it privately?

  • Hi Nick, 
    Which chip are you working with ? 
    I'm not so sure why you are testing with PCA10040e if you have nRF52832. 
    I compiled the bootloader project here and saw no issue compiling. 
    NRF_GPIO_PIN_SENSE_LOW is defined in nrf_gpio.h . Could you please double check ?  I would suggest to try testing on a fresh copy of nRF5 SDK. 

    Could you show how you generate .zip file. And also show us the size of the application (either when compiling or show us the .bin file). 

    I have converted the case to Private , you can upload your .hex and .zip here. 

  • Hi. The only reason I'm using PCA10040e example is because that is the nearest as far as I can see that would fit. I'm using S112 with my nrf52832 but the PCA10040 examples in the SDK are all configured for S132.

    I'm out today but should be able to take a look tomorrow.

    Nick

Reply Children
  • Hi Nick, 

    Nick_RA said:
    The only reason I'm using PCA10040e example is because that is the nearest as far as I can see that would fit.

    I don't think it's a good idea. PCA10040e example is for emulating the nRF52810 on a nRF52832. This may explain why you receive  insufficient resource error. The nRF52810 has only 192kB of flash. 
    Please have a look here: https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/index.html?cp=9_1_0

    You will find this: 

    If you want to use S112 with nRF52832 you should base on S132 example and then need to change the : 

    - Preprocessor symbol to S112

    - Start address of your application 

    - Change the include directory of header file for S132 softdevice to S112 softdevice:

  • Thanks for your patience, and sorry if I'm appearing a bit obtuse :/

    Firstly, I've downloaded a fresh example and using "pca10040_s132_ble" (Segger) is giving the buttons not defined error when building when compiled as-is making no changes apart from replacing the dummy public key file. It's not an issue for me as I'm not using buttons anyway and it builds fine with the buttonless option removed.

    On final (hopefully!) thing I don't really get is the memory addresses. Obviously one needs to set the addresses for the bootloader program itself to load & run, but I assume the bootloader needs to know the main application start address, which I can't see?

    FYI, here's the Segger project file contents, this is the s132 bootloader being tweaked to s112

    <!DOCTYPE CrossStudio_Project_File>
    <solution Name="LPTB Bootloader" target="8" version="2">
      <project Name="LPTB _Bootloader">
        <configuration
          Name="Common"
          arm_architecture="v7EM"
          arm_core_type="Cortex-M4"
          arm_endian="Little"
          arm_fp_abi="Hard"
          arm_fpu_type="FPv4-SP-D16"
          arm_linker_heap_size="0"
          arm_linker_process_stack_size="0"
          arm_linker_stack_size="2048"
          arm_linker_treat_warnings_as_errors="No"
          arm_simulator_memory_simulation_parameter="RWX 00000000,00100000,FFFFFFFF;RWX 20000000,00010000,CDCDCDCD"
          arm_target_device_name="nRF52832_xxAA"
          arm_target_interface_type="SWD"
          c_preprocessor_definitions="BLE_STACK_SUPPORT_REQD;BOARD_PCA10040;CONFIG_GPIO_AS_PINRESET;FLOAT_ABI_HARD;INITIALIZE_USER_SECTIONS;NO_VTOR_CONFIG;NRF52;NRF52832_XXAA;NRF52_PAN_74;NRF_DFU_SETTINGS_VERSION=2;NRF_DFU_SVCI_ENABLED;NRF_SD_BLE_API_VERSION=7;S112;SOFTDEVICE_PRESENT;SVC_INTERFACE_CALL_AS_NORMAL_FUNCTION;uECC_ENABLE_VLI_API=0;uECC_OPTIMIZATION_LEVEL=3;uECC_SQUARE_FUNC=0;uECC_SUPPORT_COMPRESSED_POINT=0;uECC_VLI_NATIVE_LITTLE_ENDIAN=1"
          c_user_include_directories="../../config;../../../../../NRFSDK17_1_1/components/ble/common;../../../../../NRFSDK17_1_1/components/boards;../../../../../NRFSDK17_1_1/components/libraries/atomic;../../../../../NRFSDK17_1_1/components/libraries/atomic_fifo;../../../../../NRFSDK17_1_1/components/libraries/balloc;../../../../../NRFSDK17_1_1/components/libraries/bootloader;../../../../../NRFSDK17_1_1/components/libraries/bootloader/ble_dfu;../../../../../NRFSDK17_1_1/components/libraries/bootloader/dfu;../../../../../NRFSDK17_1_1/components/libraries/crc32;../../../../../NRFSDK17_1_1/components/libraries/crypto;../../../../../NRFSDK17_1_1/components/libraries/crypto/backend/cc310;../../../../../NRFSDK17_1_1/components/libraries/crypto/backend/cc310_bl;../../../../../NRFSDK17_1_1/components/libraries/crypto/backend/cifra;../../../../../NRFSDK17_1_1/components/libraries/crypto/backend/mbedtls;../../../../../NRFSDK17_1_1/components/libraries/crypto/backend/micro_ecc;../../../../../NRFSDK17_1_1/components/libraries/crypto/backend/nrf_hw;../../../../../NRFSDK17_1_1/components/libraries/crypto/backend/nrf_sw;../../../../../NRFSDK17_1_1/components/libraries/crypto/backend/oberon;../../../../../NRFSDK17_1_1/components/libraries/crypto/backend/optiga;../../../../../NRFSDK17_1_1/components/libraries/delay;../../../../../NRFSDK17_1_1/components/libraries/experimental_section_vars;../../../../../NRFSDK17_1_1/components/libraries/fstorage;../../../../../NRFSDK17_1_1/components/libraries/log;../../../../../NRFSDK17_1_1/components/libraries/log/src;../../../../../NRFSDK17_1_1/components/libraries/mem_manager;../../../../../NRFSDK17_1_1/components/libraries/memobj;../../../../../NRFSDK17_1_1/components/libraries/queue;../../../../../NRFSDK17_1_1/components/libraries/ringbuf;../../../../../NRFSDK17_1_1/components/libraries/scheduler;../../../../../NRFSDK17_1_1/components/libraries/sha256;../../../../../NRFSDK17_1_1/components/libraries/stack_info;../../../../../NRFSDK17_1_1/components/libraries/strerror;../../../../../NRFSDK17_1_1/components/libraries/svc;../../../../../NRFSDK17_1_1/components/libraries/util;../../../../../NRFSDK17_1_1/components/softdevice/common;../../../../../NRFSDK17_1_1/components/softdevice/s112/headers;../../../../../NRFSDK17_1_1/components/softdevice/s112/headers/nrf52;../../../../../NRFSDK17_1_1/components/toolchain/cmsis/include;../..;../../../../../NRFSDK17_1_1/external/fprintf;../../../../../NRFSDK17_1_1/external/micro-ecc/micro-ecc;../../../../../NRFSDK17_1_1/external/nano-pb;../../../../../NRFSDK17_1_1/external/nrf_oberon;../../../../../NRFSDK17_1_1/external/nrf_oberon/include;../../../../../NRFSDK17_1_1/integration/nrfx;../../../../../NRFSDK17_1_1/modules/nrfx;../../../../../NRFSDK17_1_1/modules/nrfx/hal;../../../../../NRFSDK17_1_1/modules/nrfx/mdk;../config"
          debug_additional_load_file="../../../../../NRFSDK17_1_1/components/softdevice/s112/hex/s112_nrf52_7.2.0_softdevice.hex"
          debug_register_definition_file="../../../../../NRFSDK17_1_1/modules/nrfx/mdk/nrf52.svd"
          debug_start_from_entry_point_symbol="No"
          debug_target_connection="J-Link"
          gcc_debugging_level="Level 3"
          gcc_entry_point="Reset_Handler"
          linker_output_format="hex"
          linker_printf_fmt_level="long"
          linker_printf_width_precision_supported="Yes"
          linker_scanf_fmt_level="long"
          linker_section_placement_file="flash_placement.xml"
          linker_section_placement_macros="FLASH_PH_START=0x0;FLASH_PH_SIZE=0x80000;RAM_PH_START=0x20000000;RAM_PH_SIZE=0x10000;FLASH_START=0x19000;FLASH_SIZE=0x67000;RAM_START=0x200022c8;RAM_SIZE=0xdd38"
          linker_section_placements_segments="FLASH1 RX 0x0 0x80000;RAM1 RWX 0x20000000 0x10000;mbr_params_page RX 0x0007E000 0x1000;bootloader_settings_page RX 0x0007F000 0x1000;uicr_bootloader_start_address RX 0x10001014 0x4;uicr_mbr_params_page RX 0x10001018 0x4"
          macros="CMSIS_CONFIG_TOOL=../../../../../NRFSDK17_1_1/external_tools/cmsisconfig/CMSIS_Configuration_Wizard.jar"
          project_directory=""
          project_type="Executable" />
        <folder Name="Segger Startup Files">
          <file file_name="$(StudioDir)/source/thumb_crt0.s" />
        </folder>
        <folder Name="nRF_Log">
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/log/src/nrf_log_frontend.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/log/src/nrf_log_str_formatter.c" />
        </folder>
        <folder Name="nRF_Libraries">
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/util/app_error_weak.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/scheduler/app_scheduler.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/util/app_util_platform.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/crc32/crc32.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/mem_manager/mem_manager.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/util/nrf_assert.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/atomic_fifo/nrf_atfifo.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/atomic/nrf_atomic.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/balloc/nrf_balloc.c" />
          <file file_name="../../../../../NRFSDK17_1_1/external/fprintf/nrf_fprintf.c" />
          <file file_name="../../../../../NRFSDK17_1_1/external/fprintf/nrf_fprintf_format.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/fstorage/nrf_fstorage.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/fstorage/nrf_fstorage_nvmc.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/fstorage/nrf_fstorage_sd.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/memobj/nrf_memobj.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/queue/nrf_queue.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/ringbuf/nrf_ringbuf.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/experimental_section_vars/nrf_section_iter.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/strerror/nrf_strerror.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/sha256/sha256.c" />
        </folder>
        <folder Name="nRF_Crypto backend uECC">
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/crypto/backend/micro_ecc/micro_ecc_backend_ecc.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/crypto/backend/micro_ecc/micro_ecc_backend_ecdh.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/crypto/backend/micro_ecc/micro_ecc_backend_ecdsa.c" />
        </folder>
        <folder Name="nano-pb">
          <file file_name="../../../../../NRFSDK17_1_1/external/nano-pb/pb_common.c" />
          <file file_name="../../../../../NRFSDK17_1_1/external/nano-pb/pb_decode.c" />
        </folder>
        <folder Name="Board Definition">
          <file file_name="../../../../../NRFSDK17_1_1/components/boards/boards.c" />
        </folder>
        <folder Name="nRF_Drivers">
          <file file_name="../../../../../NRFSDK17_1_1/modules/nrfx/hal/nrf_nvmc.c" />
          <file file_name="../../../../../NRFSDK17_1_1/modules/nrfx/soc/nrfx_atomic.c" />
        </folder>
        <folder Name="nRF_Oberon_Crypto">
          <file file_name="../../../../../NRFSDK17_1_1/external/nrf_oberon/lib/cortex-m4/hard-float/liboberon_3.0.8.a" />
        </folder>
        <folder Name="nRF_Crypto">
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/crypto/nrf_crypto_ecc.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/crypto/nrf_crypto_ecdsa.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/crypto/nrf_crypto_hash.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/crypto/nrf_crypto_init.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/crypto/nrf_crypto_shared.c" />
        </folder>
        <folder Name="Application">
          <file file_name="../../main.c" />
          <file file_name="../config/sdk_config.h" />
          <file file_name="../../../Keys/public_key.c" />
        </folder>
        <folder Name="nRF_micro-ecc">
          <file file_name="../../../../../NRFSDK17_1_1/external/micro-ecc/nrf52hf_armgcc/armgcc/micro_ecc_lib_nrf52.a" />
        </folder>
        <folder Name="nRF_BLE">
          <file file_name="../../../../../NRFSDK17_1_1/components/ble/common/ble_srv_common.c" />
        </folder>
        <folder Name="nRF_Bootloader">
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/bootloader/nrf_bootloader.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/bootloader/nrf_bootloader_app_start.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/bootloader/nrf_bootloader_app_start_final.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/bootloader/nrf_bootloader_dfu_timers.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/bootloader/nrf_bootloader_fw_activation.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/bootloader/nrf_bootloader_info.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/bootloader/nrf_bootloader_wdt.c" />
        </folder>
        <folder Name="None">
          <file file_name="../../../../../NRFSDK17_1_1/modules/nrfx/mdk/ses_startup_nrf52.s" />
          <file file_name="../../../../../NRFSDK17_1_1/modules/nrfx/mdk/ses_startup_nrf_common.s" />
          <file file_name="../../../../../NRFSDK17_1_1/modules/nrfx/mdk/system_nrf52.c" />
        </folder>
        <folder Name="nRF_Crypto backend nRF sw">
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/crypto/backend/nrf_sw/nrf_sw_backend_hash.c" />
        </folder>
        <folder Name="nRF_DFU">
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/bootloader/dfu/dfu-cc.pb.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/bootloader/dfu/nrf_dfu.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/bootloader/ble_dfu/nrf_dfu_ble.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/bootloader/dfu/nrf_dfu_flash.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/bootloader/dfu/nrf_dfu_handling_error.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/bootloader/dfu/nrf_dfu_mbr.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/bootloader/dfu/nrf_dfu_req_handler.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/bootloader/dfu/nrf_dfu_settings.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/bootloader/dfu/nrf_dfu_settings_svci.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/bootloader/dfu/nrf_dfu_transport.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/bootloader/dfu/nrf_dfu_utils.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/bootloader/dfu/nrf_dfu_validation.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/bootloader/dfu/nrf_dfu_ver_validation.c" />
        </folder>
        <folder Name="nRF_SVC">
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/bootloader/dfu/nrf_dfu_svci.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/bootloader/dfu/nrf_dfu_svci_handler.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/svc/nrf_svc_handler.c" />
        </folder>
        <folder Name="nRF_SoftDevice">
          <file file_name="../../../../../NRFSDK17_1_1/components/softdevice/common/nrf_sdh.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/softdevice/common/nrf_sdh_ble.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/softdevice/common/nrf_sdh_soc.c" />
        </folder>
        <folder Name="nRF_Crypto backend Oberon">
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/crypto/backend/oberon/oberon_backend_chacha_poly_aead.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/crypto/backend/oberon/oberon_backend_ecc.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/crypto/backend/oberon/oberon_backend_ecdh.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/crypto/backend/oberon/oberon_backend_ecdsa.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/crypto/backend/oberon/oberon_backend_eddsa.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/crypto/backend/oberon/oberon_backend_hash.c" />
          <file file_name="../../../../../NRFSDK17_1_1/components/libraries/crypto/backend/oberon/oberon_backend_hmac.c" />
        </folder>
      </project>
      <configuration
        Name="Release"
        c_preprocessor_definitions="NDEBUG"
        gcc_optimization_level="Optimize For Size"
        link_time_optimization="No" />
    </solution>
    

  • Hi Nick, 
    It's strange that the bootloader didn't work out of the box. It's been there for a few years and we haven't got any report about this. Maybe you can test on a fresh copy of the SDK. 

    Regarding your question, the bootloader automatically know the start address of the application because it has to be located right after the softdevice. The bootloader just need to read a special register in the softdevice to know the size of the softdevice. So you don't have to change that in the bootloader. 
    However, if you change the softdevice in the application, you need to change the start address of the application according to the size of the softdevice. You can find the size of the softdevice by looking at the release note or look at an example that use the softdevice. 

  • Regarding your question, the bootloader automatically know the start address of the application because it has to be located right after the softdevice. The bootloader just need to read a special register in the softdevice to know the size of the softdevice. So you don't have to change that in the bootloader. 

    OK I understand, but that conflicts with this:

    - Start address of your application

    Sorry to drag this on, but this bit I don't really understand:

    However, if you change the softdevice in the application, you need to change the start address of the application according to the size of the softdevice. You can find the size of the softdevice by looking at the release note or look at an example that use the softdevice.

    1. I am not changing anything at all in my actual application. It is the bootloader which I need to change  from the SDK example's S132 to suit my application's S112

    2. So what memory changes do I need to make to the bootloader project, if any? I presume it is the section placement macros where it is set I(in SES). Or am I over thinking this and the existing S132 bootloader memory settings will work?

    Thanks for your perseverence!

    Nick

  • Hi Nick, 

    Sorry for the confusion. Let me try again. 

    - You don't need to modify the bootloader.

    - You need to modify the application if you are converting it from using S132 to S112. You need to change where you set the start address of your application. Again , this is only in your application. No modification in the bootloader. If your application is already working with S112 then you don't need to do anything. 

Related