29集【重要】 ESP-IDF cmake编译流程梳理-《MCU嵌入式AI开发笔记》
ESP-IDF的cmake流程梳理
1、最上层ai-chat目录下的CMakeLists.txt:
2、d:\Espressif\frameworks\esp-idf-v5.2.2\tools\cmake\project.cmake
-》targets.cmake(d:\Espressif\frameworks\esp-idf-v5.2.2\tools\cmake\targets.cmake)
-》idf.cmake(d:\Espressif\frameworks\esp-idf-v5.2.2\tools\cmake\idf.cmake)
-》include(build)
set(IDF_PATH KaTeX parse error: Expected group after '_' at position 434: ...on) _̲_build_init("{idf_path}")
-》 idf_build_process( I D F T A R G E T S D K C O N F I G D E F A U L T S " {IDF_TARGET} SDKCONFIG_DEFAULTS " IDFTARGETSDKCONFIGDEFAULTS"{sdkconfig_defaults}"
SDKCONFIG ${sdkconfig}
BUILD_DIR ${build_dir}
PROJECT_NAME ${CMAKE_PROJECT_NAME}
PROJECT_DIR C M A K E C U R R E N T L I S T D I R P R O J E C T V E R " {CMAKE_CURRENT_LIST_DIR} PROJECT_VER " CMAKECURRENTLISTDIRPROJECTVER"{project_ver}"
COMPONENTS " c o m p o n e n t s ; {components}; components;{test_components}")
-》set(project_elf ${CMAKE_PROJECT_NAME}.elf)
-》foreach(build_component b u i l d c o m p o n e n t s ) t a r g e t l i n k l i b r a r i e s ( {build_components}) target_link_libraries( buildcomponents)targetlinklibraries({project_elf} PRIVATE
"-Wl,-force_load"
${build_component})
-》add_custom_target(size
COMMAND C M A K E C O M M A N D − D " I D F S I Z E T O O L = {CMAKE_COMMAND} -D "IDF_SIZE_TOOL= CMAKECOMMAND−D"IDFSIZETOOL={idf_size}"
-D "MAP_FILE= m a p f i l e " − D " O U T P U T J S O N = {mapfile}" -D "OUTPUT_JSON= mapfile"−D"OUTPUTJSON={OUTPUT_JSON}"
-P "${idf_path}/tools/cmake/run_size_tool.cmake"
DEPENDS ${mapfile}
USES_TERMINAL
VERBATIM
)
-》__add_dfu_targets()
-》idf_build_executable(${project_elf})
重要的log
menuconfig的log
[SDK Configuration Editor]
---------------------------ERROR--------------------------
WARNING: Python interpreter "D:\Espressif\python_env\idf5.2_py3.11_env\Scripts\python.exe" used to start idf.py is not from installed venv "D:/Espressif/python_env/idf5.2_py3.11_env"
-----------------------END OF ERROR-----------------------
Executing action: confserver
Running cmake in directory D:\workspace\esp-idf\ai_chat\build
Executing "cmake -G Ninja -DPYTHON_DEPS_CHECKED=1 -DPYTHON=D:\Espressif\python_env\idf5.2_py3.11_env\Scripts\python.exe -DESP_PLATFORM=1 -DCCACHE_ENABLE=1 D:\workspace\esp-idf\ai_chat"...
-- Found Git: D:/Espressif/tools/idf-git/2.44.0/cmd/git.exe (found version "2.44.0.windows.1")
-- ccache will be used for faster recompilation
-- The C compiler identification is GNU 13.2.0
-- The CXX compiler identification is GNU 13.2.0
-- The ASM compiler identification is GNU
-- Found assembler: D:/Espressif/tools/riscv32-esp-elf/esp-13.2.0_20230928/riscv32-esp-elf/bin/riscv32-esp-elf-gcc.exe
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: D:/Espressif/tools/riscv32-esp-elf/esp-13.2.0_20230928/riscv32-esp-elf/bin/riscv32-esp-elf-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:/Espressif/tools/riscv32-esp-elf/esp-13.2.0_20230928/riscv32-esp-elf/bin/riscv32-esp-elf-g++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- git rev-parse returned 'fatal: not a git repository (or any of the parent directories): .git'
-- Could not use 'git describe' to determine PROJECT_VER.
-- Building ESP-IDF components for target esp32c3
Processing 7 dependencies:
[1/7] espressif/esp-dsp (1.4.12)
[2/7] espressif/esp_lcd_touch (1.1.2) from file:///D:/Espressif/registry
[3/7] espressif/esp_lcd_touch_ft5x06 (1.0.6)
[4/7] espressif/jsmn (1.1.0)
[5/7] espressif/nghttp (1.62.1)
[6/7] idf (5.2.2)
[7/7] lvgl/lvgl (8.3.11) from file:///D:/Espressif/registry
-- Project sdkconfig file D:/workspace/esp-idf/ai_chat/sdkconfig
Loading defaults file D:/workspace/esp-idf/ai_chat/sdkconfig.defaults...
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of time_t
-- Check size of time_t - done
-- Found Python3: D:/Espressif/python_env/idf5.2_py3.11_env/Scripts/python.exe (found version "3.11.2") found components: Interpreter
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
...
Build 的log
- 正在执行任务: D:\Espressif\tools\ninja
[0/1] Re-running CMake...-- ccache will be
-- git rev-parse returned 'fatal: not a gi
-- Could not use 'git describe' to determi
-- Building ESP-IDF components for target
Processing 7 dependencies:
[1/7] espressif/esp-dsp (1.4.12)
[2/7] espressif/esp_lcd_touch (1.1.2) from
[3/7] espressif/esp_lcd_touch_ft5x06 (1.0.
[4/7] espressif/jsmn (1.1.0)
[5/7] espressif/nghttp (1.62.1)
[6/7] idf (5.2.2)
[7/7] lvgl/lvgl (8.3.11) from file:///D:/E
-- Project sdkconfig file D:/workspace/esp
Loading defaults file D:/workspace/esp-idf
-- App "ai_chat" version: 1
-- Adding linker script D:/workspace/esp-i
-- Adding linker script D:/workspace/esp-i
-- Adding linker script D:/Espressif/frame
-- Adding linker script D:/Espressif/frame
-- Adding linker script D:/Espressif/frameld
-- Adding linker script D:/Espressif/frameld
-- Adding linker script D:/Espressif/frame.ld
-- Adding linker script D:/Espressif/frame-- Adding linker script D:/Espressif/frame
-- Chip is esp32c3, D:/Espressif/esp-adf/c
-- Current board name is CONFIG_AUDIO_BOAR
-- Components: adf_utils app_trace app_updo_stream battery_service bluetooth_service_service cxx display_service driver dueros_format esp_bootloader_format esp_codec_de
esp_gdbstub esp_hid esp_http_client esp_htcal_ctrl esp_mm esp_netif esp_netif_stack rom esp_system esp_timer esp_wifi espcoreuch_ft5x06 espressif__jsmn espressif__nght
input_key_service json log lvgl__lvgl lwipad ota_service partition_table playlist prort tone_partition ulp unity usb vfs wear
-- Component paths: D:/Espressif/esp-adf/capp_trace D:/Espressif/frameworks/esp-idf-rd D:/Espressif/esp-adf/components/audio_h/components/audio_recorder D:/Espressif/esm D:/Espressif/esp-adf/components/battery_/frameworks/esp-idf-v5.2.2/components/bootpport D:/Espressif/frameworks/esp-idf-v5.2rameworks/esp-idf-v5.2.2/components/cmock /esp-adf/components/coredump_upload_servicsp-adf/components/display_service D:/Esprecomponents/dueros_service D:/Espressif/fras/esp-adf-libs D:/Espressif/esp-adf/compon
D:/Espressif/esp-adf/components/esp_actionif/frameworks/esp-idf-v5.2.2/components/estloader_format D:/Espressif/esp-adf/componsp_coex D:/Espressif/frameworks/esp-idf-v5her D:/Espressif/frameworks/esp-idf-v5.2.2esp_event D:/Espressif/esp-adf/components/dbstub D:/Espressif/frameworks/esp-idf-v5.ts/esp_http_client D:/Espressif/frameworks-idf-v5.2.2/components/esp_https_ota D:/Esssif/frameworks/esp-idf-v5.2.2/components/cd D:/Espressif/frameworks/esp-idf-v5.2.2/nents/esp_mm D:/Espressif/frameworks/esp-icomponents/esp_netif_stack D:/Espressif/frcomponents/esp_peripherals D:/Espressif/fr-idf-v5.2.2/components/esp_pm D:/Espressifs/esp-idf-v5.2.2/components/esp_ringbuf D:rameworks/esp-idf-v5.2.2/components/esp_sypressif/frameworks/esp-idf-v5.2.2/componenump D:/workspace/esp-idf/ai_chat/managed_conents/espressif__esp_lcd_touch D:/workspapace/esp-idf/ai_chat/managed_components/esf__nghttp D:/Espressif/frameworks/esp-idf-mponents/fatfs D:/Espressif/frameworks/esp/components/hal D:/Espressif/frameworks/esmponents/http_parser D:/Espressif/frameworv5.2.2/components/ieee802154 D:/Espressif/5.2.2/components/json D:/Espressif/framewo_components/lvgl__lvgl D:/Espressif/framew
D:/Espressif/frameworks/esp-idf-v5.2.2/com D:/workspace/esp-idf/ai_chat/components/mpressif/frameworks/esp-idf-v5.2.2/componen_provider D:/Espressif/frameworks/esp-idf-ce D:/Espressif/frameworks/esp-idf-v5.2.2//Espressif/frameworks/esp-idf-v5.2.2/compotocomm D:/Espressif/frameworks/esp-idf-v5.ts/riscv D:/Espressif/frameworks/esp-idf-vts/soc D:/Espressif/frameworks/esp-idf-v5.ents/spiffs D:/Espressif/frameworks/esp-id_partition D:/Espressif/frameworks/esp-idfts/unity D:/Espressif/frameworks/esp-idf-v/vfs D:/Espressif/frameworks/esp-idf-v5.2.ponents/wifi_provisioning D:/Espressif/espmponents/wpa_supplicant
-- Configuring done
-- Generating done
-- Build files have been written to: D:/wo
[9/1607] Generating .../.../partition_table/
Partition table binary generated. Contents
ESP-IDF Partition Table
Name, Type, SubType, Offset, Size, Flags
nvs,data,nvs,0x9000,16K,
phy_init,data,phy,0xd000,4K,
factory,app,factory,0x10000,7M,
[780/1607] Performing configure step for '
-- Found Git: D:/Espressif/tools/idf-git/2
-- The C compiler identification is GNU 13
-- The CXX compiler identification is GNU
-- The ASM compiler identification is GNU
-- Found assembler: D:/Espressif/tools/riscc.exe
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: D:/Espresv32-esp-elf-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:/Esprscv32-esp-elf-g++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Building ESP-IDF components for target
-- Project sdkconfig file D:/workspace/esp
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of time_t
-- Check size of time_t - done
-- Adding linker script D:/Espressif/frame
-- Bootloader project name: "bootloader" v
-- Adding linker script D:/Espressif/frame
-- Adding linker script D:/Espressif/frame
-- Adding linker script D:/Espressif/frameld
-- Adding linker script D:/Espressif/frameld
-- Adding linker script D:/Espressif/framebootloader.ld
-- Adding linker script D:/Espressif/framebootloader.rom.ld
-- Components: bootloader bootloader_suppot esp_rom esp_system esptool_py freertos h
-- Component paths: D:/Espressif/framework-v5.2.2/components/bootloader_support D:/Eworks/esp-idf-v5.2.2/components/esp_app_foformat D:/Espressif/frameworks/esp-idf-v5.nents/esp_hw_support D:/Espressif/framewor5.2.2/components/esp_system D:/Espressif/f/esp-idf-v5.2.2/components/freertos D:/Esps/esp-idf-v5.2.2/components/log D:/EspressEspressif/frameworks/esp-idf-v5.2.2/compons/esp-idf-v5.2.2/components/newlib D:/Esprf/frameworks/esp-idf-v5.2.2/components/risframeworks/esp-idf-v5.2.2/components/spi_f
-- Configuring done
-- Generating done
-- Build files have been written to: D:/wo
[1231/1607] Performing build step for 'boo
[1/97] Generating project_elf_src_esp32c3.
[2/97] Building C object esp-idf/soc/CMake
[3/97] Building C object esp-idf/soc/CMake
[4/97] Building C object esp-idf/soc/CMake
[5/97] Building C object esp-idf/soc/CMake
[6/97] Building C object esp-idf/soc/CMake
[7/97] Building C object CMakeFiles/bootlo
[8/97] Building C object esp-idf/soc/CMake
[9/97] Building C object esp-idf/soc/CMake
[10/97] Building C object esp-idf/soc/CMak
[11/97] Building C object esp-idf/soc/CMak
[12/97] Building C object esp-idf/soc/CMak
[13/97] Building C object esp-idf/soc/CMak
[14/97] Building C object esp-idf/soc/CMak
[15/97] Building C object esp-idf/soc/CMak
[16/97] Building C object esp-idf/soc/CMak