Just walking through my experience with setting this up.
Environment:
- Windows 11
- WSL 2 (Windows subsystem for Linux)
- Ubuntu 22.04 (in WSL)
VS Code insisted on installing the Platform.io extension in WSL:Unbuntu-22.04 - it would not give me a choice to install it to Windows. So rolling with that …
Set up Platform.io as per the video linked above.
Note that at the end of the video, where you create the test project, Platform.io insists on using a back slash \
in the path name to the project, even though it is going into a Linux folder, and then the project will not load. Find the misspelled project folder and remove the offending part of its name. I found this was easiest through Window file manager.
Now the project can be found and loaded into VS Code.
Next, Ubuntu under WSL has no access to the COM ports. However, there is a way to give it access. Follow this guide: Connect USB devices | Microsoft Learn
And there it is
And then finally restart VS Code (because I had rebooted of course). And lo and behold, it could find the device.
But…
It couldn’t Upload
to the device. And there’s this warning:
Warning! Please install `99-platformio-udev.rules`.
More details: https://docs.platformio.org/en/latest/core/installation/udev-rules.html
So back to the Ubuntu terminal to install the above rules. And then another reboot (although I probably could have just restarted WSL)
And after the reboot I had to open a PowerShell Window (as admin) again and rerun usbipd wsl list
, find my device’s bus-id
(it didn’t change), and then run usbipd wsl attach --busid 2-3
Got VS Code up again
… and I still can’t upload to the device.
So back to the udev.rules page and I because I do not run my Ubuntu VM as root
I went and also ran:
sudo usermod -a -G dialout $USER
sudo usermod -a -G plugdev $USER
And this stackexchange permissions - Could not open port /dev/ttyACM0 Error after every restart - Ask Ubuntu
From which I tried: sudo adduser $USER $(stat --format="%G" /dev/ttyACM0 )
And it still wouldn’t upload, because VS Code is running in a Window context, not as my Ubuntu user. So also, as per this https://arduino.stackexchange.com/questions/47429/failed-to-open-dev-ttyacm0-port-busy
I ran sudo chmod 666 /dev/ttyACM0
And now I could upload! … not quite … now I get
A fatal error occurred: Failed to connect to ESP32-C3: No serial data received.
For troubleshooting steps visit: https://docs.espressif.com/projects/esptool/en/latest/troubleshooting.html
*** [upload] Error 2
And poking around a few things I wonder if it’s because I’ve already flashed this particular ESP32-S3 with the .net nanoFramework.
So I get the other one that I bought, and go through the whole process again. And no success.
So then I wonder about trying the other USB connector to see what I get - getting desperate here. And, after all of the above rigmarol, it finally tells me that perhaps my chipset is different. And I go Whaaat?!? after all this time.
So I go through everything again, again, and finally I’m able to upload to the device. I’m going to have a lie down now …