This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Secure Buttonless DFU Problem on nRF52832 Soft Device 112

Hello

I am facing problem from many days on buttonless DFU.

Whoever from Nordic approaches kindly give a customized solution rather than other links. I have almost gone through all the links with none exactly matching my issue. I will be really thankful.

I am trying to perform Buttonless DFU on nRF52832 512 kB version on nRF DK. I am using SDK 112 v7 (the latest one) and latest versions of nRF util, etc.. as well. Although I am using SDK 16.

My first act was to convert my application from s132 to S112 on nRF52832 a few months ago as I was using default ble_app_blinky as my base. A kind person from nordic helped me on the issue since the memory mapping on s112 pca10040 example is that of nRF52810

Now for DFU, I am supposed to convert the bootloader s112 example on nRF52810 to nRF52832 by editing the project file for library and memory mapping right?

I used the following links:

1) https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v15.3.0%2Flib_bootloader.html

2) https://devzone.nordicsemi.com/nordic/short-range-guides/b/software-development-kit/posts/getting-started-with-nordics-secure-dfu-bootloader#h61sjziauupw1j397q9s9ldr01q4j6d5

3) https://devzone.nordicsemi.com/f/nordic-q-a/41386/guide-to-allocate-the-amount-of-ram-rom-i-need

and my project application  + BL + setting + SD oombined well using merge hex. It  went into DFU mode on start up and I started OTA 

OTA package is received successfully and after 100% OTA the DK rebooted and nRF log said bootloader not found:

My guess is something is wrong in my conversions as I am trying to convert from s112 nRF52810 examples to nrf 52832 the following projects:

1) Bootloader S112 example

2) I OTA ble_app_blinky s112 example and change it's memory mapping and nrf52832 libraries as we have to keep the same soft device in OTA

Please note from above screenshot that my OTA is fully complete (100%)

I am using the following memory mapping:

1) Bootloader example: nrf52832 s112

linker_section_placement_macros="FLASH_PH_START=0x0;FLASH_PH_SIZE=0x80000;RAM_PH_START=0x20000000;RAM_PH_SIZE=0x10000;FLASH_START=0x78000;FLASH_SIZE=0x6000;RAM_START=0x20005968;RAM_SIZE=0xa698"

linker_section_placements_segments="FLASH RX 0x0 0x80000;RAM RWX 0x20000000 0x10000;uicr_bootloader_start_address RX 0x10001014 0x4;uicr_mbr_params_page RX 0x10001018 0x4;mbr_params_page RX 0x0007E000 0x1000;bootloader_settings_page RX 0x0007F000 0x1000"

2) Base Application FW - nrf52832 s112

linker_section_placement_macros="FLASH_PH_START=0x0;FLASH_PH_SIZE=0x80000;RAM_PH_START=0x20000000;RAM_PH_SIZE=0x10000;FLASH_START=0x26000;FLASH_SIZE=0x5a000;RAM_START=0x200022f0;RAM_SIZE=0xdd10"


linker_section_placements_segments="FLASH RX 0x0 0x80000;RAM RWX 0x20000000 0x10000"

3) The OTA package - S112 nRF52832

linker_section_placement_macros="FLASH_PH_START=0x0;FLASH_PH_SIZE=0x80000;RAM_PH_START=0x20000000;RAM_PH_SIZE=0x10000;FLASH_START=0x26000;FLASH_SIZE=0x5a000;RAM_START=0x20001ae0;RAM_SIZE=0x4520"

linker_section_placements_segments="FLASH RX 0x0 0x80000;RAM RWX 0x20000000 0x10000"

Here are my nrfutil commands -

1) Bootloader settings and hex merges

BOOTLOADER SETTINGS
nrfutil settings generate --family NRF52 --application E_MCB_Project.hex --application-version 1 --bootloader-version 1 --bl-settings-version 2 bootloader_settings.hex


nrfutil settings generate --family NRF52 --application E_MCB_Project.hex --application-version 1 --bootloader-version 1 --bl-settings-version 2 --app-boot-validation VALIDATE_GENERATED_CRC --softdevice s112_sd.hex --sd-boot-validation VALIDATE_GENERATED_CRC bootloader_settings.hex


SETTING AND BOOTLOADER MERGE
mergehex -m secure_bootloader.hex bootloader_settings.hex -o bootloaderAndSettings.hex

PACKAGE HEX FROM ABOVE
mergehex -m bootloaderAndSettings.hex s112_sd.hex -o random.hex

PACKAGE HEX FROM ABOVE 2
mergehex -m random.hex E_MCB_Project.hex -o package_EMCB.hex

Here are commands I used for OTA package

echo "## Creating a FW.zip package that can be used to update the FW on the DK"


nrfutil pkg generate --application blinky_112_2.hex --application-version 61 --application-version-string "1.0.61" --hw-version 52 --sd-req 0xCD --sd-id 0xCD --softdevice s112_sd.hex --key-file private.pem fw81_MCB.zip


echo.

sd_112. hex is default  soft devicce 112 I just renamed it rest is self explanatory.

I have provided complete details and I need help on this. Please provide a customized solution and please dont divert me to other links. Its not a huge issue the OTA happens perfectly  but after reboot it cannot find the bootloader

I am assuming its something withbootloader settings or bootloader memory mapping

Regards

Ali

  • Hi Vidar
    Thanks again for the prompt replies.

    I'll look into it. Meanwhile I have a general question. When I run the application standalone, the interrupts work.

    When I merge APP + SD + BL + Settings and flash it. The BL successfully boots the application as desired but interrupts dont work.

    If the BL booted the application successfully, then the application is now basically running standalone right without any dependency on the bootloader? Im a bit baffled as to how the interrupts arent working when I merge

    Keeping the issue aside, when bootloader boots the application, are there any dependencies such as GPIO interrupts which the bootloader may effect? Or the application is really running standalone

    Thanks again

    Ali

  • Hi Vidar. I dug deep into my app. Yes its on custom board but we already had that covered according to link you have shared, taking inspiration from the DK board examples pinout configuration.

    I have searched multiple posts online as well. Most notable is this although of different SoC:

    https://devzone.nordicsemi.com/f/nordic-q-a/16398/gpio-interrupts-not-working-with-bootloader

    Im pretty sure the bootloader must be doing something as my app works fine when standalone. You are well versed with the bootloader project. I used the one you sent in fact. Could you please help me in solving this issue?

  • Hi,

    I don't think this has to do with interrupt forwarding. Did you disable the button and LED configurations in the bootlaoder project as I asked you to? Also, 1. does your board use P0.21 as a reset pin? 2. do other parts of the app work  (e.g. does it start BLE advertising, etc)?

  • Hi Vidar

    I did try that. But removing LED pins in pca10040.h gave me led errors in main.c. I will try it again today by commenting out LED on functions.

    I'll check P0.21 as well.

    Yes advertising works infact even DFU works completely fine just not the interrupts

  • Hi,

    You need to comment the led functions as you said.

    Disabling LEDs and Button:

    diff --git a/components/boards/custom_board.h b/components/boards/custom_board.h
    index 597ff69..3c8915c 100644
    --- a/components/boards/custom_board.h
    +++ b/components/boards/custom_board.h
    @@ -47,7 +47,7 @@ extern "C" {
     #include "nrf_gpio.h"
     
     // LEDs definitions for PCA10040
    -#define LEDS_NUMBER    4
    +#define LEDS_NUMBER    0
     
     #define LED_START      17
     #define LED_1          17
    @@ -67,7 +67,7 @@ extern "C" {
     #define BSP_LED_2      LED_3
     #define BSP_LED_3      LED_4
     
    -#define BUTTONS_NUMBER 4
    +#define BUTTONS_NUMBER 0
     
     #define BUTTON_START   13
     #define BUTTON_1       13
    diff --git a/examples/dfu/secure_bootloader/main.c b/examples/dfu/secure_bootloader/main.c
    index 0c72b38..44ebde3 100644
    --- a/examples/dfu/secure_bootloader/main.c
    +++ b/examples/dfu/secure_bootloader/main.c
    @@ -106,14 +106,14 @@ static void dfu_observer(nrf_dfu_evt_type_t evt_type)
             case NRF_DFU_EVT_DFU_FAILED:
             case NRF_DFU_EVT_DFU_ABORTED:
             case NRF_DFU_EVT_DFU_INITIALIZED:
    -            bsp_board_init(BSP_INIT_LEDS);
    +            /*bsp_board_init(BSP_INIT_LEDS);
                 bsp_board_led_on(BSP_BOARD_LED_0);
                 bsp_board_led_on(BSP_BOARD_LED_1);
    -            bsp_board_led_off(BSP_BOARD_LED_2);
    +            bsp_board_led_off(BSP_BOARD_LED_2);*/
                 break;
             case NRF_DFU_EVT_TRANSPORT_ACTIVATED:
    -            bsp_board_led_off(BSP_BOARD_LED_1);
    -            bsp_board_led_on(BSP_BOARD_LED_2);
    +            /*bsp_board_led_off(BSP_BOARD_LED_1);
    +            bsp_board_led_on(BSP_BOARD_LED_2);*/
                 break;
             case NRF_DFU_EVT_DFU_STARTED:
                 break;
    diff --git a/examples/dfu/secure_bootloader/pca10040_s112_ble_debug/config/sdk_config.h b/examples/dfu/secure_bootloader/pca10040_s112_ble_debug/config/sdk_config.h
    index 501ed20..e72d2d8 100644
    --- a/examples/dfu/secure_bootloader/pca10040_s112_ble_debug/config/sdk_config.h
    +++ b/examples/dfu/secure_bootloader/pca10040_s112_ble_debug/config/sdk_config.h
    @@ -99,7 +99,7 @@
     // <e> NRF_BL_DFU_ENTER_METHOD_BUTTON - Enter DFU mode on button press.
     //==========================================================
     #ifndef NRF_BL_DFU_ENTER_METHOD_BUTTON
    -#define NRF_BL_DFU_ENTER_METHOD_BUTTON 1
    +#define NRF_BL_DFU_ENTER_METHOD_BUTTON 0
     #endif
     // <o> NRF_BL_DFU_ENTER_METHOD_BUTTON_PIN  - Button for entering DFU mode.
      
    

    AliMahmood123 said:
    just not the interrupts

    Only GPIOTE interrupts, or are there other interrupts that don't work either?

Related