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

[SDK12][PCA10040]ble_app_buttonless_dfu not resetting to bootloader

Hi,

I have modified my files as mentioned here. When I upload the package, the template device show and I am able to connect. But when I subscribe to the notification and write 0x01, the device doesn't reboot.

In bootloader log it asks to change the ram start address:

:INFO:Inside main
:INFO:In nrf_bootloader_init
:INFO:In real nrf_dfu_init
:INFO:running nrf_dfu_settings_init
:INFO:!!!!!!!!!!!!!!! Resetting bootloader settings !!!!!!!!!!!
:INFO:Erasing old settings at: 0x0007f000
:INFO:Erasing: 0x0007f000, num: 1
:INFO:Writing 0x00000057 words
:INFO:Writing settings...
:INFO:Enter nrf_dfu_continue
:INFO:Single: Invalid bank
:INFO:Enter nrf_dfu_app_is_valid
:INFO:Return false in valid app check
:INFO:In nrf_dfu_transports_init
:INFO:num transports: 1
:INFO:vector table: 0x00075000
SDH:INFO:sd_ble_enable: RAM START at 0x20002c00
SDH:WARNING:sd_ble_enable: app_ram_base should be adjusted to 0x20002798
SDH:WARNING:ram size should be adjusted to 0xd868 
:INFO:After nrf_dfu_transports_init
:INFO:------- nrf_dfu_flash_init-------
:INFO:Waiting for events

Here is the log without changing the base address:

SDH:INFO:sd_ble_enable: RAM START at 0x20002128
:INFO:running nrf_dfu_settings_init
:INFO:!!!!!!!!!!!!!!! Resetting bootloader settings !!!!!!!!!!!
:INFO:Erasing old settings at: 0x200021ac
:INFO:Erasing: 0x200021ac, num: 1
:INFO:Erase failed: 6
:INFO:Failed to erase bootloader settings
APP:INFO:Indication for BLE_DFU is enabled
APP:INFO:Indication for BLE_DFU is disabled
APP:INFO:Indication for BLE_DFU is enabled
APP:INFO:Device is entering bootloader mode!
:INFO:Erasing old settings at: 0x200021ac
:INFO:Erasing: 0x200021ac, num: 1
:INFO:Erase failed: 6
:INFO:Failed to erase bootloader settings

Here is the log after changing the address:

SDH:INFO:sd_ble_enable: RAM START at 0x20002128
:INFO:running nrf_dfu_settings_init
:INFO:!!!!!!!!!!!!!!! Resetting bootloader settings !!!!!!!!!!!
:INFO:Erasing old settings at: 0x200021ac
:INFO:Erasing: 0x200021ac, num: 1
:INFO:Erase failed: 6
:INFO:Failed to erase bootloader settings
APP:INFO:Indication for BLE_DFU is enabled
APP:INFO:Device is entering bootloader mode!
:INFO:Erasing old settings at: 0x200021ac
:INFO:Erasing: 0x200021ac, num: 1
:INFO:Erase failed: 6
:INFO:Failed to erase bootloader settings

I have tried with both debug bootloader and normal one, the problem remains the same. I am using GCC on Linux. Please help.

Thanks in advance :)


[EDIT]

When I power on the board with BUTTON 4 pressed, the device starts in bootloader mode. Here is the log:

:INFO:Inside main
:INFO:In nrf_bootloader_init
:INFO:In real nrf_dfu_init
:INFO:running nrf_dfu_settings_init
:INFO:Enter nrf_dfu_continue
:INFO:Valid App
:INFO:Application sent bootloader request
:INFO:In nrf_dfu_transports_init
:INFO:num transports: 1
:INFO:vector table: 0x00075000
SDH:INFO:sd_ble_enable: RAM START at 0x20002c00
SDH:WARNING:sd_ble_enable: app_ram_base should be adjusted to 0x20002798
SDH:WARNING:ram size should be adjusted to 0xd868 
:INFO:After nrf_dfu_transports_init
:INFO:------- nrf_dfu_flash_init-------
:INFO:Waiting for events

Also LED3 and LED1 are turned on in this state, not LED4. If I connect LED2 will turn on and LED1 will turn off. I guess this is the desired result right?


[EDIT]

This is the process that I'm following:

  • Erase the flash

  • Program Softdevice from buttonless_dfu Makefile using make flash_softdevice

  • Program bootloader_secure from pca10040_debug Makefile using make flash

  • Create package in buttonless_dfu directory using

    nrfutil pkg generate --debug-mode --key-file priv.pem --application _build/nrf52832_xxaa.hex pkg.zip

  • Transfer the zip to phone and upload using nrfConnect

  • Successfully upload the file

  • Device resets.

  • Connect to the device and enable notification on the unknown characteristic

  • Write 0x01 on the characteristic

  • The received response is 20-01-01, and the logs are as mentioned in the question.

I hope I am not doing anything wrong here.

  • Could you show your log output when you manually trigger the bootloader by holding BUTTON4 and powering the board on? Also do you get "bootloader ready" state (LED2 and LED4 on) when you do so?

  • this is very puzzling as everything seems to be ok at your side.

    Could you please do a full chip erase, flash bootloader+softdevice and upload via ota package containing experimental_ble_app_buttonless_dfu with the only modification from stock SDK would be adding write permission to dfu control point as I've described here: devzone.nordicsemi.com/.../

    If that won't work I give up as identical setup is working for me.

  • I see on difference that may be significant - I use Keil 5.21a. I don't want to spread FUD here but there was some kind of problem related to experimental_section_vars (used in fstorage module) and gcc in SDK11. It resulted in wrong memory map and overwriting parts of the program.

    This part of your log:

    :INFO:Erasing old settings at: 0x200021ac
    :INFO:Erasing: 0x200021ac, num: 1
    :INFO:Erase failed: 6
    :INFO:Failed to erase bootloader settings
    

    hints that something is wrong with flash access. For comparison my instance of ble_app_buttonless_dfu show following:

    :INFO:Erasing old settings at: 0x0007f000
    :INFO:Erasing: 0x0007f000, num: 1
    :INFO:Writing 0x00000057 words
    :INFO:Writing settings...
    :INFO:Obtained settings, enter dfu is 1
    

    Note that bootloader configuration page address is different. By default bootloader flash starts at 0x73000 and is 0xB000 (45kb) long. Address 0x0007f000 points to 508th kilobyte of flash, more or less where bootloader ends. Address 0x200021ac from your log points to ~536 megabyte of flash which is most likely outside of nRF52 address space. So it's likely that some macro that should calculate bootloader address doesn't work for gcc. For reference I can attach my bootloader .hex and update .zip so you can rule out hardware problem.

  • Please provide bootloader .hex and update .zip. I'll also check with Keil and see how it works. This might be a bug in SDK12.

Related