Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DFU Never Finishes #2

Closed
tpevahouse25 opened this issue Nov 24, 2021 · 26 comments · Fixed by #10
Closed

DFU Never Finishes #2

tpevahouse25 opened this issue Nov 24, 2021 · 26 comments · Fixed by #10
Labels
wontfix This will not be worked on

Comments

@tpevahouse25
Copy link

I am having an issue with the nordic dfu service finishing. I have been using the flutter_nordic_dfu package for a while now with great success but since Android 12 has been released I have had to move to nordic_dfu. The dfu starts and in my on progress listener, I am printing out the percent. It will print out from 1% to 100% but then does nothing. My progress indicator shows that it has large jumps from 0 to 30 to 50 to 80 then 100 then stays at 100. The time it takes from 0% to 100% is only about 10 seconds when normally it would take about a minute and 30 seconds. After a couple of minutes at 100% the app will crash.

I am testing on a Google Pixel 6 with Android 12 and a Samsung Tab A with Android 11 and getting the same results.
I can put this same code on an iPhone and it performs like it should and always has.

Can you give me an idea why this might be happening and how i could fix it.

Thank you.

@juliansteenbakker juliansteenbakker added the bug Something isn't working label Nov 29, 2021
@juliansteenbakker
Copy link
Owner

Thanks for reporting. I will try and see if it works later this week.

@tpevahouse25
Copy link
Author

Have you found out anything on this yet?

@juliansteenbakker
Copy link
Owner

No not yet, i do think this is an issue with the underlying nordic dfu android library. They are however actively improving this so i am waiting for a new version of it over at https://github.com/NordicSemiconductor/Android-DFU-Library

@tpevahouse25
Copy link
Author

Nordic has released an updated library and I was wondering if you have had the chance to work on this.

@tpevahouse25
Copy link
Author

@tpevahouse25
Copy link
Author

Thank you for working on this. I'll be looking forward for a package update on pub.dev.

@juliansteenbakker
Copy link
Owner

@tpevahouse25 I have released v3.3.0. I hope it solves your problem.

@tpevahouse25
Copy link
Author

Unfortunately, that update didn't fix my issue.
I am using a google pixel 6 with Android 12. My project is using Android sdk version 31. I have also made sure to add the new permissions to my manifest file. When I start the dfu service, it sits for about 3-5 seconds, then jumps to 47%. Then sits for another 3-5 seconds and jumps to 71%, 85%, 99%, then 100%. It will stay at 100% for about a minute then the dfu service will restart.
Before upgrading my project to android sdk 31, the percentage would smoothly increase until finished successfully with no restarts.
I have tried nordic's nrfConnect app to update and they have recently fixed this same issue with their app. It acted the same as described above until recently. Now it will successfully update a device without restarting the dfu service.
Is there anything you can suggest me trying on my side?

@tpevahouse25
Copy link
Author

Screen Shot 2022-01-17 at 10 31 33 AM

Here is the printout from when the DFU service finally failed after about 30 minutes of retrying.

@Montvydas
Copy link

Montvydas commented Apr 8, 2022

I got the same problem on my pixel 6. Although I noticed that recently even the nRF Connect app no longer works and outputs identical behaviour...

Edit: Tested the code on my old Oneplus 3T (Androdi 9) and I get the same problem, however the loading bar was progressing smoothly as opposed to jumping. I also tested various nrf Connect app versions on both of my phones and it seems that the last version that still worked for me on both phones was 4.24.3. New versions 4.25.X would behave slightly differently on each of my phones. Pixel 6 would have those same jumps, while OnePlus 3T would be progressing smoothly. But in the end, after reaching 100% neither of the phones would complete the OTA and would just get stuck. Given this, I am 100% sure that the problem is within the Nordic SDK, since their own app no longer works in identical way that I am observing on my app using their SDK... 🥲

@juliansteenbakker
Copy link
Owner

I have released V5.0.0 and checked with my Pixel 4a 5G with Android 13. I had no problems with DFU.

@Montvydas
Copy link

Sadly it's still not working for me. But I think it might have something to do with the bootloader that I am using, it's Adafruit bootloader, which I think is considered a legacy, since it's not a secure bootloader, thus maybe Nordic isn't serious about making the new SDK to work with it or simply they didn't test it...
@juliansteenbakker can you share with us what kind of bootloader and which version are you using for testing? When trying to upload the firmware I get this kind of log and when it reaches 100 percent it stops:

I/DfuBaseService(  919): DFU service created. Version: 2.0.2
I/DfuBaseService(  919): Starting DFU service in foreground
I/DfuBaseService(  919): Connecting to the device...
D/BluetoothGatt(  919): connect() - device: F3:BB:99:46:63:A2, auto: false
D/BluetoothGatt(  919): registerApp()
D/BluetoothGatt(  919): registerApp() - UUID=9e6cedb3-b274-4323-ae62-95086f7f95aa
D/BluetoothGatt(  919): onClientRegistered() - status=0 clientIf=10
D/BluetoothGatt(  919): onClientConnectionState() - status=0 clientIf=10 device=F3:BB:99:46:63:A2
I/DfuBaseService(  919): Connected to GATT server
D/BluetoothGatt(  919): discoverServices() - device: F3:BB:99:46:63:A2
I/DfuBaseService(  919): Attempting to start service discovery... succeed
D/BluetoothGatt(  919): onSearchComplete() = Device=F3:BB:99:46:63:A2 Status=0
I/DfuBaseService(  919): Services discovered
I/DfuImpl (  919): Reading DFU version number...
I/DfuImpl (  919): Version number read: 0.8 -> Bootloader from SDK 9.0 or newer. Signature supported
W/DfuImpl (  919): Legacy DFU bootloader found
I/DfuImpl (  919): Requesting MTU = 517
D/BluetoothGatt(  919): configureMTU() - device: F3:BB:99:46:63:A2 mtu: 517
D/BluetoothGatt(  919): onConfigureMTU() - Device=F3:BB:99:46:63:A2 mtu=247 status=0
I/DfuImpl (  919): MTU changed to: 247
I/DfuImpl (  919): Enabling notifications...
D/BluetoothGatt(  919): setCharacteristicNotification() - uuid: 00001531-1212-efde-1523-785feabcd123 enable: true
I/DfuImpl (  919): Sending Start DFU command (Op Code = 1, Upload Mode = 4)
I/DfuImpl (  919): Sending image size array to DFU Packet (0b, 0b, 116240b)
I/DfuImpl (  919): Sending the Initialize DFU Parameters START (Op Code = 2, Value = 0)
I/DfuImpl (  919): Sending 14 bytes of init packet
I/DfuImpl (  919): Sending init packet (Value = 52-00-FF-FF-FF-FF-FF-FF-01-00-B6-00-A5-99)
I/DfuImpl (  919): Sending the Initialize DFU Parameters COMPLETE (Op Code = 2, Value = 1)
I/DfuImpl (  919): Sending Receive Firmware Image request (Op Code = 3)
I/flutter (  919): deviceAddress: F3:BB:99:46:63:A2, percent: 0
I/DfuImpl (  919): Uploading firmware...
I/flutter (  919): deviceAddress: F3:BB:99:46:63:A2, percent: 1
I/flutter (  919): deviceAddress: F3:BB:99:46:63:A2, percent: 2
I/flutter (  919): deviceAddress: F3:BB:99:46:63:A2, percent: 3
...
I/flutter (  919): deviceAddress: F3:BB:99:46:63:A2, percent: 100

@juliansteenbakker
Copy link
Owner

@Montvydas I am using secure DFU which is working without problems. I think it would be better to open an issue on the android dfu github page https://github.com/NordicSemiconductor/Android-DFU-Library
It does not seem like a problem that's caused in the flutter part of the plugin.

@Montvydas
Copy link

Yep, I am also 100% it's got nothing to do with the Flutter part :)

@juliansteenbakker juliansteenbakker added wontfix This will not be worked on and removed bug Something isn't working labels May 6, 2022
@Satan-HuangZ
Copy link

Why ? fail to open file: No such file or directory

@Satan-HuangZ
Copy link

Why ? fail to open file: No such file or directory

I solved it, thanks

@tpevahouse25
Copy link
Author

@juliansteenbakker Would you be able to tell me:
Library version you're using?
Which nRF SDK are you using?

@juliansteenbakker
Copy link
Owner

juliansteenbakker commented May 10, 2022

Which nRF SDK are you using?

Version 2.0.2

https://github.com/juliansteenbakker/nordic_dfu/blob/master/android/build.gradle#L38

@onurcoskun145
Copy link

I/flutter (18078): PlatformException(File Error, File not found!, flutter_assets/assets/file.zip, null)

I am getting this error can anybody help ?

@juliansteenbakker
Copy link
Owner

Did you add the file to your assets folder? And did you also add it in your pubspec.yaml?

@onurcoskun145
Copy link

yes I did

assets:
-assets/dfu_application.zip

image

@juliansteenbakker
Copy link
Owner

I/flutter (18078): PlatformException(File Error, File not found!, flutter_assets/assets/file.zip, null)

Your path is not correct. You need to change flutter_assets/assets/file.zip to assets/dfu_application.zip

@onurcoskun145
Copy link

If you mean i need to change path in main.dart file i have already done that

image
i really dont know where is flutter_assets/assets/file.zip path coming from

@tpevahouse25
Copy link
Author

I have been talking to Nordic about the issue with updating legacy bootloaders on android. I was told to use the default mtu of 23. I noticed that when using the nordic_dfu package is switches the mtu to 247. Is there a way to manually request an mtu using this package.
Also they have updated the android dfu library to version 2.1

@juliansteenbakker
Copy link
Owner

I have released v5.1.0 of this package which updates both the android side aswell as the iOS side to the latest versions of the DFU library. The MTU is not something that can be controlled right now, so that would be a good addition imo.

@juliansteenbakker
Copy link
Owner

I've updated this package to version 5.1.1. Please check if the issue still persist and otherwise feel free to comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants