mirror of
https://github.com/espressif/esp-idf.git
synced 2026-09-22 13:01:16 +03:00
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.
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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()
|
||||
|
||||
120
components/ulp/subproject/components/lp_core/CMakeLists.txt
Normal file
120
components/ulp/subproject/components/lp_core/CMakeLists.txt
Normal file
@@ -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)
|
||||
21
components/ulp/subproject/components/ulp_fsm/CMakeLists.txt
Normal file
21
components/ulp/subproject/components/ulp_fsm/CMakeLists.txt
Normal file
@@ -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")
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 \
|
||||
|
||||
@@ -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 \
|
||||
|
||||
@@ -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 \
|
||||
|
||||
@@ -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 \
|
||||
|
||||
@@ -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::
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -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 <ulp/lp_core/lp_core/include/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 <ulp/subproject/components/lp_core/include/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:
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -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::
|
||||
|
||||
|
||||
@@ -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``) 默认用于调试。
|
||||
|
||||
|
||||
@@ -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 <ulp/lp_core/lp_core/include/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 <ulp/subproject/components/lp_core/include/ulp_lp_core_interrupts.h>`。有关特定目标可使用的中断的详细信息,请参阅 **{IDF_TARGET_NAME} 技术参考手册** [`PDF <{IDF_TARGET_TRM_CN_URL}#ulp>`__]。
|
||||
|
||||
例如,要重写 LP IO 中断的处理程序,可以在 ULP LP 内核代码中定义以下函数:
|
||||
|
||||
|
||||
@@ -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`` 可用于调试。
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
idf_component_register(SRCS "main.S"
|
||||
REQUIRES ulp)
|
||||
REQUIRES ulp_fsm)
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
idf_component_register(SRCS "main.c"
|
||||
REQUIRES ulp)
|
||||
REQUIRES ulp_riscv)
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
idf_component_register(SRCS "wake_up.S"
|
||||
REQUIRES ulp)
|
||||
REQUIRES ulp_fsm)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
idf_component_register(SRCS "main.c"
|
||||
REQUIRES ulp)
|
||||
REQUIRES lp_core)
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
idf_component_register(SRCS "main.c"
|
||||
REQUIRES ulp)
|
||||
REQUIRES lp_core)
|
||||
|
||||
@@ -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
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user