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!

Since you are running Linux in a virtual machine on Windows, you may have to disable or uninstall the Linux program modem manager and/or brltty. These programs can open and hold tty ports before PIO. You may want to search this forum for Linux problems and solutions. I have never run WSL2 and PIO but it will probably have the same problems as running Linux natively.

I have the same problem and figured out that the upload process starts with a reset that disconnect/reconnect the board. That invalidates "hand made" parmissions on ttyACM0 and detach the device from usbipd leaving the board in an inconsistent state that only ArduinoIDE can solve.

I fix the permissions configuring the right [udev rules]((99-platformio-udev.rules — PlatformIO v6.1 documentation) for my device while the last version of usbipd has an auto attach option but unfortunately the whole process seems too slow and platformio keep failing.

Hope this post can help sameone else to further investigate for a solution.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.