earlephilhower / arduino-pico

Raspberry Pi Pico Arduino core, for all RP2040 and RP2350 boards
GNU Lesser General Public License v2.1
2.06k stars 431 forks source link

Uploading to Raspberry Pi Pico from platformio gives error 1 #520

Closed Sciman101 closed 2 years ago

Sciman101 commented 2 years ago

I'm trying to move my development from the Arduino IDE, which has worked fine with arduino-pico for me, to platformio, and followed the example platformio.ini given on the docs to try and upload a simple blink sketch, no dependencies. Every time I upload, it gets to this point

Use manually specified: COM9
Forcing reset using 1200bps open/close on port COM9
Uploading .pio\build\pico\firmware.elf
rp2040load 1.0.1 - compiled with go1.15.8
.....................
*** [upload] Error 1

and fails. There's no obvious error in the rest of the log, and in fact the code itself compiles fine. When I manually copy the compiled firmware.uf2 to the pico, it loads the blink sketch without issue. I've tried uploading in and out of BOOTSEL mode, though I'd previously uploaded arduino-pico code to this device so I'd assume I wouldn't need to use BOOTSEL. I've reinstalled my platformio extension, ran in verbose mode, used automatic port finding and manual port config, and force disabled USB mode, and nothing seems to work.

Has anyone else ran into this issue, and is there something I'm missing? My platformio.ini is exactly the same as the one listed here

Gavin-Perry commented 2 years ago

Looks like your baud rate is far to low. Also be sure it matches at both ends.

-- Gavin Perry, PhD Chief Technology Officer Meridian Electric Company 2392 Grissom Drive St Louis MO 63146 http://meridianlighting.com cell: 314 406-0697 http://voice.google.com/calls?a=nc,%2B13144060697

On Sun, Mar 20, 2022 at 10:15 AM Yali Izzo @.***> wrote:

I'm trying to move my development from the Arduino IDE, which has worked fine with arduino-pico for me, to platformio, and followed the example platformio.ini given on the docs to try and upload a simple blink sketch, no dependencies. Every time I upload, it gets to this point

Use manually specified: COM9 Forcing reset using 1200bps open/close on port COM9 Uploading .pio\build\pico\firmware.elf rp2040load 1.0.1 - compiled with go1.15.8 ..................... *** [upload] Error 1

and fails. There's no obvious error in the rest of the log, and in fact the code itself compiles fine. When I manually copy the compiled firmware.uf2 to the pico, it loads the blink sketch without issue. I've tried uploading in and out of BOOTSEL mode, though I'd previously uploaded arduino-pico code to this device so I'd assume I wouldn't need to use BOOTSEL. I've reinstalled my platformio extension, ran in verbose mode, used automatic port finding and manual port config, and force disabled USB mode, and nothing seems to work.

Has anyone else ran into this issue, and is there something I'm missing? My platformio.ini is exactly the same as the one listed here https://arduino-pico.readthedocs.io/en/latest/platformio.html

— Reply to this email directly, view it on GitHub https://github.com/earlephilhower/arduino-pico/issues/520, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVR4PPYQBM3PG5OT5JX4BMLVA46HZANCNFSM5RFUKC6Q . You are receiving this because you are subscribed to this thread.Message ID: @.***>

earlephilhower commented 2 years ago

the 1200baud is correct. It is just what is used to reset the chip as a doorbell knock. There is no serial upload on this chip, just UF2 copy.

Sciman101 commented 2 years ago

So, do I just need to manually copy the file each time I compile?

maxgerhardt commented 2 years ago

For the first flashing you can copy the .uf2 file from .pio\build\pico\ to the Pico, starting from then, the upload should work without any additional work automatically (give the WinUSB drivers are installed for the Pico on bootloader mode). Same as in https://community.platformio.org/t/arduino-rp4020-connect-upload-error/26655.

Sciman101 commented 2 years ago

Tried that just now, doesn't seem to work - are the WinUSB drivers installed automatically or do I need to do that on my own?

maxgerhardt commented 2 years ago

If you at least installed the Arduino-pico core in the Arduino IDE, they are installed. Otherwise, plug in your Pico in bootloader mode (BOOTSEL button pressed then plugged in) and use Zadig (https://zadig.akeo.ie/) to load WinUSB drivers for the "RP2 Boot2 (Interface 1)" device.

earlephilhower commented 2 years ago

Is anything at all needed for UF2 upload, though? In bootloader mode it presents itself as a MSD (mass storage device, aka USB stick) which should "just work," no?

maxgerhardt commented 2 years ago

In bootloader mode

Exactly, in bootloader mode. To get back in bootloader mode, PlatformIO and the core uses a 1200bps UART reset mechanism, and after that, PlatformIO doesn't use the mass storage device, but instructs picotool to load the binary onto it, which requires WinUSB or libusb-win32 drivers to be loaded for it. At least in the default settings.

Sciman101 commented 2 years ago

Hm, I flashed a blink sketch with the Arduino IDE, then tried flashing the same sketch with different timing from platformio. Same error as before, it successfully autodetected the port and managed to enter bootloader mode so tbh I'm not sure what's going on

maxgerhardt commented 2 years ago

And after PlatformIO has reset the device in the bootloader, Zadig shows that the RP2 Boot2 Interace 1 device has still WinUSB drivers loaded?

Sciman101 commented 2 years ago

I haven't tried Zadig yet, gonna give that a go now

Sciman101 commented 2 years ago

Should have just tried that from the start, works perfectly now. Thanks for the help!