Commit Graph

541 Commits

Author SHA1 Message Date
Sudeep Mohanty
8979950ebf 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.
2026-09-08 17:26:30 +02:00
Sudeep Mohanty
53ea9b200e 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.
2026-09-02 09:31:07 +02:00
Sudeep Mohanty
cb2b2f9b78 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.
2026-09-02 09:31:07 +02:00
Sudeep Mohanty
1bec6e09d9 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.
2026-09-02 09:31:07 +02:00
morris
cd356d592d refactor(adc): move channel count to adc LL 2026-08-25 12:30:52 +08:00
wanckl
8889acc3d1 fix(ci): reduce peripheral multi dev test timeout time 2026-08-19 15:30:55 +08:00
Wu Zheng Hui
234c68ba93 Merge branch 'feat/support_esp32s31_xtal_fosc_force_pu' into 'master'
feat: update XTAL sleep FPU parameters to save power

Closes PM-824 and IDF-15576

See merge request espressif/esp-idf!51100
2026-08-10 15:37:00 +08:00
Sudeep Mohanty
06963baf0b test(ulp): add custom linker host tests
Add build-only host tests for LP-core custom linker layouts supplied through the
LINKER option. Cover the positive paths (a full-replacement layout, a
multi-region layout with a fixed-address section, a run-from-HP-mem layout, and
memory protection) and the link-time and configure-time checks (reset-vector
placement, sizing, shared-memory overrun, the MEMPROT RX/RW boundary, a missing
reset vector, and a missing LINKER script).
2026-07-31 14:50:09 +02:00
Sudeep Mohanty
7c3b82562a feat(ulp): support custom LP-core linker layouts via the LINKER_LAYOUT option 2026-07-31 14:48:52 +02:00
Sudeep Mohanty
869f2f355f refactor(ulp): assemble LP-core linker scripts from base, layout and checks 2026-07-31 14:48:52 +02:00
Renz Bagaporo
2fe7e0f047 fix(ulp): preserve legacy ulp_embed_binary link order
Legacy ulp_embed_binary() call-site sources were attached directly to the CMake v2 child executable. However, the ULP runtime is linked with WHOLE_ARCHIVE through target_link_options(), which CMake emits before executable objects. This reversed the CMake v1 order, changed ULP code placement, and allowed runtime weak definitions to take precedence over legacy strong handlers.

Build the call-site sources as a dedicated static archive and place its whole-archive option before the runtime archive. Preserve the parent sdkconfig and include view, including FSM-specific include behavior, without generating a synthetic component tree.

Factor linker-specific whole-archive handling into a shared CMake v2 helper for GNU, Darwin, and ULP FSM linkers. Link the archive target normally as well so CMake tracks build and relink dependencies when a legacy ULP source changes.
2026-07-30 08:02:26 +09:00
Renz Bagaporo
1f5cba3070 fix(ulp): clarify buildv2 child marker
Rename the internal ULP child-build marker to __ULP_BUILDV2 so component CMake files make the build-system scope explicit.

Document that the marker is currently set only by the IDF_BUILD_V2 ULP child path.
2026-07-29 13:08:23 +09:00
Renz Bagaporo
83cdcc1da3 fix(ulp): use builtin v2 project for legacy embed
Route ulp_embed_binary() through a built-in CMake v2 default ULP project instead of generating a compatibility project with a synthetic main component.

Attach legacy ULP sources directly to the ULP executable, pass the parent component include view through the existing ULP_S_SOURCES/COMPONENT_* channel, and remove the generated legacy project templates plus the component path ownership validation bypass they required.

Update the build-system coverage to assert that the builtin child project builds and rebuilds when parent-owned ULP sources change.
2026-07-29 13:08:23 +09:00
Renz Bagaporo
c925f6bcc6 fix(ulp): restore legacy LP-core child link behavior
Preserve all linker scripts passed to target_linker_script() so LP-core child builds keep the full esp32p4 LP ROM script set instead of only the first script.

Link the ULP runtime component as WHOLE_ARCHIVE for ULP child builds, matching the legacy helper behavior where runtime sources were added directly to the executable. This keeps strong runtime handlers such as ulp_lp_core_panic_handler from being skipped in favor of weak defaults from already-extracted archive objects.

Validated with the esp32p4 lp_core_hp_uart panic and LP-ROM pytest cases, plus the focused local/CI build_all shape for the app.
2026-07-29 13:08:23 +09:00
Renz Bagaporo
a91a316449 ci(ulp): re-enable legacy ULP buildv2 jobs 2026-07-29 13:08:22 +09:00
Renz Bagaporo
288b9a6e00 feat(ulp): build legacy ULP APIs through CMake v2 shim 2026-07-29 13:08:22 +09:00
wuzhenghui
228970b0c2 feat(esp_system): support XTAL as RTC fast clock source 2026-07-28 19:57:57 +08:00
Renz Bagaporo
5b67ff37cd ci(ulp): temporarily disable legacy ULP apps for buildv2
Keep legacy ULP apps on the CMake v1 build path while buildv2 coverage
is limited to full_subproject ULP apps.

Also add the missing esp_driver_gpio dependency to the esp_pm test app
so buildv2 dependency checks see driver/rtc_io.h explicitly.
2026-07-15 10:17:52 +09:00
Frantisek Hrbata
a9ea4f1105 refactor(ulp): provide a ulp_project.cmake subproject wrapper API
Build ULP full subprojects through a dedicated entry file,
components/ulp/cmake/ulp_project.cmake, that wraps tools/cmakev2/idf.cmake
and layers a small ULP API on top, mirroring the cmakev2 layering:

  ulp_project_init      like idf_project_init (init, detect the ULP type,
                        reset the compile/link options inherited from the app)
  ulp_build_executable  like idf_build_executable, plus the embeddable
                        .bin/.h/.ld artifacts
  ulp_project_default   like idf_project_default (single-executable case)

A child project now includes this one file instead of idf.cmake and calls
these helpers directly, so idf_build_executable is used as-is for the
multi-binary case and the module-path indirection (include(IDFULPProject)
resolved via -DCMAKE_MODULE_PATH) is gone.

As a result:
- IDFULPProjectv2.cmake is removed; its setup moves into the wrapper.
- IDFULPProject.cmake becomes the CMake v1-only entry point.
- The ULP component no longer registers a POST_ELF callback; the binary
  artifacts are produced by ulp_build_executable.
- The v2 full-subproject examples (lp_core, riscv, fsm, multi_binary,
  combined) are updated to the new API.
- The ULP subproject API is documented in build-system-v2.rst.

Also fix a latent bug this exercises: idf_build_library emitted linker
scripts as "-T <name>" relying on a following "-L" search directory. GNU
ld only searches -L directories that precede -T, so the direct
esp32ulp-elf-ld link used for ULP FSM failed to open the script. Emit the
absolute path instead, matching what the CMake v1 ULP build already does.

Finally, replace the parent-argument bypass loop that used to live in
IDFULPProjectv2.cmake with --no-warn-unused-cli on the child configure,
and stop passing the unused IDF_PARENT_BUILD_DIR.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2026-07-15 09:34:05 +09:00
Frantisek Hrbata
ceaa0b7a3d refactor(ulp): use target_linker_script for memory-layout scripts
Rename the ULP memory-layout linker scripts to .ld.in and let the
standard build system preprocess them, instead of the ULP build doing
its own C-preprocessor pass.

CMake v2 (full subproject): register each memory-layout template with
target_linker_script using the new FLAGS (the include dirs its #include
lines need) and MEMORY (emit before section-placement scripts) options.
soc/soc.h and the esp_common headers now resolve from the linked
component graph automatically, so the POST_ELF callback no longer
harvests include directories or preprocesses the template; it only
produces the .bin and the symbol header/linker exports from the ELF.

CMake v1 (legacy): the templates are now .ld.in, so strip the suffix
with NAME_WLE when deriving the generated script name. The v1-only
preprocessing helpers (__ulp_add_preprocessed_linker_script and
__ulp_create_arg_file) move from the shared IDFULPProjectCommon.cmake
to IDFULPProject.cmake next to their only caller, since CMake v2 no
longer references them.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2026-07-15 09:14:35 +09:00
Renz Bagaporo
010ab4ca1f feat(ulp): use cmakev2 linker script preprocessing
Register ULP memory linker scripts with target_linker_script so CMake v2 handles preprocessing and attachment through the component graph.

Keep the generated legacy outputs named .ld by stripping only the .in suffix, and pass full linker script paths to support direct ld invocation.
2026-07-15 09:14:35 +09:00
Renz Bagaporo
7d75f85221 feat(ulp): build ULP full subprojects as CMake v2 children 2026-07-15 09:14:35 +09:00
Frantisek Hrbata
96c474e554 fix(ulp/cmakev2): place sub-project artifacts under parent build dir
The ULP sub-project's editable sdkconfig and dependencies.lock previously
landed in the source tree (the defaults of __init_kconfig and the
component manager). A typical cleanup before changing target (rm -rf
build/ sdkconfig) did not reach them, so a stale CONFIG_IDF_TARGET would
survive into the next build and trip the cross-check in the ULP's
__init_idf_target.

In the cmakev2 path of __setup_ulp_project, anchor the ULP binary dir to
${BUILD_DIR}/subprojects/${app_name} and pass -DSDKCONFIG and
-DDEPENDENCIES_LOCK so both files live alongside the rest of the ULP
build artifacts. Wiping build/ (or idf.py fullclean, which set-target
pulls in) now reverts all sub-project state in one shot.

Also add a safety-net rename of any pre-existing sub-project sdkconfig
to .old when _IDF_PY_SET_TARGET_ACTION=1 is set in the parent's
configure environment. This mirrors what cmakev1 does for its own
sdkconfig and covers the off-path case where someone reconfigures via
cmake -B build -DIDF_TARGET=... directly, without running fullclean. In
the normal idf.py set-target flow the rename is a no-op because
fullclean has already removed the build tree.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2026-07-14 16:54:58 +09:00
Frantisek Hrbata
5aca23352a feat(cmakev2): add menuconfig dispatcher for sub-projects with own configuration
Sub-projects that grow their own configuration (e.g. the ULP cmakev2
flow, where the sub-project runs its own kconfgen and writes its own
sdkconfig) need a way to expose that configuration via `idf.py
menuconfig` without forcing every caller to know per-sub-project target
names.

Add a small registration + dispatcher mechanism in cmakev2:

* `idf_register_menuconfig(NAME <label> TARGET <cmake-target>)` records
  a menuconfig target with the build. It is intentionally decoupled
  from `idf_create_menuconfig` so that any custom target may be
  registered, including the parent-side proxy targets that sub-projects
  add via `externalproject_add` (e.g. ULP's `menuconfig-<app_name>`).
* `__finalize_menuconfig()` at project finalization creates the
  user-facing `menuconfig` target:
  - With a single registration, `menuconfig` is a thin alias for that
    target. Behaviour is identical to before for all existing single
    -menuconfig projects (bootloader/TEE share the main configuration,
    so they do not register).
  - With two or more registrations, `menuconfig` runs a small Python
    dispatcher (`tools/kconfig_new/menuconfig_dispatcher.py`) that
    lists the registered configurations and re-invokes the selected
    target. The prompt surfaces the direct target name (e.g.
    `idf.py menuconfig-ulp_app`) so users learn the per-sub-project
    target after first use.

`__project_default()` is updated to register the main application as
`menuconfig-app` and then call `__finalize_menuconfig`. The component
side change is one line in `components/ulp/project_include.cmake`,
registering the existing `menuconfig-<app_name>` proxy target.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2026-07-14 16:54:58 +09:00
Frantisek Hrbata
c7b83d32d8 feat(ulp): build ULP sub-project using cmakev2
Add cmakev2 support for the ULP sub-project, allowing it to be built
using the standard idf_project_init() flow when the main project uses
cmakev2. The existing cmakev1 path is preserved — the ULP
CMakeLists.txt checks IDF_BUILD_V2 and delegates to CMakeLists_v2.txt,
following the same pattern used by the bootloader sub-project.

The parent's project_include.cmake now has separate externalproject_add
blocks for cmakev1 and cmakev2, making the different requirements of
each build system explicit:

cmakev1 path:
  Passes -DSDKCONFIG_HEADER and -DSDKCONFIG_CMAKE from the parent.
  The ULP sub-project includes the parent's sdkconfig.cmake directly
  (no kconfgen). This is the existing behavior.

cmakev2 path:
  Passes -DSDKCONFIG_DEFAULTS pointing to the parent's sdkconfig.
  The ULP sub-project runs its own kconfgen with its own component
  set, generating separate sdkconfig.h and sdkconfig.cmake outputs.
  The parent's sdkconfig serves as defaults, so the ULP inherits
  the parent's IDF configuration while adding ULP-specific options
  from its own components. A menuconfig-<app_name> proxy target is
  registered in the parent build for ULP-specific configuration.
  The proxy target depends on the ULP configure step to ensure the
  cmake cache exists before menuconfig runs.

  Passes -DIDF_CUSTOM_TOOLCHAIN=1 so that __init_toolchain() skips
  IDF_TARGET-based toolchain resolution and component
  project_include.cmake files skip IDF toolchain flag manipulation.

IDFULPProject.cmake is updated to skip the direct
include(${SDKCONFIG_CMAKE}) when running under cmakev2, as
idf_project_init() handles sdkconfig loading.

Verified with identical ULP artifacts (bin, ld, h) across all three
ULP types:
- LP Core (esp32c6, lp_core/lp_uart/lp_uart_print example)
- RISC-V (esp32s3, ulp_riscv/adc example)
- FSM (esp32, ulp_fsm/ulp example)

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2026-07-14 16:54:58 +09:00
Meet Patel
25fe69f946 Merge branch 'bugfix/pthread_find_key_uaf' into 'master'
fix(pthread,ulp): harden TLS key lookup and ULP bss_size validation

Closes SEC-248 and SEC-1122

See merge request espressif/esp-idf!50410
2026-07-11 23:18:21 +05:30
Renz Christian Bagaporo
907f4a66d9 Merge branch 'fix/lp_core_gpio_wakeup' into 'master'
fix(ulp): wake pin wakes ESP32-P4 from deep sleep on P4

Closes IDF-15823

See merge request espressif/esp-idf!49855
2026-07-10 07:44:36 +08:00
Meet Patel
8c92af6201 fix(ulp): validate bss_size before zeroing ULP BSS region
Crafted ULP binaries could specify a bss_size larger than the reserved
memory, causing memset to zero past the ULP region boundary.
2026-07-06 22:56:21 +05:30
morris
651d6a283f refactor(esp_common): centralize ALIGN_UP/ALIGN_DOWN into esp_macros.h
Remove ~50 duplicate local definitions of ALIGN_UP/ALIGN_DOWN/ALIGN_UP_BY/
ALIGN_DOWN_BY across the codebase and replace them with canonical
ESP_ALIGN_UP/ESP_ALIGN_DOWN from esp_macros.h.
2026-07-06 13:36:06 +08:00
Renz Bagaporo
e382c58e46 fix(ulp): clear LP GPIO edge wakeup latch 2026-07-02 16:43:46 +09:00
Renz Bagaporo
b4215c6d4d test(ulp): add gpio wakeup test 2026-07-02 16:43:46 +09:00
Sudeep Mohanty
8541991224 Merge branch 'fix/lp_spi_driver_and_tests' into 'master'
fix(ulp/lp_spi): fix stale data in driver

Closes IDF-11471, IDF-11472, and IDFCI-10465

See merge request espressif/esp-idf!48972
2026-06-30 15:50:26 +02:00
Sudeep Mohanty
ae1386e891 test(ulp/lp_spi): improve test stability and add cleanup
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-30 10:21:56 +02:00
Sudeep Mohanty
a019532119 fix(ulp/lp_spi): fix driver bugs and add bus deinit API
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-30 10:21:34 +02:00
Sudeep Mohanty
c5d8ff7ef6 fix(ulp): make LP peripheral default config macros C++ compatible
Use dual-path macros: C keeps fragment-style designated initializers;
C++ uses GNU statement expressions (ESP_LOG_CONFIG_INIT pattern).
Add compile-only C++ regression tests for LP UART/I2C and ULP RISC-V I2C.

Closes https://github.com/espressif/esp-idf/issues/18369

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-29 12:16:39 +02:00
Samuel Obuch
7fac3ca134 Merge branch 'fix/lp_core_noreset_under_debug_option' into 'master'
fix(lp_core): fix build for CONFIG_ULP_NORESET_UNDER_DEBUG=n

See merge request espressif/esp-idf!49831
2026-06-22 11:05:10 +02:00
Marius Vikhammer
ecd0b36adb Merge branch 'fix/lp-core-rc-fast-delay' into 'master'
fix(ulp): use SoC RC_FAST frequency for LP core delay

Closes IDFCI-10618

See merge request espressif/esp-idf!49797
2026-06-22 14:00:28 +08:00
Samuel Obuch
a555e67f0b fix(lp_core): fix build for CONFIG_ULP_NORESET_UNDER_DEBUG=n 2026-06-19 13:09:18 +02:00
Marius Vikhammer
d74d5959da test(ulp): check LP core apps avoid soft-float helpers
Inspect generated LP core ELF files so accidental floating-point helper linkage is caught in CI.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-18 14:08:14 +08:00
Marius Vikhammer
dd5533e911 fix(ulp): use RC_FAST approximation for LP core fallback
Use the shared SoC RC_FAST approximation when the target has no RTC_FAST source option.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-18 11:58:40 +08:00
Marius Vikhammer
7b1da65f95 fix(ulp): use SoC RC_FAST frequency for LP core delay
Use the target RC_FAST approximation for LP core delay conversion.
This prevents ESP32-S31 from under-delaying when running from RC_FAST.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-18 11:46:23 +08:00
Meet Patel
d72bdfedc9 fix(ulp): force SW channel control in ULP-RISC-V ADC read
On ESP32-S2/S3 the ULP-RISC-V ADC shares the RTC SAR controller with the
main CPU. ulp_adc_init() sets sar1_en_pad_force = 1 so software selects
the channel, but deep-sleep entry resets it to 0 (ULP/HW control). After
that, the per-read channel selection in ulp_riscv_adc_read_channel() is
ignored and every channel returns the same stale value. Single-channel
worked only because the channel never changed.

Re-assert RTC controller (sar1_en_pad_force = 1) before selecting the
channel on each read so multi-channel sampling works after deep sleep.
2026-06-17 21:57:10 +05:30
Meet Patel
c0601e512b feat(ulp): add multi-channel ADC init for ULP
ulp_adc_init() could only configure a single ADC channel, so monitoring
several channels from the ULP on one ADC unit was not possible. Add
ulp_adc_multi_channel_init() to configure multiple channels with
per-channel attenuation while keeping the existing single-channel API
unchanged.

Closes https://github.com/espressif/esp-idf/issues/11160
2026-06-16 12:50:58 +05:30
Abanoub Salah
8e53a4a5df fix(ulp_riscv): Prioritize error bits over data flags in I2C interrupt wait 2026-06-15 10:13:18 +03:00
Marius Vikhammer
5e0e916591 Merge branch 'fix/lp_core_s31_pdma_intr_entry' into 'master'
fix(ulp): fix LP core interrupt vector entry for LP PDMA on esp32s31

See merge request espressif/esp-idf!49521
2026-06-11 15:55:43 +08:00
Marius Vikhammer
0577a6bf87 fix(ulp): fix LP core interrupt vector entry for LP PDMA on esp32s31 2026-06-10 15:03:57 +08:00
Marius Vikhammer
42bb45db22 fix(ulp): fixes potential race-condition for lp-timer wakeup with lp-core
Reconfigure wakeup time before enabling the wakeup source to avoid
a wakeup from potentially stale values.

Closes https://github.com/espressif/esp-idf/issues/17009
2026-06-10 11:10:01 +08:00
hebinglin
46ff88717c fix(ulp): fix lp uart keep wakeup triggered 2026-06-08 16:17:09 +08:00
Alexey Lapshin
7bcf7dcbcf feat(lp_core): optimize ulp_lp_core_delay_X functions 2026-06-04 16:12:21 +07:00
Guillaume Souchere
33e774397c Merge branch 'feat/error-code-registration' into 'master'
feat(esp_common): implement composable error code registration via link-time arrays

Closes IDF-15105 and IDF-15486

See merge request espressif/esp-idf!46125
2026-06-01 09:40:37 +02:00