Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"ardi attach-and-watch" fails on platforms with onboard USB-serial support #92

Open
egnor opened this issue Sep 24, 2021 · 0 comments
Open

Comments

@egnor
Copy link

egnor commented Sep 24, 2021

Some Arduino platforms (like the Uno) have a dedicated USB-serial chip, so the USB-serial device is consistently present throughout the program-run-reset cycle. However, others (like the Leonardo and Micro) use the same chip for USB-serial and for running Arduino programs, which means that on reset the device goes away (at least momentarily).

The one I'm using now is from Adafruit's "Bluefruit" line of nRF52-based Arduino-compatible boards.

Because the USB-serial device doesn't exist for a moment after programming (until the chip boots and the USB-serial device is recognized by the host), ardi attach-and-watch can fail:

% ardi attach-and-watch
ardi    Using compile opts from build definition: blinky 
ardi    Using baud from build definition: blinky      baud=9600
ardi    Compiling...                                  fqbn="adafruit:nrf52:cplaynrf52840" sketch=blinky.ino
Sketch uses 40596 bytes (4%) of program storage space. Maximum is 815104 bytes.
Global variables use 7140 bytes (3%) of dynamic memory, leaving 230428 bytes for local variables. Maximum is 237568 bytes.
ardi    Compilation successful                        fqbn="adafruit:nrf52:cplaynrf52840" sketch=blinky.ino
ardi    Uploading...                                  build=. device=/dev/ttyACM0 fqbn="adafruit:nrf52:cplaynrf52840"
TOUCH: error during reset: setting DTR to OFF: protocol error
Upgrading target on /dev/ttyACM0 with DFU package /tmp/arduino-sketch-3015A9A7226BD79EC290418CB735FCEF/bluefruit.ino.zip. Flow control is disabled, Single bank, Touch disabled
########################################
########################################
Activating new firmware
Device programmed.
ardi    Upload successful                             build=. device=/dev/ttyACM0 fqbn="adafruit:nrf52:cplaynrf52840"
ardi    Watching blinky.ino for changes              
ardi    Attaching to port                             port=/dev/ttyACM0
ardi Failed to read from device                    baud=9600 error="no such file or directory" name=/dev/ttyACM0

Note that once the chip boots (mere milliseconds later), the serial device shows up and can be accessed just fine; a separate ardi attach afterward works:

% ardi attach
ardi    Attaching to port                             port=/dev/ttyACM0
Hello!
Hello!
Hello!
...

Probably this is best dealt with by polling for the serial port to exist? Note that if the chip gets reset (e.g. someone hits a reset button) the serial port will wink out of existence for a moment, so it's probably best if after a serial read error "attach" returned to polling for the device? (That's secondary though.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant