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的基礎環境就算搭建完成啦。