Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF52840 wouldn't reset automatically after DFU update

Hello,

I'm using nRF52840 custom board with nRF5 SDK v16.0 and Softdevice v7.0.1. 

I can successfully DFU/OTA the device using nRFConnect app. But after DFU is complete, the device remains in DFU mode and device name keeps displayed as DfuTarg. Ideally the device should reset itself (or without reset) and start the user application. But I have to manually power cycle the board to achieve this. This give a very annoying user experience to the customer. 

I have read forums where they have discussed the gcc version and LTO enabled in the make file ("flto" option) with which the bootloader is compiled.

Link: https://devzone.nordicsemi.com/f/nordic-q-a/34224/device-does-not-reset-after-dfu

However, I have checked Makefile at "..\nRF Software\nRF5_SDK_16.0.0_98a08e2\external\micro-ecc\nrf52hf_armgcc\armgcc", the "-flto" option is already disabled.

# Optimization flags
OPT = -Os -g3
# Uncomment the line below to enable link time optimization
#OPT += -flto

I have made a few changes to dfu at "...\nRF5_SDK_16.0.0_98a08e2\examples\dfu\secure_bootloader\pca10056_s140_ble\ses" regarding dfu button but not much.

I have checked my gcc version which is here:

C:\Users\Universal>gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/8.2.0/lto-wrapper.exe
Target: mingw32
Configured with: ../src/gcc-8.2.0/configure --build=x86_64-pc-linux-gnu --host=mingw32 --target=mingw32 --prefix=/mingw --disable-win32-registry --with-arch=i586 --with-tune=generic --enable-languages=c,c++,objc,obj-c++,fortran,ada --with-pkgversion='MinGW.org GCC-8.2.0-3' --with-gmp=/mingw --with-mpfr=/mingw --with-mpc=/mingw --enable-static --enable-shared --enable-threads --with-dwarf2 --disable-sjlj-exceptions --enable-version-specific-runtime-libs --with-libiconv-prefix=/mingw --with-libintl-prefix=/mingw --enable-libstdcxx-debug --with-isl=/mingw --enable-libgomp --disable-libvtv --enable-nls --disable-build-format-warnings
Thread model: win32
gcc version 8.2.0 (MinGW.org GCC-8.2.0-3)

I am not sure what to do. If I need to change the gcc version how to do that, exactly which version to use with SDK16? The https://sourceforge.net/projects/mingw/ only gives latest version for download. BTW after making changes to bootloader code I had compiled the code in Segger Embedded Studio, does that make any difference?

Regards.

Parents
  • Hello,

     It sounds like the bootloader falls back to DFU mode after the update. Are you able to debug the bootloader when this happens? If so, please try to debug the nrf_bootloader.c->dfu_enter_check() function to see if any of these checks return true. RESETREAS and GPREGRET are both cleared through power on reset so maybe the explanation is that one of these registers are not properly cleared after the update was completed.

    Regards,

    Vidar

  • Thank you Vidar for the reply.

    Is there any way to exist the DFU mode by accessing GATT characteristics of DfuTarg? There "Secure DFU Packet" and "Secure DFU Control Point". May be we send some packet with reset command? 

  • Yes, you can send the Abort request to trigger a reset (ie write 0xC to control point)

  • I have tried Abort to no success. The device remains in the DFU mode. See the attached picture.

    I have also tried to debug the bootloader. For that I enabled the log by:

    #define NRF_LOG_ENABLED 1

    But I get compile errors like:

    Building ‘secure_bootloader_ble_s140_pca10056’ from solution ‘secure_bootloader_ble_s140_pca10056’ in configuration ‘Release’
      Compiling ‘nrf_log_str_formatter.c’
      Compiling ‘nrf_log_frontend.c’
      Compiling ‘app_error_weak.c’
      Compiling ‘app_scheduler.c’
      Compiling ‘crc32.c’
      Compiling ‘mem_manager.c’
      Compiling ‘nrf_atfifo.c’
      Compiling ‘nrf_atomic.c’
      Compiling ‘nrf_balloc.c’
      Compiling ‘nrf_fprintf.c’
      Compiling ‘nrf_fprintf_format.c’
      Compiling ‘nrf_fstorage.c’
      Compiling ‘nrf_fstorage_nvmc.c’
      Compiling ‘nrf_fstorage_sd.c’
      Compiling ‘nrf_memobj.c’
      Compiling ‘nrf_queue.c’
      Compiling ‘nrf_ringbuf.c’
      Compiling ‘nrf_strerror.c’
      Compiling ‘nrf_section_iter.c’
      Compiling ‘cc310_bl_backend_ecc.c’
      Compiling ‘cc310_bl_backend_ecdsa.c’
      Compiling ‘cc310_bl_backend_hash.c’
      Compiling ‘cc310_bl_backend_init.c’
      Compiling ‘cc310_bl_backend_shared.c’
      Compiling ‘boards.c’
      Compiling ‘nrf_sdh.c’
      Compiling ‘nrf_sdh_ble.c’
      Compiling ‘nrf_sdh_soc.c’
      Compiling ‘nrf_nvmc.c’
      Compiling ‘nrfx_atomic.c’
      Compiling ‘nrf_crypto_ecc.c’
      Compiling ‘nrf_crypto_ecdsa.c’
      Compiling ‘nrf_crypto_hash.c’
      Compiling ‘nrf_crypto_init.c’
      Compiling ‘nrf_crypto_shared.c’
      Compiling ‘main.c’
      Compiling ‘nrf_dfu_svci.c’
      Compiling ‘nrf_dfu_svci_handler.c’
      Compiling ‘nrf_bootloader.c’
      Compiling ‘nrf_bootloader_app_start.c’
      Compiling ‘nrf_bootloader_app_start_final.c’
      Compiling ‘nrf_bootloader_dfu_timers.c’
      Compiling ‘nrf_bootloader_fw_activation.c’
      Compiling ‘nrf_bootloader_info.c’
      Compiling ‘nrf_bootloader_wdt.c’
      Compiling ‘nrf_dfu.c’
      Compiling ‘nrf_dfu_ble.c’
      Compiling ‘nrf_dfu_flash.c’
      Compiling ‘nrf_dfu_mbr.c’
      Compiling ‘nrf_dfu_handling_error.c’
      Compiling ‘nrf_dfu_req_handler.c’
      Compiling ‘nrf_dfu_settings.c’
      Compiling ‘nrf_dfu_settings_svci.c’
      Compiling ‘nrf_dfu_transport.c’
      Compiling ‘nrf_dfu_utils.c’
      Compiling ‘nrf_dfu_validation.c’
      Compiling ‘nrf_dfu_ver_validation.c’
      Compiling ‘oberon_backend_chacha_poly_aead.c’
      Compiling ‘oberon_backend_ecc.c’
      Compiling ‘oberon_backend_ecdh.c’
      Compiling ‘oberon_backend_ecdsa.c’
      Compiling ‘oberon_backend_eddsa.c’
      Compiling ‘oberon_backend_hash.c’
      Compiling ‘oberon_backend_hmac.c’
      Linking secure_bootloader_ble_s140_pca10056.elf
        .text is too large to fit in FLASH memory segment
        .crypto_data is too large to fit in FLASH memory segment
        .dfu_trans is too large to fit in FLASH memory segment
        .svc_data is too large to fit in FLASH memory segment
        .log_const_data is too large to fit in FLASH memory segment
        .nrf_balloc is too large to fit in FLASH memory segment
        .sdh_ble_observers is too large to fit in FLASH memory segment
        .sdh_state_observers is too large to fit in FLASH memory segment
        .sdh_stack_observers is too large to fit in FLASH memory segment
        .sdh_req_observers is too large to fit in FLASH memory segment
        .sdh_soc_observers is too large to fit in FLASH memory segment
        .fs_data is too large to fit in FLASH memory segment
        .rodata is too large to fit in FLASH memory segment
        .data is too large to fit in FLASH memory segment
        Output/secure_bootloader_ble_s140_pca10056 Release/Obj/main.o: in function `main':
        undefined reference to `nrf_log_default_backends_init'
    Build failed

    It seems like I have to change the memory areas for bootloader but I'm not sure which areas and what changes to make. This project uses softdevice as well.

  • Notifications need to be enable before you can send command requests.

    Debug logging over RTT is enabled in the debug project 'pca10056_s140_ble_debug'. The logs can be viewed with RTTViewer or RTTClient.

  • Hello Vidar,

    I have tried this but it's not working, the device does not reset by sending 0xC0 command. To demonstrate I have made a video, please have a look at that:

    drive.google.com/.../view

    Thanks.

  • It's hard to say what the problem is without being able to debug it. Have you had any success with enabling logs, and have you tried to place breakpoints inside the nrf_bootloader.c->dfu_enter_check() function?

Reply Children
No Data
Related