Skip to content

Can a board be USB host and USB device at the same time? Nothing records an answer #16

Description

@claude

What this decides

Whether a pedal can host a USB MIDI controller while still presenting itself to a PC — REPL, sound card, MIDI, or a drive for patch files — on a second connector. That combination is a stated board-selection requirement, and it is the only one of the three that is currently unrecorded anywhere. The other two (an ESP32-P4, readily available) are decidable from a product page.

Right now nobody can look this up. It came up in conversation, it got a plausible answer, and it was never settled or written down.

What we actually know

The pins don't collide on the P4. CONFIG_SOC_USB_OTG_PERIPH_NUM=2 is recorded in #3 from a built sdkconfig, and #3's bench notes place the second USB on USB_IN1_P/N (GPIO24/25) going to a header, separate from the HS OTG port that was under test. USB Serial/JTAG is a third block again. So the structural precondition holds: there are enough independent peripherals for the two roles to sit on different ones.

That is not the same as the stack supporting it. The precondition being met says nothing about whether usb_host_install() and the TinyUSB device stack can be up in the same firmware, on different peripherals, at the same time. I could not find an Espressif statement either way. Nothing in this repo claims it, and nothing here has ever run it.

The ESP32-S3 recollection needs checking before it's relied on. The belief that an S3 has done both at once may be a memory of something else, because the closest thing this repo records is not dual-role:

If the S3 really did run host and device concurrently, it would have been on the one OTG peripheral plus USB Serial/JTAG, and on the S3 those share pins — which is the usual reason only one works at a time. That deserves a check rather than an assumption in either direction.

The experiment

Cheap, and it needs no new hardware beyond a board with two usable USB connectors.

  1. host_start() on the port wired for host, with a full-speed device attached, and confirm an attach in host_stats().
  2. With the host still running, bring the device side up — bare CDC is enough — on the other peripheral.
  3. Check both directions still work: the host still reports its device, and the PC still sees the CDC.
  4. Then reverse the order — device first, host second — because a stack that tolerates one order may not tolerate the other.
  5. Record which peripheral carried which role, and the FIFO bias in force (Choose the host FIFO bias at runtime, not at build time #2), since the host side's channel and FIFO budget is per-controller and this doubles the demand on whatever is shared.

What each outcome means

If it works, the pedal can host its own controller and still be a sound card and a REPL to a PC, and the board requirement is satisfiable. It should become a documented capability with the pin and peripheral assignment spelled out, because it constrains which dev kits qualify.

If it doesn't, a pedal has to choose per session, or use a second chip for the control surface. That is a product-shape decision, not a firmware detail, and it wants to be known before a board is picked rather than after.

Related: #3 (the P4 HS host defect, and where the peripheral count is recorded), #15 (full-speed devices behind a hub, the other half of whether a MIDI controller works at all), #2 (host FIFO bias, which this would put under more pressure), #1 (the S3 device-side attach failure).


Generated by Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-boardNeeds a board on the bench (P4 panel, S3-Touch-4.3, T-Embed)parkedWaiting on a named trigger

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions