Skip to content

ESP32s3 hangs on stdout if USB cable connected but CDC not attached #18000

@jonathanhogg

Description

@jonathanhogg

Port, board and/or hardware

ESP32 / UM_TINYS3

MicroPython version

HEAD as of 8c47e44 with the suggested USB fix from #17560 applied – otherwise USB is not reliable for me as I'm using macOS. Same behaviour with official release version of 1.26 though.

Reproduction

  1. Install code below as boot.py
from time import sleep_ms
from machine import Pin, bitstream


led_power = Pin(17, Pin.OUT, value=1)
led = Pin(18, Pin.OUT)

while True:
    bitstream(led, 0, (400, 850, 800, 450), bytes([0, 127, 0]))
    sleep_ms(500)
    bitstream(led, 0, (400, 850, 800, 450), bytes([0, 0, 0]))
    sleep_ms(500)
    print("Hello world!")

Expected behaviour

Code should run, blinking the LED as soon as power is applied – either from USB or externally – and continue to run if the USB cable is connected or disconnected, whether or not a serial console is attached.

Observed behaviour

  • Power up from USB: LED blinks for about 20 seconds and then controller locks solid and mpremote cannot attach to it
  • Power up from USB and attach mpremote immediately: LED blinks and Hello world! appears repeatedly on the console ad infinitum
  • Power up from USB, attach mpremote watch for a bit and then detach serial console leaving USB cable connected: LED blinks for a few seconds after detaching terminal and then controller locks solid
  • Power up from external power: LED blinks ad infinitum
  • Power up from external power, wait a bit and then connect a USB cable without attaching to the serial: locks solid a few seconds after connecting the cable

It looks like connecting the USB is starting some kind of serial buffering that is exhausted after 255 bytes and hangs the controller.

Additional Information

This used to work in 1.24.

Code of Conduct

Yes, I agree

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions