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

Firmware not starting after DFU

Hello, I have the following question. I'm trying to program my firmware via DFU Bootloader and nRF Connect (smartphone). That works perfectly with the test board SparkFun nRF52832 Breakout. But if I do the same with my own hardware, the firmware won't start. The upload goes perfectly, but DFU will start again in two seconds. If the firmware is flashed without a DFU, it works without a problem. It looks like the problem is with the hardware. But I compared everything and found no mistake. What could be causing the error in the hardware that does not allow the flashed firmware to start?

SDK_17.0.0_9d13099, nRF52832

Schematic board SparkFun


Thanks in advance

Parents
  • Hello,

    I don't know what sort of bootloader you are using, but please check out the equvialent _debug project, such as:

    SDK\examples\dfu\secure_bootloader\pca10040_uart_debug

    And monitor the RTT log. What does it say? When the DFU is finished, but it restarts in DFU mode, does the RTT log say anything about why the DFU mode was re-entered?

    What changes did you do to the bootloader project? Have you tested a bootloader from an unmodified SDK?

    Best regards,

    Edvin

  • Sorry Edvin,

    This is the last part of log when I use DFU with debug function:

    .......
    
    00> <debug> nrf_dfu_flash: nrf_fstorage_erase(addr=0x0x0002C000, len=1 pages), queue usage: 1
    00> 
    00> <debug> nrf_dfu_req_handler: Creating object with size: 1324. Offset: 0x00006000, CRC: 0x12CFD00B
    00> 
    00> <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    00> 
    00> <debug> nrf_dfu_flash: Flash erase success: addr=0x0002C000, pending 1
    00> 
    00> <debug> nrf_dfu_ble: Buffer 0x200082AC acquired, len 244 (244)
    00> 
    00> <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_WRITE (data)
    00> 
    00> <debug> nrf_dfu_flash: nrf_fstorage_write(addr=0x0002C000, src=0x200082AC, len=244 bytes), queue usage: 1
    00> 
    00> <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    00> 
    00> <debug> nrf_dfu_flash: Flash write success: addr=0x0002C000, pending 1
    00> 
    00> <debug> nrf_dfu_ble: Freeing buffer 0x200082AC
    00> 
    00> <debug> nrf_dfu_ble: Buffer 0x200082AC acquired, len 244 (244)
    00> 
    00> <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_WRITE (data)
    00> 
    00> <debug> nrf_dfu_flash: nrf_fstorage_write(addr=0x0002C0F4, src=0x200082AC, len=244 bytes), queue usage: 1
    00> 
    00> <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    00> 
    00> <debug> nrf_dfu_flash: Flash write success: addr=0x0002C0F4, pending 1
    00> 
    00> <debug> nrf_dfu_ble: Freeing buffer 0x200082AC
    00> 
    00> <debug> nrf_dfu_ble: Buffer 0x200082AC acquired, len 244 (244)
    00> 
    00> <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_WRITE (data)
    00> 
    00> <debug> nrf_dfu_flash: nrf_fstorage_write(addr=0x0002C1E8, src=0x200082AC, len=244 bytes), queue usage: 1
    00> 
    00> <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    00> 
    00> <debug> nrf_dfu_flash: Flash write success: addr=0x0002C1E8, pending 1
    00> 
    00> <debug> nrf_dfu_ble: Freeing buffer 0x200082AC
    00> 
    00> <debug> nrf_dfu_ble: Buffer 0x200082AC acquired, len 244 (244)
    00> 
    00> <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_WRITE (data)
    00> 
    00> <debug> nrf_dfu_flash: nrf_fstorage_write(addr=0x0002C2DC, src=0x200082AC, len=244 bytes), queue usage: 1
    00> 
    00> <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    00> 
    00> <debug> nrf_dfu_flash: Flash write success: addr=0x0002C2DC, pending 1
    00> 
    00> <debug> nrf_dfu_ble: Freeing buffer 0x200082AC
    00> 
    00> <debug> nrf_dfu_ble: Buffer 0x200082AC acquired, len 244 (244)
    00> 
    00> <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_WRITE (data)
    00> 
    00> <debug> nrf_dfu_flash: nrf_fstorage_write(addr=0x0002C3D0, src=0x200082AC, len=244 bytes), queue usage: 1
    00> 
    00> <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    00> 
    00> <debug> nrf_dfu_flash: Flash write success: addr=0x0002C3D0, pending 1
    00> 
    00> <debug> nrf_dfu_ble: Freeing buffer 0x200082AC
    00> 
    00> <debug> nrf_dfu_ble: Buffer 0x200082AC acquired, len 104 (244)
    00> 
    00> <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_WRITE (data)
    00> 
    00> <debug> nrf_dfu_flash: nrf_fstorage_write(addr=0x0002C4C4, src=0x200082AC, len=104 bytes), queue usage: 1
    00> 
    00> <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    00> 
    00> <debug> nrf_dfu_flash: Flash write success: addr=0x0002C4C4, pending 1
    00> 
    00> <debug> nrf_dfu_ble: Freeing buffer 0x200082AC
    00> 
    00> <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_CRC_GET (data)
    00> 
    00> <debug> nrf_dfu_req_handler: Offset:25900, CRC:0x2A9E2C99
    00> 
    00> <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    00> 
    00> <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_EXECUTE (data)
    00> 
    00> <debug> nrf_dfu_req_handler: Whole firmware image received. Postvalidating.
    00> 
    00> <debug> nrf_dfu_validation: Hash verification. start address: 0x26000, size: 0x652C
    00> 
    00> <debug> nrf_dfu_validation: Invalidating old application in bank 0.
    00> 
    00> <debug> nrf_dfu_settings: Writing settings...
    00> 
    00> <debug> nrf_dfu_settings: Erasing old settings at: 0x0007F000
    00> 
    00> <debug> nrf_dfu_flash: nrf_fstorage_erase(addr=0x0x0007F000, len=1 pages), queue usage: 1<info> app: Inside main
    00> 
    00> <debug> app: In nrf_bootloader_init
    00> 
    00> <debug> nrf_dfu_settings: Calling nrf_dfu_settings_init()...
    00> 
    00> <debug> nrf_dfu_flash: Initializing nrf_fstorage_nvmc backend.
    00> 
    00> <debug> nrf_dfu_settings: Using settings page.
    00> 
    00> <debug> nrf_dfu_settings: Copying forbidden parts from backup page.
    00> 
    00> <debug> nrf_dfu_settings: Destination settings are identical to source, write not needed. Skipping.
    00> 
    00> <info> nrf_dfu_settings: Backing up settings page to address 0x7E000.
    00> 
    00> <debug> nrf_dfu_settings: Destination settings are identical to source, write not needed. Skipping.
    00> 
    00> <debug> app: Enter nrf_bootloader_fw_activate
    00> 
    00> <info> app: No firmware to activate.
    00> 
    00> <info> app: Boot validation failed. No valid app to boot.
    00> 
    00> <debug> app: DFU mode because app is not valid.
    00> 
    00> <info> nrf_bootloader_wdt: WDT is not enabled
    00> 
    00> <debug> app: in weak nrf_dfu_init_user
    00> 
    00> <debug> app: timer_stop (0x20005984)
    00> 
    00> <debug> app: timer_activate (0x20005984)
    00> 
    00> <info> app: Entering DFU mode.
    00> 
    00> <debug> app: Initializing transports (found: 1)
    00> 
    00> <debug> nrf_dfu_ble: Initializing BLE DFU transport
    00> 
    00> <debug> nrf_dfu_ble: Setting up vector table: 0x00071000
    00> 
    00> <debug> nrf_dfu_ble: Enabling SoftDevice.
    00> 
    00> <debug> nrf_dfu_ble: Configuring BLE stack.
    00> 
    00> <debug> nrf_dfu_ble: Enabling the BLE stack.
    00> 
    00> <debug> nrf_dfu_ble: No advertising name found
    00> 
    00> <debug> nrf_dfu_ble: Using default advertising name
    00> 
    00> <debug> nrf_dfu_ble: Advertising...
    00> 
    00> <debug> nrf_dfu_ble: BLE DFU transport initialized.
    00> 
    00> <debug> nrf_dfu_flash: Initializing nrf_fstorage_sd backend.
    00> 
    00> <debug> app: Enter main loop
    00> 
    00> <debug> nrf_dfu_ble: Connected
    00> 
    00> <debug> nrf_dfu_ble: Received BLE_GAP_EVT_CONN_PARAM_UPDATE
    00> 
    00> <debug> nrf_dfu_ble: max_conn_interval: 12
    00> 
    00> <debug> nrf_dfu_ble: min_conn_interval: 12
    00> 
    00> <debug> nrf_dfu_ble: slave_latency: 0
    00> 
    00> <debug> nrf_dfu_ble: conn_sup_timeout: 600
    00> 
    00> <debug> nrf_dfu_ble: Received BLE_GAP_EVT_CONN_PARAM_UPDATE
    00> 
    00> <debug> nrf_dfu_ble: max_conn_interval: 6
    00> 
    00> <debug> nrf_dfu_ble: min_conn_interval: 6
    00> 
    00> <debug> nrf_dfu_ble: slave_latency: 0
    00> 
    00> <debug> nrf_dfu_ble: conn_sup_timeout: 500
    00> 
    00> <debug> nrf_dfu_ble: Received BLE_GAP_EVT_CONN_PARAM_UPDATE
    00> 
    00> <debug> nrf_dfu_ble: max_conn_interval: 12
    00> 
    00> <debug> nrf_dfu_ble: min_conn_interval: 12
    00> 
    00> <debug> nrf_dfu_ble: slave_latency: 0
    00> 
    00> <debug> nrf_dfu_ble: conn_sup_timeout: 600
    00> 
    00> <debug> nrf_dfu_ble: Advertising...
    00> 
    00> <debug> nrf_dfu_settings: Using settings page.
    00> 
    00> <debug> nrf_dfu_settings: Copying forbidden parts from backup page.

Reply
  • Sorry Edvin,

    This is the last part of log when I use DFU with debug function:

    .......
    
    00> <debug> nrf_dfu_flash: nrf_fstorage_erase(addr=0x0x0002C000, len=1 pages), queue usage: 1
    00> 
    00> <debug> nrf_dfu_req_handler: Creating object with size: 1324. Offset: 0x00006000, CRC: 0x12CFD00B
    00> 
    00> <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    00> 
    00> <debug> nrf_dfu_flash: Flash erase success: addr=0x0002C000, pending 1
    00> 
    00> <debug> nrf_dfu_ble: Buffer 0x200082AC acquired, len 244 (244)
    00> 
    00> <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_WRITE (data)
    00> 
    00> <debug> nrf_dfu_flash: nrf_fstorage_write(addr=0x0002C000, src=0x200082AC, len=244 bytes), queue usage: 1
    00> 
    00> <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    00> 
    00> <debug> nrf_dfu_flash: Flash write success: addr=0x0002C000, pending 1
    00> 
    00> <debug> nrf_dfu_ble: Freeing buffer 0x200082AC
    00> 
    00> <debug> nrf_dfu_ble: Buffer 0x200082AC acquired, len 244 (244)
    00> 
    00> <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_WRITE (data)
    00> 
    00> <debug> nrf_dfu_flash: nrf_fstorage_write(addr=0x0002C0F4, src=0x200082AC, len=244 bytes), queue usage: 1
    00> 
    00> <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    00> 
    00> <debug> nrf_dfu_flash: Flash write success: addr=0x0002C0F4, pending 1
    00> 
    00> <debug> nrf_dfu_ble: Freeing buffer 0x200082AC
    00> 
    00> <debug> nrf_dfu_ble: Buffer 0x200082AC acquired, len 244 (244)
    00> 
    00> <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_WRITE (data)
    00> 
    00> <debug> nrf_dfu_flash: nrf_fstorage_write(addr=0x0002C1E8, src=0x200082AC, len=244 bytes), queue usage: 1
    00> 
    00> <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    00> 
    00> <debug> nrf_dfu_flash: Flash write success: addr=0x0002C1E8, pending 1
    00> 
    00> <debug> nrf_dfu_ble: Freeing buffer 0x200082AC
    00> 
    00> <debug> nrf_dfu_ble: Buffer 0x200082AC acquired, len 244 (244)
    00> 
    00> <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_WRITE (data)
    00> 
    00> <debug> nrf_dfu_flash: nrf_fstorage_write(addr=0x0002C2DC, src=0x200082AC, len=244 bytes), queue usage: 1
    00> 
    00> <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    00> 
    00> <debug> nrf_dfu_flash: Flash write success: addr=0x0002C2DC, pending 1
    00> 
    00> <debug> nrf_dfu_ble: Freeing buffer 0x200082AC
    00> 
    00> <debug> nrf_dfu_ble: Buffer 0x200082AC acquired, len 244 (244)
    00> 
    00> <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_WRITE (data)
    00> 
    00> <debug> nrf_dfu_flash: nrf_fstorage_write(addr=0x0002C3D0, src=0x200082AC, len=244 bytes), queue usage: 1
    00> 
    00> <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    00> 
    00> <debug> nrf_dfu_flash: Flash write success: addr=0x0002C3D0, pending 1
    00> 
    00> <debug> nrf_dfu_ble: Freeing buffer 0x200082AC
    00> 
    00> <debug> nrf_dfu_ble: Buffer 0x200082AC acquired, len 104 (244)
    00> 
    00> <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_WRITE (data)
    00> 
    00> <debug> nrf_dfu_flash: nrf_fstorage_write(addr=0x0002C4C4, src=0x200082AC, len=104 bytes), queue usage: 1
    00> 
    00> <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    00> 
    00> <debug> nrf_dfu_flash: Flash write success: addr=0x0002C4C4, pending 1
    00> 
    00> <debug> nrf_dfu_ble: Freeing buffer 0x200082AC
    00> 
    00> <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_CRC_GET (data)
    00> 
    00> <debug> nrf_dfu_req_handler: Offset:25900, CRC:0x2A9E2C99
    00> 
    00> <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    00> 
    00> <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_EXECUTE (data)
    00> 
    00> <debug> nrf_dfu_req_handler: Whole firmware image received. Postvalidating.
    00> 
    00> <debug> nrf_dfu_validation: Hash verification. start address: 0x26000, size: 0x652C
    00> 
    00> <debug> nrf_dfu_validation: Invalidating old application in bank 0.
    00> 
    00> <debug> nrf_dfu_settings: Writing settings...
    00> 
    00> <debug> nrf_dfu_settings: Erasing old settings at: 0x0007F000
    00> 
    00> <debug> nrf_dfu_flash: nrf_fstorage_erase(addr=0x0x0007F000, len=1 pages), queue usage: 1<info> app: Inside main
    00> 
    00> <debug> app: In nrf_bootloader_init
    00> 
    00> <debug> nrf_dfu_settings: Calling nrf_dfu_settings_init()...
    00> 
    00> <debug> nrf_dfu_flash: Initializing nrf_fstorage_nvmc backend.
    00> 
    00> <debug> nrf_dfu_settings: Using settings page.
    00> 
    00> <debug> nrf_dfu_settings: Copying forbidden parts from backup page.
    00> 
    00> <debug> nrf_dfu_settings: Destination settings are identical to source, write not needed. Skipping.
    00> 
    00> <info> nrf_dfu_settings: Backing up settings page to address 0x7E000.
    00> 
    00> <debug> nrf_dfu_settings: Destination settings are identical to source, write not needed. Skipping.
    00> 
    00> <debug> app: Enter nrf_bootloader_fw_activate
    00> 
    00> <info> app: No firmware to activate.
    00> 
    00> <info> app: Boot validation failed. No valid app to boot.
    00> 
    00> <debug> app: DFU mode because app is not valid.
    00> 
    00> <info> nrf_bootloader_wdt: WDT is not enabled
    00> 
    00> <debug> app: in weak nrf_dfu_init_user
    00> 
    00> <debug> app: timer_stop (0x20005984)
    00> 
    00> <debug> app: timer_activate (0x20005984)
    00> 
    00> <info> app: Entering DFU mode.
    00> 
    00> <debug> app: Initializing transports (found: 1)
    00> 
    00> <debug> nrf_dfu_ble: Initializing BLE DFU transport
    00> 
    00> <debug> nrf_dfu_ble: Setting up vector table: 0x00071000
    00> 
    00> <debug> nrf_dfu_ble: Enabling SoftDevice.
    00> 
    00> <debug> nrf_dfu_ble: Configuring BLE stack.
    00> 
    00> <debug> nrf_dfu_ble: Enabling the BLE stack.
    00> 
    00> <debug> nrf_dfu_ble: No advertising name found
    00> 
    00> <debug> nrf_dfu_ble: Using default advertising name
    00> 
    00> <debug> nrf_dfu_ble: Advertising...
    00> 
    00> <debug> nrf_dfu_ble: BLE DFU transport initialized.
    00> 
    00> <debug> nrf_dfu_flash: Initializing nrf_fstorage_sd backend.
    00> 
    00> <debug> app: Enter main loop
    00> 
    00> <debug> nrf_dfu_ble: Connected
    00> 
    00> <debug> nrf_dfu_ble: Received BLE_GAP_EVT_CONN_PARAM_UPDATE
    00> 
    00> <debug> nrf_dfu_ble: max_conn_interval: 12
    00> 
    00> <debug> nrf_dfu_ble: min_conn_interval: 12
    00> 
    00> <debug> nrf_dfu_ble: slave_latency: 0
    00> 
    00> <debug> nrf_dfu_ble: conn_sup_timeout: 600
    00> 
    00> <debug> nrf_dfu_ble: Received BLE_GAP_EVT_CONN_PARAM_UPDATE
    00> 
    00> <debug> nrf_dfu_ble: max_conn_interval: 6
    00> 
    00> <debug> nrf_dfu_ble: min_conn_interval: 6
    00> 
    00> <debug> nrf_dfu_ble: slave_latency: 0
    00> 
    00> <debug> nrf_dfu_ble: conn_sup_timeout: 500
    00> 
    00> <debug> nrf_dfu_ble: Received BLE_GAP_EVT_CONN_PARAM_UPDATE
    00> 
    00> <debug> nrf_dfu_ble: max_conn_interval: 12
    00> 
    00> <debug> nrf_dfu_ble: min_conn_interval: 12
    00> 
    00> <debug> nrf_dfu_ble: slave_latency: 0
    00> 
    00> <debug> nrf_dfu_ble: conn_sup_timeout: 600
    00> 
    00> <debug> nrf_dfu_ble: Advertising...
    00> 
    00> <debug> nrf_dfu_settings: Using settings page.
    00> 
    00> <debug> nrf_dfu_settings: Copying forbidden parts from backup page.

Children
  • So the log above says that app is invalid: <debug> app: DFU mode because app is not valid. What can be the error when app works without DFU. And with other SparkFun hardware, the app also works with DFU? What else can I look for?

    Thanks

  • Hello,

    On the SparkFun hardware, did you program the bootloader yourself, or was it pre-programmed?

    How did you program the bootloader and application on your custom hardware? Did you generate and program the bootloader settings? If you compiled the bootloader yourself, did you do any changes to the bootloader project? If so, which ones?

    Do you see the bootloader advertisements? have you tried to update the firmware via DFU? If so, how did you generate the DFU image?

    Best regards,

    Edvin

  • Hi Edvin,

    On the SparkFun hardware, did you program the bootloader yourself, or was it pre-programmed?

    I programmed both hardware (SparkFun and my own hardware) with SES. First Target -> Erase All and then Target -> Download secure_bootloader_ble_s132_pca10040.

    How did you program the bootloader and application on your custom hardware? Did you generate and program the bootloader settings?

    I did not generate bootloader settings. Probably here is my mistake?

    If you compiled the bootloader yourself, did you do any changes to the bootloader project? If so, which ones?

    I only removed LED functions (bsp_board_led_on(BSP_BOARD_LED_0)…) and #include "boards.h" from example nRF5_SDK_17.0.0_9d13099 \ examples \ dfu \ secure_bootloader \ pca10040_s132_ble.

    Do you see the bootloader advertisements? have you tried to update the firmware via DFU? If so, how did you generate the DFU image?

    Yes, I see DFU advertisements in nRF Connect Android app. I can also flash FW. I generated the FW image with nrfutill. The image is successfully flashed via Android app and works with SparkFun hardware. The image is flashed in the same way with own hardware but does not start. The RTT log says that app is invalid: <debug> app: DFU mode because app is not valid.

    Maybe it is missing bootloader settings in own hardware?

    Thanks

  • Hello Edvin,

    I believe i have found possible cause. The SparkFun hardware has nRF52832-QFAA 64kB. In my own hardware I have nRF52832-QFAB 32kB. I only now understood that I ordered the wrong nRF. I have read out memories from both nRFs with nRF Connect (please see screenshot). With nRF AB (32 kB) bootloader is not displayed, why? Although DFU works and the screenshots are already with the app that I flashed via DFU (please see address 0x00026000 - 0x0002C52B). App is only 25,900 bytes and should also work with nRF AB. The app does not start with nRF52832-QFAB 32kB. What do I have to adjust in order to start the app with nRF AB (32 kB)?

  • I see.

    Did it not throw any errors when you programmed the bootloader? If not, what happens if you try to read out e.g. the flash address:

    "nrfjprog --memrd 0x00078000 --n 1024"

    ?

    What is the bootloader's flash start address?

    Basically what you need to do is to change the flash addresses. If your application uses FDS (Used if you use the peer manager or any other parts that uses FDS), then make sure that it fetches the correct address.

    Depening on what IDE you are using, it is probably possible to change the compiler to set the QFAB instead of QFAA as the target.

    Best regards,

    Edvin

Related