Skip to content

Commit b97ad57

Browse files
jakub-kockapedrominatel
authored andcommitted
Blog: Added article ESP devices and WSL2
Editorial changes and added the author json file Changes on the introduction
1 parent 012bd4f commit b97ad57

File tree

4 files changed

+113
-0
lines changed

4 files changed

+113
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
title: "Jakub Kocka"
3+
---
85.1 KB
Loading
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
---
2+
title: "Working with Espressif's SoC's using WSL2"
3+
date: 2024-10-31
4+
showAuthor: false
5+
authors:
6+
- jakub-kocka
7+
tags: ["ESP-IDF", "devkit", "Windows", "WSL", "WSL2", "USB"]
8+
---
9+
10+
Released in 2016 by Microsoft, the Windows Subsystem for Linux [(WSL)](https://learn.microsoft.com/en-us/windows/wsl/) is a feature that allows the use of a Linux environment with no need of a virtual machine, container or dual boot. The [WSL](https://learn.microsoft.com/en-us/windows/wsl/) is a great way to run Linux alongside Windows.
11+
12+
## Introduction
13+
14+
In some cases, users can't use Windows PowerShell for developing ESP-IDF applications for ESP SoCs, or when WSL is already in use, the flashing and monitoring steps can be tricky.
15+
16+
This article is a step-by-step guide, provided to help you work with Espressif's SoCs when using WSL.
17+
18+
### Alternatives
19+
20+
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](https://openocd.org/) (Open On-Chip Debugger) cannot be used with this approach.
21+
22+
## Guide
23+
24+
The following steps describe a serial port forwarding method for WSL using [USBIPD-WIN](https://github.com/dorssel/usbipd-win).
25+
It is assumed that the latest version of WSL2 is already installed. A detailed guide and troubleshooting can be found in [Microsoft documentation](https://learn.microsoft.com/en-us/windows/wsl/connect-usb).
26+
27+
(*tested with:* Windows 11 (23H2), USBIPD-WIN 4.3.0)
28+
29+
### 1. Install the USBIPD-WIN
30+
31+
Using package manager in the host terminal, run:
32+
33+
```bash
34+
winget install usbipd
35+
```
36+
37+
Or download the `.msi` file from the [latest releases](https://github.com/dorssel/usbipd-win/releases) and install it manually.
38+
39+
After the installation, the terminal must be restarted.
40+
41+
### 2. Attach the USB
42+
43+
With the devkit connected, in the host terminal, run:
44+
45+
```bash
46+
usbipd list
47+
```
48+
49+
In this example, the devkit used is the **ESP32-C6-DevKit-C**, with the **1-1 is the BUSID**, which will be needed in the following commands.
50+
51+
```text
52+
BUSID VID:PID DEVICE STATE
53+
1-1 303a:1001 USB Serial Device (COM4), USB JTAG/serial debug unit Not shared
54+
```
55+
56+
Now, bind the listed devkit with following command in host terminal (needs administrative privileges).
57+
58+
```bash
59+
usbipd bind --busid 1-1
60+
```
61+
62+
Attach the device in the host terminal (needs already running instance of WSL).
63+
64+
```bash
65+
usbipd attach --wsl --busid 1-1
66+
```
67+
68+
Now you should be able to see the devkit in the WSL terminal. You can run `lsusb` command to check it. You can now start using the attached serial port directly in the WSL.
69+
70+
### Troubleshooting note
71+
72+
If is not possible to use the devkit, even after attaching, but it is visible with the `lsusb` command, you can run the following command in the WSL terminal:
73+
74+
```bash
75+
sudo modprobe cp210x
76+
```
77+
78+
This will add kernel module with the needed controller only for the current instance.
79+
80+
To add this permanently, it can be done with the following command:
81+
82+
```bash
83+
echo "cp210x" | sudo tee -a /etc/modules
84+
```
85+
86+
### Detach the USB
87+
88+
When you don't need to keep the devkit connected, you can detach the USB with this command:
89+
90+
```bash
91+
usbipd detach --busid 1-1
92+
```
93+
94+
## Conclusion
95+
96+
Working with WSL and Espressif's SoCs, 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 devkits from within WSL becomes necessary. When that happens, serial port forwarding can be employed.
97+
98+
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.
99+
100+
## Resources
101+
102+
- [Windows Subsystem for Linux Documentation](https://learn.microsoft.com/en-us/windows/wsl/)
103+
- [Microsoft documentation WSL - Connect USB devices](https://learn.microsoft.com/en-us/windows/wsl/connect-usb)
104+
- [USBIPD-WIN](https://github.com/dorssel/usbipd-win)

data/authors/jakub-kocka.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "Jakub Kocka",
3+
"image" : "img/authors/espressif.png",
4+
"social": [
5+
]
6+
}

0 commit comments

Comments
 (0)