From ce8f59e0c21db97b24f02333a84ad71ff33f7dd7 Mon Sep 17 00:00:00 2001 From: David Lechner Date: Thu, 12 Aug 2021 15:46:32 -0500 Subject: [PATCH] firmware: fix flashing on Android Hubs that don't use the minimum chunk size will fail on Android since it defaults to the smallest possible MTU. Issue: https://github.com/pybricks/support/issues/403 --- src/firmware/sagas.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/firmware/sagas.ts b/src/firmware/sagas.ts index b523bde0..cba8ca3d 100644 --- a/src/firmware/sagas.ts +++ b/src/firmware/sagas.ts @@ -55,6 +55,7 @@ import { import { RootState } from '../reducers'; import { defined, maybe } from '../utils'; import { fmod, sumComplement32 } from '../utils/math'; +import { isAndroid } from '../utils/os'; import { FailToFinishReasonType, FlashFirmwareActionType, @@ -376,8 +377,9 @@ function* flashFirmware(action: FlashFirmwareFlashAction): Generator { yield* disconnectAndCancel(); } - // 14 is "safe" size for all hubs - const maxDataSize = MaxProgramFlashSize.get(info.hubType) || 14; + // 14 is "safe" size for all hubs and Android + const maxDataSize = + (!isAndroid() && MaxProgramFlashSize.get(info.hubType)) || 14; for (let count = 1, offset = 0; ; count++) { const payload = firmware.slice(offset, offset + maxDataSize);