Repository navigation
Conversation
stinos
reviewed
Jan 2, 2018
Contributor
There was a problem hiding this comment.
There's one semicolon too much
Enable the addition of heap space at runtime. Advantages:
- The ESP32 has a fragmented heap so to use all of it the heap must be
split.
- Support a dynamic heap while running on an OS, adding more heap when
necessary.
Contributor
Author
|
Replaced by a better PR that supports disabling of multiheap support: #3580. |
UKTailwind
added a commit
to UKTailwind/micropython
that referenced
this pull request
Sep 2, 2026
The PicoMite tree ran its TinyUSB 0.21 host work on this same hardware - two keyboards (one marginal), a touch panel and a flash drive behind one hub - across software, hardware and power-on resets, and wrote up what actually held (docs/usb-host-hardening). Root cause: the RP2 SIE keeps ONE handshake-result latch shared between EPX and the interrupt-endpoint poller (upstream micropython#3533), so an interrupt poll can overwrite a control transfer's ACK before the IRQ handler reads it, and the transfer is misread as RX_TIMEOUT. The validated answer is to tolerate the race above the silicon, not to adopt the strict micropython#3533 driver rewrite - which enumerated FEWER devices on the marginal rig. Applied here: hcd_rp2040.patch Grace period for EP0 RX timeouts: within a 1 s window the transfer is left armed and the clobbered result outlasted; the window closes on any EP0 completion. Expiry (a genuinely dead device) takes the original fail path, which keeps our buffer clear (micropython#3874). Bulk/interrupt keep the fast-fail: their flow control is NAK, which never raises RX_TIMEOUT. usbh.patch Enumeration-exclusive control dispatch: while a device enumerates, only address 0, the enumerating address and the hub in use may claim the control slot; LED writes and touch handshakes wait in the pending FIFO (gated at the claim, the two drain checks and the dispatcher, by peeking the head). And a failed enumeration now disables its hub port (CLEAR_FEATURE(PORT_ENABLE), async no-op callback) - 0.21 left the abandoned device enabled at address 0, where it answers in parallel with the next device's bring-up. The 100 ms reset recovery (micropython#3876) stays. mp_usbh.c Mount-callback prints deferred: the callbacks now usb_msc.c format into a small static ring and mp_usbh_task() prints it after tuh_task() returns. A print in the callback runs the VM via dupterm mid-enumeration - the measured cost of "one connect chime" on the PicoMite rig was the marginal device. The existing reentrancy guard treated the symptom; this removes the stall itself. tusb_config.h CFG_TUH_CONTROL_PENDING_QUEUE_SZ 4 -> 8: the gate parks more traffic in the FIFO during enumeration. Not adopted, by the doc's own measurement: the micropython#3533 reference hcd (fewer devices on marginal hardware; revisit when merged upstream). Already carried, now cross-validated: MULTI_HUB_FIX and the 64-entry event queue. Builds clean; the board leg - all reset kinds, hot attach, MSC beside HID, pulling the marginal device - is owed before this is believed. Co-Authored-By: Claude Fable 5 <[email protected]>
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.
Enable the addition of heap space at runtime. Advantages:
With this code, I managed to extend the MicroPython heap to ~200kB on the ESP32:
There appears no way to have one large heap on the ESP32, as the ESP-IDF itself fragments the heap:
I haven't included the code for the ESP32 yet, but it is very simple.
I have tested these changes using #3532 and haven't seen a regression.