microbit-foundation / microbit-android

micro:bit official Android application code. The application is free to download from https://play.google.com/store/apps/details?id=com.samsung.microbit
Apache License 2.0
13 stars 10 forks source link

Flashing to V2: fails to choose partial flashing when it could. Spontaneous DFU mode and full flashes #8

Open martinwork opened 3 years ago

martinwork commented 3 years ago

Samsung SM-T580, Android 8.1 micro:bit app 2.8.8 micro:bit V1.5, USB flashed from MakeCode.

Fresh start: reinstalled the app, removed pairings in Settings/Connections/Bluetooth, and USB flashed micro:bit from MakeCode.

Pairing went OK.

Created a simple "on start, show number" project in MakeCode, updating the number and project name for each Download.

A+B+RESET then tap Download,

Download 1: full flash Download 2: full flash Download 3: partial flash

After A+B+RESET, ready for Download 4, micro:bit jumped into DFU mode (+), as I was tapping Download, before answering "Do you want to flash.."

Download 4: full flash

After A+B+RESET, ready for Download 5, before tapping Download, micro:bit jumped into DFU mode and did a full flash

Download 5: partial flash Download 6: full flash

After A+B+RESET, ready for Download 7, before tapping Download, micro:bit jumped into DFU mode and did a full flash After A+B+RESET, ready for Download 7, as I tapped Download, micro:bit jumped into DFU mode, showing +

Download 7: full flash

microbit-mark commented 3 years ago

After A+B+RESET, ready for Download 7, as I tapped Download, micro:bit jumped into DFU mode, showing +

I've seen a few issues on support where the micro:bit is showing a `+' symbol so this seems to be a more common occurrence @microbit-sam

microbit-mark commented 3 years ago

More users reporting the + symbol Flashing via USB resolves this, so I have updated https://github.com/microbit-foundation/microbit-android/issues/8. Is the + symbol an error state? If so, could we indicate this to the user in the same way we do others eg with ( : XXX?

martinwork commented 3 years ago

https://github.com/microbit-foundation/v2-bootloader/blob/master/bootloader/main.c#L214

The "+" symbol indicates DFU mode, when the client hasn't connected yet or has disconnected. If the "+" still shows after a reset, it indicates that there is no valid application to boot. This state can be reached when a DFU fails part way through. From memory, micro:bit will be advertising with open security.

A Bluetooth symbol is shown when the client app connects, and an X when DFU fails. DFU error codes are sent to the client app. Showing a numeric code on the LEDs would make the bootloader bigger.

The actual problem in this issue, with regard to the "+" symbol, is that the Android app was spontaneously reconnecting before being asked and causing a reboot to DFU mode, followed by a full flash. I seem to remember, the original Android app used a BLE connection mode that stays connected and attempts to reconnect automatically. It seems likely that an automatic reconnection is incorrectly triggering a DFU event handler.