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

DFU and application code conflicting? After firmware uploading, neither dfu nor application code work

Hi

We are experiencing a strange behaviour involving secure DFU and the user application code.

The environment is:

nRF5_SDK_12.3.0_d7731ad

nRF51822xxAC

s130_nrf51_2.0.1_softdevice.hex

Keil uvision 5.13

HW: nRF PCA10028

DFU code : ..\nRF5_SDK_12.3.0_d7731ad\examples\dfu\bootloader_secure\pca10028\arm5_no_packs\secure_dfu_secure_dfu_ble_s130_pca10028.uvprojx

Application code has been developed starting from ble_app_proximity and ble_app_uart in ..\nRF5_SDK_12.3.0_d7731ad\examples\ble_peripheral folder

Private key priv.pem has been generated and nrfutil pkg generate used for creating

We erase the device, load DFU, Softdevice, and leave application space erased, so that upon boot, DFU mode is entered.

So far so good: at reset the IC enters DFU mode, the device is recognized, it loads our application properly via DFU (Nordic APP), and the application starts and works as expected.

If at this point the device is reset, the application doesn't start anymore and the device is not in DFU mode either.

ROM and RAM are kept the same as the examples that we started from, and they seem OK.

There's obviously something wrong in our code, does anyone have any previous experience on a similar behaviour?

Thanks in advance for your support

Cristian

  • Hi,

    You should test with the debug variant of the bootloader(pca10028_debug project), and output the nrf_log either over UART or Segger RTT. The log might reveal what is going wrong.


    You could also try to run nrfjprog --memrd 0 --n 0x100000 -f nrf52 > flash_dump.txt
    One dump before and one after the reset, and see if/what is being changed.

  • Hi Sigurd

    Thanks for your prompt reply.

    I found the origin of the problem. I had inadvertently commented  the buttons_leds_init (& erase_bonds) function; and consequently a consistent value of erase_bonds was not passed to the peer_manager_init(erase_bonds) function.

    Uncommenting the function, everything seems to work properly.

    One more question, if possible. 

    Inside the buttons_leds_init (& erase_bonds) function, can I leave uncommented only the line below i.e. *p_erase_bonds = (startup_event == BSP_EVENT_CLEAR_BONDING_DATA) since I don't need to use the BSP_INIT_BUTTONS or are there any contraindications in this?

    static void buttons_leds_init(bool * p_erase_bonds)
    {
        bsp_event_t startup_event;
    
    //    uint32_t err_code = bsp_init(BSP_INIT_LED | BSP_INIT_BUTTONS,
    //                                 APP_TIMER_TICKS(100, APP_TIMER_PRESCALER),
    //                                 bsp_event_handler);
    
    //    APP_ERROR_CHECK(err_code);
    
    //    err_code = bsp_btn_ble_init(NULL, &startup_event);
    //    APP_ERROR_CHECK(err_code);
    
        *p_erase_bonds = (startup_event == BSP_EVENT_CLEAR_BONDING_DATA);
    }

    Thanks for your support

     
  • cristian.anceschi said:
    everything seems to work properly.

     Great!

     

    cristian.anceschi said:
    can I leave uncommented only the line below i.e. *p_erase_bonds = (startup_event == BSP_EVENT_CLEAR_BONDING_DATA) since I don't need to use the BSP_INIT_BUTTONS or are there any contraindications in this?

     If you are not using buttons_leds_init(), and not planning to delete bond data on button-press at start-up, then I believe you can just remove the buttons_leds_init() function, and set  erase_bonds to false. Snippet:

    /**@brief Function for application main entry.
     */
    int main(void)
    {
        uint32_t err_code;
        bool     erase_bonds = false;

Related