Hi,
Currently, I know that OTA updates for the nRF5340 can be performed using Device Manager and the nRF Connect mobile application. However, if using a PC, is it possible to achieve the same functionality via the command line?
Thanks!!
Mike
Hi,
Currently, I know that OTA updates for the nRF5340 can be performed using Device Manager and the nRF Connect mobile application. However, if using a PC, is it possible to achieve the same functionality via the command line?
Thanks!!
Mike
Hi Mike,
Is it a Windows PC? There has not been BLE support for this OS in the past, but it looks like that may have changed with the introduction of the smpmgr tool added here: https://github.com/zephyrproject-rtos/zephyr/issues/70871
- https://github.com/intercreate/smpmgr/releases
Best regards,
Vidar
Hi Vidar,
Yes, that’s correct. I am trying to run this on a Windows PC.
I have already installed the smpmgr tool (version 0.17.0) on my Windows PC and attempted to perform FOTA on my nRF5340 device.
However, I encountered the following issue. The error logs are shown below.
C:\Users\user>smpmgr --ble E8:B8:C3:0E:CC:23 image upload C:\Users\user\Desktop\Mike\p1_v1.1.2_32M_12pF_dfu_application.zip
[08:48:32] ERROR Inspection of FW image failed - image_management:187 image_management.py:187
╭─────────────────── Traceback (most recent call last) ────────────────────╮
│ C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-pack │
│ ages\smpmgr\image_management.py:184 in upload │
│ │
│ 181 │ """Upload a FW image.""" │
│ 182 │ │
│ 183 │ try: │
│ ❱ 184 │ │ image_info = ImageInfo.load_file(str(file)) │
│ 185 │ │ logger.info(str(image_info)) │
│ 186 │ except Exception: │
│ 187 │ │ logger.exception("Inspection of FW image failed") │
│ │
│ C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-pack │
│ ages\smpclient\mcuboot.py:326 in load_file │
│ │
│ 323 │ │ │ │ raise MCUBootImageError(f"hex2bin() ret: {ret}") │
│ 324 │ │ │
│ 325 │ │ f.seek(0) # move to the start of the image │
│ ❱ 326 │ │ image_header = ImageHeader.load_from(f) │
│ 327 │ │ │
│ 328 │ │ tlv_offset = image_header.hdr_size + image_header.img_size │
│ 329 │
│ │
│ C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-pack │
│ ages\smpclient\mcuboot.py:223 in load_from │
│ │
│ 220 │ @staticmethod │
│ 221 │ def load_from(file: BytesIO | BufferedReader) -> 'ImageHeader' │
│ 222 │ │ """Load an `ImageHeader` from an open file.""" │
│ ❱ 223 │ │ return ImageHeader.loads(file.read(IMAGE_HEADER_STRUCT.siz │
│ 224 │ │
│ 225 │ @staticmethod │
│ 226 │ def load_file(path: str) -> 'ImageHeader': │
│ │
│ C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-pack │
│ ages\smpclient\mcuboot.py:205 in loads │
│ │
│ 202 │ │ │ flags, │
│ 203 │ │ │ *ver, │
│ 204 │ │ ) = IMAGE_HEADER_STRUCT.unpack(data) │
│ ❱ 205 │ │ return ImageHeader( │
│ 206 │ │ │ magic=magic, │
│ 207 │ │ │ load_addr=load_addr, │
│ 208 │ │ │ hdr_size=hdr_size, │
│ │
│ C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-pack │
│ ages\pydantic\_internal\_dataclasses.py:121 in __init__ │
│ │
│ 118 │ def __init__(__dataclass_self__: PydanticDataclass, *args: Any │
│ None: │
│ 119 │ │ __tracebackhide__ = True │
│ 120 │ │ s = __dataclass_self__ │
│ ❱ 121 │ │ s.__pydantic_validator__.validate_python(ArgsKwargs(args, │
│ self_instance=s) │
│ 122 │ │
│ 123 │ __init__.__qualname__ = f'{cls.__qualname__}.__init__' │
│ 124 │
│ │
│ C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-pack │
│ ages\smpclient\mcuboot.py:218 in __post_init__ │
│ │
│ 215 │ def __post_init__(self) -> None: │
│ 216 │ │ """Do initial validation of the header.""" │
│ 217 │ │ if self.magic != IMAGE_MAGIC: │
│ ❱ 218 │ │ │ raise MCUBootImageError(f"Magic is {hex(self.magic)}, │
│ {hex(IMAGE_MAGIC)}") │
│ 219 │ │
│ 220 │ @staticmethod │
│ 221 │ def load_from(file: BytesIO | BufferedReader) -> 'ImageHeader' │
╰──────────────────────────────────────────────────────────────────────────╯
MCUBootImageError: Magic is 0x4034b50, expected 0x96f3b83d
C:\Users\user>
I am not sure whether I am using the smpmgr tool correctly.
Thanks!!
Mike
Hi Mike,
The zip package format is only recognised by Nordic tools. For mcumgr you have to pass the binary file. application.signed.bin in this case.
Best regards,
Vidar
Hi Vidar,
I am currently using Ubuntu 24.04.3 to perform nRF5340 DFU testing with mcumgr, but I have encountered an issue at the very beginning.
$ mcumgr --conntype ble --name 'Test 3116' echo hello Error: Failed to connect to peer after 10s
It seems that I am unable to establish a connection with my device using mcumgr.
However, I can successfully discover the device using bluetoothctl, and DFU works normally when using nRF Device Manager.
Could you please provide some suggestions or guidance on what might be causing this issue?
Thanks!!
Mike
Hi Mike,
please try using the lower case address instead of using the the device name as filter and see if you get the same result.
https://github.com/apache/mynewt-mcumgr-cli/issues/7#issuecomment-494863151
Hi Vidar,
The version of mcumgr I am currently using (mcumgr 0.0.0-dev) does not seem to support the peer_id option. At the moment, I only have the options shown below available
$ mcumgr -h
mcumgr helps you manage remote devices
Usage:
mcumgr [flags]
mcumgr [command]
Available Commands:
config Read or write a config value on a device
conn Manage mcumgr connection profiles
crash Send a crash command to a device
datetime Manage datetime on a device
echo Send data to a device and display the echoed back data
fs Access files on a device
help Help about any command
image Manage images on a device
interactive Run mcumgr interactive mode (used for COAP only)
log Manage logs on a device
mpstat Read mempool statistics from a device
res Access a CoAP resource on a device
reset Perform a soft reset of a device
run Run test procedures on a device
shell Execute shell commands remotely
stat Read statistics from a device
taskstat Read task statistics from a device
version Display the mcumgr version number
Flags:
-c, --conn string connection profile to use
--connextra string Additional key-value pair to append to the connstring
--connstring string Connection key-value pairs to use instead of using the profile's connstring
--conntype string Connection type to use instead of using the profile's type
-i, --hci int HCI index for the controller on Linux machine
-h, --help help for mcumgr
-l, --loglevel string log level to use (default "info")
--name string name of target BLE device; overrides profile setting
--ompres string Use this CoAP resource instead of /omgr (default "/omgr")
-t, --timeout float timeout in seconds (partial seconds allowed) (default 10)
-r, --tries int total number of tries in case of timeout (default 1)
--write-rsp Send BLE acked write requests instead of unacked write commands
Use "mcumgr [command] --help" for more information about a command..Hi Mike,
The supported --constring arguments have always been the same as far as I can tell. Please post the command you used along with the error you got.
Hi Mike,
The supported --constring arguments have always been the same as far as I can tell. Please post the command you used along with the error you got.
Hi Vidar,
I am able to successfully perform DFU using mcumgr on a Linux PC.
Thank you for your valuable suggestions
Best regards,
Mike