solokeys / solo1-cli

Solo 1 library and CLI in Python
https://pypi.org/project/solo-python
Apache License 2.0
183 stars 69 forks source link

Flashing in DFU mode very unstable #97

Open enrikb opened 3 years ago

enrikb commented 3 years ago

Finally found some time to play with my Solo Hacker.

After building the firmware successfully following the docs, I immediately bricked the device during the first flash try.

Fortunately, I could recover it two days later using one of those cheap ST-Link clones found on ebay...

Then I started playing with DFU mode again to find it very unstable. Every flash program cycle with the full firmware aborted (without error message!) between 10% and 80% of progress.

The root cause of my problems is the fact that USB error exceptions are not handled in the following line:

https://github.com/solokeys/solo-python/blob/76d7255b47cc5697578bce8aac2982daf3aaab04/solo/dfu.py#L141

The ctrl transfer for get status sometimes leads to a USB pipe error, which is not handled and silently aborts the program.

I could fix the issue by catching and ignoring all USB errors at this location, which is of course a very harsh work around.

I think the flash programming especially in DFU mode, where it is very easy to brick the device, should be more robust. At least clear error indications should be given in the case of failure.