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:
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:
Sorry, please forget above error. Today, we started from step 1 of the DFU quick start guide
Attached is CMD commands file
C:\Nordic\nRF5_SDK_15.0.0_a53641a\mesh_sdk\tools\dfu>cd .. C:\Nordic\nRF5_SDK_15.0.0_a53641a\mesh_sdk\tools>cd ... C:\Nordic\nRF5_SDK_15.0.0_a53641a\mesh_sdk\tools>cd .. C:\Nordic\nRF5_SDK_15.0.0_a53641a\mesh_sdk>nrfutil keys --show-vk hex private_k y.txt Verification key Qx: 3945432e6a79ffab61a713a4b363e46d2c8d0ab1ee06693269728ecffa 11155 Verification key Qy: dc64ce8b83c13fc6bb6d50923cf3b28b23f30d8faa0efa2f097a5c8a39 597d5 C:\Nordic\nRF5_SDK_15.0.0_a53641a\mesh_sdk> C:\Nordic\nRF5_SDK_15.0.0_a53641a\mesh_sdk>nrfutil dfu genpkg --application bin blinky/blinky_nrf52832_xxAA_s132_5.0.0.hex --company-id 0x00000089 --applicatio -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_15.0.0_a53641a\mesh_sdk>cd tools/dfu C:\Nordic\nRF5_SDK_15.0.0_a53641a\mesh_sdk\tools\dfu>python device_page_generat r.py -d nrf52832_xxAA -sd "s132_5.0.0" Traceback (most recent call last): File "device_page_generator.py", line 241, in <module> main() File "device_page_generator.py", line 235, in main write_specific_page(platforms, softdevices, args) File "device_page_generator.py", line 178, in write_specific_page device_page = DevicePage(platform, softdevice, bootloader_config) File "device_page_generator.py", line 94, in __init__ self.generate_entries(platform, softdevice, bootloader_config) File "device_page_generator.py", line 103, in generate_entries DevicePageEntry(BLInfoType.ECDSA_PUBLIC_KEY, public_key)) File "device_page_generator.py", line 69, in __init__ raise TypeError TypeError
Now we got TypeError. I also attached bootloader_config_default.json and the file tree of SDK 15 and Mesh. Please advise. Thanks.
{ "bootloader_config": { "bootloader_id": 1, "bootloader_version": 1, "company_id": 89, "application_id": 1, "application_version": 1, "public_key": "d78ea2728b31c63b185402f4209803b478d0828b02a0f44da9f5d782b047fe45b60bf4db2e572b4b6053c0c7e9371b309c93ee53c300906afc6c7f2d99ce11cd" } }
Sorry for the delayed response. From your command line input in the comment, it seems that you did not generate the private_key.txt file. My guess is that you did do this step, as generating the public key did not lead to an error. Just want to make sure that it is not a small error like this that has lead to this issue.
Hi Bjorn,
We started everything from scratch following the DFU quick start guide from step 1 to step 4, then we got stuck
Please see my attached cmd scripts files
Microsoft Windows [Version 6.1.7601] Copyright (c) 2009 Microsoft Corporation. All rights reserved. C:\Users\StanYue>cd C:\Nordic\nRF5_SDK_15.0.0_a53641a\mesh_sdk C:\Nordic\nRF5_SDK_15.0.0_a53641a\mesh_sdk>nrfutil keys --gen-key private_key.tx t Generated key at: private_key.txt C:\Nordic\nRF5_SDK_15.0.0_a53641a\mesh_sdk>nrfutil keys --show-vk hex private_ke y.txt Verification key Qx: 54b8abe3c8aabb2063e3f15d137100e724d7dda797fb9edfa8c86989a09 b4812 Verification key Qy: bbcf2140106d7bddf9da908c3ba2cadff92b42991b06c0b3d3a60ae4c40 eedd3 C:\Nordic\nRF5_SDK_15.0.0_a53641a\mesh_sdk>n C:\Nordic\nRF5_SDK_15.0.0_a53641a\mesh_sdk>keys --show-vk hex private_key.txt The syntax of the command is incorrect. C:\Nordic\nRF5_SDK_15.0.0_a53641a\mesh_sdk>keys --show-vk hex private_key.txt The syntax of the command is incorrect. C:\Nordic\nRF5_SDK_15.0.0_a53641a\mesh_sdk>nrfutil keys --show-vk hex private_ke y.txt Verification key Qx: 54b8abe3c8aabb2063e3f15d137100e724d7dda797fb9edfa8c86989a09 b4812 Verification key Qy: bbcf2140106d7bddf9da908c3ba2cadff92b42991b06c0b3d3a60ae4c40 eedd3 C:\Nordic\nRF5_SDK_15.0.0_a53641a\mesh_sdk>nrfutil dfu genpkg --application bin/ blinky/blinky_nrf52832_xxAA_s132_5.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_15.0.0_a53641a\mesh_sdk>cd tools/dfu C:\Nordic\nRF5_SDK_15.0.0_a53641a\mesh_sdk\tools\dfu>python device_page_generato r.py -d nrf52832_xxAA -sd "s132_5.0.0" Traceback (most recent call last): File "device_page_generator.py", line 241, in <module> main() File "device_page_generator.py", line 235, in main write_specific_page(platforms, softdevices, args) File "device_page_generator.py", line 178, in write_specific_page device_page = DevicePage(platform, softdevice, bootloader_config) File "device_page_generator.py", line 94, in __init__ self.generate_entries(platform, softdevice, bootloader_config) File "device_page_generator.py", line 103, in generate_entries DevicePageEntry(BLInfoType.ECDSA_PUBLIC_KEY, public_key)) File "device_page_generator.py", line 69, in __init__ raise TypeError TypeError C:\Nordic\nRF5_SDK_15.0.0_a53641a\mesh_sdk\tools\dfu>
This is the private_key.txt, we used this private_key.txt file for "nrfutil keys --show-vk hex private_key.txt" .
-----BEGIN EC PRIVATE KEY----- MHcCAQEEIHPeFxystPEoiZd7uOpCqfRxyO69QavgEeIowj7u+fp2oAoGCCqGSM49 AwEHoUQDQgAE146icosxxjsYVAL0IJgDtHjQgosCoPRNqfXXgrBH/kW2C/TbLlcr S2BTwMfpNxswnJPuU8MAkGr8bH8tmc4RzQ== -----END EC PRIVATE KEY-----
Then we added both output HEX strings "Verification key Qx and Qy" to bootloader_config_default.json
{ "bootloader_config": { "bootloader_id": 1, "bootloader_version": 1, "company_id": 89, "application_id": 1, "application_version": 1, "public_key": "d78ea2728b31c63b185402f4209803b478d0828b02a0f44da9f5d782b047fe45b60bf4db2e572b4b6053c0c7e9371b309c93ee53c300906afc6c7f2d99ce11cd" } }
We got the exact same "TypeError" as before. Please advise. Thanks.
I have tested the DFU quick start guide using both Mesh SDK v2.0.0 & v2.0.1 & I receive the exact same TypeError as you do. I will mention this to the developers of nrfutil & see if they have any suggestions.
Update:
There was an issue with the python device_page_generator.py file. Should work if you download this file & copy it into the tools/dfu folder. I do not get any errors with step 4, but have not had time yet to test the rest. Could you please let me know if everything else works fine? If it does not, I will test a bit later.
# 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_5.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()
Thanks Bjorn. Yes, Step 4 works now. We continued following the DFU quick start guide, but since Step 8 stated that "Building the mesh stack. If you have built them with Segger Embedded Studio, you can flash the DFU example directly from the IDE, as described in the build-guide, and move on to step 9."
I think we got step 8 done, but not sure how to verify it so we just skipped step 8 and move to step 9. Now we are up to Step 10. Please see the attached CMD Scripts that
Failed to upgrade target. Error is: Serial port could not be opened on COM48. Re
ason: could not open port u'COM48': WindowsError(2, 'The system cannot find the
file specified.')
C:\Nordic\nRF5_SDK_15.0.0_a53641a\mesh_sdk\examples>cd .. C:\Nordic\nRF5_SDK_15.0.0_a53641a\mesh_sdk>nrfjprog --program tools/dfu/bin/devi ce_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. Programing device. C:\Nordic\nRF5_SDK_15.0.0_a53641a\mesh_sdk>nrfjprog --reset Applying system reset. Run. C:\Nordic\nRF5_SDK_15.0.0_a53641a\mesh_sdk>nrfjprog --program bin/softdevice/s13 2_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. Programing device. C:\Nordic\nRF5_SDK_15.0.0_a53641a\mesh_sdk>nrfjprog --program bin/bootloader/arm cc/mesh_bootloader_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. Programing device. C:\Nordic\nRF5_SDK_15.0.0_a53641a\mesh_sdk>nrfjprog --program tools/dfu/bin/devi ce_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. Programing device. C:\Nordic\nRF5_SDK_15.0.0_a53641a\mesh_sdk>--reset '--reset' is not recognized as an internal or external command, operable program or batch file. C:\Nordic\nRF5_SDK_15.0.0_a53641a\mesh_sdk>nrfjprog --reset Applying system reset. Run. C:\Nordic\nRF5_SDK_15.0.0_a53641a\mesh_sdk>nrfutil dfu serial -pkg dfu_test.zip -p <COM port> -b 115200 -fc --mesh The system cannot find the file specified. C:\Nordic\nRF5_SDK_15.0.0_a53641a\mesh_sdk>nrfutil dfu serial -pkg dfu_test.zip -p COM48 -b 115200 -fc --mesh Upgrading target on COM48 with DFU package C:\Nordic\nRF5_SDK_15.0.0_a53641a\mes h_sdk\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_15.0.0_a53641a\mesh_sdk>nrfutil dfu serial -pkg dfu_test.zip -p COM48 -b 115200 -fc --mesh Upgrading target on COM48 with DFU package C:\Nordic\nRF5_SDK_15.0.0_a53641a\mes h_sdk\dfu_test.zip. Flow control is enabled. [------------------------------------] 0% Failed to upgrade target. Error is: Serial port could not be opened on COM48. Re ason: could not open port u'COM48': WindowsError(2, 'The system cannot find the file specified.') 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_15.0.0_a53641a\mesh_sdk>nrfutil dfu serial -pkg dfu_test.zip -p COM48 -b 115200 -fc --mesh Upgrading target on COM48 with DFU package C:\Nordic\nRF5_SDK_15.0.0_a53641a\mes h_sdk\dfu_test.zip. Flow control is enabled. [------------------------------------] 0% Failed to upgrade target. Error is: Serial port could not be opened on COM48. Re ason: could not open port u'COM48': WindowsError(2, 'The system cannot find the file specified.') 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_15.0.0_a53641a\mesh_sdk>
I also attached the directory folder to show you where the dfu_test.zip located.
Please advise.