NordicSemiconductor / Flutter-nRF-Connect-Device-Manager

A Flutter plugin for McuMgr libraries for Android and iOS.
BSD 3-Clause "New" or "Revised" License
36 stars 17 forks source link

Detailed explanation of NO_ENTRY(5) error #36

Open olo95 opened 1 year ago

olo95 commented 1 year ago

I'm receiving this error while trying to upload .bin file, could you provide more detailed explanation of this error? Can it be connected to .bin file itself?

"No entry was found for the request. This commonly means that the command group has not been enabled on the device, although the exact meaning."

philips77 commented 1 year ago

So you're getting this error: https://github.com/NordicSemiconductor/Android-nRF-Connect-Device-Manager/blob/75dfbcad35da8dfde97f1c63dc89bbd694668731/mcumgr-core/src/main/java/io/runtime/mcumgr/McuMgrErrorCode.java#L45-L49

First of all, I need to fix the documentation.

Could you say what API are you using? Are you using this method: https://github.com/NordicSemiconductor/Flutter-nRF-Connect-Device-Manager/blob/ba4cf9f45bba1061be6ab8e10861718fdbc8b02f/lib/src/mcumgr_flutter.dart#L65-L67

Could you paste the logs that you're getting with the logger?

olo95 commented 1 year ago

Yes, I use this method, code below

          try {
            if (Platform.isAndroid) await bluetoothDevice.requestMtu(252);

            final FirmwareUpdateManagerFactory managerFactory = FirmwareUpdateManagerFactory();
            final FirmwareUpdateManager updateManager = await managerFactory.getUpdateManager(connectedDeviceRemoteId);
            final Stream<FirmwareUpgradeState> updateStream = updateManager.setup();
            final List<Tuple2<int, Uint8List>> firmwareScheme = [Tuple2(1, firmware)];
            const FirmwareUpgradeConfiguration configuration = FirmwareUpgradeConfiguration(
              estimatedSwapTime: Duration(seconds: 0),
              byteAlignment: ImageUploadAlignment.fourByte,
              eraseAppSettings: true,
              pipelineDepth: 1,
            );
            final FirmwareUpdateLogger logger = updateManager.logger;
            logger.logMessageStream.listen((event) {
              print(event.toString());
            });

            updateManager.updateStateStream?.listen((event) {
              print(event.toString());
            });

            updateManager.updateInProgressStream?.listen((event) {
              print(event.toString());
            });

            updateManager.update(firmwareScheme, configuration: configuration).catchError((error) {
              print(error.toString());
            });
          } catch (error) {
            _firmwareUpdateStreamController.add(State(progress: 0, isCompleted: false, isFailed: true));
          }
olo95 commented 1 year ago

Logs from Android Studio, NO_ENTRY(5) error is caught but is not visible in logs

D/McuManager(13059): Connected to FD:A7:42:5E:A3:65
D/BluetoothGatt(13059): onConfigureMTU() - Device=FD:A7:42:5E:A3:65 mtu=252 status=0
D/McuManager(13059): MTU changed to: 252
D/BluetoothGatt(13059): discoverServices() - device: FD:A7:42:5E:A3:65
D/BluetoothGatt(13059): onSearchComplete() = Device=FD:A7:42:5E:A3:65 Status=0
D/McuManager(13059): Services discovered
D/BluetoothGatt(13059): configureMTU() - device: FD:A7:42:5E:A3:65 mtu: 498
D/BluetoothGatt(13059): onConfigureMTU() - Device=FD:A7:42:5E:A3:65 mtu=498 status=0
D/McuManager(13059): MTU changed to: 498
D/BluetoothGatt(13059): setCharacteristicNotification() - uuid: da2e7828-fbce-4e01-ae9e-261174997c48 enable: true
D/McuManager(13059): Data written to descr. 00002902-0000-1000-8000-00805f9b34fb
D/McuManager(13059): Notifications enabled
D/McuManager(13059): Data written to da2e7828-fbce-4e01-ae9e-261174997c48
D/McuManager(13059): Notification received from da2e7828-fbce-4e01-ae9e-261174997c48, value: (0x) 01-00-00-19-00-00-FF-06-BF-68-62-75-66-5F-73-69-7A-65-19-09-AB-69-62-75-66-5F-63-6F-75-6E-74-04-FF
D/McuManager(13059): Wait for value changed complete
D/McuManager(13059): Received Header (Op: 1, Flags: 0, Len: 25, Group: 0, Seq: 255, Command: 6) CBOR {"buf_size":2475,"buf_count":4}
D/McuManager(13059): SMP reassembly supported with buffer size: 2475 bytes and count: 4
D/McuManager(13059): Sending (10 bytes) Header (Op: 0, Flags: 0, Len: 2, Group: 1, Seq: 0, Command: 0) CBOR {}
D/McuManager(13059): Data written to da2e7828-fbce-4e01-ae9e-261174997c48
D/McuManager(13059): Notification received from da2e7828-fbce-4e01-ae9e-261174997c48, value: (0x) 01-00-00-86-00-01-00-00-BF-66-69-6D-61-67-65-73-9F-BF-64-73-6C-6F-74-00-67-76-65-72-73-69-6F-6E-65-30-2E-30-2E-30-64-68-61-73-68-58-20-F2-EC-64-E1-2D-03-71-6B-80-38-01-F9-56-03-34-E7-C9-3D-13-B3-7F-FF-ED-08-D3-2E-6F-E4-1B-1D-45-84-68-62-6F-6F-74-61-62-6C-65-F5-67-70-65-6E-64-69-6E-67-F4-69-63-6F-6E-66-69-72-6D-65-64-F4-66-61-63-74-69-76-65-F5-69-70-65-72-6D-61-6E-65-6E-74-F4-FF-FF-6B-73-70-6C-69-74-53-74-61-74-75-73-00-FF
D/McuManager(13059): Received Header (Op: 1, Flags: 0, Len: 134, Group: 1, Seq: 0, Command: 0) CBOR {"images":[{"slot":0,"version":"0.0.0","hash":"8uxk4S0DcWuAOAH5VgM058k9E7N//+0I0y5v5BsdRYQ=","bootable":true,"pending":false,"confirmed":false,"active":true,"permanent":false}],"splitStatus":0}
D/McuManager(13059): State changed: VALIDATE -> UPLOAD
I/flutter (13059): Upload
I/flutter (13059): true
D/McuManager(13059): Upgrade failed
D/BluetoothGatt(13059): onConnectionUpdated() - Device=FD:A7:42:5E:A3:65 interval=9 latency=0 timeout=42 status=0
D/BluetoothGatt(13059): onConnectionUpdated() - Device=FD:A7:42:5E:A3:65 interval=9 latency=0 timeout=42 status=0
D/McuManager(13059): Connection parameters updated (interval: 11.25ms, latency: 0, timeout: 420ms)
olo95 commented 1 year ago

@philips77 You mentioned potential solution from Android package perspective here, I suppose it's the same case since Flutter-nRF-Connect-Device-Manager is plugin right?

philips77 commented 1 year ago

Yes, but here you're using the ImageManager under the hood, not the FsManager. It would be helpful to get logs with the failure.

philips77 commented 1 year ago

Also, which SDK are you using on the device side and in which version?

philips77 commented 1 year ago

From the code here: https://github.com/zephyrproject-rtos/zephyr/blob/zephyr-v3.3.0/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt.c I can assume that this error would happen if no TLV structure was found in the .bin file. Are you using the file created during compilation and signing of your project (https://docs.zephyrproject.org/latest/develop/west/sign.html#west-sign)

olo95 commented 1 year ago

Unfortunately that's all I got in console, can I make those logs more verbose?

olo95 commented 1 year ago

What do you mean by SDK on the device side? About the link that you sent: I passed this info to my hardware team, they'll look into it, thanks.

olo95 commented 1 year ago

About the error itself, this is all I got:

uuid: FD:A7:42:5E:A3:65 error: { localizedDescription: Mcu Mgr Error: NO_ENTRY (5) } updateStateChanges: { oldState: UPLOAD newState: UPLOAD }

jim-cat commented 10 months ago

I'm having the same issue uploading app_update.bin with an nrf52840 and SDK 2.4.2 using Device Manager for Android. Any recommendations?

jwtestuser882 commented 9 months ago

I was confused by the error as well. I had two versions of the firmware I wanted to switch between. When I deleted the secondary partition manually, then attempted to re-upload the firmware I'd just deleted, I'd get the NO_ENTRY (5) error. However, I could get it to go through by briefly starting an upload of the other firmware (the one currently in the primary partition), stopping, then retrying with the other version.

What I believe to be the actual cause of the issue in my case was identical version numbers. In prj.conf, CONFIG_MCUBOOT_IMAGE_VERSION was the same for both firmwares. Incrementing the value for one allowed me to upload the other version without issue.