keyboardio / Chrysalis

Graphical configurator for Kaleidoscope-powered keyboards
https://github.com/keyboardio/Chrysalis#chrysalis
GNU General Public License v3.0
496 stars 64 forks source link

api/flash/DFUUtilFlasher: rebootToApplicationMode should be retryable #1222

Closed algernon closed 1 year ago

algernon commented 2 years ago

Rebooting to Application mode is retryable, we should not be throwing an uncrecoverable exception if it fails, as that will abort the flashing process needlessly.

To make it retryable, this patch changes runDFUUtil to throw an exception with either a HARD_FAIL or a SOFT_FAIL message. Flashing will then stop in either case, because we do not retry flashing. But rebootToApplicationMode can catch the exception, and ignore it, because the main flashing loop will double check that the keyboard did end up in app mode.

Additionally, when doing flashing, lets not run dfu-util with --reset, because we'll do that reset explicitly in rebootToApplicationMode(). In turn, do not use --reset there, either, because --detach is enough, --reset just gives us an extra warning and doesn't do anything.

However, if we're starting from bootloader mode, with --reset removed from the flash call, we need to do an explicit rebootToApplicationMode() before returning. Lets do that, too.

Fixes #1221.

chrysalis-pr-bot commented 2 years ago

Build artifacts for this pull request are available!

:warning: These are not official builds!

The build artifacts are provided as-is, for testing and reviewing purposes. They contain code that has not been reviewed or audited by Chrysalis' developers. They are not endorsed by Keyboardio, they are not signed. Install and use them only if you know what you are doing.