Skip to content

Commit d5583ef

Browse files
JurajSadeljessebraham
authored andcommitted
Support WSL2 flashing for NON-usb-serial-jtag chips
1 parent 097c6ff commit d5583ef

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

cargo-espflash/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ vid = "303A"
104104
pid = "8000"
105105
```
106106

107+
## WSL2
108+
It is not possible to flash `usb-serial-jtag` chips with `WSL2` because the reset also resets `serial-jtag-peripheral` which disconnects the chip from WSL2.
109+
107110
## Package Metadata
108111

109112
You can specify the bootloader, partition table, or image format for a project in the package metadata in `Cargo.toml`:

espflash/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ vid = 12346 # 0x303A
8787
pid = 32768 # 0x8000
8888
```
8989

90+
## WSL2
91+
It is not possible to flash `usb-serial-jtag` chips with `WSL2` because the reset also resets `serial-jtag-peripheral` which disconnects the chip from WSL2.
92+
9093
## Use as a Cargo Runner
9194

9295
You can also use `espflash` as a Cargo runner by adding the followin to your project's `.cargo/config` file:

espflash/src/cli/mod.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::{
1111
use clap::Parser;
1212
use config::Config;
1313
use miette::{IntoDiagnostic, Result, WrapErr};
14-
use serialport::{FlowControl, SerialPortType};
14+
use serialport::{FlowControl, SerialPortType, UsbPortInfo};
1515
use strum::VariantNames;
1616

1717
use crate::{
@@ -99,6 +99,16 @@ pub fn connect(opts: &ConnectOpts, config: &Config) -> Result<Flasher> {
9999
// can just pretend the remaining types don't exist here.
100100
let port_info = match port_info.port_type {
101101
SerialPortType::UsbPort(info) => info,
102+
SerialPortType::Unknown => {
103+
println!("Matched SerialPortType::Unknown");
104+
UsbPortInfo {
105+
vid: 0,
106+
pid: 0,
107+
serial_number: None,
108+
manufacturer: None,
109+
product: None,
110+
}
111+
}
102112
_ => unreachable!(),
103113
};
104114

espflash/src/cli/serial.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,12 @@ fn detect_usb_serial_ports() -> Result<Vec<SerialPortInfo>> {
132132
let ports = available_ports().into_diagnostic()?;
133133
let ports = ports
134134
.into_iter()
135-
.filter(|port_info| matches!(&port_info.port_type, SerialPortType::UsbPort(..)))
135+
.filter(|port_info| {
136+
matches!(
137+
&port_info.port_type,
138+
SerialPortType::UsbPort(..) | SerialPortType::Unknown
139+
)
140+
})
136141
.collect::<Vec<_>>();
137142

138143
Ok(ports)
@@ -214,6 +219,13 @@ fn select_serial_port(
214219
let port_name = port.port_name.clone();
215220
let port_info = match &port.port_type {
216221
SerialPortType::UsbPort(info) => info,
222+
SerialPortType::Unknown => &UsbPortInfo {
223+
vid: 0,
224+
pid: 0,
225+
serial_number: None,
226+
manufacturer: None,
227+
product: None,
228+
},
217229
_ => unreachable!(),
218230
};
219231

0 commit comments

Comments
 (0)