Skip to content

Commit c4aa3b2

Browse files
committed
Blog: Added article ESP devices and WSL2
1 parent ad372a0 commit c4aa3b2

File tree

3 files changed

+83
-0
lines changed

3 files changed

+83
-0
lines changed

content/authors/jakub-kocka/_index.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
title: "Jakub Kocka"
3+
---
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
title: "Working with Espressif's devkits using WSL2"
3+
date: 2024-10-31
4+
showAuthor: false
5+
tags: ["ESP-IDF", "Windows", "WSL2"]
6+
authors:
7+
- "jakub-kocka"
8+
---
9+
10+
## Introduction
11+
12+
[WSL](https://learn.microsoft.com/en-us/windows/wsl/) (Windows Subsystem for Linux) is a great way to run Linux alongside Windows. However, when there is a need to use it with Espressif's devkits, it can be a bit tricky due to the required serial port forwarding. In this short article, a step-by-step guide is provided to help you work with Espressif's devkits using WSL.
13+
14+
### Alternatives
15+
16+
Many common operations (e.g., flashing, monitoring, etc. ) can be handled by the [esp_rfc2217_server](https://docs.espressif.com/projects/esptool/en/latest/esp32/esptool/remote-serial-ports.html?highlight=rfc) (Telnet) where the host Windows machine acts as the server and the WSL terminal acts as the client. However, tools like OpenOCD (Open On-Chip Debugger) cannot be used with this approach.
17+
18+
## Step-by-step Guide
19+
20+
The following steps describe a serial port forwarding method for WSL using [usbipd-win](https://github.com/dorssel/usbipd-win).
21+
It is assumed that the latest version of WSL is already installed. A detailed guide and troubleshooting can be found in [Microsoft documentation](https://learn.microsoft.com/en-us/windows/wsl/connect-usb).
22+
23+
(*tested with:* Windows 11 (23H2), usbipd-win 4.3.0)
24+
25+
### 1. Install the USBIPD-WIN
26+
27+
Using package manager in the host terminal
28+
29+
winget install usbipd
30+
31+
Or download the .msi file from the [latest releases](https://github.com/dorssel/usbipd-win/releases).
32+
After the installation the terminal will be needed to restart.
33+
34+
### 2. Attach a devkit
35+
36+
In the host terminal run
37+
38+
usbipd list
39+
40+
For example the used devkit is ESP32-C6 (**1-1 is the BUSID** which will be needed in the following commands)
41+
42+
BUSID VID:PID DEVICE STATE
43+
1-1 303a:1001 USB Serial Device (COM4), USB JTAG/serial debug unit Not shared
44+
45+
46+
Bind the listed devkit with following command in host terminal (needs administrative privileges)
47+
48+
usbipd bind --busid 1-1
49+
50+
Attach the device in the host terminal (needs already running instance of WSL)
51+
52+
usbipd attach --wsl --busid 1-1
53+
54+
Now you should be able to see the devkit in the WSL terminal (run *lsusb* to check) and that should be everything needed. You can start using the attached serial port directly in the WSL.
55+
56+
### Troubleshooting note
57+
58+
If the devkit is not possible to use even after attaching (and is visible with the *lsusb* command) you can run the following command in the WSL terminal
59+
60+
sudo modprobe cp210x
61+
62+
this will add kernel module with the needed controller but only for the instance. To add this permanently, it can be done with the following command
63+
64+
echo "cp210x" | sudo tee -a /etc/modules
65+
66+
### Detach a devkit
67+
68+
When working with the devkit is completed, you can detach the devkit with the command in the host terminal
69+
70+
usbipd detach --busid 1-1
71+
72+
## Conclusion
73+
74+
Working with WSL and Espressif's devkits for certain use cases may not be that simple. While for basic operations, using the esp_rfc2217_server might be enough (where the host machine acts as the server and the WSL terminal as the client) this method may not be always sufficient. In some cases, direct interaction with the devkit from within WSL becomes necessary. When that happens, serial port forwarding can be employed. With the help of this guide, we hope the process is now clearer, making it easier for you to work with Espressif's devkits in a WSL.
75+
76+
## Resources
77+
78+
- [Windows Subsystem for Linux Documentation](https://learn.microsoft.com/en-us/windows/wsl/)
79+
- [Microsoft documentation WSL - Connect USB devices](https://learn.microsoft.com/en-us/windows/wsl/connect-usb)
80+
- [USBIPD-WIN](https://github.com/dorssel/usbipd-win)

0 commit comments

Comments
 (0)