JoNil / elf2uf2-rs

BSD Zero Clause License
81 stars 31 forks source link

WSL support needed, Unable to find mounted pico. #10

Open HughGrant opened 2 years ago

HughGrant commented 2 years ago

Hi, my dev ENV is setup in WSL2.0, even though my pi pico is correctly showing up in windows, it still give this error in my WSL Ubuntu20.04

Anyway how to quick fix this?

Cryowatt commented 2 years ago

Here's a workaround you (and anyone else who stumbles across this issue) can use:

Add a shell script runner.sh.

#!/bin/sh
mkdir -p ./target/publish/
elf2uf2-rs $1 ./target/publish/image.uf2

Update runner in .cargo/config.toml file to look like this:

[target.thumbv6m-none-eabi]
# ...
runner = "./runner.sh"

When you run cargo run it will run elf2uf2-rs to package and publish the uf2 file to the target/publish/ path. This doesn't put it onto the USB device, but that's just a simple copy command away. I couldn't find an easy way to mount a USB drive in WSL2, so I'm personally living with the extra copy step for now.

HughGrant commented 2 years ago

@Cryowatt this is actually a good solution.

cgxeiji commented 1 year ago

In WSL, you can mount the drive where pico shows on Windows. For example, if pico mounts to D:\ drive, you can do:

$ sudo mkdir -p /mnt/pico
$ sudo mount -t drvfs d: /mnt/pico

You can automate this process by creating a custom runner.sh:

#!/bin/sh
sudo mkdir -p /mnt/pico
sudo mount -t drvfs d: /mnt/pico
elf2uf2-rs -d $1

and updating your .cargo/config.toml to:

runner = "./runner.sh"

Don't forget to:

$ chmod +x runner.sh

to make it executable!