DFU update with custom application

I am trying to do the dfu update in my custom flutter application like it does in the nrf connect application. My device is correctly being put in bootloader mode and the update is working fine in the nrf connect app. I have tried to use the nordic_dfu package from flutter to update the dfu but I kept getting the error message "[DFU] Buttonless DFU characteristic not found!" when doing start dfu, but the device was correctly in the dfu bootloader mode. After that I have also tried to use mcumgr_flutter package but I am getting the following error every time: "MissingPluginException(No implementation found for method getPlatformVersion on channel mcumgr_flutter/method_channel)" and basically the only solution that I have found for that issue is to clean and get the libraries again and restart the app which have also not worked. Is there another way that I could do the dfu update from my custom application? Or maybe a solution to one of my issues with any of the previous packages that I mentioned I used? Thanks in advance!

Parents
  • Hello!

    If your device is based on nRF5 SDK and you are using Legacy DFU (SDK v4.3-11) or Secure DFU (SDK v12-17.x) you should use `nordic_dfu` package. The `mcumgr_flutter` supports SMP protocol, which is used in nRF Connect SDK and Zephyr. The fact that you say, that your device is put to bootlaoder mode suggests that you're using nRF5 SDK, in some version.

    Could you please paste here logs from nRF Connect for Android gathered during successful DFU operation?

  • Good morning!
    I think that the SDK is in fact nRF5 SDK. I got the log of doing the DFU operation on nRF Connect for Android and I have attached the txt with it.

Reply
  • Good morning!
    I think that the SDK is in fact nRF5 SDK. I got the log of doing the DFU operation on nRF Connect for Android and I have attached the txt with it.

Children
  • I see in the logs, that the service found on the device is SMP Service:

    This means, that your device is based on nRF Connect SDK, not nRF5 SDK, and `mcumgr_flutter` is the right library, if you're using Flutter.

    There is no method "getPlatformVersion" in this library.

  • I realized that in the post I copied the wrong error, when doing the firmware update the error I get is the following: "Error during firmware update: MissingPluginException(No implementation found for method update on channel mcumgr_flutter/method_channel)". I will also add below the code of how I did the firmware update. Thanks in advance!

    try {
                      // Load firmware data
                      final byteData = await rootBundle.load('assets/dfu_application.zip');
                      final firmwareBytes = byteData.buffer.asUint8List();

                      final image = mcumgr.Image(
                        image: 0,
                        data: firmwareBytes,
                      );

                      // Initialize manager
                      final updateManagerFactory = mcumgr.FirmwareUpdateManagerFactory();
                      final updateManager = await updateManagerFactory.getUpdateManager(device.remoteId.str);

                      // Setup streams
                      final updateStream = updateManager.setup();

                      updateManager.updateStateStream?.listen((event) {
                        print("Update State: $event");
                        if (event == mcumgr.FirmwareUpgradeState.success) {
                          ScaffoldMessenger.of(context).showSnackBar(
                            SnackBar(content: Text('Firmware update completed successfully!')),
                          );
                        }
                      });

                      updateManager.progressStream.listen((event) {
                        print("Progress: ${event.bytesSent} / ${event.imageSize} bytes sent");
                      });

                      updateManager.logger.logMessageStream
                          .where((log) => log.level.rawValue > 1)
                          .listen((log) => print("Log: ${log.message}"));

                      // Configuration
                      const config = mcumgr.FirmwareUpgradeConfiguration(
                        eraseAppSettings: true,
                        firmwareUpgradeMode: FirmwareUpgradeMode.testAndConfirm,
                      );

                      // Perform update
                      await updateManager.update([image], configuration: config);
                    } catch (e) {
                      print("Error during firmware update: $e");
                      ScaffoldMessenger.of(context).showSnackBar(
                        SnackBar(content: Text('Firmware update failed: $e')),
                      );
                    }
  • Are you using version 0.4.2 of mcumgr_flutter library?

  • Yes, I am using 0.4.2

  • If you comment out the the block where you call the 'update' method, does it compile, or you get an error reg some other method?

    I'm not familiar with Flutter, tbh. This looks for me like some configuration issue with adding dependency to the library...