Skip to content

Commit 9635550

Browse files
committed
Moved EOT
1 parent 12bbd6e commit 9635550

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

source/bluetooth/MicroBitPartialFlashingService.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ void MicroBitPartialFlashingService::flashData(uint8_t *data)
219219
{
220220
uint8_t flashNotificationBuffer[] = {FLASH_DATA, 0xAA};
221221
ble.gattServer().notify(partialFlashCharacteristicHandle, (const uint8_t *)flashNotificationBuffer, sizeof(flashNotificationBuffer));
222-
packetCount = blockPacketCount + 4;
222+
packetCount = blockPacketCount + 3;
223223
blockNum = 0;
224224
return;
225225
}
@@ -297,15 +297,22 @@ void MicroBitPartialFlashingService::partialFlashingEvent(MicroBitEvent e)
297297
// Update flash control buffer to send next packet
298298
uint8_t flashNotificationBuffer[] = {FLASH_DATA, 0xFF};
299299
ble.gattServer().notify(partialFlashCharacteristicHandle, (const uint8_t *)flashNotificationBuffer, sizeof(flashNotificationBuffer));
300+
break;
301+
}
302+
case END_OF_TRANSMISSION:
303+
{
304+
// Write one more packet over the next block: if source embed magic was not previously erased, it will be now!
305+
uint32_t *blockPointer;
306+
uint32_t *flashPointer = (uint32_t *) ((baseAddress << 16) + offset + 0x40);
307+
308+
blockPointer = block;
309+
flash.flash_burn(flashPointer, blockPointer, 16);
300310

301311
// Once the final packet has been written remove the BLE mode flag and reset
302312
// the micro:bit
303-
if(e.value == END_OF_TRANSMISSION)
304-
{
305313
MicroBitStorage storage;
306314
storage.remove("BLEMode");
307315
microbit_reset();
308-
}
309316
break;
310317
}
311318
case MICROBIT_RESET:

0 commit comments

Comments
 (0)