Skip to content

ESP32P4: espflash fails to communicate with USB HS port when using flash stub #1038

Description

@xobs

Bug description

The ESP32P4 bootloader has a check that will put the OTG port into Device mode if the BOOT pin is held down. espflash currently fails to communicate with the device when it's in this state when using the flash stub, unlike esptool. The failure causes the device to leave debugging mode, so trying again without the stub requires manual user intervention.

To Reproduce

Steps to reproduce the behavior:

  1. Connect an ESP32-P4X-Function_EV_Board via the "USB HS" port
  2. Hold down the "BOOT" button and press "RST"
  3. Try flashing interacting with the device
  • I have reproduced the bug in main branch too

Expected behavior

The device should flash.

Screenshots

bash-3.2$ # Reset board here again by holding down "BOOT" and pressing "RST"
bash-3.2$ espflash board-info
✔ Use serial port '/dev/cu.usbmodem2101' - ESP32-P4? · yes
✔ Remember this serial port for future use? · no
[2026-06-05T09:47:37Z INFO ] Serial port: '/dev/cu.usbmodem2101'
[2026-06-05T09:47:37Z INFO ] Connecting...
[2026-06-05T09:47:38Z INFO ] Using flash stub
Error:   × Communication error while flashing device
bash-3.2$ # Reset board here again by holding down "BOOT" and pressing "RST"
bash-3.2$ uvx esptool chip-id
esptool v5.3.0
Connected to ESP32-P4 on /dev/cu.usbmodem2101:
Chip type:          ESP32-P4 (revision v3.2)
Features:           Dual Core + LP Core, 400MHz
Crystal frequency:  40MHz
USB mode:           USB-OTG
MAC:                e8:f6:0a:e3:a9:1f

Stub flasher running.

Warning: ESP32-P4 has no chip ID. Reading MAC address instead.
MAC:                e8:f6:0a:e3:a9:1f

Hard resetting with a watchdog...
bash-3.2$

Environment

  • OS: macOs
  • espflash/cargo-espflash version: feat/p4-stub
  • Target: ESP32P4

Additional context

I recognize that the usual method is to communicate with the device using the USB-to-UART bridge that most devices have, and I was surprised to learn that the OTG port even had this behaviour. However, since esptool is able to work with it, I feel that espflash should be able to work with it as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions