From 1bec6e09d9d3870c1192c22bc2194ca0f2a00570 Mon Sep 17 00:00:00 2001 From: Sudeep Mohanty Date: Tue, 1 Sep 2026 14:51:47 +0200 Subject: [PATCH 1/4] refactor(ulp): make the ULP subproject directory explicit components/ulp/cmake holds the project that builds a ULP program. Name it subproject, as the bootloader does. --- .gitlab/ci/rules.yml | 2 +- components/ulp/project_include.cmake | 22 +++++++++---------- .../ulp/{cmake => subproject}/CMakeLists.txt | 0 .../{cmake => subproject}/CMakeLists_v2.txt | 0 .../{cmake => subproject}/IDFULPProject.cmake | 2 +- .../IDFULPProjectCommon.cmake | 7 +++++- .../ulp/{ => subproject}/esp32ulp_mapgen.py | 0 .../preprocess_fsm_asm.cmake | 0 .../toolchain-esp32-ulp.cmake | 0 .../toolchain-esp32s2-ulp.cmake | 0 .../toolchain-esp32s3-ulp.cmake | 0 .../toolchain-lp-core-riscv.cmake | 0 .../toolchain-ulp-riscv.cmake | 0 .../{cmake => subproject}/ulp_project.cmake | 0 .../main/ulp/CMakeLists.txt | 2 +- tools/ci/executable-list.txt | 2 +- .../combined/main/ulp_fsm/CMakeLists.txt | 2 +- .../combined/main/ulp_riscv/CMakeLists.txt | 2 +- .../fsm/main/ulp/CMakeLists.txt | 2 +- .../lp_core/main/ulp/CMakeLists.txt | 2 +- .../multi_binary/main/ulp/CMakeLists.txt | 2 +- .../riscv/main/ulp/CMakeLists.txt | 2 +- tools/test_build_system/buildv2/test_ulp.py | 8 +++---- 23 files changed, 31 insertions(+), 26 deletions(-) rename components/ulp/{cmake => subproject}/CMakeLists.txt (100%) rename components/ulp/{cmake => subproject}/CMakeLists_v2.txt (100%) rename components/ulp/{cmake => subproject}/IDFULPProject.cmake (99%) rename components/ulp/{cmake => subproject}/IDFULPProjectCommon.cmake (92%) rename components/ulp/{ => subproject}/esp32ulp_mapgen.py (100%) rename components/ulp/{cmake => subproject}/preprocess_fsm_asm.cmake (100%) rename components/ulp/{cmake => subproject}/toolchain-esp32-ulp.cmake (100%) rename components/ulp/{cmake => subproject}/toolchain-esp32s2-ulp.cmake (100%) rename components/ulp/{cmake => subproject}/toolchain-esp32s3-ulp.cmake (100%) rename components/ulp/{cmake => subproject}/toolchain-lp-core-riscv.cmake (100%) rename components/ulp/{cmake => subproject}/toolchain-ulp-riscv.cmake (100%) rename components/ulp/{cmake => subproject}/ulp_project.cmake (100%) diff --git a/.gitlab/ci/rules.yml b/.gitlab/ci/rules.yml index dc7bda7bf8b..24cd2ca4291 100644 --- a/.gitlab/ci/rules.yml +++ b/.gitlab/ci/rules.yml @@ -52,7 +52,7 @@ - ".gitlab/ci/host-test.yml" - "components/ulp/ld/**/*" - - "components/ulp/cmake/**/*" + - "components/ulp/subproject/**/*" - "components/ulp/CMakeLists*.txt" - "components/ulp/component_ulp_common.cmake" - "components/ulp/project_include.cmake" diff --git a/components/ulp/project_include.cmake b/components/ulp/project_include.cmake index 7ef3b4d7ea4..a5662f6442b 100644 --- a/components/ulp/project_include.cmake +++ b/components/ulp/project_include.cmake @@ -10,7 +10,7 @@ function(__setup_ulp_project app_name project_path prefix prefix_append_bin_name s_sources exp_dep_srcs linker_script) if(NOT CMAKE_BUILD_EARLY_EXPANSION) - set(ulp_cmake_dir "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/cmake") + set(ulp_subproject_dir "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/subproject") set(sources "") spaces2list(s_sources) foreach(source ${s_sources}) @@ -95,7 +95,7 @@ function(__setup_ulp_project app_name project_path prefix prefix_append_bin_name "Only FSM type is available for ULP on this target.") endif() endif() - set(TOOLCHAIN_FLAG ${ulp_cmake_dir}/toolchain-${idf_target}-ulp.cmake) + set(TOOLCHAIN_FLAG ${ulp_subproject_dir}/toolchain-${idf_target}-ulp.cmake) set(ULP_IS_RISCV OFF) elseif(IDF_TARGET STREQUAL "esp32s2" OR IDF_TARGET STREQUAL "esp32s3") # If both FSM and RISC-V are enabled in sdkconfig and a TYPE was @@ -105,21 +105,21 @@ function(__setup_ulp_project app_name project_path prefix prefix_append_bin_name message(STATUS "Both RISCV and FSM are enabled, using '${type}' toolchain for ${app_name} ULP project.") string(TOLOWER "${type}" type_lower) if(type_lower STREQUAL "riscv") - set(TOOLCHAIN_FLAG ${ulp_cmake_dir}/toolchain-ulp-riscv.cmake) + set(TOOLCHAIN_FLAG ${ulp_subproject_dir}/toolchain-ulp-riscv.cmake) elseif(type_lower STREQUAL "fsm") - set(TOOLCHAIN_FLAG ${ulp_cmake_dir}/toolchain-${idf_target}-ulp.cmake) + set(TOOLCHAIN_FLAG ${ulp_subproject_dir}/toolchain-${idf_target}-ulp.cmake) else() message(FATAL_ERROR "Invalid ULP_TYPE '${type}'; expected 'fsm' or 'riscv'.") endif() else() if(CONFIG_ULP_COPROC_TYPE_RISCV STREQUAL "y") - set(TOOLCHAIN_FLAG ${ulp_cmake_dir}/toolchain-ulp-riscv.cmake) + set(TOOLCHAIN_FLAG ${ulp_subproject_dir}/toolchain-ulp-riscv.cmake) else() - set(TOOLCHAIN_FLAG ${ulp_cmake_dir}/toolchain-${idf_target}-ulp.cmake) + set(TOOLCHAIN_FLAG ${ulp_subproject_dir}/toolchain-${idf_target}-ulp.cmake) endif() endif() elseif(CONFIG_ULP_COPROC_TYPE_LP_CORE) - set(TOOLCHAIN_FLAG ${ulp_cmake_dir}/toolchain-lp-core-riscv.cmake) + set(TOOLCHAIN_FLAG ${ulp_subproject_dir}/toolchain-lp-core-riscv.cmake) endif() set(ulp_project_args) @@ -133,7 +133,7 @@ function(__setup_ulp_project app_name project_path prefix prefix_append_bin_name -DIDF_DEFAULT_PROJECT_NAME=${app_name} -DULP_APP_NAME=${app_name} -DIDF_BUILD_V2=y - -DCMAKE_MODULE_PATH=${ulp_cmake_dir} + -DCMAKE_MODULE_PATH=${ulp_subproject_dir} # Internal marker for ULP child component graphs. Only the # IDF_BUILD_V2 path sets it for now. -D__ULP_BUILDV2=1 @@ -176,7 +176,7 @@ function(__setup_ulp_project app_name project_path prefix prefix_append_bin_name -DSDKCONFIG_HEADER=${SDKCONFIG_HEADER} -DSDKCONFIG_CMAKE=${SDKCONFIG_CMAKE} # The v1 ULP child resolves include(IDFULPProject) via the module path. - -DCMAKE_MODULE_PATH=${ulp_cmake_dir}) + -DCMAKE_MODULE_PATH=${ulp_subproject_dir}) endif() externalproject_add(${app_name} @@ -315,9 +315,9 @@ function(ulp_embed_binary app_name s_sources exp_dep_srcs) set(ULP_TYPE "${ulp_resolved_type}") endif() __resolve_lp_core_linker("${ULP_LINKER_LAYOUT}" "${ulp_resolved_type}" LP_CORE_LINKER) - set(ulp_cmake_dir "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/cmake") + set(ulp_subproject_dir "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/subproject") - __setup_ulp_project("${app_name}" "${ulp_cmake_dir}" + __setup_ulp_project("${app_name}" "${ulp_subproject_dir}" "${ULP_PREFIX}" FALSE "${ULP_TYPE}" "${app_name}" "${s_sources}" "${exp_dep_srcs}" "${LP_CORE_LINKER}") diff --git a/components/ulp/cmake/CMakeLists.txt b/components/ulp/subproject/CMakeLists.txt similarity index 100% rename from components/ulp/cmake/CMakeLists.txt rename to components/ulp/subproject/CMakeLists.txt diff --git a/components/ulp/cmake/CMakeLists_v2.txt b/components/ulp/subproject/CMakeLists_v2.txt similarity index 100% rename from components/ulp/cmake/CMakeLists_v2.txt rename to components/ulp/subproject/CMakeLists_v2.txt diff --git a/components/ulp/cmake/IDFULPProject.cmake b/components/ulp/subproject/IDFULPProject.cmake similarity index 99% rename from components/ulp/cmake/IDFULPProject.cmake rename to components/ulp/subproject/IDFULPProject.cmake index ed082b1763f..3ae78c21168 100644 --- a/components/ulp/cmake/IDFULPProject.cmake +++ b/components/ulp/subproject/IDFULPProject.cmake @@ -1,5 +1,5 @@ # This is the CMake v1 (legacy) ULP child entry point, used by ulp_embed_binary. -# CMake v2 full-subproject builds include components/ulp/cmake/ulp_project.cmake +# CMake v2 full-subproject builds include components/ulp/subproject/ulp_project.cmake # instead. # # Legacy ULP child projects are plain CMake projects, so the parent-provided diff --git a/components/ulp/cmake/IDFULPProjectCommon.cmake b/components/ulp/subproject/IDFULPProjectCommon.cmake similarity index 92% rename from components/ulp/cmake/IDFULPProjectCommon.cmake rename to components/ulp/subproject/IDFULPProjectCommon.cmake index 8579ccbd396..e11097741c6 100644 --- a/components/ulp/cmake/IDFULPProjectCommon.cmake +++ b/components/ulp/subproject/IDFULPProjectCommon.cmake @@ -1,3 +1,8 @@ +# The directory of this file, captured while it is being processed: +# CMAKE_CURRENT_LIST_DIR inside a function resolves at call time, which is the +# caller's directory, not this one. +set(__ULP_SUBPROJECT_DIR "${CMAKE_CURRENT_LIST_DIR}") + macro(ulp_detect_build_type) # Logic to determine ULP type and set reusable flags set(BUILD_RISCV OFF) @@ -49,7 +54,7 @@ function(ulp_add_build_binary_targets ulp_app_name) set(ULP_BASE_ADDR "0x50000000") endif() - set(ULP_MAP_GEN ${PYTHON} ${IDF_PATH}/components/ulp/esp32ulp_mapgen.py) + set(ULP_MAP_GEN ${PYTHON} ${__ULP_SUBPROJECT_DIR}/esp32ulp_mapgen.py) # Dump the list of global symbols in a convenient format add_custom_command(OUTPUT ${ulp_app_name}.sym diff --git a/components/ulp/esp32ulp_mapgen.py b/components/ulp/subproject/esp32ulp_mapgen.py similarity index 100% rename from components/ulp/esp32ulp_mapgen.py rename to components/ulp/subproject/esp32ulp_mapgen.py diff --git a/components/ulp/cmake/preprocess_fsm_asm.cmake b/components/ulp/subproject/preprocess_fsm_asm.cmake similarity index 100% rename from components/ulp/cmake/preprocess_fsm_asm.cmake rename to components/ulp/subproject/preprocess_fsm_asm.cmake diff --git a/components/ulp/cmake/toolchain-esp32-ulp.cmake b/components/ulp/subproject/toolchain-esp32-ulp.cmake similarity index 100% rename from components/ulp/cmake/toolchain-esp32-ulp.cmake rename to components/ulp/subproject/toolchain-esp32-ulp.cmake diff --git a/components/ulp/cmake/toolchain-esp32s2-ulp.cmake b/components/ulp/subproject/toolchain-esp32s2-ulp.cmake similarity index 100% rename from components/ulp/cmake/toolchain-esp32s2-ulp.cmake rename to components/ulp/subproject/toolchain-esp32s2-ulp.cmake diff --git a/components/ulp/cmake/toolchain-esp32s3-ulp.cmake b/components/ulp/subproject/toolchain-esp32s3-ulp.cmake similarity index 100% rename from components/ulp/cmake/toolchain-esp32s3-ulp.cmake rename to components/ulp/subproject/toolchain-esp32s3-ulp.cmake diff --git a/components/ulp/cmake/toolchain-lp-core-riscv.cmake b/components/ulp/subproject/toolchain-lp-core-riscv.cmake similarity index 100% rename from components/ulp/cmake/toolchain-lp-core-riscv.cmake rename to components/ulp/subproject/toolchain-lp-core-riscv.cmake diff --git a/components/ulp/cmake/toolchain-ulp-riscv.cmake b/components/ulp/subproject/toolchain-ulp-riscv.cmake similarity index 100% rename from components/ulp/cmake/toolchain-ulp-riscv.cmake rename to components/ulp/subproject/toolchain-ulp-riscv.cmake diff --git a/components/ulp/cmake/ulp_project.cmake b/components/ulp/subproject/ulp_project.cmake similarity index 100% rename from components/ulp/cmake/ulp_project.cmake rename to components/ulp/subproject/ulp_project.cmake diff --git a/components/ulp/test_apps/lp_core/host_tests/lp_core_custom_linker_v2/main/ulp/CMakeLists.txt b/components/ulp/test_apps/lp_core/host_tests/lp_core_custom_linker_v2/main/ulp/CMakeLists.txt index 46cc1d8f144..6a89cf6f960 100644 --- a/components/ulp/test_apps/lp_core/host_tests/lp_core_custom_linker_v2/main/ulp/CMakeLists.txt +++ b/components/ulp/test_apps/lp_core/host_tests/lp_core_custom_linker_v2/main/ulp/CMakeLists.txt @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 cmake_minimum_required(VERSION 3.22) -include(${IDF_PATH}/components/ulp/cmake/ulp_project.cmake) +include(${IDF_PATH}/components/ulp/subproject/ulp_project.cmake) project(${IDF_DEFAULT_PROJECT_NAME} C CXX ASM) diff --git a/tools/ci/executable-list.txt b/tools/ci/executable-list.txt index 0ebf0d55f63..3b3b81eccb8 100644 --- a/tools/ci/executable-list.txt +++ b/tools/ci/executable-list.txt @@ -25,7 +25,7 @@ components/partition_table/test_gen_esp32part_host/check_sizes_test.py components/partition_table/test_gen_esp32part_host/gen_esp32part_tests.py components/spiffs/spiffsgen.py components/spiffs/test_spiffsgen/test_spiffsgen.py -components/ulp/esp32ulp_mapgen.py +components/ulp/subproject/esp32ulp_mapgen.py docs/check_lang_folder_sync.sh examples/build_system/cmake/idf_as_lib/build-esp32.sh examples/build_system/cmake/idf_as_lib/build-esp32c2.sh diff --git a/tools/test_apps/system/ulp/full_subproject/combined/main/ulp_fsm/CMakeLists.txt b/tools/test_apps/system/ulp/full_subproject/combined/main/ulp_fsm/CMakeLists.txt index b48a7286f3e..4105a4fa745 100644 --- a/tools/test_apps/system/ulp/full_subproject/combined/main/ulp_fsm/CMakeLists.txt +++ b/tools/test_apps/system/ulp/full_subproject/combined/main/ulp_fsm/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.22) -include(${IDF_PATH}/components/ulp/cmake/ulp_project.cmake) +include(${IDF_PATH}/components/ulp/subproject/ulp_project.cmake) project(${IDF_DEFAULT_PROJECT_NAME} ASM) diff --git a/tools/test_apps/system/ulp/full_subproject/combined/main/ulp_riscv/CMakeLists.txt b/tools/test_apps/system/ulp/full_subproject/combined/main/ulp_riscv/CMakeLists.txt index ec8b058fc29..99d21d6d5a7 100644 --- a/tools/test_apps/system/ulp/full_subproject/combined/main/ulp_riscv/CMakeLists.txt +++ b/tools/test_apps/system/ulp/full_subproject/combined/main/ulp_riscv/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.22) -include(${IDF_PATH}/components/ulp/cmake/ulp_project.cmake) +include(${IDF_PATH}/components/ulp/subproject/ulp_project.cmake) project(${IDF_DEFAULT_PROJECT_NAME} C CXX ASM) diff --git a/tools/test_apps/system/ulp/full_subproject/fsm/main/ulp/CMakeLists.txt b/tools/test_apps/system/ulp/full_subproject/fsm/main/ulp/CMakeLists.txt index b48a7286f3e..4105a4fa745 100644 --- a/tools/test_apps/system/ulp/full_subproject/fsm/main/ulp/CMakeLists.txt +++ b/tools/test_apps/system/ulp/full_subproject/fsm/main/ulp/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.22) -include(${IDF_PATH}/components/ulp/cmake/ulp_project.cmake) +include(${IDF_PATH}/components/ulp/subproject/ulp_project.cmake) project(${IDF_DEFAULT_PROJECT_NAME} ASM) diff --git a/tools/test_apps/system/ulp/full_subproject/lp_core/main/ulp/CMakeLists.txt b/tools/test_apps/system/ulp/full_subproject/lp_core/main/ulp/CMakeLists.txt index ec8b058fc29..99d21d6d5a7 100644 --- a/tools/test_apps/system/ulp/full_subproject/lp_core/main/ulp/CMakeLists.txt +++ b/tools/test_apps/system/ulp/full_subproject/lp_core/main/ulp/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.22) -include(${IDF_PATH}/components/ulp/cmake/ulp_project.cmake) +include(${IDF_PATH}/components/ulp/subproject/ulp_project.cmake) project(${IDF_DEFAULT_PROJECT_NAME} C CXX ASM) diff --git a/tools/test_apps/system/ulp/full_subproject/multi_binary/main/ulp/CMakeLists.txt b/tools/test_apps/system/ulp/full_subproject/multi_binary/main/ulp/CMakeLists.txt index 1df774c07fb..c30110b29d3 100644 --- a/tools/test_apps/system/ulp/full_subproject/multi_binary/main/ulp/CMakeLists.txt +++ b/tools/test_apps/system/ulp/full_subproject/multi_binary/main/ulp/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.22) -include(${IDF_PATH}/components/ulp/cmake/ulp_project.cmake) +include(${IDF_PATH}/components/ulp/subproject/ulp_project.cmake) project(${IDF_DEFAULT_PROJECT_NAME} C CXX ASM) diff --git a/tools/test_apps/system/ulp/full_subproject/riscv/main/ulp/CMakeLists.txt b/tools/test_apps/system/ulp/full_subproject/riscv/main/ulp/CMakeLists.txt index ec8b058fc29..99d21d6d5a7 100644 --- a/tools/test_apps/system/ulp/full_subproject/riscv/main/ulp/CMakeLists.txt +++ b/tools/test_apps/system/ulp/full_subproject/riscv/main/ulp/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.22) -include(${IDF_PATH}/components/ulp/cmake/ulp_project.cmake) +include(${IDF_PATH}/components/ulp/subproject/ulp_project.cmake) project(${IDF_DEFAULT_PROJECT_NAME} C CXX ASM) diff --git a/tools/test_build_system/buildv2/test_ulp.py b/tools/test_build_system/buildv2/test_ulp.py index 77750628a34..5f75bdb3dfe 100644 --- a/tools/test_build_system/buildv2/test_ulp.py +++ b/tools/test_build_system/buildv2/test_ulp.py @@ -87,7 +87,7 @@ def _sha256(path: Path) -> str: 'entry_point,add_native_executable,expected_available,expected_unavailable', ( ( - '${IDF_PATH}/components/ulp/cmake/ulp_project.cmake', + '${IDF_PATH}/components/ulp/subproject/ulp_project.cmake', False, FULL_PROJECT_APIS, LEGACY_PROJECT_APIS, @@ -116,7 +116,7 @@ def test_ulp_cmake_api_availability( build_dir = tmp_path / 'build' project_dir.mkdir() _write_api_probe_project(project_dir, entry_point, add_native_executable) - ulp_cmake_dir = idf_path / 'components' / 'ulp' / 'cmake' + ulp_subproject_dir = idf_path / 'components' / 'ulp' / 'subproject' cmake_args = ( 'cmake', @@ -126,8 +126,8 @@ def test_ulp_cmake_api_availability( _cmake_path(project_dir), '-B', _cmake_path(build_dir), - f'-DCMAKE_MODULE_PATH={_cmake_path(ulp_cmake_dir)}', - f'-DCMAKE_TOOLCHAIN_FILE={_cmake_path(ulp_cmake_dir / "toolchain-lp-core-riscv.cmake")}', + f'-DCMAKE_MODULE_PATH={_cmake_path(ulp_subproject_dir)}', + f'-DCMAKE_TOOLCHAIN_FILE={_cmake_path(ulp_subproject_dir / "toolchain-lp-core-riscv.cmake")}', f'-DIDF_PATH={_cmake_path(idf_path)}', '-DIDF_TARGET=esp32c6', f'-DSDKCONFIG_CMAKE={_cmake_path(project_dir / "sdkconfig.cmake")}', From cb2b2f9b78646f9299e14935cb98be1265ee56d8 Mon Sep 17 00:00:00 2001 From: Sudeep Mohanty Date: Wed, 2 Sep 2026 09:09:26 +0200 Subject: [PATCH 2/4] refactor(ulp): build the ULP coprocessor code as per-architecture components A ULP program is built against ulp_riscv, lp_core or ulp_fsm, each stating its own sources, dependencies and memory layout. Sources shared with the driver stay in components/ulp. --- .gitlab/ci/rules.yml | 1 - components/ulp/CMakeLists_v2.txt | 450 +++++------------- components/ulp/project_include.cmake | 12 +- components/ulp/subproject/CMakeLists_v2.txt | 10 +- components/ulp/subproject/IDFULPProject.cmake | 78 +-- .../components/lp_core/CMakeLists.txt | 120 +++++ .../lp_core/include/ulp_lp_core_gpio.h | 0 .../lp_core/include/ulp_lp_core_i2c.h | 0 .../lp_core/include/ulp_lp_core_interrupts.h | 0 .../lp_core/include/ulp_lp_core_mailbox.h | 0 .../lp_core/include/ulp_lp_core_pmp.h | 0 .../lp_core/include/ulp_lp_core_print.h | 0 .../lp_core/include/ulp_lp_core_spi.h | 0 .../lp_core/include/ulp_lp_core_touch.h | 0 .../lp_core/include/ulp_lp_core_uart.h | 0 .../lp_core/include/ulp_lp_core_utils.h | 0 .../lp_core}/ld/lp_core_riscv.ld.in | 0 .../lp_core}/ld/lp_core_riscv_base.ld.in | 0 .../lp_core}/ld/lp_core_riscv_checks.ld.in | 0 .../ld/lp_core_riscv_default_layout.ld.in | 0 .../components}/lp_core/lp_core_i2c.c | 0 .../components}/lp_core/lp_core_interrupt.c | 0 .../components}/lp_core/lp_core_mailbox.c | 0 .../components}/lp_core/lp_core_panic.c | 0 .../components}/lp_core/lp_core_pmp.c | 0 .../components}/lp_core/lp_core_print.c | 0 .../components}/lp_core/lp_core_spi.c | 0 .../components}/lp_core/lp_core_startup.c | 0 .../components}/lp_core/lp_core_touch.c | 0 .../components}/lp_core/lp_core_uart.c | 0 .../components}/lp_core/lp_core_ubsan.c | 0 .../components}/lp_core/lp_core_utils.c | 0 .../lp_core/port/esp32c5/vector_table.S | 0 .../lp_core/port/esp32c6/vector_table.S | 0 .../lp_core/port/esp32p4/vector_table.S | 0 .../lp_core/port/esp32s31/vector_table.S | 0 .../lp_core/port/lp_core_mailbox_impl_hw.c | 0 .../lp_core/port/lp_core_mailbox_impl_sw.c | 0 .../components}/lp_core/start.S | 0 .../lp_core}/toolchain-lp-core-riscv.cmake | 0 .../components}/lp_core/vector.S | 0 .../components/ulp_fsm/CMakeLists.txt | 21 + .../components/ulp_fsm}/ld/ulp_fsm.ld.in | 0 .../ulp_fsm}/preprocess_fsm_asm.cmake | 0 .../ulp_fsm}/toolchain-esp32-ulp.cmake | 0 .../ulp_fsm}/toolchain-esp32s2-ulp.cmake | 0 .../ulp_fsm}/toolchain-esp32s3-ulp.cmake | 0 .../components/ulp_riscv/CMakeLists.txt | 53 +++ .../include/ulp_riscv_adc_ulp_core.h | 0 .../ulp_riscv}/include/ulp_riscv_gpio.h | 0 .../include/ulp_riscv_i2c_ulp_core.h | 0 .../ulp_riscv}/include/ulp_riscv_interrupt.h | 0 .../include/ulp_riscv_interrupt_ops.h | 2 +- .../include/ulp_riscv_lock_ulp_core.h | 0 .../ulp_riscv}/include/ulp_riscv_print.h | 0 .../include/ulp_riscv_register_ops.h | 0 .../include/ulp_riscv_touch_ulp_core.h | 0 .../include/ulp_riscv_uart_ulp_core.h | 0 .../ulp_riscv}/include/ulp_riscv_utils.h | 0 .../ulp_riscv}/ld/esp32s2.peripherals.ld | 0 .../ulp_riscv}/ld/esp32s3.peripherals.ld | 0 .../components/ulp_riscv}/ld/ulp_riscv.ld.in | 0 .../components/ulp_riscv}/start.S | 0 .../ulp_riscv}/toolchain-ulp-riscv.cmake | 0 .../components/ulp_riscv}/ulp_riscv_adc.c | 0 .../components/ulp_riscv}/ulp_riscv_gpio.c | 0 .../components/ulp_riscv}/ulp_riscv_i2c.c | 0 .../ulp_riscv}/ulp_riscv_interrupt.c | 0 .../components/ulp_riscv}/ulp_riscv_lock.c | 0 .../components/ulp_riscv}/ulp_riscv_print.c | 0 .../components/ulp_riscv}/ulp_riscv_touch.c | 0 .../components/ulp_riscv}/ulp_riscv_uart.c | 0 .../components/ulp_riscv}/ulp_riscv_utils.c | 0 .../components/ulp_riscv}/ulp_riscv_vectors.S | 0 components/ulp/subproject/ulp_project.cmake | 20 + .../main/ulp/main/CMakeLists.txt | 2 +- .../main/lp_core/test_shared.h | 2 +- .../ulp/ulp_fsm/include/ulp_fsm_common.h | 2 +- components/ulp/ulp_riscv/include/ulp_riscv.h | 2 +- docs/component_info_ignore_file.txt | 16 +- docs/doxygen/Doxyfile_esp32c5 | 14 +- docs/doxygen/Doxyfile_esp32c6 | 14 +- docs/doxygen/Doxyfile_esp32p4 | 16 +- docs/doxygen/Doxyfile_esp32s31 | 16 +- .../peripherals/cap_touch_sens.rst | 2 +- docs/en/api-reference/system/ulp-fsm.rst | 2 +- docs/en/api-reference/system/ulp-lp-core.rst | 4 +- docs/en/api-reference/system/ulp-risc-v.rst | 2 +- .../peripherals/cap_touch_sens.rst | 2 +- docs/zh_CN/api-reference/system/ulp-fsm.rst | 2 +- .../api-reference/system/ulp-lp-core.rst | 4 +- .../zh_CN/api-reference/system/ulp-risc-v.rst | 2 +- .../combined/main/ulp_fsm/main/CMakeLists.txt | 2 +- .../main/ulp_riscv/main/CMakeLists.txt | 2 +- .../ulp/components/ulp_wake/CMakeLists.txt | 2 +- .../fsm/main/ulp/main/CMakeLists.txt | 2 +- .../lp_core/main/ulp/main/CMakeLists.txt | 2 +- .../components/ulp_add_main/CMakeLists.txt | 2 +- .../ulp_multiply_main/CMakeLists.txt | 2 +- .../riscv/main/ulp/main/CMakeLists.txt | 2 +- tools/test_build_system/buildv2/test_ulp.py | 3 +- 101 files changed, 461 insertions(+), 429 deletions(-) create mode 100644 components/ulp/subproject/components/lp_core/CMakeLists.txt rename components/ulp/{lp_core => subproject/components}/lp_core/include/ulp_lp_core_gpio.h (100%) rename components/ulp/{lp_core => subproject/components}/lp_core/include/ulp_lp_core_i2c.h (100%) rename components/ulp/{lp_core => subproject/components}/lp_core/include/ulp_lp_core_interrupts.h (100%) rename components/ulp/{lp_core => subproject/components}/lp_core/include/ulp_lp_core_mailbox.h (100%) rename components/ulp/{lp_core => subproject/components}/lp_core/include/ulp_lp_core_pmp.h (100%) rename components/ulp/{lp_core => subproject/components}/lp_core/include/ulp_lp_core_print.h (100%) rename components/ulp/{lp_core => subproject/components}/lp_core/include/ulp_lp_core_spi.h (100%) rename components/ulp/{lp_core => subproject/components}/lp_core/include/ulp_lp_core_touch.h (100%) rename components/ulp/{lp_core => subproject/components}/lp_core/include/ulp_lp_core_uart.h (100%) rename components/ulp/{lp_core => subproject/components}/lp_core/include/ulp_lp_core_utils.h (100%) rename components/ulp/{ => subproject/components/lp_core}/ld/lp_core_riscv.ld.in (100%) rename components/ulp/{ => subproject/components/lp_core}/ld/lp_core_riscv_base.ld.in (100%) rename components/ulp/{ => subproject/components/lp_core}/ld/lp_core_riscv_checks.ld.in (100%) rename components/ulp/{ => subproject/components/lp_core}/ld/lp_core_riscv_default_layout.ld.in (100%) rename components/ulp/{lp_core => subproject/components}/lp_core/lp_core_i2c.c (100%) rename components/ulp/{lp_core => subproject/components}/lp_core/lp_core_interrupt.c (100%) rename components/ulp/{lp_core => subproject/components}/lp_core/lp_core_mailbox.c (100%) rename components/ulp/{lp_core => subproject/components}/lp_core/lp_core_panic.c (100%) rename components/ulp/{lp_core => subproject/components}/lp_core/lp_core_pmp.c (100%) rename components/ulp/{lp_core => subproject/components}/lp_core/lp_core_print.c (100%) rename components/ulp/{lp_core => subproject/components}/lp_core/lp_core_spi.c (100%) rename components/ulp/{lp_core => subproject/components}/lp_core/lp_core_startup.c (100%) rename components/ulp/{lp_core => subproject/components}/lp_core/lp_core_touch.c (100%) rename components/ulp/{lp_core => subproject/components}/lp_core/lp_core_uart.c (100%) rename components/ulp/{lp_core => subproject/components}/lp_core/lp_core_ubsan.c (100%) rename components/ulp/{lp_core => subproject/components}/lp_core/lp_core_utils.c (100%) rename components/ulp/{lp_core => subproject/components}/lp_core/port/esp32c5/vector_table.S (100%) rename components/ulp/{lp_core => subproject/components}/lp_core/port/esp32c6/vector_table.S (100%) rename components/ulp/{lp_core => subproject/components}/lp_core/port/esp32p4/vector_table.S (100%) rename components/ulp/{lp_core => subproject/components}/lp_core/port/esp32s31/vector_table.S (100%) rename components/ulp/{lp_core => subproject/components}/lp_core/port/lp_core_mailbox_impl_hw.c (100%) rename components/ulp/{lp_core => subproject/components}/lp_core/port/lp_core_mailbox_impl_sw.c (100%) rename components/ulp/{lp_core => subproject/components}/lp_core/start.S (100%) rename components/ulp/subproject/{ => components/lp_core}/toolchain-lp-core-riscv.cmake (100%) rename components/ulp/{lp_core => subproject/components}/lp_core/vector.S (100%) create mode 100644 components/ulp/subproject/components/ulp_fsm/CMakeLists.txt rename components/ulp/{ => subproject/components/ulp_fsm}/ld/ulp_fsm.ld.in (100%) rename components/ulp/subproject/{ => components/ulp_fsm}/preprocess_fsm_asm.cmake (100%) rename components/ulp/subproject/{ => components/ulp_fsm}/toolchain-esp32-ulp.cmake (100%) rename components/ulp/subproject/{ => components/ulp_fsm}/toolchain-esp32s2-ulp.cmake (100%) rename components/ulp/subproject/{ => components/ulp_fsm}/toolchain-esp32s3-ulp.cmake (100%) create mode 100644 components/ulp/subproject/components/ulp_riscv/CMakeLists.txt rename components/ulp/{ulp_riscv/ulp_core => subproject/components/ulp_riscv}/include/ulp_riscv_adc_ulp_core.h (100%) rename components/ulp/{ulp_riscv/ulp_core => subproject/components/ulp_riscv}/include/ulp_riscv_gpio.h (100%) rename components/ulp/{ulp_riscv/ulp_core => subproject/components/ulp_riscv}/include/ulp_riscv_i2c_ulp_core.h (100%) rename components/ulp/{ulp_riscv/ulp_core => subproject/components/ulp_riscv}/include/ulp_riscv_interrupt.h (100%) rename components/ulp/{ulp_riscv/ulp_core => subproject/components/ulp_riscv}/include/ulp_riscv_interrupt_ops.h (98%) rename components/ulp/{ulp_riscv/ulp_core => subproject/components/ulp_riscv}/include/ulp_riscv_lock_ulp_core.h (100%) rename components/ulp/{ulp_riscv/ulp_core => subproject/components/ulp_riscv}/include/ulp_riscv_print.h (100%) rename components/ulp/{ulp_riscv/ulp_core => subproject/components/ulp_riscv}/include/ulp_riscv_register_ops.h (100%) rename components/ulp/{ulp_riscv/ulp_core => subproject/components/ulp_riscv}/include/ulp_riscv_touch_ulp_core.h (100%) rename components/ulp/{ulp_riscv/ulp_core => subproject/components/ulp_riscv}/include/ulp_riscv_uart_ulp_core.h (100%) rename components/ulp/{ulp_riscv/ulp_core => subproject/components/ulp_riscv}/include/ulp_riscv_utils.h (100%) rename components/ulp/{ => subproject/components/ulp_riscv}/ld/esp32s2.peripherals.ld (100%) rename components/ulp/{ => subproject/components/ulp_riscv}/ld/esp32s3.peripherals.ld (100%) rename components/ulp/{ => subproject/components/ulp_riscv}/ld/ulp_riscv.ld.in (100%) rename components/ulp/{ulp_riscv/ulp_core => subproject/components/ulp_riscv}/start.S (100%) rename components/ulp/subproject/{ => components/ulp_riscv}/toolchain-ulp-riscv.cmake (100%) rename components/ulp/{ulp_riscv/ulp_core => subproject/components/ulp_riscv}/ulp_riscv_adc.c (100%) rename components/ulp/{ulp_riscv/ulp_core => subproject/components/ulp_riscv}/ulp_riscv_gpio.c (100%) rename components/ulp/{ulp_riscv/ulp_core => subproject/components/ulp_riscv}/ulp_riscv_i2c.c (100%) rename components/ulp/{ulp_riscv/ulp_core => subproject/components/ulp_riscv}/ulp_riscv_interrupt.c (100%) rename components/ulp/{ulp_riscv/ulp_core => subproject/components/ulp_riscv}/ulp_riscv_lock.c (100%) rename components/ulp/{ulp_riscv/ulp_core => subproject/components/ulp_riscv}/ulp_riscv_print.c (100%) rename components/ulp/{ulp_riscv/ulp_core => subproject/components/ulp_riscv}/ulp_riscv_touch.c (100%) rename components/ulp/{ulp_riscv/ulp_core => subproject/components/ulp_riscv}/ulp_riscv_uart.c (100%) rename components/ulp/{ulp_riscv/ulp_core => subproject/components/ulp_riscv}/ulp_riscv_utils.c (100%) rename components/ulp/{ulp_riscv/ulp_core => subproject/components/ulp_riscv}/ulp_riscv_vectors.S (100%) diff --git a/.gitlab/ci/rules.yml b/.gitlab/ci/rules.yml index 24cd2ca4291..5c2ee7ef98b 100644 --- a/.gitlab/ci/rules.yml +++ b/.gitlab/ci/rules.yml @@ -51,7 +51,6 @@ .patterns-host_test_ulp_linker: &patterns-host_test_ulp_linker - ".gitlab/ci/host-test.yml" - - "components/ulp/ld/**/*" - "components/ulp/subproject/**/*" - "components/ulp/CMakeLists*.txt" - "components/ulp/component_ulp_common.cmake" diff --git a/components/ulp/CMakeLists_v2.txt b/components/ulp/CMakeLists_v2.txt index 3bdd8fc778f..8f8eb900cb2 100644 --- a/components/ulp/CMakeLists_v2.txt +++ b/components/ulp/CMakeLists_v2.txt @@ -1,347 +1,159 @@ +# The application's driver for the ULP coprocessor. The code that runs on the +# ULP coprocessor is built from the components in subproject/components, whose +# headers this component also publishes: they are on the application's include +# path. +if(__ULP_BUILDV2) + idf_die("The ulp component is not built for the ULP coprocessor. A ULP " + "program is built against the components in ulp/subproject.") +endif() + set(srcs "") set(includes "") set(requires "") set(priv_requires "") -if(__ULP_BUILDV2) - if(ULP_TYPE STREQUAL "riscv") - list(APPEND includes - ulp_common/include - ulp_riscv/include - ulp_riscv/shared/include - ulp_riscv/ulp_core/include) - list(APPEND srcs - "ulp_riscv/ulp_core/ulp_riscv_vectors.S" - "ulp_riscv/ulp_core/start.S" - "ulp_riscv/ulp_core/ulp_riscv_adc.c" - "ulp_riscv/ulp_core/ulp_riscv_lock.c" - "ulp_riscv/ulp_core/ulp_riscv_uart.c" - "ulp_riscv/ulp_core/ulp_riscv_print.c" - "ulp_riscv/ulp_core/ulp_riscv_i2c.c" - "ulp_riscv/ulp_core/ulp_riscv_utils.c" - "ulp_riscv/ulp_core/ulp_riscv_touch.c" - "ulp_riscv/ulp_core/ulp_riscv_gpio.c" - "ulp_riscv/ulp_core/ulp_riscv_interrupt.c") - list(APPEND requires - esp_common - esp_hal_ana_conv - esp_hal_gpio - esp_hal_i2c - esp_hal_touch_sens - esp_hw_support - riscv - soc) - elseif(ULP_TYPE STREQUAL "lp_core") - list(APPEND includes - ulp_common/include - lp_core/include - lp_core/lp_core/include - lp_core/shared/include) - list(APPEND srcs - "lp_core/lp_core/start.S" - "lp_core/lp_core/vector.S" - "lp_core/lp_core/port/${target}/vector_table.S" - "lp_core/shared/ulp_lp_core_memory_shared.c" - "lp_core/lp_core/lp_core_startup.c" - "lp_core/lp_core/lp_core_pmp.c" - "lp_core/lp_core/lp_core_utils.c" - "lp_core/lp_core/lp_core_print.c" - "lp_core/lp_core/lp_core_panic.c" - "lp_core/lp_core/lp_core_interrupt.c" - "lp_core/lp_core/lp_core_ubsan.c" - "lp_core/lp_core/lp_core_mailbox.c" - "lp_core/shared/ulp_lp_core_critical_section_shared.c") +# TODO(IDF-15993): Keep esp_driver_gpio and esp_adc public for compatibility +# with the CMake v1 dependency graph until downstream users are fixed. +list(APPEND requires + esp_adc + esp_driver_gpio) - list(APPEND requires - esp_common - esp_hal_gpio - esp_hal_uart - esp_rom - hal - riscv - soc) - list(APPEND priv_requires - esp_hal_pmu - esp_hw_support) - - if(CONFIG_SOC_RTC_TIMER_V2 OR CONFIG_SOC_RTC_TIMER_V3) - list(APPEND srcs "lp_core/shared/ulp_lp_core_lp_timer_shared.c") - list(APPEND priv_requires - esp_hal_clock - esp_hal_rtc_timer) - endif() - - if(CONFIG_SOC_LP_CORE_SUPPORT_I2C) - list(APPEND srcs "lp_core/lp_core/lp_core_i2c.c") - list(APPEND requires esp_hal_i2c) - endif() - - if(CONFIG_SOC_LP_SPI_SUPPORTED) - list(APPEND srcs "lp_core/lp_core/lp_core_spi.c") - list(APPEND priv_requires esp_hal_gpspi) - endif() - - if(CONFIG_SOC_ULP_LP_UART_SUPPORTED) - list(APPEND srcs - "lp_core/shared/ulp_lp_core_lp_uart_shared.c" - "lp_core/lp_core/lp_core_uart.c") - list(APPEND requires esp_driver_uart) - endif() - - if(CONFIG_SOC_LP_MAILBOX_SUPPORTED) - list(APPEND srcs "lp_core/lp_core/port/lp_core_mailbox_impl_hw.c") - else() - list(APPEND srcs "lp_core/lp_core/port/lp_core_mailbox_impl_sw.c") - endif() - - if(CONFIG_SOC_TOUCH_SENSOR_SUPPORTED) - list(APPEND srcs "lp_core/lp_core/lp_core_touch.c") - list(APPEND requires esp_hal_touch_sens) - endif() - - if(CONFIG_SOC_LP_ADC_SUPPORTED) - list(APPEND srcs "lp_core/shared/ulp_lp_core_lp_adc_shared.c") - list(APPEND requires - esp_adc - esp_hal_ana_conv) - endif() - - if(CONFIG_SOC_LP_VAD_SUPPORTED) - list(APPEND srcs "lp_core/shared/ulp_lp_core_lp_vad_shared.c") - list(APPEND requires esp_driver_i2s) - endif() - elseif(ULP_TYPE STREQUAL "fsm") - list(APPEND includes - ulp_common/include - ulp_fsm/include - ulp_fsm/include/${target}) - list(APPEND requires soc) - else() - message(FATAL_ERROR "__ULP_BUILDV2 requires ULP_TYPE to be one of: riscv, lp_core, fsm.") - endif() -else() - # TODO(IDF-15993): Keep esp_driver_gpio and esp_adc public for compatibility - # with the CMake v1 dependency graph until downstream users are fixed. +if(CONFIG_ULP_COPROC_ENABLED OR CONFIG_IDF_DOC_BUILD) + list(APPEND includes + ulp_common/include) list(APPEND requires - esp_adc - esp_driver_gpio) + esp_common + soc) +endif() - if(CONFIG_ULP_COPROC_ENABLED OR CONFIG_IDF_DOC_BUILD) - list(APPEND includes - ulp_common/include) - list(APPEND requires - esp_common - soc) - endif() +if(CONFIG_ULP_COPROC_TYPE_FSM OR (CONFIG_IDF_DOC_BUILD AND CONFIG_SOC_ULP_FSM_SUPPORTED)) + list(APPEND includes + ulp_fsm/include + ulp_fsm/include/${target}) + list(APPEND requires esp_hw_support) +endif() - if(CONFIG_ULP_COPROC_TYPE_FSM OR (CONFIG_IDF_DOC_BUILD AND CONFIG_SOC_ULP_FSM_SUPPORTED)) - list(APPEND includes - ulp_fsm/include - ulp_fsm/include/${target}) - list(APPEND requires esp_hw_support) - endif() +if(CONFIG_ULP_COPROC_TYPE_RISCV OR CONFIG_IDF_DOC_BUILD) + list(APPEND includes + ulp_riscv/include + ulp_riscv/shared/include + subproject/components/ulp_riscv/include) + list(APPEND requires esp_hw_support) +endif() - if(CONFIG_ULP_COPROC_TYPE_RISCV OR CONFIG_IDF_DOC_BUILD) - list(APPEND includes - ulp_riscv/include - ulp_riscv/shared/include - ulp_riscv/ulp_core/include) - list(APPEND requires esp_hw_support) - endif() +if(CONFIG_ULP_COPROC_TYPE_LP_CORE OR CONFIG_IDF_DOC_BUILD) + list(APPEND includes + lp_core/include + subproject/components/lp_core/include + lp_core/shared/include) +endif() - if(CONFIG_ULP_COPROC_TYPE_LP_CORE OR CONFIG_IDF_DOC_BUILD) - list(APPEND includes - lp_core/include - lp_core/lp_core/include - lp_core/shared/include) - endif() +if(CONFIG_ULP_COPROC_TYPE_FSM OR CONFIG_ULP_COPROC_TYPE_RISCV) + list(APPEND srcs + "ulp_common/ulp_common.c" + "ulp_common/ulp_adc.c") - if(CONFIG_ULP_COPROC_TYPE_FSM OR CONFIG_ULP_COPROC_TYPE_RISCV) + if(CONFIG_ULP_COPROC_TYPE_FSM) list(APPEND srcs - "ulp_common/ulp_common.c" - "ulp_common/ulp_adc.c") - - if(CONFIG_ULP_COPROC_TYPE_FSM) - list(APPEND srcs - "ulp_fsm/ulp.c" - "ulp_fsm/ulp_macro.c") - endif() - - if(CONFIG_ULP_COPROC_TYPE_RISCV) - list(APPEND srcs - "ulp_riscv/ulp_riscv.c" - "ulp_riscv/ulp_riscv_lock.c" - "ulp_riscv/ulp_riscv_i2c.c") - list(APPEND priv_requires esp_driver_gpio) - list(APPEND requires - # ulp/ulp_riscv/ulp_core/include/ulp_riscv_touch_ulp_core.h - # includes hal/touch_sens_types.h. - esp_hal_touch_sens - esp_hal_i2c - hal) - endif() + "ulp_fsm/ulp.c" + "ulp_fsm/ulp_macro.c") endif() - if(CONFIG_ULP_COPROC_TYPE_LP_CORE) + if(CONFIG_ULP_COPROC_TYPE_RISCV) list(APPEND srcs - "lp_core/lp_core.c" - "lp_core/shared/ulp_lp_core_memory_shared.c" - "lp_core/shared/ulp_lp_core_critical_section_shared.c") + "ulp_riscv/ulp_riscv.c" + "ulp_riscv/ulp_riscv_lock.c" + "ulp_riscv/ulp_riscv_i2c.c") + list(APPEND priv_requires esp_driver_gpio) list(APPEND requires - esp_common - esp_hal_pmu - esp_rom - hal - riscv - soc) - - if(CONFIG_SOC_ULP_LP_UART_SUPPORTED) - list(APPEND srcs - "lp_core/lp_core_uart.c" - "lp_core/shared/ulp_lp_core_lp_uart_shared.c") - list(APPEND requires - esp_driver_gpio - esp_driver_uart) - endif() - - if(CONFIG_SOC_LP_CORE_SUPPORT_I2C) - list(APPEND srcs "lp_core/lp_core_i2c.c") - list(APPEND requires - esp_driver_gpio - esp_hal_i2c) - endif() - - if(CONFIG_SOC_RTC_TIMER_V2 OR CONFIG_SOC_RTC_TIMER_V3) - list(APPEND srcs "lp_core/shared/ulp_lp_core_lp_timer_shared.c") - list(APPEND requires - esp_hal_clock - esp_hal_rtc_timer) - endif() - - if(CONFIG_SOC_LP_SPI_SUPPORTED) - list(APPEND srcs "lp_core/lp_core_spi.c") - list(APPEND requires - esp_driver_gpio - esp_hal_gpspi) - endif() - - if(CONFIG_SOC_LP_CORE_SUPPORT_ETM) - list(APPEND srcs "lp_core/lp_core_etm.c") - endif() - - if(CONFIG_SOC_TOUCH_SENSOR_SUPPORTED) - list(APPEND requires esp_hal_touch_sens) - endif() - - if(CONFIG_SOC_LP_ADC_SUPPORTED) - list(APPEND srcs "lp_core/shared/ulp_lp_core_lp_adc_shared.c") - list(APPEND priv_requires esp_hw_support) - endif() - - if(CONFIG_SOC_LP_VAD_SUPPORTED) - list(APPEND srcs "lp_core/shared/ulp_lp_core_lp_vad_shared.c") - list(APPEND requires esp_driver_i2s) - endif() - - list(APPEND srcs "lp_core/lp_core_mailbox.c") - if(CONFIG_SOC_LP_MAILBOX_SUPPORTED) - list(APPEND srcs "lp_core/lp_core_mailbox_impl_hw.c") - else() - list(APPEND srcs "lp_core/lp_core_mailbox_impl_sw.c") - endif() - endif() - - if(srcs) - list(APPEND priv_requires - bootloader_support - esp_mm) + # ulp/subproject/components/ulp_riscv/include/ulp_riscv_touch_ulp_core.h + # includes hal/touch_sens_types.h. + esp_hal_touch_sens + esp_hal_i2c + hal) endif() endif() -if(requires) - list(REMOVE_DUPLICATES requires) +if(CONFIG_ULP_COPROC_TYPE_LP_CORE) + list(APPEND srcs + "lp_core/lp_core.c" + "lp_core/shared/ulp_lp_core_memory_shared.c" + "lp_core/shared/ulp_lp_core_critical_section_shared.c") + list(APPEND requires + esp_common + esp_hal_pmu + esp_rom + hal + riscv + soc) + + if(CONFIG_SOC_ULP_LP_UART_SUPPORTED) + list(APPEND srcs + "lp_core/lp_core_uart.c" + "lp_core/shared/ulp_lp_core_lp_uart_shared.c") + list(APPEND requires + esp_driver_gpio + esp_driver_uart) + endif() + + if(CONFIG_SOC_LP_CORE_SUPPORT_I2C) + list(APPEND srcs "lp_core/lp_core_i2c.c") + list(APPEND requires + esp_driver_gpio + esp_hal_i2c) + endif() + + if(CONFIG_SOC_RTC_TIMER_V2 OR CONFIG_SOC_RTC_TIMER_V3) + list(APPEND srcs "lp_core/shared/ulp_lp_core_lp_timer_shared.c") + list(APPEND requires + esp_hal_clock + esp_hal_rtc_timer) + endif() + + if(CONFIG_SOC_LP_SPI_SUPPORTED) + list(APPEND srcs "lp_core/lp_core_spi.c") + list(APPEND requires + esp_driver_gpio + esp_hal_gpspi) + endif() + + if(CONFIG_SOC_LP_CORE_SUPPORT_ETM) + list(APPEND srcs "lp_core/lp_core_etm.c") + endif() + + if(CONFIG_SOC_TOUCH_SENSOR_SUPPORTED) + list(APPEND requires esp_hal_touch_sens) + endif() + + if(CONFIG_SOC_LP_ADC_SUPPORTED) + list(APPEND srcs "lp_core/shared/ulp_lp_core_lp_adc_shared.c") + list(APPEND priv_requires esp_hw_support) + endif() + + if(CONFIG_SOC_LP_VAD_SUPPORTED) + list(APPEND srcs "lp_core/shared/ulp_lp_core_lp_vad_shared.c") + list(APPEND requires esp_driver_i2s) + endif() + + list(APPEND srcs "lp_core/lp_core_mailbox.c") + if(CONFIG_SOC_LP_MAILBOX_SUPPORTED) + list(APPEND srcs "lp_core/lp_core_mailbox_impl_hw.c") + else() + list(APPEND srcs "lp_core/lp_core_mailbox_impl_sw.c") + endif() endif() -if(priv_requires) - list(REMOVE_DUPLICATES priv_requires) -endif() - -set(whole_archive) -if(__ULP_BUILDV2) - # Legacy ULP child builds added the LP-core runtime sources directly to the - # executable. Preserve that behavior so strong handlers such as - # ulp_lp_core_panic_handler are not dropped in favor of weak defaults from - # other runtime objects. - set(whole_archive WHOLE_ARCHIVE) +if(srcs) + list(APPEND priv_requires + bootloader_support + esp_mm) endif() +list(REMOVE_DUPLICATES requires) +list(REMOVE_DUPLICATES priv_requires) idf_component_register(SRCS ${srcs} INCLUDE_DIRS ${includes} REQUIRES ${requires} - PRIV_REQUIRES ${priv_requires} - ${whole_archive}) + PRIV_REQUIRES ${priv_requires}) -# In the parent app build, the ulp component only provides the host-side API. -# The executable/linker setup below is for native ULP child projects. -if(NOT __ULP_BUILDV2) - idf_define_esp_err_codes(HEADERS ulp_fsm/include/ulp_fsm_common.h) - return() -endif() - -# Preprocessor flags shared by every ULP memory-layout template. The template -# is a ".in" file, so the standard target_linker_script flow runs the C -# preprocessor on it. -D__ASSEMBLER__ keeps SoC headers to their macro-only -# form, and the component's own ld directory is available for relative -# includes. -set(ulp_ld_flags "-D__ASSEMBLER__ -I\"${CMAKE_CURRENT_SOURCE_DIR}/ld\"") - -# Select the linker template and target-specific link options used by the ULP -# executable created in the child project. The memory-layout template is -# registered with target_linker_script so the standard build system -# preprocesses and attaches it; per-type FLAGS supply the include directories -# its #include lines need. -if(ULP_TYPE STREQUAL "riscv") - target_linker_script(${COMPONENT_LIB} INTERFACE "ld/ulp_riscv.ld.in" MEMORY - FLAGS "${ulp_ld_flags}") - target_linker_script(${COMPONENT_LIB} INTERFACE "ld/${target}.peripherals.ld") - target_link_options(${COMPONENT_LIB} INTERFACE - -nostartfiles - -Wl,--gc-sections - -Wl,--no-warn-rwx-segments - LINKER:-u,main) - target_compile_definitions(${COMPONENT_LIB} PUBLIC - IS_ULP_COCPU - ULP_RISCV_REGISTER_OPS) -elseif(ULP_TYPE STREQUAL "lp_core") - # lp_core_riscv.ld includes soc/soc.h and esp_common headers, which are - # resolved automatically from the linked component graph. It also includes - # the esp_system ld snippets (ld.common, ld.hp_mem_defs); those live in the - # component's ld/ directory, which is not a public include dir, so pass it - # via FLAGS. - idf_component_get_property(esp_system_dir esp_system COMPONENT_DIR) - set(lp_core_ld_flags "${ulp_ld_flags} -I\"${esp_system_dir}/ld\" -I\"${esp_system_dir}/ld/${target}\"") - # A user-supplied LINKER layout replaces the default one composed into - # lp_core_riscv.ld.in. It reaches this child project as LP_CORE_LINKER_SCRIPT - # (passed by __setup_ulp_project, same as the CMake v1 path). Hand it to the - # wrapper as the LP_CORE_LINKER_INCLUDE macro it #includes. The escaped quotes - # survive separate_arguments() in the linker-script preprocessor so the macro - # expands to a quoted header-name token ("/abs/path.ld"). - if(LP_CORE_LINKER_SCRIPT) - message(STATUS "Using custom LP-core linker layout: ${LP_CORE_LINKER_SCRIPT}") - string(APPEND lp_core_ld_flags " -DLP_CORE_LINKER_INCLUDE=\\\"${LP_CORE_LINKER_SCRIPT}\\\"") - endif() - target_linker_script(${COMPONENT_LIB} INTERFACE "ld/lp_core_riscv.ld.in" MEMORY - FLAGS "${lp_core_ld_flags}") - - target_link_options(${COMPONENT_LIB} INTERFACE - -nostartfiles - -Wl,--gc-sections - -Wl,--no-warn-rwx-segments - LINKER:-u,main) - target_compile_definitions(${COMPONENT_LIB} PUBLIC IS_ULP_COCPU) - target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-implicit-fallthrough) -elseif(ULP_TYPE STREQUAL "fsm") - target_linker_script(${COMPONENT_LIB} INTERFACE "ld/ulp_fsm.ld.in" MEMORY - FLAGS "${ulp_ld_flags}") - target_link_options(${COMPONENT_LIB} INTERFACE "SHELL:-u entry") -endif() +idf_define_esp_err_codes(HEADERS ulp_fsm/include/ulp_fsm_common.h) diff --git a/components/ulp/project_include.cmake b/components/ulp/project_include.cmake index a5662f6442b..9733568660b 100644 --- a/components/ulp/project_include.cmake +++ b/components/ulp/project_include.cmake @@ -95,7 +95,7 @@ function(__setup_ulp_project app_name project_path prefix prefix_append_bin_name "Only FSM type is available for ULP on this target.") endif() endif() - set(TOOLCHAIN_FLAG ${ulp_subproject_dir}/toolchain-${idf_target}-ulp.cmake) + set(TOOLCHAIN_FLAG ${ulp_subproject_dir}/components/ulp_fsm/toolchain-${idf_target}-ulp.cmake) set(ULP_IS_RISCV OFF) elseif(IDF_TARGET STREQUAL "esp32s2" OR IDF_TARGET STREQUAL "esp32s3") # If both FSM and RISC-V are enabled in sdkconfig and a TYPE was @@ -105,21 +105,21 @@ function(__setup_ulp_project app_name project_path prefix prefix_append_bin_name message(STATUS "Both RISCV and FSM are enabled, using '${type}' toolchain for ${app_name} ULP project.") string(TOLOWER "${type}" type_lower) if(type_lower STREQUAL "riscv") - set(TOOLCHAIN_FLAG ${ulp_subproject_dir}/toolchain-ulp-riscv.cmake) + set(TOOLCHAIN_FLAG ${ulp_subproject_dir}/components/ulp_riscv/toolchain-ulp-riscv.cmake) elseif(type_lower STREQUAL "fsm") - set(TOOLCHAIN_FLAG ${ulp_subproject_dir}/toolchain-${idf_target}-ulp.cmake) + set(TOOLCHAIN_FLAG ${ulp_subproject_dir}/components/ulp_fsm/toolchain-${idf_target}-ulp.cmake) else() message(FATAL_ERROR "Invalid ULP_TYPE '${type}'; expected 'fsm' or 'riscv'.") endif() else() if(CONFIG_ULP_COPROC_TYPE_RISCV STREQUAL "y") - set(TOOLCHAIN_FLAG ${ulp_subproject_dir}/toolchain-ulp-riscv.cmake) + set(TOOLCHAIN_FLAG ${ulp_subproject_dir}/components/ulp_riscv/toolchain-ulp-riscv.cmake) else() - set(TOOLCHAIN_FLAG ${ulp_subproject_dir}/toolchain-${idf_target}-ulp.cmake) + set(TOOLCHAIN_FLAG ${ulp_subproject_dir}/components/ulp_fsm/toolchain-${idf_target}-ulp.cmake) endif() endif() elseif(CONFIG_ULP_COPROC_TYPE_LP_CORE) - set(TOOLCHAIN_FLAG ${ulp_subproject_dir}/toolchain-lp-core-riscv.cmake) + set(TOOLCHAIN_FLAG ${ulp_subproject_dir}/components/lp_core/toolchain-lp-core-riscv.cmake) endif() set(ulp_project_args) diff --git a/components/ulp/subproject/CMakeLists_v2.txt b/components/ulp/subproject/CMakeLists_v2.txt index a8e52e733f2..299a20e6c85 100644 --- a/components/ulp/subproject/CMakeLists_v2.txt +++ b/components/ulp/subproject/CMakeLists_v2.txt @@ -1,6 +1,6 @@ -# CMake v2 default ULP project for ulp_embed_binary() callers. The ULP runtime -# is built from the ulp component graph, and the legacy source list is attached -# directly to the executable, matching the CMake v1 link semantics. +# CMake v2 default ULP project for ulp_embed_binary() callers. The ULP program +# is built against the component for its architecture, and the call-site source +# list is linked before it, matching the build system v1 link semantics. include(${CMAKE_CURRENT_LIST_DIR}/ulp_project.cmake) if("${ULP_TYPE}" STREQUAL "fsm") @@ -49,7 +49,9 @@ function(__ulp_embed_binary_add_legacy_sources executable) __idf_build_link_whole_archive(${executable} PRIVATE ${legacy_sources_lib} BEFORE) endfunction() -set(executable_args COMPONENTS ulp) +__ulp_arch_component(ulp_component) + +set(executable_args COMPONENTS ${ulp_component}) if(NOT BUILD_FSM) list(APPEND executable_args MAPFILE_TARGET ${ULP_APP_NAME}_mapfile) endif() diff --git a/components/ulp/subproject/IDFULPProject.cmake b/components/ulp/subproject/IDFULPProject.cmake index 3ae78c21168..41ac84c7494 100644 --- a/components/ulp/subproject/IDFULPProject.cmake +++ b/components/ulp/subproject/IDFULPProject.cmake @@ -103,11 +103,11 @@ function(ulp_apply_default_sources ulp_app_name) # replaces the layout, swapped in by the wrapper. This is supported for the # LP-core type only. if(BUILD_RISCV) - set(ULP_LD_TEMPLATE ${IDF_PATH}/components/ulp/ld/ulp_riscv.ld.in) + set(ULP_LD_TEMPLATE ${IDF_PATH}/components/ulp/subproject/components/ulp_riscv/ld/ulp_riscv.ld.in) elseif(BUILD_LP_CORE) - set(ULP_LD_TEMPLATE ${IDF_PATH}/components/ulp/ld/lp_core_riscv.ld.in) + set(ULP_LD_TEMPLATE ${IDF_PATH}/components/ulp/subproject/components/lp_core/ld/lp_core_riscv.ld.in) elseif(BUILD_FSM) - set(ULP_LD_TEMPLATE ${IDF_PATH}/components/ulp/ld/ulp_fsm.ld.in) + set(ULP_LD_TEMPLATE ${IDF_PATH}/components/ulp/subproject/components/ulp_fsm/ld/ulp_fsm.ld.in) else() message(FATAL_ERROR "Unable to determine ULP type. ") endif() @@ -143,24 +143,27 @@ function(ulp_apply_default_sources ulp_app_name) if(BUILD_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" - "${IDF_PATH}/components/ulp/ulp_riscv/ulp_core/start.S" - "${IDF_PATH}/components/ulp/ulp_riscv/ulp_core/ulp_riscv_adc.c" - "${IDF_PATH}/components/ulp/ulp_riscv/ulp_core/ulp_riscv_lock.c" - "${IDF_PATH}/components/ulp/ulp_riscv/ulp_core/ulp_riscv_uart.c" - "${IDF_PATH}/components/ulp/ulp_riscv/ulp_core/ulp_riscv_print.c" - "${IDF_PATH}/components/ulp/ulp_riscv/ulp_core/ulp_riscv_i2c.c" - "${IDF_PATH}/components/ulp/ulp_riscv/ulp_core/ulp_riscv_utils.c" - "${IDF_PATH}/components/ulp/ulp_riscv/ulp_core/ulp_riscv_touch.c" - "${IDF_PATH}/components/ulp/ulp_riscv/ulp_core/ulp_riscv_gpio.c" - "${IDF_PATH}/components/ulp/ulp_riscv/ulp_core/ulp_riscv_interrupt.c") + "${IDF_PATH}/components/ulp/subproject/components/ulp_riscv/ulp_riscv_vectors.S" + "${IDF_PATH}/components/ulp/subproject/components/ulp_riscv/start.S" + "${IDF_PATH}/components/ulp/subproject/components/ulp_riscv/ulp_riscv_adc.c" + "${IDF_PATH}/components/ulp/subproject/components/ulp_riscv/ulp_riscv_lock.c" + "${IDF_PATH}/components/ulp/subproject/components/ulp_riscv/ulp_riscv_uart.c" + "${IDF_PATH}/components/ulp/subproject/components/ulp_riscv/ulp_riscv_print.c" + "${IDF_PATH}/components/ulp/subproject/components/ulp_riscv/ulp_riscv_i2c.c" + "${IDF_PATH}/components/ulp/subproject/components/ulp_riscv/ulp_riscv_utils.c" + "${IDF_PATH}/components/ulp/subproject/components/ulp_riscv/ulp_riscv_touch.c" + "${IDF_PATH}/components/ulp/subproject/components/ulp_riscv/ulp_riscv_gpio.c" + "${IDF_PATH}/components/ulp/subproject/components/ulp_riscv/ulp_riscv_interrupt.c") target_sources(${ulp_app_name} PRIVATE ${ULP_S_SOURCES}) #Makes the csr utillies for riscv visible: - target_include_directories(${ulp_app_name} PRIVATE "${IDF_PATH}/components/ulp/ulp_riscv/ulp_core/include" - "${IDF_PATH}/components/ulp/ulp_riscv/shared/include" - "${IDF_PATH}/components/riscv/include") - target_link_options(${ulp_app_name} PRIVATE SHELL:-T ${IDF_PATH}/components/ulp/ld/${IDF_TARGET}.peripherals.ld) + target_include_directories(${ulp_app_name} PRIVATE + "${IDF_PATH}/components/ulp/subproject/components/ulp_riscv/include" + "${IDF_PATH}/components/ulp/ulp_riscv/shared/include" + "${IDF_PATH}/components/riscv/include") + target_link_options(${ulp_app_name} + PRIVATE SHELL:-T + ${IDF_PATH}/components/ulp/subproject/components/ulp_riscv/ld/${IDF_TARGET}.peripherals.ld) target_compile_definitions(${ulp_app_name} PRIVATE IS_ULP_COCPU) target_compile_definitions(${ulp_app_name} PRIVATE ULP_RISCV_REGISTER_OPS) @@ -191,31 +194,31 @@ function(ulp_apply_default_sources ulp_app_name) elseif(BUILD_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" - "${IDF_PATH}/components/ulp/lp_core/lp_core/port/${IDF_TARGET}/vector_table.S" + "${IDF_PATH}/components/ulp/subproject/components/lp_core/start.S" + "${IDF_PATH}/components/ulp/subproject/components/lp_core/vector.S" + "${IDF_PATH}/components/ulp/subproject/components/lp_core/port/${IDF_TARGET}/vector_table.S" "${IDF_PATH}/components/ulp/lp_core/shared/ulp_lp_core_memory_shared.c" "${IDF_PATH}/components/ulp/lp_core/shared/ulp_lp_core_lp_timer_shared.c" - "${IDF_PATH}/components/ulp/lp_core/lp_core/lp_core_startup.c" - "${IDF_PATH}/components/ulp/lp_core/lp_core/lp_core_pmp.c" - "${IDF_PATH}/components/ulp/lp_core/lp_core/lp_core_utils.c" - "${IDF_PATH}/components/ulp/lp_core/lp_core/lp_core_print.c" - "${IDF_PATH}/components/ulp/lp_core/lp_core/lp_core_panic.c" - "${IDF_PATH}/components/ulp/lp_core/lp_core/lp_core_interrupt.c" - "${IDF_PATH}/components/ulp/lp_core/lp_core/lp_core_ubsan.c" - "${IDF_PATH}/components/ulp/lp_core/lp_core/lp_core_mailbox.c" + "${IDF_PATH}/components/ulp/subproject/components/lp_core/lp_core_startup.c" + "${IDF_PATH}/components/ulp/subproject/components/lp_core/lp_core_pmp.c" + "${IDF_PATH}/components/ulp/subproject/components/lp_core/lp_core_utils.c" + "${IDF_PATH}/components/ulp/subproject/components/lp_core/lp_core_print.c" + "${IDF_PATH}/components/ulp/subproject/components/lp_core/lp_core_panic.c" + "${IDF_PATH}/components/ulp/subproject/components/lp_core/lp_core_interrupt.c" + "${IDF_PATH}/components/ulp/subproject/components/lp_core/lp_core_ubsan.c" + "${IDF_PATH}/components/ulp/subproject/components/lp_core/lp_core_mailbox.c" "${IDF_PATH}/components/ulp/lp_core/shared/ulp_lp_core_lp_adc_shared.c" "${IDF_PATH}/components/ulp/lp_core/shared/ulp_lp_core_lp_vad_shared.c" "${IDF_PATH}/components/ulp/lp_core/shared/ulp_lp_core_critical_section_shared.c") if(CONFIG_SOC_LP_CORE_SUPPORT_I2C) list(APPEND ULP_S_SOURCES - "${IDF_PATH}/components/ulp/lp_core/lp_core/lp_core_i2c.c") + "${IDF_PATH}/components/ulp/subproject/components/lp_core/lp_core_i2c.c") endif() if(CONFIG_SOC_LP_SPI_SUPPORTED) list(APPEND ULP_S_SOURCES - "${IDF_PATH}/components/ulp/lp_core/lp_core/lp_core_spi.c") + "${IDF_PATH}/components/ulp/subproject/components/lp_core/lp_core_spi.c") endif() if(CONFIG_SOC_ULP_LP_UART_SUPPORTED) @@ -224,20 +227,20 @@ function(ulp_apply_default_sources ulp_app_name) "${IDF_PATH}/components/esp_driver_uart/src/uart_wakeup.c" "${IDF_PATH}/components/esp_hal_uart/uart_hal_iram.c" "${IDF_PATH}/components/esp_hal_uart/uart_hal.c" - "${IDF_PATH}/components/ulp/lp_core/lp_core/lp_core_uart.c") + "${IDF_PATH}/components/ulp/subproject/components/lp_core/lp_core_uart.c") endif() if(CONFIG_SOC_LP_MAILBOX_SUPPORTED) list(APPEND ULP_S_SOURCES - "${IDF_PATH}/components/ulp/lp_core/lp_core/port/lp_core_mailbox_impl_hw.c") + "${IDF_PATH}/components/ulp/subproject/components/lp_core/port/lp_core_mailbox_impl_hw.c") else() list(APPEND ULP_S_SOURCES - "${IDF_PATH}/components/ulp/lp_core/lp_core/port/lp_core_mailbox_impl_sw.c") + "${IDF_PATH}/components/ulp/subproject/components/lp_core/port/lp_core_mailbox_impl_sw.c") endif() if(CONFIG_SOC_TOUCH_SENSOR_SUPPORTED) list(APPEND ULP_S_SOURCES - "${IDF_PATH}/components/ulp/lp_core/lp_core/lp_core_touch.c") + "${IDF_PATH}/components/ulp/subproject/components/lp_core/lp_core_touch.c") endif() set(target_folder ${IDF_TARGET}) @@ -257,8 +260,9 @@ function(ulp_apply_default_sources ulp_app_name) endif() target_sources(${ulp_app_name} PRIVATE ${ULP_S_SOURCES}) - target_include_directories(${ulp_app_name} PRIVATE "${IDF_PATH}/components/ulp/lp_core/lp_core/include" - "${IDF_PATH}/components/ulp/lp_core/shared/include") + target_include_directories(${ulp_app_name} PRIVATE + "${IDF_PATH}/components/ulp/subproject/components/lp_core/include" + "${IDF_PATH}/components/ulp/lp_core/shared/include") target_compile_definitions(${ulp_app_name} PRIVATE IS_ULP_COCPU) endif() diff --git a/components/ulp/subproject/components/lp_core/CMakeLists.txt b/components/ulp/subproject/components/lp_core/CMakeLists.txt new file mode 100644 index 00000000000..32bbe1bcfea --- /dev/null +++ b/components/ulp/subproject/components/lp_core/CMakeLists.txt @@ -0,0 +1,120 @@ +# The code compiled for the LP core. +# +# Sources shared with the driver stay in components/ulp and are named by path +# from here. + +idf_build_get_property(target IDF_TARGET) +get_filename_component(ulp_dir "${CMAKE_CURRENT_LIST_DIR}/../../.." ABSOLUTE) + +set(srcs "start.S" + "vector.S" + "port/${target}/vector_table.S" + "${ulp_dir}/lp_core/shared/ulp_lp_core_memory_shared.c" + "lp_core_startup.c" + "lp_core_pmp.c" + "lp_core_utils.c" + "lp_core_print.c" + "lp_core_panic.c" + "lp_core_interrupt.c" + "lp_core_ubsan.c" + "lp_core_mailbox.c" + "${ulp_dir}/lp_core/shared/ulp_lp_core_critical_section_shared.c") + +set(requires esp_common + esp_hal_gpio + esp_hal_uart + esp_rom + hal + riscv + soc) +set(priv_requires esp_hal_pmu + esp_hw_support) + +if(CONFIG_SOC_RTC_TIMER_V2 OR CONFIG_SOC_RTC_TIMER_V3) + list(APPEND srcs "${ulp_dir}/lp_core/shared/ulp_lp_core_lp_timer_shared.c") + list(APPEND priv_requires esp_hal_clock esp_hal_rtc_timer) +endif() + +if(CONFIG_SOC_LP_CORE_SUPPORT_I2C) + list(APPEND srcs "lp_core_i2c.c") + list(APPEND requires esp_hal_i2c) +endif() + +if(CONFIG_SOC_LP_SPI_SUPPORTED) + list(APPEND srcs "lp_core_spi.c") + list(APPEND priv_requires esp_hal_gpspi) +endif() + +if(CONFIG_SOC_ULP_LP_UART_SUPPORTED) + list(APPEND srcs + "${ulp_dir}/lp_core/shared/ulp_lp_core_lp_uart_shared.c" + "lp_core_uart.c") + list(APPEND requires esp_driver_uart) +endif() + +if(CONFIG_SOC_LP_MAILBOX_SUPPORTED) + list(APPEND srcs "port/lp_core_mailbox_impl_hw.c") +else() + list(APPEND srcs "port/lp_core_mailbox_impl_sw.c") +endif() + +if(CONFIG_SOC_TOUCH_SENSOR_SUPPORTED) + list(APPEND srcs "lp_core_touch.c") + list(APPEND requires esp_hal_touch_sens) +endif() + +if(CONFIG_SOC_LP_ADC_SUPPORTED) + list(APPEND srcs "${ulp_dir}/lp_core/shared/ulp_lp_core_lp_adc_shared.c") + list(APPEND requires esp_adc esp_hal_ana_conv) +endif() + +if(CONFIG_SOC_LP_VAD_SUPPORTED) + list(APPEND srcs "${ulp_dir}/lp_core/shared/ulp_lp_core_lp_vad_shared.c") + list(APPEND requires esp_driver_i2s) +endif() + +# The ULP subproject in build system v1 adds these sources straight to the +# executable, so a strong handler such as ulp_lp_core_panic_handler is not +# dropped in favour of a weak default from another runtime object. +# WHOLE_ARCHIVE keeps that behaviour here. +idf_component_register(SRCS ${srcs} + INCLUDE_DIRS "${ulp_dir}/ulp_common/include" + "${ulp_dir}/lp_core/include" + "include" + "${ulp_dir}/lp_core/shared/include" + REQUIRES ${requires} + PRIV_REQUIRES ${priv_requires} + WHOLE_ARCHIVE) + +# -D__ASSEMBLER__ keeps the SoC headers to their macro-only form. +set(ulp_ld_flags "-D__ASSEMBLER__ -I\"${CMAKE_CURRENT_SOURCE_DIR}/ld\"") + +# lp_core_riscv.ld includes soc/soc.h and esp_common headers, resolved from the +# linked component graph. It also includes the esp_system ld snippets +# (ld.common, ld.hp_mem_defs); those live in that component's ld/ directory, +# which is not a public include dir, so pass it via FLAGS. +idf_component_get_property(esp_system_dir esp_system COMPONENT_DIR) +set(lp_core_ld_flags "${ulp_ld_flags} -I\"${esp_system_dir}/ld\" -I\"${esp_system_dir}/ld/${target}\"") + +# A user-supplied LINKER layout replaces the default one composed into +# lp_core_riscv.ld.in. It reaches this child project as LP_CORE_LINKER_SCRIPT +# (passed by __setup_ulp_project, same as the build system v1 path). Hand it to +# the wrapper as the LP_CORE_LINKER_INCLUDE macro it #includes. The escaped +# quotes survive separate_arguments() in the linker-script preprocessor so the +# macro expands to a quoted header-name token ("/abs/path.ld"). +if(LP_CORE_LINKER_SCRIPT) + message(STATUS "Using custom LP-core linker layout: ${LP_CORE_LINKER_SCRIPT}") + string(APPEND lp_core_ld_flags " -DLP_CORE_LINKER_INCLUDE=\\\"${LP_CORE_LINKER_SCRIPT}\\\"") +endif() + +target_linker_script(${COMPONENT_LIB} INTERFACE "ld/lp_core_riscv.ld.in" MEMORY + FLAGS "${lp_core_ld_flags}") + +target_link_options(${COMPONENT_LIB} INTERFACE + -nostartfiles + -Wl,--gc-sections + -Wl,--no-warn-rwx-segments + LINKER:-u,main) + +target_compile_definitions(${COMPONENT_LIB} PUBLIC IS_ULP_COCPU) +target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-implicit-fallthrough) diff --git a/components/ulp/lp_core/lp_core/include/ulp_lp_core_gpio.h b/components/ulp/subproject/components/lp_core/include/ulp_lp_core_gpio.h similarity index 100% rename from components/ulp/lp_core/lp_core/include/ulp_lp_core_gpio.h rename to components/ulp/subproject/components/lp_core/include/ulp_lp_core_gpio.h diff --git a/components/ulp/lp_core/lp_core/include/ulp_lp_core_i2c.h b/components/ulp/subproject/components/lp_core/include/ulp_lp_core_i2c.h similarity index 100% rename from components/ulp/lp_core/lp_core/include/ulp_lp_core_i2c.h rename to components/ulp/subproject/components/lp_core/include/ulp_lp_core_i2c.h diff --git a/components/ulp/lp_core/lp_core/include/ulp_lp_core_interrupts.h b/components/ulp/subproject/components/lp_core/include/ulp_lp_core_interrupts.h similarity index 100% rename from components/ulp/lp_core/lp_core/include/ulp_lp_core_interrupts.h rename to components/ulp/subproject/components/lp_core/include/ulp_lp_core_interrupts.h diff --git a/components/ulp/lp_core/lp_core/include/ulp_lp_core_mailbox.h b/components/ulp/subproject/components/lp_core/include/ulp_lp_core_mailbox.h similarity index 100% rename from components/ulp/lp_core/lp_core/include/ulp_lp_core_mailbox.h rename to components/ulp/subproject/components/lp_core/include/ulp_lp_core_mailbox.h diff --git a/components/ulp/lp_core/lp_core/include/ulp_lp_core_pmp.h b/components/ulp/subproject/components/lp_core/include/ulp_lp_core_pmp.h similarity index 100% rename from components/ulp/lp_core/lp_core/include/ulp_lp_core_pmp.h rename to components/ulp/subproject/components/lp_core/include/ulp_lp_core_pmp.h diff --git a/components/ulp/lp_core/lp_core/include/ulp_lp_core_print.h b/components/ulp/subproject/components/lp_core/include/ulp_lp_core_print.h similarity index 100% rename from components/ulp/lp_core/lp_core/include/ulp_lp_core_print.h rename to components/ulp/subproject/components/lp_core/include/ulp_lp_core_print.h diff --git a/components/ulp/lp_core/lp_core/include/ulp_lp_core_spi.h b/components/ulp/subproject/components/lp_core/include/ulp_lp_core_spi.h similarity index 100% rename from components/ulp/lp_core/lp_core/include/ulp_lp_core_spi.h rename to components/ulp/subproject/components/lp_core/include/ulp_lp_core_spi.h diff --git a/components/ulp/lp_core/lp_core/include/ulp_lp_core_touch.h b/components/ulp/subproject/components/lp_core/include/ulp_lp_core_touch.h similarity index 100% rename from components/ulp/lp_core/lp_core/include/ulp_lp_core_touch.h rename to components/ulp/subproject/components/lp_core/include/ulp_lp_core_touch.h diff --git a/components/ulp/lp_core/lp_core/include/ulp_lp_core_uart.h b/components/ulp/subproject/components/lp_core/include/ulp_lp_core_uart.h similarity index 100% rename from components/ulp/lp_core/lp_core/include/ulp_lp_core_uart.h rename to components/ulp/subproject/components/lp_core/include/ulp_lp_core_uart.h diff --git a/components/ulp/lp_core/lp_core/include/ulp_lp_core_utils.h b/components/ulp/subproject/components/lp_core/include/ulp_lp_core_utils.h similarity index 100% rename from components/ulp/lp_core/lp_core/include/ulp_lp_core_utils.h rename to components/ulp/subproject/components/lp_core/include/ulp_lp_core_utils.h diff --git a/components/ulp/ld/lp_core_riscv.ld.in b/components/ulp/subproject/components/lp_core/ld/lp_core_riscv.ld.in similarity index 100% rename from components/ulp/ld/lp_core_riscv.ld.in rename to components/ulp/subproject/components/lp_core/ld/lp_core_riscv.ld.in diff --git a/components/ulp/ld/lp_core_riscv_base.ld.in b/components/ulp/subproject/components/lp_core/ld/lp_core_riscv_base.ld.in similarity index 100% rename from components/ulp/ld/lp_core_riscv_base.ld.in rename to components/ulp/subproject/components/lp_core/ld/lp_core_riscv_base.ld.in diff --git a/components/ulp/ld/lp_core_riscv_checks.ld.in b/components/ulp/subproject/components/lp_core/ld/lp_core_riscv_checks.ld.in similarity index 100% rename from components/ulp/ld/lp_core_riscv_checks.ld.in rename to components/ulp/subproject/components/lp_core/ld/lp_core_riscv_checks.ld.in diff --git a/components/ulp/ld/lp_core_riscv_default_layout.ld.in b/components/ulp/subproject/components/lp_core/ld/lp_core_riscv_default_layout.ld.in similarity index 100% rename from components/ulp/ld/lp_core_riscv_default_layout.ld.in rename to components/ulp/subproject/components/lp_core/ld/lp_core_riscv_default_layout.ld.in diff --git a/components/ulp/lp_core/lp_core/lp_core_i2c.c b/components/ulp/subproject/components/lp_core/lp_core_i2c.c similarity index 100% rename from components/ulp/lp_core/lp_core/lp_core_i2c.c rename to components/ulp/subproject/components/lp_core/lp_core_i2c.c diff --git a/components/ulp/lp_core/lp_core/lp_core_interrupt.c b/components/ulp/subproject/components/lp_core/lp_core_interrupt.c similarity index 100% rename from components/ulp/lp_core/lp_core/lp_core_interrupt.c rename to components/ulp/subproject/components/lp_core/lp_core_interrupt.c diff --git a/components/ulp/lp_core/lp_core/lp_core_mailbox.c b/components/ulp/subproject/components/lp_core/lp_core_mailbox.c similarity index 100% rename from components/ulp/lp_core/lp_core/lp_core_mailbox.c rename to components/ulp/subproject/components/lp_core/lp_core_mailbox.c diff --git a/components/ulp/lp_core/lp_core/lp_core_panic.c b/components/ulp/subproject/components/lp_core/lp_core_panic.c similarity index 100% rename from components/ulp/lp_core/lp_core/lp_core_panic.c rename to components/ulp/subproject/components/lp_core/lp_core_panic.c diff --git a/components/ulp/lp_core/lp_core/lp_core_pmp.c b/components/ulp/subproject/components/lp_core/lp_core_pmp.c similarity index 100% rename from components/ulp/lp_core/lp_core/lp_core_pmp.c rename to components/ulp/subproject/components/lp_core/lp_core_pmp.c diff --git a/components/ulp/lp_core/lp_core/lp_core_print.c b/components/ulp/subproject/components/lp_core/lp_core_print.c similarity index 100% rename from components/ulp/lp_core/lp_core/lp_core_print.c rename to components/ulp/subproject/components/lp_core/lp_core_print.c diff --git a/components/ulp/lp_core/lp_core/lp_core_spi.c b/components/ulp/subproject/components/lp_core/lp_core_spi.c similarity index 100% rename from components/ulp/lp_core/lp_core/lp_core_spi.c rename to components/ulp/subproject/components/lp_core/lp_core_spi.c diff --git a/components/ulp/lp_core/lp_core/lp_core_startup.c b/components/ulp/subproject/components/lp_core/lp_core_startup.c similarity index 100% rename from components/ulp/lp_core/lp_core/lp_core_startup.c rename to components/ulp/subproject/components/lp_core/lp_core_startup.c diff --git a/components/ulp/lp_core/lp_core/lp_core_touch.c b/components/ulp/subproject/components/lp_core/lp_core_touch.c similarity index 100% rename from components/ulp/lp_core/lp_core/lp_core_touch.c rename to components/ulp/subproject/components/lp_core/lp_core_touch.c diff --git a/components/ulp/lp_core/lp_core/lp_core_uart.c b/components/ulp/subproject/components/lp_core/lp_core_uart.c similarity index 100% rename from components/ulp/lp_core/lp_core/lp_core_uart.c rename to components/ulp/subproject/components/lp_core/lp_core_uart.c diff --git a/components/ulp/lp_core/lp_core/lp_core_ubsan.c b/components/ulp/subproject/components/lp_core/lp_core_ubsan.c similarity index 100% rename from components/ulp/lp_core/lp_core/lp_core_ubsan.c rename to components/ulp/subproject/components/lp_core/lp_core_ubsan.c diff --git a/components/ulp/lp_core/lp_core/lp_core_utils.c b/components/ulp/subproject/components/lp_core/lp_core_utils.c similarity index 100% rename from components/ulp/lp_core/lp_core/lp_core_utils.c rename to components/ulp/subproject/components/lp_core/lp_core_utils.c diff --git a/components/ulp/lp_core/lp_core/port/esp32c5/vector_table.S b/components/ulp/subproject/components/lp_core/port/esp32c5/vector_table.S similarity index 100% rename from components/ulp/lp_core/lp_core/port/esp32c5/vector_table.S rename to components/ulp/subproject/components/lp_core/port/esp32c5/vector_table.S diff --git a/components/ulp/lp_core/lp_core/port/esp32c6/vector_table.S b/components/ulp/subproject/components/lp_core/port/esp32c6/vector_table.S similarity index 100% rename from components/ulp/lp_core/lp_core/port/esp32c6/vector_table.S rename to components/ulp/subproject/components/lp_core/port/esp32c6/vector_table.S diff --git a/components/ulp/lp_core/lp_core/port/esp32p4/vector_table.S b/components/ulp/subproject/components/lp_core/port/esp32p4/vector_table.S similarity index 100% rename from components/ulp/lp_core/lp_core/port/esp32p4/vector_table.S rename to components/ulp/subproject/components/lp_core/port/esp32p4/vector_table.S diff --git a/components/ulp/lp_core/lp_core/port/esp32s31/vector_table.S b/components/ulp/subproject/components/lp_core/port/esp32s31/vector_table.S similarity index 100% rename from components/ulp/lp_core/lp_core/port/esp32s31/vector_table.S rename to components/ulp/subproject/components/lp_core/port/esp32s31/vector_table.S diff --git a/components/ulp/lp_core/lp_core/port/lp_core_mailbox_impl_hw.c b/components/ulp/subproject/components/lp_core/port/lp_core_mailbox_impl_hw.c similarity index 100% rename from components/ulp/lp_core/lp_core/port/lp_core_mailbox_impl_hw.c rename to components/ulp/subproject/components/lp_core/port/lp_core_mailbox_impl_hw.c diff --git a/components/ulp/lp_core/lp_core/port/lp_core_mailbox_impl_sw.c b/components/ulp/subproject/components/lp_core/port/lp_core_mailbox_impl_sw.c similarity index 100% rename from components/ulp/lp_core/lp_core/port/lp_core_mailbox_impl_sw.c rename to components/ulp/subproject/components/lp_core/port/lp_core_mailbox_impl_sw.c diff --git a/components/ulp/lp_core/lp_core/start.S b/components/ulp/subproject/components/lp_core/start.S similarity index 100% rename from components/ulp/lp_core/lp_core/start.S rename to components/ulp/subproject/components/lp_core/start.S diff --git a/components/ulp/subproject/toolchain-lp-core-riscv.cmake b/components/ulp/subproject/components/lp_core/toolchain-lp-core-riscv.cmake similarity index 100% rename from components/ulp/subproject/toolchain-lp-core-riscv.cmake rename to components/ulp/subproject/components/lp_core/toolchain-lp-core-riscv.cmake diff --git a/components/ulp/lp_core/lp_core/vector.S b/components/ulp/subproject/components/lp_core/vector.S similarity index 100% rename from components/ulp/lp_core/lp_core/vector.S rename to components/ulp/subproject/components/lp_core/vector.S diff --git a/components/ulp/subproject/components/ulp_fsm/CMakeLists.txt b/components/ulp/subproject/components/ulp_fsm/CMakeLists.txt new file mode 100644 index 00000000000..eed8b34db23 --- /dev/null +++ b/components/ulp/subproject/components/ulp_fsm/CMakeLists.txt @@ -0,0 +1,21 @@ +# What a ULP FSM program is built against. +# +# An FSM program is assembled from the application's own sources, so this +# component carries no sources of its own: it publishes the headers the program +# is written against and the memory layout it is linked with. + +idf_build_get_property(target IDF_TARGET) +get_filename_component(ulp_dir "${CMAKE_CURRENT_LIST_DIR}/../../.." ABSOLUTE) + +idf_component_register( + INCLUDE_DIRS "${ulp_dir}/ulp_common/include" + "${ulp_dir}/ulp_fsm/include" + "${ulp_dir}/ulp_fsm/include/${target}" + REQUIRES soc) + +# -D__ASSEMBLER__ keeps the SoC headers to their macro-only form. +set(ulp_ld_flags "-D__ASSEMBLER__ -I\"${CMAKE_CURRENT_SOURCE_DIR}/ld\"") + +target_linker_script(${COMPONENT_LIB} INTERFACE "ld/ulp_fsm.ld.in" MEMORY + FLAGS "${ulp_ld_flags}") +target_link_options(${COMPONENT_LIB} INTERFACE "SHELL:-u entry") diff --git a/components/ulp/ld/ulp_fsm.ld.in b/components/ulp/subproject/components/ulp_fsm/ld/ulp_fsm.ld.in similarity index 100% rename from components/ulp/ld/ulp_fsm.ld.in rename to components/ulp/subproject/components/ulp_fsm/ld/ulp_fsm.ld.in diff --git a/components/ulp/subproject/preprocess_fsm_asm.cmake b/components/ulp/subproject/components/ulp_fsm/preprocess_fsm_asm.cmake similarity index 100% rename from components/ulp/subproject/preprocess_fsm_asm.cmake rename to components/ulp/subproject/components/ulp_fsm/preprocess_fsm_asm.cmake diff --git a/components/ulp/subproject/toolchain-esp32-ulp.cmake b/components/ulp/subproject/components/ulp_fsm/toolchain-esp32-ulp.cmake similarity index 100% rename from components/ulp/subproject/toolchain-esp32-ulp.cmake rename to components/ulp/subproject/components/ulp_fsm/toolchain-esp32-ulp.cmake diff --git a/components/ulp/subproject/toolchain-esp32s2-ulp.cmake b/components/ulp/subproject/components/ulp_fsm/toolchain-esp32s2-ulp.cmake similarity index 100% rename from components/ulp/subproject/toolchain-esp32s2-ulp.cmake rename to components/ulp/subproject/components/ulp_fsm/toolchain-esp32s2-ulp.cmake diff --git a/components/ulp/subproject/toolchain-esp32s3-ulp.cmake b/components/ulp/subproject/components/ulp_fsm/toolchain-esp32s3-ulp.cmake similarity index 100% rename from components/ulp/subproject/toolchain-esp32s3-ulp.cmake rename to components/ulp/subproject/components/ulp_fsm/toolchain-esp32s3-ulp.cmake diff --git a/components/ulp/subproject/components/ulp_riscv/CMakeLists.txt b/components/ulp/subproject/components/ulp_riscv/CMakeLists.txt new file mode 100644 index 00000000000..fc8a377b64c --- /dev/null +++ b/components/ulp/subproject/components/ulp_riscv/CMakeLists.txt @@ -0,0 +1,53 @@ +# The code compiled for the ULP RISC-V coprocessor. +# +# Sources shared with the driver stay in components/ulp and are named by path +# from here. + +idf_build_get_property(target IDF_TARGET) +get_filename_component(ulp_dir "${CMAKE_CURRENT_LIST_DIR}/../../.." ABSOLUTE) + +# The ULP subproject in build system v1 adds these sources straight to the +# executable, so a strong handler is not dropped in favour of a weak default +# from another runtime object. WHOLE_ARCHIVE keeps that behaviour here. +idf_component_register( + SRCS "ulp_riscv_vectors.S" + "start.S" + "ulp_riscv_adc.c" + "ulp_riscv_lock.c" + "ulp_riscv_uart.c" + "ulp_riscv_print.c" + "ulp_riscv_i2c.c" + "ulp_riscv_utils.c" + "ulp_riscv_touch.c" + "ulp_riscv_gpio.c" + "ulp_riscv_interrupt.c" + INCLUDE_DIRS "${ulp_dir}/ulp_common/include" + "${ulp_dir}/ulp_riscv/include" + "${ulp_dir}/ulp_riscv/shared/include" + "include" + REQUIRES esp_common + esp_hal_ana_conv + esp_hal_gpio + esp_hal_i2c + esp_hal_touch_sens + esp_hw_support + riscv + soc + WHOLE_ARCHIVE) + +# -D__ASSEMBLER__ keeps the SoC headers to their macro-only form. +set(ulp_ld_flags "-D__ASSEMBLER__ -I\"${CMAKE_CURRENT_SOURCE_DIR}/ld\"") + +target_linker_script(${COMPONENT_LIB} INTERFACE "ld/ulp_riscv.ld.in" MEMORY + FLAGS "${ulp_ld_flags}") +target_linker_script(${COMPONENT_LIB} INTERFACE "ld/${target}.peripherals.ld") + +target_link_options(${COMPONENT_LIB} INTERFACE + -nostartfiles + -Wl,--gc-sections + -Wl,--no-warn-rwx-segments + LINKER:-u,main) + +target_compile_definitions(${COMPONENT_LIB} PUBLIC + IS_ULP_COCPU + ULP_RISCV_REGISTER_OPS) diff --git a/components/ulp/ulp_riscv/ulp_core/include/ulp_riscv_adc_ulp_core.h b/components/ulp/subproject/components/ulp_riscv/include/ulp_riscv_adc_ulp_core.h similarity index 100% rename from components/ulp/ulp_riscv/ulp_core/include/ulp_riscv_adc_ulp_core.h rename to components/ulp/subproject/components/ulp_riscv/include/ulp_riscv_adc_ulp_core.h diff --git a/components/ulp/ulp_riscv/ulp_core/include/ulp_riscv_gpio.h b/components/ulp/subproject/components/ulp_riscv/include/ulp_riscv_gpio.h similarity index 100% rename from components/ulp/ulp_riscv/ulp_core/include/ulp_riscv_gpio.h rename to components/ulp/subproject/components/ulp_riscv/include/ulp_riscv_gpio.h diff --git a/components/ulp/ulp_riscv/ulp_core/include/ulp_riscv_i2c_ulp_core.h b/components/ulp/subproject/components/ulp_riscv/include/ulp_riscv_i2c_ulp_core.h similarity index 100% rename from components/ulp/ulp_riscv/ulp_core/include/ulp_riscv_i2c_ulp_core.h rename to components/ulp/subproject/components/ulp_riscv/include/ulp_riscv_i2c_ulp_core.h diff --git a/components/ulp/ulp_riscv/ulp_core/include/ulp_riscv_interrupt.h b/components/ulp/subproject/components/ulp_riscv/include/ulp_riscv_interrupt.h similarity index 100% rename from components/ulp/ulp_riscv/ulp_core/include/ulp_riscv_interrupt.h rename to components/ulp/subproject/components/ulp_riscv/include/ulp_riscv_interrupt.h diff --git a/components/ulp/ulp_riscv/ulp_core/include/ulp_riscv_interrupt_ops.h b/components/ulp/subproject/components/ulp_riscv/include/ulp_riscv_interrupt_ops.h similarity index 98% rename from components/ulp/ulp_riscv/ulp_core/include/ulp_riscv_interrupt_ops.h rename to components/ulp/subproject/components/ulp_riscv/include/ulp_riscv_interrupt_ops.h index f902507995a..c354375653f 100644 --- a/components/ulp/ulp_riscv/ulp_core/include/ulp_riscv_interrupt_ops.h +++ b/components/ulp/subproject/components/ulp_riscv/include/ulp_riscv_interrupt_ops.h @@ -80,7 +80,7 @@ r_type_insn(0b0000001, 0, regnum_ ## _rs, 0b010, regnum_ ## _qd, 0b0001011) /** * Instruction: retirq - * Description: This instruction copies the value of Q0 to CPU PC, and renables interrupts + * Description: This instruction copies the value of Q0 to CPU PC, and re-enables interrupts */ #define retirq_insn() \ r_type_insn(0b0000010, 0, 0, 0b000, 0, 0b0001011) diff --git a/components/ulp/ulp_riscv/ulp_core/include/ulp_riscv_lock_ulp_core.h b/components/ulp/subproject/components/ulp_riscv/include/ulp_riscv_lock_ulp_core.h similarity index 100% rename from components/ulp/ulp_riscv/ulp_core/include/ulp_riscv_lock_ulp_core.h rename to components/ulp/subproject/components/ulp_riscv/include/ulp_riscv_lock_ulp_core.h diff --git a/components/ulp/ulp_riscv/ulp_core/include/ulp_riscv_print.h b/components/ulp/subproject/components/ulp_riscv/include/ulp_riscv_print.h similarity index 100% rename from components/ulp/ulp_riscv/ulp_core/include/ulp_riscv_print.h rename to components/ulp/subproject/components/ulp_riscv/include/ulp_riscv_print.h diff --git a/components/ulp/ulp_riscv/ulp_core/include/ulp_riscv_register_ops.h b/components/ulp/subproject/components/ulp_riscv/include/ulp_riscv_register_ops.h similarity index 100% rename from components/ulp/ulp_riscv/ulp_core/include/ulp_riscv_register_ops.h rename to components/ulp/subproject/components/ulp_riscv/include/ulp_riscv_register_ops.h diff --git a/components/ulp/ulp_riscv/ulp_core/include/ulp_riscv_touch_ulp_core.h b/components/ulp/subproject/components/ulp_riscv/include/ulp_riscv_touch_ulp_core.h similarity index 100% rename from components/ulp/ulp_riscv/ulp_core/include/ulp_riscv_touch_ulp_core.h rename to components/ulp/subproject/components/ulp_riscv/include/ulp_riscv_touch_ulp_core.h diff --git a/components/ulp/ulp_riscv/ulp_core/include/ulp_riscv_uart_ulp_core.h b/components/ulp/subproject/components/ulp_riscv/include/ulp_riscv_uart_ulp_core.h similarity index 100% rename from components/ulp/ulp_riscv/ulp_core/include/ulp_riscv_uart_ulp_core.h rename to components/ulp/subproject/components/ulp_riscv/include/ulp_riscv_uart_ulp_core.h diff --git a/components/ulp/ulp_riscv/ulp_core/include/ulp_riscv_utils.h b/components/ulp/subproject/components/ulp_riscv/include/ulp_riscv_utils.h similarity index 100% rename from components/ulp/ulp_riscv/ulp_core/include/ulp_riscv_utils.h rename to components/ulp/subproject/components/ulp_riscv/include/ulp_riscv_utils.h diff --git a/components/ulp/ld/esp32s2.peripherals.ld b/components/ulp/subproject/components/ulp_riscv/ld/esp32s2.peripherals.ld similarity index 100% rename from components/ulp/ld/esp32s2.peripherals.ld rename to components/ulp/subproject/components/ulp_riscv/ld/esp32s2.peripherals.ld diff --git a/components/ulp/ld/esp32s3.peripherals.ld b/components/ulp/subproject/components/ulp_riscv/ld/esp32s3.peripherals.ld similarity index 100% rename from components/ulp/ld/esp32s3.peripherals.ld rename to components/ulp/subproject/components/ulp_riscv/ld/esp32s3.peripherals.ld diff --git a/components/ulp/ld/ulp_riscv.ld.in b/components/ulp/subproject/components/ulp_riscv/ld/ulp_riscv.ld.in similarity index 100% rename from components/ulp/ld/ulp_riscv.ld.in rename to components/ulp/subproject/components/ulp_riscv/ld/ulp_riscv.ld.in diff --git a/components/ulp/ulp_riscv/ulp_core/start.S b/components/ulp/subproject/components/ulp_riscv/start.S similarity index 100% rename from components/ulp/ulp_riscv/ulp_core/start.S rename to components/ulp/subproject/components/ulp_riscv/start.S diff --git a/components/ulp/subproject/toolchain-ulp-riscv.cmake b/components/ulp/subproject/components/ulp_riscv/toolchain-ulp-riscv.cmake similarity index 100% rename from components/ulp/subproject/toolchain-ulp-riscv.cmake rename to components/ulp/subproject/components/ulp_riscv/toolchain-ulp-riscv.cmake diff --git a/components/ulp/ulp_riscv/ulp_core/ulp_riscv_adc.c b/components/ulp/subproject/components/ulp_riscv/ulp_riscv_adc.c similarity index 100% rename from components/ulp/ulp_riscv/ulp_core/ulp_riscv_adc.c rename to components/ulp/subproject/components/ulp_riscv/ulp_riscv_adc.c diff --git a/components/ulp/ulp_riscv/ulp_core/ulp_riscv_gpio.c b/components/ulp/subproject/components/ulp_riscv/ulp_riscv_gpio.c similarity index 100% rename from components/ulp/ulp_riscv/ulp_core/ulp_riscv_gpio.c rename to components/ulp/subproject/components/ulp_riscv/ulp_riscv_gpio.c diff --git a/components/ulp/ulp_riscv/ulp_core/ulp_riscv_i2c.c b/components/ulp/subproject/components/ulp_riscv/ulp_riscv_i2c.c similarity index 100% rename from components/ulp/ulp_riscv/ulp_core/ulp_riscv_i2c.c rename to components/ulp/subproject/components/ulp_riscv/ulp_riscv_i2c.c diff --git a/components/ulp/ulp_riscv/ulp_core/ulp_riscv_interrupt.c b/components/ulp/subproject/components/ulp_riscv/ulp_riscv_interrupt.c similarity index 100% rename from components/ulp/ulp_riscv/ulp_core/ulp_riscv_interrupt.c rename to components/ulp/subproject/components/ulp_riscv/ulp_riscv_interrupt.c diff --git a/components/ulp/ulp_riscv/ulp_core/ulp_riscv_lock.c b/components/ulp/subproject/components/ulp_riscv/ulp_riscv_lock.c similarity index 100% rename from components/ulp/ulp_riscv/ulp_core/ulp_riscv_lock.c rename to components/ulp/subproject/components/ulp_riscv/ulp_riscv_lock.c diff --git a/components/ulp/ulp_riscv/ulp_core/ulp_riscv_print.c b/components/ulp/subproject/components/ulp_riscv/ulp_riscv_print.c similarity index 100% rename from components/ulp/ulp_riscv/ulp_core/ulp_riscv_print.c rename to components/ulp/subproject/components/ulp_riscv/ulp_riscv_print.c diff --git a/components/ulp/ulp_riscv/ulp_core/ulp_riscv_touch.c b/components/ulp/subproject/components/ulp_riscv/ulp_riscv_touch.c similarity index 100% rename from components/ulp/ulp_riscv/ulp_core/ulp_riscv_touch.c rename to components/ulp/subproject/components/ulp_riscv/ulp_riscv_touch.c diff --git a/components/ulp/ulp_riscv/ulp_core/ulp_riscv_uart.c b/components/ulp/subproject/components/ulp_riscv/ulp_riscv_uart.c similarity index 100% rename from components/ulp/ulp_riscv/ulp_core/ulp_riscv_uart.c rename to components/ulp/subproject/components/ulp_riscv/ulp_riscv_uart.c diff --git a/components/ulp/ulp_riscv/ulp_core/ulp_riscv_utils.c b/components/ulp/subproject/components/ulp_riscv/ulp_riscv_utils.c similarity index 100% rename from components/ulp/ulp_riscv/ulp_core/ulp_riscv_utils.c rename to components/ulp/subproject/components/ulp_riscv/ulp_riscv_utils.c diff --git a/components/ulp/ulp_riscv/ulp_core/ulp_riscv_vectors.S b/components/ulp/subproject/components/ulp_riscv/ulp_riscv_vectors.S similarity index 100% rename from components/ulp/ulp_riscv/ulp_core/ulp_riscv_vectors.S rename to components/ulp/subproject/components/ulp_riscv/ulp_riscv_vectors.S diff --git a/components/ulp/subproject/ulp_project.cmake b/components/ulp/subproject/ulp_project.cmake index 96dfe0129ec..321bf969192 100644 --- a/components/ulp/subproject/ulp_project.cmake +++ b/components/ulp/subproject/ulp_project.cmake @@ -6,6 +6,11 @@ # ulp_project_default, the ULP analogs of idf_project_init, # idf_build_executable, idf_build_binary and idf_project_default. +# The components a ULP program is built against live inside this subproject, so +# an application build does not discover them. Added before components are +# searched for. +list(APPEND EXTRA_COMPONENT_DIRS "${CMAKE_CURRENT_LIST_DIR}/components") + include(${IDF_PATH}/tools/cmakev2/idf.cmake) include(${CMAKE_CURRENT_LIST_DIR}/IDFULPProjectCommon.cmake) @@ -17,6 +22,21 @@ if(__ULP_BUILDV2) idf_build_set_property(NON_OS_BUILD 1) endif() +# The component a ULP program of the detected architecture is built against. +function(__ulp_arch_component out_var) + if(BUILD_RISCV) + set(component ulp_riscv) + elseif(BUILD_LP_CORE) + set(component lp_core) + elseif(BUILD_FSM) + set(component ulp_fsm) + else() + idf_die("Unable to determine the ULP type. Set ULP_TYPE to riscv, lp_core or fsm.") + endif() + + set(${out_var} "${component}" PARENT_SCOPE) +endfunction() + # Reset the compile/link state inherited from the parent app build and select # ULP-specific build behavior. Idempotent within a child configure. function(__ulp_prepare_build) diff --git a/components/ulp/test_apps/lp_core/host_tests/lp_core_custom_linker_v2/main/ulp/main/CMakeLists.txt b/components/ulp/test_apps/lp_core/host_tests/lp_core_custom_linker_v2/main/ulp/main/CMakeLists.txt index 7a031e58974..e817767e3e1 100644 --- a/components/ulp/test_apps/lp_core/host_tests/lp_core_custom_linker_v2/main/ulp/main/CMakeLists.txt +++ b/components/ulp/test_apps/lp_core/host_tests/lp_core_custom_linker_v2/main/ulp/main/CMakeLists.txt @@ -1,4 +1,4 @@ # SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD # SPDX-License-Identifier: Apache-2.0 idf_component_register(SRCS "main.c" - REQUIRES ulp) + REQUIRES lp_core) diff --git a/components/ulp/test_apps/lp_core/lp_core_basic_tests/main/lp_core/test_shared.h b/components/ulp/test_apps/lp_core/lp_core_basic_tests/main/lp_core/test_shared.h index 83b5d5747fb..77c669e2b65 100644 --- a/components/ulp/test_apps/lp_core/lp_core_basic_tests/main/lp_core/test_shared.h +++ b/components/ulp/test_apps/lp_core/lp_core_basic_tests/main/lp_core/test_shared.h @@ -22,7 +22,7 @@ * LP UART read_bytes return-value test (HP + LP): * The burst must fit in the hardware RX FIFO yet typically exceed the LP UART * driver's default RX FIFO full threshold (LP_UART_FULL_THRESH_DEFAULT in - * components/ulp/lp_core/lp_core/lp_core_uart.c). If either value changes, + * components/ulp/subproject/components/lp_core/lp_core_uart.c). If either value changes, * revisit this guard. */ #if (SOC_LP_UART_FIFO_LEN) < 12 diff --git a/components/ulp/ulp_fsm/include/ulp_fsm_common.h b/components/ulp/ulp_fsm/include/ulp_fsm_common.h index 881067d4c30..0536e536a20 100644 --- a/components/ulp/ulp_fsm/include/ulp_fsm_common.h +++ b/components/ulp/ulp_fsm/include/ulp_fsm_common.h @@ -80,7 +80,7 @@ esp_err_t ulp_process_macros_and_load(uint32_t load_addr, const ulp_insn_t* prog * 7. .text section * 8. .data section * - * Linker script in components/ulp/ld/esp32.ulp.ld produces ELF files which + * Linker script in components/ulp/subproject/components/ulp_fsm/ld/ulp_fsm.ld produces ELF files which * correspond to this format. This linker script produces binaries with load_addr == 0. * * @param load_addr address where the program should be loaded, expressed in 32-bit words diff --git a/components/ulp/ulp_riscv/include/ulp_riscv.h b/components/ulp/ulp_riscv/include/ulp_riscv.h index b77934d9641..59a8833cd84 100644 --- a/components/ulp/ulp_riscv/include/ulp_riscv.h +++ b/components/ulp/ulp_riscv/include/ulp_riscv.h @@ -93,7 +93,7 @@ esp_err_t ulp_riscv_run(void); * Different than ULP FSM, the binary program has no special format, it is the ELF * file generated by RISC-V toolchain converted to binary format using objcopy. * - * Linker script in components/ulp/ld/ulp_riscv.ld produces ELF files which + * Linker script in components/ulp/subproject/components/ulp_riscv/ld/ulp_riscv.ld produces ELF files which * correspond to this format. This linker script produces binaries with load_addr == 0. * * @param program_binary pointer to program binary diff --git a/docs/component_info_ignore_file.txt b/docs/component_info_ignore_file.txt index 5c9a44e9a8e..909fa9f19d2 100644 --- a/docs/component_info_ignore_file.txt +++ b/docs/component_info_ignore_file.txt @@ -1,14 +1,14 @@ # Header files that will be ignored when generating extra header information # For API reference (include path/REQUIRE component) # ULP header files for the ULP app do not have an IDF header path/component require -components/ulp/lp_core/lp_core/include/ulp_lp_core_gpio.h -components/ulp/lp_core/lp_core/include/ulp_lp_core_i2c.h -components/ulp/lp_core/lp_core/include/ulp_lp_core_print.h -components/ulp/lp_core/lp_core/include/ulp_lp_core_uart.h -components/ulp/lp_core/lp_core/include/ulp_lp_core_utils.h -components/ulp/lp_core/lp_core/include/ulp_lp_core_interrupts.h -components/ulp/lp_core/lp_core/include/ulp_lp_core_spi.h -components/ulp/lp_core/lp_core/include/ulp_lp_core_mailbox.h +components/ulp/subproject/components/lp_core/include/ulp_lp_core_gpio.h +components/ulp/subproject/components/lp_core/include/ulp_lp_core_i2c.h +components/ulp/subproject/components/lp_core/include/ulp_lp_core_print.h +components/ulp/subproject/components/lp_core/include/ulp_lp_core_uart.h +components/ulp/subproject/components/lp_core/include/ulp_lp_core_utils.h +components/ulp/subproject/components/lp_core/include/ulp_lp_core_interrupts.h +components/ulp/subproject/components/lp_core/include/ulp_lp_core_spi.h +components/ulp/subproject/components/lp_core/include/ulp_lp_core_mailbox.h # ESP-TEE header files components/esp_tee/subproject/components/tee_sec_storage/include/esp_tee_sec_storage.h components/esp_tee/subproject/components/tee_attestation/esp_tee_attestation.h diff --git a/docs/doxygen/Doxyfile_esp32c5 b/docs/doxygen/Doxyfile_esp32c5 index 0c487949294..c83752011cc 100644 --- a/docs/doxygen/Doxyfile_esp32c5 +++ b/docs/doxygen/Doxyfile_esp32c5 @@ -4,13 +4,13 @@ INPUT += \ $(PROJECT_PATH)/components/ulp/lp_core/include/lp_core_uart.h \ $(PROJECT_PATH)/components/ulp/lp_core/include/lp_core_etm.h \ $(PROJECT_PATH)/components/ulp/lp_core/include/ulp_lp_core.h \ - $(PROJECT_PATH)/components/ulp/lp_core/lp_core/include/ulp_lp_core_gpio.h \ - $(PROJECT_PATH)/components/ulp/lp_core/lp_core/include/ulp_lp_core_i2c.h \ - $(PROJECT_PATH)/components/ulp/lp_core/lp_core/include/ulp_lp_core_print.h \ - $(PROJECT_PATH)/components/ulp/lp_core/lp_core/include/ulp_lp_core_uart.h \ - $(PROJECT_PATH)/components/ulp/lp_core/lp_core/include/ulp_lp_core_utils.h \ - $(PROJECT_PATH)/components/ulp/lp_core/lp_core/include/ulp_lp_core_interrupts.h \ - $(PROJECT_PATH)/components/ulp/lp_core/lp_core/include/ulp_lp_core_mailbox.h \ + $(PROJECT_PATH)/components/ulp/subproject/components/lp_core/include/ulp_lp_core_gpio.h \ + $(PROJECT_PATH)/components/ulp/subproject/components/lp_core/include/ulp_lp_core_i2c.h \ + $(PROJECT_PATH)/components/ulp/subproject/components/lp_core/include/ulp_lp_core_print.h \ + $(PROJECT_PATH)/components/ulp/subproject/components/lp_core/include/ulp_lp_core_uart.h \ + $(PROJECT_PATH)/components/ulp/subproject/components/lp_core/include/ulp_lp_core_utils.h \ + $(PROJECT_PATH)/components/ulp/subproject/components/lp_core/include/ulp_lp_core_interrupts.h \ + $(PROJECT_PATH)/components/ulp/subproject/components/lp_core/include/ulp_lp_core_mailbox.h \ $(PROJECT_PATH)/components/ulp/ulp_common/include/ulp_common.h \ $(PROJECT_PATH)/components/ulp/lp_core/shared/include/ulp_lp_core_lp_uart_shared.h \ $(PROJECT_PATH)/components/bt/include/esp32c5/include/esp_bt.h \ diff --git a/docs/doxygen/Doxyfile_esp32c6 b/docs/doxygen/Doxyfile_esp32c6 index 7b0066b0e31..248121aa588 100644 --- a/docs/doxygen/Doxyfile_esp32c6 +++ b/docs/doxygen/Doxyfile_esp32c6 @@ -3,13 +3,13 @@ INPUT += \ $(PROJECT_PATH)/components/ulp/lp_core/include/lp_core_uart.h \ $(PROJECT_PATH)/components/ulp/lp_core/include/lp_core_etm.h \ $(PROJECT_PATH)/components/ulp/lp_core/include/ulp_lp_core.h \ - $(PROJECT_PATH)/components/ulp/lp_core/lp_core/include/ulp_lp_core_gpio.h \ - $(PROJECT_PATH)/components/ulp/lp_core/lp_core/include/ulp_lp_core_i2c.h \ - $(PROJECT_PATH)/components/ulp/lp_core/lp_core/include/ulp_lp_core_print.h \ - $(PROJECT_PATH)/components/ulp/lp_core/lp_core/include/ulp_lp_core_uart.h \ - $(PROJECT_PATH)/components/ulp/lp_core/lp_core/include/ulp_lp_core_utils.h \ - $(PROJECT_PATH)/components/ulp/lp_core/lp_core/include/ulp_lp_core_interrupts.h \ - $(PROJECT_PATH)/components/ulp/lp_core/lp_core/include/ulp_lp_core_mailbox.h \ + $(PROJECT_PATH)/components/ulp/subproject/components/lp_core/include/ulp_lp_core_gpio.h \ + $(PROJECT_PATH)/components/ulp/subproject/components/lp_core/include/ulp_lp_core_i2c.h \ + $(PROJECT_PATH)/components/ulp/subproject/components/lp_core/include/ulp_lp_core_print.h \ + $(PROJECT_PATH)/components/ulp/subproject/components/lp_core/include/ulp_lp_core_uart.h \ + $(PROJECT_PATH)/components/ulp/subproject/components/lp_core/include/ulp_lp_core_utils.h \ + $(PROJECT_PATH)/components/ulp/subproject/components/lp_core/include/ulp_lp_core_interrupts.h \ + $(PROJECT_PATH)/components/ulp/subproject/components/lp_core/include/ulp_lp_core_mailbox.h \ $(PROJECT_PATH)/components/bt/include/esp32c6/include/esp_bt.h \ $(PROJECT_PATH)/components/bt/include/$(IDF_TARGET)/include/esp_bt_vs.h \ $(PROJECT_PATH)/components/esp_phy/include/esp_phy_init.h \ diff --git a/docs/doxygen/Doxyfile_esp32p4 b/docs/doxygen/Doxyfile_esp32p4 index d227fe6adc9..0fa5df75a2a 100644 --- a/docs/doxygen/Doxyfile_esp32p4 +++ b/docs/doxygen/Doxyfile_esp32p4 @@ -45,14 +45,14 @@ INPUT += \ $(PROJECT_PATH)/components/ulp/lp_core/include/lp_core_spi.h \ $(PROJECT_PATH)/components/ulp/lp_core/include/lp_core_uart.h \ $(PROJECT_PATH)/components/ulp/lp_core/include/ulp_lp_core.h \ - $(PROJECT_PATH)/components/ulp/lp_core/lp_core/include/ulp_lp_core_gpio.h \ - $(PROJECT_PATH)/components/ulp/lp_core/lp_core/include/ulp_lp_core_i2c.h \ - $(PROJECT_PATH)/components/ulp/lp_core/lp_core/include/ulp_lp_core_interrupts.h \ - $(PROJECT_PATH)/components/ulp/lp_core/lp_core/include/ulp_lp_core_mailbox.h \ - $(PROJECT_PATH)/components/ulp/lp_core/lp_core/include/ulp_lp_core_print.h \ - $(PROJECT_PATH)/components/ulp/lp_core/lp_core/include/ulp_lp_core_spi.h \ - $(PROJECT_PATH)/components/ulp/lp_core/lp_core/include/ulp_lp_core_uart.h \ - $(PROJECT_PATH)/components/ulp/lp_core/lp_core/include/ulp_lp_core_utils.h \ + $(PROJECT_PATH)/components/ulp/subproject/components/lp_core/include/ulp_lp_core_gpio.h \ + $(PROJECT_PATH)/components/ulp/subproject/components/lp_core/include/ulp_lp_core_i2c.h \ + $(PROJECT_PATH)/components/ulp/subproject/components/lp_core/include/ulp_lp_core_interrupts.h \ + $(PROJECT_PATH)/components/ulp/subproject/components/lp_core/include/ulp_lp_core_mailbox.h \ + $(PROJECT_PATH)/components/ulp/subproject/components/lp_core/include/ulp_lp_core_print.h \ + $(PROJECT_PATH)/components/ulp/subproject/components/lp_core/include/ulp_lp_core_spi.h \ + $(PROJECT_PATH)/components/ulp/subproject/components/lp_core/include/ulp_lp_core_uart.h \ + $(PROJECT_PATH)/components/ulp/subproject/components/lp_core/include/ulp_lp_core_utils.h \ $(PROJECT_PATH)/components/ulp/lp_core/shared/include/ulp_lp_core_lp_uart_shared.h \ $(PROJECT_PATH)/components/ulp/lp_core/shared/include/ulp_lp_core_lp_vad_shared.h \ $(PROJECT_PATH)/components/ulp/ulp_common/include/ulp_common.h \ diff --git a/docs/doxygen/Doxyfile_esp32s31 b/docs/doxygen/Doxyfile_esp32s31 index 36b6afc8779..3f7f138f2e6 100644 --- a/docs/doxygen/Doxyfile_esp32s31 +++ b/docs/doxygen/Doxyfile_esp32s31 @@ -25,12 +25,12 @@ INPUT += \ $(PROJECT_PATH)/components/ulp/lp_core/include/lp_core_spi.h \ $(PROJECT_PATH)/components/ulp/lp_core/include/ulp_lp_core.h \ $(PROJECT_PATH)/components/ulp/lp_core/shared/include/ulp_lp_core_lp_uart_shared.h \ - $(PROJECT_PATH)/components/ulp/lp_core/lp_core/include/ulp_lp_core_gpio.h \ - $(PROJECT_PATH)/components/ulp/lp_core/lp_core/include/ulp_lp_core_i2c.h \ - $(PROJECT_PATH)/components/ulp/lp_core/lp_core/include/ulp_lp_core_print.h \ - $(PROJECT_PATH)/components/ulp/lp_core/lp_core/include/ulp_lp_core_uart.h \ - $(PROJECT_PATH)/components/ulp/lp_core/lp_core/include/ulp_lp_core_utils.h \ - $(PROJECT_PATH)/components/ulp/lp_core/lp_core/include/ulp_lp_core_interrupts.h \ - $(PROJECT_PATH)/components/ulp/lp_core/lp_core/include/ulp_lp_core_mailbox.h \ - $(PROJECT_PATH)/components/ulp/lp_core/lp_core/include/ulp_lp_core_spi.h \ + $(PROJECT_PATH)/components/ulp/subproject/components/lp_core/include/ulp_lp_core_gpio.h \ + $(PROJECT_PATH)/components/ulp/subproject/components/lp_core/include/ulp_lp_core_i2c.h \ + $(PROJECT_PATH)/components/ulp/subproject/components/lp_core/include/ulp_lp_core_print.h \ + $(PROJECT_PATH)/components/ulp/subproject/components/lp_core/include/ulp_lp_core_uart.h \ + $(PROJECT_PATH)/components/ulp/subproject/components/lp_core/include/ulp_lp_core_utils.h \ + $(PROJECT_PATH)/components/ulp/subproject/components/lp_core/include/ulp_lp_core_interrupts.h \ + $(PROJECT_PATH)/components/ulp/subproject/components/lp_core/include/ulp_lp_core_mailbox.h \ + $(PROJECT_PATH)/components/ulp/subproject/components/lp_core/include/ulp_lp_core_spi.h \ $(PROJECT_PATH)/components/ulp/ulp_common/include/ulp_common.h \ diff --git a/docs/en/api-reference/peripherals/cap_touch_sens.rst b/docs/en/api-reference/peripherals/cap_touch_sens.rst index 580bda0eb61..e3746485457 100644 --- a/docs/en/api-reference/peripherals/cap_touch_sens.rst +++ b/docs/en/api-reference/peripherals/cap_touch_sens.rst @@ -415,7 +415,7 @@ Call :cpp:func:`touch_channel_read_data` to read the data with different types. .. only:: SOC_RISCV_COPROC_SUPPORTED - If you want to read or configure the touch sensor during the sleep, you can turn to the driver ``components/ulp/ulp_riscv/ulp_core/include/ulp_riscv_touch_ulp_core.h`` which based on the :doc:`Ultra Low Power (ULP) Coprocessor <../system/ulp>`. + If you want to read or configure the touch sensor during the sleep, you can turn to the driver ``components/ulp/subproject/components/ulp_riscv/include/ulp_riscv_touch_ulp_core.h`` which based on the :doc:`Ultra Low Power (ULP) Coprocessor <../system/ulp>`. .. list:: diff --git a/docs/en/api-reference/system/ulp-fsm.rst b/docs/en/api-reference/system/ulp-fsm.rst index f120b0ab9f2..b3cc0c1cbe9 100644 --- a/docs/en/api-reference/system/ulp-fsm.rst +++ b/docs/en/api-reference/system/ulp-fsm.rst @@ -75,7 +75,7 @@ The additional PREFIX argument can be a C style prefix (like ``ulp2_``) or a C++ 2. **Run preprocessed assembly sources through the assembler.** This produces object (foo.ulp.o) and listing (foo.ulp.lst) files. Listing files are generated for debugging purposes and are not used at later stages of the build process. - 3. **Run the linker script template through the C preprocessor.** The template is located in ``components/ulp/ld`` directory. + 3. **Run the linker script template through the C preprocessor.** The template is located in ``components/ulp/subproject/components/ulp_fsm/ld`` directory. 4. **Link the object files into an output ELF file** (``ulp_app_name.elf``). The Map file (``ulp_app_name.map``) generated at this stage may be useful for debugging purposes. diff --git a/docs/en/api-reference/system/ulp-lp-core.rst b/docs/en/api-reference/system/ulp-lp-core.rst index 89544eaed44..2996312d900 100644 --- a/docs/en/api-reference/system/ulp-lp-core.rst +++ b/docs/en/api-reference/system/ulp-lp-core.rst @@ -117,7 +117,7 @@ During the build process, the following steps are taken to build ULP program: 1. **Run each source file through the C compiler and assembler.** This step generates the object files ``.obj.c`` or ``.obj.S`` in the component build directory depending on the source file processed. - 2. **Run the linker script template through the C preprocessor.** The template is located in ``components/ulp/ld`` directory. + 2. **Run the linker script template through the C preprocessor.** The template is located in ``components/ulp/subproject/components/lp_core/ld`` directory. 3. **Link the object files into an output ELF file** (``ulp_app_name.elf``). The Map file ``ulp_app_name.map`` generated at this stage may be useful for debugging purposes. @@ -274,7 +274,7 @@ To enhance the capabilities of the ULP LP core coprocessor, it has access to per ULP LP Core Interrupts ---------------------- -The LP core coprocessor can be configured to handle interrupts from various sources. Examples of such interrupts could be LP IO low/high or LP timer interrupts. To register a handler for an interrupt, simply override any of the weak handlers provided by IDF. A complete list of handlers can be found in :component_file:`ulp_lp_core_interrupts.h `. For details on which interrupts are available on a specific target, please consult **{IDF_TARGET_NAME} Technical Reference Manual** [`PDF <{IDF_TARGET_TRM_EN_URL}#ulp>`__]. +The LP core coprocessor can be configured to handle interrupts from various sources. Examples of such interrupts could be LP IO low/high or LP timer interrupts. To register a handler for an interrupt, simply override any of the weak handlers provided by IDF. A complete list of handlers can be found in :component_file:`ulp_lp_core_interrupts.h `. For details on which interrupts are available on a specific target, please consult **{IDF_TARGET_NAME} Technical Reference Manual** [`PDF <{IDF_TARGET_TRM_EN_URL}#ulp>`__]. For example, to override the handler for the LP IO interrupt, you can define the following function in your ULP LP core code: diff --git a/docs/en/api-reference/system/ulp-risc-v.rst b/docs/en/api-reference/system/ulp-risc-v.rst index 2b1ea141362..2fa38a5b406 100644 --- a/docs/en/api-reference/system/ulp-risc-v.rst +++ b/docs/en/api-reference/system/ulp-risc-v.rst @@ -116,7 +116,7 @@ During the build process, the following steps are taken to build ULP program: 1. **Run each source file through the C compiler and assembler.** This step generates the object files ``.obj.c`` or ``.obj.S`` in the component build directory depending on the source file processed. - 2. **Run the linker script template through the C preprocessor.** The template is located in ``components/ulp/ld`` directory. + 2. **Run the linker script template through the C preprocessor.** The template is located in ``components/ulp/subproject/components/ulp_riscv/ld`` directory. 3. **Link the object files into an output ELF file** (``ulp_app_name.elf``). The Map file ``ulp_app_name.map`` generated at this stage may be useful for debugging purposes. diff --git a/docs/zh_CN/api-reference/peripherals/cap_touch_sens.rst b/docs/zh_CN/api-reference/peripherals/cap_touch_sens.rst index eb3ec0e62cd..6b0b2470070 100644 --- a/docs/zh_CN/api-reference/peripherals/cap_touch_sens.rst +++ b/docs/zh_CN/api-reference/peripherals/cap_touch_sens.rst @@ -415,7 +415,7 @@ .. only:: SOC_RISCV_COPROC_SUPPORTED - 若需要在睡眠过程中进行读数、配置等操作,可通过运行在 :doc:`超低功耗协处理器 ULP <../system/ulp>` 上的触摸传感器驱动 ``components/ulp/ulp_riscv/ulp_core/include/ulp_riscv_touch_ulp_core.h`` 实现。 + 若需要在睡眠过程中进行读数、配置等操作,可通过运行在 :doc:`超低功耗协处理器 ULP <../system/ulp>` 上的触摸传感器驱动 ``components/ulp/subproject/components/ulp_riscv/include/ulp_riscv_touch_ulp_core.h`` 实现。 .. list:: diff --git a/docs/zh_CN/api-reference/system/ulp-fsm.rst b/docs/zh_CN/api-reference/system/ulp-fsm.rst index aa827a4953d..b26e4da8ce0 100644 --- a/docs/zh_CN/api-reference/system/ulp-fsm.rst +++ b/docs/zh_CN/api-reference/system/ulp-fsm.rst @@ -75,7 +75,7 @@ ULP FSM 协处理器代码由汇编语言编写,使用 `binutils-esp32ulp 工 2. **通过汇编器运行预处理过的汇编源码。** 此步骤会生成目标文件 (foo.ulp.o) 和清单 (foo.ulp.lst)。清单文件仅用于调试,不用于编译进程的后续步骤。 - 3. **通过 C 预处理器运行链接器脚本模板。** 模板位于 ``components/ulp/ld`` 目录中。 + 3. **通过 C 预处理器运行链接器脚本模板。** 模板位于 ``components/ulp/subproject/components/ulp_fsm/ld`` 目录中。 4. **将目标文件链接到 ELF 输出文件** (``ulp_app_name.elf``)。此步骤生成的 .map 文件 (``ulp_app_name.map``) 默认用于调试。 diff --git a/docs/zh_CN/api-reference/system/ulp-lp-core.rst b/docs/zh_CN/api-reference/system/ulp-lp-core.rst index 4e345a0d645..d19fa8a6681 100644 --- a/docs/zh_CN/api-reference/system/ulp-lp-core.rst +++ b/docs/zh_CN/api-reference/system/ulp-lp-core.rst @@ -117,7 +117,7 @@ ULP LP 内核代码会与 ESP-IDF 项目共同编译,生成一个单独的二 1. **通过 C 编译器和汇编器运行每个源文件。** 此步骤会在组件构建目录中生成目标文件 ``.obj.c`` 或 ``.obj.S``,具体取决于处理的源文件。 - 2. **通过 C 预处理器运行链接器脚本模板。** 模板位于 ``components/ulp/ld`` 目录中。 + 2. **通过 C 预处理器运行链接器脚本模板。** 模板位于 ``components/ulp/subproject/components/lp_core/ld`` 目录中。 3. **将对象文件链接到一个 ELF 输出文件中,** 即 ``ulp_app_name.elf``。在此阶段生成的映射文件 ``ulp_app_name.map`` 可用于调试。 @@ -274,7 +274,7 @@ ULP LP 内核支持的外设 ULP LP 内核中断 --------------- -配置 LP 内核协处理器,可以处理各种类型的中断,例如 LP IO 低/高电平中断或是 LP 定时器中断。只需重写 IDF 提供的任何一个弱处理函数,就可以注册一个中断处理程序。所有处理程序可见 :component_file:`ulp_lp_core_interrupts.h `。有关特定目标可使用的中断的详细信息,请参阅 **{IDF_TARGET_NAME} 技术参考手册** [`PDF <{IDF_TARGET_TRM_CN_URL}#ulp>`__]。 +配置 LP 内核协处理器,可以处理各种类型的中断,例如 LP IO 低/高电平中断或是 LP 定时器中断。只需重写 IDF 提供的任何一个弱处理函数,就可以注册一个中断处理程序。所有处理程序可见 :component_file:`ulp_lp_core_interrupts.h `。有关特定目标可使用的中断的详细信息,请参阅 **{IDF_TARGET_NAME} 技术参考手册** [`PDF <{IDF_TARGET_TRM_CN_URL}#ulp>`__]。 例如,要重写 LP IO 中断的处理程序,可以在 ULP LP 内核代码中定义以下函数: diff --git a/docs/zh_CN/api-reference/system/ulp-risc-v.rst b/docs/zh_CN/api-reference/system/ulp-risc-v.rst index a496e9d3fb2..9a91ea18cbf 100644 --- a/docs/zh_CN/api-reference/system/ulp-risc-v.rst +++ b/docs/zh_CN/api-reference/system/ulp-risc-v.rst @@ -116,7 +116,7 @@ ULP RISC-V 协处理器代码以 C 语言(或汇编语言)编写,使用基 1. **通过 C 编译器和汇编器运行每个源文件。** 此步骤会在组件构建目录中生成目标文件 ``.obj.c`` 或 ``.obj.S``,具体取决于处理的源文件。 - 2. **通过 C 预处理器运行链接器脚本模板。** 模板位于 ``components/ulp/ld`` 目录中。 + 2. **通过 C 预处理器运行链接器脚本模板。** 模板位于 ``components/ulp/subproject/components/ulp_riscv/ld`` 目录中。 3. **将对象文件链接到一个 ELF 输出文件中,** 即 ``ulp_app_name.elf``。在此阶段生成的映射文件 ``ulp_app_name.map`` 可用于调试。 diff --git a/tools/test_apps/system/ulp/full_subproject/combined/main/ulp_fsm/main/CMakeLists.txt b/tools/test_apps/system/ulp/full_subproject/combined/main/ulp_fsm/main/CMakeLists.txt index 5021b10db9f..71bc4527ab5 100644 --- a/tools/test_apps/system/ulp/full_subproject/combined/main/ulp_fsm/main/CMakeLists.txt +++ b/tools/test_apps/system/ulp/full_subproject/combined/main/ulp_fsm/main/CMakeLists.txt @@ -1,2 +1,2 @@ idf_component_register(SRCS "main.S" - REQUIRES ulp) + REQUIRES ulp_fsm) diff --git a/tools/test_apps/system/ulp/full_subproject/combined/main/ulp_riscv/main/CMakeLists.txt b/tools/test_apps/system/ulp/full_subproject/combined/main/ulp_riscv/main/CMakeLists.txt index 9d04d40931e..831c0a745bf 100644 --- a/tools/test_apps/system/ulp/full_subproject/combined/main/ulp_riscv/main/CMakeLists.txt +++ b/tools/test_apps/system/ulp/full_subproject/combined/main/ulp_riscv/main/CMakeLists.txt @@ -1,2 +1,2 @@ idf_component_register(SRCS "main.c" - REQUIRES ulp) + REQUIRES ulp_riscv) diff --git a/tools/test_apps/system/ulp/full_subproject/fsm/main/ulp/components/ulp_wake/CMakeLists.txt b/tools/test_apps/system/ulp/full_subproject/fsm/main/ulp/components/ulp_wake/CMakeLists.txt index 694ddcfaa66..cde67787ae4 100644 --- a/tools/test_apps/system/ulp/full_subproject/fsm/main/ulp/components/ulp_wake/CMakeLists.txt +++ b/tools/test_apps/system/ulp/full_subproject/fsm/main/ulp/components/ulp_wake/CMakeLists.txt @@ -1,2 +1,2 @@ idf_component_register(SRCS "wake_up.S" - REQUIRES ulp) + REQUIRES ulp_fsm) diff --git a/tools/test_apps/system/ulp/full_subproject/fsm/main/ulp/main/CMakeLists.txt b/tools/test_apps/system/ulp/full_subproject/fsm/main/ulp/main/CMakeLists.txt index 81958e793d6..1d25b1e1eee 100644 --- a/tools/test_apps/system/ulp/full_subproject/fsm/main/ulp/main/CMakeLists.txt +++ b/tools/test_apps/system/ulp/full_subproject/fsm/main/ulp/main/CMakeLists.txt @@ -2,7 +2,7 @@ set(srcs "counter.S") idf_component_register(SRCS ${srcs} - REQUIRES ulp ulp_wake + REQUIRES ulp_fsm ulp_wake LDFRAGMENTS "ulp_fsm_sections.lf") target_compile_definitions(${COMPONENT_LIB} PRIVATE ULP_BUILD_SYSTEM_FSM_EXAMPLE=1) diff --git a/tools/test_apps/system/ulp/full_subproject/lp_core/main/ulp/main/CMakeLists.txt b/tools/test_apps/system/ulp/full_subproject/lp_core/main/ulp/main/CMakeLists.txt index 09d8933709d..a37977dbb44 100644 --- a/tools/test_apps/system/ulp/full_subproject/lp_core/main/ulp/main/CMakeLists.txt +++ b/tools/test_apps/system/ulp/full_subproject/lp_core/main/ulp/main/CMakeLists.txt @@ -1,5 +1,5 @@ idf_component_register(SRCS "main.c" - REQUIRES ulp ulp_sum ulp_math) + REQUIRES lp_core ulp_sum ulp_math) # Linker script template processed by ldgen. The mapping[ulp_math_fast] # marker is resolved using the .lf fragment from the ulp_math component. diff --git a/tools/test_apps/system/ulp/full_subproject/multi_binary/main/ulp/components/ulp_add_main/CMakeLists.txt b/tools/test_apps/system/ulp/full_subproject/multi_binary/main/ulp/components/ulp_add_main/CMakeLists.txt index 9d04d40931e..8457c1b2eb5 100644 --- a/tools/test_apps/system/ulp/full_subproject/multi_binary/main/ulp/components/ulp_add_main/CMakeLists.txt +++ b/tools/test_apps/system/ulp/full_subproject/multi_binary/main/ulp/components/ulp_add_main/CMakeLists.txt @@ -1,2 +1,2 @@ idf_component_register(SRCS "main.c" - REQUIRES ulp) + REQUIRES lp_core) diff --git a/tools/test_apps/system/ulp/full_subproject/multi_binary/main/ulp/components/ulp_multiply_main/CMakeLists.txt b/tools/test_apps/system/ulp/full_subproject/multi_binary/main/ulp/components/ulp_multiply_main/CMakeLists.txt index 9d04d40931e..8457c1b2eb5 100644 --- a/tools/test_apps/system/ulp/full_subproject/multi_binary/main/ulp/components/ulp_multiply_main/CMakeLists.txt +++ b/tools/test_apps/system/ulp/full_subproject/multi_binary/main/ulp/components/ulp_multiply_main/CMakeLists.txt @@ -1,2 +1,2 @@ idf_component_register(SRCS "main.c" - REQUIRES ulp) + REQUIRES lp_core) diff --git a/tools/test_apps/system/ulp/full_subproject/riscv/main/ulp/main/CMakeLists.txt b/tools/test_apps/system/ulp/full_subproject/riscv/main/ulp/main/CMakeLists.txt index a6e1be0adc6..bc4cc55c3c4 100644 --- a/tools/test_apps/system/ulp/full_subproject/riscv/main/ulp/main/CMakeLists.txt +++ b/tools/test_apps/system/ulp/full_subproject/riscv/main/ulp/main/CMakeLists.txt @@ -1,5 +1,5 @@ idf_component_register(SRCS "main.c" - REQUIRES ulp + REQUIRES ulp_riscv LDFRAGMENTS "ulp_riscv_sections.lf") # Supplementary linker script template processed by ldgen. The mapping marker diff --git a/tools/test_build_system/buildv2/test_ulp.py b/tools/test_build_system/buildv2/test_ulp.py index 5f75bdb3dfe..30bc3a6dc0e 100644 --- a/tools/test_build_system/buildv2/test_ulp.py +++ b/tools/test_build_system/buildv2/test_ulp.py @@ -117,6 +117,7 @@ def test_ulp_cmake_api_availability( project_dir.mkdir() _write_api_probe_project(project_dir, entry_point, add_native_executable) ulp_subproject_dir = idf_path / 'components' / 'ulp' / 'subproject' + lp_core_toolchain = ulp_subproject_dir / 'components' / 'lp_core' / 'toolchain-lp-core-riscv.cmake' cmake_args = ( 'cmake', @@ -127,7 +128,7 @@ def test_ulp_cmake_api_availability( '-B', _cmake_path(build_dir), f'-DCMAKE_MODULE_PATH={_cmake_path(ulp_subproject_dir)}', - f'-DCMAKE_TOOLCHAIN_FILE={_cmake_path(ulp_subproject_dir / "toolchain-lp-core-riscv.cmake")}', + f'-DCMAKE_TOOLCHAIN_FILE={_cmake_path(lp_core_toolchain)}', f'-DIDF_PATH={_cmake_path(idf_path)}', '-DIDF_TARGET=esp32c6', f'-DSDKCONFIG_CMAKE={_cmake_path(project_dir / "sdkconfig.cmake")}', From 53ea9b200ebee718bff023ae953542c5896a4035 Mon Sep 17 00:00:00 2001 From: Sudeep Mohanty Date: Wed, 2 Sep 2026 09:12:14 +0200 Subject: [PATCH 3/4] refactor(ulp): select ULP architecture component as common component The subproject knows which architecture it builds for, so a ULP program names only its own dependencies. --- components/ulp/subproject/ulp_project.cmake | 15 +++++++++++---- .../main/ulp/main/CMakeLists.txt | 3 +-- .../combined/main/ulp_fsm/main/CMakeLists.txt | 3 +-- .../combined/main/ulp_riscv/main/CMakeLists.txt | 3 +-- .../main/ulp/components/ulp_wake/CMakeLists.txt | 3 +-- .../fsm/main/ulp/main/CMakeLists.txt | 2 +- .../lp_core/main/ulp/main/CMakeLists.txt | 2 +- .../ulp/components/ulp_add_main/CMakeLists.txt | 3 +-- .../components/ulp_multiply_main/CMakeLists.txt | 3 +-- .../riscv/main/ulp/main/CMakeLists.txt | 1 - 10 files changed, 19 insertions(+), 19 deletions(-) diff --git a/components/ulp/subproject/ulp_project.cmake b/components/ulp/subproject/ulp_project.cmake index 321bf969192..b741444f268 100644 --- a/components/ulp/subproject/ulp_project.cmake +++ b/components/ulp/subproject/ulp_project.cmake @@ -64,11 +64,18 @@ function(__ulp_prepare_build) idf_build_set_property(${property} "") endforeach() - # Do not apply the default app component closure to ULP child projects. - # ULP components should contribute dependencies explicitly. - idf_build_set_property(__COMPONENT_REQUIRES_COMMON "") - idf_build_set_property(__COMMON_COMPONENT_INTERFACES "") + # A ULP program is built against the component for its architecture, so + # every component of the child gets it without naming it. Nothing else of + # the application component closure applies, and the interfaces are set + # here rather than through __init_common_components, which would also add + # the target's architecture component. + __ulp_arch_component(ulp_component) + + idf_component_get_property(ulp_component_interface "${ulp_component}" COMPONENT_INTERFACE) + idf_build_set_property(__COMPONENT_REQUIRES_COMMON "${ulp_component}") + idf_build_set_property(__COMMON_COMPONENT_INTERFACES "${ulp_component_interface}") idf_build_set_property(__COMMON_COMPONENTS_INITIALIZED YES) + idf_component_include("${ulp_component}") idf_build_set_property(__ULP_BUILD_PREPARED YES) endfunction() diff --git a/components/ulp/test_apps/lp_core/host_tests/lp_core_custom_linker_v2/main/ulp/main/CMakeLists.txt b/components/ulp/test_apps/lp_core/host_tests/lp_core_custom_linker_v2/main/ulp/main/CMakeLists.txt index e817767e3e1..225c5b9c5b9 100644 --- a/components/ulp/test_apps/lp_core/host_tests/lp_core_custom_linker_v2/main/ulp/main/CMakeLists.txt +++ b/components/ulp/test_apps/lp_core/host_tests/lp_core_custom_linker_v2/main/ulp/main/CMakeLists.txt @@ -1,4 +1,3 @@ # SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD # SPDX-License-Identifier: Apache-2.0 -idf_component_register(SRCS "main.c" - REQUIRES lp_core) +idf_component_register(SRCS "main.c") diff --git a/tools/test_apps/system/ulp/full_subproject/combined/main/ulp_fsm/main/CMakeLists.txt b/tools/test_apps/system/ulp/full_subproject/combined/main/ulp_fsm/main/CMakeLists.txt index 71bc4527ab5..37d4277a338 100644 --- a/tools/test_apps/system/ulp/full_subproject/combined/main/ulp_fsm/main/CMakeLists.txt +++ b/tools/test_apps/system/ulp/full_subproject/combined/main/ulp_fsm/main/CMakeLists.txt @@ -1,2 +1 @@ -idf_component_register(SRCS "main.S" - REQUIRES ulp_fsm) +idf_component_register(SRCS "main.S") diff --git a/tools/test_apps/system/ulp/full_subproject/combined/main/ulp_riscv/main/CMakeLists.txt b/tools/test_apps/system/ulp/full_subproject/combined/main/ulp_riscv/main/CMakeLists.txt index 831c0a745bf..34613e8e3cd 100644 --- a/tools/test_apps/system/ulp/full_subproject/combined/main/ulp_riscv/main/CMakeLists.txt +++ b/tools/test_apps/system/ulp/full_subproject/combined/main/ulp_riscv/main/CMakeLists.txt @@ -1,2 +1 @@ -idf_component_register(SRCS "main.c" - REQUIRES ulp_riscv) +idf_component_register(SRCS "main.c") diff --git a/tools/test_apps/system/ulp/full_subproject/fsm/main/ulp/components/ulp_wake/CMakeLists.txt b/tools/test_apps/system/ulp/full_subproject/fsm/main/ulp/components/ulp_wake/CMakeLists.txt index cde67787ae4..9bd5443dd4e 100644 --- a/tools/test_apps/system/ulp/full_subproject/fsm/main/ulp/components/ulp_wake/CMakeLists.txt +++ b/tools/test_apps/system/ulp/full_subproject/fsm/main/ulp/components/ulp_wake/CMakeLists.txt @@ -1,2 +1 @@ -idf_component_register(SRCS "wake_up.S" - REQUIRES ulp_fsm) +idf_component_register(SRCS "wake_up.S") diff --git a/tools/test_apps/system/ulp/full_subproject/fsm/main/ulp/main/CMakeLists.txt b/tools/test_apps/system/ulp/full_subproject/fsm/main/ulp/main/CMakeLists.txt index 1d25b1e1eee..f04ec9d5c05 100644 --- a/tools/test_apps/system/ulp/full_subproject/fsm/main/ulp/main/CMakeLists.txt +++ b/tools/test_apps/system/ulp/full_subproject/fsm/main/ulp/main/CMakeLists.txt @@ -2,7 +2,7 @@ set(srcs "counter.S") idf_component_register(SRCS ${srcs} - REQUIRES ulp_fsm ulp_wake + REQUIRES ulp_wake LDFRAGMENTS "ulp_fsm_sections.lf") target_compile_definitions(${COMPONENT_LIB} PRIVATE ULP_BUILD_SYSTEM_FSM_EXAMPLE=1) diff --git a/tools/test_apps/system/ulp/full_subproject/lp_core/main/ulp/main/CMakeLists.txt b/tools/test_apps/system/ulp/full_subproject/lp_core/main/ulp/main/CMakeLists.txt index a37977dbb44..5b867f38515 100644 --- a/tools/test_apps/system/ulp/full_subproject/lp_core/main/ulp/main/CMakeLists.txt +++ b/tools/test_apps/system/ulp/full_subproject/lp_core/main/ulp/main/CMakeLists.txt @@ -1,5 +1,5 @@ idf_component_register(SRCS "main.c" - REQUIRES lp_core ulp_sum ulp_math) + REQUIRES ulp_sum ulp_math) # Linker script template processed by ldgen. The mapping[ulp_math_fast] # marker is resolved using the .lf fragment from the ulp_math component. diff --git a/tools/test_apps/system/ulp/full_subproject/multi_binary/main/ulp/components/ulp_add_main/CMakeLists.txt b/tools/test_apps/system/ulp/full_subproject/multi_binary/main/ulp/components/ulp_add_main/CMakeLists.txt index 8457c1b2eb5..34613e8e3cd 100644 --- a/tools/test_apps/system/ulp/full_subproject/multi_binary/main/ulp/components/ulp_add_main/CMakeLists.txt +++ b/tools/test_apps/system/ulp/full_subproject/multi_binary/main/ulp/components/ulp_add_main/CMakeLists.txt @@ -1,2 +1 @@ -idf_component_register(SRCS "main.c" - REQUIRES lp_core) +idf_component_register(SRCS "main.c") diff --git a/tools/test_apps/system/ulp/full_subproject/multi_binary/main/ulp/components/ulp_multiply_main/CMakeLists.txt b/tools/test_apps/system/ulp/full_subproject/multi_binary/main/ulp/components/ulp_multiply_main/CMakeLists.txt index 8457c1b2eb5..34613e8e3cd 100644 --- a/tools/test_apps/system/ulp/full_subproject/multi_binary/main/ulp/components/ulp_multiply_main/CMakeLists.txt +++ b/tools/test_apps/system/ulp/full_subproject/multi_binary/main/ulp/components/ulp_multiply_main/CMakeLists.txt @@ -1,2 +1 @@ -idf_component_register(SRCS "main.c" - REQUIRES lp_core) +idf_component_register(SRCS "main.c") diff --git a/tools/test_apps/system/ulp/full_subproject/riscv/main/ulp/main/CMakeLists.txt b/tools/test_apps/system/ulp/full_subproject/riscv/main/ulp/main/CMakeLists.txt index bc4cc55c3c4..561bab33a0c 100644 --- a/tools/test_apps/system/ulp/full_subproject/riscv/main/ulp/main/CMakeLists.txt +++ b/tools/test_apps/system/ulp/full_subproject/riscv/main/ulp/main/CMakeLists.txt @@ -1,5 +1,4 @@ idf_component_register(SRCS "main.c" - REQUIRES ulp_riscv LDFRAGMENTS "ulp_riscv_sections.lf") # Supplementary linker script template processed by ldgen. The mapping marker From 8979950ebfa89fa08cf6d3f65dfb66ceabefbade Mon Sep 17 00:00:00 2001 From: Sudeep Mohanty Date: Tue, 8 Sep 2026 15:20:26 +0200 Subject: [PATCH 4/4] refactor(ulp): move ULP program Kconfig options to its components The Kconfig options for the program running on the ULP coprocessor now live with the components that build it, not with the ULP coprocessor driver on the HP core. The driver sources them, so applications resolve them as before. --- components/ulp/Kconfig | 74 ++----------------- .../components/lp_core/Kconfig.lp_core | 26 +++++++ .../components/lp_core/Kconfig.lp_core_debug | 36 +++++++++ .../components/ulp_riscv/Kconfig.ulp_riscv | 20 +++++ 4 files changed, 88 insertions(+), 68 deletions(-) create mode 100644 components/ulp/subproject/components/lp_core/Kconfig.lp_core create mode 100644 components/ulp/subproject/components/lp_core/Kconfig.lp_core_debug create mode 100644 components/ulp/subproject/components/ulp_riscv/Kconfig.ulp_riscv diff --git a/components/ulp/Kconfig b/components/ulp/Kconfig index 029026fc1a3..429e606ddc1 100644 --- a/components/ulp/Kconfig +++ b/components/ulp/Kconfig @@ -54,20 +54,8 @@ menu "Ultra Low Power (ULP) Co-processor" menu "ULP RISC-V Settings" depends on ULP_COPROC_TYPE_RISCV - config ULP_RISCV_INTERRUPT_ENABLE - bool - prompt "Enable ULP RISC-V interrupts" - default "n" - help - Turn on this setting to enabled interrupts on the ULP RISC-V core. - - config ULP_RISCV_UART_BAUDRATE - int - prompt "Baudrate used by the bitbanged ULP RISC-V UART driver" - default 9600 - help - The accuracy of the bitbanged UART driver is limited, it is not - recommend to increase the value above 19200. + # Declared by the component that builds the ULP RISC-V program. + rsource "subproject/components/ulp_riscv/Kconfig.ulp_riscv" config ULP_RISCV_I2C_RW_TIMEOUT int @@ -117,28 +105,8 @@ menu "Ultra Low Power (ULP) Co-processor" HP application. endmenu - config ULP_ROM_PRINT_ENABLE - depends on ULP_COPROC_TYPE_LP_CORE && ESP_ROM_HAS_LP_ROM - bool - prompt "Enable print utilities from LP ROM" - default "y" - help - Set this option to enable printf functionality from LP ROM. This option - can help reduce the LP core binary size by not linking printf functionality - from RAM code. - Note: For LP ROM prints to work properly, make sure that the LP core boots - from the LP ROM. - - config ULP_LP_CORE_MEMPROT - bool "Enable LP Core memory protection (PMP)" - depends on ULP_COPROC_TYPE_LP_CORE && SOC_LP_CORE_HAS_PMP && !ULP_COPROC_RUN_FROM_HP_MEM - default n - help - Configures the LP CPU's PMP entries to enforce memory protection. - LP RAM is split into executable (.text) and data (.data/.bss/stack) - regions. Regions not explicitly permitted are inaccessible. - Not available when "Run LP Core from HP memory" is enabled. - Disable this if you need full control over PMP configuration. + # Declared by the component that builds the LP core program. + rsource "subproject/components/lp_core/Kconfig.lp_core" config ULP_TRAP_WAKEUP depends on ULP_COPROC_TYPE_LP_CORE @@ -150,38 +118,8 @@ menu "Ultra Low Power (ULP) Co-processor" the LP-core encounters an exception. menu "ULP Debugging Options" - config ULP_PANIC_OUTPUT_ENABLE - depends on ULP_COPROC_TYPE_LP_CORE && SOC_ULP_LP_UART_SUPPORTED - bool - prompt "Enable panic handler which outputs over LP UART" - default "n" - help - Set this option to enable panic handler functionality. If this option is - enabled then the LP Core will output a panic dump over LP UART, - similar to what the main core does. Output depends on LP UART already being - initialized and configured. - Disabling this option will reduce the LP core binary size by not - linking in panic handler functionality. - - config ULP_HP_UART_CONSOLE_PRINT - depends on ULP_COPROC_TYPE_LP_CORE - bool - prompt "Route lp_core_printf to the console HP-UART" - help - Set this option to route lp_core_printf to the console HP-UART. - This allows you to easily view print outputs from the LP core, without - having to connect to the LP-UART. This option comes with the following - limitations: - - 1. There is no mutual exclusion between the HP-Core and the LP-Core accessing - the HP-UART, which means that if both cores are logging heavily the output - strings might get mangled together. - 2. The HP-UART can only work while the HP-Core is running, which means that - if the HP-Core is in deep sleep, the LP-Core will not be able to print to the - console HP-UART. - - Due to these limitations it is only recommended to use this option for easy debugging. - For more serious use-cases you should use the LP-UART. + # Declared by the component that builds the LP core program. + rsource "subproject/components/lp_core/Kconfig.lp_core_debug" config ULP_NORESET_UNDER_DEBUG bool "Avoid resetting LP core when debugger is attached" diff --git a/components/ulp/subproject/components/lp_core/Kconfig.lp_core b/components/ulp/subproject/components/lp_core/Kconfig.lp_core new file mode 100644 index 00000000000..51ac0f48e4d --- /dev/null +++ b/components/ulp/subproject/components/lp_core/Kconfig.lp_core @@ -0,0 +1,26 @@ +# Sourced by the ULP coprocessor driver on the HP core, in +# components/ulp/Kconfig. Not named Kconfig, which would also attach it to +# this component and define every option twice. + +config ULP_ROM_PRINT_ENABLE + depends on ULP_COPROC_TYPE_LP_CORE && ESP_ROM_HAS_LP_ROM + bool + prompt "Enable print utilities from LP ROM" + default "y" + help + Set this option to enable printf functionality from LP ROM. This option + can help reduce the LP core binary size by not linking printf functionality + from RAM code. + Note: For LP ROM prints to work properly, make sure that the LP core boots + from the LP ROM. + +config ULP_LP_CORE_MEMPROT + bool "Enable LP Core memory protection (PMP)" + depends on ULP_COPROC_TYPE_LP_CORE && SOC_LP_CORE_HAS_PMP && !ULP_COPROC_RUN_FROM_HP_MEM + default n + help + Configures the LP CPU's PMP entries to enforce memory protection. + LP RAM is split into executable (.text) and data (.data/.bss/stack) + regions. Regions not explicitly permitted are inaccessible. + Not available when "Run LP Core from HP memory" is enabled. + Disable this if you need full control over PMP configuration. diff --git a/components/ulp/subproject/components/lp_core/Kconfig.lp_core_debug b/components/ulp/subproject/components/lp_core/Kconfig.lp_core_debug new file mode 100644 index 00000000000..ac50e0b4c8d --- /dev/null +++ b/components/ulp/subproject/components/lp_core/Kconfig.lp_core_debug @@ -0,0 +1,36 @@ +# Sourced by the ULP coprocessor driver on the HP core, in +# components/ulp/Kconfig. Not named Kconfig, which would also attach it to +# this component and define every option twice. + +config ULP_PANIC_OUTPUT_ENABLE + depends on ULP_COPROC_TYPE_LP_CORE && SOC_ULP_LP_UART_SUPPORTED + bool + prompt "Enable panic handler which outputs over LP UART" + default "n" + help + Set this option to enable panic handler functionality. If this option is + enabled then the LP Core will output a panic dump over LP UART, + similar to what the main core does. Output depends on LP UART already being + initialized and configured. + Disabling this option will reduce the LP core binary size by not + linking in panic handler functionality. + +config ULP_HP_UART_CONSOLE_PRINT + depends on ULP_COPROC_TYPE_LP_CORE + bool + prompt "Route lp_core_printf to the console HP-UART" + help + Set this option to route lp_core_printf to the console HP-UART. + This allows you to easily view print outputs from the LP core, without + having to connect to the LP-UART. This option comes with the following + limitations: + + 1. There is no mutual exclusion between the HP-Core and the LP-Core accessing + the HP-UART, which means that if both cores are logging heavily the output + strings might get mangled together. + 2. The HP-UART can only work while the HP-Core is running, which means that + if the HP-Core is in deep sleep, the LP-Core will not be able to print to the + console HP-UART. + + Due to these limitations it is only recommended to use this option for easy debugging. + For more serious use-cases you should use the LP-UART. diff --git a/components/ulp/subproject/components/ulp_riscv/Kconfig.ulp_riscv b/components/ulp/subproject/components/ulp_riscv/Kconfig.ulp_riscv new file mode 100644 index 00000000000..f757731350d --- /dev/null +++ b/components/ulp/subproject/components/ulp_riscv/Kconfig.ulp_riscv @@ -0,0 +1,20 @@ +# Sourced by the ULP coprocessor driver on the HP core, in +# components/ulp/Kconfig. Not named Kconfig, which would also attach it to +# this component and define every option twice. + +config ULP_RISCV_INTERRUPT_ENABLE + depends on ULP_COPROC_TYPE_RISCV + bool + prompt "Enable ULP RISC-V interrupts" + default "n" + help + Turn on this setting to enable interrupts on the ULP RISC-V core. + +config ULP_RISCV_UART_BAUDRATE + depends on ULP_COPROC_TYPE_RISCV + int + prompt "Baudrate used by the bitbanged ULP RISC-V UART driver" + default 9600 + help + The accuracy of the bitbanged UART driver is limited, it is not + recommended to increase the value above 19200.