3. Compile Project
This chapter will guide you through compiling the project source code to generate flashable firmware files.
Note
Before starting compilation, please ensure you have completed all steps in 1. Development Environment Setup
Compilation Preparation
Confirm that you have:
✅ Installed Pico SDK and development toolchain
✅ Set the
PICO_SDK_PATHenvironment variable✅ Downloaded the project source code (including submodules)
Quick Start
If you have already configured the environment, you can directly execute the following commands to compile:
cd ~/LAFVIN-PICO-Development-Kit
mkdir build
cd build
cmake --no-warn-unused-cli \
-DPICO_OPTIMIZED_DEBUG=1 \
-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE \
-DCMAKE_BUILD_TYPE:STRING=Debug \
../
make -j4
Detailed Compilation Steps
Step 1: Enter Project Directory
cd ~/LAFVIN-PICO-Development-Kit
Confirm you are in the project root directory, you should see the CMakeLists.txt file.
Step 2: Create Build Directory
mkdir build
cd build
Tip
Using a separate build directory keeps the source code directory clean and makes it easy to clean and recompile.
Step 3: Run CMake Configuration
cmake --no-warn-unused-cli \
-DPICO_OPTIMIZED_DEBUG=1 \
-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE \
-DCMAKE_BUILD_TYPE:STRING=Debug \
../
Parameter descriptions:
--no-warn-unused-cli: Ignore warnings for unused parameters-DPICO_OPTIMIZED_DEBUG=1: Enable optimized debug mode (very important, affects display and peripheral timing)-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE: Generate compilation command database (IDE support)-DCMAKE_BUILD_TYPE:STRING=Debug: Set to debug version
This command will:
Check compilation environment and dependencies
Find Pico SDK
Configure FreeRTOS and LVGL
Generate Makefile
You should see the following output:
Attention
If you see a PICO_SDK_PATH not found error, please return to 1. Development Environment Setup to check environment variable settings.
Step 4: Compile Project
make -j4
Parameter description:
-j4: Use 4 parallel tasks to accelerate compilation (can be adjusted based on CPU cores)
The compilation process takes approximately 2-3 minutes, you will see the following output:
Step 5: Verify Compilation Results
After successful compilation, check the generated files:
ls -lh *.uf2
You should see the following file:
hello_world.uf2- This is the firmware file that can be flashed to Pico
# View file size
-rw-r--r-- 1 pi pi 1.3M Nov 5 10:46 hello_world.uf2
Recompilation
Clean and Recompile
If you need to completely recompile:
cd build
rm -rf *
cmake --no-warn-unused-cli \
-DPICO_OPTIMIZED_DEBUG=1 \
-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE \
-DCMAKE_BUILD_TYPE:STRING=Debug \
../
make -j4
Incremental Compilation
If you only modified part of the code, run directly:
cd build
make -j4
Compilation Output Description
After successful compilation, the build directory will contain the following files:
File |
Description |
|---|---|
|
UF2 firmware file (flash to Pico) |
|
ELF format executable file (for debugging) |
|
Binary firmware file |
|
HEX format firmware file |
|
Memory map file |
Next Steps
After successful compilation, you can:
Flash Firmware: Refer to the flashing steps in 1. Quick Start Guide
Modify Code: Learn about 2. Code Structure Overview for secondary development
Tip
It is recommended to backup the compiled hello_world.uf2 file for future use.