From 1a6f1e67c6d9f885a989d6c01eb85d4b144d20a4 Mon Sep 17 00:00:00 2001 From: Marius Vikhammer Date: Mon, 15 Jul 2024 16:02:56 +0800 Subject: [PATCH] feat(ulp): include sdkconfig macros in cmake build --- components/ulp/cmake/CMakeLists.txt | 19 ++++++++++--------- components/ulp/project_include.cmake | 11 ++--------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/components/ulp/cmake/CMakeLists.txt b/components/ulp/cmake/CMakeLists.txt index 97b8d2eccc..d6117e5a95 100644 --- a/components/ulp/cmake/CMakeLists.txt +++ b/components/ulp/cmake/CMakeLists.txt @@ -5,8 +5,8 @@ project(${ULP_APP_NAME} ASM C) add_executable(${ULP_APP_NAME}) set(CMAKE_EXECUTABLE_SUFFIX ".elf") -option(ULP_COCPU_IS_RISCV "Use RISC-V based ULP" OFF) -option(ULP_COCPU_IS_LP_CORE "Use RISC-V based LP Core" OFF) +# Import all sdkconfig variables into the cmake build +include(${SDKCONFIG_CMAKE}) function(create_arg_file arguments output_file) # Escape all spaces @@ -20,7 +20,7 @@ endfunction() message(STATUS "Building ULP app ${ULP_APP_NAME}") # Check the supported assembler version -if(NOT (ULP_COCPU_IS_RISCV OR ULP_COCPU_IS_LP_CORE)) +if(CONFIG_ULP_COPROC_TYPE_FSM) check_expected_tool_version("esp32ulp-elf" ${CMAKE_ASM_COMPILER}) endif() @@ -28,6 +28,8 @@ endif() set(ULP_MAP_GEN ${PYTHON} ${IDF_PATH}/components/ulp/esp32ulp_mapgen.py) get_filename_component(sdkconfig_dir ${SDKCONFIG_HEADER} DIRECTORY) + + foreach(include ${COMPONENT_INCLUDES}) list(APPEND component_includes -I${include}) endforeach() @@ -41,9 +43,9 @@ list(APPEND ULP_PREPROCESSOR_ARGS -I${IDF_PATH}/components/esp_system/ld) target_include_directories(${ULP_APP_NAME} PRIVATE ${COMPONENT_INCLUDES}) # Pre-process the linker script -if(ULP_COCPU_IS_RISCV) +if(CONFIG_ULP_COPROC_TYPE_RISCV) set(ULP_LD_TEMPLATE ${IDF_PATH}/components/ulp/ld/ulp_riscv.ld) -elseif(ULP_COCPU_IS_LP_CORE) +elseif(CONFIG_ULP_COPROC_TYPE_LP_CORE) set(ULP_LD_TEMPLATE ${IDF_PATH}/components/ulp/ld/lp_core_riscv.ld) else() set(ULP_LD_TEMPLATE ${IDF_PATH}/components/ulp/ld/ulp_fsm.ld) @@ -69,8 +71,7 @@ target_link_options(${ULP_APP_NAME} PRIVATE SHELL:-T ${CMAKE_CURRENT_BINARY_DIR} # To avoid warning "Manually-specified variables were not used by the project" set(bypassWarning "${IDF_TARGET}") -set(bypassWarning "${CONFIG_ESP_ROM_HAS_LP_ROM}") -if(ULP_COCPU_IS_RISCV) +if(CONFIG_ULP_COPROC_TYPE_RISCV) #risc-v ulp uses extra files for building: list(APPEND ULP_S_SOURCES "${IDF_PATH}/components/ulp/ulp_riscv/ulp_core/ulp_riscv_vectors.S" @@ -98,7 +99,7 @@ if(ULP_COCPU_IS_RISCV) target_compile_definitions(${ULP_APP_NAME} PRIVATE IS_ULP_COCPU) target_compile_definitions(${ULP_APP_NAME} PRIVATE ULP_RISCV_REGISTER_OPS) -elseif(ULP_COCPU_IS_LP_CORE) +elseif(CONFIG_ULP_COPROC_TYPE_LP_CORE) list(APPEND ULP_S_SOURCES "${IDF_PATH}/components/ulp/lp_core/lp_core/start.S" "${IDF_PATH}/components/ulp/lp_core/lp_core/vector.S" @@ -172,7 +173,7 @@ else() endif() -if(ULP_COCPU_IS_LP_CORE) +if(CONFIG_ULP_COPROC_TYPE_LP_CORE) set(ULP_BASE_ADDR "0x0") else() set(ULP_BASE_ADDR "0x50000000") diff --git a/components/ulp/project_include.cmake b/components/ulp/project_include.cmake index b3e35dca96..2e6f5e9620 100644 --- a/components/ulp/project_include.cmake +++ b/components/ulp/project_include.cmake @@ -30,6 +30,7 @@ function(ulp_embed_binary app_name s_sources exp_dep_srcs) string(REPLACE ";" "|" ulp_s_sources "${ulp_s_sources}") idf_build_get_property(sdkconfig_header SDKCONFIG_HEADER) + idf_build_get_property(sdkconfig_cmake SDKCONFIG_CMAKE) idf_build_get_property(idf_path IDF_PATH) idf_build_get_property(idf_target IDF_TARGET) idf_build_get_property(python PYTHON) @@ -41,17 +42,11 @@ function(ulp_embed_binary app_name s_sources exp_dep_srcs) elseif(IDF_TARGET STREQUAL "esp32s2" OR IDF_TARGET STREQUAL "esp32s3") if(CONFIG_ULP_COPROC_TYPE_RISCV STREQUAL "y") set(TOOLCHAIN_FLAG ${idf_path}/components/ulp/cmake/toolchain-ulp-riscv.cmake) - set(ULP_IS_RISCV ON) else() set(TOOLCHAIN_FLAG ${idf_path}/components/ulp/cmake/toolchain-${idf_target}-ulp.cmake) - set(ULP_IS_RISCV OFF) endif() elseif(CONFIG_ULP_COPROC_TYPE_LP_CORE) set(TOOLCHAIN_FLAG ${idf_path}/components/ulp/cmake/toolchain-lp-core-riscv.cmake) - set(ULP_IS_LP_CORE_RISCV ON) - if(CONFIG_ESP_ROM_HAS_LP_ROM) - set(CONFIG_ESP_ROM_HAS_LP_ROM ON) - endif() endif() externalproject_add(${app_name} @@ -67,10 +62,8 @@ function(ulp_embed_binary app_name s_sources exp_dep_srcs) -DIDF_TARGET=${idf_target} -DIDF_PATH=${idf_path} -DSDKCONFIG_HEADER=${SDKCONFIG_HEADER} + -DSDKCONFIG_CMAKE=${SDKCONFIG_CMAKE} -DPYTHON=${python} - -DULP_COCPU_IS_RISCV=${ULP_IS_RISCV} - -DULP_COCPU_IS_LP_CORE=${ULP_IS_LP_CORE_RISCV} - -DCONFIG_ESP_ROM_HAS_LP_ROM=${CONFIG_ESP_ROM_HAS_LP_ROM} ${extra_cmake_args} BUILD_COMMAND ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/${app_name} --target build BUILD_BYPRODUCTS ${ulp_artifacts} ${ulp_artifacts_extras} ${ulp_ps_sources}