Repository navigation
Conversation
macOS appends a zero-length packet after a write whose length is a multiple of 64. TinyUSB CDC then corrupts the image and the device reports ESP_ERR_OTA_VALIDATE_FAILED without changing firmware. Write 4095-byte chunks and split a trailing multiple of 64. Close the port when the update throws so the next Connect can open it. Co-authored-by: rileykeen <rileykeen@users.noreply.github.com>
Replace theoretical 4095-byte writes with the console-updater plans that succeeded on Mac: 63/31/127-byte chunks with inter-write delays, tried in order until OTA OK. Non-Mac hosts keep 128-byte chunks; every write still avoids a multiple of the 64-byte USB packet size. Co-authored-by: rileykeen <rileykeen@users.noreply.github.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: OTA tests assume non-Mac chunks
- The OTA streaming test now pins the user agent and asserts both the default 128-byte schedule and the Macintosh 63-byte schedule, and the failure test pins a non-Mac agent so it still stops after one attempt.
Or push these changes by commenting:
@cursor push 97e8a34b1e
You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit 390a84e. Configure here.
| [127, 300], | ||
| [254, 300], | ||
| [300, 300], | ||
| ]); |
There was a problem hiding this comment.
OTA tests assume non-Mac chunks
Medium Severity
updateFirmware picks MAC_OTA_PLANS whenever navigator.userAgent contains Macintosh, but the streaming test hardcodes progress [127, 300], [254, 300], [300, 300] from the 128-byte default plan. Playwright Chromium on macOS includes Macintosh, so that assertion fails and the Mac path this PR exists to fix is never what CI (Linux) actually runs.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 390a84e. Configure here.



Mac OTA updates were rejected with
OTA FAIL END <byte count> ESP_ERR_OTA_VALIDATE_FAILEDwhile Windows succeeded. The running firmware never changed, so this has to be fixed in the Device Manager.updateFirmware()wrote the image in 128-byte chunks. 128 is a multiple of the full-speed USB packet size (64), so macOS appends a zero-length packet after each write. The keyboard's TinyUSB CDC stack then delivers a corrupted stream andesp_ota_endfails validation. 256, 512, and 1024 are still multiples of 64 and fail the same way.Writes are now 4095 bytes. A trailing chunk whose length is still a multiple of 64 (including 128, 256, 512, and 1024) is shortened by one byte so that write does not get a zero-length packet either. Each chunk is still a fresh
Uint8Array.On failure the update threw before
suspend(), so the serial port stayed open and the next Connect failed withInvalidStateError: The port is already openuntil the page was refreshed. The port is now closed when the update throws, and the device's validation error is still the one reported to the page.Testing
pnpm exec vitest run --project ui src/lib/serial/device.svelte.spec.ts(OTA chunk sizes 64–1024, failure path closes port and allows reconnect)Note
Medium Risk
Changes firmware OTA streaming and serial port teardown in a critical user-facing path; behavior is platform-specific but covered by expanded unit tests rather than broad integration coverage.
Reviewed by Cursor Bugbot for commit 390a84e. Bugbot is set up for automated code reviews on this repo. Configure here.
Mac OTA updates were rejected with
OTA FAIL END <byte count> ESP_ERR_OTA_VALIDATE_FAILEDwhile Windows succeeded. The running firmware never changed, so this has to be fixed in the Device Manager.updateFirmware()wrote the image in 128-byte chunks. 128 is a multiple of the full-speed USB packet size (64), so macOS appends a zero-length packet after each write. The keyboard's TinyUSB CDC stack then delivers a corrupted stream andesp_ota_endfails validation.macOS (field-validated): transfer plans match the standalone DevTools updater that succeeded on CC2:
[63, 5],[63, 12],[31, 8],[127, 15]ms between writes. Each failed plan re-issuesRST OTAafter a short pause until one returnsOTA OK.Other platforms: 128-byte chunks, no pacing (unchanged throughput). Every write still avoids a length that is an exact multiple of 64 bytes (including the last chunk).
On failure the update threw before
suspend(), so the serial port stayed open and the next Connect failed withInvalidStateErroruntil refresh. The port is now closed when the update throws.Testing
pnpm exec vitest run --project ui src/lib/serial/device.svelte.spec.ts