Skip to content

deploy: daemon holds /dev/ttyUSB0 (CP2104) and then its own flash/esptool open fails with EBUSY #1705

Closed

Description

@zackees

fbuild 2.5.43 on Linux (NixOS). Board: classic ESP32 behind a CP2104 (10C4:EA60) on /dev/ttyUSB0.

After several successful fbuild deploy -e <env> -p /dev/ttyUSB0 runs, every later deploy fails. It fails from any project and with or without --monitor:

native write-flash failed (deploy failed: native write: failed to open serial port /dev/ttyUSB0: Device or resource busy); falling back to esptool
A fatal error occurred: Could not open /dev/ttyUSB0, the port is busy or doesn't exist.
  • Before the deploy, the port opens and closes cleanly from pyserial. fbuild port doctor reports it attached and healthy.
  • While the deploy runs, sampling /proc/*/fd shows exactly one holder: the fbuild-daemon that the deploy spawned. Its own native writer and its esptool fallback both then get EBUSY.
  • fbuild daemon clear-locks reports that no daemon is running. Killing the daemon does not help, because the next deploy reproduces the failure.
  • The daemon log also shows USB re-enumeration: port /dev/ttyUSB0 not available after 3s, then port closed client_id="deploy_preemption".

Recent daemon log lines for this port:

2026-10-23T03:47:35.900727Z  WARN fbuild_deploy::esp32::deployer: native write-flash failed (deploy failed: native write: failed to open serial port /dev/ttyUSB0: Device or resource busy); falling back to esptool port="/dev/ttyUSB0"
2026-10-23T03:47:35.900759Z  INFO fbuild_deploy::esp32::deployer: flashing /home/niteris/.clud/tmp/claude-1000/-home-niteris-dev-fastled/3ac941c0-6dd1-4dc4-b6eb-d30e74e5aea0/scratchpad/hil/.fbuild/build/esp32dev_stock/release/firmware.bin to /dev/ttyUSB0 via e
2026-10-23T03:47:39.800543Z  WARN fbuild_deploy: USB re-enumeration: port /dev/ttyUSB0 not available after 3s
2026-10-23T03:48:04.281057Z  INFO fbuild_serial::manager: port closed port="/dev/ttyUSB0" client_id="deploy_preemption"
2026-10-23T03:48:04.399900Z  INFO fbuild_deploy::esp32::deployer: verifying /home/niteris/.clud/tmp/claude-1000/-home-niteris-dev-fastled/3ac941c0-6dd1-4dc4-b6eb-d30e74e5aea0/scratchpad/hil/.fbuild/build/esp32dev_stock/release/firmware.bin on /dev/ttyUSB0 via 
2026-10-23T03:48:04.402670Z  WARN fbuild_deploy::esp32::deployer: native verify-flash failed (deploy failed: native verify: failed to open serial port /dev/ttyUSB0: Device or resource busy); falling back to esptool port="/dev/ttyUSB0"
2026-10-23T03:48:04.402747Z  INFO fbuild_deploy::esp32::deployer: verifying /home/niteris/.clud/tmp/claude-1000/-home-niteris-dev-fastled/3ac941c0-6dd1-4dc4-b6eb-d30e74e5aea0/scratchpad/hil/.fbuild/build/esp32dev_stock/release/firmware.bin on /dev/ttyUSB0 via 
A fatal error occurred: Could not open /dev/ttyUSB0, the port is busy or doesn't exist.
([Errno 16] could not open port /dev/ttyUSB0: [Errno 16] Device or resource busy: '/dev/ttyUSB0')
); proceeding with full flash port="/dev/ttyUSB0"
2026-10-23T03:48:05.756929Z  INFO fbuild_deploy::esp32::deployer: flashing /home/niteris/.clud/tmp/claude-1000/-home-niteris-dev-fastled/3ac941c0-6dd1-4dc4-b6eb-d30e74e5aea0/scratchpad/hil/.fbuild/build/esp32dev_stock/release/firmware.bin to /dev/ttyUSB0 via e
2026-10-23T03:48:05.757039Z  WARN fbuild_deploy::esp32::deployer: native write-flash failed (deploy failed: native write: failed to open serial port /dev/ttyUSB0: Device or resource busy); falling back to esptool port="/dev/ttyUSB0"
2026-10-23T03:48:05.757071Z  INFO fbuild_deploy::esp32::deployer: flashing /home/niteris/.clud/tmp/claude-1000/-home-niteris-dev-fastled/3ac941c0-6dd1-4dc4-b6eb-d30e74e5aea0/scratchpad/hil/.fbuild/build/esp32dev_stock/release/firmware.bin to /dev/ttyUSB0 via e
2026-10-23T03:48:09.874369Z  WARN fbuild_deploy: USB re-enumeration: port /dev/ttyUSB0 not available after 3s
2026-10-23T03:48:19.480399Z  INFO fbuild_serial::manager: port closed port="/dev/ttyUSB0" client_id="deploy_preemption"
2026-10-23T03:48:19.906416Z  INFO fbuild_deploy::esp32::deployer: verifying /home/niteris/.clud/tmp/claude-1000/-home-niteris-dev-fastled/3ac941c0-6dd1-4dc4-b6eb-d30e74e5aea0/scratchpad/hilu/.fbuild/build/esp32dev_stock/release/firmware.bin on /dev/ttyUSB0 via
2026-10-23T03:48:19.906557Z  WARN fbuild_deploy::esp32::deployer: native verify-flash failed (deploy failed: native verify: failed to open serial port /dev/ttyUSB0: Device or resource busy); falling back to esptool port="/dev/ttyUSB0"
2026-10-23T03:48:19.906583Z  INFO fbuild_deploy::esp32::deployer: verifying /home/niteris/.clud/tmp/claude-1000/-home-niteris-dev-fastled/3ac941c0-6dd1-4dc4-b6eb-d30e74e5aea0/scratchpad/hilu/.fbuild/build/esp32dev_stock/release/firmware.bin on /dev/ttyUSB0 via
A fatal error occurred: Could not open /dev/ttyUSB0, the port is busy or doesn't exist.
([Errno 16] could not open port /dev/ttyUSB0: [Errno 16] Device or resource busy: '/dev/ttyUSB0')
); proceeding with full flash port="/dev/ttyUSB0"
2026-10-23T03:48:20.419048Z  INFO fbuild_deploy::esp32::deployer: flashing /home/niteris/.clud/tmp/claude-1000/-home-niteris-dev-fastled/3ac941c0-6dd1-4dc4-b6eb-d30e74e5aea0/scratchpad/hilu/.fbuild/build/esp32dev_stock/release/firmware.bin to /dev/ttyUSB0 via 
2026-10-23T03:48:20.419206Z  WARN fbuild_deploy::esp32::deployer: native write-flash failed (deploy failed: native write: failed to open serial port /dev/ttyUSB0: Device or resource busy); falling back to esptool port="/dev/ttyUSB0"
2026-10-23T03:48:20.419261Z  INFO fbuild_deploy::esp32::deployer: flashing /home/niteris/.clud/tmp/claude-1000/-home-niteris-dev-fastled/3ac941c0-6dd1-4dc4-b6eb-d30e74e5aea0/scratchpad/hilu/.fbuild/build/esp32dev_stock/release/firmware.bin to /dev/ttyUSB0 via 
2026-10-23T03:48:23.902882Z  WARN fbuild_deploy: USB re-enumeration: port /dev/ttyUSB0 not available after 3s

Found while validating FastLED/FastLED#4911.

Activity

  1. zackees commented on Oct 23, 2026

    @zackees
    MemberAuthor

    Correction: a scan of /proc fds finds no user process (fbuild-daemon included) holding /dev/ttyUSB0 when the EBUSY happens. ModemManager (root, ID_MM_CANDIDATE=1 on this CP2104) is the likely holder, so this may be a host udev/ModemManager problem rather than the daemon (see #1653).

  2. zackees commented on Oct 24, 2026

    @zackees
    MemberAuthor

    Per the correction above (ModemManager probing the CP2104, ID_MM_CANDIDATE=1): PR #1712 (fixes #1653) adds ENV{ID_MM_DEVICE_IGNORE}="1" to the tty/usb rules fbuild port udev generates, in 70-fbuild.rules (before 80-mm-candidate.rules). After it lands, reinstall with fbuild port udev --install; on NixOS use the services.udev.packages form from #1713/#1654, because extraRules lands in 99-local.rules. If EBUSY persists with ID_MM_CANDIDATE no longer set on the device, this is a separate fbuild bug.

  3. zackees commented on Oct 28, 2026

    @zackees
    MemberAuthor

    Resolved — closing with host evidence re-verified today.

    The follow-up correction on this issue identified ModemManager as the real holder (ID_MM_CANDIDATE=1 on the CP2104), and PR #1712 (fixing #1653) added ENV{ID_MM_DEVICE_IGNORE}="1" to the tty/usb rules fbuild port udev generates, in 70-fbuild.rules so it sorts before 80-mm-candidate.rules.

    Verified on the reporter's host (NixOS, ModemManager active):

    • /run/udev/rules.d/70-fbuild.rules carries ENV{ID_MM_DEVICE_IGNORE}="1" for the tty and usb rules of each supported vendor.
    • udevadm info -q all -n /dev/ttyUSB0 → ID_MM_DEVICE_IGNORE=1.
    • mmcli -L → No modems were found even though ModemManager is running (it no longer takes the board).
    • /dev/ttyUSB0 opens and closes cleanly right now (no EBUSY, no holder).

    If EBUSY ever returns on a device where ID_MM_CANDIDATE is no longer set, that is a separate fbuild bug — please open a new issue with the fbuild port doctor output.

    — fbuild steward (automated)

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

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions