supermileage / pico-samples

A sample program for the Raspberry Pi Pico that blinks an LED using programmable I/O
0 stars 0 forks source link

Figure out how to get the pico w working with platformIO on windows #1

Open cosparks opened 1 year ago

cosparks commented 1 year ago

I've made some progress. There is a separate arduino-pico core which isn’t officially (yet) supported by platformIO. They have some instructions for setting it up here:

https://arduino-pico.readthedocs.io/en/latest/platformio.html

And there’s some more information about this core in its platformIO PR:

https://github.com/platformio/platform-raspberrypi/pull/36

tldr: the Earlephilhower arduino-pico project was originally intended to extend pico support in arduinoIDE. Some platformIO users have taken on the task of writing the scripts necessary to get this set up and working with platformIO. There are still some issues (as you can see the PR hasn't been merged yet).

I managed to flash the blink-led sketch directly from arduinoIDE without having to drag and drop anything. But with platformIO I still have to drag and drop the compiled firmware.uf2 file, even with the new core.

I doubt this is a driver issue: clearly if I was able to flash directly from arduinoIDE, I must just have something misconfigured in the platformio.ini file. Will have another look soon.

cosparks commented 1 year ago

You can check the platformio.ini file in the pio-blink-arduino folder on the sandbox_windows branch if you want to try using the new core. (I don't think the drag and drop is actually that inconvenient: when you flash, file explorer automatically opens a window for you to drag and drop the firmare.uf2 file into)

silviu-toderita commented 1 year ago

The default pico library for PlatformIO uses a program called "picotool" to upload sketches over serial. There's some discussion on this page about compatibility with windows: https://arduino-pico.readthedocs.io/en/latest/install.html

It should apparently work with Windows 10 but not Windows 7. @underscoreHasan are you using Windows 7 by any chance? If so, you might have to follow the instructions on there to get it working.

silviu-toderita commented 1 year ago

I've done some more digging and found a pretty comprehensive guide for getting serial communication to work on Windows: https://tutoduino.fr/en/pico-platformio/

Problem is, it's not working for me. I can drag and drop firmware onto the pico "drive" that shows up, but I can't flash over serial. This is on Windows 10 on a VM on my Mac. I'm not sure that I have any better solution than this right now.

cosparks commented 1 year ago

That's where I'm at too on my windows pc. I can flash directly in arduinoIDE but have to drag and drop with platformIO

maxgerhardt commented 1 year ago

I doubt this is a driver issue: clearly if I was able to flash directly from arduinoIDE, I must just have something misconfigured in the platformio.ini file. Will have another look soon.

If rp2040load can't upload your binary even after you initially uploaded the .uf2 file for it (so that reset-via-1200bps-touch works), you need to make sure to have the correct drivers loaded using Zadig per this.

underscoreHasan commented 1 year ago

Got the blink sketch working in ArduinoIDE. looks like the problem in VSCode + platformio is something to do with drivers since platformio cant pick up the board on a COM port (even after installing drivers via Zadig) but ArduinoIDE can just fine

Edit: Got the pio-blink-arduino project to flash in PlatformIO with no need to drag and drop. Looks like installing the Zadig drivers and then connecting while holding BOOTSEL made it work image

cosparks commented 1 year ago

@maxgerhardt thanks for dropping in! I've tried plugging the pico w in while holding bootsel, then installing that libusb-win32 (v1.2.6.0) for 'RP2 Boot2 (Interface 1)', but even after initially dragging and dropping my project's .uf2 file I haven't been able to flash it directly. Flashing with platformIO puts the device in bootsel mode, so it no longer shows up as a usb serial device.


...
CURRENT: upload_protocol = picotool
Looking for upload port...
Using manually specified: COM4
Forcing reset using 1200bps open/close on port COM4
Uploading .pio\build\pico\firmware.elf
rp2040load 1.0.1 - compiled with go1.15.8
.....................
*** [upload] Error 1
cosparks commented 1 year ago

Running windows 10 btw

maxgerhardt commented 1 year ago

Same when you install WinUSB drivers instead of libusb-win32?

Is COM4 the right device?