Zeyu Gu
Tested on: Lenovo XiaoXinPro 16ACH 2021 Windows 11 21H2
Guide:
-
I use MinGW instead of NMake.
-
Download and install:
- PuTTY
- Arm GNU Toolchain (add path to environment variable)
- CMake (add CMake to the system PATH for all users)
- MinGW (.exe file; in the folder “bin”, copying the file “mingw32-make” and renaming it to “make”)
- Visual Studio 2022 (Desktop development with C++)
- Visual Studio Code
- Python 3.0 (install launcher for all users; add Python 3.10 to PATH; disable the MAX_PATH length limit)
- Git (use Visual Studio Code as Git’s default editor; allow Git to be used from 3rd-party software; checkout as is, commit as-is; use Window’s default console window; enable experimental support for pseudo consoles)
-
Create the folder “Pico” in C:\Users\gzyhk, and the folder “Downloads” in the folder “Pico”.
-
In System Properties > Environment Variables, edit Path (user variables for admin) and Path (system variables). Then add path:
- C:\MinGW\bin
- C:\Program Files (x86)\Arm GNU Toolchain arm-none-eabi\12.2 mpacbti-bet1\bin
- C:\Program Files\CMake\bin
-
In the cmd, getting sdk and examples:
- C:\Users\gzyhk\Pico\Downloads> git clone -b master https://github.com/raspberrypi/pico-sdk.git
- C:\Users\gzyhk\Pico\Downloads> cd pico-sdk
- C:\Users\gzyhk\Pico\Downloads\pico-sdk> git submodule update --init
- C:\Users\gzyhk\gzyhk\Pico\Downloads\pico-sdk> cd ..
- C:\Users\gzyhk\Pico\Downloads> git clone -b master https://github.com/raspberrypi/pico-examples.git
-
Building “Hello World” from the cmd:
- Open the Developer Command Prompt from VS Studio 2022. Then set the path: C:\Users\gzyhk\Pico\Downloads> setx PICO_SDK_PATH "..\..\pico-sdk". Restart the command prompt window.
- Build the “Hello World” example:
- The file “hello_usb.uf2” is produced in the directory C:\Users\gzyhk\Pico\Downloads\pico-examples\build\hello_world\usb.
-
Building “Hello World” from VS Code:
-
Open VS Code and install extensions: C/C++ and CMake Tools.
-
In CMake Tools’ extension settings > Cmake: Configure Environment, add item ”Item: PICO_SDK_PATH; Value: C:\Users\gzyhk\Pico\Downloads\pico-sdk”.
-
In CMake Tools’ extension settings > Cmake: Generator, add “MinGW Makefiles”.
-
In CMake Tools’ extension settings > Cmake: Mingw Search Dirs, add item “C:\MinGW”.
-
In VS Code, open the folder “pico-examples”. Press Ctrl+Shift+P and select “CMake: Select a Kit”. Then select “GCC 12.2.0 arm-none-eabi”.
-
Open CMake in the left side menu. Click the top button “Configure All Projects”. Building all projects takes too long time. I can select the folder “hello_world” > “usb” > “hello_usb”. Click the button “Build” near the folder.
-
The file “hello_usb.uf2” is produced in the directory C:\Users\gzyhk\Pico\Downloads\pico-examples\build\hello_world\usb.
-
-
Connect RP 2040. hold down the “BOOT” button on the board while pressing “RESET” to re-enter programming mode. Drag and drop the file “hello_usb.uf2” into the drive.
-
Open Device Manager. Click on Ports to check the number of COM#.
-
Open PuTTY:
- Connection type: Serial
- Serial line: COM5
- Speed: 115200
- Save the session as “COM5”
-
Click open. Now “Hello, world!” is appearing on the window.