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

nRF52840 BLE Buttonless DFU SDK 15.3.0 example memory issue

Hello



File: secure_bootloader_ble_s140_pca10056.emProject

File: ble_app_buttonless_dfu_pca10056_s140.emProject

Board: nRF52840-DK

SDK Version: 15.3.0

Soft Device: s140_nrf52_6.1.1

OS: Ubuntu 18.04.3

Intent: Add buttonless dfu feature to our existing ble project.

Issue 1: Buttonless example is successful when uploading the package.zip using the DFU. When uploading Buttonless example with J-Link through SES, we get an err_code = 4, resulting in NRF_BREAKPOINT_COND.

When uploading with SES/J-Link the 0x1000 (4096) page is being written to and this is causing the uicr_bootloader_start_address @ 0xff8 location to be erased, and is reading 0xffff-ffff. We are expecting the uicr_bootloader_start_address @ 0xff8 to be 0xF8000.

I believe the reason the DFU transfer of the buttonless example works, is because the bootloader is protecting the flash from being overwritten (Line 32 of secure bootloader main.c). While the SES upload is not protecting that space.

Question 1: Can this issue be recreated with the BLE Buttonless DFU example?

Question 2: Why is the project writing to 0x0 – 0xfff?


Modifications made to our application: We have an existing BLE application we are developing, and are adding the buttonless dfu feature to our application. I will list the settings I have modified in my attempt to get the buttonless dfu feature working on our application.

After making these changes our application does not work with both upload methods, SES/J-Link or, DFU. The 0xff8 memory issue described above is also seen with our application.

    Modified main.c to include buttonless features
    Include several SDK files into the project
        nRF_DFU folder
            ble_dfu_bonded
            ble_dfu
            ble_dfu_unbonded
        nRF_SVC folder
            nrf_dfu_svci
        Add user include directories
            ../nRF5-SDK/components/libraries/bootloader/ble_dfu
            ../nRF5-SDK/components/libraries/bootloader/dfu
            ../nRF5-SDK/components/libraries/bootloader
            ../nRF5-SDK/components/libraries/svc
        Add Preprocessor Defines Code>>Preprocessor>>Preprocessor Definitions (Common)
            BL_SETTINGS_ACCESS_ONLY
            NRF_DFU_SVCI_ENABLED
            NRF_DFU_TRANSPORT_BLE=1
        Modified sdk_config.h
            Note: These were the only defines different in our app vs the buttonless example. These are the values I kept in our app.
            BLE_DFU_ENABLED 1
            NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY 1
            NRF_LOG_BACKEND_RTT_ENABLED 1
        flash_placement xml
            added "uicr_bootloader_start_address" section
        Added bootloader address to Build>>Memory Segments (Common) "uicr_bootloader_start_address RX 0x00000FF8 0x4"

Question 3: Have I left out settings or properties from this list for the BLE Buttonless DFU to work?

(EDIT) Additionally I have discovered the SoftDevice.hex included in the Project Options>>Loader>> Additional Load File[0]

../nRF5-SDK/components/softdevice/s140/hex/s140_nrf52_6.1.1_softdevice.hex

Was programming the softdevice before the application, this was writing to the MBR Page

MyApplication with s140, MRB page is written to

Preparing target for download
Executing Reset script TargetInterface.resetAndStop()
Reset: Halt core after reset via DEMCR.VC_CORERESET.
Reset: Reset device via AIRCR.SYSRESETREQ.
Downloading 's140_nrf52_6.1.1_softdevice.hex' to J-Link
Programming 2.7 KB of addresses 00000000 -- 00000aff
Programming 147.4 KB of addresses 00001000 -- 00025de7
J-Link: Flash download: Bank 0 @ 0x00000000: 1 range affected (4096 bytes)
J-Link: Flash download: Total time needed: 0.619s (Prepare: 0.165s, Compare: 0.159s, Erase: 0.088s, Program: 0.098s, Verify: 0.003s, Restore: 0.104s)
Download successful
Downloading 'myApplication.elf' to J-Link
Programming 78.8 KB of addresses 00026200 -- 00039d3b
Programming 0.0 KB of addresses 00039d3c -- 00039d4f
Programming 14.8 KB of .rodata addresses 00039d50 -- 0003d8b3
Programming 0.1 KB of addresses 0003d8b4 -- 0003d97b
J-Link: Flash download: Bank 0 @ 0x00000000: 1 range affected (98304 bytes)
J-Link: Flash download: Total time needed: 2.615s (Prepare: 0.160s, Compare: 0.022s, Erase: 0.000s, Program: 2.315s, Verify: 0.004s, Restore: 0.113s)
Download successful

MyApplication without s140 Included MRB page is not written to

Preparing target for download
Executing Reset script TargetInterface.resetAndStop()
Reset: Halt core after reset via DEMCR.VC_CORERESET.
Reset: Reset device via AIRCR.SYSRESETREQ.
Downloading 'myApplication.elf' to J-Link
Programming 79.3 KB of addresses 00026000 -- 00039d3b
Programming 0.0 KB of addresses 00039d3c -- 00039d4f
Programming 14.8 KB of .rodata addresses 00039d50 -- 0003d8b3
Programming 0.1 KB of addresses 0003d8b4 -- 0003d97b
J-Link: Flash download: Bank 0 @ 0x00000000: 1 range affected (4096 bytes)
J-Link: Flash download: Total time needed: 0.391s (Prepare: 0.083s, Compare: 0.090s, Erase: 0.088s, Program: 0.104s, Verify: 0.002s, Restore: 0.020s)
Download successful

I have been following the documentation and the process of uploading Softdevice, then Bootloader, the Application. I have noticed the Bootloader and Application examples include the s140 softdevice within the project.

Question 4: Why is the recommended order to programming softDevice>>BootLoader>>Application, if the bootloader includes the softDevice, and the application includes the softDevice?

Source: https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/ble_sdk_app_buttonless_dfu.html

I should be able to upload softdevice >> bootloader (without softdevice) >> application (without softdevice) and this should work?

Alternatively I should be able to load bootloader (with softdevice) and application (without softdevice)

To be clear our application is a ble application.

Thank you,

  • Would you be able to expand on how to generate the correct bootloader settings page?

    I understand how to generate the settings.hex, but it seems to be incorrect.

    where can I check to confirm what options to choose in the 'nrfutil settings generate' command?

    At this point I am making my best educated guess, but I would like to confirm within the project or bootloader that I am setting the correct value for the bootloader settings page.

    Thank you,

  • Hi,

    This is best described in the bootloader documentation, particularly the Creating a firmware package with nrfutil section under Validation. You can also refer to help from nrfutil ("nrfutil pkg generate --help"):

    Usage: nrfutil pkg generate [OPTIONS] ZIPFILE
    
      Generate a zip package for distribution to apps that support Nordic DFU
      OTA. The application, bootloader, and SoftDevice files are converted to
      .bin if supplied as .hex files. For more information on the generated
      package, see: http://developer.nordicsemi.com/nRF5_SDK/doc/
    
      The following combinations are supported by this command:
    
      * BL only: Supported.
    
      * SD only: Supported (SD of same Major Version).
    
      * APP only: Supported (external or internal).
    
      * BL + SD: Supported.
    
      * BL + APP: Not supported (use two packages instead).
    
      * BL + SD + APP: Supported.
    
      * SD + APP: Supported (SD of same Major Version).
    
    Options:
      --debug-mode                    Debug mode switch, enables version check
                                      skipping.
      --application TEXT              The application firmware file.
      --application-version INTEGER   The application version.
      --application-version-string TEXT
                                      The application version string, e.g
                                      "2.7.31".
      --bootloader TEXT               The bootloader firmware file.
      --bootloader-version INTEGER    The bootloader version.
      --hw-version INTEGER            The hardware version.
      --sd-req TEXT                   The SoftDevice requirements. A comma-
                                      separated list of SoftDevice firmware IDs (1
                                      or more) of which one must be present on the
                                      target device. Each item on the list must be
                                      a two- or four-digit hex number prefixed
                                      with "0x" (e.g. "0x12", "0x1234").
                                      A non-
                                      exhaustive list of well-known values to use
                                      with this option follows:
                                      |s112_nrf52_6.0.0|0xA7|
                                      |s112_nrf52_6.1.0|0xB0|
                                      |s112_nrf52_6.1.1|0xB8|
                                      |s130_nrf51_1.0.0|0x67|
                                      |s130_nrf51_2.0.0|0x80|
                                      |s132_nrf52_2.0.0|0x81|
                                      |s130_nrf51_2.0.1|0x87|
                                      |s132_nrf52_2.0.1|0x88|
                                      |s132_nrf52_3.0.0|0x8C|
                                      |s132_nrf52_3.1.0|0x91|
                                      |s132_nrf52_4.0.0|0x95|
                                      |s132_nrf52_4.0.2|0x98|
                                      |s132_nrf52_4.0.3|0x99|
                                      |s132_nrf52_4.0.4|0x9E|
                                      |s132_nrf52_4.0.5|0x9F|
                                      |s132_nrf52_5.0.0|0x9D|
                                      |s132_nrf52_5.1.0|0xA5|
                                      |s132_nrf52_6.0.0|0xA8|
                                      |s132_nrf52_6.1.0|0xAF|
                                      |s132_nrf52_6.1.1|0xB7|
                                      |s140_nrf52_6.0.0|0xA9|
                                      |s140_nrf52_6.1.0|0xAE|
                                      |s140_nrf52_6.1.1|0xB6|
      --sd-id TEXT                    The new SoftDevice ID to be used as --sd-req
                                      for the Application update in case the ZIP
                                      contains a SoftDevice and an Application.
      --softdevice TEXT               The SoftDevice firmware file.
      --sd-boot-validation TEXT       The method of boot validation for
                                      Softdevice. Choose from:
                                      NO_VALIDATION
                                      VALIDATE_GENERATED_CRC
                                      VALIDATE_GENERATED_SHA256
                                      VALIDATE_ECDSA_P256_SHA256
      --app-boot-validation TEXT      The method of boot validation for
                                      application. Choose from:
                                      NO_VALIDATION
                                      VALIDATE_GENERATED_CRC
                                      VALIDATE_GENERATED_SHA256
                                      VALIDATE_ECDSA_P256_SHA256
      --key-file FILE                 The private (signing) key in PEM fomat.
      --external-app                  Indicates that the FW upgrade is intended to
                                      be passed through (not applied on the
                                      receiving device)
      --zigbee BOOLEAN                Create an image and distribution package for
                                      Zigbee DFU server.
      --zigbee-manufacturer-id INTEGER
                                      Manufacturer ID to be used in Zigbee OTA
                                      header.
      --zigbee-image-type INTEGER     Image type to be used in Zigbee OTA header.
      --zigbee-comment TEXT           Firmware comment to be used in Zigbee OTA
                                      header.
      --zigbee-ota-hw-version INTEGER
                                      The zigbee OTA hw version.
      --zigbee-ota-fw-version INTEGER
                                      The zigbee OTA fw version.
      --help                          Show this message and exit.

Related