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

SDK 15 and Mesh 2.0 Generate a DFU file with nrfutil - ValueError

We used nRF5_SDK_15.0.0_a53641a and nrf5_SDK_for_Mesh_v2.0.0_src.

We are following DFU quick start guide http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.meshsdk.v0.10.0%2Findex.html

For nRF52:

mesh-sdk$ nrfutil dfu genpkg --application bin/blinky/blinky_nrf52832_xxAA_s132_5.0.0.hex \
--company-id 0x00000089 \
--application-id 1 \
--application-version 2 \
--key-file private_key.txt \
--sd-req 0x009D \
--mesh dfu_test.zip
We used "--company-id 0x00000089 \" to match Step 2 public key:
{
"bootloader_config": {
"bootloader_id": 1,
"bootloader_version": 1,
"company_id": 89,
"application_id": 1,
"application_version": 1,
"public_key": "ed09a58df6db5cd15b8637304f31d31f4042492ed7c7e4839fbe903f260a2ba1a855e92b72885825481ad56282bcf549ad7455ec46f000f0f62d97eeec883ba6"
}
}
The hex we used is C:\Nordic\nRF5_SDK_15.0.0_a53641a\mesh_sdk\bin\blinky\blinky_nrf52832_xxAA_s132_5.0.0.hexblinky_nrf52832_xxAA_s132_5.0.0.hex
We got ValueError, please see attached screen shot. 
Please advise.  Thanks
Parents
  • We started command prompt on an administrator.  I have make sure all the steps before and after step 8 using s132 softdevice version 6.0.  We tried to flash the program via both SES and nrfjprog (like shown in step 8).  We also used difference Bud rate 115200, 57600, 38400, 19200, 14400 and 9600.

    Attached are the cmd script file

    Microsoft Windows [Version 6.1.7601]
    Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
    
    C:\Users\ALaw>cd C:\Nordic\nrf5_SDK_for_Mesh_v2.0.1_src
    
    C:\Nordic\nrf5_SDK_for_Mesh_v2.0.1_src>nrfutil keys --gen-key private_key.txt
    Generated key at: private_key.txt
    
    C:\Nordic\nrf5_SDK_for_Mesh_v2.0.1_src>nrfutil keys --show-vk hex private_key.tx
    t
    Verification key Qx: d78ea2728b31c63b185402f4209803b478d0828b02a0f44da9f5d782b04
    7fe45
    Verification key Qy: b60bf4db2e572b4b6053c0c7e9371b309c93ee53c300906afc6c7f2d99c
    e11cd
    
    C:\Nordic\nrf5_SDK_for_Mesh_v2.0.1_src>nrfutil dfu genpkg --application bin/blin
    ky/blinky_nrf52832_xxAA_s132_6.0.0.hex --company-id 0x00000059 --application-id
    1 --application-version 2 --key-file private_key.txt --sd-req 0x009D --mesh dfu_
    test.zip
    Key file was given, setting DFU version to 0.8
    Zip created at dfu_test.zip
    
    C:\Nordic\nrf5_SDK_for_Mesh_v2.0.1_src>cd tools/dfu
    
    C:\Nordic\nrf5_SDK_for_Mesh_v2.0.1_src\tools\dfu>python device_page_generator.py
     -d nrf52832_xxAA -sd "s132_6.0.0"
    Wrote device page for nrf52832_xxAA with the s132_6.0.0 SoftDevice to bin/device
    _page_nrf52832_xxAA_s132_6.0.0.hex.
    
    C:\Nordic\nrf5_SDK_for_Mesh_v2.0.1_src\tools\dfu>cd ..
    
    C:\Nordic\nrf5_SDK_for_Mesh_v2.0.1_src\tools>cd ..
    
    C:\Nordic\nrf5_SDK_for_Mesh_v2.0.1_src>nrfjprog --eraseall
    Erasing user available code and UICR flash areas.
    Applying system reset.
    
    C:\Nordic\nrf5_SDK_for_Mesh_v2.0.1_src>nrfjprog --program bin/softdevice/s132_nr
    f52_6.0.0_softdevice.hex --chiperase
    Parsing hex file.
    Erasing user available code and UICR flash areas.
    Applying system reset.
    Checking that the area to write is not protected.
    Programming device.
    
    C:\Nordic\nrf5_SDK_for_Mesh_v2.0.1_src>nrfjprog --program bin/bootloader/armcc/m
    esh_bootloader_serial_armcc__nrf52832_xxAA.hex
    Parsing hex file.
    ERROR: The file specified could not be found.
    
    C:\Nordic\nrf5_SDK_for_Mesh_v2.0.1_src>nrfjprog --program bin/bootloader/armcc/m
    esh_bootloader_serial_armcc_nrf52832_xxAA.hex
    Parsing hex file.
    Reading flash area to program to guarantee it is erased.
    Checking that the area to write is not protected.
    Programming device.
    
    C:\Nordic\nrf5_SDK_for_Mesh_v2.0.1_src>nrfjprog --program examples\dfu\build\dfu
    _nrf52832_xxAA_s132_6.0.0_Debug\dfu_nrf52832_xxAA_s132_6.0.0.hex
    Parsing hex file.
    Reading flash area to program to guarantee it is erased.
    Checking that the area to write is not protected.
    Programming device.
    
    C:\Nordic\nrf5_SDK_for_Mesh_v2.0.1_src>nrfjprog --program tools/dfu/bin/device_p
    age_nrf52832_xxAA_s132_6.0.0.hex
    Parsing hex file.
    Reading flash area to program to guarantee it is erased.
    Checking that the area to write is not protected.
    Programming device.
    
    C:\Nordic\nrf5_SDK_for_Mesh_v2.0.1_src>nrfjprog --reset
    Applying system reset.
    Run.
    
    C:\Nordic\nrf5_SDK_for_Mesh_v2.0.1_src>nrfutil dfu serial -pkg dfu_test.zip -p C
    OM46 -b 115200 -fc --mesh
    Upgrading target on COM46 with DFU package C:\Nordic\nrf5_SDK_for_Mesh_v2.0.1_sr
    c\dfu_test.zip. Flow control is enabled.
      [------------------------------------]    0%
    
    Failed to upgrade target. Error is: Failed to establish connection
    
    Possible causes:
    - bootloader, SoftDevice or application on target does not match the requirement
    s in the DFU package.
    - baud rate or flow control is not the same as in the target bootloader.
    - target is not in DFU mode. If using the SDK examples, press Button 4 and RESET
     and release both to enter DFU mode.
    
    C:\Nordic\nrf5_SDK_for_Mesh_v2.0.1_src>nrfutil --verbose dfu serial -pkg dfu_tes
    t.zip -p COM46 -b 115200 -fc --mesh
    Upgrading target on COM46 with DFU package C:\Nordic\nrf5_SDK_for_Mesh_v2.0.1_sr
    c\dfu_test.zip. Flow control is enabled.
      [------------------------------------]    0%Flushing com-port...
    Opened com-port
    Starting DFU upgrade of type 4, SoftDevice size: 0, bootloader size: 0, applicat
    ion size: 1912
    Sending DFU start packet, afterwards we wait for the flash on target to be initi
    alized before continuing.
    PC -> target: 0502aabbccdd
    PC -> target: 0502aabbccdd
    PC -> target: 0502aabbccdd
    PC -> target: 0502aabbccdd
    PC -> target: 0502aabbccdd
    
    
    Failed to upgrade target. Error is: Failed to establish connection
    
    Possible causes:
    - bootloader, SoftDevice or application on target does not match the requirement
    s in the DFU package.
    - baud rate or flow control is not the same as in the target bootloader.
    - target is not in DFU mode. If using the SDK examples, press Button 4 and RESET
     and release both to enter DFU mode.
    Closing serial port...
    
    C:\Nordic\nrf5_SDK_for_Mesh_v2.0.1_src>nrfutil dfu serial -pkg dfu_test.zip -p C
    OM46 -b 57600 -fc --mesh
    Upgrading target on COM46 with DFU package C:\Nordic\nrf5_SDK_for_Mesh_v2.0.1_sr
    c\dfu_test.zip. Flow control is enabled.
      [------------------------------------]    0%
    
    Failed to upgrade target. Error is: Failed to establish connection
    
    Possible causes:
    - bootloader, SoftDevice or application on target does not match the requirement
    s in the DFU package.
    - baud rate or flow control is not the same as in the target bootloader.
    - target is not in DFU mode. If using the SDK examples, press Button 4 and RESET
     and release both to enter DFU mode.
    
    C:\Nordic\nrf5_SDK_for_Mesh_v2.0.1_src>nrfutil --verbose dfu serial -pkg dfu_tes
    t.zip -p COM46 -b 38400 -fc --mesh
    Upgrading target on COM46 with DFU package C:\Nordic\nrf5_SDK_for_Mesh_v2.0.1_sr
    c\dfu_test.zip. Flow control is enabled.
      [------------------------------------]    0%Flushing com-port...
    Opened com-port
    Starting DFU upgrade of type 4, SoftDevice size: 0, bootloader size: 0, applicat
    ion size: 1912
    Sending DFU start packet, afterwards we wait for the flash on target to be initi
    alized before continuing.
    PC -> target: 0502aabbccdd
    PC -> target: 0502aabbccdd
    PC -> target: 0502aabbccdd
    PC -> target: 0502aabbccdd
    PC -> target: 0502aabbccdd
    
    
    Failed to upgrade target. Error is: Failed to establish connection
    
    Possible causes:
    - bootloader, SoftDevice or application on target does not match the requirement
    s in the DFU package.
    - baud rate or flow control is not the same as in the target bootloader.
    - target is not in DFU mode. If using the SDK examples, press Button 4 and RESET
     and release both to enter DFU mode.
    Closing serial port...
    
    C:\Nordic\nrf5_SDK_for_Mesh_v2.0.1_src>nrfutil --verbose dfu serial -pkg dfu_tes
    t.zip -p COM46 -b 19200 -fc --mesh
    Upgrading target on COM46 with DFU package C:\Nordic\nrf5_SDK_for_Mesh_v2.0.1_sr
    c\dfu_test.zip. Flow control is enabled.
      [------------------------------------]    0%Flushing com-port...
    Opened com-port
    Starting DFU upgrade of type 4, SoftDevice size: 0, bootloader size: 0, applicat
    ion size: 1912
    Sending DFU start packet, afterwards we wait for the flash on target to be initi
    alized before continuing.
    PC -> target: 0502aabbccdd
    PC -> target: 0502aabbccdd
    PC -> target: 0502aabbccdd
    PC -> target: 0502aabbccdd
    PC -> target: 0502aabbccdd
    
    
    Failed to upgrade target. Error is: Failed to establish connection
    
    Possible causes:
    - bootloader, SoftDevice or application on target does not match the requirement
    s in the DFU package.
    - baud rate or flow control is not the same as in the target bootloader.
    - target is not in DFU mode. If using the SDK examples, press Button 4 and RESET
     and release both to enter DFU mode.
    Closing serial port...
    target -> PC: e8
    
    C:\Nordic\nrf5_SDK_for_Mesh_v2.0.1_src>nrfutil --verbose dfu serial -pkg dfu_tes
    t.zip -p COM46 -b 14400 -fc --mesh
    Upgrading target on COM46 with DFU package C:\Nordic\nrf5_SDK_for_Mesh_v2.0.1_sr
    c\dfu_test.zip. Flow control is enabled.
      [------------------------------------]    0%Flushing com-port...
    Opened com-port
    Starting DFU upgrade of type 4, SoftDevice size: 0, bootloader size: 0, applicat
    ion size: 1912
    Sending DFU start packet, afterwards we wait for the flash on target to be initi
    alized before continuing.
    PC -> target: 0502aabbccdd
    PC -> target: 0502aabbccdd
    PC -> target: 0502aabbccdd
    PC -> target: 0502aabbccdd
    PC -> target: 0502aabbccdd
    
    
    Failed to upgrade target. Error is: Failed to establish connection
    
    Possible causes:
    - bootloader, SoftDevice or application on target does not match the requirement
    s in the DFU package.
    - baud rate or flow control is not the same as in the target bootloader.
    - target is not in DFU mode. If using the SDK examples, press Button 4 and RESET
     and release both to enter DFU mode.
    Closing serial port...
    
    C:\Nordic\nrf5_SDK_for_Mesh_v2.0.1_src>nrfutil --verbose dfu serial -pkg dfu_tes
    t.zip -p COM46 -b 9600 -fc --mesh
    Upgrading target on COM46 with DFU package C:\Nordic\nrf5_SDK_for_Mesh_v2.0.1_sr
    c\dfu_test.zip. Flow control is enabled.
      [------------------------------------]    0%Flushing com-port...
    Opened com-port
    Starting DFU upgrade of type 4, SoftDevice size: 0, bootloader size: 0, applicat
    ion size: 1912
    Sending DFU start packet, afterwards we wait for the flash on target to be initi
    alized before continuing.
    PC -> target: 0502aabbccdd
    PC -> target: 0502aabbccdd
    PC -> target: 0502aabbccdd
    PC -> target: 0502aabbccdd
    PC -> target: 0502aabbccdd
    
    
    Failed to upgrade target. Error is: Failed to establish connection
    
    Possible causes:
    - bootloader, SoftDevice or application on target does not match the requirement
    s in the DFU package.
    - baud rate or flow control is not the same as in the target bootloader.
    - target is not in DFU mode. If using the SDK examples, press Button 4 and RESET
     and release both to enter DFU mode.
    Closing serial port...
    
    C:\Nordic\nrf5_SDK_for_Mesh_v2.0.1_src>
    
    
    
    
    C:\Nordic\nrf5_SDK_for_Mesh_v2.0.1_src>

    Step 1: private_key.txt 

    -----BEGIN EC PRIVATE KEY-----
    MHcCAQEEIHPeFxystPEoiZd7uOpCqfRxyO69QavgEeIowj7u+fp2oAoGCCqGSM49
    AwEHoUQDQgAE146icosxxjsYVAL0IJgDtHjQgosCoPRNqfXXgrBH/kW2C/TbLlcr
    S2BTwMfpNxswnJPuU8MAkGr8bH8tmc4RzQ==
    -----END EC PRIVATE KEY-----
    

    Step 2: bootloader_config_default.json 

    {
        "bootloader_config": {
            "bootloader_id": 1,
            "bootloader_version": 1,
            "company_id": 89,
            "application_id": 1,
            "application_version": 1,
    		"public_key": 
    	"d78ea2728b31c63b185402f4209803b478d0828b02a0f44da9f5d782b047fe45b60bf4db2e572b4b6053c0c7e9371b309c93ee53c300906afc6c7f2d99ce11cd"	
    	
        }
    }
    

    Step 3: dfu_test.zip dfu_test.zip

    Step 4: Modified  dfu_nrf52832_xxAA_s132_6.0.0.py from 5.0.0 to 6.0.0 

    # Copyright (c) 2010 - 2018, Nordic Semiconductor ASA
    # All rights reserved.
    #
    # Redistribution and use in source and binary forms, with or without
    # modification, are permitted provided that the following conditions are met:
    #
    # 1. Redistributions of source code must retain the above copyright notice, this
    #    list of conditions and the following disclaimer.
    #
    # 2. Redistributions in binary form must reproduce the above copyright
    #    notice, this list of conditions and the following disclaimer in the
    #    documentation and/or other materials provided with the distribution.
    #
    # 3. Neither the name of Nordic Semiconductor ASA nor the names of its
    #    contributors may be used to endorse or promote products derived from this
    #    software without specific prior written permission.
    #
    # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    # IMPLIED WARRANTIES OF MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE
    # ARE DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
    # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    # POSSIBILITY OF SUCH DAMAGE.
    
    import argparse
    import enum
    import struct
    import intelhex
    import sys
    import json
    import os
    
    PACKAGE_PARENT = '..'
    SCRIPT_DIR = os.path.dirname(os.path.realpath(os.path.join(os.getcwd(), os.path.expanduser(__file__))))
    sys.path.append(os.path.normpath(os.path.join(SCRIPT_DIR, PACKAGE_PARENT)))
    
    from deviceutil.deviceutil import \
        get_application_limits, \
        make_bootloader_for_platforms, \
        set_softdevices_for_platforms, \
        load_softdevies, \
        load_platforms
    
    WORD_SIZE = 4
    
    
    class BLInfoType(enum.IntEnum):
        INVALID = 0x00
        ECDSA_PUBLIC_KEY = 0x01
        VERSION = 0x02
        JOURNAL = 0x03
        FLAGS = 0x04
        SEGMENT_SD = 0x10
        SEGMENT_BL = 0x11
        SEGMENT_APP = 0x12
        LAST = 0x7FFF
    
    
    class DevicePageEntry(object):
        def __init__(self, bl_info_type, data):
            #print("Type: ", type(data).__name__)
            if not (isinstance(bl_info_type, BLInfoType) and
                    (isinstance(data, bytearray) or isinstance(data, str))):
                raise TypeError("Invalid type %r" % (type(data)))
    
            self.bl_info_type = bl_info_type
            if (isinstance(data, str)):
               data = bytearray.fromhex(data)
            self.data = self.pad(data)
    
        @property
        def word_count(self):
            return (len(self.data) + WORD_SIZE) // WORD_SIZE
    
        def pad(self, data):
            pad_byte_count = (WORD_SIZE - len(data) % WORD_SIZE) % WORD_SIZE
            if pad_byte_count > 0:
                data += bytearray([0xFF] * pad_byte_count)
            return data
    
        def serialize(self):
            return (bytearray(struct.pack('<HH', self.word_count, self.bl_info_type)
                              + self.data))
    
    
    class DevicePage(object):
        def __init__(self, platform, softdevice, bootloader_config):
            self.entries = []
            self.generate_entries(platform, softdevice, bootloader_config)
            self.platform = platform
            self.softdevice = softdevice
    
        def generate_entries(self, platform, softdevice, bootloader_config):
            public_key = bytearray.fromhex(bootloader_config["public_key"]) \
                         if "public_key" in bootloader_config else None
            if public_key:
                self.entries.append(
                    DevicePageEntry(BLInfoType.ECDSA_PUBLIC_KEY, public_key))
    
            app_limits = get_application_limits(platform, softdevice)
            app_segment = bytearray(struct.pack("<II",
                                                app_limits["flash_start"],
                                                app_limits["flash_size"]))
            sd_segment = bytearray(struct.pack("<II",
                                               softdevice["flash_start"],
                                               softdevice["flash_size"]))
            bl_segment = bytearray(struct.pack("<II",
                                               platform["bootloader"]["flash_start"],
                                               platform["bootloader"]["flash_size"]))
    
            self.entries.append(
                DevicePageEntry(BLInfoType.SEGMENT_APP, app_segment))
            self.entries.append(
                DevicePageEntry(BLInfoType.SEGMENT_SD, sd_segment))
            self.entries.append(
                DevicePageEntry(BLInfoType.SEGMENT_BL, bl_segment))
    
            version_data = bytearray(struct.pack("<HBBIHI",
                                                 int(softdevice["version"], 16),
                                                 bootloader_config["bootloader_id"],
                                                 bootloader_config["bootloader_version"],
                                                 bootloader_config["company_id"],
                                                 bootloader_config["application_id"],
                                                 bootloader_config["application_version"]))
    
            #print(version_data)
            self.entries.append(DevicePageEntry(BLInfoType.VERSION,
                                                version_data))
    
            self.entries.append(DevicePageEntry(BLInfoType.FLAGS,
                                                bytearray(struct.pack('I', 0xFFFFFFFF))))
    
        def write_hex(self, hexfile):
            # Info page metadata
            raw_data = bytearray(struct.pack("<BBBB", 4, 1, 8, 8))
            raw_data += bytearray().join(map(DevicePageEntry.serialize, self.entries))
            raw_data += bytearray(struct.pack("<HH", 0xFFFF, BLInfoType.LAST))
            hex_output = intelhex.IntelHex()
            hex_output.frombytes(raw_data,
                                 self.platform["flash_size"] - self.platform["page_size"])
            hex_output.tofile(hexfile, "hex")
    
    
    def write_specific_page(platforms, softdevices, args):
        platform = next((p for p in platforms if args.device == p["name"]), None)
        if not platform:
            print("Unknown device: \"%s\" in list %r" % (args.device, [p["name"] for p in platforms]))
            sys.exit(1)
    
        softdevice = next((s for s in softdevices if args.softdevice == s["name"]), None)
        if not softdevice:
            print("Unknown SoftDevice: \"%s\"" % (args.softdevice))
            sys.exit(1)
    
        if args.softdevice not in platform["softdevices"]:
            print("Unknown SoftDevice \"%s\" for platform \"%s\"" %
                  (args.softdevice, args.device))
            sys.exit(1)
    
        # Filter out the others...
        platforms = [p for p in platforms
                     if args.device.lower() in p["name"].lower()]
    
        make_bootloader_for_platforms(platforms)
        set_softdevices_for_platforms(platforms, softdevices)
    
        # Dict is updated by reference
        # platform = platforms[args.device]
        # softdevice = softdevices[args.softdevice]
    
        with open(args.bootloader_config, "r") as f:
            bootloader_config = json.load(f)["bootloader_config"]
        device_page = DevicePage(platform, softdevice, bootloader_config)
        if not args.output_file:
            args.output_file = "_".join(["device_page",
                                         self.platform["name"],
                                         self.softdevice["name"]]) + ".hex"
    
        device_page.write_hex(args.output_file)
    
    
    def write_all(platforms, softdevices, args):
        make_bootloader_for_platforms(platforms)
        set_softdevices_for_platforms(platforms, softdevices)
    
        with open(args.bootloader_config, "r") as f:
            bootloader_config = json.load(f)["bootloader_config"]
    
        for platform in platforms:
            for softdevice in platform["softdevices"]:
                device_page = DevicePage(platform, softdevice, bootloader_config)
                device_page.write_hex(args.output_file)
    
    
    def main():
        softdevices = load_softdevies("../configuration/softdevices.json")
        platforms = load_platforms("../configuration/platforms.json")
        sd_str = ''
        for sd in softdevices:
            sd_str += ''.join(sd["name"]) + "\n"
        plt_str = ''
        for plt in platforms:
            plt_str += ''.join(plt["name"]) + '\n'
    
        SOFTDEVICE = "s132_6.0.0"
        DEVICE = "nrf52832_xxAA"
        parser = argparse.ArgumentParser(description="Device Page Generator")
        parser.add_argument("-d", "--device", help="Select device: " + ''.join(plt_str),
                            default=DEVICE)
        parser.add_argument("-sd", "--softdevice", help="Select SoftDevice: "  + ''.join(sd_str),
                            default=SOFTDEVICE)
        parser.add_argument("-c", "--bootloader-config",
                            default="bootloader_config_default.json",
                            help="Bootloader configuration file")
        parser.add_argument("-o", "--output-file", help="Output hex file",
                            default="bin/device_page_%s_%s.hex" % (DEVICE, SOFTDEVICE))
        parser.add_argument("--all", default=False, action="store_true",
                            help=("Writes all known device page combinations to "
                                  + "\'bin/\'"))
        args = parser.parse_args()
    
        dirname = os.path.dirname(args.output_file)
        if not os.path.exists(dirname):
            os.mkdir(dirname)
    
        if args.all:
            write_all(platforms, softdevices, args)
            print("Wrote for device pages for all devices.")
        elif args.softdevice and args.device:
            write_specific_page(platforms, softdevices, args)
            print("Wrote device page for %s with the %s SoftDevice to %s." %
                  (args.device, args.softdevice, args.output_file))
    
    
    if __name__ == "__main__":
        main()
    

    to generate 

     device_page_nrf52832_xxAA_s132_6.0.0.hex device_page_nrf52832_xxAA_s132_6.0.0.hex

    Step 6: s132_nrf52_6.0.0_softdevice.hex s132_nrf52_6.0.0_softdevice.hex

    Step 7: s132_nrf52_6.0.0_softdevice.hex mesh_bootloader_serial_armcc_nrf52832_xxAA.hex

    Step 8: Program device using nrfjprog  to download dfu_nrf52832_xxAA_s132_6.0.0.hex dfu_nrf52832_xxAA_s132_6.0.0.hexdfu_nrf52832_xxAA_s132_6.0.0.map

     

    Step 9: Program device_page_nrf52832_xxAA_s132_6.0.0.hex device_page_nrf52832_xxAA_s132_6.0.0.hex 

    Step 10: We tried difference Baud Rates, press Button 4 and RESET and release both to enter DFU mode and use s132 and version 6.0.0, still got

    "Error is: Failed to establish connection"

     

    Please advise.  Thanks.

  • I got a few tips from a Mesh developer here at Nordic:

    "The original issue seems to be an error in the json file. Looks like there is an extra "}" at the end, maybe.

    Next, is the customer sure that the com port used is the correct com port?

    The SEGGER DFU build had a known issue with the flash_placement.xml file. I would advise the customer to use some of the pre-compiled binaries to test the DFU first."

    But I believe you have fixed the first issue, correct? I also believe you are using the correct com port & I believe you have used the pre-compiled binaries & not your own built hex files.

    I am not sure these tips will help all too much, but it's worth giving it a shot!

  • I believe it might be best if you add a new issue at this github link for nrfutil. They should be quite quick in debugging the issue for you. The mesh developer I have talked to is quite busy & does not have the time currently to debug this issue. If you have found a fix to this problem, could you please update this thread with the solution?

    Regarding not being able to upload pictures, we have done a test & found out that it is possible to attach images & files in this thread. Which browser are you using? We tested with Google Chrome & that worked very well.

  • Great! I will let the team know to take a look at the case ASAP.

  • I have tried the whole dfu quick start guide again & received this error while trying to do the DFU:

    Will talk to the nrfutil developer, ask him to try & get back to you soon.

  • Finally found the answer! Tried the dfu quick start guide using mesh v2.0.0. Used two nrf52832 dev kits & softdevice v5.0.0. I uploaded the blinky hex file located in the bin/blinky/blinky_nrf52832_xxAA_s132_5.0.0.hex. In step 8, I built the segger embedded studio project for the dfu example using the 5.0.0 softdevice (since only the emproject for the 6.0.0 softdevice is available in the mesh sdk). Here is the link to building the mesh stack using cmake (see the subsection "Generating SEGGER Embedded Studio project files).

    To make it simpler, I have uploaded the zipped mesh sdk that I used. 

    nrf5_SDK_for_Mesh_v2.0.0_src.zip

    The changes you will need to make relate to step 8 in the quick start guide. You will need to make changes to the generated SES project using the v5.0.0 softdevice in the flash_placement.xml file located in examples/dfu/.

     

    The fix for this is relatively simple: In examples/dfu/flash_placement.xml, change line 32 from

      <MemorySegment name="RAM" start="$(RAM_PH_START)" size="$(RAM_PH_SIZE)">

    to

      <MemorySegment name="RAM" start="$(RAM_PH_START)" size="$(RAM_SIZE)">

     

    After this, follow all of the steps & the dfu should complete without any issues. Hope that helps & sorry for the long time it took in getting this to work!!!

Reply
  • Finally found the answer! Tried the dfu quick start guide using mesh v2.0.0. Used two nrf52832 dev kits & softdevice v5.0.0. I uploaded the blinky hex file located in the bin/blinky/blinky_nrf52832_xxAA_s132_5.0.0.hex. In step 8, I built the segger embedded studio project for the dfu example using the 5.0.0 softdevice (since only the emproject for the 6.0.0 softdevice is available in the mesh sdk). Here is the link to building the mesh stack using cmake (see the subsection "Generating SEGGER Embedded Studio project files).

    To make it simpler, I have uploaded the zipped mesh sdk that I used. 

    nrf5_SDK_for_Mesh_v2.0.0_src.zip

    The changes you will need to make relate to step 8 in the quick start guide. You will need to make changes to the generated SES project using the v5.0.0 softdevice in the flash_placement.xml file located in examples/dfu/.

     

    The fix for this is relatively simple: In examples/dfu/flash_placement.xml, change line 32 from

      <MemorySegment name="RAM" start="$(RAM_PH_START)" size="$(RAM_PH_SIZE)">

    to

      <MemorySegment name="RAM" start="$(RAM_PH_START)" size="$(RAM_SIZE)">

     

    After this, follow all of the steps & the dfu should complete without any issues. Hope that helps & sorry for the long time it took in getting this to work!!!

Children
  • Thank you so much for the answer. I ran the DFU example again using the zipped mesh sdk nrf5_SDK_for_Mesh_v2.0.0_src.zip from your last reply and I named it nrf5_SDK_for_Mesh_v2.0.0_src_support.   After I made change to the line 32 of flash_placement.xml, the device was successfully program.  Please see line 333 of the attached cmd_script_06062018.txt. 

    C:\Nordic_SES\nrf5_SDK_for_Mesh_v2.0.0_src_support>nrfutil keys --gen-key private_key.txt
    Generated key at: private_key.txt
    
    C:\Nordic_SES\nrf5_SDK_for_Mesh_v2.0.0_src_support>nrfutil keys --show-vk hex private_key.txt
    Verification key Qx: 90e589a537b2f65497895ea3bf90209ccc5e424850e6ee0113bad5db80317275
    Verification key Qy: 6cedeca9499f8d6832724cdfe8f5bdf511e0f7eb737c6a8cec5bb959f5e81fdb
    
    C:\Nordic_SES\nrf5_SDK_for_Mesh_v2.0.0_src_support>nrfutil dfu genpkg --application bin/blinky/blinky_nrf52832_xxAA_s132_6.0.0.hex --company-id 0x00000059 --application-id 1 --application-version 3 --key-file private_key.txt --sd-req 0x009D --mesh dfu_test.zip
    Key file was given, setting DFU version to 0.8
    Zip created at dfu_test.zip
    
    C:\Nordic_SES\nrf5_SDK_for_Mesh_v2.0.0_src_support>cd tools\dfu
    
    C:\Nordic_SES\nrf5_SDK_for_Mesh_v2.0.0_src_support\tools\dfu>python device_page_generator.py -d nrf52832_xxAA -sd "s132_5.0.0"
    Wrote device page for nrf52832_xxAA with the s132_5.0.0 SoftDevice to bin/device_page_nrf52832_xxAA_s132_5.0.0.hex.
    
    C:\Nordic_SES\nrf5_SDK_for_Mesh_v2.0.0_src_support\tools\dfu>nrfjprog --eraseall
    Erasing user available code and UICR flash areas.
    Applying system reset.
    
    C:\Nordic_SES\nrf5_SDK_for_Mesh_v2.0.0_src_support\tools\dfu>cd ..
    
    C:\Nordic_SES\nrf5_SDK_for_Mesh_v2.0.0_src_support\tools>cd ..
    
    C:\Nordic_SES\nrf5_SDK_for_Mesh_v2.0.0_src_support>nrfjprog --eraseall
    Erasing user available code and UICR flash areas.
    Applying system reset.
    
    C:\Nordic_SES\nrf5_SDK_for_Mesh_v2.0.0_src_support>nrfjprog --program bin/softdevice/s132_5.0.0/s132_nrf52_5.0.0_softdevice.hex --chiperase
    Parsing hex file.
    ERROR: The file specified could not be found.
    
    C:\Nordic_SES\nrf5_SDK_for_Mesh_v2.0.0_src_support>nrfjprog --program bin/softdevice/s132_nrf52_5.0.0_softdevice.hex --chiperase
    Parsing hex file.
    Erasing user available code and UICR flash areas.
    Applying system reset.
    Checking that the area to write is not protected.
    Programming device.
    
    C:\Nordic_SES\nrf5_SDK_for_Mesh_v2.0.0_src_support>nrfjprog --program bin/bootloader/armcc/mesh_bootloader_serial_armcc_nrf52832_xxAA.hex
    Parsing hex file.
    Reading flash area to program to guarantee it is erased.
    Checking that the area to write is not protected.
    Programming device.
    
    C:\Nordic_SES\nrf5_SDK_for_Mesh_v2.0.0_src_support>nrfjprog --program examples\dfu\build\dfu_nrf52832_xxAA_s132_5.0.0_Release\dfu_nrf52832_xxAA_s132_5.0.0.hex
    Parsing hex file.
    Reading flash area to program to guarantee it is erased.
    Checking that the area to write is not protected.
    Programming device.
    
    C:\Nordic_SES\nrf5_SDK_for_Mesh_v2.0.0_src_support>nrfjprog --program tools/dfu/bin/device_page_nrf52832_xxAA_s132_5.0.0.hex
    Parsing hex file.
    Reading flash area to program to guarantee it is erased.
    Checking that the area to write is not protected.
    Programming device.
    
    C:\Nordic_SES\nrf5_SDK_for_Mesh_v2.0.0_src_support>nrfjprog --reset
    Applying system reset.
    Run.
    
    C:\Nordic_SES\nrf5_SDK_for_Mesh_v2.0.0_src_support>nrfutil --verbose dfu serial -pkg dfu_test.zip -p COM3 -b 115200 -fc --mesh
    Upgrading target on COM3 with DFU package C:\Nordic_SES\nrf5_SDK_for_Mesh_v2.0.0_src_support\dfu_test.zip. Flow control is enabled.
      [------------------------------------]    0%Flushing com-port...
    Opened com-port
    Starting DFU upgrade of type 4, SoftDevice size: 0, bootloader size: 0, application size: 1912
    Sending DFU start packet, afterwards we wait for the flash on target to be initialized before continuing.
    PC -> target: 0502aabbccdd
    target -> PC: 0582aabbccdd
    Got echo response
    Sending DFU init packet
    PC -> target: 1378fdff040f8bfabcc059000000010003000000
    target -> PC: 16a6045900000001000300000059000000010002000000
    target -> PC: 03847800
    PC -> target: 1378fdff040f8bfabcc059000000010003000000
    target -> PC: 03847800
    PC -> target: 1478fcff00008bfabcc0ffffffffde01000040000c
    target -> PC: 0da2010459000000010003000000
    target -> PC: 03847800
    Sending firmware file
      [------------------------------------]    1%  0d 00:11:49PC -> target: 1978fcff01008bfabcc000fd0020196602004166020043660200
    target -> PC: 03847800
    PC -> target: 1978fcff02008bfabcc045660200476602004966020000000000
    target -> PC: 03847800
      [------------------------------------]    2%  0d 00:11:38PC -> target: 1978fcff03008bfabcc00000000000000000000000004b660200
    target -> PC: 03847800
    PC -> target: 1978fcff04008bfabcc04d660200000000004f66020051660200
    target -> PC: 03847800
      [#-----------------------------------]    4%  0d 00:07:22PC -> target: 1978fcff05008bfabcc053660200536602005366020053660200
    target -> PC: 03847800
    PC -> target: 1978fcff06008bfabcc053660200536602005366020053660200
    target -> PC: 03847800
      [##----------------------------------]    5%  0d 00:05:42PC -> target: 1978fcff07008bfabcc053660200536602005366020053660200
    target -> PC: 03847800
    PC -> target: 1978fcff08008bfabcc053660200536602005366020053660200
    target -> PC: 03847800
      [##----------------------------------]    7%  0d 00:04:46PC -> target: 1978fcff09008bfabcc053660200536602005366020053660200
    target -> PC: 03847800
    PC -> target: 1978fcff0a008bfabcc053660200536602005366020053660200
    target -> PC: 03847800
      [###---------------------------------]    9%  0d 00:04:08PC -> target: 1978fcff0b008bfabcc053660200536602005366020053660200
    target -> PC: 03847800
    PC -> target: 1978fcff0c008bfabcc053660200536602000000000000000000
    target -> PC: 03847800
      [###---------------------------------]   10%  0d 00:03:41PC -> target: 1978fcff0d008bfabcc053660200536602005366020053660200
    target -> PC: 03847800
    PC -> target: 1978fcff0e008bfabcc053660200536602005366020000000000
    target -> PC: 03847800
      [####--------------------------------]   12%  0d 00:03:20PC -> target: 1978fcff0f008bfabcc000000000000000000000000000000000
    target -> PC: 03847800
    PC -> target: 1978fcff10008bfabcc000000000000000000000000000000000
    target -> PC: 03847800
      [#####-------------------------------]   13%  0d 00:02:02PC -> target: 1978fcff11008bfabcc000000000000000000000000000000000
    target -> PC: 03847800
    PC -> target: 1978fcff12008bfabcc000000000000000000000000000000000
    target -> PC: 03847800
      [#####-------------------------------]   15%  0d 00:01:47PC -> target: 1978fcff13008bfabcc000000000000000000000000000000000
    target -> PC: 03847800
    PC -> target: 1978fcff14008bfabcc000000000000000000000000000000000
    target -> PC: 03847800
      [######------------------------------]   17%  0d 00:01:37PC -> target: 1978fcff15008bfabcc000000000000000000000000000000000
    target -> PC: 03847800
    PC -> target: 1978fcff16008bfabcc000000000000000000000000000000000
    target -> PC: 03847800
      [######------------------------------]   18%  0d 00:01:29PC -> target: 1978fcff17008bfabcc000000000000000000000000000000000
    target -> PC: 03847800
    PC -> target: 1978fcff18008bfabcc000000000000000000000000000000000
    target -> PC: 03847800
      [#######-----------------------------]   20%  0d 00:01:23PC -> target: 1978fcff19008bfabcc000000000000000000000000000000000
    target -> PC: 03847800
    PC -> target: 1978fcff1a008bfabcc000000000000000000000000000000000
    target -> PC: 03847800
      [#######-----------------------------]   21%  0d 00:01:18PC -> target: 1978fcff1b008bfabcc000000000000000000000000000000000
    target -> PC: 03847800
    PC -> target: 1978fcff1c008bfabcc000000000000000000000000000000000
    target -> PC: 03847800
      [########----------------------------]   23%  0d 00:01:14PC -> target: 1978fcff1d008bfabcc000000000000000000000000000000000
    target -> PC: 03847800
    PC -> target: 1978fcff1e008bfabcc000000000000000000000000000000000
    target -> PC: 03847800
      [#########---------------------------]   25%  0d 00:01:11PC -> target: 1978fcff1f008bfabcc000000000000000000000000000000000
    target -> PC: 03847800
    PC -> target: 1978fcff20008bfabcc000000000000000000000000000000000
    target -> PC: 03847800
      [#########---------------------------]   26%  0d 00:01:07PC -> target: 1978fcff21008bfabcc010b5054c237833b9044b13b10448aff3
    target -> PC: 03847800
    PC -> target: 1978fcff22008bfabcc000800123237010bd3833002000000000
    target -> PC: 03847800
      [##########--------------------------]   28%  0d 00:01:05PC -> target: 1978fcff23008bfabcc0fc6602000c4b43b10c480d4910b5aff3
    target -> PC: 03847800
    PC -> target: 1978fcff24008bfabcc000800c48036823b910bd0a48036833b9
    target -> PC: 03847800
      [##########--------------------------]   30%  0d 00:01:02PC -> target: 1978fcff25008bfabcc07047094b002bf7d0bde810401847064b
    target -> PC: 03847800
    PC -> target: 1978fcff26008bfabcc0002bf5d0184700bf00000000fc660200
    target -> PC: 03847800
      [###########-------------------------]   31%  0d 00:00:59PC -> target: 1978fcff27008bfabcc03c3300203433002000000000154b002b
    target -> PC: 03847800
    PC -> target: 1978fcff28008bfabcc008bf134b9d46a3f5803a00218b460f46
    target -> PC: 03847800
      [###########-------------------------]   33%  0d 00:00:57PC -> target: 1978fcff29008bfabcc01348144a121a00f01dfa0f4b002b00d0
    target -> PC: 03847800
    PC -> target: 1978fcff2a008bfabcc098470e4b002b00d09847002000210400
    target -> PC: 03847800
      [############------------------------]   34%  0d 00:00:55PC -> target: 1978fcff2b008bfabcc00d000d48002802d00c48aff3008000f0
    target -> PC: 03847800
    PC -> target: 1978fcff2c008bfabcc0e5f92000290000f013f800f0cbf900bf
    target -> PC: 03847800
      [#############-----------------------]   36%  0d 00:00:53PC -> target: 1978fcff2d008bfabcc00000080000fd00200000000000000000
    target -> PC: 03847800
    PC -> target: 1978fcff2e008bfabcc038330020543300200000000000000000
    target -> PC: 03847800
      [#############-----------------------]   38%  0d 00:00:51PC -> target: 1978fcff2f008bfabcc070b5002301224ff0a041032002fa03f4
    target -> PC: 03847800
    PC -> target: 1978fcff30008bfabcc014f4f01f18bf03f5e07403f1010318bf
    target -> PC: 03847800
      [##############----------------------]   39%  0d 00:00:49PC -> target: 1978fcff31008bfabcc041f82400202bf1d14ff0a0434ff4f012
    target -> PC: 03847800
    PC -> target: 1978fcff32008bfabcc00a4dc3f808250022c3f80c251c4645f0
    target -> PC: 03847800
      [##############----------------------]   41%  0d 00:00:47PC -> target: 1978fcff33008bfabcc00105d4f8043583f40033c4f804356426
    target -> PC: 03847800
    PC -> target: 1978fcff34008bfabcc04ff47a40a847013efad1f2e7f0660200
    target -> PC: 03847800
      [###############---------------------]   42%  0d 00:00:46PC -> target: 1978fcff35008bfabcc0094b1b78062b0cd1084b1b681a0708d1
    target -> PC: 03847800
    PC -> target: 1978fcff36008bfabcc0074b186800f0f000a0f1300358425841
    target -> PC: 03847800
      [################--------------------]   44%  0d 00:00:44PC -> target: 1978fcff37008bfabcc070470020704700bfe00f00f0e40f00f0
    target -> PC: 03847800
    PC -> target: 1978fcff38008bfabcc0e80f00f00c4b1b78062b10d10b4b1b68
    target -> PC: 03847800
      [################--------------------]   46%  0d 00:00:43PC -> target: 1978fcff39008bfabcc01a070cd10a4b186800f0f003302b08d0
    target -> PC: 03847800
    PC -> target: 1978fcff3a008bfabcc000f0e000a0f140035842584170470020
    target -> PC: 03847800
      [#################-------------------]   47%  0d 00:00:41PC -> target: 1978fcff3b008bfabcc070470120704700bfe00f00f0e40f00f0
    target -> PC: 03847800
    PC -> target: 1978fcff3c008bfabcc0e80f00f008b5fff7ddff28b17f4b804a
    target -> PC: 03847800
      [#################-------------------]   49%  0d 00:00:39PC -> target: 1978fcff3d008bfabcc01b68c3f304231360fff7baff10b17d4b
    target -> PC: 03847800
    PC -> target: 1978fcff3e008bfabcc07d4a1a60fff7ceff28b17c4b7c4a1b68
    target -> PC: 03847800
      [##################------------------]   50%  0d 00:00:38PC -> target: 1978fcff3f008bfabcc0c3f342331360fff7abff20b1794ad368
    target -> PC: 03847800
    PC -> target: 1978fcff40008bfabcc023f08073d360fff7bdff40b14ff08043
    target -> PC: 03847800
      [##################------------------]   52%  0d 00:00:37PC -> target: 1978fcff41008bfabcc00022c3f80c21c3f81021c3f83825fff7
    target -> PC: 03847800
    PC -> target: 1978fcff42008bfabcc097ff10b1704b03221a60fff791ff40b1
    target -> PC: 03847800
      [###################-----------------]   54%  0d 00:00:35PC -> target: 1978fcff43008bfabcc06e4b05221a6001229a6700229a603f22
    target -> PC: 03847800
    PC -> target: 1978fcff44008bfabcc05a606b4b1b78062b09d16a4b1b681907
    target -> PC: 03847800
      [####################----------------]   55%  0d 00:00:34PC -> target: 1978fcff45008bfabcc005d1694b1b6803f0f003502b67d0fff7
    target -> PC: 03847800
    PC -> target: 1978fcff46008bfabcc091ff28b1654b664a1b6803f04f031360
    target -> PC: 03847800
      [####################----------------]   57%  0d 00:00:32PC -> target: 1978fcff47008bfabcc0fff788ff48b14ff08043d3f80024d207
    target -> PC: 03847800
    PC -> target: 1978fcff48008bfabcc044bf6ff00102c3f800245e4b1b68062b
    target -> PC: 03847800
      [#####################---------------]   59%  0d 00:00:31PC -> target: 1978fcff49008bfabcc004d15d4b1b68062b00f091805b4ad2f8
    target -> PC: 03847800
    PC -> target: 1978fcff4a008bfabcc0883043f47003c2f88830bff34f8fbff3
    target -> PC: 03847800
      [#####################---------------]   60%  0d 00:00:30PC -> target: 1978fcff4b008bfabcc06f8f4ff01023d3f80022002a03dbd3f8
    target -> PC: 03847800
    PC -> target: 1978fcff4c008bfabcc00432002b2fda524b0122c3f80425d3f8
    target -> PC: 03847800
      [######################--------------]   62%  0d 00:00:28PC -> target: 1978fcff4d008bfabcc00024002afbd04ff010221521c2f80012
    target -> PC: 03847800
    PC -> target: 1978fcff4e008bfabcc0d3f80024002afbd04ff010231522c3f8
    target -> PC: 03847800
      [#######################-------------]   63%  0d 00:00:27PC -> target: 1978fcff4f008bfabcc00422474b1a46d3f800140029fbd00021
    target -> PC: 03847800
    PC -> target: 1978fcff50008bfabcc0c3f80415d2f80034002bfbd0bff34f8f
    target -> PC: 03847800
      [#######################-------------]   65%  0d 00:00:26PC -> target: 1978fcff51008bfabcc03e49404bca6802f4e0621343cb60bff3
    target -> PC: 03847800
    PC -> target: 1978fcff52008bfabcc04f8f00bffde73c4b3c4a1a6008bd4ff0
    target -> PC: 03847800
      [########################------------]   67%  0d 00:00:25PC -> target: 1978fcff53008bfabcc080523b4bd2f80414c3f82015d2f80814
    target -> PC: 03847800
    PC -> target: 1978fcff54008bfabcc0c3f82415d2f80c14c3f82815d2f81014
    target -> PC: 03847800
      [########################------------]   68%  0d 00:00:23PC -> target: 1978fcff55008bfabcc0c3f82c15d2f81414c3f83015d2f81814
    target -> PC: 03847800
    PC -> target: 1978fcff56008bfabcc0c3f83415d2f81c14c3f84015d2f82014
    target -> PC: 03847800
      [#########################-----------]   70%  0d 00:00:22PC -> target: 1978fcff57008bfabcc0c3f84415d2f82414c3f84815d2f82814
    target -> PC: 03847800
    PC -> target: 1978fcff58008bfabcc0c3f84c15d2f82c14c3f85015d2f83014
    target -> PC: 03847800
      [#########################-----------]   71%  0d 00:00:21PC -> target: 1978fcff59008bfabcc0c3f85415d2f83414c3f86015d2f83814
    target -> PC: 03847800
    PC -> target: 1978fcff5a008bfabcc0c3f86415d2f83c14c3f86815d2f84014
    target -> PC: 03847800
      [##########################----------]   73%  0d 00:00:20PC -> target: 1978fcff5b008bfabcc0c3f86c15d2f84424c3f870254fe7194a
    target -> PC: 03847800
    PC -> target: 1978fcff5c008bfabcc0136843f48063136068e700bf24030010
    target -> PC: 03847800
      [###########################---------]   75%  0d 00:00:18PC -> target: 1978fcff5d008bfabcc04035014074c007400df0adba44020010
    target -> PC: 03847800
    PC -> target: 1978fcff5e008bfabcc03c050040f0ed00e0a005004010560040
    target -> PC: 03847800
      [###########################---------]   76%  0d 00:00:17PC -> target: 1978fcff5f008bfabcc0e00f00f0e40f00f0e80f00f058020010
    target -> PC: 03847800
    PC -> target: 1978fcff60008bfabcc0e40e0040300100103401001000ed00e0
    target -> PC: 03847800
      [############################--------]   78%  0d 00:00:16PC -> target: 1978fcff61008bfabcc000e001400400fa05c83200200090d003
    target -> PC: 03847800
    PC -> target: 1978fcff62008bfabcc000c000403c1700400649074a074b9b1a
    target -> PC: 03847800
      [############################--------]   80%  0d 00:00:15PC -> target: 1978fcff63008bfabcc003dd043bc858d050fbdcfff7c3fefff7
    target -> PC: 03847800
    PC -> target: 1978fcff64008bfabcc01dfe000008670200c832002038330020
    target -> PC: 03847800
      [#############################-------]   81%  0d 00:00:14PC -> target: 1978fcff65008bfabcc0fee7fee7fee7fee7fee7fee7fee7fee7
    target -> PC: 03847800
    PC -> target: 1978fcff66008bfabcc0fee7fee708b5074b044613b10021aff3
    target -> PC: 03847800
      [#############################-------]   83%  0d 00:00:12PC -> target: 1978fcff67008bfabcc00080054b1868836a03b19847204600f0
    target -> PC: 03847800
    PC -> target: 1978fcff68008bfabcc031f800bf00000000f866020070b50d4e
    target -> PC: 03847800
      [##############################------]   84%  0d 00:00:11PC -> target: 1978fcff69008bfabcc00d4ca41ba4100025a54209d10b4e0c4c
    target -> PC: 03847800
    PC -> target: 1978fcff6a008bfabcc000f022f8a41ba4100025a54205d170bd
    target -> PC: 03847800
      [###############################-----]   86%  0d 00:00:10PC -> target: 1978fcff6b008bfabcc056f8253098470135eee756f825309847
    target -> PC: 03847800
    PC -> target: 1978fcff6c008bfabcc00135f2e72c3300202c3300202c330020
    target -> PC: 03847800
      [###############################-----]   88%  0d 00:00:09PC -> target: 1978fcff6d008bfabcc03033002002440346934200d1704703f8
    target -> PC: 03847800
    PC -> target: 1978fcff6e008bfabcc0011bf9e7fee700bff8b500bff8bc08bc
    target -> PC: 03847800
      [################################----]   89%  0d 00:00:08PC -> target: 1978fcff6f008bfabcc09e467047f8b500bff8bc08bc9e467047
    target -> PC: 03847800
    PC -> target: 1978fcff70008bfabcc00338fdd870470000cc32002000000000
    target -> PC: 03847800
      [################################----]   91%  0d 00:00:07PC -> target: 1978fcff71008bfabcc06cfbff7f010000000090d00300000000
    target -> PC: 03847800
    PC -> target: 1978fcff72008bfabcc000000000000000000000000000000000
    target -> PC: 03847800
      [#################################---]   92%  0d 00:00:05PC -> target: 1978fcff73008bfabcc000000000000000000000000000000000
    target -> PC: 03847800
    PC -> target: 1978fcff74008bfabcc000000000000000000000000000000000
    target -> PC: 03847800
      [##################################--]   94%  0d 00:00:04PC -> target: 1978fcff75008bfabcc000000000000000000000000000000000
    target -> PC: 03847800
    PC -> target: 1978fcff76008bfabcc000000000000000000000000000000000
    target -> PC: 03847800
      [##################################--]   96%  0d 00:00:03PC -> target: 1978fcff77008bfabcc000000000000000000000000025620200
    target -> PC: 03847800
    PC -> target: 1178fcff78008bfabcc00162020000000000
    target -> PC: 03847800
      [###################################-]   97%  0d 00:00:02PC -> target: 1978fcff79008bfabcc0a26ab73dcf789254eb973d308b552d94
    target -> PC: 03847800
    PC -> target: 1978fcff7a008bfabcc0ffb1f286c7c3df9b740d930ccf2e1f56
    target -> PC: 03847800
      [###################################-]   99%  0d 00:00:01PC -> target: 1978fcff7b008bfabcc0328d5b5b7c2542a5fb955e83d2a6e393
    target -> PC: 03847800
    PC -> target: 1978fcff7c008bfabcc000f4f35aed15d7f7631d8d09d82d1121
    target -> PC: 03847800
      [####################################]  100%             DFU upgrade took 69.4719998837s
    Closing serial port...
    
    Closing serial port...
    Device programmed.
    
    C:\Nordic_SES\nrf5_SDK_for_Mesh_v2.0.0_src_support>cd tools/dfu
    
    C:\Nordic_SES\nrf5_SDK_for_Mesh_v2.0.0_src_support\tools\dfu>python bootloader_verify.py nrf52832_xxAA COM3
    Invalid serial number nrf52832_xxAA
    
    Usage:  bootloader_verify.py <Segger serial-number> <COM-port>
    
    C:\Nordic_SES\nrf5_SDK_for_Mesh_v2.0.0_src_support\tools\dfu>python bootloader_verify.py 682 COM3
    Device family:                  NRF52
    Reading UICR..                  ERROR: There is no debugger connected to the PC with the given serial number.
    Error calling nrfjprog with arguments -s 682 --memrd 0x10001014 --n 4 --w 32 --family NRF52.
    
    
    C:\Nordic_SES\nrf5_SDK_for_Mesh_v2.0.0_src_support\tools\dfu>python bootloader_verify.py NRF52 COM3
    Invalid serial number NRF52
    
    Usage:  bootloader_verify.py <Segger serial-number> <COM-port>
    
    C:\Nordic_SES\nrf5_SDK_for_Mesh_v2.0.0_src_support\tools\dfu>python bootloader_verify.py 682 COM3
    Device family:                  NRF52
    Reading UICR..                  ERROR: There is no debugger connected to the PC with the given serial number.
    Error calling nrfjprog with arguments -s 682 --memrd 0x10001014 --n 4 --w 32 --family NRF52.
    
    
    C:\Nordic_SES\nrf5_SDK_for_Mesh_v2.0.0_src_support\tools\dfu>
     

    Now I have a few more questions:

    1. According to the DFU quick start guide, please see attached screenshot, I supposed to see one user LED start blinking, but I do NOT see any user LED is on or blinking except the LD5 is always ON. 
    2. Verifying bootloader with the bootloader_verify.py script
      python bootloader_verify.py <serial number> COM3
      Please tell me what is <serial number>? I tried 682, NRF52 and nrf52832_xxAAnrf52832_xxAA, all did NOT work.  Please see from line 337 to line 356 of the attached cmd_script_06062018.txt above.

    3. I would like to know the reasons you used mesh v2.0.0 and 5.0.0 softdevice instead of mesh v2.0.1 and 6.0.0 softdevice because we are using mesh v2.0.1 and 6.0.0 softdevice for our development. What are the reasons we can NOT use 6.0.0 softdevice?

    4. You suggested to building the mesh stack using cmake (see the subsection "Generating SEGGER Embedded Studio project files). Do you mean below is the only command I need to run in the Command Prompt Window?  Do I need to put the two dots “..” at the end?

      "cmake -G Ninja -DGENERATE_SES_PROJECTS=ON -DPLATFORM=nrf52832_xxAA -DSOFTDEVICE=s132_6.0.0 .."

      I copied the nrf5_SDK_for_Mesh_v2.0.1_src folder to nrf5_SDK_for_Mesh_v2.0.1_src _CMake folder and ran CMake.  Please see attached cmd_script_cmake_06062018.txt, I tried with “..” and without “..”, both are NOT working.

      C:\Nordic_SES\nrf5_SDK_for_Mesh_v2.0.1_src_CMake>cmake -G Ninja -DGENERATE_SES_PROJECTS=ON -DPLATFORM=nrf52832_xxAA -DSOFTDEVICE=s132_6.0.0 ..
      CMake Error: The source directory "C:/Nordic_SES" does not appear to contain CMakeLists.txt.
      Specify --help for usage, or press the help button on the CMake GUI.
      
      C:\Nordic_SES\nrf5_SDK_for_Mesh_v2.0.1_src_CMake>cd examples
      
      C:\Nordic_SES\nrf5_SDK_for_Mesh_v2.0.1_src_CMake\examples>cmake -G Ninja -DGENERATE_SES_PROJECTS=ON -DPLATFORM=nrf52832_xxAA -DSOFTDEVICE=s132_6.0.0 ..
      -- Configuring CMake for nRF5 SDK for Bluetooth Mesh 2.0.1
      CMake Error: CMake was unable to find a build program corresponding to "Ninja".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
      -- Configuring incomplete, errors occurred!
      See also "C:/Nordic_SES/nrf5_SDK_for_Mesh_v2.0.1_src_CMake/examples/CMakeFiles/CMakeOutput.log".
      
      C:\Nordic_SES\nrf5_SDK_for_Mesh_v2.0.1_src_CMake\examples>cmake -G Ninja -DGENERATE_SES_PROJECTS=ON -DPLATFORM=nrf52832_xxAA -DSOFTDEVICE=s132_6.0.0
      CMake Error: The source "C:/Nordic_SES/nrf5_SDK_for_Mesh_v2.0.1_src_CMake/examples/CMakeLists.txt" does not match the source "C:/Nordic_SES/nrf5_SDK_for_Mesh_v2.0.1_src_CMake/CMakeLists.txt" used to generate cache.  Re-run cmake with a different source directory.
      
      C:\Nordic_SES\nrf5_SDK_for_Mesh_v2.0.1_src_CMake\examples>
    5. Please elaborate how to build mesh stack for mesh v2.0.1 and future mesh release. Actually, I need to make DFU to work with SDK 15.0.0 and Mesh v2.0.1 combined together, please advise on how to make it happens.

    Thanks.

  • 1) Update: I have tried to erase the chip, program the softdevice to the nrf52 & then program the blinky hex file that is updated during the dfu process & no LEDs are blinking. Update2: The precompiled blinky hex file works fine. First off, you must program the softdevice before programming the blinky hex file. Secondly, you must reset the board before it starts working (i.e. nrfjprog --reset). I believe the dfu worked fine, only that I was stupid enough not reset the board at the end of the DFU. I will double check this.

    2) The serial number is the number on top of the interface MCU on the dev kit. It's the number on the white sticker on the bottom which I believe always is 9 digits long.

    3) The only reason I used Mesh SDK v2.0.0 & SD v5 was because you used this setup in your original question. I would recommend you to use the latest SDK & Softdevice. Not sure exactly why I used the v5 softdevice.

    4) If you want to use mesh sdk v2.0.1 & softdevice 6, I do not believe you need to use the cmake command to generate a new SES project (I believe this was only the case because the ses dfu mesh bootloader project used softdevice 5 in mesh sdk v2.0.0, whereas we wanted it to use v6 softdevice.)

    To answer your question: Yes, I believe you need the .. at the end of the cmake command. The reason it is not working is because you need to make a build folder inside the root folder of the mesh sdk (i.e. where examples, mesh, models & all other folders are located). Then, inside the build folder, you can run the command you posted in your question. If you look at the cmake infocenter doc, you notice that there is a "build$" in front of the cmake command. This will then build an examples folder inside the build folder which does not contain the SES project files (I do not know why this happens). What you will notice though is that the examples inside the root mesh sdk folder do get updated.

    5) Here is more info about building the mesh stack. Normally, you can just open a Segger Embedded Studio project & compile to build the mesh stack. You can use cmake if you cannot find a SES project for your device or softdevice version. 

    Regarding the question about doing a dfu with sdk 15 & mesh sdk v2.0.1 combined, this should be doable. Would you only need to update the application? If you want to do a dfu of all of the nodes in the mesh network, you could use the dfu bootloader from the dfu example in the mesh sdk.

  • I used other blinky example file and Mesh SDK v2.0.1 & softdevice 6, device was programmed and LEDs were ON. Thanks for the advices. But when I verified the bootloader, it was stuck at “Resetting device ..”, please see attached cmd_script 

    C:\Users\advanchip>cd C:\Nordic_SES\nrf5_SDK_for_Mesh_v2.0.0_src_support\tools\dfu
    
    C:\Nordic_SES\nrf5_SDK_for_Mesh_v2.0.0_src_support\tools\dfu>python bootloader_verify.py 682630616 COM3
    Device family:                  NRF52
    Reading UICR..                  OK.
    Reading Device page..           OK.
    Resetting device..
    

    which is difference from DFU quick start guide, please see screen shoot. 

    For Cmake, I created a Build folder using mkdir and still got the same error.

    CMake Error: CMake was unable to find a build program corresponding to "Ninja".

    C:\Nordic_SES\nrf5_SDK_for_Mesh_v2.0.1_src_CMake>mkdir build
    
    C:\Nordic_SES\nrf5_SDK_for_Mesh_v2.0.1_src_CMake>cd build
    
    C:\Nordic_SES\nrf5_SDK_for_Mesh_v2.0.1_src_CMake\build>cmake -G Ninja ..
    -- Configuring CMake for nRF5 SDK for Bluetooth Mesh 2.0.1
    CMake Error: CMake was unable to find a build program corresponding to "Ninja".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
    -- Configuring incomplete, errors occurred!
    See also "C:/Nordic_SES/nrf5_SDK_for_Mesh_v2.0.1_src_CMake/build/CMakeFiles/CMakeOutput.log".
    
    C:\Nordic_SES\nrf5_SDK_for_Mesh_v2.0.1_src_CMake\build>
    

    Please advise.  Thanks.

  • Have you tried using the bootloader_verify.py file from mesh sdk v2.0.1? Do you still receive the same error then? Did you make sure to run an nrfjprog --reset running the python script? This may help.

    Regarding ninja, I believe you can run the command: pip install Ninja or pip install ninja

    As far as I am aware though, for your use case, you will not need to use cmake unless you want a different segger project for a different device.

  • I successfully built file using cmake.  Thank you very much.

    Yes, I used the bootloader_verify.py file from mesh sdk v2.0.1, please see attached directory folder of bootloader_verify.py 

    # Copyright (c) 2010 - 2018, Nordic Semiconductor ASA
    # All rights reserved.
    #
    # Redistribution and use in source and binary forms, with or without
    # modification, are permitted provided that the following conditions are met:
    #
    # 1. Redistributions of source code must retain the above copyright notice, this
    #    list of conditions and the following disclaimer.
    #
    # 2. Redistributions in binary form must reproduce the above copyright
    #    notice, this list of conditions and the following disclaimer in the
    #    documentation and/or other materials provided with the distribution.
    #
    # 3. Neither the name of Nordic Semiconductor ASA nor the names of its
    #    contributors may be used to endorse or promote products derived from this
    #    software without specific prior written permission.
    #
    # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    # IMPLIED WARRANTIES OF MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE
    # ARE DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
    # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    # POSSIBILITY OF SUCH DAMAGE.
    
    import binascii
    import subprocess
    import shlex
    import sys
    import serial
    import time
    
    def get_device_family(serial_number):
        family = {
            '480': 'NRF51',
            '680': 'NRF51',
            '681': 'NRF51',
            '682': 'NRF52',
        }
        if not serial_number[:3] in family:
            return 'NRF51' # fallback to 51.
        else:
            return family[serial_number[:3]]
    
    def read_serial_event(s):
        evt = ""
        while True:
            length = s.read()
            if ord(length) > 0:
                evt = s.read(ord(length))
                return evt
    
    
    
    def print_usage():
        print("")
        print("Usage:\tbootloader_verify.py <Segger serial-number> <COM-port>")
    
    def nrfjprog(args):
        process = subprocess.Popen(shlex.split("nrfjprog " + args), stdout=subprocess.PIPE)
        out, err = process.communicate()
        if process != None and process.returncode == 2:
            print("Couldn't find nrfjprog, exiting.")
            exit(2)
        if process == None or process.returncode != 0:
            print("Error calling nrfjprog with arguments " + args + ".")
            print(out)
            exit(2)
        return out
    
    def read_uicr(serial_number):
        family = get_device_family(serial_number)
        sys.stdout.write("Device family:\t\t\t" + family + "\n")
        sys.stdout.write("Reading UICR..\t\t\t")
        read = nrfjprog("-s " + serial_number + " --memrd 0x10001014 --n 4 --w 32 --family " + family).strip()
        bootloader_addr = str(read).split()[1]
        if bootloader_addr == "FFFFFFFF":
            print("ERROR: UICR NOT SET.")
            print("Checkpoints:")
            print("\tHave you flashed the bootloader with nrfjprog?")
            print("\tDid you flash the Softdevice BEFORE the bootloader?")
            exit(1)
    
        read = nrfjprog("-s " + serial_number + " --memrd 0x" + bootloader_addr + " --n 4 --w 32 --family " + family).strip()
        bootloader_vector_pointer = str(read).split()[1]
        if bootloader_vector_pointer < "20000000":
            print("ERROR: Bootloader vector pointer invalid.")
            print("Checkpoints:")
            print("\tHave you flashed the bootloader with nrfjprog?")
            print("\tDid you flash the Softdevice BEFORE the bootloader?")
            print("\tDid you erase the device before programming all the hex-files?")
            exit(1)
        if bootloader_vector_pointer == "FFFFFFFF":
            print("ERROR: Bootloader not present.")
            print("Checkpoints:")
            print("\tHave you flashed the bootloader with nrfjprog?")
            print("\tDid you flash the Softdevice BEFORE the bootloader?")
            print("\tDid you erase the device before programming all the hex-files?")
            exit(1)
        print("OK.")
        return bootloader_addr
    
    def read_device_page(serial_number):
        family = get_device_family(serial_number)
        # need to know the flash size to get the device page. Can read this from the FICR:
        ficr = str(nrfjprog("-s " + serial_number + " --memrd 0x10000010 --n 8 --w 32 --family " + family).strip()).split()[1:]
        code_page_size = int(ficr[0], 16)
        code_page_count = int(ficr[1], 16)
        device_page_location = code_page_size * (code_page_count - 1)
    
        sys.stdout.write("Reading Device page..\t\t")
        device_page = nrfjprog("-s " + serial_number + " --memrd " + hex(device_page_location) + " --n 4 --w 32 --family " + family).strip()
        device_page_header = str(device_page).split()[1]
        if device_page_header == "FFFFFFFF":
            print("ERROR: DEVICE PAGE NOT PRESENT.")
            print("Checkpoints:")
            print("\tHave you flashed the device page?")
            exit(1)
        if device_page_header != "08080104":
            print("ERROR: DEVICE PAGE INVALID.")
            print("Checkpoints:")
            print("\tDid you erase the device before programming all the hex-files?")
            exit(1)
        print("OK.")
        return device_page_header
    
    def reset_device(serial_number, port):
        sys.stdout.write("Resetting device..\t\t")
        try:
            s = serial.Serial(port, 115200, rtscts = True)
        except:
            print("ERROR: Could not open COM port " + port)
            exit(1)
        family = get_device_family(serial_number)
        nrfjprog("-s " + serial_number + " --reset --family " + family)
        time.sleep(0.2)
        response = read_serial_event(s)
    
        if b"\x81\x02\x00" == response[:3]:
            print("OK (In application)")
        elif not b"\x81\x01\x00" in response:
            print("ERROR: Invalid start sequence from bootloader: " + binascii.hexlify(response))
            print("Checkpoints:")
            print("\tHave you flashed the bootloader with nrfjprog?")
            print("\tDoes your bootloader have serial communication enabled?")
            s.close()
            exit(1)
        else:
            print("OK.")
        time.sleep(0.1)
        s.close()
    
    def echo(port):
        sys.stdout.write("Checking serial connection..\t")
        try:
            s = serial.Serial(port, 115200, rtscts = True)
        except:
            print("ERROR: Could not open COM port " + port)
            exit(1)
        s.write(b"\x03\x02\xaa\xbb")
        time.sleep(0.1)
        if not s.read(4).startswith(b"\x03\x82\xaa\xbb"):
            print("ERROR: Invalid response!")
            print("Checkpoints:")
            s.close()
            exit(1)
        s.close()
        print("OK.")
    
    if __name__ == "__main__":
        if len(sys.argv) < 2:
            print("Please provide the serial number of your device")
            print_usage()
            exit(1)
        if len(sys.argv) < 3:
            print("Please provide the COM port of your device")
            print_usage()
            exit(1)
        try:
            int(sys.argv[1])
        except:
            print("Invalid serial number " + sys.argv[1])
            print_usage()
            exit(1)
    
        bootloader_addr = read_uicr(sys.argv[1])
        read_device_page(sys.argv[1])
        reset_device(sys.argv[1], sys.argv[2])
        echo(sys.argv[2])
    
        print("\nBootloader verification OK.")
    

    When I ran python bootloader_verify.py 682630616 COM3, it was get stuck in

    Resetting device..

    and didn't go anywhere.  The Command Prompt won't accept any command, please see attached screen shoot.  

    Please advise.  Thanks.

Related