Can't flash Arduino on WSL2: No device found on ttyACM0

Hello everyone,

I’d like to upload an Arduino script to my MKR WiFi 1010, but run into the error “No device found on ttyACM0.” I’m running VS Code in WSL2 and can view the port under PIO Home > Devices. PIO’s serial monitor also works on the port without issue, which I tested after uploading code to my board using the Arduino IDE.

Here’s my trace for the verbose upload:

 *  Executing task: platformio run --verbose --target upload --environment mkrwifi1010 

pyenv shell 3.9.5
Processing mkrwifi1010 (platform: atmelsam; board: mkrwifi1010; framework: arduino; monitor_speed: 9600; lib_deps: arduino-libraries/ArduinoMqttClient@^0.1.6, arduino-libraries/WiFiNINA@^1.8.13)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
CONFIGURATION: https://docs.platformio.org/page/boards/atmelsam/mkrwifi1010.html
PLATFORM: Atmel SAM (8.1.0) > Arduino MKR WiFi 1010
HARDWARE: SAMD21G18A 48MHz, 32KB RAM, 256KB Flash
DEBUG: Current (atmel-ice) External (atmel-ice, blackmagic, jlink)
PACKAGES: 
 - framework-arduino-samd @ 1.8.13 
 - framework-cmsis @ 1.40500.0 (4.5.0) 
 - framework-cmsis-atmel @ 1.2.2 
 - tool-bossac @ 1.10700.190624 (1.7.0) 
 - toolchain-gccarmnoneeabi @ 1.70201.0 (7.2.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 15 compatible libraries
Scanning dependencies...
Dependency Graph
|-- ArduinoMqttClient @ 0.1.6 (License: Unknown, Path: /home/mferuscomelo/Programming/smart_home_mkr1010/.pio/libdeps/mkrwifi1010/ArduinoMqttClient)
|-- WiFiNINA @ 1.8.13 (License: Unknown, Path: /home/mferuscomelo/Programming/smart_home_mkr1010/.pio/libdeps/mkrwifi1010/WiFiNINA)
|   |-- SPI @ 1.0 (License: Unknown, Path: /home/mferuscomelo/.platformio/packages/framework-arduino-samd/libraries/SPI)
Building in release mode
MethodWrapper(["checkprogsize"], [".pio/build/mkrwifi1010/firmware.elf"])
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]  11.7% (used 3824 bytes from 32768 bytes)
Flash: [=         ]  15.0% (used 39228 bytes from 262144 bytes)
.pio/build/mkrwifi1010/firmware.elf  :
section            size        addr
.text             38684        8192
.data               544   536870912
.bss               3280   536871456
.ARM.attributes      40           0
.comment            126           0
.debug_frame       3088           0
.stabstr            441           0
Total             46203
<lambda>(["upload"], [".pio/build/mkrwifi1010/firmware.bin"])
AVAILABLE: atmel-ice, blackmagic, jlink, sam-ba
CURRENT: upload_protocol = sam-ba
BeforeUpload(["upload"], [".pio/build/mkrwifi1010/firmware.bin"])
Auto-detected: /dev/ttyACM0
Forcing reset using 1200bps open/close on port /dev/ttyACM0
Waiting for the new upload port...
bossac --info --debug --port "ttyACM0" --write --verify --reset --erase -U true .pio/build/mkrwifi1010/firmware.bin
No device found on ttyACM0
Set binary mode
Send auto-baud
Set binary mode
*** [upload] Error 1
================================================================================================================================= [FAILED] Took 70.63 seconds =================================================================================================================================

 *  The terminal process "platformio 'run', '--verbose', '--target', 'upload', '--environment', 'mkrwifi1010'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 

To be able to develop in WSL, I need to execute the following command in an elevated command prompt: usbipd wsl attach --busid 1-1, which then allows WSL to view the port. Once done, I execute sudo chmod 666 /dev/ttyACM0 on WSL.

Running stty -F /dev/ttyACM0 -a gives me the following output:

speed 115200 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; discard = ^O; min = 0; time = 0;
-parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff -iuclc -ixany -imaxbel -iutf8
-opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
-isig -icanon -iexten -echo -echoe -echok -echonl -noflsh -xcase -tostop -echoprt -echoctl -echoke -flusho -extproc

What could be preventing the code from being uploaded to the Arduino? Please let me know if you need any more information.

Thanks in advance!

Having the same issue with a Seeed WIO Terminal and WSL2

  • I have my platform io udev rules setup
  • Have platform io in vscode
  • Device monitor works fine
 *  Executing task: platformio device monitor 

--- Terminal on /dev/ttyACM0 | 9600 8-N-1
--- Available filters and text transformations: colorize, debug, default, direct, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at https://bit.ly/pio-monitor-filters
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H

But upload fails with a not found error:

Executing task: platformio run --target upload 

Processing seeed_wio_terminal (platform: atmelsam; board: seeed_wio_terminal; framework: arduino)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelsam/seeed_wio_terminal.html
PLATFORM: Atmel SAM (8.1.0) > Seeeduino Wio Terminal
HARDWARE: SAMD51P19A 120MHz, 192KB RAM, 496KB Flash
DEBUG: Current (atmel-ice) External (atmel-ice, blackmagic, jlink)
PACKAGES: 
 - framework-arduino-samd-seeed @ 1.8.1 
 - framework-cmsis @ 2.50400.181126 (5.4.0) 
 - framework-cmsis-atmel @ 1.2.2 
 - tool-bossac @ 1.10900.0 (1.9.0) 
 - toolchain-gccarmnoneeabi @ 1.70201.0 (7.2.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 14 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Checking size .pio/build/seeed_wio_terminal/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   1.6% (used 3056 bytes from 196608 bytes)
Flash: [          ]   2.6% (used 13428 bytes from 507904 bytes)
Configuring upload protocol...
AVAILABLE: atmel-ice, blackmagic, jlink, sam-ba
CURRENT: upload_protocol = sam-ba
Looking for upload port...
Auto-detected: /dev/ttyACM0
Forcing reset using 1200bps open/close on port /dev/ttyACM0
Waiting for the new upload port...
Uploading .pio/build/seeed_wio_terminal/firmware.bin
No device found on ttyACM0
*** [upload] Error 1
===================================================================================================== [FAILED] Took 70.24 seconds =====================================================================================================

 *  The terminal process "platformio 'run', '--target', 'upload'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it.