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

nRF5 SDK16.0.0 bootloader issue

Hello,

I am trying to upload the firmware with secure DFU using following method:

  1. generated the dfu_public_key.c and private.pem pair
  2. copied the "dfu_public_key.c" into "\examples\dfu" folder
  3. Ran "build_all.bat" to create "micro_ecc_lib_nrf52.a" at "\nRF5_SDK_16.0.0_98a08e2\external\micro-ecc\nrf52hf_armgcc\armgcc"
  4. Compiled "secure_bootloader_ble_s140_pca10056.emProject" and copied "secure_bootloader_ble_s140_pca10056.hex" to the package folder as "bootloader.hex"
  5. Ran "02_flash_SD_and_bootloader.bat" to upload the bootloader
  6. FW.zip was created using "03_create_fw_zip_package.bat"

I can see DFUTarg when I search the devices but when try to upload the FW.zip, it prompts error: "When writing 'EXECUTE' command to Control Point Characteristic of DFU Target: Operation code 4 (EXECUTE) failed on DFU Target. Result code 5 (INVALID_OBJECT)". Please see the attached image of error.

I have been doing this for SDK15.0.0 and nRF52832 for several months. The only difference now is that the SDK is v16.0.0 and chip is nRF52840. I have paid attention when copied the bootloader (which is s140 for nRF52840). Also the DFU example is also for S140 and nRF840. The FW.zip compiled project is also for nRF52840 which, otherwise, works fine on chip. 

Please let me know why this error is happening.

Parents
  • Hello,

    I don't understand what scripts you refer to. Where did you find "02_flash_SD_and_bootloader.bat" and "03_create_fw_zip_package.bat"? What command was used to generate the packet?

    BR,

    Edvin

  • 01_generate_private_public_keys.bat

    
    @echo off
    
    :: # Check to make sure nrfutil is installed before moving on
    WHERE >nul 2>nul nrfutil
    IF %ERRORLEVEL% NEQ 0 (
    ECHO "nrfutil was not found in PATH, please install using pip install"
    goto :end
    )
    
    :: Generate private key - ref http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.tools/dita/tools/nrfutil/nrfutil_keys_generate_display.html?cp=5_5_5
    :: and http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.0.0/lib_bootloader_dfu_keys.html?cp=4_0_0_3_5_1_3
    echo Generate a private key in private.pem
    nrfutil keys generate private.pem
    
    ::echo Display the generated private key (in little-endian format)
    ::nrfutil keys display --key sk --format hex private.pem
    
    ::echo Display the public key that corresponds to the generated private key
    ::echo (in little-endian format)
    ::nrfutil keys display --key pk --format hex private.pem
    
    ::echo Display the public key that corresponds to the generated private key
    ::echo (in code format to be used with DFU)
    ::nrfutil keys display --key pk --format code private.pem
    
    echo Write the public key that corresponds to the generated private key
    echo to the file dfu_public_key.c (in code format)
    nrfutil keys display --key pk --format code private.pem --out_file dfu_public_key.c
    
    :end
    pause

    02_flash_SD_and_bootloader.bat

    @echo off
    
    :: # Check to make sure nrfjprog is installed before moving on
    WHERE >nul 2>nul nrfjprog
    IF %ERRORLEVEL% NEQ 0 (
    ECHO "nrfjprog was not found in PATH, please install using windows installed as found on nordicsemi.com"
    goto :end
    )
    WHERE >nul 2>nul mergehex
    IF %ERRORLEVEL% NEQ 0 (
    ECHO "mergehex was not found in PATH, please install using windows installed as found on nordicsemi.com"
    goto :end
    )
    
    SET S140=s140_nrf52_6.1.0_softdevice.hex
    SET BOOTLOADER=bootloader.hex
    
    echo "## Looking to make sure %S140% exists"
    if not exist %S140% (
    echo "#### s140 hex file does not exist! Make sure the softdevice is in the same folder as this script!"
    goto :end
    )
    echo.
    
    echo "## Looking to make sure %BOOTLOADER% exists"
    if not exist %BOOTLOADER% (
    echo "#### Bootloader hex file does not exist! Please make sure its compiled, copied, and renamed into this folder!"
    goto :end
    )
    echo.
    
    echo "## Merging S140 and bootloader, then flashing it to nRF52-DK; make sure the DK is powered on and connected to the PC"
    mergehex -m %S140% %BOOTLOADER% -o merged_SD_bootloader.hex
    nrfjprog --program merged_SD_bootloader.hex --chiperase
    echo.
    
    echo "## Please power cycle the DK and then with nRF Connect, make sure the board is in bootloader mode and ADV as DfuTarg"
    echo.
    
    :end
    pause

    03_create_fw_zip_package.bat

    
    @echo off
    
    :: # Check to make sure nrfutil is installed before moving on
    WHERE >nul 2>nul nrfutil
    IF %ERRORLEVEL% NEQ 0 (
    ECHO "nrfutil was not found in PATH, please install using pip install"
    goto :end
    )
    
    SET S140=s140_nrf52_6.1.0_softdevice.hex
    SET APPLICATION_HEX=app.hex
    
    echo "## Looking to make sure %S140% is present in folder"
    if not exist %S140% (
    echo "#### s140 hex file does not exist! Please copy this file into the folder and try again!"
    goto :end
    )
    echo.
    
    echo "## Looking to make sure %APPLICATION_HEX% is present in folder"
    if not exist %APPLICATION_HEX% (
    echo "#### app.hex file does not exist! Please copy a application .hex file into the folder, rename it, and try again!"
    goto :end
    )
    echo.
    
    echo "## Creating a FW.zip package that can be used to update the FW on the DK"
    nrfutil pkg generate --application app.hex --application-version 1 --application-version-string "1.0.0" --hw-version 52 --sd-req 0xA8 --sd-id 0xA8 --softdevice s140_nrf52_6.1.0_softdevice.hex --key-file private.pem FW_Hotshot_hv_fv.zip
    echo.
    
    :end
    pause

  • Hello ,

    I have copied exact script in the SDK16.0.0\examples\dfu\secure_bootloader\pca10056_s140_ble\armgcc

    make -j9
    nrfjprog -e
    nrfjprog --program ..\..\..\..\..\components\softdevice\s140\hex\s140_nrf52_7.0.1_softdevice.hex --verify
    nrfjprog --program _build\nrf52840_xxaa_s140.hex --verify
    nrfjprog --reset
    
    del files\bootloader.hex
    del files\buttonless.hex
    del files\private.key
    
    copy ..\..\..\..\ble_peripheral\ble_app_buttonless_dfu\pca10056\s140\armgcc\_build\nrf52840_xxaa.hex files\buttonless.hex
    copy _build\nrf52840_xxaa_s140.hex files\bootloader.hex
    copy ..\..\..\private.key files\private.key
    
    
    nrfutil pkg generate --application files\buttonless.hex --application-version 1 --hw-version 52 --sd-req 0xCA --key-file files\private.key files\my_image.zip

    Here is the result of the script when executed:

    DONE nrf52840_xxaa_s140
    Erasing user available code and UICR flash areas.
    Applying system reset.
    Parsing hex file.
    Reading flash area to program to guarantee it is erased.
    Checking that the area to write is not protected.
    Programming device.
    Verifying programming.
    Verified OK.
    Parsing hex file.
    Reading flash area to program to guarantee it is erased.
    Checking that the area to write is not protected.
    Programming device.
    Verifying programming.
    Verified OK.
    Applying system reset.
    Run.
            1 file(s) copied.
            1 file(s) copied.
            1 file(s) copied.
    Zip created at files\my_image.zip
    Press any key to continue . . .
    

    Before this, I had to compile the "nRF5_SDK_16.0.0_98a08e2\examples\ble_peripheral\ble_app_buttonless_dfu" project using following script:

    @ECHO OFF
    
    :: This script will use git (must be in %PATH%) and arm-none-eabi tools in combination with GNU Make
    :: to both fetch and compile all variants of micro-ecc for the nRF5 families
    
    WHERE >nul 2>nul git
    IF %ERRORLEVEL% NEQ 0 (
        ECHO "git is not installed. Please install and append to PATH."
    )
    
    IF NOT EXIST micro-ecc/uECC.c (
        ECHO "micro-ecc not found! Let's pull it from HEAD."
        git clone https://github.com/kmackay/micro-ecc.git
    )
    
    make -C pca10056/s140/armgcc
    ::make -C nrf51_iar/armgcc
    
    pause

    The "my_image.zip" was created in the "files folder".

    But when I try to upload the "my_image.zip" via DFU, exact same error is prompted as noted in the very first post of this ticket:

    When writing 'EXECUTE' command to Control Point Characteristic of DFU Target: Operation code 4 (EXECUTE) failed on DFU Target. Result code 5 (INVALID_OBJECT).

    About the following line in your script:

    copy ..\..\..\..\ble_peripheral\ble_app_buttonless_dfu\pca10056\s140\armgcc\_build\nrf52840_xxaa.hex files\buttonless.hex

    Are you sure it is ble_app_buttonless_dfu and not \examples\dfu\secure_bootloader\pca10056_s140_ble\armgcc\_build folder from where dfu file needs to be copied?

  • I used the buttonless example as an example of the application that I wanted to update to via DFU.

    What HW are you running on? A normal DK?

    Can you please try to unzip an unmodified version of the SDK and:

    1: generate private.key and dfu_public_key.c in SDK\examples\dfu.
    2: compile the bootloader, ble_app_buttonless_dfu.
    3: run the build_all.bat from SDK\external\micro-ecc, and run the script again? 

    It should work out of the box like that, if you are running on a DK. What DK version do you have?

    BR,

    Edvin

  • It's a 3rd party DK with nRF52840 module. So the pca10056 and S140 should work on it. 

  • Does it have an external LFXTAL, or only RC Oscillator? And what are the specs on the LFXTAL?

    Did you try the unmodified SDK?

  • Yes, I tried unmodified SDK and it miraculously worked.  

    Thanks for the help.

Reply Children
No Data
Related