08 Sep 2024
This is a guide to use rust for arduino development on wsl (Windows subsystem for linux). Everything will be setup and available in the wsl terminal. Through this guide we will install the following components:
wsl --install
this command this will install a default ubuntu distro. If you want to install a different distro refer to this pageCtrl+,
to open settings "profiles":
{
"list": [
{
"guid": "{2c4de342-38b7-51cf-b940-2309a097f518}",
"hidden": false,
"name": "Ubuntu",
"source": "Windows.Terminal.Wsl",
"colorScheme": "Ubuntu-ColorScheme",
"cursorShape": "filledBox",
"font": {
"face": "Cousine Nerd Font", <-- specify the installed nerd font here
"size": 12
}
},
]
}
usbipd list
usbipd bind --busid <busid>
You only need to share it onceusbipd attach --wsl --busid <busid>
lsusb
You can also create a shortcut to be able to launch a new windows terminal directly with the Ubuntu profile. To do that simply navigate to C:\Users\{username}\AppData\Roaming\Microsoft\Windows\Start Menu\Programs
, right click, new and shortcut. Use wt.exe
as target and add -p Ubuntu
to start the ubuntu wsl profile. So the resulting shortcut target should be wt.exe -p Ubuntu
. Note that you might need to use the full path to wt.exe
. To get the full path you can simply run where wt
in a windows terminal.
Follow this page to install zsh in wsl.
Note: You don’t need to install the font since we already installed nerdfonts in the previous step.
Let’s get Rusty youtube channel as a nice video on how to setup linux for rust development. Follow there step in the wsl terminal.
Look at this page to setup rust for arduino. This will install all the necessary dependencies and init a new project with cargo generate
.
To make sure what /dev/tty**
file to use for ravendude you can follow these steps.
First, make sure that you have installed usbipd-win and that the bus is shared with wsl in visble in wsl with lsusb
. To determine what /dev/tty***
unbeffured file to use you can do
❯ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 002: ID 2341:0043 Arduino SA Uno R3 (CDC ACM) <-- arduino device. this is a acm so looking for ttyACM* file
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
If this is the only usb device shared with wsl we can suppose that the file name will be /dev/ttyACM0
. But if you want to be sure you can use this command dmesg -H > test.txt
. This will output to the test.txt
file. Open this file and search for arduino.
[ +0.000002] usb 1-1: Manufacturer: Arduino (www.arduino.cc)
[ +0.000002] usb 1-1: SerialNumber: 75130303036351106150
[ +0.024063] cdc_acm 1-1:1.0: ttyACM0: USB ACM device <-- ttyACM0
You could also use this method:
ls \dev\tty* > test.txt
ls \dev\tty* > test2.txt
❯ comm -1 -3 test.txt test2.txt
/dev/ttyACM0