当前位置: 首页 > news >正文

Windows11下搭建Raspberry Pi Pico编译环境

1. 系统与工具要求

PC平台: Windows 11 专业版

Windows GCC: gcc-15.1.0-64.exe

GNU Make: 4.3

Git: 2.49.0

cmake: 4.0.2

python:3.12.11

Arm GNU Toolchain Downloads – Arm Developer

 2. 工具安装与验证

2.1 工具安装

winget安装依赖工具(Windows Package Manager)

管理员身份 打开 cmd.exe或者PowerShell,运行:

winget install Kitware.CMake Ninja-build.Ninja python Git.Git 7zip.7zip Arm.GnuArmEmbeddedToolchain

windows安装包下载临时目录

C:\Users\Administrator\AppData\Local\Temp\WinGet

安装日志:

Microsoft Windows [版本 10.0.26100.4061]
(c) Microsoft Corporation。保留所有权利。C:\Users\Administrator>winget install Kitware.CMake Ninja-build.Ninja python Git.Git 7zip.7zip
找到已安装的现有包。正在尝试升级已安装的包...
找到已安装的现有包。正在尝试升级已安装的包...
找不到可用的升级。
配置的源中没有可用的较新的包版本。
已安装程序包: Ninja-build.Ninja
找到已安装的现有包。正在尝试升级已安装的包...
找不到可用的升级。
配置的源中没有可用的较新的包版本。
已安装程序包: python
找到已安装的现有包。正在尝试升级已安装的包...
找不到可用的升级。
配置的源中没有可用的较新的包版本。
已安装程序包: Git.Git
(1/1) 已找到 CMake [Kitware.CMake] 版本 4.0.3
此应用程序由其所有者授权给你。
Microsoft 对第三方程序包概不负责,也不向第三方程序包授予任何许可证。
正在下载 https://github.com/Kitware/CMake/releases/download/v4.0.3/cmake-4.0.3-windows-x86_64.msi██████████████████████████████  32.9 MB / 32.9 MB
已成功验证安装程序哈希
正在启动程序包安装...
已成功安装

GCC/Make安装

从http://www.equation.com/servlet/equation.cmd?fa=fortra 下载gcc套件,gcc套件内包含make,因为编译picotool需要gcc所以一并就装了这俩。

解压gcc套件,比如默认按照在了个人账户目录内为 C:\Users\Administrator\gcc

ARM GNU Toolchain:

arm-gnu-toolchain-14.2.rel1-mingw-w64-x86_64-arm-none-eabi.zip

7z.exe x "arm-gnu-toolchain-14.2.rel1-mingw-w64-x86_64-arm-none-eabi.zip" -o "arm-gnu-toolchain-14.2" -y

 2.2 工具验证

验证方法:

命令行中输入以下指令,会打印出版本信息

make -v
GNU Make 4.3cmake --version
cmake version 4.0.2git -v
git version 2.49.0.windows.1python -V
Python 3.12.11arm-none-eabi-gcc -v

3 SDK环境搭建

3.1 官方参考文档

在github中获取树莓派pico的sdk和example(内容可参考树莓派pico提供的资料)

pico/getting-started-with-pico.pdf

pico/pico-datasheet.pdf

pico/raspberry-pi-pico-c-sdk.pdf

pico/raspberry-pi-pico-python-sdk.pdf

rp2040/hardware-design-with-rp2040.pdf

rp2040/rp2040-datasheet.pdf

3.2 SDK源码获取

可通过官网获取以下信息

sdk github链接https://github.com/raspberrypi/pico-sdk

example github链接https://github.com/raspberrypi/pico-examples

通过git下载好sdk和example,进入pico-sdk中,git执行此条指令

git submodule update --init

该过程是更新sdk中第三方的库,例如usb、wifi等,更新内容在pico_sdk lib文件夹

3.3 编译

首先添加一下sdk环境变量将pico-sdk的文件路径添加PICO_SDK_PATH。

进入pico-examples参考工程目录

# 进入pico-examples文件夹中
cd D:\workspace\raspberrypi\pico-examples\
# 创建build目录
mkdir build
# 进入到build目录
cd build
# 生成Makefile文件
D:\workspace\raspberrypi\pico-examples\build>cmake -G "MinGW Makefiles" ..
Using PICO_SDK_PATH from environment ('D:\workspace\raspberrypi\pico-sdk')
PICO_SDK_PATH is D:/workspace/raspberrypi/pico-sdk
Defaulting platform (PICO_PLATFORM) to 'rp2040' since not specified.
Defaulting target board (PICO_BOARD) to 'pico' since not specified.
Using board configuration from D:/workspace/raspberrypi/pico-sdk/src/boards/include/boards/pico.h
Pico Platform (PICO_PLATFORM) is 'rp2040'.
-- Defaulting build type to 'Release' since not specified.
Defaulting compiler (PICO_COMPILER) to 'pico_arm_cortex_m0plus_gcc' since not specified.
Configuring toolchain based on PICO_COMPILER 'pico_arm_cortex_m0plus_gcc'
Defaulting PICO_GCC_TRIPLE to 'arm-none-eabi'
-- The C compiler identification is GNU 14.2.1
-- The CXX compiler identification is GNU 14.2.1
-- The ASM compiler identification is GNU
-- Found assembler: D:/workspace/zephyrproject/zephyr-sdk/arm-none-eabi-gcc-14.2.1/bin/arm-none-eabi-gcc.exe
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: D:/workspace/zephyrproject/zephyr-sdk/arm-none-eabi-gcc-14.2.1/bin/arm-none-eabi-gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: D:/workspace/zephyrproject/zephyr-sdk/arm-none-eabi-gcc-14.2.1/bin/arm-none-eabi-g++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
Build type is Release
-- Found Python3: C:/Users/Administrator/AppData/Local/Programs/Python/Python313/python.exe (found version "3.13.4") found components: Interpreter
TinyUSB available at D:/workspace/raspberrypi/pico-sdk/lib/tinyusb/src/portable/raspberrypi/rp2040; enabling build support for USB.
BTstack available at D:/workspace/raspberrypi/pico-sdk/lib/btstack
cyw43-driver available at D:/workspace/raspberrypi/pico-sdk/lib/cyw43-driver
lwIP available at D:/workspace/raspberrypi/pico-sdk/lib/lwip
mbedtls available at D:/workspace/raspberrypi/pico-sdk/lib/mbedtls
CMake Warning at D:/workspace/raspberrypi/pico-sdk/tools/Findpicotool.cmake:30 (message):No installed picotool with version 2.1.1 found - building from sourceIt is recommended to build and install picotool separately, or to setPICOTOOL_FETCH_FROM_GIT_PATH to a common directory for all your SDKprojects
Call Stack (most recent call first):D:/workspace/raspberrypi/pico-sdk/tools/CMakeLists.txt:138 (find_package)D:/workspace/raspberrypi/pico-sdk/tools/CMakeLists.txt:493 (pico_init_picotool)D:/workspace/raspberrypi/pico-sdk/src/cmake/on_device.cmake:56 (picotool_postprocess_binary)blink/CMakeLists.txt:13 (pico_add_extra_outputs)# 由于下载https://github.com/raspberrypi/picotool.git非常困难
# 这里需要修改pico-sdk目录下的tools/Findpicotool.cmake文件
# 使用https://gitee.com/msntec/picotool.git镜像源替换
Downloading Picotool
Only building blink_any for non W boards as PICO_CYW43_SUPPORTED is not set
Skipping encrypted example which is unsupported on this platform
Skipping hello_dcp example which is unsupported on this platform
Skipping runtime_flash_permissions example which is unsupported on this platform
Skipping dvi_out_hstx_encoder example which is unsupported on this platform
Skipping spi_lcd example which is unsupported on this platform
Skipping multicore_doorbell example which is unsupported on this platform
Skipping hello_otp example which is unsupported on this platform
Skipping boot_info example which is unsupported on this platform
Skipping universal examples as PICO_RISCV_TOOLCHAIN_PATH and PICO_ARM_TOOLCHAIN_PATH are not defined
Skipping TinyUSB dual examples, as TinyUSB hw/mcu/raspberry_pi/Pico-PIO-USB submodule unavailable
Skipping SHA256 examples as pico_sha256 or pico_mbedtls unavailable
Skipping FreeRTOS examples as FREERTOS_KERNEL_PATH not defined
-- Configuring done (53.7s)
-- Generating done (30.2s)
-- Build files have been written to: D:/workspace/raspberrypi/pico-examples/build

 会遇到pico-tool下载问题,请使用下面资源替代

D:\msys64\home\Weston\pico-sdk> git diff tools/Findpicotool.cmake
warning: in the working copy of 'tools/Findpicotool.cmake', LF will be replaced by CRLF the next time Git touches it
diff --git a/tools/Findpicotool.cmake b/tools/Findpicotool.cmake
index e5bfaea..cbc2e3a 100644
--- a/tools/Findpicotool.cmake
+++ b/tools/Findpicotool.cmake
@@ -36,7 +36,7 @@ if (NOT TARGET picotool)message("Downloading Picotool")FetchContent_Populate(picotool QUIET
-            GIT_REPOSITORY https://github.com/raspberrypi/picotool.git
+            GIT_REPOSITORY https://gitee.com/msntec/picotool.gitGIT_TAG developSOURCE_DIR ${picotool_INSTALL_DIR}/picotool-src

进入到build目录下的blink工程

接着执行编译指令,不出意外,接着就是刷刷的编译时间

make -j4Building ASM object pico-sdk/src/rp2040/boot_stage2/CMakeFiles/bs2_default.dir/compile_time_choice.S.obj
Built target picotoolForceReconfigure
Creating directories for 'picotoolBuild'
Linking ASM executable bs2_default.elf
No download step for 'picotoolBuild'
No update step for 'picotoolBuild'
Built target bs2_default
No patch step for 'picotoolBuild'
Generating bs2_default.bin
Generating bs2_default_padded_checksummed.S
Performing configure step for 'picotoolBuild'
Not searching for unused variables given on the command line.
Building ASM object pico-sdk/src/rp2040/boot_stage2/CMakeFiles/bs2_default_library.dir/bs2_default_padded_checksummed.S.obj
Built target bs2_default_library
-- The C compiler identification is GNU 15.1.0
-- The CXX compiler identification is GNU 15.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Users/Administrator/gcc/bin/gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Users/Administrator/gcc/bin/c++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Using the single-header code from D:/workspace/raspberrypi/pico-examples/build/_deps/picotool-src/lib/nlohmann_json/single_include/
PICOTOOL_NO_LIBUSB is set - no USB support will be built
-- Configuring done (5.3s)
-- Generating done (0.4s)
-- Build files have been written to: D:/workspace/raspberrypi/pico-examples/build/_deps/picotool-build
Performing build step for 'picotoolBuild'
-- The C compiler identification is GNU 15.1.0
[  2%] Built target errors
-- The C compiler identification is GNU 15.1.0
-- The CXX compiler identification is GNU 15.1.0
-- The CXX compiler identification is GNU 15.1.0
-- The ASM compiler identification is GNU
-- The ASM compiler identification is GNU
-- Found assembler: C:/Users/Administrator/gcc/bin/gcc.exe
-- Found assembler: C:/Users/Administrator/gcc/bin/gcc.exe
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Users/Administrator/gcc/bin/gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working C compiler: C:/Users/Administrator/gcc/bin/gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Users/Administrator/gcc/bin/c++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working CXX compiler: C:/Users/Administrator/gcc/bin/c++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
Using precompiled enc_bootloader.elf
-- Configuring done (4.3s)
-- Generating done (0.0s)
-- Build files have been written to: D:/workspace/raspberrypi/pico-examples/build/_deps/picotool-build/enc_bootloader
Using precompiled enc_bootloader.elf
-- Configuring done (4.4s)
-- Generating done (0.0s)
-- Build files have been written to: D:/workspace/raspberrypi/pico-examples/build/_deps/picotool-build/enc_bootloader_mbedtls
[  4%] Built target elf
[ 11%] Built target enc_bootloader
[ 18%] Built target enc_bootloader_mbedtls
[ 20%] Built target embedded_data_no_libusb
[ 22%] Built target elf2uf2
[ 90%] Built target mbedtls
[ 92%] Built target bintool
[100%] Built target picotool
Performing install step for 'picotoolBuild'
[  2%] Built target errors
[ 70%] Built target mbedtls
[ 72%] Built target elf
[ 79%] Built target enc_bootloader
[ 81%] Built target elf2uf2
[ 88%] Built target enc_bootloader_mbedtls
[ 90%] Built target bintool
[ 92%] Built target embedded_data_no_libusb
[100%] Built target picotool
Install the project...
-- Install configuration: "Release"
Performing test step for 'picotoolBuild'
picotool v2.1.2-develop (Windows, GNU-15.1.0, Release)
Completed 'picotoolBuild'
Built target picotoolBuild
Building C object blink/CMakeFiles/blink.dir/blink.c.obj
......
......
Linking CXX executable blink.elf
Built target blinkD:\workspace\raspberrypi\pico-examples\build\blink>dirVolume in drive D is DATAVolume Serial Number is 0EFA-D4A2Directory of D:\workspace\raspberrypi\pico-examples\build\blink2025/06/18  21:08    <DIR>          .
2025/06/18  21:06    <DIR>          ..
2025/06/18  21:08             6,764 blink.bin
2025/06/18  21:08           125,987 blink.dis
2025/06/18  21:08           351,204 blink.elf
2025/06/18  21:08           398,194 blink.elf.map
2025/06/18  21:08            19,091 blink.hex
2025/06/18  21:08            13,824 blink.uf2
2025/06/18  21:07    <DIR>          CMakeFiles
2025/06/18  21:05             1,551 cmake_install.cmake
2025/06/18  21:05           118,156 Makefile
2025/06/18  21:05    <DIR>          picotool8 File(s)      1,034,771 bytes4 Dir(s)  3,577,542,651,904 bytes free

下载方法:按住BOOT键进行上电,使电脑弹出虚拟U盘,将.uf2文件拖拽到树莓派pico的虚拟U盘中,这时树莓派pico会自动重启,运行下载后的程序。

到此,整个树莓派pico的基础环境就算搭建完成啦。

相关文章:

  • AutoHotkey 脚本生成器:一键打开网页到指定位置(v2版本:自定义位置)
  • C语言——枚举
  • 基于python的web系统界面登录
  • 前端开发面试题总结-vue2框架篇(四)
  • 利用Java进行验证码的实现——字母数字验证码
  • FPGA基础 -- Verilog 数据流建模
  • WPF入门 #1 WPF布局基础、WPF样式基础、WPF控件模板、WPF数据模板
  • Python笔记1
  • 影刀rpa-3步获取社区信息
  • Dify动手实战教程(入门-猜病、哄哄模拟器)
  • singlefligt使用方法和源码解读
  • MySQL 索引和select优化
  • vuex中的辅助函数怎样使用
  • P7 QT项目----会学天气预报
  • 初识树及二叉树
  • 18.字符串函数
  • 【Redis】持久化机制:RDB / AOF 的应用与场景
  • 48-Oracle CDB下的SID-实例名-服务名
  • LVS+Keepliaved高可用群集
  • 【web应用】Vue 3 中实现 Chart.js 柱状图:详细指南
  • 泰国做那个视频网站/合肥网站推广公司排名
  • 长春网站seo哪家好/大量微信群推广代发广告
  • 无锡做网站 选众诺/优化seo搜索
  • 新手怎么做html5网站/网络销售怎么做
  • dede企业网站带留言板后台查询/海南百度推广公司
  • 旅游网站建设费用/学网络运营在哪里学比较好