You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用PlatformIO向Raspberry Pi Pico上传代码时出现[upload] Error 1错误

Raspberry Pi Pico PlatformIO上传失败解决办法

问题背景

  • 开发环境:VSCode + PlatformIO,目标设备Raspberry Pi Pico
  • 异常现象:此前代码上传正常,修改代码后编译无报错,但上传失败;测试极简blink程序仍无法上传
  • 排除项:Thonny可正常上传Python代码,说明硬件设备、USB线缆无问题,问题锁定在VSCode/PlatformIO配置或工具链

错误输出

Processing pico (platform: raspberrypi; board: pico; framework: arduino)
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/raspberrypi/pico.html
PLATFORM: Raspberry Pi RP2040 (1.9.0) > Raspberry Pi Pico
HARDWARE: RP2040 133MHz, 264KB RAM, 2MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, jlink, raspberrypi-swd)
PACKAGES:
 - framework-arduino-mbed @ 4.0.2
 - tool-openocd-raspberrypi @ 2.1100.0 (11.0)
 - tool-rp2040tools @ 1.0.2
 - toolchain-gccarmnoneeabi @ 1.90201.191206 (9.2.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 41 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Checking size .pio\build\pico\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [==        ]  15.1% (used 40740 bytes from 270336 bytes)
Flash: [          ]   0.2% (used 4034 bytes from 2097152 bytes)
Configuring upload protocol...
AVAILABLE: cmsis-dap, jlink, picotool, raspberrypi-swd
CURRENT: upload_protocol = picotool
Looking for upload port...
Using manually specified: COM8
Forcing reset using 1200bps open/close on port COM8
Uploading .pio\build\pico\firmware.elf
rp2040load 1.0.1 - compiled with go1.15.8
.....................
*** [upload] Error 1
================================================================================ [FAILED] Took 11.99 seconds ================================================================================
 *  The terminal process "C:\Users\dylan\.platformio\penv\Scripts\platformio.exe 'run', '--target', 'upload', '--upload-port', 'COM8'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it.

当前PlatformIO配置(platformio.ini)

[env:pico]
platform = raspberrypi
board = pico
framework = arduino
upload_protocol = picotool

排查与解决步骤

  1. 切换上传协议
    当前使用的picotool协议可能存在兼容性问题,修改platformio.ini更换为cmsis-dap协议:

    [env:pico]
    platform = raspberrypi
    board = pico
    framework = arduino
    upload_protocol = cmsis-dap
    

    保存配置后重新尝试上传。

  2. 手动进入BOOTSEL模式上传

    • 按住Pico上的BOOTSEL按钮,重新插拔USB,设备会进入U盘模式
    • 编译项目后,找到.pio\build\pico\路径下的firmware.uf2文件,将其拖入Pico的U盘驱动器中
    • 若此方法能正常运行程序,说明是PlatformIO自动上传脚本的问题,可继续排查工具链
  3. 更新PlatformIO工具链

    • 打开PlatformIO Home,进入Platforms页面,找到Raspberry Pi RP2040平台,点击更新至最新版本(当前使用的1.9.0版本较旧,新版本修复了大量上传相关问题)
    • 同步更新tool-rp2040tools工具,错误日志中使用的rp2040load 1.0.1存在已知兼容性缺陷
  4. 取消手动指定串口端口
    上传时去掉--upload-port COM8参数,让PlatformIO自动检测设备端口,避免端口识别错误。

  5. 检查Windows串口权限

    • 打开设备管理器,找到COM8对应的Pico设备,右键选择「更新驱动程序」,安装官方USB串行驱动
    • 以管理员身份运行VSCode,避免权限不足导致无法访问串口设备

内容的提问来源于stack exchange,提问作者Davandjes

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.08 17:07:51