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

Application doesn't work after update with DFU

Hi!

SDK 16.0

I use secure bootloader from SDK with button.

1. Single app written from Segger Studio work fine.

2. Firmware (bootloader with app) written from script below work fine.

However App package (app_dfu_package.zip) updated from nrfConnect for Android start fail.

3. When bootloader written from Segger Studio and app_dfu_package.zip updated from nrfConnect for Android, all work fine.

Why can't write full package and then update app with DFU?

# write bootloader, softdevice and app

OUTPUT_DIR=Output

mergehex=/opt/mergehex/mergehex
nrfjprog=/opt/nrfjprog/nrfjprog
nrfutil=nrfutil

SOFTDEVICE=../../../components/softdevice/s132/hex/s132_nrf52_7.0.1_softdevice.hex
BOOTLOADER=../secure_bootloader/pca10040_s132_ble/ses/Output/Release/Exe/secure_bootloader_ble_s132_pca10040.hex

PRIVATE_KEY=private.pem
APP=../fw/pca10040/s132/ses/Output/Release/Exe/fw_aac_52832_s132.hex
APP_VERSION=1

NRF_FAMILY=NRF52
HW_VERSION=52

BOOTLOADER_SETTINGS=$(OUTPUT_DIR)/bootloader_settings.hex
BOOTLOADER_VERSION=1
BOOTLOADER_SETTINGS_VERSION=1


MERGED_BOOTLOADER_SETTINGS=$(OUTPUT_DIR)/m_bootloader_settings.hex
MERGED_APP_BOOTLOADER_SETTINGS=$(OUTPUT_DIR)/m_app_bootloader_settings.hex

#make bootloader settings
nrfutil settings generate --family $(NRF_FAMILY) --application $(APP) --application-version $(APP_VERSION) --bootloader-version $(BOOTLOADER_VERSION) --bl-settings-version $(BOOTLOADER_SETTINGS_VERSION) $(BOOTLOADER_SETTINGS)

#add softdevice to bootloader with settings
$(mergehex) -m $(SOFTDEVICE) $(BOOTLOADER_SETTINGS)  $(BOOTLOADER) -o $(MERGED_BOOTLOADER_SETTINGS)

#add app
$(mergehex)  -m  $(MERGED_BOOTLOADER_SETTINGS) $(APP) -o $(MERGED_APP_BOOTLOADER_SETTINGS)

#flash into device
$(nrfjprog) --family $(NRF_FAMILY) --recover
$(nrfjprog) --family $(NRF_FAMILY) --program $(MERGED_APP_BOOTLOADER_SETTINGS)  --chiperase  --verify
$(nrfjprog) --family $(NRF_FAMILY) --reset

#make package for DFU updating
$(nrfutil) pkg generate --hw-version $(HW_VERSION) --application-version $(APP_VERSION) --application $(APP) --sd-req 0xCB --sd-id 0xCB  --key-file $(PRIVATE_KEY) $(OUTPUT_DIR)/app_dfu_package.zip

Parents Reply Children
  • Transfer comes to an end successfully.

    sdk_config.h


    #ifndef NRF_DFU_APP_ACCEPT_SAME_VERSION
    #define NRF_DFU_APP_ACCEPT_SAME_VERSION 1
    #endif

  • Thanks for confirming. Have you tried to debug the application after DFU? The first thing I would check is if the program reaches main() after reset, and if not, check if the program counter (PC) register appears to get stuck at a particular address.

    You can run 'nrfjprog --readregs' from the command line to read out the CPU registers.

  • <info> app: Inside main
    <debug> app: In nrf_bootloader_init
    <debug> nrf_dfu_settings: Calling nrf_dfu_settings_init()...
    <debug> nrf_dfu_flash: Initializing nrf_fstorage_nvmc backend.
    <debug> nrf_dfu_settings: Using settings page.
    <debug> nrf_dfu_settings: Copying forbidden parts from backup page.
    <info> nrf_dfu_settings: Old settings page detected. Upgrading info.
    <debug> nrf_dfu_settings: Writing settings...
    <debug> nrf_dfu_settings: Erasing old settings at: 0x0007F000
    <debug> nrf_dfu_flash: nrf_fstorage_erase(addr=0x0x0007F000, len=1 pages), queue usage: 0
    <debug> nrf_dfu_flash: Flash erase success: addr=0x0007F000, pending 0
    <debug> nrf_dfu_flash: nrf_fstorage_write(addr=0x0007F000, src=0x2000934C, len=896 bytes), queue usage: 1
    <debug> nrf_dfu_flash: Flash write success: addr=0x0007F000, pending 0
    <info> nrf_dfu_settings: Backing up settings page to address 0x7E000.
    <debug> nrf_dfu_settings: Writing settings...
    <debug> nrf_dfu_settings: Erasing old settings at: 0x0007E000
    <debug> nrf_dfu_flash: nrf_fstorage_erase(addr=0x0x0007E000, len=1 pages), queue usage: 1
    <debug> nrf_dfu_flash: Flash erase success: addr=0x0007E000, pending 0
    <debug> nrf_dfu_flash: nrf_fstorage_write(addr=0x0007E000, src=0x200096CC, len=896 bytes), queue usage: 1
    <debug> nrf_dfu_flash: Flash write success: addr=0x0007E000, pending 0
    <debug> app: Enter nrf_bootloader_fw_activate
    <info> app: No firmware to activate.
    <debug> app: App is valid
    <info> nrf_dfu_settings: Backing up settings page to address 0x7E000.
    <debug> nrf_dfu_settings: Destination settings are identical to source, write not needed. Skipping.
    <debug> app: Running nrf_bootloader_app_start with address: 0x00001000
    <debug> app: Disabling interrupts. NVIC->ICER[0]: 0x0

    /opt/nrfjprog/nrfjprog --readregs

    PC:   0x0002656C

    Next problem founded:

    After writing firmware with DFU and first reset i got (<debug> app: Running nrf_bootloader_app_start with address: 0x00001000) and application does not running.

    After second reset all correct:

    <info> app: Load.
    <info> app: Load main_config.
    <debug> app: Main FDS Event: 0 received
    <info> app: FDS initialized

    Every  second reset not run app, but start bootloader with halt.

  • Hi,

    PC:   0x0002656C is inside the application region, so the app did start in this case. Could you post the entire readout from "readregs", and also if you are able to check what your application is doing at this address (with addr2line, from *.map file, or disassembly view in IDE)?

  • addr2line -e fw_aac_52832_s132.elf  0x0002656C
    ./components/libraries/util/app_error_weak.c:100 (discriminator 1)

    Once view error:

    <error> app: SOFTDEVICE: INVALID MEMORY ACCESS

Related