Add --throttle flag to prevent QEMU buffer overflows on large payloads#54
Open
JunderscoreB wants to merge 1 commit intocoredevices:mainfrom
Open
Add --throttle flag to prevent QEMU buffer overflows on large payloads#54JunderscoreB wants to merge 1 commit intocoredevices:mainfrom
JunderscoreB wants to merge 1 commit intocoredevices:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add Transfer Throttling for Large Payloads on QEMU (
--throttle)Overview
This PR introduces an optional
--throttleflag to thepebble installcommand. It solves a notorious edge-case bug where installing large apps (e.g., 1MB+ payloads with heavy audio/image assets) on local QEMU emulators causes catastrophic timeouts or hardware panics, particularly on theemery(Pebble Time 2) emulator.The Root Cause
Modern host machines execute Python networking scripts significantly faster than the 2016-era QEMU emulators can simulate flash memory writes.
.pbwvia BlobDB, the host CPU overwhelms the QEMU serial buffer. QEMU locks the virtual CPU to catch up on flash writes, triggering the watchdog timer and causing aresult=2failure.emeryemulator features an unpatched prototype hardware bug. If the watchdog timer resets the watch, or if the transfer takes longer than the 60-second idle timer, the watch attempts to enter Stop Mode while the PLL is active, resulting in a fatal QEMU panic:qemu stm32: hardware warning: PLL cannot be disabled while it is selected as the system clock.The Solution
By injecting a microscopic
time.sleep()into thelibpebble2packet sender, we can safely drip-feed the packets to the emulator.A default delay of 4 milliseconds (
0.004) limits the transfer to ~250 packets per second. This completely prevents the flash controller lock-up while ensuring a 1MB payload finishes installing in ~32 seconds—safely beating the 60-second idle sleep timeout.What Changed
--throttleflag topebble_tool/commands/install.py(defaults to 0.004s).PebbleConnection.send_packetif the flag is passed, keeping the fix localized topebble-toolwithout requiring cross-repo changes tolibpebble2.