Compare commits

..

990 Commits

Author SHA1 Message Date
81900f4fb9 Implement i2c_master_multi_buffer_transmit_receive() 2025-12-01 12:44:27 +01:00
Wang Meng Yang
683ddf8a6e Merge branch 'bugfix/a2dp_deinit_crash' into 'master'
fix(bt): fixed crash caused by deinit during A2DP connection initiation

Closes IDFCI-3092, BT-4158, BTQABR2023-617, IDFCI-6268, and BT-4134

See merge request espressif/esp-idf!43534
2025-11-27 09:34:35 +08:00
Adam Múdry
862f000805 Merge branch 'feat/sdmmc_bdl' into 'master'
feat(bdl): Add support for SDMMC

Closes IDF-12751

See merge request espressif/esp-idf!39640
2025-11-26 17:46:10 +01:00
Tomas Rezucha
24efd7f1e7 Merge branch 'ci/reenable_p4_usb_device_tests' into 'master'
ci(usb/device): re-enable usb_device tests for ESP32-P4

Closes IDF-14369 and IDF-14832

See merge request espressif/esp-idf!43734
2025-11-26 14:44:12 +01:00
Roland Dobai
b60860eb7e Merge branch 'fix/cmakev2_unnecessary_config_generation' into 'master'
fix(cmakev2/kconfig): avoid unnecessary sdkconfig generation

Closes IDF-14431

See merge request espressif/esp-idf!43663
2025-11-26 13:32:12 +01:00
Roland Dobai
20e3e8a5af Merge branch 'feat/cmakev2_fast_reflashing' into 'master'
feat(cmakev2/ldgen): provide ldgen with a list of mutable libraries

Closes IDF-14322

See merge request espressif/esp-idf!43672
2025-11-26 13:31:58 +01:00
Jiang Jiang Jian
0638306b11 Merge branch 'bugfix/fix_get_current_band_error_after_set_bandmode' into 'master'
fix(wifi): fix get incorrect current band after set bandmode

Closes WIFIBUG-1575 and WIFIBUG-1588

See merge request espressif/esp-idf!43608
2025-11-26 20:28:28 +08:00
Ondrej Kosta
b111c84f9e Merge branch 'feat/upt_tests_new_runners' into 'master'
feat(ci): updated Ethernet test to align with new runners

Closes IDF-14823

See merge request espressif/esp-idf!43573
2025-11-26 17:52:43 +08:00
Rahul Tank
f888ded5fb Merge branch 'bugfix/check_psync_status' into 'master'
fix(nimble): Add a check for psync before processing

Closes BLERP-2293, BLERP-2397, and BLERP-2414

See merge request espressif/esp-idf!42377
2025-11-26 13:36:24 +05:30
Roland Dobai
e4a050c939 Merge branch 'change/pip_install_eager' into 'master'
CI: Upgrade the full dependency tree of CI-related Python packages

Closes IDF-14409

See merge request espressif/esp-idf!43265
2025-11-26 09:00:52 +01:00
Ren Peiying
a5d3f81c9c Merge branch 'docs/update_translation_for_size' into 'master'
docs: Update translation for size.rst

Closes DOC-12964

See merge request espressif/esp-idf!43702
2025-11-26 15:19:22 +08:00
Roland Dobai
584e8c71fd Merge branch 'ci/unlock_click' into 'master'
Fixed ctx.params resolving for the new Click version

Closes IDF-14158

See merge request espressif/esp-idf!42610
2025-11-26 08:09:59 +01:00
Song Ruo Jing
551b264193 Merge branch 'bugfix/ppa_srm_stuck_on_dma' into 'master'
fix(ppa): fix potential SRM operation stuck on DMA issue

Closes IDFGH-16401

See merge request espressif/esp-idf!42733
2025-11-26 15:01:50 +08:00
Wang Ning
08a3ef14fa Merge branch 'docs/update_twai_api_ref_struct' into 'master'
docs: update heading levels for twai api reference

Closes IDFGH-16815

See merge request espressif/esp-idf!43657
2025-11-26 14:36:26 +08:00
Wang Ning
914dc26402 docs: update heading levels for twai api reference 2025-11-26 14:36:25 +08:00
morris
c68237f5fa Merge branch 'feat/esp32p4_eco5_adc_cali' into 'master'
feat(adc): support ADC calibration on ESP32P4 ECO5

Closes IDF-14357

See merge request espressif/esp-idf!43685
2025-11-26 12:22:20 +08:00
Mahavir Jain
4186f75296 Merge branch 'feat/esp_tee_hw_stack_guard' into 'master'
feat(esp_tee): Support for the RISC-V H/W stack guard with ESP-TEE enabled

Closes IDF-10770 and IDF-14350

See merge request espressif/esp-idf!43162
2025-11-26 09:42:38 +05:30
Wu Zheng Hui
f45c68b63d Merge branch 'feat/enable_wakeup_tests_for_p4_v3' into 'master'
feat(esp_hw_support): re-enable P4 sleep wakeup tests for rev3.0

Closes IDF-14400

See merge request espressif/esp-idf!43674
2025-11-26 12:03:05 +08:00
Song Ruo Jing
a49d44b188 Merge branch 'ci/fix_p4_eco5_test_cases' into 'master'
fix(ci): re-enable p4 eco5 ledc, dma2d, rtc_clk test cases

Closes IDF-14398 and IDFGH-16808

See merge request espressif/esp-idf!43611
2025-11-26 12:00:45 +08:00
Shu Chen
5e33abd510 Merge branch 'feat/support_154_for_h4' into 'master'
feat(802.15.4): supported 802.15.4 for esp32h4

See merge request espressif/esp-idf!43148
2025-11-26 03:52:37 +00:00
xiongweichao
86975e6487 fix(bt): fixed crash caused by deinit during A2DP connection initiation
- Only clean up when idle
2025-11-26 11:31:56 +08:00
C.S.M
d628254a01 Merge branch 'feat/update_esp32s31_system_support' into 'master'
feat(esp32s31): Add esp_system component support

See merge request espressif/esp-idf!43655
2025-11-26 11:06:15 +08:00
Yi Wen Xiu
d061906490 Merge branch 'bugfix/update_thread_ci_testcases' into 'master'
feat(openthread): optimize fail cases in CI test

Closes IDFCI-3019, IDFCI-2537, and IDFCI-3623

See merge request espressif/esp-idf!43576
2025-11-26 11:01:47 +08:00
Ondrej Kosta
4e6b35ca9e feat(ci): updated Ethernet tests to align with new runners 2025-11-25 17:26:49 +01:00
Tomas Rezucha
98af307c66 ci(usb/device): re-enable usb_device tests for ESP32-P4 2025-11-25 16:06:57 +01:00
Erhan Kurubas
c9bee75b52 Merge branch 'fix/int_wdt_double_exception' into 'master'
fix(espcoredump): prevent double exception during int_wdt panic with custom stack

Closes IDF-9361

See merge request espressif/esp-idf!43185
2025-11-25 14:03:03 +01:00
Chen Ji Chang
a20b2fab82 Merge branch 'feat/esp_hal_rmt' into 'master'
feat(hal): graudate the RMT hal driver into a new component

Closes IDF-14083 and IDF-13684

See merge request espressif/esp-idf!43336
2025-11-25 19:48:52 +08:00
Konstantin Kondrashov
b7f0fb2827 Merge branch 'contrib/github_pr_17797' into 'master'
feat(esp_event): Allow an event carry more data without malloc (GitHub PR)

Closes IDFGH-16709

See merge request espressif/esp-idf!43128
2025-11-25 19:39:52 +08:00
morris
7540cc3ca0 Merge branch 'ci/add_esp_hal_components_in_g0_test' into 'master'
refactor(g0_components): update component list to dynamically include esp_hal_* components

See merge request espressif/esp-idf!43703
2025-11-25 19:28:05 +08:00
Roland Dobai
8b8301d845 ci(gitlab): Upgrade the full dependency tree of CI-related Python packages
The eager upgreade policy should upgrade the full dependency tree and
not just the packages listed in the requirements file. The disadvantage
is some extra time for package resolution.

This upgrade policy is applied to CI-related packages only because we
don't want this to be used for customer-facing packages and/or provide
the customers with a different environment to that tested in the CI.
2025-11-25 11:22:21 +01:00
Gao Xu
abbb392d70 Merge branch 'feat/p4_eco5_rng' into 'master'
feat(rng): support P4 ECO5 TRNG

Closes IDF-13521

See merge request espressif/esp-idf!42196
2025-11-25 17:41:41 +08:00
gaoxu
c5c586af3e ci(adc): re-enable ADC test on ESP32P4 2025-11-25 17:27:20 +08:00
C.S.M
4becb6dbf6 feat(esp32s31): Add esp_system component support 2025-11-25 17:11:59 +08:00
Jakub Kocka
402cf47f7a ci: Fixed MacOS default shell command 2025-11-25 09:58:53 +01:00
Jakub Kocka
6c2551b4a6 fix: Fixed ctx.params resolving because of the new Click 2025-11-25 09:58:53 +01:00
renpeiying
4b53e05572 docs: Update translation for size.rst 2025-11-25 16:41:40 +08:00
Zhang Wen Xu
7886209dfa Merge branch 'feature/change_ot_psram_default_config' into 'master'
feat(openthread): Use PSRAM by default for OpenThread message buffers when PSRAM is enabled

See merge request espressif/esp-idf!43512
2025-11-25 07:55:08 +00:00
Konstantin Kondrashov
6866cd1d95 Merge branch 'fix/p4_v3_efuse_missed_defines' into 'master'
fix(efuse): Fix test where size of field was obtained incorrectly and missed SOC defines

Closes IDF-14403

See merge request espressif/esp-idf!43574
2025-11-25 15:53:34 +08:00
Peter Dragun
2c0372a66c Merge branch 'tools/monitor_autocolor_docs' into 'master'
docs: Add note about automatic log coloring in IDF Monitor

Closes IDF-11995 and DOC-13023

See merge request espressif/esp-idf!43403
2025-11-25 15:27:00 +08:00
morris
e4192f88e6 refactor(g0_components): update component list to dynamically include esp_hal_* components 2025-11-25 15:21:48 +08:00
Song Ruo Jing
672005c642 fix(ppa): fix potential SRM operation stuck on DMA issue
Apply a workaound to bypass macro block order function in PPA SRM
when specific conditions are met to avoid SRM operation getting stuck
2025-11-25 15:19:41 +08:00
yiwenxiu
0898f62669 feat(openthread): optimize fail cases in CI test 2025-11-25 14:30:17 +08:00
Chen Jichang
2cb84ecf95 feat(hal): graudate the RMT hal driver into a new component 2025-11-25 14:21:01 +08:00
C.S.M
cb5f2ff4c2 Merge branch 'feat/update_esp32s31_g0_support' into 'master'
feat(esp32s31): Add g0 component support

See merge request espressif/esp-idf!43599
2025-11-25 13:49:55 +08:00
morris
c7f4c62e00 Merge branch 'refactor/bitscrambler_in_esp_hal_dma' into 'master'
refactor(hal): bitscrambler hal -> esp_hal_dma, usj hal -> esp_hal_usb

Closes IDF-14353

See merge request espressif/esp-idf!43542
2025-11-25 13:06:26 +08:00
Zhang Shuxian
bcedb69c37 docs: Update CN translation 2025-11-25 11:54:43 +08:00
Peter Dragun
007ae938c1 docs: Add note about automatic log coloring in IDF Monitor 2025-11-25 11:46:55 +08:00
gaoxu
2b24530b33 feat(rng): support P4 ECO5 TRNG 2025-11-25 11:17:48 +08:00
Song Ruo Jing
d33e8a48ad fix(ppa): YUV444 cannot be a PPA SRM output color mode 2025-11-25 10:53:15 +08:00
Song Ruo Jing
9079838b64 docs(ppa): add a note about bilinear scaling algorithm in PPA SRM
Closes https://github.com/espressif/esp-idf/issues/17531
2025-11-25 10:53:15 +08:00
gaoxu
7a352eb676 feat(adc): support ADC calibration on ESP32P4 ECO5 2025-11-25 10:44:01 +08:00
Island
c6f14a5663 Merge branch 'bugfix/fix_ble_scan_enable_timeout' into 'master'
Fixed scan HCI command timeout issue on ESP32

Closes BT-4153 and BLERP-2404

See merge request espressif/esp-idf!43344
2025-11-25 10:30:54 +08:00
C.S.M
b450150fff feat(esp32s31): Add g0 component support 2025-11-25 10:16:08 +08:00
morris
8981838fbe Merge branch 'fix/mcpwm_p4eco_psram_test' into 'master'
chor(mcpwm): replace p4 psram test

Closes IDF-14412

See merge request espressif/esp-idf!43651
2025-11-25 08:33:20 +08:00
Erhan Kurubas
69924c2322 Merge branch 'refactor_apptrace_uart' into 'master'
Refactor apptrace uart

Closes IDF-4323, IDF-4804, and IDF-7823

See merge request espressif/esp-idf!42885
2025-11-24 23:19:11 +01:00
Konstantin Kondrashov
ccee6d23a2 fix(efuse): Fix test where size of field was obtained incorrectly
When the eFuse field consists of single descriptor, its size can be
taken from struct member 'bit_count'. However, when the field consists of
multiple descriptors, the size should be obtained via esp_efuse_get_field_size()
2025-11-24 17:13:54 +02:00
Konstantin Kondrashov
3f519e8a97 fix(efuse): Adds missing SOC defines for ESP32-P4 v3 2025-11-24 17:13:54 +02:00
wuzhenghui
0728cfef74 feat(esp_hw_support): re-enable P4 sleep wakeup tests for rev3.0 2025-11-24 22:10:13 +08:00
Frantisek Hrbata
ca3974c937 feat(cmakev2/ldgen): provide ldgen with a list of mutable libraries
The build system keeps track of each component source. Currently
there are four types of sources:

1. "project_components" - project components
2. "project_extra_components" - components from EXTRA_COMPONENT_DIRS
3. "project_managed_components" - custom project dependencies managed by the IDF Component Manager
4. "idf_components" - ESP-IDF built-in components, typically under /components

This can be used to identify the component libraries that are likely to
change during application development and pass them to ldgen as mutable
libraries. Add all components with "project_components" as their source
as mutable.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-11-24 14:58:02 +01:00
Laukik Hase
7c24682643 feat(esp_tee): Add support for the RISC-V H/W stack guard mechanism 2025-11-24 18:49:06 +05:30
Frantisek Hrbata
4ba40bce20 fix(cmakev2/kconfig): avoid unnecessary sdkconfig generation
Add a helper function `__should_generate_sdkconfig()` that checks
whether the sdkconfig file should be generated.  The
`__generate_sdkconfig()` function can be called multiple times, such as
when the initial sdkconfig is generated at the start of the build
process and later after additional components are fetched by the
component manager.  There might be no components fetched by the
component manager, for example, in the hello_world example, or the
downloaded components may not contain any configuration files. In such
cases, there is no need to regenerate the sdkconfig. This helper
function stores the list of configuration files in the
`__PREV_KCONFIGS`, `__PREV_KCONFIG_PROJBUILDS`, and
`__PREV_SDKCONFIG_RENAMES` build properties at its end, and at the
beginning, it compares them with the current lists of configuration
files.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-11-24 13:44:01 +01:00
Erhan Kurubas
f2c75dcf52 change(app_trace): implement uart without driver APIs 2025-11-24 12:17:30 +01:00
Martin Vychodil
80ed20959d Merge branch 'feat/nvs_iteration_statistics_examples' into 'master'
feat(examples/storage): add nvs statistics and iteration examples

Closes DOC-12742

See merge request espressif/esp-idf!42327
2025-11-24 17:54:31 +08:00
Konstantin Kondrashov
18eee1daa6 Merge branch 'feat/esp_timer_systimer_h4_support' into 'master'
feat(systimer): Support systimer/esp_timer/OS tick for esp32h4

Closes IDF-12375, IDF-12377, and IDF-12327

See merge request espressif/esp-idf!43613
2025-11-24 17:44:04 +08:00
Fu Hanxi
26a01e843c Merge branch 'ci/known-failure-dut-id' into 'master'
ci: pytest-ignore skip using dut id

Closes CII-44

See merge request espressif/esp-idf!43539
2025-11-24 10:25:04 +01:00
Shen Meng Jing
a9523977dc Merge branch 'docs/sync_en_and_cn_docs' into 'master'
docs: Sync EN and CN docs without translation label

Closes DOC-13026

See merge request espressif/esp-idf!43628
2025-11-24 16:10:04 +08:00
morris
96120a5219 chor(mcpwm): replace p4 psram test 2025-11-24 16:03:46 +08:00
Sudeep Mohanty
256dd4df96 Merge branch 'fix/reenable_freertos_esp_system_test_apps_for_p4_eco5' into 'master'
Re-enable freertos and esp_system test apps for p4 eco5

Closes IDF-14419 and IDF-14421

See merge request espressif/esp-idf!43630
2025-11-24 08:30:07 +01:00
Gao Xu
8fc0489408 Merge branch 'fix/adc_continuous_iram_config' into 'master'
fix(adc): fix ESP32/S2 panic when use continuous ADC

Closes IDFGH-16388

See merge request espressif/esp-idf!41732
2025-11-24 14:14:58 +08:00
Sudeep Mohanty
25c7a8179d ci(esp_system): Re-enable esp_system tests for esp32p4 2025-11-24 10:25:48 +05:30
Sudeep Mohanty
4832c72163 ci(freertos): Re-enable freertos tests for esp32p4 2025-11-24 10:24:27 +05:30
zhanghaipeng
c5e50ccd19 fix(bt): Update esp32 libbtdm_app.a (15a18b1a)
- fix(ble): fixed BLE enable scan timeout
 - fix(ble): fixed crash in "btdm_controller_task"
2025-11-24 12:14:37 +08:00
Shen Mengjing
bc79ba454d docs: Sync EN and CN docs without translation label 2025-11-24 11:40:24 +08:00
Chen Ji Chang
16b81515b2 Merge branch 'fix/update_h4_mp_final_ld' into 'master'
fix(esp_rom): update H4 MP ld files

See merge request espressif/esp-idf!43590
2025-11-24 11:29:28 +08:00
gaoxu
93f4b9c13f fix(adc): fix ESP32/S2 panic when use continuous ADC 2025-11-24 11:16:07 +08:00
Rahul Tank
c9090a57f2 fix(nimble): Add a check for psync before processing 2025-11-24 08:27:41 +05:30
zhuanghang
6928688a1e fix(802.15.4): fix sfd_cnt and crc_cnt reg for 154 on h2 c5 c6 2025-11-24 10:39:09 +08:00
zhuanghang
ceef28fe9e feat(802.15.4): supported 802.15.4 for esp32h4 2025-11-24 10:39:01 +08:00
Island
470db615fb Merge branch 'feat/show_how_to_use_smp_in_blufi_example' into 'master'
feat(ble/blufi): Support setting BLE encryption for blufi

Closes BLERP-2232 and DOC-13032

See merge request espressif/esp-idf!41779
2025-11-24 10:31:03 +08:00
morris
49d5fa4532 Merge branch 'fix/usb_phy_on_linux' into 'master'
fix(usb): Fix USB PHY mocking on linux target

Closes IEC-418

See merge request espressif/esp-idf!43563
2025-11-23 11:48:32 +08:00
Marius Vikhammer
6a07ab8834 Merge branch 'bugfix/libc_unligned_opt_p4_eco5' into 'master'
fix(libc): fixed P4 ECO5 always using sub opt. version of memcpy and similar

Closes IDF-14415

See merge request espressif/esp-idf!43580
2025-11-21 23:49:03 +08:00
Konstantin Kondrashov
0084024973 feat(systimer): Support systimer/esp_timer/OS tick for esp32h4 2025-11-21 15:18:43 +02:00
Omar Chebib
41e9060961 Merge branch 'fix/reenable_eh_frame' into 'master'
ci: re-enable eh_frame for the ESP32-P4

Closes IDF-14424

See merge request espressif/esp-idf!43579
2025-11-21 20:56:35 +08:00
Song Ruo Jing
f4a5108d49 fix(uart): fix clock deinitialization in uart_detect_bitrate_stop 2025-11-21 20:41:19 +08:00
Song Ruo Jing
c10ddb0f52 fix(ci): improve rtc_clk test stability on esp32 32k xtal 2025-11-21 20:41:19 +08:00
Song Ruo Jing
5ca9827894 fix(uart): fix parenthesis typo on UART_INTR_CONFIG_FLAG macro
No real impact on the logic, just typo fix
Closes https://github.com/espressif/esp-idf/issues/17885
2025-11-21 20:41:19 +08:00
Song Ruo Jing
9f750b58be fix(ci): re-enable p4 eco5 ledc, dma2d, rtc_clk test cases 2025-11-21 20:41:19 +08:00
Zhang Shuxian
feff20614e docs: Update CN translation and improve formatting 2025-11-21 20:38:20 +08:00
Omar Chebib
0853adcac7 Merge branch 'ci/reenable_cxx_tests' into 'master'
ci: re-enable cxx tests_apps and examples for the ESP32-P4

Closes IDF-14402

See merge request espressif/esp-idf!43581
2025-11-21 20:37:56 +08:00
yinqingzhao
5e27f6623a fix(wifi): fix get incorrect current band after set bandmode 2025-11-21 19:25:26 +08:00
Michael (XIAO Xufeng)
92f4ade659 Merge branch 'feat/add_c5_v102_config' into 'master'
hw_support: add new config for c5 v1.2 and c61 v1.1

See merge request espressif/esp-idf!43532
2025-11-21 19:20:59 +08:00
Wang Meng Yang
289e04dcbe Merge branch 'bugfix/bt_idf_ci' into 'master'
fix(bt/examples): Fixed test_bt_l2cap not finding ESP_SDP_CREATE_RECORD_COMP_EVT

Closes IDFCI-6518

See merge request espressif/esp-idf!43428
2025-11-21 18:55:05 +08:00
C.S.M
16be3c2bfe Merge branch 'feat/update_esp32s31_efuse_rom' into 'master'
feat(esp32s31): Add efuse and esp_rom support

See merge request espressif/esp-idf!43533
2025-11-21 18:29:49 +08:00
zhanghaipeng
60a028fb17 feat(ble/blufi): Support setting BLE encryption for blufi 2025-11-21 16:41:33 +08:00
Chen Jichang
0ce7125942 fix(esp_rom): update H4 MP ld files 2025-11-21 16:18:23 +08:00
morris
b1fdb0db2b refactor(hal_usb): move USB Serial JTAG HAL from hal component 2025-11-21 16:10:17 +08:00
morris
bc064a353a refactor(hal_dma): move bitscrambler from hal component
because bitscrambler can't live without DMA, it's highly binded with the
GDMA peripheral.
2025-11-21 16:10:16 +08:00
Omar Chebib
473dd5c134 ci: re-enable cxx tests_apps and examples for the ESP32-P4 2025-11-21 15:54:41 +08:00
Wang Meng Yang
e48d37f307 Merge branch 'feat/add_param_indicate_create_spp_records' into 'master'
feat(bt): Add an SPP API parameter to indicate whether to create the SPP record

See merge request espressif/esp-idf!43485
2025-11-21 15:47:10 +08:00
Marius Vikhammer
aefab81f37 fix(libc): fixed P4 ECO5 always using sub opt. version of memcpy and similar 2025-11-21 15:45:18 +08:00
Omar Chebib
58e2fc7926 ci: re-enable eh_frame for the ESP32-P4 2025-11-21 15:40:40 +08:00
Konstantin Kondrashov
2b0edd6714 Merge branch 'fix/p4_v3_ipc_isr_example_test' into 'master'
fix(examples): Fix IPC ISR RISC-V test for ESP32-P4 rev3

Closes IDF-14423

See merge request espressif/esp-idf!43555
2025-11-21 15:37:59 +08:00
Armando (Dou Yiwen)
852d56a8f0 Merge branch 'feat/esp_hal_cam' into 'master'
cam:graudate the camera hal driver into a new component

Closes IDF-14277

See merge request espressif/esp-idf!43169
2025-11-21 07:25:03 +00:00
Island
b978710fd1 Merge branch 'feat/support_bhost2025_52' into 'master'
feat(ble/nimble): support runtime allocation for mempool

Closes BLERP-2341

See merge request espressif/esp-idf!42963
2025-11-21 15:24:01 +08:00
Marius Vikhammer
673c27dcf8 Merge branch 'bugfix/stall_wfi' into 'master'
fix(system): fixed p4 eco5 getting stuck when stalling other CPU

See merge request espressif/esp-idf!43577
2025-11-21 15:16:20 +08:00
Zhang Wen Xu
8df5b40dcc Merge branch 'fix/remove_the_duplicate_macro_definition' into 'master'
fix(openthread): remove the duplicate macro definition

See merge request espressif/esp-idf!43540
2025-11-21 07:04:02 +00:00
Fu Hanxi
6c585a0e18 Merge branch 'ci/simplify-ci' into 'master'
Ci/simplify ci

Closes IDFCI-6717

See merge request espressif/esp-idf!43157
2025-11-21 07:34:24 +01:00
C.S.M
fc697158a5 feat(esp32s31): Add efuse and esp_rom support 2025-11-21 11:43:27 +08:00
igor.udot
083200737c ci: pytest-ignore skip using dut id 2025-11-21 11:43:15 +08:00
Island
80454bbc59 Merge branch 'bugfix/bug_ble_max_device_record' into 'master'
fix(ble/bluedroid): Fixed BLE incorrect device record count issue

Closes BLERP-2405

See merge request espressif/esp-idf!43450
2025-11-21 11:37:47 +08:00
Marius Vikhammer
47d9739bb5 Merge branch 'ci/enable_esp_timer_eco5' into 'master'
ci(esp_timer): re-enable ci tests for esp-timer on p4 eco5

See merge request espressif/esp-idf!43575
2025-11-21 11:34:09 +08:00
Island
e7e5a82a02 Merge branch 'bugfix/fix_ble_no_conn_and_disconn_evt' into 'master'
fix(ble/bluedroid): Fixed missing BLE connect and disconnect events

Closes BLERP-2340

See merge request espressif/esp-idf!42962
2025-11-21 11:25:03 +08:00
Mahavir Jain
70be8e404d Merge branch 'bugfix/protocomm_sec1_validation' into 'master'
fix(protocomm): add validation for Security1 client verifier data

See merge request espressif/esp-idf!43545
2025-11-21 08:49:29 +05:30
Mahavir Jain
130fdc7ce7 Merge branch 'fix/fix_bootloader_skip_validate_in_deep_sleep' into 'master'
fix(bootloader): fix signature verification skip in deep sleep scenarios

Closes IDFGH-14871

See merge request espressif/esp-idf!43067
2025-11-21 08:49:12 +05:30
armando
66da426c83 feat(hal):graudate the camera hal driver into a new component 2025-11-21 10:51:28 +08:00
Marius Vikhammer
461c0d8f65 Merge branch 'bugfix/p4_zcmp_fix' into 'master'
fix(interrupts): fixed interrupted related issues due to ZCMP on P4 ECO5

See merge request espressif/esp-idf!43523
2025-11-21 10:46:35 +08:00
Marius Vikhammer
32ebe139c4 fix(system): fixed p4 eco5 getting stuck when stalling other CPU 2025-11-21 10:12:40 +08:00
Marius Vikhammer
9a32500f74 ci(esp_timer): re-enable ci tests for esp-timer on p4 eco5 2025-11-21 09:47:40 +08:00
Marius Vikhammer
257ee931cd Merge branch 'bugfix/p4_eco5_init_arrays' into 'master'
fix(system): fixed constructors not working properly on P4 ECO5

Closes IDF-14425

See merge request espressif/esp-idf!43547
2025-11-21 09:42:26 +08:00
Marius Vikhammer
9632e67efd Merge branch 'bugfix/ulp_p4_eco5_fixes' into 'master'
fix(lp-core): fixed rtc mem conflict on p4 eco5 between app and ULP

Closes IDF-14422

See merge request espressif/esp-idf!43544
2025-11-21 09:40:45 +08:00
Marius Vikhammer
963bc0fa5e Merge branch 'bugfix/p4_eco_5_rom_tests' into 'master'
fix(rom): fixed systimer hal implementation from ROM always being used on P4

Closes IDF-14417 and IDF-14420

See merge request espressif/esp-idf!43538
2025-11-21 09:21:53 +08:00
Roland Dobai
69a5c7384f Merge branch 'change/add-support-for-kconfig-report' into 'master'
Change/add support for kconfig report

Closes IDF-11816

See merge request espressif/esp-idf!37165
2025-11-20 23:30:54 +01:00
Mahavir Jain
0da64692c4 Merge branch 'update/update_certs_bundle' into 'master'
Update esp_crt_bundle certificates

See merge request espressif/esp-idf!43500
2025-11-20 21:54:26 +05:30
Lu Wei Ke
7c4e2d0aa2 Merge branch 'docs/update_bt_common_homepage' into 'master'
docs: Add intro and brief descriptions to Bluetooth Common API home page

Closes DOC-11910

See merge request espressif/esp-idf!42582
2025-11-21 00:20:14 +08:00
Lu Wei Ke
c69210ef09 Merge branch 'docs/update_bt_classic_homepage' into 'master'
docs: Add intro and profile summaries to Bluetooth Classic API home page

Closes DOC-11911

See merge request espressif/esp-idf!42612
2025-11-21 00:13:19 +08:00
Roland Dobai
cbfda195a8 Merge branch 'feat/update_ccache_to_4.12.1' into 'master'
feat(tools): Updated ccache 4.11.2 -> 4.12.1

Closes IDFGH-16658

See merge request espressif/esp-idf!43521
2025-11-20 13:41:44 +01:00
Tomas Rezucha
da7d0e6979 fix(usb): Fix USB PHY mocking on linux target 2025-11-20 12:44:11 +01:00
luweike
ac4cd16cdf docs: Add intro and brief descriptions to Bluetooth Common API home page 2025-11-20 18:56:15 +08:00
luweike
83a26231a6 docs: Add intro and profile summaries to Bluetooth Classic API home page 2025-11-20 18:53:46 +08:00
Konstantin Kondrashov
da720ce74c fix(examples): Fix IPC ISR RISC-V test for ESP32-P4 rev3
Remove checks for MSTATUS and MCAUSE values that
may vary in different chip revisions.
2025-11-20 12:38:30 +02:00
Erhan Kurubas
083999290e fix(espcoredump): prevent double exception during int_wdt panic with custom stack 2025-11-20 11:14:42 +01:00
Marius Vikhammer
641420c5e0 fix(system): fixed constructors not working properly on P4 ECO5 2025-11-20 17:37:48 +08:00
Ondrej Kosta
1e6f49d178 Merge branch 'chore/update-protocol-eth-connect' into 'master'
feat(protocol_examples_common): Use Ethernet Init component

Closes IDF-14227

See merge request espressif/esp-idf!42265
2025-11-20 17:28:17 +08:00
morris
8799b8bc72 Merge branch 'contrib/github_pr_17803' into 'master'
Fixes for reference pages (GitHub PR)

Closes IDFGH-16714

See merge request espressif/esp-idf!43085
2025-11-20 17:27:44 +08:00
Marius Vikhammer
0961294484 fix(interrupts): fixed interrupted related issues due to ZCMP on P4 ECO5 2025-11-20 17:07:45 +08:00
Marius Vikhammer
cd0e6ec2ca fix(lp-core): fixed rtc mem conflict on p4 eco5 between app and ULP 2025-11-20 17:03:23 +08:00
Mahavir Jain
9c6f6c7470 fix(protocomm): add validation for Security1 client verifier data
Add checks to validate client_verify_data pointer and length before
processing in handle_session_command1. Prevents NULL pointer dereference
when client omits verifier data in Session_Command1, which could cause
device crash during provisioning (remote DoS attack).
2025-11-20 14:22:40 +05:30
C.S.M
3f7a004cee Merge branch 'feat/update_esp32s31_socs_3' into 'master'
feat(esp32s31): Add soc register from t~z and manually headers

See merge request espressif/esp-idf!43511
2025-11-20 16:46:40 +08:00
Fu Hanxi
accfcc96f4 ci: move host test unittest jobs to pytest 2025-11-20 09:07:22 +01:00
Fu Hanxi
8e130d4cd6 Merge branch 'ci/macos-timeout' into 'master'
ci: set macos timeout

See merge request espressif/esp-idf!43515
2025-11-20 08:56:44 +01:00
Xu Si Yu
330c174117 fix(openthread): remove the duplicate macro definition 2025-11-20 15:51:39 +08:00
Marius Vikhammer
4ebad0a47d fix(rom): fixed systimer hal implementation from ROM always being used on P4 2025-11-20 15:36:26 +08:00
morris
c48a08803f Merge branch 'feat/dedic_gpio_esp32h4' into 'master'
feat(gpio): support fast gpio driver on esp32h4

Closes IDF-12401 and IDF-12391

See merge request espressif/esp-idf!43472
2025-11-20 15:24:28 +08:00
Xiao Xufeng
762fceb5f8 feat(hw_support): add config version for c61 v1.1 2025-11-20 14:41:41 +08:00
Xiao Xufeng
419c2ddfcf feat(hw_support): add config version for c5 v1.2 2025-11-20 14:41:41 +08:00
Island
6dbd7b4183 Merge branch 'feat/ble_log_compression_modularized' into 'master'
refactor(ble): modularize compressed log scripts for better maintainability

Closes BLERP-2400, BLERP-2401, and BLERP-2402

See merge request espressif/esp-idf!43473
2025-11-20 14:33:24 +08:00
morris
795f5c6aa3 Merge branch 'fix/touch_bit_swap_esp32' into 'master'
fix(touch): Add missing bit swap to fix channel 8 and 9

See merge request espressif/esp-idf!43268
2025-11-20 14:26:11 +08:00
Mahavir Jain
aef3656efc Merge branch 'fix/https_server_cert_generation_command' into 'master'
fix(https_server): Fixed the server cert generation command

See merge request espressif/esp-idf!43432
2025-11-20 10:29:11 +05:30
Mahavir Jain
32da6e0f03 fix(bootloader): fix signature verification skip in deep sleep scenario
For CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP enabled and exit from
deep sleep case the secure boot signature verification must be skipped
to improve the wakeup performance.

Closes https://github.com/espressif/esp-idf/issues/15590
2025-11-20 10:28:27 +05:30
Kevin (Lao Kaiyao)
5d49a68b0f Merge branch 'refactor/esp_hal_parlio' into 'master'
feat(hal): graudate the parlio hal driver into a new component

Closes IDF-14099

See merge request espressif/esp-idf!43359
2025-11-20 12:41:28 +08:00
Zhang Wen Xu
e50f12974d Merge branch 'fix/ieee802154_energy_detect_result' into 'master'
fix(802.15.4): fixed energy detection result

See merge request espressif/esp-idf!43242
2025-11-20 04:26:35 +00:00
C.S.M
958a4bffc8 feat(esp32s31): Add soc register from t~z and manually headers 2025-11-20 11:58:03 +08:00
He Binglin
0b9dce89f4 Merge branch 'bugfix/esp_idf_h2_flash_cs_hold' into 'master'
fix(esp_hw_support): fix flash cs unhold during sleep when pd top in esp32h2

Closes IDF-7359

See merge request espressif/esp-idf!43509
2025-11-20 10:44:44 +08:00
Jiang Jiang Jian
5b04e26ebc Merge branch 'bugfix/esp_idf_h21_static_cpu_retention' into 'master'
fix(esp_hw_support): fix sleep_cpu_static.c compile error

See merge request espressif/esp-idf!43474
2025-11-20 10:33:14 +08:00
Chen Chen
33e56cb115 Merge branch 'fix/ledc_isr_handle' into 'master'
fix(ledc): fix potential null dereference issue & add test case

See merge request espressif/esp-idf!43505
2025-11-20 10:05:22 +08:00
C.S.M
395aa3fe4f Merge branch 'feat/update_esp32s31_socs_2' into 'master'
feat(esp32s31): Add soc register from j~s

See merge request espressif/esp-idf!43489
2025-11-20 00:29:01 +08:00
Vaia Patta
ef4f475a73 docs: fix anonymous flags in various structs
I noticed a few structs where the flags didn't show up correctly in the
docs.
Naming the flag struct makes the individual flags appear properly in the
nested struct.

Merges https://github.com/espressif/esp-idf/pull/17803
Closes https://github.com/espressif/esp-idf/issues/17804
2025-11-19 23:12:17 +08:00
glmfe
f398594982 feat(protocol_examples_common): Use Ethernet Init component
- Refactored protocol_examples_common to use ethernet_init component
2025-11-19 15:58:12 +01:00
Marek Fiala
a279eeac29 feat(tools): Updated ccache 4.11.2 -> 4.12.1
Closes https://github.com/espressif/esp-idf/issues/17756
2025-11-19 15:54:26 +01:00
Marek Fiala
0ce86cbb7b refactor(tools): test_idf_tools.py ruff changes 2025-11-19 15:53:25 +01:00
Frantisek Hrbata
b07432e42c Merge branch 'feat/cmakev2_size_targets' into 'master'
fix(cmakev2): add size report targets

Closes IDF-14184

See merge request espressif/esp-idf!43490
2025-11-19 15:18:08 +01:00
Erhan Kurubas
1a4828cca8 Merge branch 'update_jtag_docs' into 'master'
Update jtag docs

Closes OCD-525

See merge request espressif/esp-idf!43210
2025-11-19 13:38:13 +01:00
Martin Vychodil
a6e7046c30 Merge branch 'feat/fatfs_r_0_16' into 'master'
feat(storage/fatfs): Update to FatFS R0.16

Closes IDF-14371

See merge request espressif/esp-idf!42810
2025-11-19 19:47:42 +08:00
Fu Hanxi
9603ea6af8 ci: set macos timeout 2025-11-19 11:47:30 +01:00
Frantisek Hrbata
e08aca162a feat(cmakev2/size): add idf_create_size_report function
The idf_create_size_report function allows for the creation of size
report targets based on the generated link map file. The size report
targets are created using the TARGET option name: "<target>",
"<target>-files", and "<target>-components". These size report targets
are added to the idf_default_project with the TARGET set to "size",
resulting in the creation of "size", "size-files", and "size-components"
targets for the default project.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-11-19 11:35:36 +01:00
Frantisek Hrbata
e216eeeebc fix(cmakev2/project): unset global variables in idf_project_init macro
The idf_project_init macro is evaluated within the global variable
scope, and currently, there are a few variables still set. Let's ensure
all variables are properly unset to avoid polluting the global variable
namespace.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-11-19 11:34:03 +01:00
Frantisek Hrbata
bba4446ee0 fix(cmakev2/build): display a warning when the MINIMAL_BUILD property is set
The MINIMAL_BUILD property is not relevant in cmakev2, as only
components explicitly linked through targets are included in the build
by design. Display a warning when this outdated build property is set.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-11-19 11:34:03 +01:00
Frantisek Hrbata
2b35b5b1bb fix(cmakev2/build): fix the generation of the link map file
The link flag for generating the map file is currently added globally to
the link_options. If multiple executables are generated, the link map
file is overwritten by the last created executable. Since cmakev2
supports building multiple executables, the link map file options need
to be set for each executable individually. To address this, add a new
MAPFILE_TARGET option to the idf_build_executable function. When set,
the link map file will be generated by the linker, and a target
specified in the MAPFILE_TARGET option will be created for the map file.

This also splits the idf_project_default macro.  Only the
idf_project_init macro needs be called within the global scope, as it
includes the project_include.cmake files and the cmake version of the
configuration. The remaining functionality of the idf_project_default
macro is implemented in a __project_default helper function to avoid
polluting the global variable space.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-11-19 11:33:57 +01:00
Frantisek Hrbata
e97027214e fix(cmakev2/build): pass binary target to idf_build_generate_metadata
Currently, the `idf_build_generate_metadata` function takes an
executable target as an argument, and the binary name is stored in the
`EXECUTABLE_BINARY` property. This approach is inconvenient because a
single executable might generate multiple binary images, making it
unreliable to store the binary image name in the executable property due
to the N:1 relationship. To address this, pass the binary image target
instead of the executable target to the `idf_build_generate_metadata`
function. This change is facilitated by linking the binary target,
executable target, and library interface targets with the following
properties:

binary:EXECUTABLE_TARGET -> executable:LIBRARY_INTERFACE -> library

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-11-19 11:30:18 +01:00
Frantisek Hrbata
5130b7d228 fix(cmakev2/project): remove temporary workaround for partition and bootloader flash dependencies
With commit b719292b75 ("refactor(build-system): Simplify flash target creation"),
partition table and bootloader components are correctly adding their
dependency on the flash target, so there is no need for this to be done
in the build system. This removes the temporary workaround.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-11-19 11:26:07 +01:00
Fu Hanxi
fa776a7d50 ci: move host test jobs into host-test.yml 2025-11-19 10:54:26 +01:00
Fu Hanxi
18bb5bacca ci: move the retry_failed_jobs to pre_check stage 2025-11-19 10:51:20 +01:00
Fu Hanxi
8ae96e188f ci: cleanup gcc_static_analyzer and .rules:build 2025-11-19 10:50:53 +01:00
Chen Chen
3ae65813ca fix(ledc): fix potential null dereference issue & add test case 2025-11-19 17:31:58 +08:00
Fu Hanxi
2988329deb ci: cleanup build_template_app jobs 2025-11-19 10:29:26 +01:00
Fu Hanxi
04a9e1ba23 ci: cleanup build_clang_test_apps jobs 2025-11-19 10:29:23 +01:00
Fu Hanxi
0f0d97f958 ci: cleanup after_script:build related rules 2025-11-19 10:27:07 +01:00
Fu Hanxi
aa60a836b5 ci: upload build junit files 2025-11-19 10:26:56 +01:00
Fu Hanxi
5304e95ac5 ci: remove generate_build_child_pipeline.py 2025-11-19 10:26:53 +01:00
Fu Hanxi
6adb0ea457 ci: remove temp minio variables 2025-11-19 10:23:17 +01:00
Sudeep Mohanty
c7b4804ffa Merge branch 'feat/cmakev2_features_and_test_updates' into 'master'
Enable more cmakev2 CI tests and support dfu, uf2 targets

Closes IDF-14181, IDF-14182, and IDF-14183

See merge request espressif/esp-idf!43460
2025-11-19 10:15:08 +01:00
Xu Si Yu
bc432615f2 feat(openthread): Use PSRAM by default for OpenThread message buffers when PSRAM is enabled 2025-11-19 17:05:50 +08:00
Armando (Dou Yiwen)
47d6c9c227 Merge branch 'fix/fix_sdspi_ci_pytest' into 'master'
sdspi: fixed sdspi pytest check

Closes IDFCI-2620

See merge request espressif/esp-idf!43464
2025-11-19 08:33:41 +00:00
hebinglin
8043966ff0 fix(esp_hw_support): fix flash cs unhold during sleep when pd top in esp32h21 2025-11-19 16:20:38 +08:00
hrushikesh.bhosale
be9ec4c179 fix(https_server): Fixed the server cert generation command
- Added the SAN field in the openssl command, to make it
compatible with modern browsers
2025-11-19 13:33:11 +05:30
Shen Mengjing
15c6cff6eb docs: Edit the CN translation from AI 2025-11-19 15:35:20 +08:00
Fu Hanxi
11ae9be9ea Merge branch 'ci/macos-tart' into 'master'
Ci/macos tart

Closes ITOPS-165

See merge request espressif/esp-idf!43346
2025-11-19 08:26:55 +01:00
Chen Chen
a59110d9cc Merge branch 'fix/isp_typos' into 'master'
fix(isp): fix some typos in isp document

See merge request espressif/esp-idf!43458
2025-11-19 15:22:25 +08:00
Fu Hanxi
8857ea99a1 Merge branch 'chore/size_json_artifact' into 'master'
chore(ci): update artifact pattern for size.json

Closes CII-6

See merge request espressif/esp-idf!43486
2025-11-19 08:08:16 +01:00
laokaiyao
873d90218c refactor(parlio): refactor of the private parlio caps 2025-11-19 14:32:40 +08:00
luoxu
0cf6f50179 refactor(ble): modularize compressed log scripts for better maintainability 2025-11-19 14:21:35 +08:00
laokaiyao
377c4d2f39 feat(hal): graudate the parlio hal driver into a new component 2025-11-19 14:16:02 +08:00
Kevin (Lao Kaiyao)
c94d08b9f2 Merge branch 'reafactor/esp_hal_i2s' into 'master'
feat(hal): graudate the I2S hal driver into a new component

Closes IDF-14078

See merge request espressif/esp-idf!43267
2025-11-19 14:08:20 +08:00
xiongweichao
67efd21f3d feat(bt): Adds an SPP API parameter to indicate whether to create SPP record 2025-11-19 06:06:01 +00:00
C.S.M
33d29b4365 feat(esp32s31): Add soc register from j~s 2025-11-19 11:32:08 +08:00
Chen Chen
70a0fb5b7f Merge branch 'fix/handle_shared_intr' into 'master'
Fix/handle shared intr

Closes IDF-12904

See merge request espressif/esp-idf!43149
2025-11-19 11:05:37 +08:00
C.S.M
929c24d6dd Merge branch 'feat/update_esp32s31_socs' into 'master'
feat(esp32s31): Add esp32s31 soc header files part1 (auto generate from a~i)

See merge request espressif/esp-idf!43471
2025-11-19 10:59:39 +08:00
Wu Zheng Hui
27bb77e77c Merge branch 'feat/support_get_pm_lock_aquired_counts' into 'master'
feat(esp_pm): add APIs to get PM lock statistics

Closes IDFGH-16676

See merge request espressif/esp-idf!43002
2025-11-19 10:52:40 +08:00
Wang Meng Yang
f5d1a87f1e Merge branch 'bugfix/refactor_c3_hci_example' into 'master'
refactor(example/bt): Refactor controller_hci_uart example for ESP32-C3/S3 to use UHCI driver

Closes IDF-14345

See merge request espressif/esp-idf!43270
2025-11-19 10:20:16 +08:00
Jan Procházka
110591ab6e fix(touch): Add missing bit swap to fix channel 8 and 9 2025-11-19 10:10:50 +08:00
Espressif BOT
96eb7ae213 change(mbedtls/crt_bundle): Update esp_crt_bundle certificates 2025-11-19 10:00:39 +08:00
Mahavir Jain
4f7e2a3597 Merge branch 'contrib/github_pr_17894' into 'master'
docs: fix typos in some files (GitHub PR)

Closes IDFGH-16818

See merge request espressif/esp-idf!43463
2025-11-19 00:09:09 +05:30
Fu Hanxi
0922674c04 ci: run macos with tart runners 2025-11-18 17:02:11 +01:00
Jan Beran
542a4f7d1f ci: move kconfig documentation under tools codeowners 2025-11-18 20:42:38 +08:00
Jan Beran
bf9b9a0259 change(kconfig): add support for configuration report 2025-11-18 20:42:38 +08:00
Alexey Gerenkov
4cf7aebfa0 Merge branch 'extend_freertos_debug_table' into 'master'
change(freertos): add task count and pointer width to OpenOCD debug table

See merge request espressif/esp-idf!43438
2025-11-18 19:21:01 +08:00
morris
3b450469d9 Merge branch 'contrib/github_pr_17858' into 'master'
fix (GitHub PR)

Closes IDFGH-14772

See merge request espressif/esp-idf!43405
2025-11-18 18:51:49 +08:00
Evgeny Torbin
d78c9317be ci: update artifact pattern for size.json 2025-11-18 10:44:40 +01:00
Harshal Patil
b873a82d5b Merge branch 'feat/generic_key_mgr_key_types' into 'master'
Store key_len field in the key_config

See merge request espressif/esp-idf!42692
2025-11-18 15:12:03 +05:30
Sudeep Mohanty
cad80548b1 test(cmakev2): Enable test_build_uf2 for buildv2 CI tests 2025-11-18 15:08:56 +05:30
Sudeep Mohanty
94809d6638 feat(cmakev2): Add uf2 target support for cmakev2
This commit adds support for uf2 targets for cmake2. The following
changes have been made:
- Adds a new tools/cmakev2/uf2.cmake.
- Adds the idf_create_uf2() function to create the uf2 targets. This
  function now takes the executable as an argument thus allowing the uf2
  target to be created per-executable.
- idf_project_default() is updated to create the uf2 targets.
2025-11-18 15:08:53 +05:30
Sudeep Mohanty
a609d5bcd2 test(cmakev2): Enable test_build_dfu for buildv2 CI tests 2025-11-18 15:08:20 +05:30
Sudeep Mohanty
5b0d81bc50 feat(cmakev2): Add dfu target support for cmakev2
This commit adds support for dfu targets for cmake2. The following
changes have been made:
- Adds a new tools/cmakev2/dfu.cmake file on similar lines as the
  tools/cmake/dfu.cmake file.
- Adds the idf_create_dfu() function to create the dfu targets. This
  function now takes the executable as an argument thus allowing the dfu
  target to be created per-executable.
- idf_project_default() is updated to create the dfu target.
2025-11-18 15:08:12 +05:30
Mahavir Jain
7da52654ba Merge branch 'feature/enable_ecc_support_for_esp32h4' into 'master'
feat: enable ecc peripheral support for ESP32H4

Closes IDF-12264

See merge request espressif/esp-idf!41408
2025-11-18 15:03:16 +05:30
Roland Dobai
a295be6658 Merge branch 'feat/ldgen_fast_reflashing' into 'master'
feat(ldgen): initial support for fast reflashing

Closes IDF-14213

See merge request espressif/esp-idf!42780
2025-11-18 10:28:49 +01:00
morris
892611191b feat(gpio): support fast gpio driver on esp32h4 2025-11-18 16:59:27 +08:00
laokaiyao
bab5a7a8ed refactor(i2s): refactor of the private i2s caps 2025-11-18 16:13:14 +08:00
Ondrej Kosta
e3af4267f1 Merge branch 'fix/multicast_filter_test' into 'master'
fix(esp_eth): maked esp_eth_test_l2 more robust

Closes IDFCI-6131

See merge request espressif/esp-idf!43328
2025-11-18 16:04:12 +08:00
C.S.M
961bd0cf78 Merge branch 'feat/introduce_esp32s31' into 'master'
feat(esp32s31): Introduce new target esp32s31

See merge request espressif/esp-idf!43316
2025-11-18 15:55:16 +08:00
laokaiyao
e8f39b4c8d feat(hal): graudate the I2S hal driver into a new component 2025-11-18 15:47:16 +08:00
morris
614221e9d5 Merge branch 'fix/no_function_call_in_min_max' into 'master'
refactor: avoid function calls inside MIN/MAX macros

See merge request espressif/esp-idf!43429
2025-11-18 15:14:48 +08:00
Song Ruo Jing
30e81e35df Merge branch 'bugfix/uart_c5_stuck_in_update' into 'master'
fix(uart): watchdog got triggered due to uart sclk not exist

Closes IDFGH-15851, IDFGH-16685, IDFGH-16687, IDFCI-2846, and TIDF-228846

See merge request espressif/esp-idf!43279
2025-11-18 14:59:58 +08:00
wuzhenghui
a5b5f19101 docs(esp_pm): add PM lock debugging and profiling documentation 2025-11-18 14:59:22 +08:00
hebinglin
91b4ac82c9 fix(esp_hw_support): fix sleep_cpu_static.c compile error 2025-11-18 14:58:48 +08:00
C.S.M
e0d62e664b feat(esp32s31): Add soc registers from a~i 2025-11-18 14:41:25 +08:00
armando
359ada9413 fix(ci): fixed sdspi pytest check 2025-11-18 14:10:22 +08:00
Sudeep Mohanty
f72292b0d7 test(cmakev2): Enable test_rebuild.py for buildv2 CI tests
The test_rebuild_no_changes test verifies that running idf.py build
successively without any file changes results in identical build
artifacts on the second run (i.e., nothing gets rebuilt).

This test was failing in buildv2 because it expected kconfig_menus.json
to be present in build/config/ after a normal build. However, in
cmakev2, kconfig_menus.json is not generated during regular builds.

In cmakev1, kconfig_menus.json was generated globally during every
build alongside other config files (sdkconfig.h, sdkconfig.cmake, etc).

In cmakev2, kconfig_menus.json generation does not happend for
normal builds because it depends on the Kconfig menu hierarchy
and cannot be generated globally. It must be generated per-executable.

Hence, this commit updates the artefacts list for cmakev2 to not expect
the kconfig_menus.json file during a build/re-build action.
2025-11-18 10:12:12 +05:30
Sudeep Mohanty
bf8129433a test(cmakev2): Enabled test_idf_extensions.py for builv2 CI tests 2025-11-18 10:12:12 +05:30
Chen Chen
47f5ac96fb fix(intr_alloc): Fix ISR allocate methods in several drivers 2025-11-18 12:33:03 +08:00
Chen Chen
4467a58fb0 fix(isp): fix some typos in isp document 2025-11-18 12:21:13 +08:00
khanhkhanhlele
22ad2e6c4c Fix typos in some files 2025-11-18 11:17:45 +07:00
Jiang Jiang Jian
2e0748aab9 Merge branch 'bugfix/ftm_terminate_asap' into 'master'
bugfix(wifi): Add the termination dialog token in ASAP FTM

Closes WIFIBUG-1504

See merge request espressif/esp-idf!43404
2025-11-18 11:25:30 +08:00
zhanghaipeng
9bfd9c5340 fix(ble/bluedroid): Fixed BLE incorrect device record count issue 2025-11-18 11:25:22 +08:00
morris
484bc2ff4b Merge branch 'change/psram_200m_as_default' into 'master'
psram: use 200MHz as default on p4

See merge request espressif/esp-idf!43427
2025-11-18 11:02:42 +08:00
Jiang Jiang Jian
504c82ff6a Merge branch 'bugfix/update_wifi_fragment_doc' into 'master'
docs(wifi): update wifi fragment doc

Closes WIFI-7097

See merge request espressif/esp-idf!43044
2025-11-18 10:50:27 +08:00
morris
3875c659d4 Merge branch 'feat/mcpwm_support_h21' into 'master'
feat(mcpwm): support mcpwm on esp32h21

Closes IDF-11601 and IDF-11602

See merge request espressif/esp-idf!43351
2025-11-18 09:36:59 +08:00
Marius Vikhammer
d3ffbccfb8 Merge branch 'ci/ulp_fsm_i_wr_reg' into 'master'
test(ulp): added larger delay in ULP FSM I_WR_REG instruction test

Closes IDFCI-3495 and IDFCI-3334

See merge request espressif/esp-idf!43420
2025-11-18 09:30:25 +08:00
Jiang Jiang Jian
75cb5ad5ff Merge branch 'feat/phy_lib_update_c5eco3_coex' into 'master'
feat(phy): updated phy lib for ESP32-C5 ECO2/ECO3 coex

See merge request espressif/esp-idf!43381
2025-11-17 23:31:50 +08:00
Song Ruo Jing
8955f13944 fix(uart): fix some wdt get triggered due to uart sclk not exist on C5
Interrupt wdt would get triggered on uart_driver_install if uart driver was deleted before
Closes https://github.com/espressif/esp-idf/issues/17779

RTC wdt would get triggered on esp_restart if uart driver was deleted before
2025-11-17 22:29:56 +08:00
morris
aa1fd9c611 refactor: avoid function calls inside MIN/MAX macros 2025-11-17 22:17:54 +08:00
Song Ruo Jing
c16d50dd20 fix(ci): increase memory leak threshold for uart rs485 test app 2025-11-17 21:52:19 +08:00
Song Ruo Jing
335273c53e fix(uart): fix send_size calculation in uart_write_bytes
MIN() macro is only an expansion of a conditional operator.
xRingbufferGetCurFreeSize was called twice in the original code,
which may return different values in two calls, leading to incorrect
send_size calculation and eventually could trigger task watchdog.
2025-11-17 21:52:18 +08:00
Song Ruo Jing
f4703a2629 fix(gpio): oe control by register only take effect when func sel is GPIO 2025-11-17 21:52:18 +08:00
Song Ruo Jing
c4c932ad2b fix(console): UART0 TX pin was not properly disabled
Closes https://github.com/espressif/esp-idf/issues/16764
Closes https://github.com/espressif/esp-idf/issues/17459
2025-11-17 21:52:18 +08:00
Erhan Kurubas
799de719d7 change(freertos): add task count and pointer width to OpenOCD debug table 2025-11-17 14:48:27 +01:00
Island
ce13ec7630 Merge branch 'fix/ble_mesh_cpp_compile_issue' into 'master'
fix(ble_mesh): resolve C++ compilation issue in net.h

Closes BLERP-2398 and BLERP-2399

See merge request espressif/esp-idf!43418
2025-11-17 20:44:44 +08:00
Chen Chen
c6ab28f336 feat(mcpwm): support mcpwm on esp32h21 2025-11-17 19:01:16 +08:00
Armando (Dou Yiwen)
1275fb1f42 Merge branch 'feat/make_p4_rev3_default' into 'master'
p4: make v3 as default

See merge request espressif/esp-idf!43142
2025-11-17 10:10:05 +00:00
morris
a7d2fb7d02 Merge branch 'feat/sdm_esp32h21' into 'master'
Support SDM, GPIO Glitch Filter, Fast GPIO on esp32h21

Closes IDF-11573, IDF-11612, and IDF-11621

See merge request espressif/esp-idf!43324
2025-11-17 17:52:10 +08:00
Akshat Agrawal
6f1618f69d bugfix(wifi): Add the termination dialog token in ASAP FTM
1. Increase the dwell time for Off-chan FTM
2. Perform the Off-Chan FTM in 20Mhz
2025-11-17 15:07:16 +05:30
Kevin (Lao Kaiyao)
f1b979d865 Merge branch 'feature/support_force_eof_workaround_for_parlio_rx' into 'master'
feat(parlio_rx): support to force trigger eof

Closes IDF-14143, IDFCI-2958, IDFCI-6027, IDFCI-2929, and IDFCI-6242

See merge request espressif/esp-idf!43116
2025-11-17 17:28:21 +08:00
yangfeng
43808ef7a9 fix(bt/examples): Fixed test_bt_l2cap not finding ESP_SDP_CREATE_RECORD_COMP_EVT 2025-11-17 16:52:08 +08:00
armando
c3995ad93e change(psram): use 200M as default 2025-11-17 16:25:57 +08:00
Marius Vikhammer
cef2f5a264 Merge branch 'feature/esp_stdio_cmakev2' into 'master'
feat(stdio): updated CMakelists.txt to support cmake v2 build system

Closes IDF-13984

See merge request espressif/esp-idf!43272
2025-11-17 16:20:50 +08:00
Marius Vikhammer
da79b1989f test(ulp): added larger delay in ULP FSM I_WR_REG instruction test
Test is flakey, could possibly be due to the ULP occasionally needing
a bit more time to start up.
2025-11-17 16:03:21 +08:00
chenjianhua
1e89ab704e feat(ble/nimble): support runtime allocation for mempool 2025-11-17 15:26:35 +08:00
harshal.patil
1c1bcf44be feat(esp_security): Support ECDSA-P384 key deployment using Key Manager 2025-11-17 12:34:09 +05:30
harshal.patil
dac0bbfcc2 change(mbedtls): Generalize key source union for the hardware ECDSA context 2025-11-17 12:34:09 +05:30
harshal.patil
1f2cbde525 change(esp_key_mgr): Store key_len field in the key_info
- Update the Key Manager key types to be generic
- Define a new enum to determine the length of the keys
- Refactor the Key Manager driver support generic key types and key lengths
- Also store key deployment mode in the key recovery info
2025-11-17 12:34:09 +05:30
C.S.M
a90c93541c feat(esp32s31): Introduce new target esp32s31 2025-11-17 14:48:55 +08:00
luoxu
e4f514ae10 fix(ble_mesh): add type casting for adv data pointer 2025-11-17 14:44:19 +08:00
luoxu
7ae9d8deb6 fix(ble_mesh): resolve C++ compilation issue in net.h
Closes https://github.com/espressif/esp-idf/issues/17868
2025-11-17 14:34:40 +08:00
Zhou Xiao
5286451f2e feat(phy): ESP32-C5 ECO2/ECO3 coex and ESP32-C6 track reset
* C5 phy_version: 1 107, 8c534c84, Nov 17 2025
* C6 phy_version: 343, b513b46, Nov 14 2025
2025-11-17 14:25:26 +08:00
armando
b25ba4a0c1 ci(p4): disable p4 rev3 invalid tests temporarily 2025-11-17 12:11:39 +08:00
armando
aac218036d refactor(sleep_cpu): suppress infinite loop warnings with compiler diagnostics 2025-11-17 12:11:39 +08:00
armando
a4821ab7f5 ci(p4): re-enable p4 jobs 2025-11-17 12:11:39 +08:00
armando
3847e78f77 change(p4): make v3 as default 2025-11-17 12:11:39 +08:00
Alexey Lapshin
8b1bb83af7 Merge branch 'feature/dynamic_flags_in_toolchain_cmake' into 'master'
feat(build): propagate compiler flags from files to toolchain.cmake

Closes IDF-11323

See merge request espressif/esp-idf!42966
2025-11-17 07:52:41 +04:00
xiongweichao
7daac582ac refactor(example/bt): Remove APIs starting with periph_ 2025-11-17 11:47:43 +08:00
xiongweichao
3618b4732a refactor(example/bt): Refactor controller_hci_uart example for ESP32-C3/S3 to use UHCI driver 2025-11-17 11:47:43 +08:00
Aleksei Apaseev
6b5eaec464 Merge branch 'ci/add-example-count-generation' into 'master'
ci: add example count generation

Closes SRV-19

See merge request espressif/esp-idf!41600
2025-11-17 08:48:19 +08:00
Aleksei Apaseev
fb1fae9627 ci: add generate metrics of the target examples count 2025-11-17 08:28:42 +08:00
Armando (Dou Yiwen)
8f1e7bc4e0 Merge branch 'feat/cache_mem_iram_h4' into 'master'
cache: use icache memroy as diram when single core

See merge request espressif/esp-idf!43352
2025-11-14 18:06:00 +00:00
Mahavir Jain
6f9c5204e9 Merge branch 'contrib/github_pr_17710' into 'master'
fix(nvs_sec_provider): replace abort() when nvs_keys is missing with a warrnig log (GitHub PR)

Closes IDFGH-16597

See merge request espressif/esp-idf!43337
2025-11-14 21:48:29 +05:30
Guilherme Ferreira
4e33677e27 Merge branch 'fix/fix-sniffer-sdcard-build' into 'master'
fix(network): Fix Sniffer Build with SD Card

Closes IDF-13850

See merge request espressif/esp-idf!43300
2025-11-14 23:13:40 +08:00
Alexey Lapshin
233015265d fix(docs): remove note about externalproject_add limitation 2025-11-14 21:04:58 +07:00
Alexey Lapshin
583a9075fa fix(test): fix tests according to the new toolchain flags 2025-11-14 21:04:58 +07:00
Alexey Lapshin
b0388ad4a5 feat(build): add COMPILER_ENABLE_RISCV_ZCMP option
Applicable for chips affected by interrupt issue:
  - ESP32C5
  - ESP32C61
  - ESP32H4

For all other chips that support the ZCMP extension without issues,
it will be enabled unconditionally.
2025-11-14 21:04:58 +07:00
Alexey Lapshin
0c1d917f78 feat(build): propagate compiler flags from files to toolchain.cmake
This change improves build consistency across external projects integrated
through CMake by ensuring that compiler flags defined in configuration files
are passed correctly to the toolchain. It covers the majority of use cases,
as external projects are typically also CMake-based. For projects that use
a custom build system, users will still need to specify the required flags
manually.
2025-11-14 21:04:54 +07:00
wuzhenghui
0ce91afc94 feat(esp_pm): add APIs to get PM lock statistics
Add new APIs to retrieve statistics about power management locks:
- esp_pm_get_lock_stats(): Get statistics for all PM lock types
- esp_pm_get_lock_instance_stats(): Get statistics for a single PM lock instance

Also update the test cases to verify the new functionality and
enable PM profiling in test configuration.

Closes https://github.com/espressif/esp-idf/issues/17770
2025-11-14 20:36:44 +08:00
Shu Chen
0fb25912fc Merge branch 'fix/fix_some_deadlock_issue' into 'master'
fix(openthread): resolve deadlock issues due to switching_lock

See merge request espressif/esp-idf!43357
2025-11-14 12:15:01 +00:00
Jiang Jiang Jian
d6d19da799 Merge branch 'bugfix/add_migration_guides_for_esp_wifi_init' into 'master'
fix(wifi): add migration guides for esp_wifi_init

See merge request espressif/esp-idf!43077
2025-11-14 19:29:00 +08:00
morris
f86febdc87 feat(gpio): add fast gpio && sdm && filter support on esp32h21 2025-11-14 18:34:06 +08:00
morris
5fb55adb74 Merge branch 'feat/etm_esp32h21' into 'master'
feat(etm): support ETM driver on esp32h21

Closes IDF-11576, IDF-11577, and IDF-11614

See merge request espressif/esp-idf!43294
2025-11-14 17:00:59 +08:00
Wu Zheng Hui
10baab1cf8 Merge branch 'fix/check_usj_status_before_access' into 'master'
fix(esp_driver_usb_serial_jtag): check USJ accessibility before read/write

Closes PM-400

See merge request espressif/esp-idf!42562
2025-11-14 16:30:40 +08:00
Wu Zheng Hui
728fc6a254 Merge branch 'fix/fix_c6_rtc_periph_depends_on_top' into 'master'
fix(esp_hw_support): add dependency of the TOP domain to the RTC_PERIPH domain for esp32c6

See merge request espressif/esp-idf!43289
2025-11-14 16:28:32 +08:00
morris
5189f9af3c Merge branch 'feat/isp_crop_driver' into 'master'
feat(isp): support Crop driver on p4 rev3

Closes IDF-12216 and IDF-13933

See merge request espressif/esp-idf!42586
2025-11-14 15:53:52 +08:00
Michael (XIAO Xufeng)
167db20ca5 Merge branch 'feat/hw_support_dep_remove_c6' into 'master'
esp_hw_support: Removed unsed priv require

See merge request espressif/esp-idf!43177
2025-11-14 15:19:47 +08:00
Jiang Jiang Jian
eaa0e3ab77 Merge branch 'feat/support_p4_unicore_auto_clock_gating' into 'master'
feat(esp_hw_support): support unicore auto clock gating for esp32p4 rev3+

Closes IDF-13501

See merge request espressif/esp-idf!43321
2025-11-14 13:57:48 +08:00
Krzysztof Lewandowski
7c536b251b fix(nvs_sec_provider): Emit warning when nvs_keys partition is missing
- Instead of returning error (ESP_FAIL), which led to an abort
  in the startup
2025-11-14 10:24:00 +05:30
Mahavir Jain
fd01095f5c Merge branch 'fix/cert_bundle_stress_test_failure' into 'master'
Fix cert bundle stress test

Closes IDFCI-2754

See merge request espressif/esp-idf!43322
2025-11-14 09:40:20 +05:30
Wu Zheng Hui
53183f9294 Merge branch 'fix/fix_xtal32k_power_breaks_adc' into 'master'
fix(esp_system): fix XTAL32K power breaks ADC function on 32k XTAL clock pin

See merge request espressif/esp-idf!43208
2025-11-14 12:06:37 +08:00
Tan Yan Quan
2d022def21 fix(openthread): resolve deadlock issues due to switching_lock
* esp-openthread: thread_zigbee/esp-openthread@068a8f4d2
* openthread: espressif/openthread@36b14d3ef
* esp-idf: espressif/esp-idf@a7e81b99d
2025-11-14 03:18:46 +00:00
Jiang Jiang Jian
a7e81b99dd Merge branch 'bugfix/ftm_recalib_esp32c5' into 'master'
Re-calibrate FTM for ESP32-C5 (ECO2) to resolve status 5 failures

Closes WIFIBUG-1434

See merge request espressif/esp-idf!43254
2025-11-14 11:10:56 +08:00
Chen Ji Chang
2aff980290 Merge branch 'fix/mipi_dsi_phy_clk_type' into 'master'
fix(lcd): fix mipi dsi phy type for p4 version below 3.0

See merge request espressif/esp-idf!43327
2025-11-14 11:06:44 +08:00
morris
6bd8524115 feat(etm): support ETM driver on esp32h21 2025-11-14 10:40:40 +08:00
armando
a28d9869c1 feat(cache): use icache memroy as diram when single core 2025-11-14 10:35:39 +08:00
Chen Ji Chang
e2e0da1a26 Merge branch 'feat/esp_hal_pcnt' into 'master'
feat(hal): graudate the PCNT hal driver into a new component

Closes IDF-14098

See merge request espressif/esp-idf!43138
2025-11-14 10:34:57 +08:00
Jiang Jiang Jian
b7c549d111 Merge branch 'bugfix/fix_espnow_send_fail_when_coex_enable' into 'master'
fix(coex): fixed the espnow send fail when coex enable

Closes WIFIBUG-1538 and WIFIBUG-1436

See merge request espressif/esp-idf!43298
2025-11-14 10:21:50 +08:00
Marius Vikhammer
d209293856 feat(stdio): updated CMakelists.txt to support cmake v2 build system 2025-11-14 10:13:38 +08:00
Frantisek Hrbata
368e55a7bc fix(ldgen): use format specifiers instead of percent format
Resolve ruff's UP031 errors related to the use of percent formatting for
strings.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-11-13 15:30:42 +01:00
Frantisek Hrbata
e65807a901 fix(ldgen): ruff formating changes and copyright update
Changes generated by pre-commit related to ruff-format and an update to
the copyright date.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-11-13 15:30:42 +01:00
Frantisek Hrbata
a034ef8713 feat(build): add initial configuration for fast reflashing
Introduce ESPTOOLPY_FAST_REFLASHING configuration option. It instructs
ldgen to group entity mappings for libraries deemed mutable (prone to
change) separately from those considered immutable (unlikely to change).

Organizing mutable and immutable libraries separately in the linker
script allows the linker to form larger contiguous blocks of data for
immutable libraries in the application's output sections. These blocks
are likely to stay mostly unchanged between application recompilations,
enabling them to be skipped during reflashing.

Separating mutable and immutable libraries in the linker script to
minimize changes in the output sections is insufficient. Padding is
added after the input sections of mutable libraries in the default data
and text output sections. This creates a buffer for the mutable
libraries, allowing additional changes to be made without altering the
layout of the binary image.

Additionally two optimizations currently in use can still mix data from
these libraries, leading to significant changes even within the grouped
immutable libraries.

1. constant merging

    Linker will try to merge input sections that have the MERGE and
    STRING flags from different libraries (object files) to perform
    optimizations like tail merging. For example, adding a string
    literal in a mutable library will also change the addresses of
    string literals from immutable libraries in such a merged section,
    causing changes in the generated code when those literals are
    referenced.

    Disabled with COMPILER_DISABLE_MERGE_CONSTANTS(-fno-merge-constants)

2. literal pools on Xtensa

    As optimization, the linker may merge literal pools from different
    libraries (object files) to improve the generated code size. This
    has the same effect as constant merging, and changes in mutable
    libraries may cause changes in the generated code for immutable
    libraries. To get larger unchanged continuous blocks in the text
    output sections for immutable libraries, we need to ensure that the
    Xtensa literal pools remain close to their references and are not
    merged.

    Disabled with CONFIG_COMPILER_ENABLE_TEXT_SECTION_LITERALS(-mtext-section-literals)

When ESPTOOLPY_FAST_REFLASHING is enabled, these two optimizations are
disabled to achieve larger unchaged continuous blocks for the grouped
immutable libraries, even though disabling these optimizations results
in slightly larger code.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-11-13 15:30:42 +01:00
Frantisek Hrbata
1eceeaace2 feat(build): provide ldgen with a list of mutable libraries
The build system keeps track of each component source. Currently
there are four types of sources:

1. "project_components" - project components
2. "project_extra_components" - components from EXTRA_COMPONENT_DIRS
3. "project_managed_components" - custom project dependencies managed by the IDF Component Manager
4. "idf_components" - ESP-IDF built-in components, typically under /components

This can be used to identify the component libraries that are likely to
change during application development and pass them to ldgen as mutable
libraries. Add all components with "project_components" as their source
as mutable.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-11-13 15:30:42 +01:00
Frantisek Hrbata
8ac9e65f4f feat(ldgen): print entity tree in debug mode
Add the `--debug` option to print the entity tree to stdout. This can be
useful for viewing the entire entity tree state to identify potential
issues or incorrect placements.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-11-13 15:30:42 +01:00
Frantisek Hrbata
3d081f0e23 fix(ldgen/test): ruff formating changes and long lines
Changes generated by pre-commit related to ruff-format and fixed long
lines.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-11-13 15:30:42 +01:00
Frantisek Hrbata
61193678e5 feat(ldgen/test): add test class for mutable libraries
Add basis tests for mutable libraries.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-11-13 15:30:42 +01:00
Frantisek Hrbata
299e172fca feat(ldgen): place input sections from mutable libraries into mutable markers
Introduce a new `--mutable-libraries-file` option that accepts a file
containing the filenames of mutable libraries, each listed on a separate
line. Mutable libraries are component libraries expected to change
during development. In contrast, immutable component libraries are not
expected to change. In the generated linker script, the input sections
of mutable libraries are grouped together rather than being mixed with
those of immutable libraries. The goal is to create large continuous
areas in the ELF file's output sections that remain unchanged for
immutable libraries during application recompilation, allowing these
areas to be skipped during flashing.

The build system identifies the mutable libraries and passes them to
ldgen using the `--mutable-libraries-file` option. It maintains
information about component sources, one of which is
`project_components`. This source type identifies components that are
directly related to the project being developed and are very likely to
change.

Mappings for mutable libraries are explicitly created for all sections
in the default scheme. This happens before the entity
`(archive:object_file:symbol/input_section)` node tree with placements is
generated and is equivalent to having these mappings in the mapping
linker fragment. All placements for mappings, whether newly added or
already existing as defined in linker fragments, associated with mutable
libraries are flagged as `mutable` in the entity node tree. This flag
ensures that these placements are included in the final linker script.
Currently, ldgen only emits placements that are either significant or
forced. A placement is considered significant if, for example, it is not
already covered by a placement in parent node. For instance, `*(.iram1
.iram1.*)` placement already includes `*libapp_trace.a:(.iram1
.iram1.*)`, so the latter is not emitted by default. The `mutable` flag
ensures that placements for mutable libraries are emitted in the linker
script and placed at dedicated location.

The locations where placements for mutable libraries are specified in
the linker script are identified by a new `mutable` marker, for example,
`mutable[flash_text]`. The placements for immutable libraries remain in
the existing `mapping` marker, for example, `mapping[flash_text]`. The
`mutable` marker for each target is placed after the `mapping` marker.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-11-13 15:30:42 +01:00
Frantisek Hrbata
2ade22ff85 feat(esp_system): add mutable markers to sections.ld.in templates
Entity mappings for immutable libraries are placed in the existing
`mapping[target]` marker, while those for mutable libraries are placed
in the new `mutable[target]` marker, which comes after the `mapping`
marker. Additionally, include padding after the input sections of
mutable libraries in the default data and text output sections,
providing a headroom for the mutable libraries to grow.  Padding is
currently not added, for example, in the `.iram0.data` output section,
which is not expected to change frequently. Padding for other mutable
input sections may be added in the future.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-11-13 15:30:36 +01:00
Mahavir Jain
4a53c4e651 Merge branch 'bugfix/esp32c5_encrypted_flash_write_v2' into 'master'
fix(esp_system): limit CPU clock to 160MHz in ESP32-C5 for flash encryption

See merge request espressif/esp-idf!43301
2025-11-13 18:01:04 +05:30
Chen Jichang
b3e48fd001 test(parlio): fix sleep test issue 2025-11-13 19:01:49 +08:00
Island
a365e7984a Merge branch 'feat/ble_mesh_lib_log_output_opt' into 'master'
feat(ble_mesh): add ext log initialization functions

Closes BLERP-2336

See merge request espressif/esp-idf!42926
2025-11-13 18:11:35 +08:00
Laukik Hase
9ee468a096 Merge branch 'feat/tee_c61_examples_and_docs' into 'master'
feat(esp_tee): Enable ESP-TEE examples and documentation for ESP32-C61

Closes IDF-14254 and IDF-14255

See merge request espressif/esp-idf!43251
2025-11-13 15:18:42 +05:30
Jiang Jiang Jian
388ec4cd6d Merge branch 'ci/rename_wifi_two_duts' into 'master'
ci: rename wifi_two_dut to two_duts

See merge request espressif/esp-idf!43269
2025-11-13 16:54:51 +08:00
Akshat Agrawal
342c82fe95 bugfix(wifi): Re-calibrate FTM for ESP32-C5 (ECO2) 2025-11-13 14:24:20 +05:30
Ondrej Kosta
f39c0633d3 fix(esp_eth): maked esp_eth_test_l2 more robust 2025-11-13 09:53:49 +01:00
Jiang Jiang Jian
f7c694ecc3 Merge branch 'ci/fix_wifi_sdkconfig_ci' into 'master'
ci: fix sdkconfig.ci.xxx for wifi examples

See merge request espressif/esp-idf!43293
2025-11-13 16:53:30 +08:00
Chen Jichang
4989cc9266 feat(hal): move i2c_periph.h to hal folder 2025-11-13 16:52:47 +08:00
Chen Jichang
3daafd870f feat(hal): graudate the PCNT hal driver into a new component 2025-11-13 16:52:45 +08:00
Chen Jichang
893b1ea2f1 fix(lcd): fix mipi dsi phy type for p4 version below 3.0 2025-11-13 16:35:07 +08:00
Wang Meng Yang
3c447d998d Merge branch 'bugfix/fix_hid_memory_leak' into 'master'
fix(bt/bluedroid): Fixed HID memory leak

Closes BTQABR2023-602

See merge request espressif/esp-idf!43118
2025-11-13 16:30:47 +08:00
Wang Meng Yang
80961aa3f4 Merge branch 'bugfix/bluetooth_chan_map_error' into 'master'
fix(bt/controller): fixed Bluetooth hardware error of 'CHMAP_ERROR'

See merge request espressif/esp-idf!43201
2025-11-13 15:24:54 +08:00
Guilherme Ferreira
7b8ad5deb1 Merge branch 'refact/split-hal-emac' into 'master'
refactor(hal): graduate emac hal into a new component

Closes IDF-14088

See merge request espressif/esp-idf!43058
2025-11-13 15:12:43 +08:00
harshal.patil
25fe0d6786 test(examples): Fix cert bundle stress test 2025-11-13 12:34:56 +05:30
wuzhenghui
83d91a153d feat(esp_hw_support): support unicore auto clock gating for esp32p4 rev3+ 2025-11-13 14:30:55 +08:00
Jiang Jiang Jian
5004daabca Merge branch 'feat/avoid_disconnect_when_set_bandmode' into 'master'
feat(wifi): avoid disconnect when set band mode and fix some wifi bugs

Closes WIFIBUG-1532

See merge request espressif/esp-idf!43073
2025-11-13 13:46:34 +08:00
Armando (Dou Yiwen)
828aea712e Merge branch 'feat/psram_250m_p4' into 'master'
psram: support 250MHz in experimental

See merge request espressif/esp-idf!32066
2025-11-13 05:05:34 +00:00
Harshal Patil
0debe71b3d Merge branch 'feat/flash_enc_using_key_manager' into 'master'
Support Flash Encryption using Key Manager

Closes IDF-13462 and IDF-14278

See merge request espressif/esp-idf!41879
2025-11-13 07:55:15 +05:30
glmfe
b4d7ede1c3 fix(network): Fix Sniffer Build with SD Card
- Added sdkConfig to cover all available SoC's
 - Defaults to the official devkit with Micro SD Card Available (ESP32 ESP-WROVER-KIT)
2025-11-12 23:05:19 -03:00
Chen Chen
61d363fd58 feat(isp): support Crop driver on p4 rev3
Add support for crop driver on p4eco5 and update example in
`isp/multi_pipelines`
2025-11-13 08:47:11 +08:00
Mahavir Jain
3c5d2e6b58 fix(esp_system): limit CPU clock to 160MHz in ESP32-C5 for flash encryption
Encrypted flash write operation sometimes result in random corruption in
certain bytes. Root cause points to sudden current surge due to involvement of
encryption block overwhelming LDO supply. More details will be provided
in the ESP32-C5 SoC Errata document.

This fix limits the CPU clock to 160MHz for flash encryption enabled
case. Failing encrypted flash write tests could successfully pass in
this configuration. Going ahead, a dynamic clock adjustment in flash
driver will be considered to mitigate this issue.
2025-11-12 19:14:55 +05:30
Jiang Jiang Jian
db1efdec09 Merge branch 'feat/set_pull_mode_of_coex_input_pin' into 'master'
feat(esp_coex): set the pull mode of the external coex input pin

See merge request espressif/esp-idf!43066
2025-11-12 21:08:44 +08:00
muhaidong
bedb741d93 fix(wifi): add migration guides for esp_wifi_init 2025-11-12 19:46:25 +08:00
zhangyanjiao
e255a4e014 fix(coex): fixed the espnow send fail when coex enable 2025-11-12 19:23:34 +08:00
muhaidong
9cbd5c2804 docs(wifi): update wifi fragment doc 2025-11-12 19:15:28 +08:00
Chen Yudong
d784a1e098 ci: fix sdkconfig.ci.xxx for wifi examples 2025-11-12 18:42:38 +08:00
glmfe
9fd020d9da refactor(hal): graduate emac hal into a new component
- Separate emac from hal component to a new one: esp_hal_emac.
2025-11-12 06:55:46 -03:00
Jiang Jiang Jian
a2d9d85a99 Merge branch 'bugfix/fix_wifi_init_issue' into 'master'
fix(wifi): fix wifi init fail issue

Closes IDFGH-12651

See merge request espressif/esp-idf!37876
2025-11-12 17:50:07 +08:00
Island
b1c7498580 Merge branch 'feat/support_bluedroid_host_pawr' into 'master'
feat(ble/bluedroid): Add bluedroid host PAwR and Advertising Coding Selection features

Closes BLERP-1974, BLERP-1975, BLERP-1982, BLERP-2061, and BLERP-2377

See merge request espressif/esp-idf!39128
2025-11-12 17:27:26 +08:00
Erhan Kurubas
9f0d7c2f06 Merge branch 'enable_gcov_tests' into 'master'
test(gcov): re-enable gcov builds and tests

See merge request espressif/esp-idf!43252
2025-11-12 10:12:17 +01:00
Euripedes Rocha
1da98604f9 Merge branch 'removes_esp_mqtt' into 'master'
change(mqtt): Removes the mqtt client from idf

Closes IDF-14118 and DOC-12722

See merge request espressif/esp-idf!40286
2025-11-12 10:10:22 +01:00
wuzhenghui
19e9890fb3 fix(esp_hw_support): add dependency of the TOP domain to the RTC_PERIPH domain for esp32c6 2025-11-12 17:03:45 +08:00
luoxu
a027b8cccb feat(ble_mesh): update mesh lib to a4262f4214 2025-11-12 16:55:56 +08:00
luoxu
7b7b9de28d feat(ble_mesh): add ext log initialization functions 2025-11-12 16:55:56 +08:00
Armando
972a6195f2 feat(psram): support 250MHz in experimental 2025-11-12 16:14:02 +08:00
Tomas Rezucha
a16739a950 Merge branch 'contrib/github_pr_17831' into 'master'
fix(hal): Fix USB PHY selection logic in usb_wrap_ll.h (GitHub PR)

Closes IDFGH-16746

See merge request espressif/esp-idf!43255
2025-11-12 08:54:30 +01:00
Laukik Hase
7a1ab62cf7 docs(esp_tee): Enable ESP-TEE documentation for ESP32-C61 2025-11-12 12:48:27 +05:30
Laukik Hase
b6a51f0ff6 ci(esp_tee): Enable the TEE examples for ESP32-C61 2025-11-12 12:48:26 +05:30
Song Ruo Jing
a2901819b4 Merge branch 'feature/esp32p4_eco5_io_hold' into 'master'
feat(gpio): add IO hold support for Deep-sleep for ESP32-P4 ECO5

Closes IDF-12844 and IDF-13518

See merge request espressif/esp-idf!43147
2025-11-12 15:13:36 +08:00
Mahavir Jain
a037d9613e Merge branch 'bugfix/lwip_stack_in_psram_limitation' into 'master'
fix(lwip): allow task stack from SPIRAM except for ESP32 ECO2 and below

Closes IDFGH-16740

See merge request espressif/esp-idf!43119
2025-11-12 12:41:55 +05:30
yinqingzhao
bb2f7e08f5 feat(wifi): avoid disconnect when set band mode and fix some wifi bugs 2025-11-12 14:32:59 +08:00
Jin Cheng
b607198192 fix(bt/controller): Fixed some controller bugs
- Fixed Bluetooth hardware error of 'CHMAP_ERROR'
- Fixed encryption collision bug
2025-11-12 14:27:16 +08:00
Island
94de317b37 Merge branch 'fix/increase_ble_log_task_stack_size_for_xtensa_chips' into 'master'
fix(ble): increase default ble log stack size for xtensa chips

See merge request espressif/esp-idf!43250
2025-11-12 14:00:53 +08:00
Meet Patel
b11ce34971 Merge branch 'contrib/github_pr_17848' into 'master'
Bump up log_v2's max arg count (GitHub PR)

Closes IDFGH-16764

See merge request espressif/esp-idf!43256
2025-11-12 10:02:34 +05:30
Jeremy Boynes
4dfad2ecc6 fix(esp_lcd): Issue where M5Stack CoreS3 uses GPIO 35 for MISO and LCD D/C
Adopts approach used by M5GFX that enables/diables output during SPI transaction.
2025-11-11 20:23:45 -08:00
laokaiyao
3fa53e16e4 fix(parlio_rx): fixed incorrect dma buffer length calculation 2025-11-12 10:35:22 +08:00
laokaiyao
297093f46b feat(parlio_rx): support to receive data into external ram 2025-11-12 10:35:22 +08:00
laokaiyao
77cae1fc61 feat(parlio_rx): support to force trigger eof 2025-11-12 10:35:22 +08:00
Chen Yudong
d591aaf1ae ci: rename wifi_two_dut to two_duts 2025-11-12 10:05:07 +08:00
Omar Chebib
8e12c7f3ab Merge branch 'fix/task_tracing_crashing' into 'master'
fix(heap): fix a bug where the biggest heap would be NULL on boot

Closes IDFGH-16182 and IDFGH-16183

See merge request espressif/esp-idf!41024
2025-11-12 09:33:32 +08:00
Jiang Jiang Jian
78986757de Merge branch 'bugfix/fix_send_wakenull_off_channel' into 'master'
fix(wifi): fix issue that disarm send wake null timer donot take effect and sta bolck scan timeout

Closes WIFI-7020, WIFIBUG-1523, and WIFIBUG-1379

See merge request espressif/esp-idf!43158
2025-11-12 09:30:22 +08:00
Adam Múdry
1725be256d feat(storage): Add support for SDMMC BDL 2025-11-11 14:59:56 +01:00
zhiweijian
738a684c36 fix(ble/bluedroid): Fixed CTE IQ sample data copy error 2025-11-11 20:00:44 +08:00
zhiweijian
a742abdcf5 fix(ble/bluedroid): Optimize some bluedroid code 2025-11-11 20:00:44 +08:00
zhiweijian
38e3f2ad3b fix(ble/bluedroid): Fixed big event status error 2025-11-11 20:00:44 +08:00
zhiweijian
d0f7140057 feat(ble/bluedroid): support bluedroid host channel sounding feature 2025-11-11 20:00:44 +08:00
zhiweijian
cb8b4df798 feat(ble/bluedroid): Supported BLE bluedroid host pawr connection 2025-11-11 20:00:34 +08:00
zhiweijian
865bccedbf feat(ble/bluedroid): Support LE Security Levels Characteristic 2025-11-11 19:58:38 +08:00
zhiweijian
9405c68bed feat(ble/bluedroid): Add bluedroid host Advertising Coding Selection feature 2025-11-11 19:58:26 +08:00
zhiweijian
056e83e3b8 feat(ble/bluedroid): Add bluedroid host PAwR feature 2025-11-11 19:58:14 +08:00
Mahavir Jain
da1ff709ce Merge branch 'fix/axi_dma_ext_mem_alignment_c5' into 'master'
Align AES and SHA buffers to 16 when SPIRAM encryption is enabled

Closes DIG-754 and IDF-14344

See merge request espressif/esp-idf!43004
2025-11-11 17:14:47 +05:30
Mahavir Jain
619cbb85b3 Merge branch 'fix/disallow_enabling_sb_sha384_when_sb_sha256_is_enabled_p4' into 'master'
fix(efuse): Disallow enabling SB using SHA-384 when SB using SHA-256 is enabled (ESP32-P4 ECO5)

Closes IDF-14063

See merge request espressif/esp-idf!42884
2025-11-11 17:11:47 +05:30
Radek Tandler
1611f123a7 Merge branch 'storage/fix_spi_flash_verify_write' into 'master'
Fix spi flash verify write of blocks shorter than 4 bytes

Closes IDF-14288

See merge request espressif/esp-idf!42614
2025-11-11 12:27:43 +01:00
sibeibei
4e2f33d445 fix(wifi): fix issue that disarm send wake null timer donot take effect 2025-11-11 17:29:38 +08:00
Erhan Kurubas
5947a29c51 test(gcov): re-enable gcov builds and tests 2025-11-11 10:23:29 +01:00
Zhou Xiao
3e0d005987 fix(ble): increase default ble log stack size for xtensa chips 2025-11-11 17:07:42 +08:00
Song Ruo Jing
7008558fe5 fix(clk): 400MHz CPU should still be selectable on ESP32-P4 less than rev3 2025-11-11 17:03:25 +08:00
Song Ruo Jing
c17644a400 feat(gpio): add IO hold support for Deep-sleep for ESP32-P4 ECO5 2025-11-11 17:03:24 +08:00
Tomas Rezucha
8948bf6ba7 Merge branch 'refactor/make_usb_hal_independent' into 'master'
refactor(usb): Make usb hal layer independent

Closes IDF-14092

See merge request espressif/esp-idf!43155
2025-11-11 09:53:45 +01:00
Mahavir Jain
d42cb3b3f7 fix(lwip): allow task stack from SPIRAM except for ESP32 ECO2 and below
Closes https://github.com/espressif/esp-idf/issues/17827
2025-11-11 14:14:22 +05:30
Mahavir Jain
437ddd1a45 Merge branch 'feat/update_mbedtls_3.6.5' into 'master'
feat(mbedtls): update to version 3.6.5

See merge request espressif/esp-idf!42623
2025-11-11 14:09:43 +05:30
Zhang Shuxian
41c3c2d539 docs: Update CN translation 2025-11-11 09:21:37 +01:00
Euripedes Rocha Filho
448714b056 remove(mqtt): Moves esp-mqtt to component manager
esp-mqtt is now a managed component at espressif/mqtt
2025-11-11 09:21:37 +01:00
Wang Meng Yang
b712ec5696 Merge branch 'bugfix/cod_chg_by_scan_ena' into 'master'
fix(bt/bluedroid): update the COD before enabling inquiry scan

Closes BTQABR2023-546

See merge request espressif/esp-idf!41481
2025-11-11 15:45:07 +08:00
Michael (XIAO Xufeng)
39f2a54179 esp_hw_support: Removed unsed priv require 2025-11-11 15:04:43 +08:00
zwx
73f7561e53 fix(802.15.4): fixed energy detection result 2025-11-11 15:01:07 +08:00
harshal.patil
0c3c284819 feat(bootloader_support): Support FE XTS-AES-256 using Key Manager for ESP32-C5 2025-11-11 12:23:27 +05:30
harshal.patil
f73cfa5def fix(hal): Force HUK power up when configuring HUK for ESP32-C5 2025-11-11 12:23:27 +05:30
harshal.patil
38f8b57fe5 feat(flash_encryption): Remove mspi reset when switching the XTS-AES key source 2025-11-11 12:23:27 +05:30
harshal.patil
c9417e418b change(bootloader_support): Rename the esp_flash_encryption_enable_key_mgr() API 2025-11-11 12:23:26 +05:30
harshal.patil
540c719c66 change(esp_key_mgr): Make Key Manager driver bootloader compatible
- Independent of heap
2025-11-11 12:23:26 +05:30
harshal.patil
8abea3c537 feat(bootloader_support): Support Flash Encryption using Key Manager 2025-11-11 12:23:25 +05:30
harshal.patil
304bd1c77b fix(esp_security/esp_key_mgr): Fix missed error codes and some cleanup 2025-11-11 12:22:08 +05:30
Gao Xu
dca6abf984 Merge branch 'fix/adc_c6_get_high_result' into 'master'
fix(adc): fix ESP32C6 ADC get high result after enable

Closes ESPCS-1045

See merge request espressif/esp-idf!42964
2025-11-11 14:13:07 +08:00
Laukik Hase
d2f8a8f86a Merge branch 'feat/esp_tee_c61' into 'master'
feat(esp_tee): Support for ESP32-C61

Closes IDF-14253

See merge request espressif/esp-idf!42054
2025-11-11 11:42:37 +05:30
C.S.M
b642a6229c Merge branch 'fix/i2c_buffer_place' into 'master'
fix(i2c): Add check for buffer place when iram safe enabled

Closes IDFGH-11486

See merge request espressif/esp-idf!43178
2025-11-11 13:34:49 +08:00
nilesh.kale
551fd1b50b feat: enable ecc peripheral support for ESP32H4 2025-11-11 10:52:01 +05:30
Harshal Patil
ed57a94687 Merge branch 'feat/extend_pmp_protection_esp32p4_eco5' into 'master'
Extend PMP memprot for ESP32-P4 V3

Closes IDF-14075

See merge request espressif/esp-idf!42402
2025-11-11 10:07:21 +05:30
Konstantin Kondrashov
8ab409e17e Merge branch 'contrib/github_pr_17648' into 'master'
docs(shared_stack): Fix incorrect or misleading expressions (GitHub PR)

Closes IDFGH-16521 and IDFGH-16500

See merge request espressif/esp-idf!42340
2025-11-11 12:32:14 +08:00
Tinyu
43574a2a92 fix(hal): correct PHY selection logic in usb_wrap_ll.h 2025-11-11 04:24:04 +00:00
Kevin (Lao Kaiyao)
0f4fa41d93 Merge branch 'bugfix/fix_gpio_reservation_issue_in_touch_driver' into 'master'
fix(touch): make the gpio init symmetric

Closes IDFGH-16717

See merge request espressif/esp-idf!43166
2025-11-11 11:59:05 +08:00
Zhang Wen Xu
6bf93681b8 Merge branch 'fix/fix_save_line_in_debug_for_154' into 'master'
fix(802.15.4): fix line save in 154 debug

See merge request espressif/esp-idf!43200
2025-11-11 03:08:10 +00:00
renpeiying
b3f95ab7b0 Update docs acc to review 2025-11-11 10:44:50 +08:00
Island
25ba007105 Merge branch 'feat/support_bhost2025_44' into 'master'
feat(ble/bluedroid): Add more debug log for bluedroid

Closes BLERP-2374

See merge request espressif/esp-idf!43093
2025-11-11 10:39:39 +08:00
laokaiyao
6c29488d9f docs(pm): updated i2s pm lock type in DFS
Related https://github.com/espressif/esp-idf/issues/14707
2025-11-11 10:23:34 +08:00
laokaiyao
3492e8fb48 fix(touch): make the gpio init symmetric
Closes https://github.com/espressif/esp-idf/issues/17806
2025-11-11 10:23:34 +08:00
Ashish Sharma
9fe50060e6 feat(mbedtls): update to version 3.6.5 2025-11-11 10:07:05 +08:00
Guillaume Souchere
518dc8d45b Merge branch 'feat/heap-support-esp32h21' into 'master'
feat(heap): Support heap for esp32h21

Closes IDF-13085

See merge request espressif/esp-idf!42961
2025-11-11 02:55:14 +01:00
Erhan Kurubas
abc6784446 docs(jtag): document program_esp_bins command 2025-11-10 19:51:34 +01:00
Erhan Kurubas
c623b12c8d docs(jtag): replace OpenOCD build instructions with GH workflow reference 2025-11-10 19:51:34 +01:00
Erhan Kurubas
08cf6c1a40 Merge branch 'move_sysview_to_component_registry' into 'master'
Move sysview to component registry

Closes IDF-13403 and DOC-12867

See merge request espressif/esp-idf!43011
2025-11-10 19:19:17 +01:00
Tomas Rezucha
b6db931b0d refactor(usb): Make usb hal layer independent 2025-11-10 17:04:22 +01:00
morris
25d5007f8b Merge branch 'refactor/minimal_build_peripheral_examples' into 'master'
refactor(example): enable minimal build for peripheral examples

Closes IDFGH-16751

See merge request espressif/esp-idf!43192
2025-11-10 22:17:03 +08:00
Guillaume Souchere
7a58d6d8fb fix(heap): Update RTC test to account for esp32h21 characteristics
"RTC memory should be lowest priority and its free size should be big enough"
was failing because the expected size of RTC heap left after init was bigger
than the total RTC size itself.

The test was updated to:
- check that the minimum free RTC heap size matches the current size
- the current RTC heap size is bigger than 80% of the total RTC memory region
2025-11-10 14:43:16 +01:00
Island
1e4520baf2 Merge branch 'feat/ble_mesh_log_enh' into 'master'
feat(ble_mesh): Miscellaneous log enhancement

Closes BLERP-2392

See merge request espressif/esp-idf!41683
2025-11-10 21:20:05 +08:00
luoxu
d0800c044d fix(ble_mesh): resolve miscellaneous logging issues 2025-11-10 20:07:19 +08:00
Rainer
3a431963e6 fix(ble_mesh): fixed issues with incorrect logs format and position 2025-11-10 20:07:19 +08:00
luoxu
ad6aab1396 feat(ble_mesh): Miscellaneous log enhancement for Provisioning 2025-11-10 20:07:19 +08:00
Liu Linyan
1fbf94ae38 feat(ble_mesh): Miscellaneous log enhancement for BLE Mesh 2025-11-10 20:07:19 +08:00
Linyan Liu
6a733ce055 feat(ble_mesh): Miscellaneous update for BLE Mesh 2025-11-10 20:07:19 +08:00
Tomáš Rohlínek
36045c6ca1 feat(storage/fatfs): Make host_test results easier to understand 2025-11-10 12:48:53 +01:00
Tomáš Rohlínek
f781970329 feat(storage/fatfs): Update to FatFS R0.16 2025-11-10 12:42:52 +01:00
Zhang Shuxian
f13c16e031 docs: Update CN translation for NVS statistics example 2025-11-10 12:18:31 +01:00
Martin Havlik
ca16bf9c68 docs(examples/storage): Add docs entries for 2 new NVS examples
Extend the existing mentions of NVS examples with 2 newly added
`nvs_statistics` and `nvs_iteration`.
2025-11-10 12:18:31 +01:00
Martin Havlik
42056cca1d feat(examples/storage): Add NVS iteration example
Add a new example showcasing iterating over NVS entries
of a specific (or any) type, and the info to be obtained from therein.
2025-11-10 12:18:31 +01:00
Martin Havlik
7d756ebd0a feat(examples/storage): Add NVS statistics example
Add a new example showcasing how to obtain and interpret statistics
about the usage of an NVS partition.

Also demonstrates how stats change after writing some key-value pairs
in 2 separate namespaces.
2025-11-10 11:53:04 +01:00
Rahul Tank
1744b070b8 Merge branch 'contrib/github_pr_17824' into 'master'
Fix typos in NimBLE example comments (GitHub PR)

Closes IDFGH-16737

See merge request espressif/esp-idf!43102
2025-11-10 16:09:59 +05:30
wuzhenghui
d815fdbe70 fix(esp_system): fix XTAL32K power breaks ADC function on 32k XTAL clock pin 2025-11-10 17:40:49 +08:00
morris
26dc40594e refactor(example): enable minimal build for peripheral examples
Closes https://github.com/espressif/esp-idf/issues/17836
2025-11-10 17:13:58 +08:00
yangfeng
98864d279f fix(bt/example): Fixed hf_ag build error 2025-11-10 16:59:16 +08:00
chenjianhua
9df842f2c3 fix(bt/bluedroid): Fixed memory debug error 2025-11-10 16:59:16 +08:00
chenjianhua
1aeb965607 feat(ble/bluedroid): Add more debug log for bluedroid 2025-11-10 16:59:16 +08:00
Roland Dobai
c0d6b67938 Merge branch 'fix/github_template_esptool_cmd' into 'master'
fix: Update esptool command in GitHub template to use legacy command for backward compatibility

Closes IDFGH-16670

See merge request espressif/esp-idf!43179
2025-11-10 09:36:18 +01:00
Song Ruo Jing
5b97ebde7e Merge branch 'refactor/gpio_rom_func_rename' into 'master'
refactor(rom/gpio): add 'rom_' prefix to GPIO ROM functions

Closes IDFGH-13174, IDF-9805, and IDF-14209

See merge request espressif/esp-idf!42213
2025-11-10 16:02:54 +08:00
Zhang Shuxian
824d1c7520 docs: Update translation for sysview 2025-11-10 15:58:15 +08:00
Erhan Kurubas
dfd26a79c7 change(examples): disable sysview tests until sysview component is uploaded to registry 2025-11-10 15:55:41 +08:00
Erhan Kurubas
79cda70029 change(app_trace): move sysview to component registry 2025-11-10 15:55:41 +08:00
zhuanghang
4b964d8405 fix(802.15.4): fix line save in 154 debug 2025-11-10 15:28:45 +08:00
Frantisek Hrbata
ee4cd8a4fe Merge branch 'fix/cmake_esp_hal_jpeg' into 'master'
fix(esp_hal_jpeg): initialize the includes variable

See merge request espressif/esp-idf!43176
2025-11-10 08:18:47 +01:00
gaoxu
c2b54dcbe0 fix(adc): fix ESP32C6 ADC get high result after enable 2025-11-10 10:47:52 +08:00
Omar Chebib
0b1aba6579 fix: wrong name in the README file for advanced heap tracing example
Closes https://github.com/espressif/esp-idf/issues/17233
2025-11-10 10:27:48 +08:00
Omar Chebib
3d5023b3a7 fix(heap): fix a bug where the biggest heap would be NULL on boot
Closes https://github.com/espressif/esp-idf/issues/17232
2025-11-10 10:27:48 +08:00
Wang Meng Yang
d02602de17 Merge branch 'bugfix/oob_in_bta_dm_sdp_result' into 'master'
fix(bt/blurdoird): fixed an OOB write in bta_dm_sdp_result

Closes BT-4137

See merge request espressif/esp-idf!42950
2025-11-10 10:01:41 +08:00
Igor Masar
8af4edb0e7 Merge branch 'docs/esp32h4-usb' into 'master'
docs(usb): add ESP32-H4 support notes and pin map

See merge request espressif/esp-idf!42723
2025-11-10 06:34:03 +08:00
nvmd
3a9c3524ae change(esp_log): Bump up log_v2's max arg count 2025-11-09 17:41:54 -03:00
Peter Marcisovsky
bd796b9cc5 Merge branch 'feat/usb_host_pwr_clk_gating_ll' into 'master'
feat(usb_host): Add power and clock gating LL, HAL functions

Closes IDF-14305

See merge request espressif/esp-idf!42762
2025-11-09 04:35:21 +01:00
Peter Dragun
943843b118 fix: Update esptool command in GitHub issue template to use legacy command
Closes https://github.com/espressif/esp-idf/issues/17765
2025-11-07 16:01:38 +01:00
renpeiying
bcef36325b docs: Update CN translation 2025-11-07 12:19:34 +01:00
igor.masar
7492f9b9cd docs(usb): add ESP32-H4 support notes and pin map
- usb_device: add esp32h4 DP/DM defaults (GPIO22/21) and "only:: esp32h4";
  add H4 PHY considerations; add H4 MSC write-speed table; generalize MSC SD
  note to {IDF_TARGET_NAME}; exclude tusb_ncm on H4
- usb_host: include esp32h4 in feature gates; add H4 PHY considerations
- usb_host_notes_dwc_otg: enable H4 by extending "only::" selector
- examples/usb: add ESP32-H4 row to DP/DM pin map
- docs_not_updated: drop H4 entries for usb_device, usb_host, and related
  usb_host notes now covered
- soc(esp32h4): set internal PHY mapping to DP=22, DM=21
2025-11-07 12:19:26 +01:00
Laukik Hase
5b80a58953 ci(esp_tee): Enable the TEE test-apps for ESP32-C61 2025-11-07 14:54:16 +05:30
Laukik Hase
f533502324 feat(esp_tee): Add support for TEE secure storage encryption for ESP32-C61 2025-11-07 14:54:16 +05:30
Laukik Hase
b9a503e9ec feat(esp_tee): Support for ESP32-C61 - the rest of the components 2025-11-07 14:54:16 +05:30
Laukik Hase
bbdd1499f1 feat(esp_tee): Support for ESP32-C61 - the esp_tee component 2025-11-07 14:54:11 +05:30
Narukara
e14dfb8b5a docs(shared_stack): Fix incorrect or misleading expressions
Merges https://github.com/espressif/esp-idf/pull/17648
Closes https://github.com/espressif/esp-idf/issues/17639
2025-11-07 11:17:04 +02:00
C.S.M
e898c7ef39 fix(i2c): Add check for buffer place when iram safe enabled,
Closes https://github.com/espressif/esp-idf/issues/12613
2025-11-07 16:45:38 +08:00
peter.marcisovsky
066318dea9 feat(usb_host): Add power and clock gating LL, HAL
- part of suspend/resume (remote wakeup) sequences
2025-11-07 16:26:02 +08:00
Frantisek Hrbata
3f7844905a fix(esp_hal_jpeg): initialize the includes variable
The cmakev2 build system may evaluate components recursively and all
components has to make sure all their variables are properly
initialized.

Fixes: a7115b6b36 ("refactor(jpeg): Split hal layer for jpeg")
Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-11-07 08:59:59 +01:00
Armando (Dou Yiwen)
c71729610f Merge branch 'feat/isp_shadow_reg' into 'master'
isp: added shadow reg settings

Closes IDF-13937

See merge request espressif/esp-idf!42698
2025-11-07 07:34:21 +00:00
Fu Hanxi
d738849397 Merge branch 'ci/attach_dut_log_url' into 'master'
ci: attach_log_url for multi dut tests

Closes CII-27

See merge request espressif/esp-idf!42899
2025-11-07 08:28:41 +01:00
Song Ruo Jing
56cbd596f5 refactor(gpio): add esp_err_t return type to gpio_uninstall_isr_service
Closes https://github.com/espressif/esp-idf/issues/14114
2025-11-07 15:26:52 +08:00
Song Ruo Jing
266c06354d refactor(gpio): remove some useless macros from io_mux_reg.h 2025-11-07 15:26:52 +08:00
Song Ruo Jing
4b8633cc2b refactor(rom/gpio): add 'rom_' prefix to GPIO ROM functions 2025-11-07 15:26:52 +08:00
Island
286b8cb76d Merge branch 'change/ble_update_lib_20251106' into 'master'
change(ble): [AUTO_MR] 20251106 - Update ESP BLE Controller Lib

Closes BLERP-2379, BLERP-2380, BLERP-2372, and BLERP-2373

See merge request espressif/esp-idf!43154
2025-11-07 14:28:26 +08:00
Konstantin Kondrashov
a8453ffabb Merge branch 'feature/ulp_ticks_and_cycles' into 'master'
feat(ulp): Removes ambiguity between ticks and cycles in ULP APIs

Closes IDFGH-16733

See merge request espressif/esp-idf!43153
2025-11-07 14:21:33 +08:00
Chen Chen
83c315c28d Merge branch 'feat/mcpwm_support_h4' into 'master'
Feat/mcpwm support h4

Closes IDF-12380 and IDF-12381

See merge request espressif/esp-idf!43003
2025-11-07 11:46:03 +08:00
Kevin (Lao Kaiyao)
be3dd5a591 Merge branch 'feature/support_i2s_on_h21' into 'master'
feat(i2s): support i2s on esp32h21

Closes IDF-11606, IDF-11607, and IDF-11608

See merge request espressif/esp-idf!41767
2025-11-07 11:41:45 +08:00
He Binglin
2213716fd5 Merge branch 'feat/esp_idf_lp_uart_wakeup' into 'master'
feat(esp_hw_support): support lp uart wakeup during sleep

Closes PM-533

See merge request espressif/esp-idf!41704
2025-11-07 11:03:08 +08:00
armando
e0b530bd64 feat(isp): added shadow reg settings 2025-11-07 10:49:34 +08:00
morris
6b9427a9f7 Merge branch 'feat/lcd_driver_use_four_cc' into 'master'
refactor(lcd): unify the color conversion API in RGB and DSI driver

Closes IDF-14235

See merge request espressif/esp-idf!43137
2025-11-07 10:37:39 +08:00
Armando (Dou Yiwen)
58e250e0bd Merge branch 'change/isp_wbg_api_change' into 'master'
isp: make wbg API standalone

See merge request espressif/esp-idf!42890
2025-11-07 02:05:13 +00:00
zhaoweiliang
29890c8916 feat(ble): add peripheral fast rx data in latency config on ESP32-C5 2025-11-07 09:59:34 +08:00
zhaoweiliang
0f03da43c8 feat(ble): add peripheral fast rx data in latency config on ESP32-C6 2025-11-07 09:59:31 +08:00
Chen Chen
4a22e36ab4 feat(mcpwm): support mcpwm on esp32h4 2025-11-07 09:28:31 +08:00
Rasmus Buurman
3794bfd96d fix(examples): Fix typos in NimBLE example comments 2025-11-06 20:13:24 +08:00
Laukik Hase
32eb85066e Merge branch 'ci/tee_flash_prot_failures' into 'master'
ci(esp_tee): Remove incorrect error checks for TEE flash protection tests

Closes IDFCI-3299, IDFCI-4947, IDFCI-4092, IDFCI-4093, and IDF-14283

See merge request espressif/esp-idf!43140
2025-11-06 17:14:21 +05:30
Roman Leonov
4be7070aa6 Merge branch 'feature/tusb_hid_remote_wakeup' into 'master'
feat(tusb_hid_example): Added possibility to wakeup the Host with the button press

Closes IDFGH-12837

See merge request espressif/esp-idf!41851
2025-11-06 19:15:32 +08:00
Laukik Hase
fdc86f8f7d Merge branch 'fix/tee_hal_ci_failures' into 'master'
ci(hal/tee): Fix intermittent hang-ups in `PERI_APM` tests on ESP32-C5

Closes IDFCI-3274, IDFCI-4807, and IDFCI-4808

See merge request espressif/esp-idf!42937
2025-11-06 16:39:09 +05:30
Jin Cheng
6ca6f422da fix(bt/blurdoird): fixed an OOB write in bta_dm_sdp_result 2025-11-06 18:57:55 +08:00
cjin
ed6587b132 feat: rename ble sleep related apt on ESP32-C5 2025-11-06 17:32:16 +08:00
cjin
658efa27f0 feat: rename ble sleep related apt on ESP32-H2 2025-11-06 17:31:44 +08:00
cjin
8e1292e1f2 feat: rename ble sleep related apt on ESP32-C6 2025-11-06 17:31:44 +08:00
zhaoweiliang
23a57eee8e change(ble): [AUTO_MR] Update lib_esp32c2 to 27b6e1dc 2025-11-06 17:25:48 +08:00
zhaoweiliang
287052fd95 change(ble): [AUTO_MR] Update lib_esp32c6 to b6027aeb 2025-11-06 17:25:48 +08:00
zhaoweiliang
a54d4fe42b change(ble): [AUTO_MR] Update lib_esp32c5 to b6027aeb 2025-11-06 17:25:48 +08:00
zhaoweiliang
f15085b592 change(ble): [AUTO_MR] Update lib_esp32h2 to b6027aeb 2025-11-06 17:25:48 +08:00
laokaiyao
6bb2a6b66d feat(i2s): support i2s on esp32h21 2025-11-06 17:23:15 +08:00
Konstantin Kondrashov
e7054752ed feat(ulp): Removes ambiguity between ticks and cycles in ULP APIs
Closes https://github.com/espressif/esp-idf/issues/17820
2025-11-06 11:11:11 +02:00
hebinglin
bf38ef3abc feat(esp_hw_support): support lp uart wakeup during sleep 2025-11-06 16:19:57 +08:00
Song Ruo Jing
b9eb99d6d9 Merge branch 'bugfix/s3_uart2_rx_break_on_rst' into 'master'
fix(uart): fix some uart port generate a RX BRK_DET intr on reset issue

See merge request espressif/esp-idf!43064
2025-11-06 16:10:28 +08:00
igor.udot
2ee022ed3d ci: attach_log_url for multi dut tests 2025-11-06 08:55:06 +01:00
morris
f24c115f4b refactor(lcd): unify the color conversion API in RGB and DSI driver
Also adopt the FourCC standard to describe color format.
See also
https://developer.espressif.com/blog/2025/04/esp-fourcc-introduction/
2025-11-06 15:02:26 +08:00
harshal.patil
a6de2c79ed fix(mbedtls/port): Align AES and SHA DMA buffers to 16 when SPIRAM encryption is enabled
- Targets that support GDMA and MSPI encryption module need data and addresses aligned to 16
2025-11-06 12:28:19 +05:30
Laukik Hase
e27e0eb6a7 ci(esp_tee): Remove incorrect error checks for TEE flash protection tests
- Also fixed coverity issue from TEE secure storage
2025-11-06 12:22:36 +05:30
David Čermák
27baa4a261 Merge branch 'fix/ci_netif_deps' into 'master'
[esp-netif]: Improve CI builds of netif tests

See merge request espressif/esp-idf!43136
2025-11-06 14:18:44 +08:00
Island
5e8f251b71 Merge branch 'change/ble_update_lib_20251105' into 'master'
change(ble): [AUTO_MR] 20251105 - Update ESP BLE Controller Lib

Closes BLERP-2367

See merge request espressif/esp-idf!43101
2025-11-06 10:40:15 +08:00
armando
5d1c607174 fix(isp): use atomic fsm check 2025-11-06 02:32:37 +00:00
armando
235d607671 change(isp): make wbg standalone 2025-11-06 02:32:37 +00:00
Fu Hanxi
cc72cf9953 Merge branch 'ci/enable-junit-report-in-mr' into 'master'
ci: enable junit report in MR

See merge request espressif/esp-idf!42925
2025-11-06 03:32:19 +01:00
C.S.M
404cc3e29a Merge branch 'refactor/split_jpeg_hal' into 'master'
refactor(jpeg): Split hal layer for jpeg

Closes IDF-14084

See merge request espressif/esp-idf!43028
2025-11-06 10:29:35 +08:00
Jimmy Wennlund
e2a6653680 feat(esp_event): Allow an event carry more data without malloc
This is both a feature and an optimization.

Feature:
Adjustable size of the internal storage in esp_event queue, currently
used by ISR posting, as they wont be able to make a malloc.

Optimization:
When non-isr is posting an event, use the inernal storage in the struct
instead of always allocating a new heap for the data. Most events in
esp-idf only contains a few bytes event information, and we have that
allocation payed for anyway.

This solved in a big part our memory fragmentation issue, as events
happens freqvently and used to create small memory allocations for just
4 bytes, and then in the event handler we usually allocated a bigger
chunk of heap for our feature. When returning from the event handler,
the 4 byte allocation was freed, leaving a hole in the heap.

Merges: https://github.com/espressif/esp-idf/pull/17797
2025-11-05 17:46:00 +02:00
Song Ruo Jing
d30846578f fix(uart): fix uart_write_bytes gets stuck internally if ring buffer is full
Introduced in c062cd9a95
2025-11-05 22:45:49 +08:00
Song Ruo Jing
8818157e42 fix(uart): fix some uart port generate a RX BRK_DET intr on reset issue
Issue saw on S3 UART2 and some LP_UART ports
2025-11-05 22:45:44 +08:00
Roland Dobai
9a704a51eb Merge branch 'fix/precommit_check_readmes' into 'master'
ci(pre-commit): exclude buildv2_test_app from check-readmes

See merge request espressif/esp-idf!43135
2025-11-05 13:55:22 +01:00
Laukik Hase
905913a8db Merge branch 'ci/esp_tee_c5_enable' into 'master'
ci(esp_tee): Re-enable test-apps and examples for ESP32-C5

Closes IDF-10431, IDFCI-3086, and IDFCI-3097

See merge request espressif/esp-idf!42791
2025-11-05 16:06:04 +05:30
Chen Ji Chang
fc3709f050 Merge branch 'fix/pcnt_example_pytest' into 'master'
test(pcnt): fix pcnt example pytest

Closes IDFCI-3827, IDFCI-3590, and IDFCI-4802

See merge request espressif/esp-idf!43081
2025-11-05 18:23:19 +08:00
David Cermak
4f8aa980be fix(ci): Refine depends pattern for netif test apps 2025-11-05 10:41:24 +01:00
Marius Vikhammer
02ff6e9656 test(netif): fixed protocols test-apps building for unrelated comp. changes 2025-11-05 10:40:39 +01:00
David Cermak
e061dec036 fix(example): Fix mtu example to use minimal build 2025-11-05 10:33:36 +01:00
Frantisek Hrbata
1a9d0ce3f5 ci(pre-commit): exclude buildv2_test_app from check-readmes
The `tools/test_build_system/buildv2_test_app` is a cmakev2 build system
testing application, same as `build_test_app`, which should be removed
from the readme check performed by check_build_test_rules.py.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-11-05 10:21:52 +01:00
Fu Hanxi
a0068b7917 ci: enable junit report in MR 2025-11-05 10:17:14 +01:00
Fu Hanxi
2160ce6c56 ci: remove generate pytest report job
this is a temp workaround, since the current job takes too much time.
should replace it a new implementation
2025-11-05 10:17:14 +01:00
Roland Dobai
d1b91b79b5 Merge branch 'fix/cmakev2_fixes' into 'master'
fix(cmakev2): sync with cmakev1 changes

See merge request espressif/esp-idf!43095
2025-11-05 09:51:30 +01:00
harshal.patil
c66ef46f99 feat(cpu_region_protect): Extend PMP memprot for ESP32-P4 V3 2025-11-05 13:34:47 +05:30
liqigan
fa813a666d fix(bt/bluedroid): Fixed HID memory leak 2025-11-05 15:06:01 +08:00
Kevin (Lao Kaiyao)
70b28a8d8a Merge branch 'fix/fix_i2s_div_zero_coverity_issues' into 'master'
Fix/fix i2s div zero coverity issues

Closes IDF-9839, IDF-12527, IDF-12528, IDF-13108, and IDF-13115

See merge request espressif/esp-idf!43043
2025-11-05 14:53:09 +08:00
Mahavir Jain
79099ee40d Merge branch 'feat/added_force_close_test_for_async_handler' into 'master'
feat(http_server/async_handler): Added test for async handler

Closes IDF-12971

See merge request espressif/esp-idf!43080
2025-11-05 10:27:08 +05:30
Mahavir Jain
4558769ebd Merge branch 'contrib/github_pr_17752' into 'master'
fix: indexing in DNS server IP address retrieval #17751 (GitHub PR)

Closes IDFGH-16654

See merge request espressif/esp-idf!43089
2025-11-05 10:22:38 +05:30
Island
09717c2be6 Merge branch 'feat/support_cble50y25_277' into 'master'
feat(ble): Support controller log compression for ESP32-C3 and ESP32-S3(0871069)

Closes BLERP-2287, BLERP-2288, BLERP-2286, and BLERP-2285

See merge request espressif/esp-idf!42293
2025-11-05 11:27:10 +08:00
Sudeep Mohanty
d96f744e20 Merge branch 'test/freertos_flaky_tests_stabilization' into 'master'
test(freertos): Added miscellaneous stability fixes to unit tests

Closes IDFCI-4361, IDFCI-5963, IDFCI-3577, IDFCI-4619, IDFCI-4932, IDFCI-6043, IDFCI-4849, IDFCI-4804, and IDFCI-4095

See merge request espressif/esp-idf!43027
2025-11-05 04:26:13 +01:00
Zhou Xiao
4ce499148e change(ble): [AUTO_MR] updated rom linker script for ESP32-C2 2025-11-05 11:24:44 +08:00
Zhou Xiao
0be8704ba6 change(ble): [AUTO_MR] Update lib_esp32c2 to eb2959f9 2025-11-05 11:24:43 +08:00
harshal.patil
3090e91e60 fix(esp_security): Set WR_DIS_SECURE_BOOT_SHA384_EN by default when
Flash Encryption Release mode is enabled and Secure Boot P384 scheme not is enabled.
2025-11-05 08:39:55 +05:30
harshal.patil
7168b9f7d3 fix(esp_security): Fix undefined efuse build failure in case of ESP32-P4
- The `wr_dis` efuse bit corresponding to `SECURE_BOOT_SHA384_EN` is absent in P4
2025-11-05 08:39:55 +05:30
harshal.patil
86b52c4f64 change(efuse): Fix the incorrect efuse field name of SECURE_BOOT_EN_SHA384 2025-11-05 08:39:50 +05:30
C.S.M
a7115b6b36 refactor(jpeg): Split hal layer for jpeg 2025-11-05 10:32:41 +08:00
Gao Xu
a359f6fbc9 Merge branch 'feat/p4_eco5_dvp' into 'master'
feat(cam): support esp32p4 eco5 dvp cam

Closes IDF-13929

See merge request espressif/esp-idf!41892
2025-11-05 10:09:46 +08:00
morris
318867b3a2 Merge branch 'refactor/mcpwm_independent_hal' into 'master'
refactor(mcpwm): make mcpwm_hal independent & cleanup soc_caps

Closes IDF-13638 and IDF-14299

See merge request espressif/esp-idf!42886
2025-11-05 09:36:50 +08:00
Armando (Dou Yiwen)
6c8e58b388 Merge branch 'feat/p4_eco5_target_test' into 'master'
esp32p4: temporarily disable target test

Closes CII-17

See merge request espressif/esp-idf!42603
2025-11-05 01:32:16 +00:00
Roman Leonov
dc2013697a feat(tusb_hid_example): Added possibility to wakeup the Host with the button press 2025-11-04 22:17:25 +08:00
Frantisek Hrbata
999cc27599 feat(cmakev2/project): add warning for usage of deprecated variables
The COMPONENTS and EXCLUDE_COMPONENTS variables are unused in cmakev2. A
deprecation warning will be printed if they are set. This change also
includes a helper functions for printing deprecation warnings.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-11-04 14:38:13 +01:00
Island
2104c051d7 Merge branch 'change/ble_update_lib_20251103' into 'master'
change(ble): [AUTO_MR] 20251103 - Update ESP BLE Controller Lib

See merge request espressif/esp-idf!43068
2025-11-04 21:22:55 +08:00
He Binglin
32a9b8a8fe Merge branch 'bugfix/esp_idf_esp32h4_dualcore_crash' into 'master'
fix(esp_hw_support): resolved setting mie to disable interrupts failed in sleep flow

Closes IDF-14279

See merge request espressif/esp-idf!42605
2025-11-04 19:10:08 +08:00
Frantisek Hrbata
de5ad78f6b fix(cmakev2/project): drop prefix_map_gdbinit in favor of gdbinit/prefix_map
The cmakev1 dropped generation of prefix_map_gdbinit, reflect this
change also in cmakev2.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-11-04 12:08:50 +01:00
Frantisek Hrbata
947d78a04e fix(kconfig): distinguish project configuration menu for excluded components
Currently both menu configs, for component's project configuration and
component's configuration, for components not included in the build have
the same name: "Configuration for components not included in the build".
This might be confusing. Let's use "Project configuration for components
not included in the build" for component Kconfig.projbuild files.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-11-04 11:39:19 +01:00
Frantisek Hrbata
37efbf8675 fix(cmakev2/project): bump C and CXX standard
The cmakev1 bumped C and CXX standard to gnu23 and gnu++26, do the same
in cmakev2.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-11-04 11:10:02 +01:00
Frantisek Hrbata
c98146a8c6 fix(cmakev2/compat): add esp_stdio to common requires
The cmakev1 added esp_stdio to common requires, add it in cmakev2 too
for backward compatibility.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-11-04 11:06:02 +01:00
Mahavir Jain
d06c3d9589 fix(ci): address pre-commit hook failure - spellcheck 2025-11-04 15:11:01 +05:30
Ashish Sharma
b768059299 Merge branch 'fix/incorrect_response_status_code_captive_portal' into 'master'
fix(http_server): Fixed response status code for temporary redirect

Closes IDFGH-16702

See merge request espressif/esp-idf!43061
2025-11-04 17:11:59 +08:00
Gao Xu
db3b7575e8 Merge branch 'fix/delete_deprecated_adc_format' into 'master'
fix(adc): removed deprecated continuous format config

See merge request espressif/esp-idf!43079
2025-11-04 17:00:59 +08:00
Chen Jichang
c696401782 test(pcnt): fix pcnt example pytest 2025-11-04 15:16:41 +08:00
hrushikesh.bhosale
940b8df3cc feat(http_server/async_handler): Added test for async handler
Added test for Async Handler example, hits the /long request
and client closes it forcefully before completion
2025-11-04 12:45:18 +05:30
gaoxu
7a933cdc07 fix(adc): removed deprecated continuous format config 2025-11-04 15:11:34 +08:00
Laukik Hase
bcfe915b74 ci(hal/tee): Fix intermittent hang-ups in PERI_APM tests on ESP32-C5 2025-11-04 11:35:52 +05:30
Laukik Hase
3f82eaed0f ci(esp_tee): Enable the TEE examples for ESP32-C5 2025-11-04 11:33:52 +05:30
Laukik Hase
052f380262 ci(esp_tee): Re-enable the TEE test-apps for ESP32-C5 2025-11-04 11:33:51 +05:30
zhaoweiliang
23847f18da change(ble): [AUTO_MR] Update lib_esp32c6 to ebb26a72 2025-11-04 14:03:45 +08:00
zhaoweiliang
d6474da2ac change(ble): [AUTO_MR] Update lib_esp32c5 to ebb26a72 2025-11-04 14:03:45 +08:00
zhaoweiliang
f667bcab5c change(ble): [AUTO_MR] Update lib_esp32h2 to ebb26a72 2025-11-04 14:03:45 +08:00
Kevin (Lao Kaiyao)
ce65a06cc2 Merge branch 'refactor/parlio_rx_use_dma_link' into 'master'
refactor(parlio_rx): use gdma_link for better gdma link management

Closes IDF-13369, IDF-13627, and IDFGH-16449

See merge request espressif/esp-idf!40743
2025-11-04 12:04:45 +08:00
gaoxu
96959a2128 feat(cam): support esp32p4 eco5 dvp cam 2025-11-04 11:46:38 +08:00
Gao Xu
6aaff2a44c Merge branch 'refactor/rng_ll_c2' into 'master'
refactor(rng): refactor to use hal/ll apis for ESP32C2

Closes IDF-12537

See merge request espressif/esp-idf!42887
2025-11-04 11:43:12 +08:00
laokaiyao
ca8996bfac fix(i2s): fixed divide-by-zero coverity issue 2025-11-04 11:35:47 +08:00
Roland Dobai
a0b589c147 Merge branch 'feat/cmakev2' into 'master'
feat(cmakev2): introduce cmake-based build system v2

See merge request espressif/esp-idf!42691
2025-11-04 02:53:36 +01:00
Roland Dobai
a6396a5387 Merge branch 'feature/cmake_presets' into 'master'
feat(tools): add idf.py support for CMake configuration presets

Closes IDF-13090, IDF-9350, and DOC-12674

See merge request espressif/esp-idf!40552
2025-11-03 17:15:46 +01:00
hrushikesh.bhosale
29d1bfb950 fix(http_server): Fixed response status code for temporary redirect
Closes https://github.com/espressif/esp-idf/issues/17791
2025-11-03 19:54:39 +05:30
hebinglin
128e1e7dc2 change(esp_hw_support): use true critical_frame length to check crc 2025-11-03 20:57:58 +08:00
zwx
7d5bcf64fb feat(esp_coex): set the pull mode of the external coex input pin 2025-11-03 19:49:44 +08:00
Sudeep Mohanty
ba9591f753 test(freertos): Added miscellaneous stability fixes to unit tests
This commit adds fixes for freertos unit tests for a more deterministic
run and avoid occational failures.
2025-11-03 17:55:45 +08:00
Zhou Xiao
b525e6555b feat(ble): make ble log task stack size configurable 2025-11-03 17:46:21 +08:00
chenjianhua
b870a8fb5a feat(ble): Enable get bt ts for ESP32-C3 and ESP32-S3 2025-11-03 17:46:21 +08:00
chenjianhua
03758ba550 feat(bt): Update bt lib for ESP32-C3 and ESP32-S3(0871069)
- Added more log for BLE
- Support BLE log filter and simeple output
- Support BLE log compression
2025-11-03 17:46:21 +08:00
Island
9eff48730e Merge branch 'fix/ble_mesh_fixed_incorrect_log' into 'master'
fix(ble_mesh): fixed incorrect log argument

Closes BLERP-808

See merge request espressif/esp-idf!43025
2025-11-03 16:30:49 +08:00
Rahul Tank
3d71614836 Merge branch 'bugfix/fix_compilation_issues' into 'master'
fix(nimble): Address compilation issues in nimble examples

See merge request espressif/esp-idf!42563
2025-11-03 13:57:31 +05:30
Mahavir Jain
8cc741cece Merge branch 'contrib/github_pr_17641' into 'master'
Allow the https server to request client certs only with OPTIONAL (GitHub PR)

Closes IDFGH-16506

See merge request espressif/esp-idf!42393
2025-11-03 13:51:48 +05:30
Mahavir Jain
3d5aa8cad1 Merge branch 'fix/add_bootloader_and_partition_table_as_encrypted_flash_targets' into 'master'
Add Bootloader, Partition Table and ESP-TEE as dependencies for encrypted-flash

See merge request espressif/esp-idf!43022
2025-11-03 09:43:58 +05:30
Mahavir Jain
06805d177c Merge branch 'feature/mbedtls_psa_migration_migrate_esp_http' into 'master'
Migrate esp_http_client and esp_http_server to PSA API

See merge request espressif/esp-idf!41035
2025-11-03 09:39:54 +05:30
Mahavir Jain
de349404a8 Merge branch 'fix/fix_coverity_483744' into 'master'
fix: fix unused value in esp uart driver (coverity 487344)

Closes IDF-13755

See merge request espressif/esp-idf!42908
2025-11-03 09:36:26 +05:30
Ondrej Kosta
2cb9c7177e Merge branch 'fix/bridge_example' into 'master'
fix(examples): fixed bridge example test endnode to host send

Closes IDFCI-2994

See merge request espressif/esp-idf!42928
2025-11-03 11:26:10 +08:00
igor.udot
824c7f7320 ci: extend wildcard support for no_runner_tags 2025-11-03 02:48:04 +00:00
igor.udot
7a411e8a1b ci: extend wildcard support for EXCLUDE_RUNNER_TAGS 2025-11-03 02:48:04 +00:00
armando
2c9c5c66c8 change(ci): temporarily disable p4 target test 2025-11-03 02:48:04 +00:00
Fu Hanxi
5a5d1ae7d9 Merge branch 'ci/improve-tests' into 'master'
tests: change wifi tests expect timeout to 60

See merge request espressif/esp-idf!42888
2025-11-03 03:45:57 +01:00
luoxu
0b20cc4bed fix(ble_mesh): fixed incorrect log argument 2025-11-03 10:41:25 +08:00
morris
0332719183 Merge branch 'refactor/remove_twai_errata_config' into 'master'
refactor(driver_twai): remove twai errata config

Closes IDF-13623 and IDF-13002

See merge request espressif/esp-idf!42850
2025-11-03 10:28:29 +08:00
gaoxu
064cd69661 refactor(rng): refactor to use hal/ll apis for ESP32C2 2025-11-03 10:25:41 +08:00
Chen Chen
d1612b952e refactor(mcpwm): make mcpwm_hal independent & cleanup soc_caps 2025-11-03 09:36:23 +08:00
Shu Chen
08d45b8ef3 Merge branch 'bugfix/fix_thread_ci_testcases_not_stable' into 'master'
feat(openthread): optimize fail cases in CI test

Closes IDFCI-2537, IDFCI-2642, IDFCI-3576, IDFCI-3623, IDFCI-3955, IDFCI-5136, IDFCI-5072, IDFCI-5065, IDFCI-4997, IDFCI-3026, IDFCI-3019, and IDFCI-3020

See merge request espressif/esp-idf!42971
2025-11-03 01:30:16 +00:00
Fu Hanxi
1e79c69fc4 tests: change wifi tests expect timeout to 60
- wifi_router
- wifi_ap
- wifi_high_traffic
2025-11-03 09:19:02 +08:00
harshal.patil
9840685b2d fix(build_system): Add Bootloader and Partition Table as dependencies for encrypted-flash
- If ESP-TEE is enabled, also add it as the dependency for the encrypted-flash target
2025-10-31 14:15:26 +05:30
Island
b50619304e Merge branch 'fix/hci_log_spi_out_ceva' into 'master'
fix(ble): fixed hci event log when link layer logging is disabled

See merge request espressif/esp-idf!42985
2025-10-31 16:06:02 +08:00
yiwenxiu
f58b23ed74 feat(openthread): optimize fail cases in CI test 2025-10-31 14:54:57 +08:00
Chen Ji Chang
7184854500 Merge branch 'feat/switch_h4_ci_build_to_mp' into 'master'
feat(esp32h4): switch default h4 build to mp version

Closes IDF-13771

See merge request espressif/esp-idf!42814
2025-10-31 14:54:41 +08:00
hebinglin
6d51f0ea8b fix(esp_hw_support): resolved setting mie to disable interrupts failed in sleep flow 2025-10-31 14:37:25 +08:00
Mahavir Jain
eda03db6d3 Merge branch 'fix/mmu_psram_anti_fi_target_condition' into 'master'
Fix MMU PSRAM anti-fi MMU target check

See merge request espressif/esp-idf!42940
2025-10-31 09:36:45 +05:30
Mahavir Jain
6f22bedf7c Merge branch 'feature/enable_ecc_const_time_support_for_esp32p4_eco5' into 'master'
feat(hal): add support for ECC constant time function in ESP32-P4 ECO5

Closes IDF-13523

See merge request espressif/esp-idf!42343
2025-10-31 09:23:47 +05:30
Jiang Jiang Jian
dc2b545a16 Merge branch 'bugfix/fix_aid_issue_and_wrong_channel_number_issue' into 'master'
fix(wifi): fix some wifi bugs related bandwidth, twt and regdomain

Closes WIFIBUG-1490

See merge request espressif/esp-idf!42564
2025-10-31 08:55:15 +08:00
morris
604e58c90a Merge branch 'bugfix/fix_gdma_acquire_and_release' into 'master'
fix(gdma): fix the concurrent contention issue of gdma application or release

Closes IDF-13548

See merge request espressif/esp-idf!40501
2025-10-31 08:47:22 +08:00
Erhan Kurubas
b3132d31ed Merge branch 'esp_tracing_component' into 'master'
New Esp tracing component

Closes IDF-13405 and DOC-12721

See merge request espressif/esp-idf!41755
2025-10-30 23:07:49 +01:00
Jiang Jiang Jian
be55a703e8 Merge branch 'fix/p4_rev3_further_fixes' into 'master'
fix(esp_hw_support): p4 rev3 further fixes

See merge request espressif/esp-idf!42939
2025-10-31 05:13:30 +08:00
Shen Meng Jing
310f973583 Merge branch 'docs/sync_en_and_cn_docs' into 'master'
docs: Sync EN and CN docs without 'needs translation' label

Closes DOC-12700

See merge request espressif/esp-idf!42919
2025-10-30 23:01:35 +08:00
Erhan Kurubas
1dac8685db feat(tracing): add new component for tracing 2025-10-30 12:15:35 +01:00
Island
3671a41e35 Merge branch 'fix/ble_mesh_trans_enh_seg_rpl' into 'master'
fix(ble_mesh): fixed incorrect rpl behavior in transport enh

Closes BLERP-2342

See merge request espressif/esp-idf!42974
2025-10-30 19:06:52 +08:00
muhaidong
7b79f8c671 fix(wifi): fix wifi init fail issue
Closes https://github.com/espressif/esp-idf/issues/13643
2025-10-30 17:22:56 +08:00
Frantisek Hrbata
7116d9dc01 feat(toolchain): more remove_duplicated_flags function to separate file
Currently, the toolchain CMake files use the remove_duplicated_flags
function from utilities.cmake. The cmakev2 implementation also includes
this function for backward compatibility. Move the
remove_duplicated_flags function to a separate file,
deduplicate_flags.cmake, so it can be shared between cmakev1 and
cmakev2.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
a5866a2566 ci(codeowners): add tools/cmakev2 into CODEOWNERS
Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
4153910238 ci(pre-commit): revert temporary disable check-kconfig-files
Enable check-kconfig-files. It was temporarily disabled because it was
not possible to add a new sourced file through an environment variable,
as kconfcheck had a fixed list of allowed environment variable names.
This issue should now be resolved.
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
e65fc5ee09 ci(cmakev2): run the buildv2 tests only if the buildv2 label is set
Currently, the buildv2 tests are initiated using the same patterns as
the tests for the current build system. This means that any change in
the current build system will also trigger the buildv2 tests. Initially,
it might be wise not to block the CI for changes in the current build
system in case there is an issue with buildv2. Therefore, let's
explicitly start the buildv2 tests only when the buildv2 label is set.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
67c8d97280 fix(esp_libc/cmake): add vfs as requirement if CONFIG_VFS_SUPPORT_IO is enabled
The esp_libc relies on the stdio implementation of the vfs component if
CONFIG_VFS_SUPPORT_IO is enabled. This is not an issue in cmakev1
because if the vfs component is not included in the project build, its
configuration is not available, and CONFIG_VFS_SUPPORT_IO is not set.
However, in cmakev2, the configuration for all components is available,
and the presence of some component configuration options does not
necessarily mean that the component is included in the project build.
When esp_libc is compiled without the vfs dependency but with
CONFIG_VFS_SUPPORT_IO enabled, the libc initialization will encounter a
panic due to a NULL pointer dereference (fp->_flags) in __swsetup_r, as
fopen in esp_libc_init_global_stdio will return NULL.
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
b8ded7cb65 feat(cmakev2/docs): add note about v2 being technical preview
Although the current documentation exposes only limited functionality,
which is unlikely to change, add an explicit note that the build system
v2 is currently a technical preview intended for testing and early
evaluation.

Ensure consistency in referring to v2 throughout the documentation. In
some places, it is referred to as V2 or Version 2; unify this to v2.

Additionally, update the hello_world example for v2 to use the
idf::spi_flash alias instead of the interface variable to maintain
consistency with the rest of the documentation.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
abdf8af8e5 feat(cmakev2/docs): prefer idf_component_register to create new components
Extend the current documentation to recommend using the
idf_component_register function as the preferred method for creating a
new component for v2.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
997cd81675 feat(cmakev2/compat): add idf_component_register to the API
Using idf_component_register is the preferred method for creating new
components for cmakev2. This approach ensures compatibility with both
versions of the build system. The KCONFIG and KCONFIG_PROJBUILD options
have been removed from the API documentation, but are retained in code
in case a cmakev1 component uses these options to warn about
incompatibility. Also remove a note about `project_include.cmake`,
because cmakev2 includes all project_include files.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
74efd5e386 feat(cmakev2/docs): extend esp_target_info component example
Enhance the `esp_target_info` component example by adding some of
the missing features that the component might require. This includes
adding a linker script, a linker fragment, linking the component archive
as a whole library, and providing an example of how the linker options
can be set.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
94a797872c feat(cmakev2/docs): add information about cmakev2 component incompatibility with cmakev1
Components designed exclusively for cmakev2 are not compatible with
cmakev1 due to the lack of forward compatibility. It is important to
clarify this at the very beginning of the `Creating a New Component`
section. Additionally recommended a guidance on how to create a
component that will be compatible with both versions.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
fc1f995e5e fix(cmakev2/component): set the cmakev2 component archive name
Currently, the archive file name is set only in the cmakev1
idf_component_register shim. The predictable component archive file name
is important, for example, for usage in linker fragments. Ensure that
the cmakev2 component also has the archive file name set.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
a7977d0d14 fix(cmakev2/component): fix setting SOURCES for cmakev2 components
Currently, when the cmakev2 component sources are set, the SRCS target
property is used.  This is obviously wrong because the correct CMake
property is SOURCES.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
2760eca984 feat(cmakev2/build): rename LINKER_SCRIPTS_STATIC to LINKER_SCRIPTS
Rename the LINKER_SCRIPTS_STATIC component property to LINKER_SCRIPTS.
This property stores linker scripts that are not processed by ldgen,
which essentially includes all of them. The only linker script processed
by ldgen is sections.ld, which is handled by the esp_system component.
This implies that there is likely no practical use case for other
components to utilize ldgen processed linker scripts. This change is
purely cosmetic to allow components to add linker scripts with:

idf_component_set_property(${COMPONENT_TARGET} LINKER_SCRIPTS linker_script.ld APPEND)

instead of

idf_component_set_property(${COMPONENT_TARGET} LINKER_SCRIPTS_STATIC linker_script.ld APPEND)

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
87fc989e54 feat(cmakev2/docs): initial basic documentation
Add very basic documentation. It is currently written with the
expectation that the reader is already familiar with the existing build
system and focuses more on the changes that might be necessary to adapt
existing components to work with cmakev2.  Additionally, it provides
basic information on how to create a new component and project.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
229000b186 fix(cmakev2/docs): keep only the very basic functions in API
Currently, we include numerous functions in the automatically generated
documentation for the build system API. Let's begin with only the
essential functions and gradually add more to the API based on requests
and actual needs.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Sudeep Mohanty
e50a9112ee feat(cmakev2): Enable buildv2 tests for windows on CI 2025-10-30 17:17:49 +08:00
Sudeep Mohanty
e744534fca fix(cmakev2): Add workaround in idf_build_component for duplicate managed component
This commit adds a workaround in idf_build_component shim to avoid
initialization of a duplicate managed component. The component manager
when running on a Windows system returns duplicate managed components
upon successive invocations.
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
06ae65cca4 fix(cmakev2/component): fix component library link with whole archive
The current approach involves wrapping the library target within the
library interface target with the whole-archive flags, such as for the
GCC linker. However, this does not work as expected because the library
target is expanded, and the whole-archive flags are also applied to
other library targets that the wrapped library target depends on. IOW
the whole-archive flags surround multiple archives, not just the one
requrested.  Generally, using linker flags like whole-archive in the
library INTERFACE(INTERFACE_LINK_LIBRARIES) does not seem to work as
CMake may perform deduplication and rearrange the flags [1].

The proof of concept used `CMAKE_LINK_LIBRARY_USING_<FEATURE>` with the
WHOLE_ARCHIVE feature, which was introduced in CMake 3.24 to specify how
the library target should be linked. There are two issues with this.
First, this feature is only available from CMake 3.24 onwards, while our
minimum CMake version is set to 3.22. More importantly, all occurrences
of a library on the link line are wrapped.  For example, if a library
like `vfs` appears multiple times on the link line due to dependencies,
each occurrence will be wrapped with whole-archive, causing the linker
to complain about multiple symbol definitions. Therefore, even though
WHOLE_ARCHIVE is recommended for handling whole-archive linkage, it does
not seem suitable for our purposes. This was overlooked in the PoC
because only a simple testing component was used to check the
WHOLE_ARCHIVE behavior.

One way to address this issue is to adopt the same approach used in
cmakev1, which involves specifying the whole-archive flags when linking
component library targets to the final executable. In this case, CMake
retains the flags without any alteration, unlike when the flags are
specified in INTERFACE_LINK_LIBRARIES for the component interface
targets. While this approach is feasible, it would alter the current
logic, where we have a single library interface for the entire idf
library that can be linked to the executable. This change would also
complicate the direct use of the idf library, as it would no longer be
possible to simply link it to the executable. Instead, the executable
would need to correctly link the component libraries with the
whole-archive flags. We could encapsulate this process within the
idf_build_executable function, but projects that only use
idf_build_library would need to implement the same solution.

It appears possible to address this issue by using target_link_options
instead. This allows to specify exactly what should appear on the link
command line. One side effect of this approach is that the library
appears on the link command line multiple times: first when used with
target_link_options and second when used in target_link_libraries.
However, this does not seem to pose a problem. The flags specified with
target_link_options appear on the command line first, ensuring that the
whole-archive is prioritized, and the component archive libraries may be
repeated on the link line anyway due to dependencies. Essentially, the
final link command line is very similar to the one from cmakev1. We may
revisit this approach in the future, but for now, it seems to work as
expected.

[1] https://gitlab.kitware.com/cmake/cmake/-/issues/20078
[2] https://cmake.org/cmake/help/latest/variable/CMAKE_LINK_LIBRARY_USING_FEATURE.html
[3] https://discourse.cmake.org/t/automatically-wrapping-a-static-library-
    in-whole-archive-no-whole-archive-when-used-during-linking/5883

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
6284960254 fix(cmakev2/component): sanitize PATHS argument before calling __get_relative_paths
Currently, when the cmakev1 properties for INCLUDE_DIRS and
PRIV_INCLUDE_DIRS are constructed in the
__set_component_cmakev1_properties function, the return values from the
get_target_property function for INCLUDE_DIRECTORIES and
INTERFACE_INCLUDE_DIRECTORIES properties are not checked. If a component
target does not set e.g. INCLUDE_DIRECTORIES property,
get_target_property will return a value such as `include_dirs-NOTFOUND`.
This value is subsequently passed to __get_relative_paths in the PATHS
argument, causing the file(RELATIVE_PATH) call in __get_relative_paths
to fail with an error.

```
CMake Error at /home/fhrbata/work/esp-idf/tools/cmakev2/utilities.cmake:235 (file):
  file RELATIVE_PATH must be passed a full path to the file:
  include_dirs-NOTFOUND
```

Fix this by explicitly set the PATHS to an empty list before passing it
to the __get_relative_paths function if the property is not set.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Sudeep Mohanty
496ebf0583 feat(cmakev2): Enabled test_cmake.py for cmakev2 in CI 2025-10-30 17:17:49 +08:00
Sudeep Mohanty
f3ffef0075 feat(cmakev2): ruff formatting changes for test_cmake.py 2025-10-30 17:17:49 +08:00
Sudeep Mohanty
577c0117cc feat(cmakev2): Create executable dummy source only if it does not exist
idf_build_executable() creates a dummy source file to create the
executable target. Since this file is created unconditionally everytime
CMake configuration happens, a source file change is registered which
causes CMake to execute other targets even though no other source file
changed.
2025-10-30 17:17:49 +08:00
Sudeep Mohanty
22eb926468 feat(cmakev2): Enabled all component manager tests for cmakev2 2025-10-30 17:17:49 +08:00
Peter Dragun
a66fecf16e fix: Update esptool commands to use new syntax 2025-10-30 17:17:49 +08:00
Frantisek Hrbata
1139551fde fix(test_build_system): disable tests related to outside component dependencies
The commit adb2d5deee ("feat(cmake): Produce warnings when component dependen..")
introduced additional checks for source files and include directories
used by a component that are located outside the component's directory.
If these files and directories belong to another component, a warning is
issued. This feature has not yet been implemented in cmakev2, so related
tests are temporary disabled.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Sudeep Mohanty
84e65e5d24 feat(cmakev2): Enable test_components.py for cmakev2 in CI 2025-10-30 17:17:49 +08:00
Sudeep Mohanty
bb3ce41141 feat(cmakev2): ruff formatting changes for test_components.py 2025-10-30 17:17:49 +08:00
Sudeep Mohanty
7030b25137 feat(cmakev2): Store COMPONENT_OVERRIDEN_DIR property for components 2025-10-30 17:17:49 +08:00
Sudeep Mohanty
0666fb28ea feat(cmakev2): Enabled test_common.py for cmakev2 2025-10-30 17:17:49 +08:00
Sudeep Mohanty
7fe743896d feat(cmakev2): Rename buildv2_test_app source file
This commit renames the buildv2_test_app.c file to build_test_app.c in
the buildv2_test_app template to enable tests to refer to the same
source file name when writing tests for both cmakev1 and cmakev2.
2025-10-30 17:17:49 +08:00
Sudeep Mohanty
c63063f3f6 feat(cmakev2): Enabled test_versions.py for cmakev2 2025-10-30 17:17:49 +08:00
Sudeep Mohanty
f51b79dbe0 feat(cmakev2): ruff formatting changes for test_versions.py 2025-10-30 17:17:49 +08:00
Sudeep Mohanty
3f69493a1e feat(cmakev2): Enable completely passing build tests for cmakev2 in CI
This commit enables the following tests for cmakev2 in CI which do not
need any updates:
- test_bootloader.py
- test_git.py
- test_kconfig.py
- test_partition.py
- test_reproducible_build.py
- test_sdkconfig.py
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
e0525d7e94 feat(cmakev2/component): add __set_component_cmakev1_properties function
In cmakev1, certain arguments provided to the idf_component_register
function are stored as component properties. These properties are used
to generate the project_description.json file, which other tools rely
on. Since the idf_component_register function is obsolete in cmakev2, we
need to recreate component properties such as INCLUDE_DIRS,
PRIV_INCLUDE_DIRS, REQUIRES, and PRIV_REQUIRES, which were previously
provided by the idf_component_register function in cmakev1.  To achieve
this, let's examine the component's real target cmake properties and
reconstruct them to maintain compatibility with cmakev1.

The real target cmake properties may include generator expressions,
which are ignored. This should be acceptable, as they were not addressed
in cmakev1 either, and handling them is likely not feasible.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
ccab0ba626 feat(cmakev2/utilities): add __list_difference function
Return the difference between two lists, meaning the elements that are
present in the first list but not in the second.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
0e9ffe7ea9 feat(cmakev2/utilities): add __list_intersection function
Return the intersection of elements in the two lists.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
e1a697ef3c feat(cmakev2/utilities): add __remove_genex function
This helper function removes entries containing generator expressions
from the given list. The list is modified in place.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
ec9c540926 feat(cmakev2/utilities): add __get_relative_paths function
This is a helper function that returns a list of paths relative to a
given base directory for a list of input paths.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
31ce25ba60 feat(cmakev2/build): preprocess linker scripts with the C preprocessor
When a linker script file with a .in extension is added using the
target_linker_script function, it is processed with the C preprocessor.
The linker scripts are preprocessed only once, even if they are used in
multiple libraries, because they are the same.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
caac44f382 feat(cmakev2/utilities): add __preprocess_linker_script function
Add a helper function to enable C preprocessing of linker script files.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
291cc6898d feat(cmakev2/component): add COMPONENT_BUILD_DIR component property
During the initialization of a component in the __init_component
function, add the COMPONENT_BUILD_DIR property. This can be used to
store component-specific generated files, such as preprocessed linker
scripts.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
2bcea86b83 fix(esp_hal_i2c/cmake): fix the usage of the uninitialized variable
The `includes` list variable is used without initialization. Initialize
it explicitly.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
7ff30604fb fix(cmakev2/compat): newlib renamed to esp_libc
The component has been renamed, update the name in the common
requirements for the cmakev1 components.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
92036ee22f feat(cmakev2/build): introduce component interface cache
The component can be referenced by multiple identifiers such as the
component name, which is derived from the component directory name,
component target, interface, or aliases. All component properties are
attached to the component interface target, which is also used for
declaring component dependencies. The cmakev2 build system has a
function called __get_component_interface, which is responsible for
identifying the component interface based on the given component
identifier. Since this function is called frequently, it needs to be
reasonably fast.

This introduces a new __idf_component_interface_cache INTERFACE target,
which serves as a mapping cache between component identifiers and the
component interface. The cache for each component is initialized in the
__init_component function, which introduces a component to the build
system. Currently, the component interface search is conducted by
examining the COMPONENTS_DISCOVERED and COMPONENT_INTERFACES lists
stored as build properties. Since the build system is aware of most
component identifiers, such as component name, target, and alias, during
component initialization, it can add mappings between component
identifiers and the component interface to a cache, which is built as
the components are initialized. This cache is used in the
__get_component_interface function instead of looking into the
COMPONENTS_DISCOVERED or COMPONENT_INTERFACES lists. This significantly
speeds up the component interface search and also makes the code much
simpler and more readable.

The component interface cache also completely replaces the existing
component name resolution, which was introduced because of the component
manager, and the cache used for resolved component names. This is
possible because all the necessary information is available during
component initialization when the component interface cache is
populated. The ambiguity of components is resolved based on component
source/priority.

Here is an example of the component interface mapping for the
espressif__led_strip component to the idf_espressif__led_strip interface
target. The component name, without the namespace, is referred to as the
short name. In this example, it is led_strip.

- espressif__led_strip -> idf_espressif__led_strip      # name(directory name)
- idf_espressif__led_strip -> idf_espressif__led_strip  # interface
- idf::espressif__led_strip -> idf_espressif__led_strip # alias
- _idf_espressif__led_strip -> idf_espressif__led_strip # real target
- led_strip -> idf_espressif__led_strip                 # short name

When another component with the same espressif__led_strip name is
initialized with a different priority, there is no need to change
anything in the cache, because the mapping stays the same.

The cache must be updated when two components share the same short name
but belong to different namespaces. This situation is likely uncommon.
For instance, consider espressif__led_strip and my__led_strip. If
my__led_strip has a higher priority, the cache is updated to reflect the
short name as follows:

- led_strip -> idf_my__led_strip

If both components have the same priority, the short name mapping for
led_strip is entirely removed. Conversely, if my__led_strip has a lower
priority, no short name mapping is added for it.

The short name is also added to the COMPONENT_SHORT_NAME property of the
component.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
998c8870eb feat(cmakev2/kconfig): add idf_create_confserver function
This is a revised version of the existing __create_confserver_target
function. It creates a specified confserver target for a given
executable. The kconfig_menus.json file, used by the IDEs, is generated
when the confserver starts. This differs from the previous behavior,
where kconfig_menus.json was created globally along with other sdkconfig
formats. The reason for this change is that kconfig_menus.json contains
the Kconfig menu hierarchy and it is not just a flat option-value
format. It needs to accurately reflect which configurations for which
components are included or excluded. The kconfig_menus.json is generated
at `build/kconfig_menus.json`, where IDEs expect it. This means the file
is overwritten every time the server starts by kconfig_menus.json
version for given executable, so only one confserver can run at a time.

This is likely acceptable, as I don't believe it's possible to safely
run multiple instances of confserver due to the potential race
conditions when the sdkconfig file are generated.

In the future, we may include the location of kconfig_menus.json in
project_description.json so it can be easily identified by IDEs for
each executable.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
c5d21936be fix(cmakev2/kconfig): do not automatically generate the kconfig_menus.json file
Currently, when the initial sdkconfig is generated, the
kconfig_menus.json format is also created alongside other formats like
CMake, JSON, or C header. The kconfig_menus.json depends on the Kconfig
hierarchy and cannot be generated globally. It must be generated for
each executable to ensure that included and excluded components are
correctly positioned within the Kconfig menu hierarchy. Remove the
automatic generation of kconfig_menus.json.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
9da953f3a7 fix(cmakev2/kconfig): remove --env-file argument from base kconfgen command
The current base kconfgen command is stored in the __BASE_KCONFGEN_CMD
build property, and it includes the --env-file option pointing to the
`build/config.env` file. The `build/config.env` file does not separate
component configuration files into included and excluded components,
because it is created before any executable is added and we need it for
the initial sdkconfig generation. The global `build/config.env` can be
used for every sdkconfig format (cmake, json, txt), but not for the
kconfig_menus.json format, because kconfig_menus.json relies on the
Kconfig layout and hierarchy. Let's allow specifying the --env-file for
each kconfgen invocation and remove it from the base kconfgen command.
This allows you to specify an --env-file for each executable, each with
its own config.env file.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
21dc3cdac9 fix(cmakev2/kconfig): __run_kconfgen does not take any arguments
The __run_kconfgen function does not take any arguments. The output
formats and related files are stored in the __KCONFGEN_OUTPUTS_CMD build
property.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
e7fad46ea7 feat(cmakev2/kconfig): add idf_create_save_defconfig function
This is basically a renamed version of __create_save_defconfig_target.
The creation of the save-defconfig target is done in
`idf_project_default()`.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
019e8ab9a6 feat(cmakev2/kconfig): add idf_create_menuconfig function
For a specified executable, create a menuconfig target using the name
provided in the TARGET option. The function generates a config.env file
specific to the executable, where Kconfig files for components linked to
the executable and Kconfig files for components not linked to it are
separated. This separation allows for a clear visual distinction between
the configuration of components that are linked and those that are not
linked to the executable within the menuconfig.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
02e6beb695 feat(cmakev2/kconfig): add __create_executable_config_env_file function
Generate the config.env file for the specified executable. The
configuration file will be stored in the build directory, within a
directory named after the executable target name. The kconfigs*.in
files, which are generated by prepare_kconfig_files.py, will also be
stored in this directory.

This function primarily prepares the arguments for the
__create_config_env_file function based on the components linked to the
executable, ensuring that component Kconfig files are stored in the
appropriate kconfigs*.in files, depending on whether the component is
linked to the executable.

The directory where the generated files are stored is added to the
executable CONFIG_ENV_DIR property.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
b88d40ce07 feat(cmakev2/kconfig): allow to specify Kconfig files for __create_config_env_file
The __create_config_env_file function generates a configuration file for
the prepare_kconfig_files.py script. Currently, it specifies the paths
for the kconfigs*.in files, which are generated by
prepare_kconfig_files.py, to be located in the build directory. The
kconfigs*.in files, along with the configuration file, must also be
generated for each executable, as each executable may have a
different set of linked components. Set the paths for the
kconfigs*.in files to be generated by the prepare_kconfig_files.py
script in the same directory as the configuration file.

Also allow explicit specification of which component configuration files
should be placed in different kconfigs*.in files. For sdkconfig
generation, it is not relevant whether a component's Kconfig file is
placed in the kconfigs.in or kconfigs_excluded.in file. This distinction
is only important for visually separating the configuration of included
and excluded components in the menuconfig. For the main sdkconfig, all
component Kconfig files are placed in the kconfigs.in file, and the
generated kconfigs*.in files are stored in the build directory. For
executables, the generated kconfigs*.in files will be stored in separate
directories for each executable.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
1bfda962ef fix(cmakev2/kconfig): do not add excluded Kconfig files in the build properties
The excluded Kconfig files cannot be collected globally, they must be
collected per executable. The distinction between included and excluded
Kconfig files is relevant only for menuconfig, which is specific to each
executable, as each executable may have a different set of linked
components. For the global sdkconfig file and its CMake and JSON
variants, whether the Kconfig files are excluded or not is irrelevant.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
75cf711cc3 fix(test_build_system): use block comment instead of return for cmakev2 test app
Commit 46b41dfec187 ("test(cmakev2): Enable CI tests for component manager ..")
introduced a temporary workaround for the cmakev2 testing
application by including the cmakev1 project.cmake file after the
return() statement. The issue is that some tests, such as
test_build_fail_on_build_time, append commands to the project's
CMakeLists.txt. These commands are placed after the newly added return()
statement, causing them to be ignored and resulting in test failures. To
resolve this, include the cmakev1 project.cmake within the cmake block
comment.

Fixes: 46b41dfec187 ("test(cmakev2): Enable CI tests for component manager ..")
Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
6e643709cc ci(cmakev2): enable test_build.py test for cmakev2
Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
99002a86af feat(test_build_system): enable test_build.py to be executed using cmakev2
Three tests are disabled for cmakev2:
* test_build_dfu
* test_build_uf2
* test_build_loadable_elf

and one is modified:
* test_build_skdconfig_phy_init_data

the other 14 tests should pass.

The tests, test_build_dfu and test_build_uf2, are temporarily disabled
because cmakev2 currently does not include the dfu and uf2 targets.
These tests should be re-enabled once support is added to cmakev2.

The test_build_loadable_elf is disabled because the bootloader_support
component determines its requirements based on the sdkconfig values,
specifically the CONFIG_APP_BUILD_TYPE_RAM used in this test. When
CONFIG_APP_BUILD_TYPE_RAM is set, bootloader_support declares a
dependency on micro-ecc. This is wrong even in cmakev1 and should be
fixed.

The test_build_skdconfig_phy_init_data test requires the esp_phy
component but does not specify it in its requirements. It relies on the
cmakev1 behavior, where all components are included in the build by
default. This approach does not work for cmakev2. To resolve this, make
the dependency on esp_phy explicit, ensuring compatibility with both
versions.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
22689ce62e fix(cmakev2/kconfig): make warnings about misspelled Kconfig names consistent with cmakev1
Currently, the cmakev2 implementation of Kconfig name consistency has a
slightly different warning message compared to cmakev2, causing the test
`test_build.py::test_build_with_misspelled_kconfig` to fail.  Make the
warning messages consistent with cmakev1.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
f28ebc5175 fix(test_build_system): rename Kconfig.projbuild to KConfig.projbuild
The test_build_with_misspelled_kconfig test expects a KConfig.projbuild
file in the main component. However, the file is correctly named
Kconfig.projbuild, which causes the test to fail for cmakev2.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
6594924bbe fix(cmakev2/component): remove EXCLUDE_FROM_ALL when calling add_subdirectory
Currently, cmakev2 evaluates each component using add_subdirectory with
the EXCLUDE_FROM_ALL option. The intention was to exclude all components
from being built by default unless they are explicitly linked to an
executable based on dependencies. This approach aims to avoid building
components that are included but not actually linked to the executable.
However, this has the side effect of preventing components from adding
their custom targets to the "all" target, which is used, for example, by
esp_phy. Generally, we should not restrict components from adding
targets to "all". Since components are only included if explicitly
requested by default, removing the EXCLUDE_FROM_ALL option should be
acceptable.

The downside is that if IDF_INCLUDE_ALL_COMPONENTS is set and the user
runs `idf.py build`, all components will be built, even if they are not
linked to the executable.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
e4fabbca80 fix(cmakev2/idf): target consistency check with sdkconfig
Currently, the check is based on the existence of sdkconfig, but there
may be situations where sdkconfig exists without containing
CONFIG_IDF_TARGET. Perform a target consistency check only if the target
is identified in the main sdkconfig file.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
fc6564f008 fix(cmakev2/utilities): fix typo in __get_sdkconfig_option description
The function name is __get_sdkconfig_option, not __get_config_option.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Sudeep Mohanty
548a4bfbac fix(cmakev2): Add build properties to store resolved component names 2025-10-30 17:17:49 +08:00
Frantisek Hrbata
abddda342f fix(cmakev2/docs): reformat function arguments for API documentation
The function arguments in the documentation comments were using field
list, which caused text overflow in the generated documentation and
generally resulted in poor formatting. Let's use paragraphs for
the argument descriptions instead.

The documentation comments are written in reStructuredText, but
currently, they use inconsistent indentation. Standardize all the
documentation comments to use a four-character indentation.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
17d7507f29 feat(docs): add build system v2 documentation files
Add stump files for the build system v2 documentation with automatic API
generation from CMake files.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
8146123890 feat(docs): load esp_docs_cmakev2_extension
Load the esp_docs_cmakev2_extension to process documentation comments
from CMake files.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
dc846dbe8d feat(cmakev2/docs): add esp_docs_cmakev2_extension sphinx extension
Add a Sphinx extension that introduces a new `cmakev2` domain with
multiple directives, allowing for the automatic extraction of
documentation comments from CMake files and their inclusion in the
Sphinx-generated documentation.

Directives:

- `cmakev2:include`: The included CMake file is processed for
  documentation comments within the `#[[api` and `#]]` marks, which
  should contain valid reStructuredText markup.

- `cmakev2:function`: Creates a CMake function node. All function nodes
  are sorted by name and placed into the `_cmakev2_functions` section.

- `cmakev2:macro`: Creates a CMake macro node. All macro nodes are
  sorted by name and placed into the `_cmakev2_macros` section.

- `cmakev2:variable`: Describes a CMake variable node. All variable
  nodes are sorted by name and placed into the `_cmakev2_variables`
  section.

Each node can be referenced with `` :cmakev2:ref:`<node name>` ``, where
the node name is the function, macro, or variable name as used in the
related directive.

Example:

CMake file:
```
 #[[api
        .. cmakev2:function:: idf_flash_binary
 #]]
```

This function can be referenced with `` :cmakev2:ref:`idf_flash_binary` ``
and will be placed in the `.. _cmakev2_functions:` section.

The extension is currently located in esp-idf, but in the future, we
should consider moving it to esp-docs.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Sudeep Mohanty
0c69d53b68 test(cmakev2): Enable CI tests for component manager for cmakev2
This commit adapts the component manager build tests for cmakev2 and
enables them for CI test runs.
2025-10-30 17:17:49 +08:00
Sudeep Mohanty
1017be951b feat(cmakev2): Allow users to set the dependencies lock file 2025-10-30 17:17:49 +08:00
Sudeep Mohanty
012670a6e0 fix(cmakev2): Build must include component manager output when re-run is expected
The build system should include the file generated by the component
manager after downloading components even if the component manager
requested a re-run due to a missing Kconfig.
2025-10-30 17:17:49 +08:00
Sudeep Mohanty
79eefd1ba9 feat(cmakev2): Reorganise build system initialization
This commit updates the order of initialization for build system v2. All
non-project initializations are handled in idf.cmake and all
project-specific initializations are now moved to idf_project_init().
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
63695ad838 feat(cmakev2/project): add idf_build_generate_flasher_args function
Generate the flasher_args.json file for the global flash target for
tools that require it.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
7e808b34ec feat(cmakev2/test): add binary image generation and flash targets
Generate binary images and add flash targets for hello_world_example and
fatfs_example.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
aacbd1773b fix(cmakev2/build): rename FILE to OUTPUT_FILE option for idf_build_generate_metadata
All other functions, such as idf_build_binary, use OUTPUT_FILE. This is
more descriptive and provides more flexibility to add additional
file-related options in the future if necessary. Make
idf_build_generate_metadata consistent with the other function
interfaces by using OUTPUT_FILE.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
df9010f894 feat(cmakev2/project): add binary genration and flash targets to idf_project_default
Use idf_build_binary, idf_sign_binary, and idf_flash_binary to generate
and flash the default project application.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
b514ed5ae7 feat(cmakev2/build): add idf_check_binary_signed function
Given the binary target generated by the idf_build_binary or
idf_sign_binary function, add a new POST_BUILD dependency that displays
a message indicating the binary image must be manually signed before
flashing. This situation arises when CONFIG_SECURE_SIGNED_APPS is
enabled, but CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES is not set.  As a
result, the binary image is not signed during the build process and
requires manual signing.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
73ee5ee8e2 feat(cmakev2/build): add idf_check_binary_size function
Given the binary target created by the idf_build_binary or
idf_sign_binary function, add a new dependency that verifies whether the
binary image fits within the smallest application partition.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
1dbdeb6bb1 feat(cmakev2/build): add idf_flash_binary function
Create a new flash target for a previously created binary target using
the idf_build_binary or idf_sign_binary function. Specify the new target
name with the TARGET option. The binary image path is stored in the
BINARY_PATH property of the binary target and is set when the binary
target is created using the idf_build_binary or idf_sign_binary
function. Use the NAME option as a prefix for the generated esptool
argument file, and the FLASH option can be used to include the binary
image flashing in the global flash target.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
db2770b281 feat(cmakev2/build): add idf_sign_binary function
Create a signed binary image from a previously generated binary using
the `idf_build_binary` function. This image can be signed with an
optional key from a KEYFILE or, by default, with the key specified in
the sdkconfig. A new custom command is added to generate the signed
binary, which is stored at the location specified by the OUTPUT_FILE
option and a new custom target is created for it, with the name provided
in the TARGET option. The BINARY_PATH property is added to this new
TARGET, containing the path to the signed binary image.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
646c16f4f2 feat(cmakev2/build): add idf_build_binary function
The `idf_build_binary` function generates a binary image for a specified
executable target, which may or may not have been created using the
`idf_build_executable` function. It adds a custom command to generate
the binary image file at the location specified by the `OUTPUT_FILE`
option and creates a new target for it, with the name specified by the
`TARGET` option. The path of the generated binary file is also stored in
the `BINARY_PATH` property of the newly created binary target.
Additionally, this binary path is stored in the `EXECUTABLE_BINARY`
property of the given executable. This information is used by the
`idf_build_generate_metadata` function, which takes the executable
target as an argument and includes the binary name in the
`project_description.json`.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
c7bde33b67 feat(cmakev2/project): initialize global flash targets
The global flash targets are created using
__create_project_flash_targets, but these are merely placeholders that
allow components to declare their dependencies on the global flash or
encrypted-flash target in their project_include.cmake. The actual logic
for flash targets is located in the project_include.cmake of the
esptool_py component. Therefore, the targets must be initialized
after this file has been included. To address this, a new function,
__init_project_flash_targets, has been added for this purpose.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
efae51696f feat(cmakev2/idf): enable ccache if requested
Enable ccache if CCACHE_ENABLE is set.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
c60f7bec27 feat(cmakev2/utilities): add fail_at_build_time helper
Create a phony target that intentionally fails the build, displaying the
error messages specified in the message arguments. An empty CMake file is
created and included, which is then deleted when the target is executed.
This forces CMake to rerun, as the file is added to the CMake rerun
dependencies.

This has been carried over from cmakev1 as it is used by several
components.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
070590986a fix(mbedtls/cmake): handle lwip dependency in cmakev2
Currently, the lwip is linked to mbedtls if CONFIG_LWIP_ENABLE is set.
This approach works in cmakev1 because only the configuration for
BUILD_COMPONENTS is available during component evaluation. However, this
is not the case in cmakev2, where the configuration for all components
is available. This means that even if CONFIG_LWIP_ENABLE is set, it does
not guarantee that the lwip component is included in the build. For
cmakev2, modify the check to use a generator expression to ensure that
lwip is linked to mbedtls only if lwip is actually included in the
build.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Sudeep Mohanty
65ed7732fe feat(cmakev2): Added support for injecting dependencies for components 2025-10-30 17:17:49 +08:00
Sudeep Mohanty
c7e9385427 feat(cmakev2): Added download of component-level managed components 2025-10-30 17:17:49 +08:00
Sudeep Mohanty
37d1a3064f feat(cmakev2): Added idf_build_component shim to compat.cmake 2025-10-30 17:17:49 +08:00
Frantisek Hrbata
020cceab23 feat(cmakev2/project): add __init_project_flash_targets helper
Some components rely on the existence of flash targets to declare
dependencies. Add flash and encrypted-flash targets during project
initialization to ensure they are available before including
project_include.cmake files.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
e45b86ac9d fix(test_build_system): use idf_project_default in buildv2 test app
Since the idf_project_default is already available, let's use it in the
buildv2 testing application. Also change the test app name from
buildv2_test_app to build_test_app, as some tests require the ELF and
bin images to be created under this name.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
a6c6193232 fix(cmakev2/compat): use alias target in idf_component_optional_requires
The optional dependency is currently added if the optional component
interface target exists, which is always the case unless a non-existent
component is requested. Instead, base the optional dependency on the
component interface target alias, as it is created only when the
component is included in the project.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
fdd8a924bc feat(cmakev2/project): allow to include all discovered components
If the IDF_INCLUDE_ALL_COMPONENTS variable is set, all discovered
components will be included. By default, components are included based
on their requirements. When IDF_INCLUDE_ALL_COMPONENTS is enabled, the
all_component_info dictionary in the project_description.json file will
be fully populated.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
b36e5adeff feat(cmakev2/build): add idf_build_generate_metadata function
The `idf_build_generate_metadata()` function is used to generate project
metadata, specifically the `project_description.json` file, for a given
executable target. The output file path can be specified as an argument
to the function, allowing metadata generation for multiple executables.
It identifies the library, created by the `idf_build_library` function,
that is linked to the executable based on the `LINK_LIBRARIES`
executable target property. The `LIBRARY_INTERFACES` build property
tracks all library interfaces created with the `idf_build_library`
function, so the targets in the `LINK_LIBRARIES` executable property are
checked against this list to find the library. The library contains
information about components linked to it in the
`LIBRARY_COMPONENTS_LINKED` library property. These components are
processed and added to the `build_component_info` dictionary in the
`project_description.json` along with other information.

Note that, compared to cmakev1, the `all_component_info` dictionary in
`project_description` does not include some information by default, such
as included directories. This information is available in cmakev1 due to
early component evaluation, which is not done in cmakev2. This will
likely require some adjustments on the hints side.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
767e73b811 feat(cmakev2/utilities): add __make_json_list helper
Helper function for converting a CMake list to a JSON list.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
2e667ee990 feat(cmakev2/component): add __PREFIX component property in __init_component()
The cmakev1 sets __PREFIX as a component property. To maintain backward
compatibility, set it in cmakev2 as well.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
06449dc17d feat(cmakev2/utilities): add __get_executable_library_or_die helper
Search for the library interface target created with the
idf_build_library() function and linked to the executable, examine the
LINK_LIBRARIES for the executable and the LIBRARY_INTERFACES build
property, which stores all library interface targets created by the
idf_build_library() function.

This helper is intended for use by functions, such as the
idf_build_generate_metadata() function, which accepts the executable
target as an argument to find the library linked to it.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
1af119a431 feat(cmakev2/project): add idf_project_default macro
The idf_project_default macro is intended to be used by default for
ESP-IDF projects. Currently, it handles the necessary project
initialization that must occur after CMake's project() is called. It
creates the default executable based on the project name and links a
library to it, based on the main component and its transitive
dependencies. This macro will be further extended to also generate
binary image, project metadata, and add other expected targets. It
primarily serves as a replacement for the project() macro used in
cmakev1.

Expected typical usage:
```
cmake_minimum_required(VERSION 3.22)
include($ENV{IDF_PATH}/tools/cmakev2/idf.cmake)
project(hello_world LANGUAGES C CXX ASM)
idf_project_default()
```

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
2a093bcb0c feat(cmakev2/build): add idf_build_executable function
Create an empty source file for the add_executable target, along with a
library containing specified components, and then create an executable.
This approach allows for the easy creation of multiple executables by
specifying the component with the app_main function, as demonstrated in
the test.

```
idf_build_executable(fatfs_example COMPONENTS fatfs_example)
idf_build_executable(hello_world_example COMPONENTS hello_world_example)
```

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
213d128718 feat(cmakev2/build): remove INTERFACE option from idf_build_library
The option is unnecessary and complicates the interface. Additionally,
it does not adhere to the previously established naming convention. The
target name for the library interface is provided as a standard function
argument.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
22cf5a61ef fix(esp_usb_cdc_rom_console/cmake): avoid using uninitialized srcs variable
In cmakev2, the component CMakeLists.txt files are evaluated recursively
based on the component dependencies. This means that variables from
previously evaluated components are set and available in the scope of
the currently evaluated component. It is necessary to initialize every
variable that is used.

Fixes: 56e0c11bb6 ("feat(usb_cdc_console): moved usb-cdc ROM console to n..")
Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
6152758c99 feat(cmakev2/test): add fatfs_example and hello_world_example
Add two components: fatfs_example and hello_world_example. These are
simply copies of the main components from the existing examples.

Enhance the test_executable test to create targets for two
executables, which can be built after CMake configuration.

```
cmake --build build/ --target hello_world_example
cmake --build build/ --target fatfs_example
```

Additionally, move the test_component_priority to the end of the test
chain, as it modifies the esp_system component, which interferes with
the linkage of the executables.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
3804fcfb2c feat(cmakev2/ldgen): add ldgen integration
Integrate the ldgen into cmakev2. With this change, it becomes possible
to actually link the project executables.

In cmakev2, the handling of linker scripts is deferred to
idf_build_library, unlike in cmakev1, where linker scripts were added
and generated during the target_linker_script call. In cmakev2, the
target_linker_script only adds the linker scripts and templates, along
with the output filenames for the linker scripts generated from the
templates, to the component property. When idf_build_library is called
and all the requested components are included, it uses the
__get_target_dependencies function to obtain all transitively linked
targets to the library interface target. These targets are mapped to the
components, and the LIBRARY_COMPONENTS_LINKED library property is set.
It contains all components linked to the library interface target. The
components from LIBRARY_COMPONENTS_LINKED are used to collect linker
fragments and linker scripts utilized in the library. Additionally, all
targets transitively linked to the library are used to identify archive
files used in the library. This includes component archives and archives
added with the add_prebuilt_library function. The archives and
ldfragments related to the components linked to the library are used
when ldgen generates the linker scripts from templates.

The linker scripts, both static and generated by ldgen, are added to the
library interface link options and INTERFACE_LINK_DEPENDS property. For
generated linker scripts, a custom target is created and added as a
dependency for the library interface to ensure they are generated before
the link.

The difference compared to cmakev1 is that the generated linker scripts,
currently only sections.ld, are not global in the project but are
generated per library. This means there might be multiple versions of
sections.ld depending on the components included in the library. For
example, a component like esp_system may be linked to multiple library
interface targets, each with a different set of components. This results
in different sets of fragment files and library archives and different
versions of the sections.ld linker script. This should ensure proper
dependencies between targets. In other words, if a component changes its
linker fragment, only executables linked to libraries using this
component should be re-linked. As a consequence of this approach, the
generated linker scripts for different libraries need to have different
names or be stored in different directories to avoid overwriting the
linker script for one library with the linker script for another library
using the same component. This is handled with a suffix, which is based
on the library interface target name and appended to the generated
linker script. So, for example, there is no sections.ld, but instead
sections.ld_fatfs_lib or sections.ld_hello_world_lib. As a next step, we
can add a DEFAULT option to idf_build_library and avoid adding the
suffix for the default library.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
e06624f552 feat(cmakev2/build): track components linked to library
There may be multiple libraries, each linking a different set of
components. Introduce a new library property, LIBRARY_COMPONENTS_LINKED,
to track the components linked with a specific library. This property
can be used, for example, by menuconfig to distinguish between included
and excluded components on a per-library or per-executable basis, or by
ldgen to identify linker scripts for the linked components.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
965650dc11 feat(cmakev2/feat): add __get_target_dependencies helper
Based on the INTERFACE_LINK_LIBRARIES and LINK_LIBRARIES properties,
recursively retrieve the list of dependencies for the specified target.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
f000545630 feat(cmakev2/compat): initialize common components within idf_component_register
Currently, the common components are initialized in the idf_project_init
macro, which means they are included even for cmakev2 components.
However, cmakev2 components are expected to explicitly specify all their
dependencies instead of relying on common components being automatically
linked. Therefore, common components are only relevant within the
context of cmakev1 components. To address this, move the
__init_common_components function call to idf_component_register and
include common components only when they are truly needed for a cmakev1
component.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
edf62c3557 feat(cmakev2/test): add simple executable test
Add a simple test_executable that links to all discovered components.
This is intended to verify if the component sources can be compiled
using the command `cmake --build build/ --target test_executable`. The
ldgen is not yet integrated, so the test_executable is not actually
created or linked. However, this process can be used to check if the
components are compiled.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
ff79ab7733 fix(cmakev2/project): add ESP_PLATFORM to compile_definitions
Set the ESP_PLATFORM macro to indicate to component sources that they
are being compiled with ESP-IDF.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
663460379c fix(cmakev2/utilities): avoid overwriting compile_options in __get_compile_options
Currently, the generic compile_options are ignored because they are
unset after retrieving the build property. To fix this, avoid explicitly
setting compile_options, as this variable is initialized with the
idf_build_get_property(compile_options ...) call.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
d9eb78c1fd feat(cmakev2/compat): link common components in idf_component_register
Automatically link commonly required components to the component target
created in the idf_component_register function. This is still necessary
even in cmakev2, as existing components depend on this behavior.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
bede750fcd feat(cmakev2/project): initialize and include commonly required components
Identify the commonly required components based on the target and
architecture, and store them in the __COMPONENT_REQUIRES_COMMON build
property. These components are automatically included, and their
interfaces are stored in the __COMMON_COMPONENT_INTERFACES build
property. The commonly required component interfaces are automatically
linked to each component.

Existing components for cmakev1 rely on the automatic linking of common
components. Therefore, at least initially, we need to implement the same
functionality in cmakev2.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
427c5ba8df fix(xtensa/cmake): do not include project_include.cmake if the architecture is not xtensa
In cmakev2, the project_include.cmake files for every component are
included. This means that even when working with RISC-V, the
project_include.cmake file for Xtensa is still included. Ensure that the
architecture is verified, and exit if it is not Xtensa.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
69a67e7e6e feat(cmakev2/idf): initialize IDF_TARGET_ARCH build property
Based on the configuration, set the IDF_TARGET build property. This is
also set by cmakev1 and can be used to easily determine the architecture
for the project.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
9040925c1c feat(cmakev2/component): add embedded files in idf_component_include
Add embedded source files to the component target sources. This is
intentionally managed in idf_component_include instead of
idf_component_register, allowing even cmakev2 components to set the
component's EMBED_FILES and EMBED_TXTFILES properties. Although it might
be more convenient to call the target_add_binary_data helper function
directly in cmakev2.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
e84250998d feat(cmakev2/compat): add idf_component_register function
Add a backward-compatible idf_component_register function. This is
necessary to enable existing components to integrate with cmakev2. Note
that, by design, when the configuration is evaluated first, the KCONFIG
and KCONFIG_PROJBUILD options become obsolete, and an error is reported
if non-default configuration file names are specified.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
edf8f4b689 fix(esp_eth/cmake): avoid using BUILD_COMPONENTS build property for IDF_BUILD_V2
IDF_BUILD_V2 does not have BUILD_COMPONENTS build property. Therefore,
when IDF_BUILD_V2 is defined, use a generator expressions instead.
The inclusion of esp_eth_netif_glue.c, which relies on the presence of
the esp_netif component, should ideally be managed by a configuration
option. The same applies to the requirements for esp_eth. Currently,
only a basic adjustment has been made to enable the inclusion of esp_eth
in cmakev2.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
3777b19bcc fix(esp_common/cmake): avoid using BUILD_COMPONENTS build property for IDF_BUILD_V2
IDF_BUILD_V2 does not have BUILD_COMPONENTS build property. Therefore,
when IDF_BUILD_V2 is defined, use idf_component_optional_requires and
generator expressions instead. I believe that the one-liner should also
work with IDF_BUILD_V1, but the change is kept separate to clearly show
the difference between IDF_BUILD_V1 and IDF_BUILD_V2.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
1b40b10dc1 fix(heap/cmake): avoid using BUILD_COMPONENTS build property for IDF_BUILD_V2
IDF_BUILD_V2 does not have BUILD_COMPONENTS build property. Therefore,
when IDF_BUILD_V2 is defined, use a generator expressions instead. I
believe that the one-liner should also work with IDF_BUILD_V1, but the
change is kept separate to clearly show the difference between
IDF_BUILD_V1 and IDF_BUILD_V2.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
4c88b9c31b feat(cmakev2/component): create component alias only after it has been included
Add a component interface alias only after the actual target is created,
meaning the component is included. The alias has a well-defined name and
can be used in generator expressions like
`$<$<TARGET_EXISTS:idf::esp_netif>:>` without needing to retrieve the
COMPONENT_ALIAS property.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
1129e8b8d4 feat(cmakev2/utilities): add add_prebuilt_library function
Imported from cmakev1 to enable the addition of prebuilt libraries into
the build.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
6431c056f7 feat(cmakev2/utilities): add target_add_binary_data function
Add binary data into the build target by converting it into a generated
source file, which is then compiled into a binary object as part of the
build process.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
cb426066d7 feat(cmakev2/utilities): add add_deprecated_target_alias function
The add_deprecated_target_alias function is used by some existing
components, so it should be added to cmakev2 as well.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
c83102eb5e feat(cmakev2/utilities): add file_generate function
The file_generate function is used by some existing components, so it
should be added to cmakev2 as well.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
d03257c9a9 feat(cmakev2/utilities): add fail_target function
The fail_target function is used by some existing components, so it
should be added to cmakev2 as well.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
e52884fc68 feat(cmakev2/utilities): add add_prefix function
The add_prefix function is used by some existing components, so it
should be added to cmakev2 as well.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
e909e51c59 feat(cmakev2/utilities): add spaces2list function
The spaces2list function is used by some existing components, so it
should be added to cmakev2 as well.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
1fe41c4521 feat(cmakev2/compat): add idf_component_optional_requires function
Add the specified component as a dependency only if it is included in
the build. This functions the same way as in cmakev1, but it uses
generator expressions because cmake2 does not maintain the
BUILD_COMPONENTS build property, which would list all components
included in the build.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
07cffc73fa feat(cmakev2/compat): add target_linker_script stump
Currently, this is just a placeholder without implementation. The
implementation will be completed in a subsequent patch set that
integrates ldgen. For now, this is enough for ESP-IDF components can be
included by cmakev2.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
d77a3c84ad fix(cmakev2/component): add component name to __DEPENDENCY_CHAIN
The __DEPENDENCY_CHAIN was not properly created because the component
names were not added to it. Fix this by maintaining it correctly.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
1b6375050b feat(cmakev2/component): evaluate all components
This removes the temporary restriction that only allowed components with
project_components as their source to be evaluated.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
c67dabd5c3 feat(cmakev2/compat): add __get_component_sources helper
This helper function collects component sources within the component's
directory. It will be used by the idf_component_register.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
49b7b2244e feat(cmakev2/utilities): add BASE_DIR option to __get_absolute_paths
Add an optional BASE_DIR option to specify a directory that will serve
as the base directory for evaluating input paths. This can be useful,
for example, when collecting component sources.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
fe94c95ad6 feat(cmake/toolchain): include utilities.cmake from correct build system version
The toolchain files are using the remove_duplicated_flags function from
utilities.cmake. However, we want to avoid mixing utilities from cmakev1
and cmakev2. Use `IDF_BUILD_VER_TAG` to include utilities from the
currently used build system version.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
f0346ce56b feat(cmakev2/utilities): add remove_duplicated_flags function
This function is primarily used by the toolchain files.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
6187d988bc feat(cmakev2/idf): add IDF_BUILD_VER_TAG identifier
Add the IDF_BUILD_VER_TAG variables to include the build system version
tag. These variables can be used in files, such as CMake toolchain
files, which are shared between cmakev1 and cmakev2. This allows for the
inclusion of files from the currently running build system version. For
example:
include($ENV{IDF_PATH}/tools/cmake${IDF_BUILD_VER_TAG}/utilities.cmake).

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Sudeep Mohanty
a1c36677d0 fix(cmakev2): Fix Kconfig interactive targets
This commit fixes the Kconfig interactive targets (such as menuconfig)
commands to have the correct Kconfig output files.
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
bb2cc6113c ci(pre-commit): temporary disable check-kconfig-files
It is not possible to add a new sourced file through an environment
variable because kconfcheck has a fixed list of allowed environment
variable names. This issue is tracked under IDF-13847.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
0d7d6f6b3e feat(cmakev2/compat): add check_expected_tool_version helper
The compat.cmake file is intended to include functions necessary for
backward compatibility with cmakev1.

Add the check_expected_tool_version function, which is used by some
project_include.cmake files to verify if the tool's version matches the
installed tool. This functionality is used, for example, by esp_common.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
645c2d468f feat(cmakev2/test): add Kconfig files for testing components
Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
5cc570960e feat(cmakev2/test): generate project_description.json
Some idf.py commands, such as menuconfig, use build_target and call
ensure_build_directory, which requires the project_description.json file
to be generated. To enable the use of idf.py commands with the testing
example, call __generate_project_info() to generate the
project_description.json file. This allows you to execute idf.py
menuconfig.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
e248b36676 feat(cmakev2/kconfig): use cmakev2 specific config_buildv2.env.in
The current config.env.in template cannot be easily extended and shared
between cmakev1 and cmakev2. Although the root Kconfig is shared and
sources COMPONENT_KCONFIGS_EXCLUDED_SOURCE_FILE and
COMPONENT_KCONFIGS_PROJBUILD_EXCLUDED_SOURCE_FILE, these environment
variables cannot be set to empty strings. This issue arises unless we
also adjust cmakev1 and esp-docs, which use prepare_kconfig_files.py, to
properly set COMPONENT_KCONFIGS_EXCLUDED_SOURCE_FILE and
COMPONENT_KCONFIGS_PROJBUILD_EXCLUDED_SOURCE_FILE.

If an environment variable is set to an empty string and sourced in
Kconfig, kconfgen will expand the variable with expandvars(), resulting
in an empty value. This expanded variable is then appended to the root
Kconfig or the currently processed Kconfig directory path, depending on
whether osource or orsource is used, and passed to iglob. The iglog will
return the directory as a result, and when Kconfig attempts to open the
file, it will encounter an error because it is a directory.

To resolve this issue and enable sharing of the root Kconfig file, a new
config_buildv2.env.in template has been added, which includes
environment variables for the excluded components.

For cmakev1, kconfgen will encounter the osource command for
COMPONENT_KCONFIGS_EXCLUDED_SOURCE_FILE. Since this variable is not
defined in config.env.in, expandvars() will return the environment
variable name instead of expanding it, and iglob will not match
anything. Because osource is used for excluded components, the
non-existent file for osource will be skipped.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
8567273b37 feat(cmakev2/kconfig): pass environment variables with excluded components to menuconfig
Pass the environmental variables COMPONENT_KCONFIGS_EXCLUDED_SOURCE_FILE
and COMPONENT_KCONFIGS_PROJBUILD_EXCLUDED_SOURCE_FILE to menuconfig.
This will display the configuration for excluded components under new
menus in menuconfig. Additionally, set the IDF_BUILD_V2 environment
variable to make these new menus visible. The IDF_BUILD_V2 variable is
also passed to all kconfgen commands.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
a6af14bc89 fix(tools): ruff formatting in prepare_kconfig_files.py
Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
38e0242636 feat(tools): generate kconfig.in files for components not included in the build
To generate a complete configuration for all discovered components, we
need to ensure that even kconfig files for the excluded components are
seen by Kconfig. Modify the prepare_kconfig_files.py script to generate
files that list the Kconfig files for excluded components. These files
are sourced in the root Kconfig using the
COMPONENT_KCONFIGS_EXCLUDED_SOURCE_FILE and
COMPONENT_KCONFIGS_PROJBUILD_EXCLUDED_SOURCE_FILE environment variables.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
2c518b2ca3 feat(Kconfig): source configuration for components not included in the build
Introduce new configuration menus for components that are not part of
the build. These menus will only be visible if the IDF_BUILD_V2
environment variable is defined and it will be set only in cmakev2. This
enables sharing of the root Kconfig file between cmakev1 and cmakev2.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
4d329250ac feat(cmakev2/idf): include ExternalProject module
For backward compatibility, since externalproject_add is used by
project_include.cmake in the bootloader component. The ExternalProject
should probably be included there instead.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
01279ea4c3 feat(cmakev2/project): include project_include.cmake files
During the initialization of a component in the __init_component
function, store the full path of the project_include.cmake file in the
component's __PROJECT_INCLUDE property, if it exists. Include the
project_include.cmake files for all discovered components at the global
scope within the idf_project_init macro.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
2967ff3e2e feat(cmakev2/idf): initialize build system version variables
Set the global variables IDF_BUILD_V2 and IDF_BUILD_VER, along with the
build properties and environmental variables. These are intended to be
used by components to determine which build system version they are
evaluated under and to make adjustments based on this information.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
70f5366408 feat(cmakev2/project): move all project-related items into project.cmake
The current approach involves transparently calling __init_build within
idf_build_library and performing all post-project() initialization
there. The issue with this method is that project_include.cmake files
also need to be included during post-project() initialization, but they
should be included in the global scope. This cannot be achieved within
the __init_build function unless it is converted into a macro. Although
using a macro is a potential solution, it risks causing global scope
pollution. Another complication is the location where project() can be
invoked; it must be explicitly[1] stated in the project's
CMakeLists.txt.  This requirement conflicts with our intention to wrap
it within the idf_project_default helper. Given these challenges, it
makes sense to introduce an explicit idf_project_init macro, where all
post-project() initialization occurs, including the inclusion of
project_include.cmake files. While we can still encapsulate this within
idf_project_default, for the plumbing commands (idf_build_library,
idf_build_executable, ...), it will need to be explicitly called after
the project() invocation.

Usage for default project:

cmake_minimum_required(VERSION 3.22)
include($ENV{IDF_PATH}/tools/cmakev2/idf.cmake)
project()
idf_project_default()

Usage for plumbing commands:

cmake_minimum_required(VERSION 3.22)
include($ENV{IDF_PATH}/tools/cmakev2/idf.cmake)
project()
idf_project_init()
idf_build_library()
...

[1] https://cmake.org/cmake/help/latest/command/project.html#usage

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
21430acb4f ci(cmakev2): enable buildv2 CI testing
A new pytest_buildv2_system job has been added to execute selected tests
from the existing test_build_system test suite. Currently, only the
test_non_default_target.py is enabled. The ultimate goal is to run most
of the build system tests with buildv2. This should help ensure
compatibility between IDF build system v1 and v2.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
f2a7c311fd feat(test_build_system): add buildv2_skip marker
This marker enables the skipping of tests that, for any reason, cannot
be executed with the IDF build system version 2. It accepts an optional
string argument that explains why the test cannot be run with version 2.
If no explanation is provided, a default message is used. This marker is
used in the `pytest_collection_modifyitems` hook to skip tests marked
with it when the `--buildv2` pytest command line option is used.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
05ec102b9f fix(test_build_system): fix ruff formatting for conftest.py
Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
1da7f3714f feat(test_build_system): add --buildv2 pytest option and buildv2 test app
The IDF build system v2 should be backward compatible with IDF build
system v1 in most situations. Therefore, it makes sense to reuse the
existing v1 tests and run them for v2 as well. This approach will help
ensure that v2 maintains backward compatibility. Introduce a new
--buildv2 option, which switches the existing tests to use the newly
added buildv2_test_app for v2. The goal is to enable the existing v1
tests incrementally in CI as the v2 implementation progresses.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
82e295ac6f fix(cmakev2/idf): fix IDF_TARGET initialization
Currently, the target consistency check with sdkconfig is performed even
if sdkconfig is not present, by comparing the selected target with the
target defined in sdkconfig.defaults. This results in an inconsistency
report when a different target is set in the IDF_TARGET environment
or cmake variable compared to sdkconfig.defaults. The behavior in
cmakev1 is to prioritize IDF_TARGET and ignore values in
sdkconfig.defaults. Perform the consistency check only if the
sdkconfig file exists.

Additionally, skip this consistency check if a set-target action is
taking place, as the old target in sdkconfig is being replaced with a
new value anyway.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
d5befe0742 fix(test_build_system): fix ruff formatting for test_non_default_target.py
Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
5bdcfc4a5b fix(test_build_system): pop SDKCONFIG_DEFAULTS from the environment
The test for guessing the target from the SDKCONFIG_DEFAULTS environment
variable is not cleaning up after itself, leaving the SDKCONFIG_DEFAULTS
environment variable set. The subsequent test performs target guessing
from SDKCONFIG_DEFAULTS passed to cmake with the -D option. The
SDKCONFIG_DEFAULTS environment variable should take precedence over the
SDKCONFIG_DEFAULTS cmake variable. This is correctly handled in cmakev2
, but in cmakev1, the SDKCONFIG_DEFAULTS cmake variable is used even if
the SDKCONFIG_DEFAULTS environment variable is set. This appears to be a
bug or at least an inconsistency in cmakev1.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
f1e467eeee feat(cmakev2/build): add __generate_project_info stub
Currently, this generates a very basic project_description.json file,
allowing idf.py commands that call ensure_build_directory, such as
reconfigure, to be used with cmakev2. The ensure_build_directory
function sets a global context, which is presently used only for hints,
and the project_description.json file is loaded as part of this context.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
3dfc8cdc49 feat(cmakev2/test): add simple test for component include
Add two project components, component1 and component2, and verify that
their real targets are created when they are included.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
77e10e0df0 feat(cmakev2/build): use idf_component_include into idf_build_library
Call idf_component_include for all components requested in the library
and link them into it.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
bcfd5f680f feat(cmakev2/component): add idf_component_include function
Add a core function of the build system, responsible for including the
specified component identified by name, into the build
process.

Currently, the non-project components written in cmakev1 are ignored and
not evaluated with the add_subdirectory command because there are no
shims for the cmakev1 API yet. However, this allows for the evaluation
of project components written using the cmakev2 approach, which is
closer to the native CMake usage.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
51de444e4f feat(cmakev2/idf): enable the generation of compile_commands.json
Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
fcdc05b4c8 feat(cmakev2/utilities): add __get_compile_options helper
Gather the compilation options from COMPILE_OPTIONS, C_COMPILE_OPTIONS,
CXX_COMPILE_OPTIONS, and ASM_COMPILE_OPTIONS build properties into a
single list using generator expressions. This list can then be used with
the target_compile_options call.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
f6f7edede2 feat(cmakev2/build): set LINKER_TYPE build property in __init_build_configuration
Set the LINKER_TYPE build property. Different linkers may have varying
options, so it's important to identify the linker type to configure the
options correctly. Currently, LINKER_TYPE is used to set the appropriate
linker options for linking the entire archive, which differs between the
GNU and Apple linkers when building on the host.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
0f536b45d8 feat(cmakev2/test): add simple test for PROJECT_NAME and PROJECT_VER
Simple test for PROJECT_NAME and PROJECT_VER build properties to ensure
they are set according to the values provided in the project() call.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
11dba11e36 fix(cmakev2/utilities): respect CMake's regular variables in __get_default_value
Currently, only the value stored in CMake's cache is considered when
setting the default value. Allow regular variables as well, which may be
set in the project's CMakeLists.txt file.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
72d4fecfa9 feat(cmakev2/build): set PROJECT_VER build property
Initialize the PROJECT_VER build property based on the following
precedence.

1. The PROJECT_VER environment or CMake variable.
2. The version.txt file located in the top-level project directory.
3. The VERSION argument, if provided, in the project() macro.
4. The output of git describe if the project is within a Git repository.
5. Defaults to 1 if none of the above conditions are met.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
754ef56594 feat(cmakev2/build): set PROJECT_NAME build property
Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
a4b0ad0cf3 feat(cmakev2/build): add build configuration
Add the __init_build_configuration() function to set all C, CXX, ASM,
and linker options, along with compilation defines, in a single
location. In cmakev1, these settings are scattered across multiple
places and it seems logical to group them together.

This function is called from the __init_build(), which is invoked after
project(). This sequence is necessary because some options depend on the
CMake information about the compiler, which is only available once the
toolchain has been initialized in project().

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
d58d08aacc feat(cmakev2/build): add __init_build() stub
Most of the global settings are configured in idf.cmake, but certain
elements can only be initialized after the project() function is called
and the toolchain is set up. For example, this includes the compilation
options, which may depend on identified compiler or the project name and
version set in the project() call. The __init_build function is called
at the beginning of the idf_build_library() function, meaning it should
be executed after the project() call. It ensures that initialization
occurs only once by setting the __BUILD_INITIALIZED build property.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
01663e7c12 ci(cmakev2): fix cmakev2 exclusion location in exclude_check_tools_files.txt
Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
abbf75acec feat(cmakev2/idf): add git submodules initialization
Initialize submodules that are not yet initialized, and issue a warning
for submodules that do not match the recorded hash in the git tree.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
5c6f37f057 feat(cmakev2/utilities): add __split helper to split the string into a list
When working with command output, it is sometimes necessary to handle it
line by line. Add a `__split` helper function that can split an input
string based on a specified separator, which defaults to a newline, and
store the results in a list. This function also offers modifiers to
strip whitespace and remove empty entries.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
572f07a340 feat(cmakev2/idf): add __init_idf_version to set IDF_VER
Initialize the IDF_VER build property using the version.txt file, or use
git-describe. If neither is available, fall back to the value of the
IDF_VERSION environment variable.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
ba16364ab5 feat(cmakev2/idf): add __git_init to identify the git executable
The Git tool will be used in various parts of the build system, such as
retrieving the IDF version using git-describe or checking submodules.
Similar to the Python interpreter, add an initialization function to
identify the Git executable.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
f1b143a23b fix(cmakev2/kconfig): add missing parentheses after the else condition
Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Sudeep Mohanty
6249c46617 feat(cmakev2/kconfig): Added support for excluded Kconfigs in menuconfig
This commit adds support for processing Kconfig files from excluded
components.
2025-10-30 17:17:49 +08:00
Sudeep Mohanty
0458b98bfa feat(cmakev2/kconfig): Added basic test for Kconfig generation 2025-10-30 17:17:49 +08:00
Sudeep Mohanty
22914237b0 feat(cmakev2/kconfig): Added support for Kconfig target creation
The following functions are added to tools/cmakev2/kconfig.cmake:
- __create_kconfig_targets(): Calls other target creation functions.
- __create_menuconfig_target(): Creates menuconfig target.
- __create_confserver_target(): Creates confserver target.
- __create_save_defconfig_target(): Creates save-defconf target.
2025-10-30 17:17:49 +08:00
Sudeep Mohanty
72e2fa0005 feat(cmakev2/kconfig): Added support for Kconfig output generation
The following functions are added to tools/cmakev2/kconfig.cmake:
- __generate_kconfig_outputs(): Generates Kconfig output files.
- __create_base_kconfgen_command(): Creates command for running
  kconfgen.
- __run_kconfgen(): Invokes kconfgen tool.
2025-10-30 17:17:49 +08:00
Sudeep Mohanty
b774ca25bc feat(cmakev2/kconfig): Added support for Kconfig environment preparation
The following functions are added to tools/cmakev2/kconfig.cmake:
- __setup_kconfig_environment(): Creates Kconfig environment for Kconfig
  output generation.
- __get_init_config_version(): Fetch ESP-IDF version and set the
  environment variable.
- __create_config_env_file(): Create the config.env file for kconfgen.
2025-10-30 17:17:49 +08:00
Sudeep Mohanty
135fed5a49 feat(cmakev2/kconfig): Added support for Kconfig files collection
The following functions are added to tools/cmakev2/kconfig.cmake:
- __collect_kconfig_files_from_components(): Collect Kconfig files from
  components.
- __collect_kconfig_files_from_bootloader_components(): Collect Kconfig
  files from bootloader components.
- __collect_kconfig_files_from_directory(): Collect Kconfig files from
  a directory.
2025-10-30 17:17:49 +08:00
Sudeep Mohanty
085633de35 feat(cmakev2/kconfig): Added __init_kconfig() and initial Kconfig properties
This commit adds the tools/cmakev2/kconfig.cmake file for Kconfig
processing. The file provides the following functions:

- __init_kconfig(): Placeholder to initialize Kconfig build properties,
  collect kconfig files and generate the initial sdkconfig.
- __generate_sdkconfig(): Placeholder to generate sdkconfig output files.
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
3b28a2ac33 feat(cmakev2/utilities): add __dump_all_properties helper
Dump all properties for build, components, and libraries.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
a71a2e1c4e fix(cmakev2/component): correct function descriptions and typos
Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
d669f1841b feat(cmakev2/build): add idf_build_library stub
Add idf_build_library function and enable setting and getting its
properties. This lays the groundwork for future initialization that
needs to occur after the project() call, such as determining compilation
options and others.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
bc645db318 fix(cmakev2/test): correct indentation in testing CMakeLists.txt
Fixes: 3488300671da ("feat(cmakev2/test): add simple test for toolchain set..")
Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
b72b14a159 feat(cmakev2/utilities): add __set_property and __get_property helpers
The `idf_build_(set|get)_property` and
`idf_component_(set|get)_property` functions share a lot of similar
code. Move these common parts into new `__(set|get)_property` helper
functions. With the upcoming `idf_build_library` API function, we might
need to add properties for the interface target created for the library,
which would otherwise lead to yet another code duplication for setting
and getting library interface properties.

Update the current implementations of `idf_build_(set|get)_property` and
`idf_component_(set|get)_property` to utilize these new helper
functions.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
27e726b176 feat(cmakev2/test): add simple test for toolchain settings
Also format the current testing CMakeLists.txt properly.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
d37f7eaeb6 feat(cmakev2/idf): initialize toolchain
Determine the IDF_TOOLCHAIN from the following sources in this order:
environmental variable and CMake cache variable.  Ensure there are no
inconsistencies between the values set in these different locations.

Set the IDF_TOOLCHAIN and IDF_TOOLCHAIN_FILE build properties. Also,
configure the IDF_TOOLCHAIN CMake cache variable and set the
CMAKE_TOOLCHAIN_FILE global variable.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
ec600a8132 feat(cmakev2/idf): initialize IDF_TARGET build property
Determine the IDF_TARGET from the following sources in this order:
environmental variable, CMake cache variable, and sdkconfig files.
Ensure there are no inconsistencies between the values set in these
different locations.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
6e27038dc3 feat(cmakev2/utilities): add __get_sdkconfig_option helper
Search for the configuration option value in the specified sdkconfig
file.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
62db5692cd feat(cmakev2/idf): initialize SDKCONFIG and SDKCONFIG_DEFAULTS build properties
Based on the environmental variables, CMake cache variables, or default
values, set the DKCONFIG and SDKCONFIG_DEFAULTS build properties.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
ed34c24de6 feat(cmakev2/idf): add Python interpreter detection
Determine the Python interpreter and verify package dependencies if the
CMake cache variable PYTHON_DEPS_CHECKED is not set.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
00671f2f1e feat(cmakev2/idf): add IDF_VERSION variables
The version.cmake file should be the sole file used from the cmakev1
build system. There's no need to maintain the IDF_VERSION information in
two separate locations.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
95f4d88dac feat(cmakev2/utilities): add __get_default_value helper
Helper for obtaining the default value of a variable. It returns the
value of the specified variable based on the following order of
precedence, with the highest precedence first:

1. Environmental variable
2. CMake cache variable
3. Provided default value

This can be used to retrieve the value of variables that might also be
set in the environment or cache, such as PYTHON or SDKCONFIG.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
4b02439599 fix(cmakev2/utilities): make the PATHS option optional in __get_absolute_paths
With the default signature of `cmake_parse_arguments`, without using
`PARSE_ARGV`, it's not possible to determine if options were not
specified or set as an empty string (or empty list)[1]. If an empty
string is passed to the `PATHS` option, the variable parsed by
`cmake_parse_arguments` is not defined. This issue can be addressed by
using `PARSE_ARGV`, but this approach only works for functions and
requires CMake version 3.31 or newer. Additionally, when `PARSE_ARGV` is
used for multiple value option, the values are not concatenated into a
single list, which is inconvenient, as the lists are instead escaped. If
the `PATHS` option is not defined, set it to an empty string.  This
allows passing an empty string, as well as a mix of lists and
individual strings, through PATHS.

The behaviour can be seen with a simple example:

$ cmake -P test.cmake

```test.cmake
cmake_minimum_required(VERSION 3.22)

function(test)
    set(options)
    set(one_value)
    set(multi_value PATHS)

    cmake_parse_arguments(ARG "${options}" "${one_value}" "${multi_value}" ${ARGN})
    #cmake_parse_arguments(PARSE_ARGV 0 ARG "${options}" "${one_value}" "${multi_value}")

    message("PATHS: ${ARG_PATHS}")
endfunction()

test(PATHS "one;two;three" "four" "five;six" "seven")
```

```
PATHS: one;two;three;four;five;six;seven
vs
PATHS: one\;two\;three;four;five\;six;seven
```

Also update the current usage of __get_absolute_paths, as the check for
empty PATHS is no longer necessary.

[1] https://cmake.org/cmake/help/latest/policy/CMP0174.html#policy:CMP0174

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
2cbeb7a1a2 test(cmakev2): add testing project CMakeLists.txt
This is a basic CMake project that currently includes tests for
displaying build and component properties, as well as testing component
priority. These tests should be removed once proper CI testing is
in place.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
050ed5c76a ci(cmakev2): temporarily exclude cmakev2 from CI testing
There are currently no CI tests for CMakeV2, so add it to the
exclude_check_tools_files.txt file. Once CI testing is implemented, this
change should be reverted.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Frantisek Hrbata
a9d55936ef feat(cmakev2): add basic component initialization
Discover component directories and initialize components within them.
This process does not include managed components, which should be added
separately at a later stage. To facilitate this, some minimal
functionalities are introduced, such as build properties, component
properties, and other helper functions.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00
Island
583cca8f8d Merge branch 'feat/support_blecrt_361' into 'master'
fix(ble/bluedroid): Fixed GATT response timeout setting

Closes BLERP-2041 and BLERP-2042

See merge request espressif/esp-idf!40187
2025-10-30 17:11:19 +08:00
laokaiyao
ff1c14b1a3 refactor(parlio_rx): refactor to support unaligned user payload buffer
Closes https://github.com/espressif/esp-idf/issues/17581
2025-10-30 16:12:34 +08:00
Chen Ji Chang
a177fe6483 Merge branch 'feat/rgb_lcd_memory' into 'master'
feat(rgb_lcd): allow users to manage the lifecycle of the frame buffer

Closes IDF-13917

See merge request espressif/esp-idf!41457
2025-10-30 16:07:15 +08:00
laokaiyao
75eacee3ec refactor(parlio_rx): use gdma_link for better gdma link management 2025-10-30 16:06:12 +08:00
laokaiyao
49284c3f8d feat(gdma_link): support to select final node link type 2025-10-30 16:06:12 +08:00
morris
717312f472 fix(gdma): fixed the race conditon in of gdma resource allocation 2025-10-30 16:05:44 +08:00
wuzhenghui
487f9204dd change(esp_hw_support): esp32p4 rev3.0 dummy read workaround refactor 2025-10-30 14:50:33 +08:00
wuzhenghui
e9da2e3606 fix(esp_hw_support): add p4 rev3.0 MSPI workaround for deepsleep 2025-10-30 14:50:27 +08:00
Shen Meng Jing
b3eaeaea7a Merge branch 'docs/update_cn_translation' into 'master'
docs: Update CN translation for several docs

Closes DOC-12708 and DOC-12686

See merge request espressif/esp-idf!42918
2025-10-30 14:42:01 +08:00
Island
ed0a86ad53 Merge branch 'fix/ble_mesh_adv_rpt_fix' into 'master'
fix(ble_mesh): check data length before assigning adv data pointer

Closes BLERP-2343

See merge request espressif/esp-idf!42976
2025-10-30 14:23:46 +08:00
Island
c705b71ffe Merge branch 'change/ble_update_lib_20251030' into 'master'
change(ble): [AUTO_MR] 20251030 - Update ESP BLE Controller Lib

Closes BLERP-2344

See merge request espressif/esp-idf!42979
2025-10-30 14:23:40 +08:00
Rahul Tank
2738c5ac76 fix(nimble): Address compilation issues in nimble examples 2025-10-30 10:54:36 +05:30
nilesh.kale
e1f7a5e1fc feat: added test_cases for ECC P-384 curve operations 2025-10-30 10:42:40 +05:30
nilesh.kale
b132ab96d3 feat(hal): add support for ESP32-P4 ECO5 ECC peripheral
This commit also enabled constant time mode for ECC.
2025-10-30 10:42:40 +05:30
radek.tandler
fffef09b50 fix(spi-flash): Fixed missing flash write check of non 4-byte aligned data 2025-10-30 12:20:32 +08:00
Shen Mengjing
3e501f5bff docs: Sync EN and CN docs without 'needs translation' label 2025-10-30 12:07:54 +08:00
Chen Ji Chang
0630fe8870 Merge branch 'fix/fix_esp32_rmt_pm_lock_type' into 'master'
fix(rmt): fix pm lock type to increase stability

Closes IDFCI-3746 and IDFCI-3343

See merge request espressif/esp-idf!42970
2025-10-30 11:53:29 +08:00
Zhou Xiao
777f21783b fix(ble): fixed hci event log when link layer logging is disabled 2025-10-30 11:44:37 +08:00
radek.tandler
c16f82b367 fix(spi-flash): Fixed wrong offset calculation in s_verify_write log message 2025-10-30 11:38:40 +08:00
Chen Jichang
73bc04afec feat(esp32h4): switch default h4 build to mp version 2025-10-30 11:23:51 +08:00
Island
338c4c471f Merge branch 'docs/ble_add_low_power_intro' into 'master'
Added BLE Low Power Mode Introduction

See merge request espressif/esp-idf!40106
2025-10-30 11:06:23 +08:00
yinqingzhao
4656a3cc7c fix(wifi): fix some wifi bugs related to bandwidth, twt and regdomain 2025-10-30 10:46:58 +08:00
zhaoweiliang
16a893e934 change(ble): [AUTO_MR] Update lib_esp32c6 to 5b8adfa8 2025-10-30 10:45:18 +08:00
zhaoweiliang
baf8a20a5e change(ble): [AUTO_MR] Update lib_esp32c5 to 5b8adfa8 2025-10-30 10:45:18 +08:00
zhaoweiliang
4e07ce892d change(ble): [AUTO_MR] Update lib_esp32h2 to 5b8adfa8 2025-10-30 10:45:18 +08:00
Jiang Jiang Jian
23455e9fd0 Merge branch 'feat/libphy_c3_s3_c2_rxdc_20250804' into 'master'
feat(phy): update esp32c3 esp32s3 esp32c2 esp32s2 libphy for PHY cali param opt

Closes ESPCS-1019

See merge request espressif/esp-idf!41045
2025-10-29 20:06:46 +08:00
luoxu
6202aa89a6 fix(ble_mesh): check data length before assigning adv data pointer 2025-10-29 20:00:06 +08:00
He Binglin
2e0f0dc66a Merge branch 'test/esp_idf_hp_uart_wakeup' into 'master'
fix(esp_driver_uart): resolve the issue of other chips receiving break data

Closes IDFCI-4616 and IDFCI-4810

See merge request espressif/esp-idf!42952
2025-10-29 19:45:26 +08:00
wanckl
a31e2b4018 refactor(driver_twai): using hal/config in hal layer 2025-10-29 17:46:15 +08:00
wanckl
59d2692bc5 refactor(driver_twai): remove errata config selection 5 2025-10-29 17:46:15 +08:00
wanckl
3bebf1041d refactor(driver_twai): remove errata config selection 4 2025-10-29 17:46:15 +08:00
wanckl
cd483606c9 refactor(driver_twai): remove errata config selection 3 2025-10-29 17:46:15 +08:00
wanckl
66f56f9ed1 refactor(driver_twai): remove errata config selection 2 2025-10-29 17:46:15 +08:00
wanckl
e894d65548 refactor(driver_twai): remove errata config selection 1 2025-10-29 17:45:43 +08:00
Chen Jichang
74b18dac5c feat(rgb_lcd): allow users to manage the lifecycle of the frame buffer 2025-10-29 17:39:18 +08:00
morris
f58a86a82a Merge branch 'feat/deprecate_legacy_twai' into 'master'
feat(driver_twai): add legacy driver deprecated warning

Closes IDF-14261

See merge request espressif/esp-idf!42622
2025-10-29 17:05:26 +08:00
luoxu
29a722296f fix(ble_mesh): fixed incorrect rpl behavior in transport enh 2025-10-29 17:03:51 +08:00
David Čermák
9748cae749 Merge branch 'fix/lwip_sys_mem_frag' into 'master'
[lwip]: Allocate signals/mboxes once to reduce heap frag

Closes IDF-11823

See merge request espressif/esp-idf!42116
2025-10-29 16:10:57 +08:00
David Čermák
113a68fb14 Merge branch 'feat/esp_netif_custom_ip_events' into 'master'
[esp_netif]: Add support for custom got-ip/lost-ip events

Closes IDF-3212

See merge request espressif/esp-idf!42148
2025-10-29 16:09:56 +08:00
Chen Jichang
f9cf0394e5 fix(rmt): fix pm lock type to increase stability 2025-10-29 15:40:31 +08:00
Kevin (Lao Kaiyao)
0d1a38e520 Merge branch 'ci/fixed_parlio_rx_test_case_incorrect_condition' into 'master'
ci(parlio): fixed incorrect condition in rx test case

See merge request espressif/esp-idf!42965
2025-10-29 15:26:41 +08:00
Meet Patel
b340a1ff15 Merge branch 'bugfix/rtc_wdt_test_app' into 'master'
fix(test_rtc_wdt): Fixed CI test failures for RTC WDT by increasing margin

Closes IDFCI-4816, IDFCI-4835, IDFCI-5863, IDFCI-4799, and IDFCI-4817

See merge request espressif/esp-idf!42959
2025-10-29 12:18:22 +05:30
Armando (Dou Yiwen)
12aebb36d0 Merge branch 'feat/c5_flash_psram_timing_tuning_120m' into 'master'
mspi: supported psram & flash 120MHz timing tuning

See merge request espressif/esp-idf!42508
2025-10-29 06:12:32 +00:00
Mahavir Jain
b463f8f1d3 Merge branch 'bugfix/psram_mmap_for_all_targets' into 'master'
fix(esp_psram): make SPIRAM_USE_MEMMAP available for all targets

Closes IDFGH-16669

See merge request espressif/esp-idf!42878
2025-10-29 10:52:51 +05:30
Zhang Shuxian
30832dcbc8 docs: Update CN translation 2025-10-29 11:47:40 +08:00
Marek Fiala
9155e04f06 docs(idf-py.rst): Added cmake preset paragraph 2025-10-29 11:47:40 +08:00
Marek Fiala
1e351a8b67 test(tools): Moved preset parsing into core_ext.py and added tests 2025-10-29 11:47:40 +08:00
Ivan Grokhotkov
78ae7ab085 feat(build): add idf.py support for CMake configuration presets
This commit adds a new idf.py --preset NAME argument, which allows
selecting the CMake configuration preset with a given name.
For idf.py, selecting the preset does two things:
- sets the build directory, which is specified in the preset itself
  using "binaryDir" field
- passes --preset argument to CMake configuration phase

The multi_config example is updated to illustrate how this feature is
expected to be used.
2025-10-29 11:47:40 +08:00
Marek Fiala
86ec7c7d6b Merge branch 'revert/env_locale' into 'master'
Revert "fix: Updated locale handling to prevent issues with build tools"

See merge request espressif/esp-idf!42953
2025-10-29 11:39:58 +08:00
C.S.M
fe29544346 Merge branch 'test/usj_test' into 'master'
test(usj): Fix usj test failure for fsync function

See merge request espressif/esp-idf!42956
2025-10-29 10:41:38 +08:00
Marius Vikhammer
74d5a120c3 Merge branch 'ci/limit_test_app_builds' into 'master'
test(test_apps): set minimal build for misc test-apps

Closes IDF-14198, IDF-14208, IDF-14194, and IDF-14199

See merge request espressif/esp-idf!42921
2025-10-29 03:56:43 +08:00
hebinglin
4e388abd0a fix(esp_driver_uart): resolve the issue of other chips receiving break data 2025-10-28 19:53:46 +08:00
laokaiyao
d229fbcf0f ci(parlio): fixed incorrect condition in rx test case 2025-10-28 18:01:46 +08:00
zhanghaipeng
2dcbd64616 fix(ble/bluedroid): Fixed missing BLE connect and disconnect events 2025-10-28 16:56:07 +08:00
muhaidong
f2af9fa65a feat(phy): update esp32c3 esp32s3 esp32c2 esp32s2 libphy for RXDC 2025-10-28 15:40:04 +08:00
Wei Yu Han
8c90e65db6 docs(ble): Optimized the BLE low power guide 2025-10-28 13:00:39 +08:00
Wei Yuhan
13b04ab89e docs(ble): Replaced the current table with the link to the Power Save README 2025-10-28 13:00:39 +08:00
Wei Yuhan
c55a1180eb docs(ble): Fixed the common operation path for all chips 2025-10-28 13:00:39 +08:00
Wei Yuhan
acc8a99aae docs(ble): Replaced BLE with Bluetooth LE 2025-10-28 13:00:39 +08:00
Wei Yuhan
19fc7319c6 docs(ble): Revisied BLE Low Power Giude 2025-10-28 13:00:39 +08:00
weiyuhan
1e84dea7d0 Added BLE Low Power Mode Introduction 2025-10-28 13:00:39 +08:00
Meet Patel
4b7a049ad7 fix(test_rtc_wdt): Fixed CI test failures for RTC WDT by increasing margin
The CI tests for RTC WDT test app were failing because we allowed only
20% margin between configured vs actual timeout of wdt. However, the
RC oscillator accuracy on some boards is very poor and it results in
almost 25% difference between configured and actual timeout. Hence,
increased the failure margin from 20% to 30%. Also some boards like
ESP32P4 have known problem and gives timeout after twice the configured
time. Hence, increased the wdt interrupt wait time to three times the
configured value, so we don't miss the interrupts for such boards.
2025-10-28 09:54:54 +05:30
C.S.M
9c7ef954b1 test(usj): Fix usj test 2025-10-28 11:51:37 +08:00
wuzhenghui
596e32312e fix(esp_hw_support): fix mie lost after pd_cpu sleep request reject 2025-10-28 11:51:17 +08:00
wuzhenghui
fcb76189aa change(esp_hw_support): set HP/LP mem in retention mode in sleep 2025-10-28 11:51:13 +08:00
He Binglin
87d18b0d3d Merge branch 'feat/esp_idf_esp32h4h21_gpioworkaround' into 'master'
feat(esp_hw_support): add gpio reset workaround in chips except ESP32 and ESP32S2

Closes PM-602

See merge request espressif/esp-idf!42512
2025-10-28 11:39:47 +08:00
C.S.M
6659af07c8 Merge branch 'fix/soft_resume' into 'master'
fix(spi_flash): Fix software resume wrong config name in flash init

See merge request espressif/esp-idf!42697
2025-10-28 11:17:22 +08:00
Marek Fiala
3c9ad9c091 Revert "fix: Updated locale handling to prevent issues with build tools"
This reverts commit 7e09b471ab.
2025-10-28 04:02:21 +01:00
wanckl
029ac60144 feat(driver_twai): add legacy driver deprecated warning 2025-10-28 10:54:48 +08:00
Marius Vikhammer
27059a16f8 test(test_apps): set minimal build for misc test-apps 2025-10-28 10:17:41 +08:00
armando
755ee49b72 feat(mspi): supported psram & flash 120MHz timing tuning 2025-10-28 09:52:36 +08:00
Michael (XIAO Xufeng)
06dfc5eda2 Merge branch 'doc/compatibility_add_p4_1.3' into 'master'
compatibility: update chip revision compatibility docs

See merge request espressif/esp-idf!42722
2025-10-28 00:40:23 +08:00
morris
6fd24b6f5b Merge branch 'bugfix/fix_gptimer_premature_match_partial_data' into 'master'
fix(gptimer): update regex patterns in example test to include non-digit characters

Closes IDFCI-4481

See merge request espressif/esp-idf!42911
2025-10-27 23:53:17 +08:00
Rahul Tank
4beeff6694 Merge branch 'feat/read_all_local_remote_sup_feat' into 'master'
feat(nimble): Add support for read all local / remote supported features / adv monitor HCI cmd

See merge request espressif/esp-idf!42183
2025-10-27 21:21:47 +05:30
harshal.patil
fbcb51653a fix(hal): Fix MMU PSRAM anti-fi MMU target check
In case of ESP32-C5 and ESP32-C61, mmu_ids for PSRAM and Flash
MMU are the same due to their shared memory space. Thus, instead of
mmu_id we should use mmu_target_t.
2025-10-27 19:10:48 +05:30
Jiang Jiang Jian
d4b4762707 Merge branch 'bugfix/fix_tkip_fragment_issue' into 'master'
fix(wifi): fix fragment issue with wpa tkip encryption

Closes WIFI-7080 and WIFIBUG-1505

See merge request espressif/esp-idf!42817
2025-10-27 21:26:58 +08:00
Ondrej Kosta
86c9decedc Merge branch 'fix/eth_connect' into 'master'
fix(esp_eth): made LAN8720 test write register function more robust

See merge request espressif/esp-idf!42856
2025-10-27 18:57:12 +08:00
Song Ruo Jing
fab48ae1b7 Merge branch 'feature/ledc_etm_support' into 'master'
feat(ledc): add ETM support for LEDC peripheral

Closes IDF-6355, IDFGH-10620, IDFGH-16378, and IDF-10683

See merge request espressif/esp-idf!41543
2025-10-27 18:28:20 +08:00
Abhik Roy
27a76f5a36 Merge branch 'examples/vlan_test_fix' into 'master'
fix: Reorder Ethernet initialization in VLAN example

Closes IDFCI-3146, IDFCI-3145, IDFCI-3144, IDFCI-5092, IDFCI-5091, and IDFCI-5090

See merge request espressif/esp-idf!42401
2025-10-27 18:27:09 +08:00
Ondrej Kosta
eb7c6a0df4 fix(examples): fixed bridge example test endnode to host send 2025-10-27 10:38:20 +01:00
chenjianhua
b936d0075c fix(ble/bluedroid): Fixed GATT response timeout setting 2025-10-27 17:34:52 +08:00
Li Shuai
7795570721 Merge branch 'docs/pm-548' into 'master'
support esp32c5 system and wifi low power programming guide docs

Closes PM-548

See merge request espressif/esp-idf!42572
2025-10-27 17:29:57 +08:00
morris
1d809c5e9c Merge branch 'bugfix/fix_lcd_coverity_warnings' into 'master'
fix(lcd): refactor get_frame_buffer functions to fix Coverity warnings

Closes IDF-13896

See merge request espressif/esp-idf!42876
2025-10-27 17:08:33 +08:00
Jiang Jiang Jian
f5f005247e Merge branch 'docs/remove_doxy_groups_in_espnow' into 'master'
fix(wifi/espnow): Remove doxygen groups as esp-docs is flat docs style

See merge request espressif/esp-idf!42737
2025-10-27 15:38:29 +08:00
Marius Vikhammer
a95eb187fb Merge branch 'ci/add_test_wdt_helper' into 'master'
test(core): add WDT protection to detect stuck tests

See merge request espressif/esp-idf!42828
2025-10-27 14:46:58 +08:00
Jiang Jiang Jian
1ff8cadfc9 Merge branch 'fix/fix_esp32p4_cache_error_false_alarm_after_wakeup' into 'master'
fix(esp_hw_support): esp32p4 eco5 hardware issues workaround

Closes PM-558

See merge request espressif/esp-idf!42626
2025-10-27 14:45:29 +08:00
Meet Patel
fbe73cce82 Merge branch 'bugfix/esp_event_performance_test_fix' into 'master'
fix(esp_event): Updated minimum events dispatched test pass criteria

Closes IDF-12299

See merge request espressif/esp-idf!42714
2025-10-27 12:04:57 +05:30
Shu Chen
7bb8a95403 Merge branch 'feat/allow_set_ot_netif_config' into 'master'
feat: allow set ot netif config

See merge request espressif/esp-idf!42847
2025-10-27 06:34:46 +00:00
Marius Vikhammer
7b6d81ebb8 Merge branch 'ci/split_system_build_test' into 'master'
test(system): restructured system build test test-apps

Closes IDF-14206

See merge request espressif/esp-idf!42320
2025-10-27 14:32:43 +08:00
Shen Mengjing
5339194a11 docs: Update CN translation for several docs 2025-10-27 14:21:11 +08:00
5b56b00ac8 feat(esp_http_server): Allow the https server to request client certs optionally
Closes https://github.com/espressif/esp-idf/pull/17641
2025-10-27 14:19:17 +08:00
morris
e3cf730cfa fix(gptimer): update regex patterns in example test to include non-digit characters
This prevents premature matching on partial data when the output is
being streamed, which was causing the test to capture 100000 instead of
the full 1000002.
2025-10-27 14:18:09 +08:00
Mahavir Jain
23c04b681e Merge branch 'feat/esp_tee_mspi_tuning' into 'master'
change(esp_tee): Fix TEE SPI flash API issues on ESP32-C5

Closes IDF-13826

See merge request espressif/esp-idf!41952
2025-10-27 10:09:29 +05:30
Shu Chen
100a45cbe4 Merge branch 'feat/support_dhcpv6' into 'master'
feat(openthread): support OT upstream dhcpv6 feature

See merge request espressif/esp-idf!40053
2025-10-27 04:16:31 +00:00
Shu Chen
9a53a10319 Merge branch 'feat/ot_timing_optimization' into 'master'
feat(openthread): add kconfig option for timing optimization

See merge request espressif/esp-idf!42825
2025-10-27 04:13:14 +00:00
Shu Chen
8193de8a80 Merge branch 'change/154_cca_threshold' into 'master'
change(802.15.4): change the default cca threshold to -75dBm

See merge request espressif/esp-idf!42824
2025-10-27 04:12:31 +00:00
morris
3ed6979a4d Merge branch 'fix/anacmpr_etm_test' into 'master'
fix(test): deley some time to ensure gptimer is stopped

Closes IDFCI-3431, IDFCI-3432, and IDFCI-3525

See merge request espressif/esp-idf!42863
2025-10-27 11:02:56 +08:00
Ashish Sharma
5b8cd3f626 fix: fix unused value in esp uart driver 2025-10-27 11:02:48 +08:00
muhaidong
369c6e8300 fix(wifi): fix fragment issue with wpa tkip encryption 2025-10-27 10:40:18 +08:00
Jiang Jiang Jian
c83ea47012 Merge branch 'bugfix/fix_espnow_offchan_crash_issue' into 'master'
fix(wifi/espnow): fix the crash issue when using espnow off channel tx

Closes WIFI-7011 and WIFI-7074

See merge request espressif/esp-idf!42633
2025-10-27 10:35:06 +08:00
Jiang Jiang Jian
ff97953b32 Merge branch 'ci/switch_to_v6.1' into 'master'
Start of v6.1 development

See merge request espressif/esp-idf!42808
2025-10-27 10:32:24 +08:00
morris
d0c49385e1 fix(lcd): refactor get_frame_buffer functions to fix Coverity warnings
Refactored esp_lcd_rgb_panel_get_frame_buffer and
esp_lcd_dpi_panel_get_frame_buffer
to follow the standard printf/vprintf pattern:

- Created static _v helper functions that take va_list as parameter
- Moved parameter validation to the public API functions
- Public functions now handle va_start/va_end and call the helper
2025-10-27 10:10:57 +08:00
Marius Vikhammer
cd741e995f test(system): restructured system build test test-apps 2025-10-27 09:25:07 +08:00
Ashish Sharma
acf89924c8 feat(esp_http): migrate esp_http to PSA API 2025-10-26 10:13:14 +08:00
Mahavir Jain
68c8f46158 fix(esp_psram): make SPIRAM_USE_MEMMAP available for all targets
This reverts earlier commit d2858847 and thereby making SPIRAM_USE_MEMMAP
available for all targets.

This config option has no direct usage but just avoids adding the PSRAM
to heap but still keeps it memory mapped.

Closes https://github.com/espressif/esp-idf/issues/17764
2025-10-24 14:21:14 +05:30
Xu Si Yu
f05099871e feat(openthread): update examples for API changes 2025-10-24 15:59:56 +08:00
Xu Si Yu
5759c4ca27 feat(openthread): support custom netif config during initialization 2025-10-24 15:59:51 +08:00
Roland Dobai
f21b4c2381 change(version): Update version to 6.1-dev
Start of v6.1 development
2025-10-24 09:01:34 +02:00
Song Ruo Jing
d76364c2a4 Merge branch 'bugfix/uart_get_tx_buffer_free_size' into 'master'
fix(uart): correct uart_get_tx_buffer_free_size calculation

Closes IDFGH-15188

See merge request espressif/esp-idf!42701
2025-10-24 14:30:39 +08:00
David Čermák
d878a786fd Merge branch 'fix/netif_enable_lostip_timer' into 'master'
[esp_netif]: Enable/disable the lost-ip-timer explicitely

Closes IDF-10922

See merge request espressif/esp-idf!42044
2025-10-24 14:23:33 +08:00
David Čermák
42abb32a86 Merge branch 'fix/netif_verbose_level_for_trace' into 'master'
[esp_netif]: Change debug->verbose level for tracing logs

Closes IDFGH-12320

See merge request espressif/esp-idf!42344
2025-10-24 14:19:40 +08:00
Mahavir Jain
9172ed9727 Merge branch 'fix/fix_host_transport_ci_test' into 'master'
fix: fix failing test_transport_on_host test in the CI pipeline

See merge request espressif/esp-idf!42621
2025-10-24 11:10:40 +05:30
David Čermák
8a64cc15a5 Merge branch 'feat/netif_mtu_path_disc' into 'master'
[esp_netif]: Support for MTU path discovery

Closes IDFGH-10355 and IDFGH-14560

See merge request espressif/esp-idf!42088
2025-10-24 13:29:03 +08:00
Island
94d2e8eff0 Merge branch 'change/ble_update_lib_20251022' into 'master'
change(ble): [AUTO_MR] 20251022 - Update ESP BLE Controller Lib

Closes BLERP-2329, BLERP-2315, BLERP-2316, BLERP-2325, BLERP-2256, BLERP-2326, BLERP-2327, BLERP-2328, BLERP-2330, BLERP-2331, BLERP-2302, BLERP-2300, and BLERP-2301

See merge request espressif/esp-idf!42821
2025-10-24 13:17:29 +08:00
Marius Vikhammer
f04d9ac50e Merge branch 'ci/ulp_fsm_reset_between_tests' into 'master'
ci(ulp): reset board between ulp-fsm tests

Closes IDFCI-3334 and IDFCI-3336

See merge request espressif/esp-idf!42857
2025-10-24 12:22:15 +08:00
morris
8b3e5b297b fix(test): deley some time to ensure gptimer is stopped 2025-10-24 11:38:49 +08:00
Marius Vikhammer
113d69f188 test(core): add WDT protection to detect stuck tests 2025-10-24 10:48:13 +08:00
C.S.M
af0187ebaf fix(spi_flash): Fix software resume wrong config name in flash init 2025-10-24 10:35:40 +08:00
Guillaume Souchere
67b258d55a Merge branch 'fix/console-deinit-test-threshold' into 'master'
fix(console): Update the leak threashold after struct update in intr_alloc.c

See merge request espressif/esp-idf!42809
2025-10-24 04:28:12 +02:00
Marius Vikhammer
865f0f4f0e ci(ulp): reset board between ulp-fsm tests 2025-10-24 10:15:35 +08:00
zhangyanjiao
345fcf2834 fix(wifi/espnow): Remove doxygen groups as esp-docs is flat docs style 2025-10-24 10:08:02 +08:00
Kevin (Lao Kaiyao)
37b8f8f3e6 Merge branch 'bugfix/fix_touch_curr_scan_workaround_on_p4' into 'master'
fix(esp32p4): P4 touch channel 14 failure fix

Closes IDFGH-16661

See merge request espressif/esp-idf!42818
2025-10-24 04:46:39 +08:00
David Čermák
b3afa26a60 Merge branch 'feat/netif_sntp_events' into 'master'
[esp_netif]: Support posting event on SNTP time updates

Closes IDF-1729

See merge request espressif/esp-idf!42075
2025-10-24 04:42:00 +08:00
David Čermák
4a59e94b4e Merge branch 'fix/lwip_dhcps_fuzz' into 'master'
[lwip]: Fix dhcp server minor issues found when fuzzing

See merge request espressif/esp-idf!42315
2025-10-24 04:41:24 +08:00
Ondrej Kosta
0640d918bb fix(esp_eth): made LAN8720 test write register function more robust 2025-10-23 15:30:15 +02:00
Tomas Rohlinek
06004072cb Merge branch 'feat/vfs_disable_termios_by_default' into 'master'
feat(storage/vfs): Disable termios support by default

Closes IDF-7998

See merge request espressif/esp-idf!42175
2025-10-23 13:25:11 +02:00
Tomas Rohlinek
734c1725fb Merge branch 'feat/fatfs_update_default_options' into 'master'
feat(storage/fatfs): Update default configuration to better fit average usecase

Closes IDF-14042

See merge request espressif/esp-idf!42174
2025-10-23 13:23:13 +02:00
Michael (XIAO Xufeng)
746485f640 Merge branch 'fix/cpu_reset_dma' into 'master'
dma: fixed issue that DMA are not reset when CPU reset

See merge request espressif/esp-idf!41512
2025-10-23 16:26:57 +08:00
Song Ruo Jing
cc3577e31a feat(ledc): add ETM support for LEDC peripheral
Closes https://github.com/espressif/esp-idf/issues/11855
2025-10-23 16:24:11 +08:00
Song Ruo Jing
21237012e6 change(example/ledc): add power management support for the example
Closes https://github.com/espressif/esp-idf/issues/17517
2025-10-23 16:24:11 +08:00
Song Ruo Jing
4fb40fa91a fix(console): wrong uart console pin info when UART console is not used 2025-10-23 16:24:11 +08:00
Song Ruo Jing
5a3eda65df fix(uart): fix -Wunused-parameter warning with uart.h 2025-10-23 16:24:11 +08:00
Li Shuai
bb29315083 docs(Power Management): support esp32c5 system and wifi low power programming guide docs 2025-10-23 15:33:15 +08:00
Tan Yan Quan
0153494eec feat(openthread): add kconfig option for timing optimization 2025-10-23 14:49:04 +08:00
zhangyanjiao
07c74dfd1a fix(wifi/espnow): fix the crash issue when using espnow off channel tx 2025-10-23 14:30:00 +08:00
David Cermak
a6b216ac22 fix(esp_netif): Change debug->verbose level for tracing logs 2025-10-23 13:57:11 +08:00
David Cermak
787bb39765 feat(esp_netif): Support posting event on SNTP time update 2025-10-23 13:56:02 +08:00
David Čermák
6bfcd4b41c Merge branch 'fix/netif_igmp_cb' into 'master'
[esp_netif]: Fix calling IGMP callbacks after igmp_init()

Closes IDF-13554

See merge request espressif/esp-idf!42310
2025-10-23 13:53:51 +08:00
David Čermák
406c7f3ec6 Merge branch 'fix/netif_deprecated_inc' into 'master'
[lwip]: Removed deprecated headers

Closes IDF-6414

See merge request espressif/esp-idf!41868
2025-10-23 13:51:26 +08:00
David Cermak
4709069e13 fix(lwip): Fix dhcp-server to use callback only if configured 2025-10-23 13:49:21 +08:00
David Cermak
0cc53db591 fix(lwip): Fix dhcp-server to mem_free() items allocated by mem_alloc() 2025-10-23 13:49:21 +08:00
David Cermak
4c69bf826f feat(esp_netif): Add support for initial MTU in netif config
Closes https://github.com/espressif/esp-idf/issues/15319
2025-10-23 07:41:42 +02:00
Meet Patel
510a7f792e fix(esp_event): Updated minimum events dispatched test pass criteria
For the dual core chips like ESP32H4 that are running on slow CPU
clock frequency (96MHz), the number of events getting dispatched in
the test case called "performance test - no dedicated task" were
falling short of expectation because of extra overhead with locks
etc when runing with a non dedicated task. Even for other chips like
ESP32S3, if the main CPU core is running at 80MHz, the result is same.
Hence, added a consideration for CPU clock frequency when deciding
pass criteria for this test case.
2025-10-23 10:32:19 +05:30
Gao Xu
23dc9a9f47 Merge branch 'fix/esp32_adc_continuous_loss_sample' into 'master'
Fix/esp32 adc continuous loss sample

Closes IDFGH-9225, IDF-8427, and FCS-1773

See merge request espressif/esp-idf!41933
2025-10-23 12:50:06 +08:00
morris
920efaabbd Merge branch 'feat/esp_hal_lcd' into 'master'
feat(hal):graudate the LCD hal driver into a new component

Closes IDF-13676 and IDF-14100

See merge request espressif/esp-idf!42751
2025-10-23 12:36:59 +08:00
Rahul Tank
d27fb27181 feat(nimble): Add support for HCI commands / events
1. Read all local supported feature
      2. Read remote supported feature
      3. Advertising monitor.
2025-10-23 09:52:25 +05:30
Tan Yan Quan
35f5dcf16d feat(openthread): update thread-lib for new OT upstream 36b14d3ef
* esp-openthread: thread_zigbee/esp-openthread@397da59b2
* openthread: espressif/openthread@36b14d3ef
* esp-idf: espressif/esp-idf@49a872fc6
2025-10-23 04:21:24 +00:00
zhaoweiliang
96bdca38a1 feat(ble): add priority level config on ESP32-C5 2025-10-23 11:25:42 +08:00
zhaoweiliang
75f2b8d4a1 feat(ble): add priority level config on ESP32-H2 2025-10-23 11:25:42 +08:00
zhaoweiliang
09337109b7 feat(ble): add priority level config on ESP32-C6 2025-10-23 11:25:37 +08:00
C.S.M
19fef9f5ac Merge branch 'refactor/remove_flash_rom_patch_cfg' into 'master'
refactor(spi_flash): Remove spi_flash rom driver patch config option

Closes IDF-1578

See merge request espressif/esp-idf!42108
2025-10-23 11:24:46 +08:00
Shu Chen
49824abf08 change(802.15.4): change the default cca threshold to -75dBm 2025-10-23 10:54:17 +08:00
laokaiyao
c253f82bec ci(touch): add test case for the curr measuring channel 2025-10-23 10:47:48 +08:00
Pete Kabaragoya
7adc84467f fix(esp32p4): P4 touch channel 14 failure fix
Merges https://github.com/espressif/esp-idf/pull/17759

Core dump when using all touch channels on a P4 unless curr_chan is allowed to be 14
2025-10-23 10:47:48 +08:00
Wang Meng Yang
f95a5f5231 Merge branch 'bugfix/oob_in_avrc_vendor_msg' into 'master'
fix(bt/bluedroid): fixed potential OOB in AVRCP vendor command composition

Closes BT-4130

See merge request espressif/esp-idf!42410
2025-10-23 09:52:42 +08:00
wuzhenghui
8741edd26d test(esp_pm): add test case for USJ printing performance during wake-up
Add a new test case to verify that USJ printing doesn't block CPU on chip
wake-up from light sleep. The test measures the average time per print
operation and ensures it's below 5000 microseconds.
2025-10-22 17:57:32 +08:00
wuzhenghui
8b87565b53 fix(esp_driver_usb_serial_jtag): check USJ accessibility before read/write
Add connection checks to usb_serial_jtag_write and usb_serial_jtag_read
functions to return -EIO error code when the USB Serial JTAG is not
connected.
2025-10-22 17:57:32 +08:00
cjin
5ff01bf027 fix(ble): fix ble wakeup causes error on ESP32-H2 2025-10-22 17:50:53 +08:00
cjin
4d1872c66d fix(ble): fix ble wakeup causes error on ESP32-C6 2025-10-22 17:50:47 +08:00
cjin
350ae64dad fix(ble): fix ble wakeup causes error on ESP32-C5 2025-10-22 17:50:40 +08:00
cjin
5407e36e4a fix(ble): fix ble wakeup causes error on ESP32-C2 2025-10-22 17:50:35 +08:00
Zhou Xiao
557b7bae2e change(ble): [AUTO_MR] updated rom linker script for ESP32-C2 2025-10-22 17:48:43 +08:00
Zhou Xiao
ee2c7247fb change(ble): [AUTO_MR] Update lib_esp32c2 to 283861b8 2025-10-22 17:48:41 +08:00
Zhou Xiao
f4d881ff59 change(ble): [AUTO_MR] Update lib_esp32c6 to a76948d4 2025-10-22 17:48:41 +08:00
Zhou Xiao
f4ebf33964 change(ble): [AUTO_MR] Update lib_esp32c5 to a76948d4 2025-10-22 17:48:41 +08:00
Zhou Xiao
ab5c1b0e3b change(ble): [AUTO_MR] Update lib_esp32h2 to a76948d4 2025-10-22 17:48:41 +08:00
Tan Yan Quan
49a872fc6c feat(openthread): support OT upstream dhcpv6 feature 2025-10-22 17:28:48 +08:00
Tan Yan Quan
60ccb1a3bf feat(openthread): update OT upstream to 36b14d3ef 2025-10-22 17:28:24 +08:00
morris
d4d8b09ced feat(hal):graudate the LCD hal driver into a new component
- Introduced new HAL components for LCD and MIPI DSI, including:
  - `lcd_hal.c` and `lcd_hal.h` for LCD hardware abstraction layer.
  - `mipi_dsi_hal.c` and `mipi_dsi_hal.h` for MIPI DSI hardware
abstraction layer.
  - Peripheral connection definitions in `lcd_periph.c` and
`lcd_periph.h`.
  - Added necessary types and utility functions in `lcd_types.h` and
`mipi_dsi_types.h`.

- Updated CMakeLists to include the new HAL components in the build
system.
- Removed legacy references to LCD and MIPI DSI in the HAL and SOC
CMakeLists.
2025-10-22 17:00:18 +08:00
Guillaume Souchere
018cd86846 fix(console): Update the leak threashold after struct update in intr_alloc.c 2025-10-22 09:24:40 +02:00
Laukik Hase
eb74a5f9dd feat(esp_tee): Enable MSPI tuning for Flash and PSRAM 2025-10-22 11:44:34 +05:30
Laukik Hase
02cb0425b9 fix(esp_tee): Handle the SPI1 WB mode incompatibility in TEE flash APIs on ESP32-C5
- When `esp_flash_read()` is invoked from REE, it internally enables WB mode
  via `spi_flash_ll_wb_mode_enable()`. However, the ROM flash APIs used by TEE
  do not support WB mode, resulting in failures when TEE attempts to access
  flash after this call.
- This commit adds a workaround in the TEE flash layer by saving WB mode state,
  temporarily disabling it for ROM API calls, and restoring it afterward.
2025-10-22 11:44:34 +05:30
Laukik Hase
71aff04c0d fix(esp_tee): Use HAL APIs instead of ROM APIs for SPI flash service calls
Currently, REE SPI flash HAL operations are routed as service calls to TEE,
but the TEE implementation incorrectly uses ROM APIs instead of HAL APIs.
This leads to issues and is not the recommended approach.
2025-10-22 11:44:33 +05:30
C.S.M
c81cf3bdf6 refactor(spi_flash): Remove spi_flash rom driver patch config option 2025-10-22 10:37:19 +08:00
gaoxu
97a3b51d11 fix(adc): fix ESP32 ADC continuous loss sample times 2025-10-22 10:11:18 +08:00
jojo2massol
b801fa0f70 fix(examples/captive_portal): Fixed indexing in DNS server IP address retrieval 2025-10-20 17:16:24 +02:00
David Cermak
62fd7276b4 feat(esp_netif): Add support for custom got-ip/lost-ip events 2025-10-20 13:46:24 +02:00
David Cermak
37a711d829 fix(esp_netif): Enable/disable the lost-ip-timer explicitely
Previously we had to set the timer to 0 to disable it completely,
    now we have a specific config option to switch it on/off
2025-10-20 18:40:51 +08:00
David Cermak
a80c9ef7ab fix(esp_netif): Fix calling IPv6 MLD callbacks after netif_init() 2025-10-20 12:38:55 +02:00
David Cermak
91bb47ec68 fix(esp_netif): Fix calling IGMP callbacks after igmp_init() 2025-10-20 12:38:55 +02:00
David Cermak
0b319e1670 fix(esp_err): Regenerated esp_err_to_name after lwip header removed 2025-10-20 17:51:39 +08:00
David Cermak
18907c2c8f fix(lwip): Remove deprecated ping wrappers over lwip raw api 2025-10-20 17:51:39 +08:00
David Cermak
a04c5ba9bc fix(esp_netif): Remove deprecated sntp.h 2025-10-20 17:51:39 +08:00
David Cermak
fdd86721e7 feat(esp_netif): Support for MTU path discovery
Closes https://github.com/espressif/esp-idf/issues/11613
2025-10-20 11:43:36 +02:00
Abhik Roy
fc197edc29 fix: Reorder Ethernet initialization in VLAN example
- Moved `ethernet_init_all` to after default event loop creation
  to ensure the event loop exists before Ethernet driver initialization.
2025-10-20 20:43:34 +11:00
David Cermak
5a9d6a5027 fix(lwip): Allocate signals/mboxes once to reduce heap frag 2025-10-20 11:21:30 +02:00
Song Ruo Jing
c062cd9a95 fix(uart): correct uart_get_tx_buffer_free_size calculation
Modified a bit on the TX ring buffer push size logic

 Closes https://github.com/espressif/esp-idf/issues/15859
2025-10-20 16:24:21 +08:00
wuzhenghui
a36983c784 change(esp_hw_support): set HP LDO powerdown in sleep by default 2025-10-20 15:56:16 +08:00
wuzhenghui
1bb84c07ad change(esp_hw_support): set HP/LP mem in retention mode in sleep 2025-10-20 15:56:16 +08:00
wuzhenghui
b71a6ce55a change(esp_hw_support): update TOP pd sleep dependency
Disable peripheral powerdown lightsleep if PSRAM if enabled on P4 v3
Force powerdown Flash if peripheral power down lightsleep is enabled
2025-10-20 15:56:15 +08:00
wuzhenghui
2bb369f542 fix(esp_hw_support): add PD_TOP lightsleep mspi failure workaround for p4 rev3 2025-10-20 15:56:15 +08:00
wuzhenghui
c7dddbb35d fix(esp_hw_support): fix esp32p4 v3 cache error false alarm after PD_TOP wakeup 2025-10-20 15:56:15 +08:00
hebinglin
77dc17dc60 feat(esp_hw_support): add gpio reset workaround in esp32h21 & esp32h4 2025-10-20 11:13:59 +08:00
Xiao Xufeng
40dd5e3957 dma: fixed issue that DMA are not reset when CPU reset
When DMA keep writing the memory, some data may be corrupted after reset. For example, the stack of bootloader may be overwritten and failed to boot until a higher scope of reset (Core).

Also removed the DPORT_PERIP_RST_EN_REG alias on ESP32S2. Now it's the same as some following chips (EN0).
2025-10-20 01:34:32 +08:00
Xiao Xufeng
676dc207e6 docs(compatibility): update chip revision compatibility docs 2025-10-20 01:31:01 +08:00
Ashish Sharma
8f0a19d169 fix: fix the failing tcp_transport host test in the CI 2025-10-16 11:47:08 +08:00
Tomáš Rohlínek
f6ba0d8aa0 feat(storage/fatfs): Update default configuration to better fit average usecase 2025-10-15 09:30:02 +02:00
Tomáš Rohlínek
d99e984a90 feat(storage/vfs): Disable termios support by default 2025-10-15 09:29:34 +02:00
Jin Cheng
565fa98d0c fix(bt/bluedroid): fixed potential OOB in AVRCP vendor command composition 2025-10-14 11:55:47 +08:00
Adam Múdry
3eb74a7e95 fix(sdspi): esp_driver_sdpsi test app increase timeout to 180 2025-10-09 15:13:23 +02:00
JinCheng
fb04218563 fix(bt/bluedroid): update the COD before enabling inquiry scan 2025-08-25 15:53:48 +08:00
2735 changed files with 492207 additions and 46932 deletions

View File

@@ -26,7 +26,7 @@ body:
id: chip_revision
attributes:
label: Espressif SoC revision.
description: On which Espressif SoC revision does your application run on? Run `esptool chip-id` to find it.
description: On which Espressif SoC revision does your application run on? Run `esptool chip-id` (or `esptool.py chip_id` for ESP-IDF v5.5 and older) to find it.
placeholder: ex. ESP32-C3 (QFN32) (revision v0.3)
validations:
required: true

View File

@@ -16,18 +16,17 @@ workflow:
# Place the default settings in `.gitlab/ci/common.yml` instead
include:
- '.gitlab/ci/danger.yml'
- '.gitlab/ci/common.yml'
- '.gitlab/ci/rules.yml'
- '.gitlab/ci/upload_cache.yml'
- '.gitlab/ci/docs.yml'
- '.gitlab/ci/static-code-analysis.yml'
- '.gitlab/ci/pre_commit.yml'
- '.gitlab/ci/pre_check.yml'
- '.gitlab/ci/build.yml'
- '.gitlab/ci/integration_test.yml'
- '.gitlab/ci/host-test.yml'
- '.gitlab/ci/deploy.yml'
- '.gitlab/ci/post_deploy.yml'
- '.gitlab/ci/retry_failed_jobs.yml'
- '.gitlab/ci/test-win.yml'
- ".gitlab/ci/danger.yml"
- ".gitlab/ci/common.yml"
- ".gitlab/ci/rules.yml"
- ".gitlab/ci/upload_cache.yml"
- ".gitlab/ci/docs.yml"
- ".gitlab/ci/static-code-analysis.yml"
- ".gitlab/ci/pre_commit.yml"
- ".gitlab/ci/pre_check.yml"
- ".gitlab/ci/build.yml"
- ".gitlab/ci/integration_test.yml"
- ".gitlab/ci/host-test.yml"
- ".gitlab/ci/deploy.yml"
- ".gitlab/ci/post_deploy.yml"
- ".gitlab/ci/test-win.yml"

View File

@@ -122,6 +122,7 @@
/components/esp_tee/ @esp-idf-codeowners/security
/components/esp_timer/ @esp-idf-codeowners/system
/components/esp-tls/ @esp-idf-codeowners/app-utilities
/components/esp_trace/ @esp-idf-codeowners/debugging
/components/esp_usb_cdc_rom_console/ @esp-idf-codeowners/system @esp-idf-codeowners/peripherals/usb
/components/esp_wifi/ @esp-idf-codeowners/wifi
/components/espcoredump/ @esp-idf-codeowners/debugging
@@ -165,6 +166,7 @@
/docs/ @esp-idf-codeowners/docs
/docs/docs_not_updated/ @esp-idf-codeowners/all-maintainers
/docs/**/api-guides/tools/ @esp-idf-codeowners/tools
/docs/**/api-guides/kconfig/ @esp-idf-codeowners/tools
/docs/en/api-guides/core_dump.rst @esp-idf-codeowners/debugging
/docs/**/api-guides/wifi* @esp-idf-codeowners/wifi
/docs/**/api-guides/esp-wifi-mesh.rst @esp-idf-codeowners/wifi
@@ -213,6 +215,7 @@
/tools/ci/ @esp-idf-codeowners/ci
/tools/cmake/ @esp-idf-codeowners/build-config
/tools/cmake/toolchain-*.cmake @esp-idf-codeowners/toolchain
/tools/cmakev2/ @esp-idf-codeowners/build-config
/tools/esp_app_trace/ @esp-idf-codeowners/debugging
/tools/gdb_panic_server.py @esp-idf-codeowners/debugging
/tools/kconfig*/ @esp-idf-codeowners/build-config

View File

@@ -1,20 +1,66 @@
.build_template:
stage: build
extends:
- .after_script:build:ccache-show-stats:upload-failed-job-logs
- .before_script:build
- .after_script:build
image: $ESP_ENV_IMAGE
tags: [build, shiny]
variables:
# Enable ccache for all build jobs. See configure_ci_environment.sh for more ccache related settings.
IDF_CCACHE_ENABLE: "1"
dependencies: []
dependencies: # set dependencies to null to avoid missing artifacts issue
######################
# build_template_app #
######################
.build_template_app_template:
extends:
- .build_template
artifacts:
paths:
- log_template_app/*
- size_info.txt
- build_template_app/**/size*.json
expire_in: 1 week
when: always
script:
# Set the variable for 'esp-idf-template' testing
- ESP_IDF_TEMPLATE_GIT=${ESP_IDF_TEMPLATE_GIT:-"https://github.com/espressif/esp-idf-template.git"}
- retry_failed git clone ${ESP_IDF_TEMPLATE_GIT}
# Try to use the same branch name for esp-idf-template that we're
# using on esp-idf. If it doesn't exist then just stick to the default branch
- python $CHECKOUT_REF_SCRIPT esp-idf-template esp-idf-template
- export PATH="$IDF_PATH/tools:$PATH"
# Only do the default cmake build for each target, remaining part are done in the build_template_app job
- tools/ci/build_template_app.sh ${BUILD_COMMAND_ARGS}
# Build at least one project for each target at earliest stage to reduce build cost for obvious failing commits
fast_template_app:
extends:
- .build_template_app_template
- .rules:build
stage: pre_check
tags: [fast_run, shiny]
variables:
BUILD_COMMAND_ARGS: "-p"
# This job builds template app with permutations of targets and optimization levels
build_template_app:
extends:
- .build_template_app_template
- .rules:build
stage: host_test
needs:
- job: fast_template_app
artifacts: false
########################################
# Clang Build Apps Without Tests Cases #
########################################
.build_cmake_clang_template:
extends:
- .build_template
- .before_script:build
- .after_script:build:ccache-show-stats
dependencies: # set dependencies to null to avoid missing artifacts issue
- .rules:build
needs:
- job: fast_template_app
artifacts: false
@@ -28,7 +74,7 @@
- "**/build*/build_log.txt"
# keep the size info to help track the binary size
- size_info.txt
- "**/build*/size.json"
- "**/build*/size*.json"
expire_in: 1 week
when: always
variables:
@@ -45,92 +91,14 @@
--modified-files ${MR_MODIFIED_FILES}
$TEST_BUILD_OPTS_EXTRA
######################
# build_template_app #
######################
.build_template_app_template:
extends:
- .build_template
- .before_script:build
variables:
LOG_PATH: "${CI_PROJECT_DIR}/log_template_app"
BUILD_PATH: "${CI_PROJECT_DIR}/build_template_app"
BUILD_DIR: "${BUILD_PATH}/@t/@w"
BUILD_LOG_CMAKE: "${LOG_PATH}/cmake_@t_@w.txt"
BUILD_COMMAND_ARGS: ""
artifacts:
paths:
- log_template_app/*
- size_info.txt
- build_template_app/**/size.json
expire_in: 1 week
when: always
script:
# Set the variable for 'esp-idf-template' testing
- ESP_IDF_TEMPLATE_GIT=${ESP_IDF_TEMPLATE_GIT:-"https://github.com/espressif/esp-idf-template.git"}
- retry_failed git clone ${ESP_IDF_TEMPLATE_GIT}
# Try to use the same branch name for esp-idf-template that we're
# using on esp-idf. If it doesn't exist then just stick to the default branch
- python $CHECKOUT_REF_SCRIPT esp-idf-template esp-idf-template
- export PATH="$IDF_PATH/tools:$PATH"
# Only do the default cmake build for each target, remaining part are done in the build_template_app job
- tools/ci/build_template_app.sh ${BUILD_COMMAND_ARGS}
build_clang_test_apps_xtensa:
extends: .build_cmake_clang_template
parallel:
matrix:
- IDF_TARGET: [esp32, esp32s2, esp32s3]
# build-related-pre-check-jobs ------------------------------------------------
# Build at least one project for each target at earliest stage to reduce build cost for obvious failing commits
fast_template_app:
extends:
- .build_template_app_template
- .rules:build:target_test
stage: pre_check
tags: [fast_run, shiny]
variables:
BUILD_COMMAND_ARGS: "-p"
#------------------------------------------------------------------------------
#######################
# gnu_static_analyzer #
#######################
gcc_static_analyzer:
extends:
- .build_template_app_template
- .rules:build:target_test
stage: pre_check
tags: [build, shiny]
variables:
CI_CCACHE_DISABLE: 1
ANALYZING_APP: "examples/get-started/hello_world"
script:
- echo "CONFIG_COMPILER_STATIC_ANALYZER=y" >> ${ANALYZING_APP}/sdkconfig.defaults
- idf-build-apps build -p ${ANALYZING_APP}
########################################
# Clang Build Apps Without Tests Cases #
########################################
build_clang_test_apps_esp32:
extends:
- .build_cmake_clang_template
- .rules:build
variables:
IDF_TARGET: esp32
build_clang_test_apps_esp32s2:
extends:
- .build_cmake_clang_template
- .rules:build
variables:
IDF_TARGET: esp32s2
build_clang_test_apps_esp32s3:
extends:
- .build_cmake_clang_template
- .rules:build
variables:
IDF_TARGET: esp32s3
.build_clang_test_apps_riscv:
extends:
- .build_cmake_clang_template
build_clang_test_apps_riscv:
extends: .build_cmake_clang_template
variables:
# https://reviews.llvm.org/D90108.
# GNU 'as' lets .weak override .globl since binutils-gdb
@@ -138,173 +106,9 @@ build_clang_test_apps_esp32s3:
# while MC lets the last directive win (PR38921).
# For RISCV chips we use integrated assembler by default, so suppress this warning to pass CI pipeline.
TEST_BUILD_OPTS_EXTRA: "--ignore-warning-str 'changed binding to STB_WEAK'"
build_clang_test_apps_esp32c3:
extends:
- .build_clang_test_apps_riscv
- .rules:build
variables:
IDF_TARGET: esp32c3
build_clang_test_apps_esp32c2:
extends:
- .build_clang_test_apps_riscv
- .rules:build
variables:
IDF_TARGET: esp32c2
build_clang_test_apps_esp32c6:
extends:
- .build_clang_test_apps_riscv
- .rules:build
variables:
IDF_TARGET: esp32c6
build_clang_test_apps_esp32c5:
extends:
- .build_clang_test_apps_riscv
- .rules:build
variables:
IDF_TARGET: esp32c5
build_clang_test_apps_esp32h2:
extends:
- .build_clang_test_apps_riscv
- .rules:build
variables:
IDF_TARGET: esp32h2
build_clang_test_apps_esp32p4:
extends:
- .build_clang_test_apps_riscv
- .rules:build
variables:
IDF_TARGET: esp32p4
######################
# Build System Tests #
######################
.test_build_system_template:
stage: host_test
extends:
- .build_template
- .rules:build:check
dependencies: # set dependencies to null to avoid missing artifacts issue
needs:
- job: fast_template_app
artifacts: false
optional: true
artifacts:
reports:
junit: XUNIT_RESULT.xml
paths:
- XUNIT_RESULT.xml
- test_build_system
expire_in: 1 week
when: always
script:
- ${IDF_PATH}/tools/ci/test_configure_ci_environment.sh
- cd ${IDF_PATH}/tools/test_build_system
- run_cmd idf-ci gitlab download-known-failure-cases-file ${KNOWN_FAILURE_CASES_FILE_NAME}
- pytest
--cleanup-idf-copy
--parallel-count ${CI_NODE_TOTAL:-1}
--parallel-index ${CI_NODE_INDEX:-1}
--work-dir ${CI_PROJECT_DIR}/test_build_system
--junitxml ${CI_PROJECT_DIR}/XUNIT_RESULT.xml
--ignore-result-files ${KNOWN_FAILURE_CASES_FILE_NAME}
.test_build_system_macos_template_extension:
tags:
- macos
variables:
PYENV_VERSION: "3.10"
# CCACHE_DIR: "/cache/idf_ccache". On macOS, you cannot write to this folder due to insufficient permissions.
CCACHE_DIR: "" # ccache will use "$HOME/Library/Caches/ccache".
# Workaround for a bug in Parallels executor where CI_PROJECT_DIR is not an absolute path,
# but a relative path to the build directory (builds/espressif/esp-idf instead of ~/builds/espressif/esp-idf.
# GitLab sets the project dir to this template `<builds_dir>/<namespace>/<project_name>`
IDF_PATH: "/Users/espressif/builds/espressif/esp-idf"
.test_build_system_minimal_cmake_template:
extends: .test_build_system_template
variables:
INSTALL_EXTRA_TOOLS: cmake@3.22.1
script:
- MINIMAL_SUPPORTED_CMAKE_VERSION=$(echo "${INSTALL_EXTRA_TOOLS}" | sed -n 's/.*cmake@\([0-9.]*\).*/\1/p')
- export PATH=$(echo "$PATH" | sed -E "s|/tools/cmake/[0-9.]+|/tools/cmake/${MINIMAL_SUPPORTED_CMAKE_VERSION}|")
- ACTUAL_CMAKE_VERSION=$(cmake --version | head -n1 | awk '{print $3}')
- |
if [ "${ACTUAL_CMAKE_VERSION}" != "${MINIMAL_SUPPORTED_CMAKE_VERSION}" ]; then
echo "ERROR: Wrong minimal CMake version! Detected: ${ACTUAL_CMAKE_VERSION}, but should be: ${MINIMAL_SUPPORTED_CMAKE_VERSION}"
exit 1
fi
- ${IDF_PATH}/tools/ci/test_configure_ci_environment.sh
- cd ${IDF_PATH}/tools/test_build_system
- run_cmd idf-ci gitlab download-known-failure-cases-file ${KNOWN_FAILURE_CASES_FILE_NAME}
- pytest
-k cmake
--cleanup-idf-copy
--parallel-count ${CI_NODE_TOTAL:-1}
--parallel-index ${CI_NODE_INDEX:-1}
--work-dir ${CI_PROJECT_DIR}/test_build_system
--junitxml ${CI_PROJECT_DIR}/XUNIT_RESULT.xml
--ignore-result-files ${KNOWN_FAILURE_CASES_FILE_NAME}
pytest_build_system:
extends: .test_build_system_template
parallel: 3
pytest_build_system_macos:
extends:
- .test_build_system_template
- .test_build_system_macos_template_extension
- .before_script:build:macos
- .after_script:build:macos:upload-failed-job-logs:ccache-show-stats
- .rules:build:macos
parallel: 3
pytest_build_system_minimal_cmake:
extends: .test_build_system_minimal_cmake_template
pytest_build_system_macos_minimal_cmake:
extends:
- .test_build_system_minimal_cmake_template
- .test_build_system_macos_template_extension
- .before_script:build:macos
- .after_script:build:macos:upload-failed-job-logs:ccache-show-stats
- .rules:build:macos
variables:
INSTALL_EXTRA_TOOLS: ninja cmake@3.22.1
build_docker:
extends:
- .before_script:minimal
- .rules:build:docker
stage: host_test
needs: []
image: espressif/docker-builder:1
tags: [shiny, dind]
variables:
DOCKER_TMP_IMAGE_NAME: "idf_tmp_image"
script:
- export DOCKER_BUILD_ARGS="--build-arg IDF_CLONE_URL=${CI_REPOSITORY_URL} --build-arg IDF_CLONE_BRANCH_OR_TAG=${CI_COMMIT_REF_NAME} --build-arg IDF_CHECKOUT_REF=${CI_COMMIT_TAG:-$CI_COMMIT_SHA} --build-arg IDF_CLONE_SHALLOW=1 --build-arg IDF_GITHUB_ASSETS=${INTERNAL_GITHUB_ASSETS}"
- docker build --tag ${DOCKER_TMP_IMAGE_NAME} ${DOCKER_BUILD_ARGS} tools/docker/
# We can't mount $PWD/examples/get-started/blink into the container, see https://gitlab.com/gitlab-org/gitlab-ce/issues/41227.
# The workaround mentioned there works, but leaves around directories which need to be cleaned up manually.
# Therefore, build a copy of the example located inside the container.
- docker run --rm --workdir /opt/esp/idf/examples/get-started/blink ${DOCKER_TMP_IMAGE_NAME} idf.py build
# This job builds template app with permutations of targets and optimization levels
build_template_app:
extends:
- .build_template_app_template
- .rules:build
stage: host_test
dependencies: # set dependencies to null to avoid missing artifacts issue
needs:
- job: fast_template_app
artifacts: false
parallel:
matrix:
- IDF_TARGET: [esp32c3, esp32c2, esp32c6, esp32c5, esp32h2, esp32p4]
####################
# Dynamic Pipeline #
@@ -326,7 +130,11 @@ generate_build_child_pipeline:
expire_in: 1 week
when: always
script:
- run_cmd python tools/ci/dynamic_pipelines/scripts/generate_build_child_pipeline.py
- run_cmd idf-ci --debug gitlab build-child-pipeline
-p components
-p examples
-p tools/test_apps
--modified-files $MR_MODIFIED_FILES
build_child_pipeline:
stage: build

View File

@@ -12,7 +12,6 @@ stages:
- test_deploy
- deploy
- post_deploy
- retry_failed_jobs
variables:
# System environment
@@ -37,7 +36,7 @@ variables:
GIT_FETCH_EXTRA_FLAGS: "--no-recurse-submodules --prune --prune-tags"
# we're using .cache folder for caches
GIT_CLEAN_FLAGS: -ffdx -e .cache/
LATEST_GIT_TAG: v6.0-beta1
LATEST_GIT_TAG: v6.1-dev
SUBMODULE_FETCH_TOOL: "tools/ci/ci_fetch_submodule.py"
# by default we will fetch all submodules
@@ -52,9 +51,9 @@ variables:
CHECKOUT_REF_SCRIPT: "$CI_PROJECT_DIR/tools/ci/checkout_project_ref.py"
# Docker images
ESP_ENV_IMAGE: "${CI_DOCKER_REGISTRY}/esp-env-v6.0:3"
ESP_IDF_DOC_ENV_IMAGE: "${CI_DOCKER_REGISTRY}/esp-idf-doc-env-v6.0:2-1"
TARGET_TEST_ENV_IMAGE: "${CI_DOCKER_REGISTRY}/target-test-env-v6.0:2"
ESP_ENV_IMAGE: "${CI_DOCKER_REGISTRY}/esp-env-v6.1:1"
ESP_IDF_DOC_ENV_IMAGE: "${CI_DOCKER_REGISTRY}/esp-idf-doc-env-v6.1:1-1"
TARGET_TEST_ENV_IMAGE: "${CI_DOCKER_REGISTRY}/target-test-env-v6.1:1"
SONARQUBE_SCANNER_IMAGE: "${CI_DOCKER_REGISTRY}/sonarqube-scanner:5"
# cache python dependencies
@@ -66,7 +65,7 @@ variables:
CI_PYTHON_CONSTRAINT_BRANCH: ""
# Update the filename for a specific ESP-IDF release. It is used only with CI_PYTHON_CONSTRAINT_BRANCH.
CI_PYTHON_CONSTRAINT_FILE: "espidf.constraints.v6.0.txt"
CI_PYTHON_CONSTRAINT_FILE: "espidf.constraints.v6.1.txt"
# Set this variable to repository name of a Python tool you wish to install and test in the context of ESP-IDF CI.
# Keep the variable empty when not used.
@@ -122,18 +121,13 @@ variables:
# add extra python packages
export PYTHONPATH="$IDF_PATH/tools:$IDF_PATH/tools/ci:$IDF_PATH/tools/esp_app_trace:$IDF_PATH/components/partition_table:$IDF_PATH/tools/ci/python_packages:$PYTHONPATH"
# minio configuration
# added here since the precedence of variables in gitlab-ci.yml is lower than project settings
export IDF_S3_SERVER="$IDF_S3_NEW_SERVER"
export IDF_S3_ACCESS_KEY="$IDF_S3_NEW_ACCESS_KEY"
.setup_tools_and_idf_python_venv: &setup_tools_and_idf_python_venv |
# must use after setup_tools_except_target_test
# otherwise the export.sh won't work properly
# download constraint file for dev
if [[ -n "$CI_PYTHON_CONSTRAINT_BRANCH" ]]; then
wget -O /tmp/constraint.txt --header="Authorization:Bearer ${ESPCI_TOKEN}" ${GITLAB_HTTP_SERVER}/api/v4/projects/2581/repository/files/${CI_PYTHON_CONSTRAINT_FILE}/raw?ref=${CI_PYTHON_CONSTRAINT_BRANCH}
wget -O /tmp/constraint.txt --header="Authorization:Bearer ${ESPCI_TOKEN}" "${GITLAB_HTTP_SERVER}/api/v4/projects/2581/repository/files/${CI_PYTHON_CONSTRAINT_FILE}/raw?ref=${CI_PYTHON_CONSTRAINT_BRANCH}"
mkdir -p ~/.espressif
mv /tmp/constraint.txt ~/.espressif/${CI_PYTHON_CONSTRAINT_FILE}
fi
@@ -166,20 +160,40 @@ variables:
section_end "install_python_env"
fi
section_start "source_export" "Source export.sh"
source ./export.sh
section_end "source_export"
# Eager upgrade of CI dependencies
# Done after sourcing export.sh so that we could easily invoke the right pip
section_start "upgrade_ci_dependencies" "Upgrading CI dependencies"
pip install --upgrade --upgrade-strategy=eager -r $IDF_PATH/tools/requirements/requirements.ci.txt -c ~/.espressif/${CI_PYTHON_CONSTRAINT_FILE}
if [[ "${CI_JOB_STAGE}" == "target_test" ]]; then
pip install --upgrade --upgrade-strategy=eager -r $IDF_PATH/tools/requirements/requirements.test-specific.txt -c ~/.espressif/${CI_PYTHON_CONSTRAINT_FILE}
fi
section_end "upgrade_ci_dependencies"
REEXPORT_NEEDED=0
if [[ ! -z "$INSTALL_EXTRA_TOOLS" ]]; then
section_start "installing_optional_tools" "Install optional tools ${INSTALL_EXTRA_TOOLS}"
$IDF_PATH/tools/idf_tools.py --non-interactive install $INSTALL_EXTRA_TOOLS
run_cmd $IDF_PATH/tools/idf_tools.py --non-interactive install $INSTALL_EXTRA_TOOLS
section_end "installing_optional_tools"
REEXPORT_NEEDED=1
fi
# Install esp-clang if necessary (esp-clang is separately installed)
if [[ "$IDF_TOOLCHAIN" == "clang" && -z "$CI_CLANG_DISTRO_URL" ]]; then
$IDF_PATH/tools/idf_tools.py --non-interactive install esp-clang
REEXPORT_NEEDED=1
fi
section_start "source_export" "Source export.sh"
source ./export.sh
section_end "source_export"
if [[ $REEXPORT_NEEDED -eq 1 ]]; then
section_start "re_source_export" "Re-source export.sh"
source ./export.sh
section_end "re_source_export"
fi
# Custom clang toolchain
if [[ "$IDF_TOOLCHAIN" == "clang" && ! -z "$CI_CLANG_DISTRO_URL" ]]; then
@@ -218,7 +232,9 @@ variables:
.show_ccache_statistics: &show_ccache_statistics |
# Show ccache statistics if enabled globally
section_start "ccache_show_stats" "Show ccache statistics"
test "$CI_CCACHE_STATS" == 1 && test -n "$(which ccache)" && ccache --show-stats -vv || true
section_end "ccache_show_stats"
.upload_failed_job_log_artifacts: &upload_failed_job_log_artifacts |
if [ $CI_JOB_STATUS = "failed" ]; then
@@ -229,30 +245,6 @@ variables:
before_script:
- *common-before_scripts
.before_script:build:macos:
before_script:
# macos is running shell executor, which means it would use
# the system installed /usr/local/bin/python3 by default.
# Ensure pyenv and PYENV_VERSION installed
- eval "$(pyenv init -)"
- *common-before_scripts
# remove idf-env.json, since it may contains enabled "features"
- rm -f $IDF_TOOLS_PATH/idf-env.json
# This adds tools (compilers) and the version-specific Python environment to PATH
- *setup_tools_and_idf_python_venv
- fetch_submodules
variables:
INSTALL_EXTRA_TOOLS: cmake ninja
.after_script:build:macos:upload-failed-job-logs:ccache-show-stats:
after_script:
# macos is running shell executor, which means it would use
# the system installed /usr/local/bin/python3 by default.
# Ensure pyenv and PYENV_VERSION installed
- eval "$(pyenv init -)"
- *upload_failed_job_log_artifacts
- *show_ccache_statistics
.before_script:build:
before_script:
- *common-before_scripts
@@ -262,19 +254,10 @@ variables:
- export EXTRA_CFLAGS=${PEDANTIC_CFLAGS}
- export EXTRA_CXXFLAGS=${PEDANTIC_CXXFLAGS}
.after_script:build:ccache-show-stats:
.after_script:build:
after_script:
- source tools/ci/utils.sh
- section_start "ccache_show_stats" "Show ccache statistics"
- *show_ccache_statistics
- section_end "ccache_show_stats"
.after_script:build:ccache-show-stats:upload-failed-job-logs:
after_script:
- source tools/ci/utils.sh
- section_start "ccache_show_stats" "Show ccache statistics"
- *show_ccache_statistics
- section_end "ccache_show_stats"
- *upload_failed_job_log_artifacts
##############################
@@ -313,7 +296,7 @@ variables:
.git_checkout_ci_commit_sha: &git_checkout_ci_commit_sha |
git checkout $CI_COMMIT_SHA
git clean ${GIT_CLEAN_FLAGS}
eval "git clean ${GIT_CLEAN_FLAGS}"
# git diff requires two commits, with different CI env var
#
@@ -372,13 +355,48 @@ variables:
before_script:
- *git_init
- *git_fetch_from_mirror_url_if_exists
- git fetch origin "${CI_COMMIT_SHA}" --depth=1 ${GIT_FETCH_EXTRA_FLAGS}
- eval "git fetch --depth=1 ${GIT_FETCH_EXTRA_FLAGS} origin ${CI_COMMIT_SHA}"
- *git_checkout_ci_commit_sha
- *common-before_scripts
- *setup_tools_and_idf_python_venv
- add_gitlab_ssh_keys
# no submodules
.brew-macos-settings:
variables:
GIT_STRATEGY: none # we do manual git clone to use local mirror
IDF_CCACHE_ENABLE: "0"
CCACHE_DIR: "/var/tmp/cache/idf_ccache"
tags:
- macos-tart
image: macos-sequoia-idf-v6.1
cache: [] # pip cache is created under amd64, and submodules are downloaded with brew mirror, so disable cache here
before_script:
# assert LOCAL_GIT_MIRROR is set
- echo -e "section_start:`date +%s`:check_out\r\e[0Kchecking out from local git mirror, then reset to CI_COMMIT_SHA"
- |
if [ -z "${LOCAL_GIT_MIRROR:-}" ]; then
echo "Error: LOCAL_GIT_MIRROR not set, cannot clone from mirror."
exit 1
fi
- MIRROR_REPO_URL="${LOCAL_GIT_MIRROR}/${CI_PROJECT_PATH}"
- cd "${CI_PROJECT_DIR}"
# since .cache exists in CI_PROJECT_DIR, so can't direct `git clone .`
- git clone -b ${CI_MERGE_REQUEST_TARGET_BRANCH_NAME:-${CI_COMMIT_BRANCH}} --depth=1 --recursive --shallow-submodules "${MIRROR_REPO_URL}" tmp
- mv tmp/.git ./
- rm -rf tmp
- git reset --hard
# set remote url back
- git remote set-url origin "${CI_REPOSITORY_URL}"
- eval "git fetch --depth=1 ${GIT_FETCH_EXTRA_FLAGS} origin ${CI_COMMIT_SHA}"
- git checkout FETCH_HEAD
- git submodule update --init --recursive --depth=1
- echo -e "section_end:`date +%s`:check_out\r\e[0K"
- *common-before_scripts
- *setup_tools_and_idf_python_venv
after_script: [] # ccache now is disabled for macos brew runners
timeout: 30m
#############
# `default` #
#############

View File

@@ -9,7 +9,6 @@
- build_system
- downloadable-tools
included_in:
- build:target_test
- build:check
# -------------------
@@ -41,8 +40,6 @@
"patterns:template-app":
patterns:
- build_template-app
included_in:
- build:target_test
"patterns:build-check":
patterns:
@@ -76,3 +73,7 @@
- if-schedule-test-build-system-windows
patterns:
- build_system_win
"labels:buildv2":
labels:
- buildv2

View File

@@ -3,6 +3,27 @@
image: $ESP_ENV_IMAGE
tags: [ deploy ]
.metrics_template:
stage: deploy
tags: [ fast_run, shiny ]
image: python:3.13-slim
dependencies: []
needs: []
variables:
PIP_CACHE_DIR: ".cache/pip"
# Metrics - related env vars
ESP_METRICS_PROJECT_URL: "$CI_PROJECT_URL"
ESP_METRICS_PROJECT_ID: "$CI_PROJECT_ID"
ESP_METRICS_COMMIT_SHA: "$PIPELINE_COMMIT_SHA"
ESP_METRICS_BRANCH_NAME: "$CI_COMMIT_REF_NAME"
cache:
key: metrics-pip
paths:
- .cache/pip
before_script:
- echo "Installing esp-metrics-cli tool"
- pip install "esp-metrics-cli>=0.3,<1"
check_submodule_sync:
extends:
- .deploy_job_template
@@ -64,3 +85,31 @@ deploy_update_SHA_in_esp-dockerfiles:
environment:
name: deploy_update_SHA_in_esp-dockerfiles_production
deployment_tier: production
upload_junit_report:
extends:
- .deploy_job_template
tags: [ fast_run, shiny ]
needs:
- pipeline_variables
- job: build_child_pipeline
artifacts: false
script:
- run_cmd idf-ci gitlab download-artifacts --type junit
rules:
- when: always
artifacts:
reports:
junit: XUNIT_RESULT_*.xml
expire_in: 1 week
when: always
target-examples-count-metrics:
extends:
- .metrics_template
allow_failure: true
script:
- echo "Generating ESP-IDF examples count metrics"
- cd tools/ci/metrics/examples_count
- python3 generate_metrics.py
- esp-metrics-cli upload -d schema.yaml -i metrics.json

View File

@@ -6,13 +6,16 @@
dependencies: # set dependencies to null to avoid missing artifacts issue
# run host_test jobs immediately, only after upload cache
needs:
- pipeline_variables
- job: upload-pip-cache
optional: true
artifacts: false
- job: upload-submodules-cache
optional: true
artifacts: false
- pipeline_variables
- job: fast_template_app
optional: true
artifacts: false
artifacts:
expire_in: 1 week
when: always
@@ -52,14 +55,14 @@ test_partition_table_on_host:
extends: .host_test_template
script:
- cd components/partition_table/test_gen_esp32part_host
- ./gen_esp32part_tests.py
- pytest_for_ut ./gen_esp32part_tests.py
test_ldgen_on_host:
extends: .host_test_template
script:
- cd tools/ldgen/test
- export PYTHONPATH=$PYTHONPATH:..
- python -m unittest
- pytest_for_ut .
variables:
LC_ALL: C.UTF-8
@@ -67,21 +70,19 @@ test_spiffs_on_host:
extends: .host_test_template
script:
- cd components/spiffs/test_spiffsgen/
- ./test_spiffsgen.py
- pytest_for_ut ./test_spiffsgen.py
test_fatfsgen_on_host:
extends: .host_test_template
script:
- cd components/fatfs/test_fatfsgen/
- ./test_fatfsgen.py
- ./test_wl_fatfsgen.py
- ./test_fatfsparse.py
- pytest_for_ut ./test_fatfsgen.py ./test_wl_fatfsgen.py ./test_fatfsparse.py
test_certificate_bundle_on_host:
extends: .host_test_template
script:
- cd components/mbedtls/esp_crt_bundle/test_gen_crt_bundle/
- ./test_gen_crt_bundle.py
- pytest_for_ut ./test_gen_crt_bundle.py
# Test for create virtualenv. It must be invoked from Python, not from virtualenv.
# Use docker image system python without any extra dependencies
@@ -104,15 +105,17 @@ test_cli_installer:
- python3 ${IDF_PATH}/tools/idf_tools.py download required qemu-riscv32 qemu-xtensa cmake cmake@3.22.1
- cd ${IDF_PATH}/tools/test_idf_tools
- python3 -m pip install jsonschema
# Testing with system python3, so don't use any third-party packages
- python3 ./test_idf_tools.py -v
- python3 ./test_idf_tools_python_env.py
# It runs at the end because it modifies dependencies
- IDF_TEST_MAY_BREAK_DEPENDENCIES=1 python3 ./test_idf_tools.py -v TestSystemDependencies.test_commands_when_nodeps
.test_efuse_table_on_host_template:
test_efuse_table_on_host:
extends: .host_test_template
variables:
IDF_TARGET: "esp32"
parallel:
matrix:
- IDF_TARGET: [esp32, esp32s2, esp32c3, esp32s3, esp32c2, esp32c6, esp32h2, esp32p4, esp32c5, esp32c61]
artifacts:
when: on_failure
paths:
@@ -122,35 +125,7 @@ test_cli_installer:
- ./efuse_table_gen.py -t "${IDF_TARGET}" ${IDF_PATH}/components/efuse/${IDF_TARGET}/esp_efuse_table.csv
- git diff --exit-code -- ${IDF_TARGET}/esp_efuse_table.c || { echo 'Differences found for ${IDF_TARGET} target. Please run idf.py efuse-common-table and commit the changes.'; exit 1; }
- cd ${IDF_PATH}/components/efuse/test_efuse_host
- ./efuse_tests.py
test_efuse_table_on_host_esp32:
extends: .test_efuse_table_on_host_template
test_efuse_table_on_host_esp32s2:
extends: .test_efuse_table_on_host_template
variables:
IDF_TARGET: esp32s2
test_efuse_table_on_host_esp32s3:
extends: .test_efuse_table_on_host_template
variables:
IDF_TARGET: esp32s3
test_efuse_table_on_host_esp32c3:
extends: .test_efuse_table_on_host_template
variables:
IDF_TARGET: esp32c3
test_efuse_table_on_host_esp32h2:
extends: .test_efuse_table_on_host_template
variables:
IDF_TARGET: esp32h2
test_efuse_table_on_host_esp32c6:
extends: .test_efuse_table_on_host_template
variables:
IDF_TARGET: esp32c6
- pytest_for_ut ./efuse_tests.py
test_logtrace_proc:
extends: .host_test_template
@@ -217,7 +192,7 @@ test_split_path_by_spaces:
extends: .host_test_template
script:
- cd ${IDF_PATH}/tools
- python -m unittest split_paths_by_spaces.py
- pytest_for_ut ./split_paths_by_spaces.py
test_transport_on_host:
extends: .host_test_template
@@ -256,8 +231,78 @@ test_gen_soc_caps_kconfig:
extends: .host_test_template
script:
- cd ${IDF_PATH}/tools/gen_soc_caps_kconfig/
- ./test/test_gen_soc_caps_kconfig.py
- pytest_for_ut ./test/test_gen_soc_caps_kconfig.py
test_idf_build_apps_load_soc_caps:
extends: .host_test_template
script:
- cd tools/ci
- pytest_for_ut ./test_soc_headers_load_in_idf_build_apps.py
test_nvs_gen_check:
extends: .host_test_template
artifacts:
paths:
- XUNIT_RESULT.xml
- components/nvs_flash/nvs_partition_tool
reports:
junit: XUNIT_RESULT.xml
variables:
LC_ALL: C.UTF-8
script:
- cd ${IDF_PATH}/components/nvs_flash/nvs_partition_tool
- pytest_for_ut test_nvs_gen_check.py
test_esp_rom:
extends: .host_test_template
artifacts:
paths:
- XUNIT_RESULT.xml
reports:
junit: XUNIT_RESULT.xml
script:
- cd ${IDF_PATH}/components/esp_rom/
- pytest_for_ut test_esp_rom.py
make_sure_soc_caps_compatible_in_idf_build_apps:
extends:
- .host_test_template
- .rules:dev-push
artifacts:
paths:
- new.json
- base.json
when: always
when: manual
script:
- python tools/ci/idf_build_apps_dump_soc_caps.py new.json
- git fetch --depth=1 origin $CI_MERGE_REQUEST_DIFF_BASE_SHA
- git checkout -f $CI_MERGE_REQUEST_DIFF_BASE_SHA
- git checkout $CI_COMMIT_SHA -- tools/ci/idf_build_apps_dump_soc_caps.py
- python tools/ci/idf_build_apps_dump_soc_caps.py base.json
- diff new.json base.json
build_docker:
extends:
- .before_script:minimal
- .rules:build:docker
stage: host_test
needs: []
image: espressif/docker-builder:1
tags: [shiny, dind]
variables:
DOCKER_TMP_IMAGE_NAME: "idf_tmp_image"
script:
- export DOCKER_BUILD_ARGS="--build-arg IDF_CLONE_URL=${CI_REPOSITORY_URL} --build-arg IDF_CLONE_BRANCH_OR_TAG=${CI_COMMIT_REF_NAME} --build-arg IDF_CHECKOUT_REF=${CI_COMMIT_TAG:-$CI_COMMIT_SHA} --build-arg IDF_CLONE_SHALLOW=1 --build-arg IDF_GITHUB_ASSETS=${INTERNAL_GITHUB_ASSETS}"
- docker build --tag ${DOCKER_TMP_IMAGE_NAME} ${DOCKER_BUILD_ARGS} tools/docker/
# We can't mount $PWD/examples/get-started/blink into the container, see https://gitlab.com/gitlab-org/gitlab-ce/issues/41227.
# The workaround mentioned there works, but leaves around directories which need to be cleaned up manually.
# Therefore, build a copy of the example located inside the container.
- docker run --rm --workdir /opt/esp/idf/examples/get-started/blink ${DOCKER_TMP_IMAGE_NAME} idf.py build
############################
# Host test with test apps #
############################
test_pytest_qemu:
extends:
- .host_test_template
@@ -321,9 +366,7 @@ test_pytest_linux:
test_pytest_macos:
extends:
- .host_test_template
- .before_script:build:macos
tags:
- macos
- .brew-macos-settings
artifacts:
paths:
- XUNIT_RESULT.xml
@@ -331,12 +374,6 @@ test_pytest_macos:
- "**/build*/build_log.txt"
reports:
junit: XUNIT_RESULT.xml
variables:
PYENV_VERSION: "3.10"
# Workaround for a bug in Parallels executor where CI_PROJECT_DIR is not an absolute path,
# but a relative path to the build directory (builds/espressif/esp-idf instead of ~/builds/espressif/esp-idf.
# GitLab sets the project dir to this template `<builds_dir>/<namespace>/<project_name>`
IDF_PATH: "/Users/espressif/builds/espressif/esp-idf"
script:
- run_cmd idf-ci build run
-p components -p examples -p tools/test_apps
@@ -352,50 +389,116 @@ test_pytest_macos:
--junitxml=XUNIT_RESULT.xml
--ignore-result-files ${KNOWN_FAILURE_CASES_FILE_NAME}
test_idf_build_apps_load_soc_caps:
extends: .host_test_template
script:
- python tools/ci/check_soc_headers_load_in_idf_build_apps.py
test_nvs_gen_check:
extends: .host_test_template
######################
# Build System Tests #
######################
.test_build_system_template:
stage: host_test
extends:
- .build_template
- .rules:build:check
dependencies: # set dependencies to null to avoid missing artifacts issue
needs:
- job: fast_template_app
artifacts: false
optional: true
artifacts:
paths:
- XUNIT_RESULT.xml
- components/nvs_flash/nvs_partition_tool
reports:
junit: XUNIT_RESULT.xml
paths:
- XUNIT_RESULT.xml
- test_build_system
expire_in: 1 week
when: always
script:
- ${IDF_PATH}/tools/ci/test_configure_ci_environment.sh
- cd ${IDF_PATH}/tools/test_build_system
- run_cmd idf-ci gitlab download-known-failure-cases-file ${KNOWN_FAILURE_CASES_FILE_NAME}
- pytest
--cleanup-idf-copy
--parallel-count ${CI_NODE_TOTAL:-1}
--parallel-index ${CI_NODE_INDEX:-1}
--work-dir ${CI_PROJECT_DIR}/test_build_system
--junitxml ${CI_PROJECT_DIR}/XUNIT_RESULT.xml
--ignore-result-files ${KNOWN_FAILURE_CASES_FILE_NAME}
.test_build_system_minimal_cmake_template:
extends: .test_build_system_template
variables:
LC_ALL: C.UTF-8
INSTALL_EXTRA_TOOLS: cmake@3.22.1
script:
- cd ${IDF_PATH}/components/nvs_flash/nvs_partition_tool
- pytest --noconftest test_nvs_gen_check.py --junitxml=XUNIT_RESULT.xml
- MINIMAL_SUPPORTED_CMAKE_VERSION=$(echo "${INSTALL_EXTRA_TOOLS}" | sed -n 's/.*cmake@\([0-9.]*\).*/\1/p')
- export PATH=$(echo "$PATH" | sed -E "s|/tools/cmake/[0-9.]+|/tools/cmake/${MINIMAL_SUPPORTED_CMAKE_VERSION}|")
- ACTUAL_CMAKE_VERSION=$(cmake --version | head -n1 | awk '{print $3}')
- |
if [ "${ACTUAL_CMAKE_VERSION}" != "${MINIMAL_SUPPORTED_CMAKE_VERSION}" ]; then
echo "ERROR: Wrong minimal CMake version! Detected: ${ACTUAL_CMAKE_VERSION}, but should be: ${MINIMAL_SUPPORTED_CMAKE_VERSION}"
exit 1
fi
- ${IDF_PATH}/tools/ci/test_configure_ci_environment.sh
- cd ${IDF_PATH}/tools/test_build_system
- run_cmd idf-ci gitlab download-known-failure-cases-file ${KNOWN_FAILURE_CASES_FILE_NAME}
- pytest
-k cmake
--cleanup-idf-copy
--parallel-count ${CI_NODE_TOTAL:-1}
--parallel-index ${CI_NODE_INDEX:-1}
--work-dir ${CI_PROJECT_DIR}/test_build_system
--junitxml ${CI_PROJECT_DIR}/XUNIT_RESULT.xml
--ignore-result-files ${KNOWN_FAILURE_CASES_FILE_NAME}
test_esp_rom:
extends: .host_test_template
artifacts:
paths:
- XUNIT_RESULT.xml
reports:
junit: XUNIT_RESULT.xml
pytest_build_system:
extends: .test_build_system_template
parallel: 3
pytest_buildv2_system:
extends:
- .test_build_system_template
- .rules:labels:buildv2
parallel: 3
script:
- cd ${IDF_PATH}/components/esp_rom/
- pytest --noconftest test_esp_rom.py --junitxml=XUNIT_RESULT.xml
- ${IDF_PATH}/tools/ci/test_configure_ci_environment.sh
- cd ${IDF_PATH}/tools/test_build_system
- run_cmd idf-ci gitlab download-known-failure-cases-file ${KNOWN_FAILURE_CASES_FILE_NAME}
- pytest
--buildv2
--cleanup-idf-copy
--parallel-count ${CI_NODE_TOTAL:-1}
--parallel-index ${CI_NODE_INDEX:-1}
--work-dir ${CI_PROJECT_DIR}/test_build_system
--junitxml ${CI_PROJECT_DIR}/XUNIT_RESULT.xml
--ignore-result-files ${KNOWN_FAILURE_CASES_FILE_NAME}
--
test_non_default_target.py
test_component_manager.py
test_build.py
test_bootloader.py
test_git.py
test_kconfig.py
test_partition.py
test_reproducible_build.py
test_sdkconfig.py
test_versions.py
test_common.py
test_components.py
test_cmake.py
test_idf_extension.py
test_rebuild.py
make_sure_soc_caps_compatible_in_idf_build_apps:
extends:
- .host_test_template
- .rules:dev-push
artifacts:
paths:
- new.json
- base.json
when: always
when: manual
script:
- python tools/ci/idf_build_apps_dump_soc_caps.py new.json
- git fetch --depth=1 origin $CI_MERGE_REQUEST_DIFF_BASE_SHA
- git checkout -f $CI_MERGE_REQUEST_DIFF_BASE_SHA
- git checkout $CI_COMMIT_SHA -- tools/ci/idf_build_apps_dump_soc_caps.py
- python tools/ci/idf_build_apps_dump_soc_caps.py base.json
- diff new.json base.json
pytest_build_system_macos:
extends:
- .test_build_system_template
- .brew-macos-settings
- .rules:build:macos
parallel: 3
pytest_build_system_minimal_cmake:
extends: .test_build_system_minimal_cmake_template
pytest_build_system_macos_minimal_cmake:
extends:
- .test_build_system_minimal_cmake_template
- .brew-macos-settings
- .rules:build:macos
variables:
INSTALL_EXTRA_TOOLS: ninja cmake@3.22.1

View File

@@ -7,7 +7,9 @@ generate_failed_jobs_report:
- .post_deploy_template
tags: [build, shiny]
when: always
dependencies: [] # Do not download artifacts from the previous stages
dependencies: # Do not download artifacts from the previous stages
needs:
- pipeline_variables
artifacts:
expire_in: 2 week
when: always

View File

@@ -191,13 +191,24 @@ baseline_manifest_sha:
expire_in: 1 week
when: always
redundant_pass_job:
gcc_static_analyzer:
extends:
- .pre_check_template
tags: [shiny, fast_run]
cache: []
- .rules:build
variables:
GIT_STRATEGY: none
before_script: []
CI_CCACHE_DISABLE: 1
ANALYZING_APP: "examples/get-started/hello_world"
script:
- echo "This job is redundant to ensure the 'retry_failed_jobs' job can exist and not be skipped"
- echo "CONFIG_COMPILER_STATIC_ANALYZER=y" >> ${ANALYZING_APP}/sdkconfig.defaults
- idf-build-apps build -p ${ANALYZING_APP}
retry_failed_jobs:
extends:
- .pre_check_template
- .rules:dev-push
tags: [shiny, fast_run]
allow_failure: true
script:
- echo "Retrieving and retrying all failed jobs for the pipeline..."
- python tools/ci/python_packages/gitlab_api.py retry_failed_jobs $CI_MERGE_REQUEST_PROJECT_ID --pipeline_id $CI_PIPELINE_ID
when: manual

View File

@@ -1,15 +0,0 @@
retry_failed_jobs:
stage: retry_failed_jobs
tags: [shiny, fast_run]
allow_failure: true
image: $ESP_ENV_IMAGE
dependencies: null
before_script: []
cache: []
extends: []
script:
- echo "Retrieving and retrying all failed jobs for the pipeline..."
- python tools/ci/python_packages/gitlab_api.py retry_failed_jobs $CI_MERGE_REQUEST_PROJECT_ID --pipeline_id $CI_PIPELINE_ID
when: manual
needs:
- redundant_pass_job

View File

@@ -41,11 +41,9 @@
- "tools/idf_tools.py"
- "tools/tools.json"
.patterns-build_template-app: &patterns-build_template-app
- "tools/ci/build_template_app.sh"
.patterns-build_system: &patterns-build_system
- "tools/cmake/**/*"
- "tools/cmakev2/**/*"
- "tools/kconfig_new/**/*"
- "tools/idf.py"
- "tools/idf_py_actions/**/*"
@@ -53,14 +51,12 @@
- "tools/ci/ignore_build_warnings.txt"
- "tools/ci/test_build_system*.sh"
- "tools/ci/test_build_system*.py"
- "tools/ci/build_template_app.sh"
- "tools/test_build_system/**/*"
.patterns-build_system_win: &patterns-build_system_win
- "tools/test_build_system/**/*"
.patterns-build_macos: &patterns-build_macos
- "tools/ci/test_configure_ci_environment.sh"
.patterns-build_check: &patterns-build_check
- "tools/test_build_system/**/*"
- "tools/ci/test_configure_ci_environment.sh"
@@ -133,6 +129,8 @@
- "tools/bsasm.py"
- "tools/test_bsasm/**/*"
- "tools/ci/test_soc_headers_load_in_idf_build_apps.py"
.patterns-docker: &patterns-docker
- "tools/docker/**/*"
@@ -149,7 +147,6 @@
- "components/esp_coex/lib"
- "components/lwip/lwip"
- "components/mbedtls/mbedtls"
- "components/mqtt/esp-mqtt"
- "components/openthread/lib"
- "components/openthread/openthread"
- "components/protobuf-c/protobuf-c"
@@ -275,6 +272,9 @@
.if-label-build: &if-label-build
if: '$BOT_LABEL_BUILD || $CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*build(?:,[^,\n\r]+)*$/i'
.if-label-buildv2: &if-label-buildv2
if: '$BOT_LABEL_BUILDV2 || $CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*buildv2(?:,[^,\n\r]+)*$/i'
.if-label-docker: &if-label-docker
if: '$BOT_LABEL_DOCKER || $CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*docker(?:,[^,\n\r]+)*$/i'
@@ -348,20 +348,11 @@
- <<: *if-label-macos
- <<: *if-label-macos_test
.rules:build:target_test:
.rules:labels:buildv2:
rules:
- <<: *if-revert-branch
when: never
- <<: *if-protected-check
- <<: *if-label-build
- <<: *if-dev-push
changes: *patterns-build_components
- <<: *if-dev-push
changes: *patterns-build_system
- <<: *if-dev-push
changes: *patterns-build_template-app
- <<: *if-dev-push
changes: *patterns-downloadable-tools
- <<: *if-label-buildv2
.rules:labels:nvs_coverage:
rules:

View File

@@ -136,3 +136,47 @@ pytest_build_system_win_minimal_cmake:
- cd ${IDF_PATH}\tools\test_build_system
- idf-ci gitlab download-known-failure-cases-file ${KNOWN_FAILURE_CASES_FILE_NAME}
- pytest -k cmake --junitxml=${CI_PROJECT_DIR}\XUNIT_RESULT.xml --ignore-result-files ${KNOWN_FAILURE_CASES_FILE_NAME}
pytest_buildv2_system_win:
extends:
- .test_build_system_template_win
- .rules:labels:buildv2
parallel: 2
needs: []
tags: [windows-build, brew]
artifacts:
paths:
- XUNIT_RESULT.xml
- test_build_system
expire_in: 2 days
reports:
junit: XUNIT_RESULT.xml
when: always
script:
- .\install.ps1 --enable-ci
- . .\export.ps1
- python "${SUBMODULE_FETCH_TOOL}" -s "all"
- cd ${IDF_PATH}\tools\test_build_system
- idf-ci gitlab download-known-failure-cases-file ${KNOWN_FAILURE_CASES_FILE_NAME}
- pytest
--buildv2
--parallel-count ${CI_NODE_TOTAL}
--parallel-index ${CI_NODE_INDEX}
--junitxml=${CI_PROJECT_DIR}\XUNIT_RESULT.xml
--ignore-result-files ${KNOWN_FAILURE_CASES_FILE_NAME}
--
test_non_default_target.py
test_component_manager.py
test_build.py
test_bootloader.py
test_git.py
test_kconfig.py
test_partition.py
test_reproducible_build.py
test_sdkconfig.py
test_versions.py
test_common.py
test_components.py
test_cmake.py
test_idf_extension.py
test_rebuild.py

5
.gitmodules vendored
View File

@@ -54,11 +54,6 @@
path = components/lwip/lwip
url = ../../espressif/esp-lwip.git
[submodule "components/mqtt/esp-mqtt"]
path = components/mqtt/esp-mqtt
# url = ../../espressif/esp-mqtt.git
url = ../../0xFEEDC0DE64/esp-mqtt.git
[submodule "components/protobuf-c/protobuf-c"]
path = components/protobuf-c/protobuf-c
url = ../../protobuf-c/protobuf-c.git

View File

@@ -48,7 +48,6 @@ pre_yaml_jinja = """
include:
- .gitlab/ci/common.yml
- tools/ci/dynamic_pipelines/templates/.dynamic_jobs.yml
- tools/ci/dynamic_pipelines/templates/generate_target_test_report.yml
"""
[gitlab.artifacts.s3.debug]
@@ -89,18 +88,19 @@ patterns = [
[gitlab.artifacts.s3.junit]
bucket = "idf-artifacts"
patterns = [
'XUNIT_RESULT_*.xml',
'**/XUNIT_RESULT_*.xml',
'**/build_summary_*.xml',
]
[gitlab.artifacts.s3.env]
bucket = "idf-artifacts"
patterns = [
'pipeline.env',
'**/pipeline.env',
]
[gitlab.artifacts.s3.longterm]
bucket = "longterm"
if_clause = '"$CI_COMMIT_REF_NAME" == "master"'
patterns = [
'**/build*/size.json',
'**/build*/size*.json',
]

View File

@@ -159,6 +159,10 @@ if(CONFIG_COMPILER_NO_MERGE_CONSTANTS)
list(APPEND compile_options "-fno-merge-constants")
endif()
if(CONFIG_COMPILER_ENABLE_TEXT_SECTION_LITERALS)
list(APPEND compile_options "-mtext-section-literals")
endif()
if(CONFIG_COMPILER_STACK_CHECK_MODE_NORM)
list(APPEND compile_options "-fstack-protector")
elseif(CONFIG_COMPILER_STACK_CHECK_MODE_STRONG)
@@ -333,10 +337,7 @@ endforeach()
# Only run validation for the main project, not subprojects like bootloader
idf_build_get_property(bootloader_build BOOTLOADER_BUILD)
idf_build_get_property(esp_tee_build ESP_TEE_BUILD)
if((NOT DEFINED ENV{ESP_IDF_DISABLE_COMPONENT_VALIDATION}
OR "$ENV{ESP_IDF_DISABLE_COMPONENT_VALIDATION}" STREQUAL ""
OR "$ENV{ESP_IDF_DISABLE_COMPONENT_VALIDATION}" STREQUAL "0")
AND NOT bootloader_build AND NOT esp_tee_build)
if(NOT bootloader_build AND NOT esp_tee_build)
include("${CMAKE_CURRENT_LIST_DIR}/tools/cmake/component_validation.cmake")
__component_validation_run_checks()
endif()

View File

@@ -140,6 +140,12 @@ Supported since ESP-IDF v5.1.
| release/v5.4 | v5.4.1+ | v5.4.1 |
| release/v5.5 and above | v5.5+ | v5.5 |
### ESP32-P4
#### v1.0, v1.3
Supported since ESP-IDF v5.3.
## What If the ESP-IDF Version Is Lower than the `Required` Version?
Latest ESP-IDF versions can prevent from downloading to, or even execute binaries on unsupported chips. ESP-IDF of versions v4.4.5+, v5.0.1+, v5.1 and above have both esptool download check and bootloader loading check against the chip revision. While ESP-IDF v4.3.5 has only esptool downloading check.

View File

@@ -140,6 +140,11 @@
| release/v5.4 | v5.4.1+ | v5.4.1 |
| release/v5.5 及以上 | v5.5+ | v5.5 |
### ESP32-P4
#### v1.0, v1.3
从 ESP-IDF v5.3 开始支持。
## 如果 ESP-IDF 版本低于 `需求版本` 会出现什么情况?

56
Kconfig
View File

@@ -151,6 +151,13 @@ mainmenu "Espressif IoT Development Framework Configuration"
select IDF_ENV_BRINGUP
select IDF_ENV_FPGA if ESP32H4_SELECTS_REV_MP
config IDF_TARGET_ESP32S31
bool
default "y" if IDF_TARGET="esp32s31"
select IDF_TARGET_ARCH_RISCV
select IDF_ENV_FPGA
select IDF_ENV_BRINGUP
config IDF_TARGET_LINUX
bool
default "y" if IDF_TARGET="linux"
@@ -169,6 +176,7 @@ mainmenu "Espressif IoT Development Framework Configuration"
default 0x0014 if IDF_TARGET_ESP32C61
default 0x0019 if IDF_TARGET_ESP32H21
default 0x001C if IDF_TARGET_ESP32H4
default 0x0020 if IDF_TARGET_ESP32S31
default 0xFFFF
@@ -370,6 +378,27 @@ mainmenu "Espressif IoT Development Framework Configuration"
endchoice
config COMPILER_ENABLE_RISCV_ZCMP
bool "Enable RISCV ZCMP extension"
depends on SOC_CPU_ZCMP_WORKAROUND
default n
help
Enable the RISC-V ZCMP (Compressed Macro) extension to reduce binary size
by optimizing function prologue and epilogue sequences.
Note: Due to a hardware issue on some ESP32 chips (e.g., ESP32C5, ESP32C61,
ESP32H4), executing "cm.push" may re-enable interrupts even when global
interrupts are disabled (mstatus.mie = 0). This can cause unexpected interrupts
during CPU retention or within critical sections.
Workarounds are implemented in the IDF codebase. However, if user code
directly disables interrupts, additional actions may be required. Refer
to code examples under the SOC_CPU_ZCMP_WORKAROUND macro, or disable
the ZCMP extension for source files that contain functions which may
execute while mstatus.mie = 0.
Even with these workarounds, the issue may still affect dual-core variants.
choice COMPILER_OPTIMIZATION_ASSERTION_LEVEL
prompt "Assertion level"
default COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE
@@ -547,6 +576,20 @@ mainmenu "Espressif IoT Development Framework Configuration"
distribution is more uniform across libraries. On downside, it may increase
the binary size and hence should be used during development phase only.
config COMPILER_ENABLE_TEXT_SECTION_LITERALS
bool
depends on IDF_TOOLCHAIN_GCC
depends on IDF_TARGET_ARCH_XTENSA
default y if ESPTOOLPY_FAST_REFLASHING
help
Intersperse Xtensa literals within the text section to keep
them as close as possible to their references. This prevents
literals from being placed into a separate section in the
output file and prevents the linker from combining literal
pools from different object files. Enabling this is necessary
for fast reflashing to prevent mixing code from mutable and
immutable libraries.
config COMPILER_WARN_WRITE_STRINGS
bool "Enable -Wwrite-strings warning flag"
default "n"
@@ -721,6 +764,17 @@ mainmenu "Espressif IoT Development Framework Configuration"
depends on "${IDF_MINIMAL_BUILD}"
source "$COMPONENT_KCONFIGS_SOURCE_FILE"
menu "Configuration for components not included in the build"
depends on "${IDF_BUILD_V2}"
osource "$COMPONENT_KCONFIGS_EXCLUDED_SOURCE_FILE"
endmenu
endmenu
menu "Project configuration for components not included in the build"
depends on "${IDF_BUILD_V2}"
osource "$COMPONENT_KCONFIGS_PROJBUILD_EXCLUDED_SOURCE_FILE"
endmenu
config IDF_EXPERIMENTAL_FEATURES
@@ -743,3 +797,5 @@ mainmenu "Espressif IoT Development Framework Configuration"
- CONFIG_LIBC_PICOLIBC
- CONFIG_GDMA_ENABLE_WEIGHTED_ARBITRATION
- CONFIG_I3C_MASTER_ENABLED
- CONFIG_MBEDTLS_ESP_IDF_USE_PSA_CRYPTO
- CONFIG_ESPTOOLPY_FAST_REFLASHING

View File

@@ -4,14 +4,14 @@ if(${target} STREQUAL "linux")
return() # This component is not supported by the POSIX/Linux simulator
endif()
if(CONFIG_APPTRACE_ENABLE)
if(CONFIG_ESP_TRACE_TRANSPORT_APPTRACE)
set(srcs
"app_trace.c"
"app_trace_util.c"
"host_file_io.c"
)
if(NOT CONFIG_APPTRACE_DEST_UART) # JTAG or ALL
if(NOT CONFIG_APPTRACE_DEST_UART) # JTAG or None
if(CONFIG_IDF_TARGET_ARCH_XTENSA)
list(APPEND srcs "port/xtensa/port_jtag.c")
elseif(CONFIG_IDF_TARGET_ARCH_RISCV)
@@ -20,7 +20,7 @@ if(CONFIG_APPTRACE_ENABLE)
list(APPEND srcs "app_trace_membufs_proto.c")
endif()
if(NOT CONFIG_APPTRACE_DEST_JTAG) # UART or ALL
if(NOT CONFIG_APPTRACE_DEST_JTAG) # UART or None
list(APPEND srcs "port/port_uart.c")
endif()
endif()
@@ -33,28 +33,6 @@ set(include_dirs "include")
set(priv_include_dirs "private_include" "port/include")
if(CONFIG_APPTRACE_SV_ENABLE)
list(APPEND include_dirs
sys_view/Config
sys_view/SEGGER
sys_view/Sample/FreeRTOSV10.4)
list(APPEND srcs
"sys_view/SEGGER/SEGGER_SYSVIEW.c"
"sys_view/Sample/FreeRTOSV10.4/Config/esp/SEGGER_SYSVIEW_Config_FreeRTOS.c"
"sys_view/Sample/FreeRTOSV10.4/SEGGER_SYSVIEW_FreeRTOS.c"
"sys_view/esp/SEGGER_RTT_esp.c"
"sys_view/ext/heap_trace_module.c"
"sys_view/ext/logging.c")
endif()
if(CONFIG_HEAP_TRACING_TOHOST)
list(APPEND srcs "heap_trace_tohost.c")
if(CONFIG_IDF_TARGET_ARCH_XTENSA)
set_source_files_properties(heap_trace_tohost.c PROPERTIES COMPILE_FLAGS -Wno-frame-address)
endif()
endif()
idf_component_register(SRCS "${srcs}"
INCLUDE_DIRS "${include_dirs}"
PRIV_INCLUDE_DIRS "${priv_include_dirs}"

View File

@@ -1,330 +0,0 @@
menu "Application Level Tracing"
config APPTRACE_ENABLE
bool "Enable Application Level Tracing"
default n
help
Enables/disable application tracing module.
This must be enabled to use any tracing library.
choice APPTRACE_DESTINATION
prompt "Data Destination"
default APPTRACE_DEST_JTAG if !PM_ENABLE
default APPTRACE_DEST_UART if PM_ENABLE
depends on APPTRACE_ENABLE
help
Select destination for application trace: JTAG or UART.
When SystemView is enabled, this also controls the SystemView destination.
config APPTRACE_DEST_JTAG
bool "JTAG"
select APPTRACE_TRAX_ENABLE if IDF_TARGET_ARCH_XTENSA
depends on !PM_ENABLE
config APPTRACE_DEST_UART
bool "UART"
config APPTRACE_DEST_NONE
bool "None (runtime selection)"
help
Compile both JTAG and UART interfaces. Increases IRAM usage.
Allows runtime selection via esp_apptrace_get_user_params().
With this option, destination and configuration must be provided
at runtime. Default JTAG and UART settings are defined in
components/app_trace/include/esp_app_trace_config.h.
Override these by implementing esp_apptrace_get_user_params()
in your application.
endchoice
config APPTRACE_BUF_SIZE
int "Size of the apptrace buffer"
depends on APPTRACE_DEST_JTAG && !APPTRACE_TRAX_ENABLE
default 16384
help
Size of the memory buffer for trace data in bytes.
config APPTRACE_DEST_UART_NUM
int "UART port number"
depends on APPTRACE_DEST_UART
range 0 1 if (SOC_UART_NUM <= 2)
range 0 2 if (SOC_UART_NUM <= 3)
range 0 5 if (SOC_UART_NUM <= 6)
default 1
help
UART communication port number for the apptrace destination.
See UART documentation for available port numbers.
config APPTRACE_UART_TX_GPIO
int "UART TX on GPIO<num>"
depends on APPTRACE_DEST_UART
range 0 46
default 12
help
This GPIO is used for UART TX pin.
config APPTRACE_UART_RX_GPIO
int "UART RX on GPIO<num>"
depends on APPTRACE_DEST_UART
range 0 46
default 13
help
This GPIO is used for UART RX pin.
config APPTRACE_UART_BAUDRATE
int
prompt "UART baud rate" if APPTRACE_DEST_UART
depends on APPTRACE_DEST_UART
default 1000000
range 1200 8000000
range 1200 1000000
help
This baud rate is used for UART.
The app's maximum baud rate depends on the UART clock source. If Power Management is disabled,
the UART clock source is the APB clock and all baud rates in the available range will be sufficiently
accurate. If Power Management is enabled, REF_TICK clock source is used so the baud rate is divided
from 1MHz. Baud rates above 1Mbps are not possible and values between 500Kbps and 1Mbps may not be
accurate.
config APPTRACE_UART_RX_BUFF_SIZE
int
prompt "UART RX ring buffer size" if APPTRACE_DEST_UART
depends on APPTRACE_DEST_UART
default 128
range 64 32768
help
Size of the UART input ring buffer.
This size related to the baudrate, system tick frequency and amount of data to transfer.
The data placed to this buffer before sent out to the interface.
config APPTRACE_UART_TX_BUFF_SIZE
int
prompt "UART TX ring buffer size" if APPTRACE_DEST_UART
depends on APPTRACE_DEST_UART
default 4096
range 2048 32768
help
Size of the UART output ring buffer.
This size related to the baudrate, system tick frequency and amount of data to transfer.
config APPTRACE_UART_TX_MSG_SIZE
int
prompt "UART TX message size" if APPTRACE_DEST_UART
depends on APPTRACE_DEST_UART
default 128
range 64 32768
help
Maximum size of the single message to transfer.
config APPTRACE_UART_TASK_PRIO
int
prompt "UART Task Priority" if APPTRACE_DEST_UART
depends on APPTRACE_DEST_UART
default 1
range 1 32
help
UART task priority. In case of high events rate,
this parameter could be changed up to (configMAX_PRIORITIES-1).
config APPTRACE_TRAX_ENABLE
bool
depends on IDF_TARGET_ARCH_XTENSA && !ESP32_TRAX && !ESP32S2_TRAX && !ESP32S3_TRAX
select ESP32_MEMMAP_TRACEMEM
select ESP32S2_MEMMAP_TRACEMEM
select ESP32S3_MEMMAP_TRACEMEM
select ESP32_MEMMAP_TRACEMEM_TWOBANKS
select ESP32S2_MEMMAP_TRACEMEM_TWOBANKS
select ESP32S3_MEMMAP_TRACEMEM_TWOBANKS
default n
help
Enables/disable TRAX tracing HW.
config APPTRACE_LOCK_ENABLE
bool "Internal Sync Lock Enable"
depends on APPTRACE_ENABLE
default n
help
Enables/disable application tracing module internal sync lock.
Keep in mind this will slow down the trace data transfer to the host.
config APPTRACE_ONPANIC_HOST_FLUSH_TMO
int "Timeout for flushing last trace data to host on panic"
depends on APPTRACE_ENABLE
range -1 5000
default -1
help
Timeout for flushing last trace data to host in case of panic. In ms.
Use -1 to disable timeout and wait forever.
config APPTRACE_POSTMORTEM_FLUSH_THRESH
int "Threshold for flushing last trace data to host on panic"
depends on APPTRACE_ENABLE
range 0 16384
default 0
help
Threshold for flushing last trace data to host on panic in post-mortem mode.
This is minimal amount of data needed to perform flush. In bytes.
menu "FreeRTOS SystemView Tracing"
depends on APPTRACE_ENABLE
config APPTRACE_SV_ENABLE
bool "SystemView Tracing Enable"
depends on APPTRACE_ENABLE
default n
help
Enables support for SEGGER SystemView tracing functionality.
choice APPTRACE_SV_CPU
prompt "CPU to trace"
depends on APPTRACE_SV_ENABLE && APPTRACE_DEST_UART && !ESP_SYSTEM_SINGLE_CORE_MODE
default APPTRACE_SV_DEST_CPU_0
help
Define the CPU to trace by SystemView.
config APPTRACE_SV_DEST_CPU_0
bool "CPU0"
help
Send SEGGER SystemView events for Pro CPU.
config APPTRACE_SV_DEST_CPU_1
bool "CPU1"
help
Send SEGGER SystemView events for App CPU.
endchoice
choice APPTRACE_SV_TS_SOURCE
prompt "Timer to use as timestamp source"
depends on APPTRACE_SV_ENABLE
default APPTRACE_SV_TS_SOURCE_CCOUNT if ESP_SYSTEM_SINGLE_CORE_MODE && !PM_ENABLE && !IDF_TARGET_ESP32C3
default APPTRACE_SV_TS_SOURCE_GPTIMER if !ESP_SYSTEM_SINGLE_CORE_MODE && !PM_ENABLE && !IDF_TARGET_ESP32C3
default APPTRACE_SV_TS_SOURCE_ESP_TIMER if PM_ENABLE || IDF_TARGET_ESP32C3
help
SystemView needs to use a hardware timer as the source of timestamps
when tracing. This option selects the timer for it.
config APPTRACE_SV_TS_SOURCE_CCOUNT
bool "CPU cycle counter (CCOUNT)"
depends on ESP_SYSTEM_SINGLE_CORE_MODE && !PM_ENABLE && !IDF_TARGET_ESP32C3
config APPTRACE_SV_TS_SOURCE_GPTIMER
bool "General Purpose Timer (Timer Group)"
depends on !PM_ENABLE && !IDF_TARGET_ESP32C3
config APPTRACE_SV_TS_SOURCE_ESP_TIMER
bool "esp_timer high resolution timer"
endchoice
config APPTRACE_SV_MAX_TASKS
int "Maximum supported tasks"
depends on APPTRACE_SV_ENABLE
range 1 64
default 16
help
Configures maximum supported tasks in sysview debug
config APPTRACE_SV_BUF_WAIT_TMO
int "Trace buffer wait timeout"
depends on APPTRACE_SV_ENABLE
default 500
help
Configures timeout (in us) to wait for free space in trace buffer.
Set to -1 to wait forever and avoid lost events.
config APPTRACE_SV_EVT_OVERFLOW_ENABLE
bool "Trace Buffer Overflow Event"
depends on APPTRACE_SV_ENABLE
default y
help
Enables "Trace Buffer Overflow" event.
config APPTRACE_SV_EVT_ISR_ENTER_ENABLE
bool "ISR Enter Event"
depends on APPTRACE_SV_ENABLE
default y
help
Enables "ISR Enter" event.
config APPTRACE_SV_EVT_ISR_EXIT_ENABLE
bool "ISR Exit Event"
depends on APPTRACE_SV_ENABLE
default y
help
Enables "ISR Exit" event.
config APPTRACE_SV_EVT_ISR_TO_SCHED_ENABLE
bool "ISR Exit to Scheduler Event"
depends on APPTRACE_SV_ENABLE
default y
help
Enables "ISR to Scheduler" event.
config APPTRACE_SV_EVT_TASK_START_EXEC_ENABLE
bool "Task Start Execution Event"
depends on APPTRACE_SV_ENABLE
default y
help
Enables "Task Start Execution" event.
config APPTRACE_SV_EVT_TASK_STOP_EXEC_ENABLE
bool "Task Stop Execution Event"
depends on APPTRACE_SV_ENABLE
default y
help
Enables "Task Stop Execution" event.
config APPTRACE_SV_EVT_TASK_START_READY_ENABLE
bool "Task Start Ready State Event"
depends on APPTRACE_SV_ENABLE
default y
help
Enables "Task Start Ready State" event.
config APPTRACE_SV_EVT_TASK_STOP_READY_ENABLE
bool "Task Stop Ready State Event"
depends on APPTRACE_SV_ENABLE
default y
help
Enables "Task Stop Ready State" event.
config APPTRACE_SV_EVT_TASK_CREATE_ENABLE
bool "Task Create Event"
depends on APPTRACE_SV_ENABLE
default y
help
Enables "Task Create" event.
config APPTRACE_SV_EVT_TASK_TERMINATE_ENABLE
bool "Task Terminate Event"
depends on APPTRACE_SV_ENABLE
default y
help
Enables "Task Terminate" event.
config APPTRACE_SV_EVT_IDLE_ENABLE
bool "System Idle Event"
depends on APPTRACE_SV_ENABLE
default y
help
Enables "System Idle" event.
config APPTRACE_SV_EVT_TIMER_ENTER_ENABLE
bool "Timer Enter Event"
depends on APPTRACE_SV_ENABLE
default y
help
Enables "Timer Enter" event.
config APPTRACE_SV_EVT_TIMER_EXIT_ENABLE
bool "Timer Exit Event"
depends on APPTRACE_SV_ENABLE
default y
help
Enables "Timer Exit" event.
endmenu
endmenu

View File

@@ -0,0 +1,134 @@
menu "Application Level Tracing"
depends on ESP_TRACE_TRANSPORT_APPTRACE
choice APPTRACE_DESTINATION
prompt "Data Destination"
default APPTRACE_DEST_JTAG if !PM_ENABLE
default APPTRACE_DEST_UART if PM_ENABLE
help
Select destination for application trace: JTAG, UART, or both.
config APPTRACE_DEST_JTAG
bool "JTAG"
select APPTRACE_TRAX_ENABLE if IDF_TARGET_ARCH_XTENSA
depends on !PM_ENABLE
config APPTRACE_DEST_UART
bool "UART"
config APPTRACE_DEST_ALL
bool "All (runtime selection)"
help
Compile both JTAG and UART interfaces in advance (higher IRAM usage).
Allows runtime switching between JTAG and UART via esp_apptrace_get_user_params().
If esp_apptrace_get_user_params() is not provided by the
application, JTAG is used by default with the default
configuration defined in components/app_trace/include/esp_app_trace_config.h.
endchoice
config APPTRACE_BUF_SIZE
int "Size of the apptrace buffer"
depends on APPTRACE_DEST_JTAG && !APPTRACE_TRAX_ENABLE
default 16384
help
Size of the memory buffer for trace data in bytes.
config APPTRACE_DEST_UART_NUM
int "UART port number"
depends on APPTRACE_DEST_UART
range 0 1 if (SOC_UART_HP_NUM <= 2)
range 0 2 if (SOC_UART_HP_NUM <= 3)
range 0 4 if (SOC_UART_HP_NUM <= 5)
default 1
help
UART communication port number for the apptrace destination.
See UART documentation for available port numbers.
config APPTRACE_UART_TX_GPIO
int "UART TX on GPIO<num>"
depends on APPTRACE_DEST_UART
range 0 46
default 12
help
This GPIO is used for UART TX pin.
config APPTRACE_UART_RX_GPIO
int "UART RX on GPIO<num>"
depends on APPTRACE_DEST_UART
range 0 46
default 13
help
This GPIO is used for UART RX pin.
config APPTRACE_UART_BAUDRATE
int
prompt "UART baud rate" if APPTRACE_DEST_UART
depends on APPTRACE_DEST_UART
default 1000000
range 1200 8000000
range 1200 1000000
help
This baud rate is used for UART.
The app's maximum baud rate depends on the UART clock source. If Power Management is disabled,
the UART clock source is the APB clock and all baud rates in the available range will be sufficiently
accurate. If Power Management is enabled, REF_TICK clock source is used so the baud rate is divided
from 1MHz. Baud rates above 1Mbps are not possible and values between 500Kbps and 1Mbps may not be
accurate.
config APPTRACE_UART_TX_BUFF_SIZE
int
prompt "UART TX ring buffer size" if APPTRACE_DEST_UART
depends on APPTRACE_DEST_UART
default 4096
range 2048 32768
help
Size of the UART output ring buffer. Must be power of two.
This size related to the baudrate, system tick frequency and amount of data to transfer.
config APPTRACE_UART_TX_MSG_SIZE
int
prompt "UART TX message size" if APPTRACE_DEST_UART
depends on APPTRACE_DEST_UART
default 128
range 64 32768
help
Maximum size of the single message to transfer.
config APPTRACE_TRAX_ENABLE
bool
depends on IDF_TARGET_ARCH_XTENSA && !ESP32_TRAX && !ESP32S2_TRAX && !ESP32S3_TRAX
select ESP32_MEMMAP_TRACEMEM
select ESP32S2_MEMMAP_TRACEMEM
select ESP32S3_MEMMAP_TRACEMEM
select ESP32_MEMMAP_TRACEMEM_TWOBANKS
select ESP32S2_MEMMAP_TRACEMEM_TWOBANKS
select ESP32S3_MEMMAP_TRACEMEM_TWOBANKS
default n
help
Enables/disable TRAX tracing HW.
config APPTRACE_LOCK_ENABLE
bool "Internal Sync Lock Enable"
default n
help
Enables/disable application tracing module internal sync lock to prevent data corruption
when multiple tasks are writing to the same trace buffer.
Keep in mind this will slow down the trace data transfer to the host.
config APPTRACE_ONPANIC_HOST_FLUSH_TMO
int "Timeout for flushing last trace data to host on panic"
range -1 5000
default -1
help
Timeout for flushing last trace data to host in case of panic. In ms.
Use -1 to disable timeout and wait forever.
config APPTRACE_POSTMORTEM_FLUSH_THRESH
int "Threshold for flushing last trace data to host on panic"
range 0 16384
default 0
help
Threshold for flushing last trace data to host on panic in post-mortem mode.
This is minimal amount of data needed to perform flush. In bytes.
endmenu

View File

@@ -32,7 +32,7 @@ typedef struct {
static esp_apptrace_channel_t s_trace_ch;
static volatile int s_trace_ch_hw_initialized = 0;
static esp_err_t esp_apptrace_init(const esp_apptrace_config_t *config)
esp_err_t esp_apptrace_init(const esp_apptrace_config_t *config)
{
__attribute__((unused)) void *hw_data = NULL;
@@ -44,7 +44,7 @@ static esp_err_t esp_apptrace_init(const esp_apptrace_config_t *config)
const esp_apptrace_uart_config_t *uart_config = &config->dest_cfg.uart;
s_trace_ch.hw = esp_apptrace_uart_hw_get(uart_config->uart_num, &hw_data);
s_trace_ch.hw_data = hw_data;
#else // CONFIG_APPTRACE_DEST_NONE allows runtime selection
#else // CONFIG_APPTRACE_DEST_ALL allows runtime selection between destinations
if (config->dest == ESP_APPTRACE_DEST_JTAG) {
s_trace_ch.hw = esp_apptrace_jtag_hw_get(&hw_data);
s_trace_ch.hw_data = hw_data;
@@ -363,6 +363,11 @@ esp_err_t esp_apptrace_set_header_size(esp_apptrace_header_size_t header_size)
return ESP_OK;
}
/* If any trace library (sysview or external) is selected with the apptrace transport,
* initialization will be handled by the esp_trace component
*/
#if CONFIG_ESP_TRACE_LIB_NONE && CONFIG_ESP_TRACE_TRANSPORT_APPTRACE
esp_apptrace_config_t __attribute__((weak)) esp_apptrace_get_user_params(void)
{
esp_apptrace_config_t default_config = APPTRACE_CONFIG_DEFAULT();
@@ -374,3 +379,4 @@ ESP_SYSTEM_INIT_FN(apptrace_early_init, SECONDARY, ESP_SYSTEM_INIT_ALL_CORES, 11
esp_apptrace_config_t config = esp_apptrace_get_user_params();
return esp_apptrace_init(&config);
}
#endif

View File

@@ -1,113 +0,0 @@
/*
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "esp_heap_trace.h"
#include "esp_heap_caps.h"
#if CONFIG_APPTRACE_SV_ENABLE
#include "esp_app_trace.h"
#include "esp_sysview_trace.h"
#endif
#define STACK_DEPTH CONFIG_HEAP_TRACING_STACK_DEPTH
#if CONFIG_HEAP_TRACING_TOHOST
#if !CONFIG_APPTRACE_SV_ENABLE
#error None of the heap tracing backends is enabled! You must enable SystemView compatible tracing to use this feature.
#endif
static bool s_tracing;
esp_err_t heap_trace_init_tohost(void)
{
if (s_tracing) {
return ESP_ERR_INVALID_STATE;
}
return ESP_OK;
}
esp_err_t heap_trace_start(heap_trace_mode_t mode_param)
{
#if CONFIG_APPTRACE_SV_ENABLE
esp_err_t ret = esp_sysview_heap_trace_start((uint32_t) -1);
if (ret != ESP_OK) {
return ret;
}
#endif
s_tracing = true;
return ESP_OK;
}
esp_err_t heap_trace_stop(void)
{
esp_err_t ret = ESP_ERR_NOT_SUPPORTED;
#if CONFIG_APPTRACE_SV_ENABLE
ret = esp_sysview_heap_trace_stop();
#endif
s_tracing = false;
return ret;
}
esp_err_t heap_trace_resume(void)
{
return heap_trace_start(HEAP_TRACE_ALL);
}
size_t heap_trace_get_count(void)
{
return 0;
}
esp_err_t heap_trace_get(size_t index, heap_trace_record_t *record)
{
return ESP_ERR_NOT_SUPPORTED;
}
esp_err_t heap_trace_summary(heap_trace_summary_t *summary)
{
return ESP_ERR_NOT_SUPPORTED;
}
void heap_trace_dump(void)
{
return;
}
void heap_trace_dump_caps(__attribute__((unused)) const uint32_t caps)
{
return;
}
/* Add a new allocation to the heap trace records */
static HEAP_IRAM_ATTR void record_allocation(const heap_trace_record_t *record)
{
if (!s_tracing) {
return;
}
#if CONFIG_APPTRACE_SV_ENABLE
esp_sysview_heap_trace_alloc(record->address, record->size, record->alloced_by);
#endif
}
/* record a free event in the heap trace log
For HEAP_TRACE_ALL, this means filling in the freed_by pointer.
For HEAP_TRACE_LEAKS, this means removing the record from the log.
*/
static HEAP_IRAM_ATTR void record_free(void *p, void **callers)
{
if (!s_tracing) {
return;
}
#if CONFIG_APPTRACE_SV_ENABLE
esp_sysview_heap_trace_free(p, callers);
#endif
}
#include "heap_trace.inc"
#endif /*CONFIG_HEAP_TRACING_TOHOST*/

View File

@@ -16,22 +16,19 @@ extern "C" {
#endif
/**
* @brief Get custom trace initialization parameters (optional callback)
* @brief Initializes application tracing module for the selected destination and configuration.
*
* This is an optional callback function that user applications can implement to provide
* custom trace configuration. A weak default implementation exists in the app_trace component
* that returns menuconfig defaults (APPTRACE_CONFIG_DEFAULT()). User applications can override
* this by providing their own implementation.
*
* This function is called during early system initialization (before app_main) on all cores.
* @note Should be called before any esp_apptrace_xxx call.
*
* @return ESP_OK on success, otherwise see esp_err_t
*/
esp_apptrace_config_t esp_apptrace_get_user_params(void);
esp_err_t esp_apptrace_init(const esp_apptrace_config_t *config);
/**
* @brief Configures down buffer.
* @note Needs to be called before attempting to receive any data using esp_apptrace_down_buffer_get and esp_apptrace_read.
* This function does not protect internal data by lock.
*
* @note Needs to be called before attempting to receive any data using esp_apptrace_down_buffer_get and
* esp_apptrace_read. This function does not protect internal data by lock.
*
* @param buf Address of buffer to use for down channel (host to target) data.
* @param size Size of the buffer.
@@ -262,8 +259,8 @@ int esp_apptrace_feof(void *stream);
#define APPTRACE_JTAG_CONFIG_DEFAULT() { \
.dest = ESP_APPTRACE_DEST_JTAG, \
.dest_cfg.jtag = {0}, \
.panic_flush_tmo = CONFIG_APPTRACE_ONPANIC_HOST_FLUSH_TMO, \
.panic_flush_thresh = CONFIG_APPTRACE_POSTMORTEM_FLUSH_THRESH, \
.flush_tmo = CONFIG_APPTRACE_ONPANIC_HOST_FLUSH_TMO, \
.flush_thresh = CONFIG_APPTRACE_POSTMORTEM_FLUSH_THRESH, \
}
#endif
@@ -275,13 +272,11 @@ int esp_apptrace_feof(void *stream);
.tx_pin_num = CONFIG_APPTRACE_UART_TX_GPIO, \
.rx_pin_num = CONFIG_APPTRACE_UART_RX_GPIO, \
.baud_rate = CONFIG_APPTRACE_UART_BAUDRATE, \
.rx_buff_size = CONFIG_APPTRACE_UART_RX_BUFF_SIZE, \
.tx_buff_size = CONFIG_APPTRACE_UART_TX_BUFF_SIZE, \
.tx_msg_size = CONFIG_APPTRACE_UART_TX_MSG_SIZE, \
.task_prio = CONFIG_APPTRACE_UART_TASK_PRIO, \
}, \
.panic_flush_tmo = CONFIG_APPTRACE_ONPANIC_HOST_FLUSH_TMO, \
.panic_flush_thresh = CONFIG_APPTRACE_POSTMORTEM_FLUSH_THRESH, \
.flush_tmo = CONFIG_APPTRACE_ONPANIC_HOST_FLUSH_TMO, \
.flush_thresh = CONFIG_APPTRACE_POSTMORTEM_FLUSH_THRESH, \
}
#endif

View File

@@ -8,10 +8,12 @@
#include "sdkconfig.h"
/* Default configurations for runtime selection (CONFIG_APPTRACE_DEST_NONE)
* These values are used when CONFIG_APPTRACE_DEST_NONE is selected in menuconfig.
* To customize at runtime, implement esp_apptrace_get_user_params()
* in your application. See esp_app_trace.h for details.
/* Default configurations for runtime selection (APPTRACE_DEST_ALL)
* These values are used when building with both JTAG and UART enabled
* to allow runtime selection. You can switch between destinations
* via esp_apptrace_get_user_params(). If this function is
* not provided by the application, JTAG is used by default with the
* configuration defined below. See esp_app_trace.h for details.
*/
#if !defined(CONFIG_APPTRACE_UART_TX_GPIO) || !defined(CONFIG_APPTRACE_UART_RX_GPIO)
@@ -22,10 +24,6 @@
#define CONFIG_APPTRACE_BUF_SIZE 16384
#endif
#ifndef CONFIG_APPTRACE_UART_RX_BUFF_SIZE
#define CONFIG_APPTRACE_UART_RX_BUFF_SIZE 128
#endif
#ifndef CONFIG_APPTRACE_UART_TX_BUFF_SIZE
#define CONFIG_APPTRACE_UART_TX_BUFF_SIZE 4096
#endif
@@ -38,10 +36,6 @@
#define CONFIG_APPTRACE_UART_BAUDRATE 1000000
#endif
#ifndef CONFIG_APPTRACE_UART_TASK_PRIO
#define CONFIG_APPTRACE_UART_TASK_PRIO 1
#endif
#ifndef CONFIG_APPTRACE_UART_TX_GPIO
#define CONFIG_APPTRACE_UART_TX_GPIO U1TXD_GPIO_NUM
#endif
@@ -54,8 +48,4 @@
#define CONFIG_APPTRACE_DEST_UART_NUM 1
#endif
#ifndef CONFIG_APPTRACE_SV_DEST_CPU_0
#define CONFIG_APPTRACE_SV_DEST_CPU_0 1
#endif
#endif /* ESP_APP_TRACE_CONFIG_H_ */

View File

@@ -27,7 +27,7 @@ typedef struct {
/** Tracing module synchronization lock */
typedef struct {
spinlock_t mux;
unsigned int_state;
unsigned int int_state;
} esp_apptrace_lock_t;
/** Ring buffer control structure.
@@ -59,10 +59,8 @@ typedef struct {
int tx_pin_num; ///< TX pin number
int rx_pin_num; ///< RX pin number
int baud_rate; ///< Baud rate
uint32_t rx_buff_size; ///< RX ring buffer size
uint32_t tx_buff_size; ///< TX ring buffer size
uint32_t tx_msg_size; ///< Maximum size of the single message to transfer.
int task_prio; ///< Task priority
} esp_apptrace_uart_config_t;
/**
@@ -86,8 +84,8 @@ typedef struct {
} jtag;
} dest_cfg; ///< Destination-specific configuration
uint32_t panic_flush_tmo; ///< Panic flush timeout in milliseconds
uint32_t panic_flush_thresh; ///< Panic flush threshold in bytes
uint32_t flush_tmo; ///< Flush timeout in milliseconds
uint32_t flush_thresh; ///< Flush threshold in bytes
} esp_apptrace_config_t;
#ifdef __cplusplus

View File

@@ -1,80 +0,0 @@
/*
* SPDX-FileCopyrightText: 2018-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ESP_SYSVIEW_TRACE_H_
#define ESP_SYSVIEW_TRACE_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <stdarg.h>
#include "esp_err.h"
#include "SEGGER_RTT.h" // SEGGER_RTT_ESP_Flush
#include "esp_app_trace_util.h" // ESP_APPTRACE_TMO_INFINITE
/**
* @brief Flushes remaining data in SystemView trace buffer to host.
*
* @param tmo Timeout for operation (in us). Use ESP_APPTRACE_TMO_INFINITE to wait indefinitely.
*
* @return ESP_OK.
*/
static inline esp_err_t esp_sysview_flush(uint32_t tmo)
{
SEGGER_RTT_ESP_Flush(0, tmo);
return ESP_OK;
}
/**
* @brief vprintf-like function to sent log messages to the host.
*
* @param format Address of format string.
* @param args List of arguments.
*
* @return Number of bytes written.
*/
int esp_sysview_vprintf(const char * format, va_list args);
/**
* @brief Starts SystemView heap tracing.
*
* @param tmo Timeout (in us) to wait for the host to be connected. Use -1 to wait forever.
*
* @return ESP_OK on success, ESP_ERR_TIMEOUT if operation has been timed out.
*/
esp_err_t esp_sysview_heap_trace_start(uint32_t tmo);
/**
* @brief Stops SystemView heap tracing.
*
* @return ESP_OK.
*/
esp_err_t esp_sysview_heap_trace_stop(void);
/**
* @brief Sends heap allocation event to the host.
*
* @param addr Address of allocated block.
* @param size Size of allocated block.
* @param callers Pointer to array with callstack addresses.
* Array size must be CONFIG_HEAP_TRACING_STACK_DEPTH.
*/
void esp_sysview_heap_trace_alloc(void *addr, uint32_t size, const void *callers);
/**
* @brief Sends heap de-allocation event to the host.
*
* @param addr Address of de-allocated block.
* @param callers Pointer to array with callstack addresses.
* Array size must be CONFIG_HEAP_TRACING_STACK_DEPTH.
*/
void esp_sysview_heap_trace_free(void *addr, const void *callers);
#ifdef __cplusplus
}
#endif
#endif //ESP_SYSVIEW_TRACE_H_

View File

@@ -1,24 +1,11 @@
[mapping:app_trace]
archive: libapp_trace.a
entries:
if APPTRACE_ENABLE = y:
if ESP_TRACE_TRANSPORT_APPTRACE = y:
app_trace (noflash)
app_trace_util (noflash)
if APPTRACE_DEST_JTAG = y || APPTRACE_DEST_NONE = y:
if APPTRACE_DEST_JTAG = y || APPTRACE_DEST_ALL = y:
port_jtag (noflash)
app_trace_membufs_proto (noflash)
if APPTRACE_DEST_UART = y || APPTRACE_DEST_NONE = y:
if APPTRACE_DEST_UART = y || APPTRACE_DEST_ALL = y:
port_uart (noflash)
if APPTRACE_SV_ENABLE = y:
SEGGER_SYSVIEW (noflash)
SEGGER_RTT_esp (noflash)
SEGGER_SYSVIEW_Config_FreeRTOS (noflash)
SEGGER_SYSVIEW_FreeRTOS (noflash)
[mapping:app_trace_driver]
archive: libesp_driver_gptimer.a
entries:
if APPTRACE_SV_TS_SOURCE_GPTIMER = y:
gptimer: gptimer_get_raw_count (noflash)
else:
* (default)

View File

@@ -3,45 +3,118 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include "soc/soc.h"
#include <inttypes.h>
#include "esp_err.h"
#include "esp_log.h"
#include "esp_cpu.h"
#include "esp_app_trace_config.h"
#include "esp_app_trace_port.h"
#include "esp_attr.h"
#include "esp_private/uart_share_hw_ctrl.h"
#include "hal/uart_hal.h"
#include "hal/gpio_hal.h"
#include "driver/uart.h"
#include "soc/uart_periph.h"
#include "esp_clk_tree.h"
#include "esp_private/esp_clk_tree_common.h"
#include "soc/gpio_periph.h"
#include "esp_rom_gpio.h"
#include "hal/uart_ll.h"
#include "esp_intr_alloc.h"
#include "esp_heap_caps.h"
#include "esp_private/esp_gpio_reserve.h"
/** UART HW transport data */
typedef struct {
uint8_t inited;
#if CONFIG_APPTRACE_LOCK_ENABLE
esp_apptrace_lock_t lock; // sync lock
#include "esp_app_trace_port.h"
#include "esp_app_trace_util.h"
#include "esp_app_trace_types.h"
static const char *TAG = "esp_apptrace_uart";
#ifndef MIN
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif
uart_port_t port_num;
/* TX data ring buffer */
uint8_t *tx_data_buff;
uint32_t tx_data_buff_size;
int32_t tx_data_buff_in;
int32_t tx_data_buff_out;
typedef struct {
uint8_t *buffer; ///< Ring buffer data
uint32_t max_size; ///< Ring buffer maximum size (must be power of 2)
volatile uint32_t count; ///< Number of bytes currently in the buffer
volatile uint32_t head; ///< Write pointer index
volatile uint32_t tail; ///< Read pointer index
} esp_apptrace_uart_rb_t;
typedef struct {
int inited;
volatile bool tx_busy; ///< TX busy flag
uart_hal_context_t hal_ctx; ///< UART HAL context
esp_apptrace_uart_rb_t tx_ring; ///< TX ring buffer
intr_handle_t intr_handle; ///< Interrupt handle
/* TX message buffer */
uint8_t *tx_msg_buff;
uint32_t tx_msg_buff_size;
uint32_t tx_pending_msg_size;
uint8_t *tx_msg_buff; ///< TX message buffer to provide with get_up_buffer
uint32_t tx_msg_buff_size; ///< TX message buffer size & maximum size of the single message to transfer.
uint32_t tx_pending_msg_size; ///< Pending message size to send with put_up_buffer
/* RX message buffer */
uint8_t *down_buffer;
uint32_t down_buffer_size;
uint8_t *rx_msg_buff; ///< RX message buffer provided with down_buffer_config function
uint32_t rx_msg_buff_size; ///< RX message buffer size provided with down_buffer_config function
#if CONFIG_APPTRACE_LOCK_ENABLE
esp_apptrace_lock_t lock; ///< Sync lock
#endif
/* Buffer overflow flags */
bool message_buff_overflow;
bool circular_buff_overflow;
} esp_apptrace_uart_data_t;
const static char *TAG = "esp_apptrace_uart";
static inline bool is_power_of_two(uint32_t n)
{
return n != 0 && (n & (n - 1)) == 0;
}
static inline uint32_t ring_buffer_mask(const esp_apptrace_uart_rb_t *rb)
{
return rb->max_size - 1;
}
/* Get the length of the data in the ring buffer */
static inline uint32_t ring_buffer_data_len(const esp_apptrace_uart_rb_t *rb)
{
return rb->count;
}
/* Get the length of the free space in the ring buffer */
static inline uint32_t ring_buffer_free_len(const esp_apptrace_uart_rb_t *rb)
{
return rb->max_size - rb->count;
}
static inline void ring_buffer_advance_tail(esp_apptrace_uart_rb_t *rb, uint32_t count)
{
rb->tail = (rb->tail + count) & ring_buffer_mask(rb);
rb->count -= count;
}
static inline void ring_buffer_advance_head(esp_apptrace_uart_rb_t *rb, uint32_t count)
{
rb->head = (rb->head + count) & ring_buffer_mask(rb);
rb->count += count;
}
static inline uint32_t ring_buffer_calc_to_send(const esp_apptrace_uart_rb_t *rb, uint32_t tx_msg_size)
{
uint32_t used = ring_buffer_data_len(rb);
if (used == 0) {
return 0;
}
uint32_t cont = rb->max_size - rb->tail;
uint32_t n = MIN(used, cont);
/* Apply message size limit if specified */
if (tx_msg_size && tx_msg_size < n) {
return tx_msg_size;
}
return n;
}
static esp_err_t esp_apptrace_uart_lock(void *hw_data, esp_apptrace_tmo_t *tmo)
{
@@ -61,271 +134,320 @@ static esp_err_t esp_apptrace_uart_unlock(void *hw_data)
#if CONFIG_APPTRACE_LOCK_ENABLE
esp_apptrace_uart_data_t *uart_data = hw_data;
ret = esp_apptrace_lock_give(&uart_data->lock);
assert(ret == ESP_OK && "Failed to unlock apptrace uart lock!");
#endif
return ret;
}
static inline void esp_apptrace_uart_hw_init(void)
static esp_err_t ring_buffer_put(esp_apptrace_uart_rb_t *rb, const uint8_t *data, uint32_t len)
{
ESP_APPTRACE_LOGI("Initialized UART on CPU%d", esp_cpu_get_core_id());
}
/*****************************************************************************************/
/***************************** Apptrace HW iface *****************************************/
/*****************************************************************************************/
static esp_err_t esp_apptrace_send_uart_data(void *hw_data, const char *data, uint32_t size, esp_apptrace_tmo_t *tmo)
{
esp_apptrace_uart_data_t *uart_data = hw_data;
esp_err_t res = esp_apptrace_uart_lock(uart_data, tmo);
if (res != ESP_OK) {
return res;
/* Drop oldest. Make available space if needed */
uint32_t free_len = ring_buffer_free_len(rb);
if (len > free_len) {
uint32_t need = len - free_len;
ring_buffer_advance_tail(rb, need);
}
// We store current out position to handle it without lock
volatile int32_t out_position = uart_data->tx_data_buff_out;
int len_free = uart_data->tx_data_buff_size - (uart_data->tx_data_buff_in - out_position);
if (out_position > uart_data->tx_data_buff_in) {
len_free = out_position - uart_data->tx_data_buff_in;
}
int check_len = uart_data->tx_data_buff_size - uart_data->tx_data_buff_in;
if (size <= len_free) {
if (check_len >= size) {
memcpy(&uart_data->tx_data_buff[uart_data->tx_data_buff_in], data, size);
uart_data->tx_data_buff_in += size;
} else {
memcpy(&uart_data->tx_data_buff[uart_data->tx_data_buff_in],
data,
uart_data->tx_data_buff_size - uart_data->tx_data_buff_in);
memcpy(&uart_data->tx_data_buff[0],
&data[uart_data->tx_data_buff_size - uart_data->tx_data_buff_in],
size - (uart_data->tx_data_buff_size - uart_data->tx_data_buff_in));
uart_data->tx_data_buff_in = size - (uart_data->tx_data_buff_size - uart_data->tx_data_buff_in);
}
if (uart_data->tx_data_buff_in >= uart_data->tx_data_buff_size) {
uart_data->tx_data_buff_in = 0;
}
uint32_t head = rb->head;
uint32_t space_to_end = rb->max_size - head;
if (len <= space_to_end) {
memcpy(&rb->buffer[head], data, len);
} else {
uart_data->circular_buff_overflow = true;
memcpy(&rb->buffer[head], data, space_to_end);
memcpy(&rb->buffer[0], &data[space_to_end], len - space_to_end);
}
if (esp_apptrace_uart_unlock(uart_data) != ESP_OK) {
assert(false && "Failed to unlock apptrace data!");
}
ring_buffer_advance_head(rb, len);
return ESP_OK;
}
static void send_buff_data(void *hw_data, esp_apptrace_tmo_t *tmo)
static esp_err_t ring_buffer_init(esp_apptrace_uart_rb_t *rb, uint32_t size)
{
esp_apptrace_uart_data_t *uart_data = hw_data;
rb->buffer = heap_caps_malloc(size, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
if (!rb->buffer) {
return ESP_ERR_NO_MEM;
}
if (uart_data->tx_data_buff_in == uart_data->tx_data_buff_out) {
return;
}
// We store current in position to handle it without lock
volatile int32_t in_position = uart_data->tx_data_buff_in;
if (in_position > uart_data->tx_data_buff_out) {
int bytes_sent = uart_write_bytes(uart_data->port_num,
&uart_data->tx_data_buff[uart_data->tx_data_buff_out],
in_position - uart_data->tx_data_buff_out);
uart_data->tx_data_buff_out += bytes_sent;
} else {
int bytes_sent = uart_write_bytes(uart_data->port_num,
&uart_data->tx_data_buff[uart_data->tx_data_buff_out],
uart_data->tx_data_buff_size - uart_data->tx_data_buff_out);
uart_data->tx_data_buff_out += bytes_sent;
if (uart_data->tx_data_buff_out >= uart_data->tx_data_buff_size) {
uart_data->tx_data_buff_out = 0;
}
}
rb->max_size = size;
rb->count = 0;
rb->head = 0;
rb->tail = 0;
return ESP_OK;
}
#define APP_TRACE_UART_STOP_WAIT_TMO 1000000 //us
static void esp_apptrace_send_uart_tx_task(void *arg)
static void IRAM_ATTR esp_apptrace_uart_isr_handler(void *arg)
{
esp_apptrace_uart_data_t *uart_data = arg;
esp_apptrace_tmo_t tmo;
esp_apptrace_uart_rb_t *rb = &uart_data->tx_ring;
esp_apptrace_tmo_init(&tmo, APP_TRACE_UART_STOP_WAIT_TMO);
uint32_t intr_status = uart_hal_get_intsts_mask(&uart_data->hal_ctx);
vTaskDelay(10);
while (1) {
send_buff_data(uart_data, &tmo);
vTaskDelay(10);
if (uart_data->circular_buff_overflow == true) {
uart_data->circular_buff_overflow = false;
ESP_LOGE(TAG, "Buffer overflow. Please increase UART baudrate, or increase UART TX ring buffer size in menuconfig.");
if (intr_status & UART_INTR_TXFIFO_EMPTY) {
uart_hal_clr_intsts_mask(&uart_data->hal_ctx, UART_INTR_TXFIFO_EMPTY);
uint32_t to_send = ring_buffer_calc_to_send(rb, uart_data->tx_msg_buff_size);
if (to_send > 0) {
uint32_t written = 0;
uart_hal_write_txfifo(&uart_data->hal_ctx, &rb->buffer[rb->tail], to_send, &written);
ring_buffer_advance_tail(rb, written);
}
if (uart_data->message_buff_overflow == true) {
uart_data->message_buff_overflow = false;
ESP_LOGE(TAG, "Message size more then message buffer!");
/* If ring buffer is empty, disable TX interrupt */
if (ring_buffer_data_len(rb) == 0) {
uart_ll_disable_intr_mask(uart_data->hal_ctx.dev, UART_INTR_TXFIFO_EMPTY);
uart_data->tx_busy = false;
}
}
}
static const int APP_TRACE_UART_RX_BUF_SIZE = 4024;
static esp_err_t esp_apptrace_uart_init(void *hw_data, const esp_apptrace_config_t *config)
{
esp_err_t ret = ESP_ERR_INVALID_ARG;
uint64_t gpio_mask = 0;
esp_apptrace_uart_data_t *uart_data = hw_data;
const esp_apptrace_uart_config_t *apptrace_uart_config = &config->dest_cfg.uart;
const esp_apptrace_uart_config_t *uart_config = &config->dest_cfg.uart;
/* esp_apptrace_uart_init() is called on every core, so ensure to do main initialization only once */
/* Init function is called on every core, so ensure to do main setup only once */
int core_id = esp_cpu_get_core_id();
if (core_id == 0) {
uart_data->tx_data_buff_size = apptrace_uart_config->tx_buff_size;
uart_data->tx_data_buff = heap_caps_malloc(uart_data->tx_data_buff_size, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
if (uart_data->tx_data_buff == NULL) {
return ESP_ERR_NO_MEM;
if (uart_config->uart_num == CONFIG_ESP_CONSOLE_UART_NUM) {
ESP_APPTRACE_LOGE("Application trace UART and console UART cannot use the same port number");
return ESP_ERR_INVALID_ARG;
}
uart_data->tx_data_buff_in = 0;
uart_data->tx_data_buff_out = 0;
uart_data->tx_msg_buff_size = apptrace_uart_config->tx_msg_size;
if (uart_config->uart_num >= SOC_UART_HP_NUM) {
ESP_APPTRACE_LOGE("UART port number %d is not supported!", uart_config->uart_num);
return ESP_ERR_NOT_SUPPORTED;
}
if (GPIO_IS_VALID_GPIO(uart_config->tx_pin_num)) {
gpio_mask |= BIT64(uart_config->tx_pin_num);
}
if (GPIO_IS_VALID_GPIO(uart_config->rx_pin_num)) {
gpio_mask |= BIT64(uart_config->rx_pin_num);
}
if (gpio_mask == 0) {
ESP_LOGE(TAG, "No valid GPIOs to reserve");
return ESP_ERR_INVALID_STATE;
}
uint64_t r = esp_gpio_reserve(gpio_mask);
if (r & gpio_mask) {
ESP_LOGE(TAG, "GPIO(s) are already reserved: 0x%"PRIx64, r & gpio_mask);
return ESP_ERR_INVALID_STATE;
}
uart_data->hal_ctx.dev = UART_LL_GET_HW(uart_config->uart_num);
HP_UART_BUS_CLK_ATOMIC() {
uart_ll_enable_bus_clock(uart_config->uart_num, true);
uart_ll_reset_register(uart_config->uart_num);
}
HP_UART_SRC_CLK_ATOMIC() {
uart_ll_sclk_enable(uart_data->hal_ctx.dev);
}
uint32_t sclk_hz;
esp_clk_tree_src_get_freq_hz(UART_SCLK_DEFAULT, ESP_CLK_TREE_SRC_FREQ_PRECISION_CACHED, &sclk_hz);
/* Enable the default clock source */
esp_clk_tree_enable_src(UART_SCLK_DEFAULT, true);
/* Initialize UART HAL (sets default 8N1 mode) */
uart_hal_init(&uart_data->hal_ctx, uart_config->uart_num);
ESP_LOGI(TAG, "uart_hal_init: %d", uart_config->uart_num);
HP_UART_SRC_CLK_ATOMIC() {
uart_hal_set_sclk(&uart_data->hal_ctx, UART_SCLK_DEFAULT);
uart_hal_set_baudrate(&uart_data->hal_ctx, uart_config->baud_rate, sclk_hz);
}
/* Configure FIFO thresholds */
uart_hal_set_txfifo_empty_thr(&uart_data->hal_ctx, 16); /* Slow down IRQ rate */
uart_hal_set_rxfifo_full_thr(&uart_data->hal_ctx, 1);
/* Initialize TX ring buffer */
if (uart_config->tx_buff_size == 0 || !is_power_of_two(uart_config->tx_buff_size)) {
ESP_APPTRACE_LOGE("TX ring buffer size (%u) must be a power of two and greater than 0",
uart_config->tx_buff_size);
goto err_init_ring_buff;
}
ret = ring_buffer_init(&uart_data->tx_ring, uart_config->tx_buff_size);
if (ret != ESP_OK) {
ESP_APPTRACE_LOGE("Failed to initialize TX ring buffer");
goto err_init_ring_buff;
}
/* Initialize TX message buffer for providing with get_up_buffer */
uart_data->tx_msg_buff_size = uart_config->tx_msg_size;
uart_data->tx_msg_buff = heap_caps_malloc(uart_data->tx_msg_buff_size, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
if (uart_data->tx_msg_buff == NULL) {
return ESP_ERR_NO_MEM;
ESP_APPTRACE_LOGE("Failed to initialize TX message buffer");
ret = ESP_ERR_NO_MEM;
goto err_alloc_msg_buff;
}
uart_data->tx_pending_msg_size = 0;
uart_data->down_buffer_size = 0;
uart_data->message_buff_overflow = false;
uart_data->circular_buff_overflow = false;
assert((uart_data->port_num <= SOC_UART_NUM) && "Not possible to configure UART. Please check selected UART port");
/* Disable all interrupts and clear status */
uart_ll_disable_intr_mask(uart_data->hal_ctx.dev, UART_LL_INTR_MASK);
uart_ll_clr_intsts_mask(uart_data->hal_ctx.dev, UART_LL_INTR_MASK);
int source_clk = UART_SCLK_DEFAULT;
#if SOC_UART_LP_NUM > 0
if (uart_data->port_num >= SOC_UART_HP_NUM) {
source_clk = LP_UART_SCLK_DEFAULT;
/* Install interrupt handler */
int intr_alloc_flags = 0;
ret = esp_intr_alloc(uart_periph_signal[uart_config->uart_num].irq, intr_alloc_flags,
esp_apptrace_uart_isr_handler, uart_data, &uart_data->intr_handle);
if (ret != ESP_OK) {
ESP_APPTRACE_LOGE("Failed to allocate interrupt: %s", esp_err_to_name(ret));
goto err_alloc_intr;
}
#endif
const uart_config_t uart_config = {
.baud_rate = apptrace_uart_config->baud_rate,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_DISABLE,
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
.source_clk = source_clk,
};
ESP_LOGI(TAG, "UART baud rate: %i", apptrace_uart_config->baud_rate);
// We won't use a buffer for sending data.
esp_err_t __attribute__((unused)) err = uart_driver_install(uart_data->port_num,
APP_TRACE_UART_RX_BUF_SIZE,
APP_TRACE_UART_RX_BUF_SIZE,
0,
NULL,
0);
assert((err == ESP_OK) && "Not possible to install UART. Please check and change uart parameters!");
err = uart_param_config(uart_data->port_num, &uart_config);
assert((err == ESP_OK) && "Not possible to configure UART. Please check and change uart parameters!");
err = uart_set_pin(uart_data->port_num,
apptrace_uart_config->tx_pin_num,
apptrace_uart_config->rx_pin_num,
UART_PIN_NO_CHANGE,
UART_PIN_NO_CHANGE);
assert((err == ESP_OK) && "Not possible to configure UART RX/TX pins. Please check and change the uart pins!");
/* Reset FIFOs */
uart_hal_rxfifo_rst(&uart_data->hal_ctx);
uart_hal_txfifo_rst(&uart_data->hal_ctx);
int uart_prio = apptrace_uart_config->task_prio;
if (uart_prio >= (configMAX_PRIORITIES - 1)) {
uart_prio = configMAX_PRIORITIES - 1;
}
err = xTaskCreate(esp_apptrace_send_uart_tx_task, "app_trace_uart_tx_task", 2500, uart_data, uart_prio, NULL);
assert((err == pdPASS) && "Not possible to configure UART. Not possible to create task!");
/* Configure GPIO pins for RX and TX */
const uint32_t tx_idx = UART_PERIPH_SIGNAL(uart_config->uart_num, SOC_UART_PERIPH_SIGNAL_TX);
const uint32_t rx_idx = UART_PERIPH_SIGNAL(uart_config->uart_num, SOC_UART_PERIPH_SIGNAL_RX);
/* Configure TX pin */
gpio_ll_func_sel(&GPIO, uart_config->tx_pin_num, PIN_FUNC_GPIO);
esp_rom_gpio_pad_pullup_only(uart_config->tx_pin_num);
esp_rom_gpio_connect_out_signal(uart_config->tx_pin_num, tx_idx, 0, 0);
/* Configure RX pin */
gpio_ll_input_enable(&GPIO, uart_config->rx_pin_num);
esp_rom_gpio_pad_pullup_only(uart_config->rx_pin_num);
esp_rom_gpio_connect_in_signal(uart_config->rx_pin_num, rx_idx, 0);
#if CONFIG_APPTRACE_LOCK_ENABLE
esp_apptrace_lock_init(&uart_data->lock);
#endif
}
// init UART on this CPU
esp_apptrace_uart_hw_init();
uart_data->inited |= 1 << core_id;
uart_data->tx_busy = false;
return ESP_OK;
err_alloc_intr:
heap_caps_free(uart_data->tx_msg_buff);
err_alloc_msg_buff:
heap_caps_free(uart_data->tx_ring.buffer);
err_init_ring_buff:
esp_clk_tree_enable_src(UART_SCLK_DEFAULT, false);
HP_UART_SRC_CLK_ATOMIC() {
uart_ll_sclk_disable(uart_data->hal_ctx.dev);
}
HP_UART_BUS_CLK_ATOMIC() {
uart_ll_enable_bus_clock(uart_config->uart_num, false);
}
esp_gpio_revoke(gpio_mask);
return ret;
}
static uint8_t *esp_apptrace_uart_up_buffer_get(void *hw_data, uint32_t size, esp_apptrace_tmo_t *tmo)
{
esp_apptrace_uart_data_t *uart_data = hw_data;
if (size > uart_data->tx_msg_buff_size) {
uart_data->message_buff_overflow = true;
if (size == 0 || size > uart_data->tx_msg_buff_size) {
return NULL;
}
if (esp_apptrace_uart_lock(uart_data, tmo) != ESP_OK) {
return NULL;
}
if (uart_data->tx_pending_msg_size != 0) {
// A previous message was not sent.
esp_apptrace_uart_unlock(uart_data);
return NULL;
}
esp_err_t res = esp_apptrace_uart_lock(uart_data, tmo);
if (res != ESP_OK) {
return NULL;
}
uint8_t *ptr = uart_data->tx_msg_buff;
// Set the amount of data to send
uart_data->tx_pending_msg_size = size;
// now we can safely unlock apptrace to allow other tasks/ISRs to get other buffers and write their data
if (esp_apptrace_uart_unlock(uart_data) != ESP_OK) {
assert(false && "Failed to unlock apptrace data!");
}
return ptr;
esp_apptrace_uart_unlock(uart_data);
return uart_data->tx_msg_buff;
}
static esp_err_t esp_apptrace_uart_up_buffer_put(void *hw_data, uint8_t *ptr, esp_apptrace_tmo_t *tmo)
{
esp_apptrace_uart_data_t *uart_data = hw_data;
esp_err_t res = esp_apptrace_send_uart_data(uart_data, (const char *)ptr, uart_data->tx_pending_msg_size, tmo);
// Clear size to indicate that we've sent data
esp_apptrace_uart_rb_t *rb = &uart_data->tx_ring;
esp_err_t res = esp_apptrace_uart_lock(uart_data, tmo);
if (res != ESP_OK) {
return res;
}
/* Add data to ring buffer */
ring_buffer_put(rb, ptr, uart_data->tx_pending_msg_size);
uart_data->tx_pending_msg_size = 0;
return res;
esp_apptrace_uart_unlock(uart_data);
// Trigger transmission if not already in progress
if (!uart_data->tx_busy) {
uart_data->tx_busy = true;
/* Enable TX interrupt */
uart_ll_clr_intsts_mask(uart_data->hal_ctx.dev, UART_INTR_TXFIFO_EMPTY);
uart_ll_ena_intr_mask(uart_data->hal_ctx.dev, UART_INTR_TXFIFO_EMPTY);
}
return ESP_OK;
}
static void esp_apptrace_uart_down_buffer_config(void *hw_data, uint8_t *buf, uint32_t size)
{
esp_apptrace_uart_data_t *uart_data = hw_data;
uart_data->down_buffer = (uint8_t *)malloc(size);
if (uart_data->down_buffer == NULL) {
assert(false && "Failed to allocate apptrace uart down buffer!");
}
uart_data->down_buffer_size = size;
assert(buf != NULL && "Down buffer cannot be NULL");
assert(size > 0 && "Down buffer size must be greater than 0");
uart_data->rx_msg_buff = buf;
uart_data->rx_msg_buff_size = size;
}
static uint8_t *esp_apptrace_uart_down_buffer_get(void *hw_data, uint32_t *size, esp_apptrace_tmo_t *tmo)
{
esp_apptrace_uart_data_t *uart_data = hw_data;
uint8_t *ptr = NULL;
if (*size > uart_data->down_buffer_size) {
if (!size || *size == 0) {
return NULL;
}
esp_err_t res = esp_apptrace_uart_lock(uart_data, tmo);
if (res != ESP_OK) {
if (!uart_data->rx_msg_buff) {
ESP_APPTRACE_LOGE("RX message buffer is not configured. Call down_buffer_config() first.");
return NULL;
}
size_t uart_fifolen = 0;
uart_get_buffered_data_len(uart_data->port_num, &uart_fifolen);
if (uart_fifolen > 0) {
if (*size < uart_fifolen) {
uart_fifolen = *size;
}
*size = uart_fifolen;
ptr = uart_data->down_buffer;
*size = uart_read_bytes(uart_data->port_num, ptr, uart_fifolen, 0);
if (esp_apptrace_uart_lock(uart_data, tmo) != ESP_OK) {
return NULL;
}
if (esp_apptrace_uart_unlock(uart_data) != ESP_OK) {
assert(false && "Failed to unlock apptrace data!");
uint32_t rx_len = uart_ll_get_rxfifo_len(uart_data->hal_ctx.dev);
int to_read = MIN(rx_len, MIN(uart_data->rx_msg_buff_size, *size));
if (to_read) {
uart_hal_read_rxfifo(&uart_data->hal_ctx, uart_data->rx_msg_buff, &to_read);
}
return ptr;
*size = to_read;
esp_apptrace_uart_unlock(uart_data);
return (*size > 0) ? uart_data->rx_msg_buff : NULL;
}
static esp_err_t esp_apptrace_uart_down_buffer_put(void *hw_data, uint8_t *ptr, esp_apptrace_tmo_t *tmo)
{
(void)hw_data;
(void)ptr;
(void)tmo;
/* No action needed - data was already read in get function */
return ESP_OK;
}
@@ -338,17 +460,50 @@ static bool esp_apptrace_uart_host_is_connected(void *hw_data)
static esp_err_t esp_apptrace_uart_flush_nolock(void *hw_data, uint32_t min_sz, esp_apptrace_tmo_t *tmo)
{
esp_apptrace_uart_data_t *uart_data = hw_data;
esp_apptrace_uart_rb_t *rb = &uart_data->tx_ring;
uint32_t pending = ring_buffer_data_len(rb);
if (pending < min_sz) {
ESP_APPTRACE_LOGD("Ignore UART flush request for min %" PRIu32 " bytes. Pending bytes: %" PRIu32, min_sz, pending);
return ESP_OK;
}
/* Trigger transmission if there's data but not busy */
if (pending > 0 && !uart_data->tx_busy) {
uart_data->tx_busy = true;
uart_ll_clr_intsts_mask(uart_data->hal_ctx.dev, UART_INTR_TXFIFO_EMPTY);
uart_ll_ena_intr_mask(uart_data->hal_ctx.dev, UART_INTR_TXFIFO_EMPTY);
}
while (uart_data->tx_busy || ring_buffer_data_len(rb) > 0) {
if (esp_apptrace_tmo_check(tmo) != ESP_OK) {
return ESP_ERR_TIMEOUT;
}
esp_rom_delay_us(100);
}
return ESP_OK;
}
static esp_err_t esp_apptrace_uart_flush(void *hw_data, esp_apptrace_tmo_t *tmo)
{
return ESP_OK;
esp_apptrace_uart_data_t *uart_data = hw_data;
esp_err_t res = esp_apptrace_uart_lock(uart_data, tmo);
if (res != ESP_OK) {
return res;
}
esp_err_t ret = esp_apptrace_uart_flush_nolock(hw_data, 0, tmo);
esp_apptrace_uart_unlock(uart_data);
return ret;
}
esp_apptrace_hw_t *esp_apptrace_uart_hw_get(int num, void **data)
{
ESP_LOGD(TAG, "esp_apptrace_uart_hw_get - %i", num);
ESP_APPTRACE_LOGD("esp_apptrace_uart_hw_get - %i", num);
static esp_apptrace_uart_data_t s_uart_hw_data;
static esp_apptrace_hw_t s_uart_hw = {
@@ -362,7 +517,6 @@ esp_apptrace_hw_t *esp_apptrace_uart_hw_get(int num, void **data)
.put_down_buffer = esp_apptrace_uart_down_buffer_put,
.host_is_connected = esp_apptrace_uart_host_is_connected,
};
s_uart_hw_data.port_num = num;
*data = &s_uart_hw_data;
return &s_uart_hw;
}

View File

@@ -3,27 +3,10 @@
CONFIG_ESP32_APPTRACE_DESTINATION CONFIG_APPTRACE_DESTINATION
CONFIG_ESP32_APPTRACE_DEST_TRAX CONFIG_APPTRACE_DEST_JTAG
CONFIG_ESP32_APPTRACE_ENABLE CONFIG_APPTRACE_ENABLE
CONFIG_ESP32_APPTRACE_ENABLE CONFIG_ESP_TRACE_TRANSPORT_APPTRACE
CONFIG_ESP32_APPTRACE_LOCK_ENABLE CONFIG_APPTRACE_LOCK_ENABLE
CONFIG_ESP32_APPTRACE_ONPANIC_HOST_FLUSH_TMO CONFIG_APPTRACE_ONPANIC_HOST_FLUSH_TMO
CONFIG_ESP32_APPTRACE_POSTMORTEM_FLUSH_TRAX_THRESH CONFIG_APPTRACE_POSTMORTEM_FLUSH_THRESH
CONFIG_SYSVIEW_ENABLE CONFIG_APPTRACE_SV_ENABLE
CONFIG_SYSVIEW_TS_SOURCE CONFIG_APPTRACE_SV_TS_SOURCE
CONFIG_SYSVIEW_TS_SOURCE_CCOUNT CONFIG_APPTRACE_SV_TS_SOURCE_CCOUNT
CONFIG_SYSVIEW_TS_SOURCE_ESP_TIMER CONFIG_APPTRACE_SV_TS_SOURCE_ESP_TIMER
CONFIG_SYSVIEW_MAX_TASKS CONFIG_APPTRACE_SV_MAX_TASKS
CONFIG_SYSVIEW_BUF_WAIT_TMO CONFIG_APPTRACE_SV_BUF_WAIT_TMO
CONFIG_SYSVIEW_EVT_OVERFLOW_ENABLE CONFIG_APPTRACE_SV_EVT_OVERFLOW_ENABLE
CONFIG_SYSVIEW_EVT_ISR_ENTER_ENABLE CONFIG_APPTRACE_SV_EVT_ISR_ENTER_ENABLE
CONFIG_SYSVIEW_EVT_ISR_EXIT_ENABLE CONFIG_APPTRACE_SV_EVT_ISR_EXIT_ENABLE
CONFIG_SYSVIEW_EVT_ISR_TO_SCHEDULER_ENABLE CONFIG_APPTRACE_SV_EVT_ISR_TO_SCHED_ENABLE
CONFIG_SYSVIEW_EVT_TASK_START_EXEC_ENABLE CONFIG_APPTRACE_SV_EVT_TASK_START_EXEC_ENABLE
CONFIG_SYSVIEW_EVT_TASK_STOP_EXEC_ENABLE CONFIG_APPTRACE_SV_EVT_TASK_STOP_EXEC_ENABLE
CONFIG_SYSVIEW_EVT_TASK_START_READY_ENABLE CONFIG_APPTRACE_SV_EVT_TASK_START_READY_ENABLE
CONFIG_SYSVIEW_EVT_TASK_STOP_READY_ENABLE CONFIG_APPTRACE_SV_EVT_TASK_STOP_READY_ENABLE
CONFIG_SYSVIEW_EVT_TASK_CREATE_ENABLE CONFIG_APPTRACE_SV_EVT_TASK_CREATE_ENABLE
CONFIG_SYSVIEW_EVT_TASK_TERMINATE_ENABLE CONFIG_APPTRACE_SV_EVT_TASK_TERMINATE_ENABLE
CONFIG_SYSVIEW_EVT_IDLE_ENABLE CONFIG_APPTRACE_SV_EVT_IDLE_ENABLE
CONFIG_SYSVIEW_EVT_TIMER_ENTER_ENABLE CONFIG_APPTRACE_SV_EVT_TIMER_ENTER_ENABLE
CONFIG_SYSVIEW_EVT_TIMER_EXIT_ENABLE CONFIG_APPTRACE_SV_EVT_TIMER_EXIT_ENABLE
CONFIG_SYSVIEW_TS_SOURCE_CCOUNT CONFIG_ESP_TRACE_TS_SOURCE_CCOUNT
CONFIG_SYSVIEW_TS_SOURCE_ESP_TIMER CONFIG_ESP_TRACE_TS_SOURCE_ESP_TIMER

View File

@@ -1,118 +0,0 @@
/*
* SPDX-FileCopyrightText: 1995-2021 SEGGER Microcontroller GmbH
*
* SPDX-License-Identifier: BSD-1-Clause
*/
/*********************************************************************
* SEGGER Microcontroller GmbH *
* The Embedded Experts *
**********************************************************************
* *
* (c) 1995 - 2021 SEGGER Microcontroller GmbH *
* *
* www.segger.com Support: support@segger.com *
* *
**********************************************************************
* *
* SEGGER SystemView * Real-time application analysis *
* *
**********************************************************************
* *
* All rights reserved. *
* *
* SEGGER strongly recommends to not make any changes *
* to or modify the source code of this software in order to stay *
* compatible with the SystemView and RTT protocol, and J-Link. *
* *
* Redistribution and use in source and binary forms, with or *
* without modification, are permitted provided that the following *
* condition is met: *
* *
* o Redistributions of source code must retain the above copyright *
* notice, this condition and the following disclaimer. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR *
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
* DAMAGE. *
* *
**********************************************************************
* *
* SystemView version: 3.42 *
* *
**********************************************************************
----------------------------------------------------------------------
File : Global.h
Purpose : Global types
In case your application already has a Global.h, you should
merge the files. In order to use Segger code, the types
U8, U16, U32, I8, I16, I32 need to be defined in Global.h;
additional definitions do not hurt.
Revision: $Rev: 12501 $
---------------------------END-OF-HEADER------------------------------
*/
#ifndef GLOBAL_H // Guard against multiple inclusion
#define GLOBAL_H
#define U8 unsigned char
#define I8 signed char
#define U16 unsigned short
#define I16 signed short
#ifdef __x86_64__
#define U32 unsigned
#define I32 int
#else
#define U32 unsigned long
#define I32 signed long
#endif
//
// CC_NO_LONG_SUPPORT can be defined to compile test
// without long support for compilers that do not
// support C99 and its long type.
//
#ifdef CC_NO_LONG_SUPPORT
#define PTR_ADDR U32
#else // Supports long type.
#if defined(_WIN32) && !defined(__clang__) && !defined(__MINGW32__)
//
// Microsoft VC6 compiler related
//
#define U64 unsigned __int64
#define U128 unsigned __int128
#define I64 __int64
#define I128 __int128
#if _MSC_VER <= 1200
#define U64_C(x) x##UI64
#else
#define U64_C(x) x##ULL
#endif
#else
//
// C99 compliant compiler
//
#define U64 unsigned long long
#define I64 signed long long
#define U64_C(x) x##ULL
#endif
#if (defined(_WIN64) || defined(__LP64__)) // 64-bit symbols used by Visual Studio and GCC, maybe others as well.
#define PTR_ADDR U64
#else
#define PTR_ADDR U32
#endif
#endif // Supports long type.
#endif // Avoid multiple inclusion
/*************************** End of file ****************************/

View File

@@ -1,433 +0,0 @@
/*
* SPDX-FileCopyrightText: 1995-2021 SEGGER Microcontroller GmbH
*
* SPDX-License-Identifier: BSD-1-Clause
*/
/*********************************************************************
* SEGGER Microcontroller GmbH *
* The Embedded Experts *
**********************************************************************
* *
* (c) 1995 - 2021 SEGGER Microcontroller GmbH *
* *
* www.segger.com Support: support@segger.com *
* *
**********************************************************************
* *
* SEGGER SystemView * Real-time application analysis *
* *
**********************************************************************
* *
* All rights reserved. *
* *
* SEGGER strongly recommends to not make any changes *
* to or modify the source code of this software in order to stay *
* compatible with the SystemView and RTT protocol, and J-Link. *
* *
* Redistribution and use in source and binary forms, with or *
* without modification, are permitted provided that the following *
* condition is met: *
* *
* o Redistributions of source code must retain the above copyright *
* notice, this condition and the following disclaimer. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR *
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
* DAMAGE. *
* *
**********************************************************************
* *
* SystemView version: 3.42 *
* *
**********************************************************************
---------------------------END-OF-HEADER------------------------------
File : SEGGER_RTT_Conf.h
Purpose : Implementation of SEGGER real-time transfer (RTT) which
allows real-time communication on targets which support
debugger memory accesses while the CPU is running.
Revision: $Rev: 24316 $
*/
#ifndef SEGGER_RTT_CONF_H
#define SEGGER_RTT_CONF_H
#ifdef __IAR_SYSTEMS_ICC__
#include <intrinsics.h>
#endif
/*********************************************************************
*
* Defines, configurable
*
**********************************************************************
*/
//
// Take in and set to correct values for Cortex-A systems with CPU cache
//
//#define SEGGER_RTT_CPU_CACHE_LINE_SIZE (32) // Largest cache line size (in bytes) in the current system
//#define SEGGER_RTT_UNCACHED_OFF (0xFB000000) // Address alias where RTT CB and buffers can be accessed uncached
//
// Most common case:
// Up-channel 0: RTT
// Up-channel 1: SystemView
//
#ifndef SEGGER_RTT_MAX_NUM_UP_BUFFERS
#define SEGGER_RTT_MAX_NUM_UP_BUFFERS (3) // Max. number of up-buffers (T->H) available on this target (Default: 3)
#endif
//
// Most common case:
// Down-channel 0: RTT
// Down-channel 1: SystemView
//
#ifndef SEGGER_RTT_MAX_NUM_DOWN_BUFFERS
#define SEGGER_RTT_MAX_NUM_DOWN_BUFFERS (3) // Max. number of down-buffers (H->T) available on this target (Default: 3)
#endif
#ifndef BUFFER_SIZE_UP
#define BUFFER_SIZE_UP (1024) // Size of the buffer for terminal output of target, up to host (Default: 1k)
#endif
#ifndef BUFFER_SIZE_DOWN
#define BUFFER_SIZE_DOWN (16) // Size of the buffer for terminal input to target from host (Usually keyboard input) (Default: 16)
#endif
#ifndef SEGGER_RTT_PRINTF_BUFFER_SIZE
#define SEGGER_RTT_PRINTF_BUFFER_SIZE (64u) // Size of buffer for RTT printf to bulk-send chars via RTT (Default: 64)
#endif
#ifndef SEGGER_RTT_MODE_DEFAULT
#define SEGGER_RTT_MODE_DEFAULT SEGGER_RTT_MODE_NO_BLOCK_SKIP // Mode for pre-initialized terminal channel (buffer 0)
#endif
/*********************************************************************
*
* RTT memcpy configuration
*
* memcpy() is good for large amounts of data,
* but the overhead is big for small amounts, which are usually stored via RTT.
* With SEGGER_RTT_MEMCPY_USE_BYTELOOP a simple byte loop can be used instead.
*
* SEGGER_RTT_MEMCPY() can be used to replace standard memcpy() in RTT functions.
* This is may be required with memory access restrictions,
* such as on Cortex-A devices with MMU.
*/
#ifndef SEGGER_RTT_MEMCPY_USE_BYTELOOP
#define SEGGER_RTT_MEMCPY_USE_BYTELOOP 0 // 0: Use memcpy/SEGGER_RTT_MEMCPY, 1: Use a simple byte-loop
#endif
//
// Example definition of SEGGER_RTT_MEMCPY to external memcpy with GCC toolchains and Cortex-A targets
//
//#if ((defined __SES_ARM) || (defined __CROSSWORKS_ARM) || (defined __GNUC__)) && (defined (__ARM_ARCH_7A__))
// #define SEGGER_RTT_MEMCPY(pDest, pSrc, NumBytes) SEGGER_memcpy((pDest), (pSrc), (NumBytes))
//#endif
//
// Target is not allowed to perform other RTT operations while string still has not been stored completely.
// Otherwise we would probably end up with a mixed string in the buffer.
// If using RTT from within interrupts, multiple tasks or multi processors, define the SEGGER_RTT_LOCK() and SEGGER_RTT_UNLOCK() function here.
//
// SEGGER_RTT_MAX_INTERRUPT_PRIORITY can be used in the sample lock routines on Cortex-M3/4.
// Make sure to mask all interrupts which can send RTT data, i.e. generate SystemView events, or cause task switches.
// When high-priority interrupts must not be masked while sending RTT data, SEGGER_RTT_MAX_INTERRUPT_PRIORITY needs to be adjusted accordingly.
// (Higher priority = lower priority number)
// Default value for embOS: 128u
// Default configuration in FreeRTOS: configMAX_SYSCALL_INTERRUPT_PRIORITY: ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
// In case of doubt mask all interrupts: 1 << (8 - BASEPRI_PRIO_BITS) i.e. 1 << 5 when 3 bits are implemented in NVIC
// or define SEGGER_RTT_LOCK() to completely disable interrupts.
//
#ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY
#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20) // Interrupt priority to lock on SEGGER_RTT_LOCK on Cortex-M3/4 (Default: 0x20)
#endif
/*********************************************************************
*
* RTT lock configuration for SEGGER Embedded Studio,
* Rowley CrossStudio and GCC
*/
#if ((defined(__SES_ARM) || defined(__SES_RISCV) || defined(__CROSSWORKS_ARM) || defined(__GNUC__) || defined(__clang__)) && !defined (__CC_ARM) && !defined(WIN32))
#if (defined(__ARM_ARCH_6M__) || defined(__ARM_ARCH_8M_BASE__))
#define SEGGER_RTT_LOCK() { \
unsigned int _SEGGER_RTT__LockState; \
__asm volatile ("mrs %0, primask \n\t" \
"movs r1, #1 \n\t" \
"msr primask, r1 \n\t" \
: "=r" (_SEGGER_RTT__LockState) \
: \
: "r1", "cc" \
);
#define SEGGER_RTT_UNLOCK() __asm volatile ("msr primask, %0 \n\t" \
: \
: "r" (_SEGGER_RTT__LockState) \
: \
); \
}
#elif (defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_8M_MAIN__))
#ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY
#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20)
#endif
#define SEGGER_RTT_LOCK() { \
unsigned int _SEGGER_RTT__LockState; \
__asm volatile ("mrs %0, basepri \n\t" \
"mov r1, %1 \n\t" \
"msr basepri, r1 \n\t" \
: "=r" (_SEGGER_RTT__LockState) \
: "i"(SEGGER_RTT_MAX_INTERRUPT_PRIORITY) \
: "r1", "cc" \
);
#define SEGGER_RTT_UNLOCK() __asm volatile ("msr basepri, %0 \n\t" \
: \
: "r" (_SEGGER_RTT__LockState) \
: \
); \
}
#elif (defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__))
#define SEGGER_RTT_LOCK() { \
unsigned int _SEGGER_RTT__LockState; \
__asm volatile ("mrs r1, CPSR \n\t" \
"mov %0, r1 \n\t" \
"orr r1, r1, #0xC0 \n\t" \
"msr CPSR_c, r1 \n\t" \
: "=r" (_SEGGER_RTT__LockState) \
: \
: "r1", "cc" \
);
#define SEGGER_RTT_UNLOCK() __asm volatile ("mov r0, %0 \n\t" \
"mrs r1, CPSR \n\t" \
"bic r1, r1, #0xC0 \n\t" \
"and r0, r0, #0xC0 \n\t" \
"orr r1, r1, r0 \n\t" \
"msr CPSR_c, r1 \n\t" \
: \
: "r" (_SEGGER_RTT__LockState) \
: "r0", "r1", "cc" \
); \
}
#elif defined(__riscv) || defined(__riscv_xlen)
#define SEGGER_RTT_LOCK() { \
unsigned int _SEGGER_RTT__LockState; \
__asm volatile ("csrr %0, mstatus \n\t" \
"csrci mstatus, 8 \n\t" \
"andi %0, %0, 8 \n\t" \
: "=r" (_SEGGER_RTT__LockState) \
: \
: \
);
#define SEGGER_RTT_UNLOCK() __asm volatile ("csrr a1, mstatus \n\t" \
"or %0, %0, a1 \n\t" \
"csrs mstatus, %0 \n\t" \
: \
: "r" (_SEGGER_RTT__LockState) \
: "a1" \
); \
}
#else
#define SEGGER_RTT_LOCK()
#define SEGGER_RTT_UNLOCK()
#endif
#endif
/*********************************************************************
*
* RTT lock configuration for IAR EWARM
*/
#ifdef __ICCARM__
#if (defined (__ARM6M__) && (__CORE__ == __ARM6M__)) || \
(defined (__ARM8M_BASELINE__) && (__CORE__ == __ARM8M_BASELINE__))
#define SEGGER_RTT_LOCK() { \
unsigned int _SEGGER_RTT__LockState; \
_SEGGER_RTT__LockState = __get_PRIMASK(); \
__set_PRIMASK(1);
#define SEGGER_RTT_UNLOCK() __set_PRIMASK(_SEGGER_RTT__LockState); \
}
#elif (defined (__ARM7EM__) && (__CORE__ == __ARM7EM__)) || \
(defined (__ARM7M__) && (__CORE__ == __ARM7M__)) || \
(defined (__ARM8M_MAINLINE__) && (__CORE__ == __ARM8M_MAINLINE__)) || \
(defined (__ARM8M_MAINLINE__) && (__CORE__ == __ARM8M_MAINLINE__))
#ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY
#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20)
#endif
#define SEGGER_RTT_LOCK() { \
unsigned int _SEGGER_RTT__LockState; \
_SEGGER_RTT__LockState = __get_BASEPRI(); \
__set_BASEPRI(SEGGER_RTT_MAX_INTERRUPT_PRIORITY);
#define SEGGER_RTT_UNLOCK() __set_BASEPRI(_SEGGER_RTT__LockState); \
}
#elif (defined (__ARM7A__) && (__CORE__ == __ARM7A__)) || \
(defined (__ARM7R__) && (__CORE__ == __ARM7R__))
#define SEGGER_RTT_LOCK() { \
unsigned int _SEGGER_RTT__LockState; \
__asm volatile ("mrs r1, CPSR \n\t" \
"mov %0, r1 \n\t" \
"orr r1, r1, #0xC0 \n\t" \
"msr CPSR_c, r1 \n\t" \
: "=r" (_SEGGER_RTT__LockState) \
: \
: "r1", "cc" \
);
#define SEGGER_RTT_UNLOCK() __asm volatile ("mov r0, %0 \n\t" \
"mrs r1, CPSR \n\t" \
"bic r1, r1, #0xC0 \n\t" \
"and r0, r0, #0xC0 \n\t" \
"orr r1, r1, r0 \n\t" \
"msr CPSR_c, r1 \n\t" \
: \
: "r" (_SEGGER_RTT__LockState) \
: "r0", "r1", "cc" \
); \
}
#endif
#endif
/*********************************************************************
*
* RTT lock configuration for IAR RX
*/
#ifdef __ICCRX__
#define SEGGER_RTT_LOCK() { \
unsigned long _SEGGER_RTT__LockState; \
_SEGGER_RTT__LockState = __get_interrupt_state(); \
__disable_interrupt();
#define SEGGER_RTT_UNLOCK() __set_interrupt_state(_SEGGER_RTT__LockState); \
}
#endif
/*********************************************************************
*
* RTT lock configuration for IAR RL78
*/
#ifdef __ICCRL78__
#define SEGGER_RTT_LOCK() { \
__istate_t _SEGGER_RTT__LockState; \
_SEGGER_RTT__LockState = __get_interrupt_state(); \
__disable_interrupt();
#define SEGGER_RTT_UNLOCK() __set_interrupt_state(_SEGGER_RTT__LockState); \
}
#endif
/*********************************************************************
*
* RTT lock configuration for KEIL ARM
*/
#ifdef __CC_ARM
#if (defined __TARGET_ARCH_6S_M)
#define SEGGER_RTT_LOCK() { \
unsigned int _SEGGER_RTT__LockState; \
register unsigned char _SEGGER_RTT__PRIMASK __asm( "primask"); \
_SEGGER_RTT__LockState = _SEGGER_RTT__PRIMASK; \
_SEGGER_RTT__PRIMASK = 1u; \
__schedule_barrier();
#define SEGGER_RTT_UNLOCK() _SEGGER_RTT__PRIMASK = _SEGGER_RTT__LockState; \
__schedule_barrier(); \
}
#elif (defined(__TARGET_ARCH_7_M) || defined(__TARGET_ARCH_7E_M))
#ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY
#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20)
#endif
#define SEGGER_RTT_LOCK() { \
unsigned int _SEGGER_RTT__LockState; \
register unsigned char BASEPRI __asm( "basepri"); \
_SEGGER_RTT__LockState = BASEPRI; \
BASEPRI = SEGGER_RTT_MAX_INTERRUPT_PRIORITY; \
__schedule_barrier();
#define SEGGER_RTT_UNLOCK() BASEPRI = _SEGGER_RTT__LockState; \
__schedule_barrier(); \
}
#endif
#endif
/*********************************************************************
*
* RTT lock configuration for TI ARM
*/
#ifdef __TI_ARM__
#if defined (__TI_ARM_V6M0__)
#define SEGGER_RTT_LOCK() { \
unsigned int _SEGGER_RTT__LockState; \
_SEGGER_RTT__LockState = __get_PRIMASK(); \
__set_PRIMASK(1);
#define SEGGER_RTT_UNLOCK() __set_PRIMASK(_SEGGER_RTT__LockState); \
}
#elif (defined (__TI_ARM_V7M3__) || defined (__TI_ARM_V7M4__))
#ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY
#define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20)
#endif
#define SEGGER_RTT_LOCK() { \
unsigned int _SEGGER_RTT__LockState; \
_SEGGER_RTT__LockState = _set_interrupt_priority(SEGGER_RTT_MAX_INTERRUPT_PRIORITY);
#define SEGGER_RTT_UNLOCK() _set_interrupt_priority(_SEGGER_RTT__LockState); \
}
#endif
#endif
/*********************************************************************
*
* RTT lock configuration for CCRX
*/
#ifdef __RX
#include <machine.h>
#define SEGGER_RTT_LOCK() { \
unsigned long _SEGGER_RTT__LockState; \
_SEGGER_RTT__LockState = get_psw() & 0x010000; \
clrpsw_i();
#define SEGGER_RTT_UNLOCK() set_psw(get_psw() | _SEGGER_RTT__LockState); \
}
#endif
/*********************************************************************
*
* RTT lock configuration for embOS Simulation on Windows
* (Can also be used for generic RTT locking with embOS)
*/
#if defined(WIN32) || defined(SEGGER_RTT_LOCK_EMBOS)
void OS_SIM_EnterCriticalSection(void);
void OS_SIM_LeaveCriticalSection(void);
#define SEGGER_RTT_LOCK() { \
OS_SIM_EnterCriticalSection();
#define SEGGER_RTT_UNLOCK() OS_SIM_LeaveCriticalSection(); \
}
#endif
/*********************************************************************
*
* RTT lock configuration fallback
*/
#ifndef SEGGER_RTT_LOCK
#define SEGGER_RTT_LOCK() // Lock RTT (nestable) (i.e. disable interrupts)
#endif
#ifndef SEGGER_RTT_UNLOCK
#define SEGGER_RTT_UNLOCK() // Unlock RTT (nestable) (i.e. enable previous interrupt lock state)
#endif
#endif
/*************************** End of file ****************************/

View File

@@ -1,90 +0,0 @@
/*
* SPDX-FileCopyrightText: 1995-2021 SEGGER Microcontroller GmbH
*
* SPDX-License-Identifier: BSD-1-Clause
*/
/*********************************************************************
* SEGGER Microcontroller GmbH *
* The Embedded Experts *
**********************************************************************
* *
* (c) 1995 - 2021 SEGGER Microcontroller GmbH *
* *
* www.segger.com Support: support@segger.com *
* *
**********************************************************************
* *
* SEGGER SystemView * Real-time application analysis *
* *
**********************************************************************
* *
* All rights reserved. *
* *
* SEGGER strongly recommends to not make any changes *
* to or modify the source code of this software in order to stay *
* compatible with the SystemView and RTT protocol, and J-Link. *
* *
* Redistribution and use in source and binary forms, with or *
* without modification, are permitted provided that the following *
* condition is met: *
* *
* o Redistributions of source code must retain the above copyright *
* notice, this condition and the following disclaimer. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR *
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
* DAMAGE. *
* *
**********************************************************************
* *
* SystemView version: 3.42 *
* *
**********************************************************************
-------------------------- END-OF-HEADER -----------------------------
File : SEGGER_SYSVIEW_Conf.h
Purpose : SEGGER SystemView configuration file.
Set defines which deviate from the defaults (see SEGGER_SYSVIEW_ConfDefaults.h) here.
Revision: $Rev: 21292 $
Additional information:
Required defines which must be set are:
SEGGER_SYSVIEW_GET_TIMESTAMP
SEGGER_SYSVIEW_GET_INTERRUPT_ID
For known compilers and cores, these might be set to good defaults
in SEGGER_SYSVIEW_ConfDefaults.h.
SystemView needs a (nestable) locking mechanism.
If not defined, the RTT locking mechanism is used,
which then needs to be properly configured.
*/
#ifndef SEGGER_SYSVIEW_CONF_H
#define SEGGER_SYSVIEW_CONF_H
/*********************************************************************
*
* Defines, configurable
*
**********************************************************************
*/
/*********************************************************************
* TODO: Add your defines here. *
**********************************************************************
*/
#endif // SEGGER_SYSVIEW_CONF_H
/*************************** End of file ****************************/

View File

@@ -1,255 +0,0 @@
/*
* SPDX-FileCopyrightText: 1995-2021 SEGGER Microcontroller GmbH
*
* SPDX-License-Identifier: BSD-1-Clause
*
* SPDX-FileContributor: 2023 Espressif Systems (Shanghai) CO LTD
*/
/*********************************************************************
* SEGGER Microcontroller GmbH *
* The Embedded Experts *
**********************************************************************
* *
* (c) 1995 - 2024 SEGGER Microcontroller GmbH *
* *
* www.segger.com Support: support@segger.com *
* *
**********************************************************************
* *
* SEGGER SystemView * Real-time application analysis *
* *
**********************************************************************
* *
* All rights reserved. *
* *
* SEGGER strongly recommends to not make any changes *
* to or modify the source code of this software in order to stay *
* compatible with the SystemView and RTT protocol, and J-Link. *
* *
* Redistribution and use in source and binary forms, with or *
* without modification, are permitted provided that the following *
* condition is met: *
* *
* o Redistributions of source code must retain the above copyright *
* notice, this condition and the following disclaimer. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR *
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
* DAMAGE. *
* *
**********************************************************************
* *
* SystemView version: 3.56 *
* *
**********************************************************************
----------------------------------------------------------------------
File : SEGGER.h
Purpose : Global types etc & general purpose utility functions
Revision: $Rev: 18102 $
---------------------------END-OF-HEADER------------------------------
*/
#ifndef SEGGER_H // Guard against multiple inclusion
#define SEGGER_H
#include <stdarg.h> // For va_list.
#include "Global.h" // Type definitions: U8, U16, U32, I8, I16, I32
#if defined(__cplusplus)
extern "C" { /* Make sure we have C-declarations in C++ programs */
#endif
/*********************************************************************
*
* Keywords/specifiers
*
**********************************************************************
*/
#ifndef INLINE
#if (defined(__ICCARM__) || defined(__RX) || defined(__ICCRX__))
//
// Other known compilers.
//
#define INLINE inline
#else
#if (defined(_WIN32) && !defined(__clang__))
//
// Microsoft VC6 and newer.
// Force inlining without cost checking.
//
#define INLINE __forceinline
#elif defined(__GNUC__) || defined(__clang__)
//
// Force inlining with GCC + clang
//
#define INLINE inline __attribute__((always_inline))
#elif (defined(__CC_ARM))
//
// Force inlining with ARMCC (Keil)
//
#define INLINE __inline
#else
//
// Unknown compilers.
//
#define INLINE
#endif
#endif
#endif
/*********************************************************************
*
* Function-like macros
*
**********************************************************************
*/
#define SEGGER_COUNTOF(a) (sizeof((a))/sizeof((a)[0]))
#define SEGGER_MIN(a,b) (((a) < (b)) ? (a) : (b))
#define SEGGER_MAX(a,b) (((a) > (b)) ? (a) : (b))
#ifndef SEGGER_USE_PARA // Some compiler complain about unused parameters.
#define SEGGER_USE_PARA(Para) (void)Para // This works for most compilers.
#endif
#define SEGGER_ADDR2PTR(Type, Addr) (/*lint -e(923) -e(9078)*/((Type*)((PTR_ADDR)(Addr)))) // Allow cast from address to pointer.
#define SEGGER_PTR2ADDR(p) (/*lint -e(923) -e(9078)*/((PTR_ADDR)(p))) // Allow cast from pointer to address.
#define SEGGER_PTR2PTR(Type, p) (/*lint -e(740) -e(826) -e(9079) -e(9087)*/((Type*)(p))) // Allow cast from one pointer type to another (ignore different size).
#define SEGGER_PTR_DISTANCE(p0, p1) (SEGGER_PTR2ADDR(p0) - SEGGER_PTR2ADDR(p1))
/*********************************************************************
*
* Defines
*
**********************************************************************
*/
#define SEGGER_PRINTF_FLAG_ADJLEFT (1 << 0)
#define SEGGER_PRINTF_FLAG_SIGNFORCE (1 << 1)
#define SEGGER_PRINTF_FLAG_SIGNSPACE (1 << 2)
#define SEGGER_PRINTF_FLAG_PRECEED (1 << 3)
#define SEGGER_PRINTF_FLAG_ZEROPAD (1 << 4)
#define SEGGER_PRINTF_FLAG_NEGATIVE (1 << 5)
/*********************************************************************
*
* Types
*
**********************************************************************
*/
typedef struct {
char* pBuffer;
int BufferSize;
int Cnt;
} SEGGER_BUFFER_DESC;
typedef struct {
unsigned int CacheLineSize; // 0: No Cache. Most Systems such as ARM9 use a 32 bytes cache line size.
void (*pfDMB) (void); // Optional DMB function for Data Memory Barrier to make sure all memory operations are completed.
void (*pfClean) (void *p, unsigned long NumBytes); // Optional clean function for cached memory.
void (*pfInvalidate)(void *p, unsigned long NumBytes); // Optional invalidate function for cached memory.
} SEGGER_CACHE_CONFIG;
typedef struct SEGGER_SNPRINTF_CONTEXT_struct SEGGER_SNPRINTF_CONTEXT;
struct SEGGER_SNPRINTF_CONTEXT_struct {
void* pContext; // Application specific context.
SEGGER_BUFFER_DESC* pBufferDesc; // Buffer descriptor to use for output.
void (*pfFlush)(SEGGER_SNPRINTF_CONTEXT* pContext); // Callback executed once the buffer is full. Callback decides if the buffer gets cleared to store more or not.
};
typedef struct {
void (*pfStoreChar) (SEGGER_BUFFER_DESC* pBufferDesc, SEGGER_SNPRINTF_CONTEXT* pContext, char c);
int (*pfPrintUnsigned) (SEGGER_BUFFER_DESC* pBufferDesc, SEGGER_SNPRINTF_CONTEXT* pContext, U32 v, unsigned Base, char Flags, int Width, int Precision);
int (*pfPrintInt) (SEGGER_BUFFER_DESC* pBufferDesc, SEGGER_SNPRINTF_CONTEXT* pContext, I32 v, unsigned Base, char Flags, int Width, int Precision);
} SEGGER_PRINTF_API;
typedef void (*SEGGER_pFormatter)(SEGGER_BUFFER_DESC* pBufferDesc, SEGGER_SNPRINTF_CONTEXT* pContext, const SEGGER_PRINTF_API* pApi, va_list* pParamList, char Lead, int Width, int Precision);
typedef struct SEGGER_PRINTF_FORMATTER {
struct SEGGER_PRINTF_FORMATTER* pNext; // Pointer to next formatter.
SEGGER_pFormatter pfFormatter; // Formatter function.
char Specifier; // Format specifier.
} SEGGER_PRINTF_FORMATTER;
typedef struct {
U32 (*pfGetHPTimestamp)(void); // Mandatory, pfGetHPTimestamp
int (*pfGetUID) (U8 abUID[16]); // Optional, pfGetUID
} SEGGER_BSP_API;
/*********************************************************************
*
* Utility functions
*
**********************************************************************
*/
//
// Memory operations.
//
void SEGGER_ARM_memcpy(void* pDest, const void* pSrc, int NumBytes);
void SEGGER_memcpy (void* pDest, const void* pSrc, unsigned NumBytes);
void SEGGER_memxor (void* pDest, const void* pSrc, unsigned NumBytes);
//
// String functions.
//
int SEGGER_atoi (const char* s);
int SEGGER_isalnum (int c);
int SEGGER_isalpha (int c);
unsigned SEGGER_strlen (const char* s);
int SEGGER_tolower (int c);
int SEGGER_strcasecmp (const char* sText1, const char* sText2);
int SEGGER_strncasecmp(const char *sText1, const char *sText2, unsigned Count);
//
// Buffer/printf related.
//
void SEGGER_StoreChar (SEGGER_BUFFER_DESC* pBufferDesc, char c);
void SEGGER_PrintUnsigned(SEGGER_BUFFER_DESC* pBufferDesc, U32 v, unsigned Base, int Precision);
void SEGGER_PrintInt (SEGGER_BUFFER_DESC* pBufferDesc, I32 v, unsigned Base, int Precision);
int SEGGER_snprintf (char* pBuffer, int BufferSize, const char* sFormat, ...);
int SEGGER_vsnprintf (char* pBuffer, int BufferSize, const char* sFormat, va_list ParamList);
int SEGGER_vsnprintfEx (SEGGER_SNPRINTF_CONTEXT* pContext, const char* sFormat, va_list ParamList);
int SEGGER_PRINTF_AddFormatter (SEGGER_PRINTF_FORMATTER* pFormatter, SEGGER_pFormatter pfFormatter, char c);
void SEGGER_PRINTF_AddDoubleFormatter (void);
void SEGGER_PRINTF_AddIPFormatter (void);
void SEGGER_PRINTF_AddBLUEFormatter (void);
void SEGGER_PRINTF_AddCONNECTFormatter(void);
void SEGGER_PRINTF_AddSSLFormatter (void);
void SEGGER_PRINTF_AddSSHFormatter (void);
void SEGGER_PRINTF_AddHTMLFormatter (void);
//
// BSP abstraction API.
//
int SEGGER_BSP_GetUID (U8 abUID[16]);
int SEGGER_BSP_GetUID32(U32* pUID);
void SEGGER_BSP_SetAPI (const SEGGER_BSP_API* pAPI);
void SEGGER_BSP_SeedUID (void);
//
// Other API.
//
void SEGGER_VERSION_GetString(char acText[8], unsigned Version);
#if defined(__cplusplus)
} /* Make sure we have C-declarations in C++ programs */
#endif
#endif // Avoid multiple inclusion
/*************************** End of file ****************************/

View File

@@ -1,515 +0,0 @@
/*
* SPDX-FileCopyrightText: 1995-2021 SEGGER Microcontroller GmbH
*
* SPDX-License-Identifier: BSD-1-Clause
*/
/*********************************************************************
* SEGGER Microcontroller GmbH *
* The Embedded Experts *
**********************************************************************
* *
* (c) 1995 - 2024 SEGGER Microcontroller GmbH *
* *
* www.segger.com Support: support@segger.com *
* *
**********************************************************************
* *
* SEGGER SystemView * Real-time application analysis *
* *
**********************************************************************
* *
* All rights reserved. *
* *
* SEGGER strongly recommends to not make any changes *
* to or modify the source code of this software in order to stay *
* compatible with the SystemView and RTT protocol, and J-Link. *
* *
* Redistribution and use in source and binary forms, with or *
* without modification, are permitted provided that the following *
* condition is met: *
* *
* o Redistributions of source code must retain the above copyright *
* notice, this condition and the following disclaimer. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR *
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
* DAMAGE. *
* *
**********************************************************************
* *
* SystemView version: 3.56 *
* *
**********************************************************************
---------------------------END-OF-HEADER------------------------------
File : SEGGER_RTT.h
Purpose : Implementation of SEGGER real-time transfer which allows
real-time communication on targets which support debugger
memory accesses while the CPU is running.
Revision: $Rev: 25842 $
----------------------------------------------------------------------
*/
#ifndef SEGGER_RTT_H
#define SEGGER_RTT_H
#include "../Config/SEGGER_RTT_Conf.h"
/*********************************************************************
*
* Defines, defaults
*
**********************************************************************
*/
#ifndef RTT_USE_ASM
//
// Some cores support out-of-order memory accesses (reordering of memory accesses in the core)
// For such cores, we need to define a memory barrier to guarantee the order of certain accesses to the RTT ring buffers.
// Needed for:
// Cortex-M7 (ARMv7-M)
// Cortex-M23 (ARM-v8M)
// Cortex-M33 (ARM-v8M)
// Cortex-A/R (ARM-v7A/R)
//
// We do not explicitly check for "Embedded Studio" as the compiler in use determines what we support.
// You can use an external toolchain like IAR inside ES. So there is no point in checking for "Embedded Studio"
//
#if (defined __CROSSWORKS_ARM) // Rowley Crossworks
#define _CC_HAS_RTT_ASM_SUPPORT 1
#if (defined __ARM_ARCH_7M__) // Cortex-M3
#define _CORE_HAS_RTT_ASM_SUPPORT 1
#elif (defined __ARM_ARCH_7EM__) // Cortex-M4/M7
#define _CORE_HAS_RTT_ASM_SUPPORT 1
#define _CORE_NEEDS_DMB 1
#define RTT__DMB() __asm volatile ("dmb\n" : : :);
#elif (defined __ARM_ARCH_8M_BASE__) // Cortex-M23
#define _CORE_HAS_RTT_ASM_SUPPORT 0
#define _CORE_NEEDS_DMB 1
#define RTT__DMB() __asm volatile ("dmb\n" : : :);
#elif (defined __ARM_ARCH_8M_MAIN__) // Cortex-M33
#define _CORE_HAS_RTT_ASM_SUPPORT 1
#define _CORE_NEEDS_DMB 1
#define RTT__DMB() __asm volatile ("dmb\n" : : :);
#elif (defined(__ARM_ARCH_8_1M_MAIN__)) // Cortex-M85
#define _CORE_HAS_RTT_ASM_SUPPORT 1
#define _CORE_NEEDS_DMB 1
#define RTT__DMB() __asm volatile ("dmb\n" : : :);
#else
#define _CORE_HAS_RTT_ASM_SUPPORT 0
#endif
#elif (defined __ARMCC_VERSION)
//
// ARM compiler
// ARM compiler V6.0 and later is clang based.
// Our ASM part is compatible to clang.
//
#if (__ARMCC_VERSION >= 6000000)
#define _CC_HAS_RTT_ASM_SUPPORT 1
#else
#define _CC_HAS_RTT_ASM_SUPPORT 0
#endif
#if (defined __ARM_ARCH_6M__) // Cortex-M0 / M1
#define _CORE_HAS_RTT_ASM_SUPPORT 0 // No ASM support for this architecture
#elif (defined __ARM_ARCH_7M__) // Cortex-M3
#define _CORE_HAS_RTT_ASM_SUPPORT 1
#elif (defined __ARM_ARCH_7EM__) // Cortex-M4/M7
#define _CORE_HAS_RTT_ASM_SUPPORT 1
#define _CORE_NEEDS_DMB 1
#define RTT__DMB() __asm volatile ("dmb\n" : : :);
#elif (defined __ARM_ARCH_8M_BASE__) // Cortex-M23
#define _CORE_HAS_RTT_ASM_SUPPORT 0
#define _CORE_NEEDS_DMB 1
#define RTT__DMB() __asm volatile ("dmb\n" : : :);
#elif (defined __ARM_ARCH_8M_MAIN__) // Cortex-M33
#define _CORE_HAS_RTT_ASM_SUPPORT 1
#define _CORE_NEEDS_DMB 1
#define RTT__DMB() __asm volatile ("dmb\n" : : :);
#elif (defined __ARM_ARCH_8_1M_MAIN__) // Cortex-M85
#define _CORE_HAS_RTT_ASM_SUPPORT 1
#define _CORE_NEEDS_DMB 1
#define RTT__DMB() __asm volatile ("dmb\n" : : :);
#elif ((defined __ARM_ARCH_7A__) || (defined __ARM_ARCH_7R__)) // Cortex-A/R 32-bit ARMv7-A/R
#define _CORE_NEEDS_DMB 1
#define RTT__DMB() __asm volatile ("dmb\n" : : :);
#else
#define _CORE_HAS_RTT_ASM_SUPPORT 0
#endif
#elif ((defined __GNUC__) || (defined __clang__))
//
// GCC / Clang
//
#define _CC_HAS_RTT_ASM_SUPPORT 1
// ARM 7/9: __ARM_ARCH_5__ / __ARM_ARCH_5E__ / __ARM_ARCH_5T__ / __ARM_ARCH_5T__ / __ARM_ARCH_5TE__
#if (defined __ARM_ARCH_7M__) // Cortex-M3
#define _CORE_HAS_RTT_ASM_SUPPORT 1
#elif (defined __ARM_ARCH_7EM__) // Cortex-M4/M7
#define _CORE_HAS_RTT_ASM_SUPPORT 1
#define _CORE_NEEDS_DMB 1 // Only Cortex-M7 needs a DMB but we cannot distinguish M4 and M7 here...
#define RTT__DMB() __asm volatile ("dmb\n" : : :);
#elif (defined __ARM_ARCH_8M_BASE__) // Cortex-M23
#define _CORE_HAS_RTT_ASM_SUPPORT 0
#define _CORE_NEEDS_DMB 1
#define RTT__DMB() __asm volatile ("dmb\n" : : :);
#elif (defined __ARM_ARCH_8M_MAIN__) // Cortex-M33
#define _CORE_HAS_RTT_ASM_SUPPORT 1
#define _CORE_NEEDS_DMB 1
#define RTT__DMB() __asm volatile ("dmb\n" : : :);
#elif (defined __ARM_ARCH_8_1M_MAIN__) // Cortex-M85
#define _CORE_HAS_RTT_ASM_SUPPORT 1
#define _CORE_NEEDS_DMB 1
#define RTT__DMB() __asm volatile ("dmb\n" : : :);
#elif ((defined __ARM_ARCH_7A__) || (defined __ARM_ARCH_7R__)) // Cortex-A/R 32-bit ARMv7-A/R
#define _CORE_NEEDS_DMB 1
#define RTT__DMB() __asm volatile ("dmb\n" : : :);
#else
#define _CORE_HAS_RTT_ASM_SUPPORT 0
#endif
#elif ((defined __IASMARM__) || (defined __ICCARM__))
//
// IAR assembler/compiler
//
#define _CC_HAS_RTT_ASM_SUPPORT 1
#if (__VER__ < 6300000)
#define VOLATILE
#else
#define VOLATILE volatile
#endif
#if (defined __ARM7M__) // Needed for old versions that do not know the define yet
#if (__CORE__ == __ARM7M__) // Cortex-M3
#define _CORE_HAS_RTT_ASM_SUPPORT 1
#endif
#endif
#if (defined __ARM7EM__)
#if (__CORE__ == __ARM7EM__) // Cortex-M4/M7
#define _CORE_HAS_RTT_ASM_SUPPORT 1
#define _CORE_NEEDS_DMB 1
#define RTT__DMB() asm VOLATILE ("DMB");
#endif
#endif
#if (defined __ARM8M_BASELINE__)
#if (__CORE__ == __ARM8M_BASELINE__) // Cortex-M23
#define _CORE_HAS_RTT_ASM_SUPPORT 0
#define _CORE_NEEDS_DMB 1
#define RTT__DMB() asm VOLATILE ("DMB");
#endif
#endif
#if (defined __ARM8M_MAINLINE__)
#if (__CORE__ == __ARM8M_MAINLINE__) // Cortex-M33
#define _CORE_HAS_RTT_ASM_SUPPORT 1
#define _CORE_NEEDS_DMB 1
#define RTT__DMB() asm VOLATILE ("DMB");
#endif
#endif
#if (defined __ARM8EM_MAINLINE__)
#if (__CORE__ == __ARM8EM_MAINLINE__) // Cortex-???
#define _CORE_HAS_RTT_ASM_SUPPORT 1
#define _CORE_NEEDS_DMB 1
#define RTT__DMB() asm VOLATILE ("DMB");
#endif
#endif
#if (defined __ARM7A__)
#if (__CORE__ == __ARM7A__) // Cortex-A 32-bit ARMv7-A
#define _CORE_NEEDS_DMB 1
#define RTT__DMB() asm VOLATILE ("DMB");
#endif
#endif
#if (defined __ARM7R__)
#if (__CORE__ == __ARM7R__) // Cortex-R 32-bit ARMv7-R
#define _CORE_NEEDS_DMB 1
#define RTT__DMB() asm VOLATILE ("DMB");
#endif
#endif
// TBD: __ARM8A__ => Cortex-A 64-bit ARMv8-A
// TBD: __ARM8R__ => Cortex-R 64-bit ARMv8-R
#else
//
// Other compilers
//
#define _CC_HAS_RTT_ASM_SUPPORT 0
#define _CORE_HAS_RTT_ASM_SUPPORT 0
#endif
//
// If IDE and core support the ASM version, enable ASM version by default
//
#ifndef _CORE_HAS_RTT_ASM_SUPPORT
#define _CORE_HAS_RTT_ASM_SUPPORT 0 // Default for unknown cores
#endif
#if (_CC_HAS_RTT_ASM_SUPPORT && _CORE_HAS_RTT_ASM_SUPPORT)
#define RTT_USE_ASM (1)
#else
#define RTT_USE_ASM (0)
#endif
#endif
#ifndef _CORE_NEEDS_DMB
#define _CORE_NEEDS_DMB 0
#endif
#ifndef RTT__DMB
#if _CORE_NEEDS_DMB
#error "Don't know how to place inline assembly for DMB"
#else
#define RTT__DMB()
#endif
#endif
#ifndef SEGGER_RTT_CPU_CACHE_LINE_SIZE
#define SEGGER_RTT_CPU_CACHE_LINE_SIZE (0) // On most target systems where RTT is used, we do not have a CPU cache, therefore 0 is a good default here
#endif
#ifndef SEGGER_RTT_UNCACHED_OFF
#if SEGGER_RTT_CPU_CACHE_LINE_SIZE
#error "SEGGER_RTT_UNCACHED_OFF must be defined when setting SEGGER_RTT_CPU_CACHE_LINE_SIZE != 0"
#else
#define SEGGER_RTT_UNCACHED_OFF (0)
#endif
#endif
#if RTT_USE_ASM
#if SEGGER_RTT_CPU_CACHE_LINE_SIZE
#error "RTT_USE_ASM is not available if SEGGER_RTT_CPU_CACHE_LINE_SIZE != 0"
#endif
#endif
#ifndef SEGGER_RTT_ASM // defined when SEGGER_RTT.h is included from assembly file
#include <stdlib.h>
#include <stdarg.h>
#include <stdint.h>
/*********************************************************************
*
* Defines, fixed
*
**********************************************************************
*/
//
// Determine how much we must pad the control block to make it a multiple of a cache line in size
// Assuming: U8 = 1B
// U16 = 2B
// U32 = 4B
// U8/U16/U32* = 4B
//
#if SEGGER_RTT_CPU_CACHE_LINE_SIZE // Avoid division by zero in case we do not have any cache
#define SEGGER_RTT__ROUND_UP_2_CACHE_LINE_SIZE(NumBytes) (((NumBytes + SEGGER_RTT_CPU_CACHE_LINE_SIZE - 1) / SEGGER_RTT_CPU_CACHE_LINE_SIZE) * SEGGER_RTT_CPU_CACHE_LINE_SIZE)
#else
#define SEGGER_RTT__ROUND_UP_2_CACHE_LINE_SIZE(NumBytes) (NumBytes)
#endif
#define SEGGER_RTT__CB_SIZE (16 + 4 + 4 + (SEGGER_RTT_MAX_NUM_UP_BUFFERS * 24) + (SEGGER_RTT_MAX_NUM_DOWN_BUFFERS * 24))
#define SEGGER_RTT__CB_PADDING (SEGGER_RTT__ROUND_UP_2_CACHE_LINE_SIZE(SEGGER_RTT__CB_SIZE) - SEGGER_RTT__CB_SIZE)
/*********************************************************************
*
* Types
*
**********************************************************************
*/
//
// Description for a circular buffer (also called "ring buffer")
// which is used as up-buffer (T->H)
//
typedef struct {
const char* sName; // Optional name. Standard names so far are: "Terminal", "SysView", "J-Scope_t4i4"
char* pBuffer; // Pointer to start of buffer
unsigned SizeOfBuffer; // Buffer size in bytes. Note that one byte is lost, as this implementation does not fill up the buffer in order to avoid the problem of being unable to distinguish between full and empty.
unsigned WrOff; // Position of next item to be written by either target.
volatile unsigned RdOff; // Position of next item to be read by host. Must be volatile since it may be modified by host.
unsigned Flags; // Contains configuration flags. Flags[31:24] are used for validity check and must be zero. Flags[23:2] are reserved for future use. Flags[1:0] = RTT operating mode.
} SEGGER_RTT_BUFFER_UP;
//
// Description for a circular buffer (also called "ring buffer")
// which is used as down-buffer (H->T)
//
typedef struct {
const char* sName; // Optional name. Standard names so far are: "Terminal", "SysView", "J-Scope_t4i4"
char* pBuffer; // Pointer to start of buffer
unsigned SizeOfBuffer; // Buffer size in bytes. Note that one byte is lost, as this implementation does not fill up the buffer in order to avoid the problem of being unable to distinguish between full and empty.
volatile unsigned WrOff; // Position of next item to be written by host. Must be volatile since it may be modified by host.
unsigned RdOff; // Position of next item to be read by target (down-buffer).
unsigned Flags; // Contains configuration flags. Flags[31:24] are used for validity check and must be zero. Flags[23:2] are reserved for future use. Flags[1:0] = RTT operating mode.
} SEGGER_RTT_BUFFER_DOWN;
//
// RTT control block which describes the number of buffers available
// as well as the configuration for each buffer
//
//
typedef struct {
char acID[16]; // Initialized to "SEGGER RTT"
int MaxNumUpBuffers; // Initialized to SEGGER_RTT_MAX_NUM_UP_BUFFERS (type. 2)
int MaxNumDownBuffers; // Initialized to SEGGER_RTT_MAX_NUM_DOWN_BUFFERS (type. 2)
SEGGER_RTT_BUFFER_UP aUp[SEGGER_RTT_MAX_NUM_UP_BUFFERS]; // Up buffers, transferring information up from target via debug probe to host
SEGGER_RTT_BUFFER_DOWN aDown[SEGGER_RTT_MAX_NUM_DOWN_BUFFERS]; // Down buffers, transferring information down from host via debug probe to target
#if SEGGER_RTT__CB_PADDING
unsigned char aDummy[SEGGER_RTT__CB_PADDING];
#endif
} SEGGER_RTT_CB;
/*********************************************************************
*
* Global data
*
**********************************************************************
*/
extern SEGGER_RTT_CB _SEGGER_RTT;
/*********************************************************************
*
* RTT API functions
*
**********************************************************************
*/
#ifdef __cplusplus
extern "C" {
#endif
int SEGGER_RTT_AllocDownBuffer (const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags);
int SEGGER_RTT_AllocUpBuffer (const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags);
int SEGGER_RTT_ConfigUpBuffer (unsigned BufferIndex, const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags);
int SEGGER_RTT_ConfigDownBuffer (unsigned BufferIndex, const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags);
int SEGGER_RTT_GetKey (void);
unsigned SEGGER_RTT_HasData (unsigned BufferIndex);
int SEGGER_RTT_HasKey (void);
unsigned SEGGER_RTT_HasDataUp (unsigned BufferIndex);
void SEGGER_RTT_Init (void);
unsigned SEGGER_RTT_Read (unsigned BufferIndex, void* pBuffer, unsigned BufferSize);
unsigned SEGGER_RTT_ReadNoLock (unsigned BufferIndex, void* pData, unsigned BufferSize);
int SEGGER_RTT_SetNameDownBuffer (unsigned BufferIndex, const char* sName);
int SEGGER_RTT_SetNameUpBuffer (unsigned BufferIndex, const char* sName);
int SEGGER_RTT_SetFlagsDownBuffer (unsigned BufferIndex, unsigned Flags);
int SEGGER_RTT_SetFlagsUpBuffer (unsigned BufferIndex, unsigned Flags);
int SEGGER_RTT_WaitKey (void);
unsigned SEGGER_RTT_Write (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
unsigned SEGGER_RTT_WriteNoLock (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
unsigned SEGGER_RTT_WriteSkipNoLock (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
unsigned SEGGER_RTT_ASM_WriteSkipNoLock (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
unsigned SEGGER_RTT_WriteString (unsigned BufferIndex, const char* s);
void SEGGER_RTT_WriteWithOverwriteNoLock(unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
unsigned SEGGER_RTT_PutChar (unsigned BufferIndex, char c);
unsigned SEGGER_RTT_PutCharSkip (unsigned BufferIndex, char c);
unsigned SEGGER_RTT_PutCharSkipNoLock (unsigned BufferIndex, char c);
unsigned SEGGER_RTT_GetAvailWriteSpace (unsigned BufferIndex);
unsigned SEGGER_RTT_GetBytesInBuffer (unsigned BufferIndex);
void SEGGER_RTT_ESP_FlushNoLock (unsigned long min_sz, unsigned long tmo);
void SEGGER_RTT_ESP_Flush (unsigned long min_sz, unsigned long tmo);
//
// Function macro for performance optimization
//
// @AGv: This macro is used inside SEGGER SystemView code.
// For ESP32 we use our own implementation of RTT, so this macro should not check SEGGER's RTT buffer state.
#define SEGGER_RTT_HASDATA(n) (1)
#if RTT_USE_ASM
#define SEGGER_RTT_WriteSkipNoLock SEGGER_RTT_ASM_WriteSkipNoLock
#endif
/*********************************************************************
*
* RTT transfer functions to send RTT data via other channels.
*
**********************************************************************
*/
unsigned SEGGER_RTT_ReadUpBuffer (unsigned BufferIndex, void* pBuffer, unsigned BufferSize);
unsigned SEGGER_RTT_ReadUpBufferNoLock (unsigned BufferIndex, void* pData, unsigned BufferSize);
unsigned SEGGER_RTT_WriteDownBuffer (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
unsigned SEGGER_RTT_WriteDownBufferNoLock (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes);
#define SEGGER_RTT_HASDATA_UP(n) (((SEGGER_RTT_BUFFER_UP*)((uintptr_t)&_SEGGER_RTT.aUp[n] + SEGGER_RTT_UNCACHED_OFF))->WrOff - ((SEGGER_RTT_BUFFER_UP*)((uintptr_t)&_SEGGER_RTT.aUp[n] + SEGGER_RTT_UNCACHED_OFF))->RdOff) // Access uncached to make sure we see changes made by the J-Link side and all of our changes go into HW directly
/*********************************************************************
*
* RTT "Terminal" API functions
*
**********************************************************************
*/
int SEGGER_RTT_SetTerminal (unsigned char TerminalId);
int SEGGER_RTT_TerminalOut (unsigned char TerminalId, const char* s);
/*********************************************************************
*
* RTT printf functions (require SEGGER_RTT_printf.c)
*
**********************************************************************
*/
int SEGGER_RTT_printf(unsigned BufferIndex, const char * sFormat, ...);
int SEGGER_RTT_vprintf(unsigned BufferIndex, const char * sFormat, va_list * pParamList);
#ifdef __cplusplus
}
#endif
#endif // ifndef(SEGGER_RTT_ASM)
/*********************************************************************
*
* Defines
*
**********************************************************************
*/
//
// Operating modes. Define behavior if buffer is full (not enough space for entire message)
//
#define SEGGER_RTT_MODE_NO_BLOCK_SKIP (0) // Skip. Do not block, output nothing. (Default)
#define SEGGER_RTT_MODE_NO_BLOCK_TRIM (1) // Trim: Do not block, output as much as fits.
#define SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL (2) // Block: Wait until there is space in the buffer.
#define SEGGER_RTT_MODE_MASK (3)
//
// Control sequences, based on ANSI.
// Can be used to control color, and clear the screen
//
#define RTT_CTRL_RESET "\x1B[0m" // Reset to default colors
#define RTT_CTRL_CLEAR "\x1B[2J" // Clear screen, reposition cursor to top left
#define RTT_CTRL_TEXT_BLACK "\x1B[2;30m"
#define RTT_CTRL_TEXT_RED "\x1B[2;31m"
#define RTT_CTRL_TEXT_GREEN "\x1B[2;32m"
#define RTT_CTRL_TEXT_YELLOW "\x1B[2;33m"
#define RTT_CTRL_TEXT_BLUE "\x1B[2;34m"
#define RTT_CTRL_TEXT_MAGENTA "\x1B[2;35m"
#define RTT_CTRL_TEXT_CYAN "\x1B[2;36m"
#define RTT_CTRL_TEXT_WHITE "\x1B[2;37m"
#define RTT_CTRL_TEXT_BRIGHT_BLACK "\x1B[1;30m"
#define RTT_CTRL_TEXT_BRIGHT_RED "\x1B[1;31m"
#define RTT_CTRL_TEXT_BRIGHT_GREEN "\x1B[1;32m"
#define RTT_CTRL_TEXT_BRIGHT_YELLOW "\x1B[1;33m"
#define RTT_CTRL_TEXT_BRIGHT_BLUE "\x1B[1;34m"
#define RTT_CTRL_TEXT_BRIGHT_MAGENTA "\x1B[1;35m"
#define RTT_CTRL_TEXT_BRIGHT_CYAN "\x1B[1;36m"
#define RTT_CTRL_TEXT_BRIGHT_WHITE "\x1B[1;37m"
#define RTT_CTRL_BG_BLACK "\x1B[24;40m"
#define RTT_CTRL_BG_RED "\x1B[24;41m"
#define RTT_CTRL_BG_GREEN "\x1B[24;42m"
#define RTT_CTRL_BG_YELLOW "\x1B[24;43m"
#define RTT_CTRL_BG_BLUE "\x1B[24;44m"
#define RTT_CTRL_BG_MAGENTA "\x1B[24;45m"
#define RTT_CTRL_BG_CYAN "\x1B[24;46m"
#define RTT_CTRL_BG_WHITE "\x1B[24;47m"
#define RTT_CTRL_BG_BRIGHT_BLACK "\x1B[4;40m"
#define RTT_CTRL_BG_BRIGHT_RED "\x1B[4;41m"
#define RTT_CTRL_BG_BRIGHT_GREEN "\x1B[4;42m"
#define RTT_CTRL_BG_BRIGHT_YELLOW "\x1B[4;43m"
#define RTT_CTRL_BG_BRIGHT_BLUE "\x1B[4;44m"
#define RTT_CTRL_BG_BRIGHT_MAGENTA "\x1B[4;45m"
#define RTT_CTRL_BG_BRIGHT_CYAN "\x1B[4;46m"
#define RTT_CTRL_BG_BRIGHT_WHITE "\x1B[4;47m"
#endif
/*************************** End of file ****************************/

File diff suppressed because it is too large Load Diff

View File

@@ -1,436 +0,0 @@
/*
* SPDX-FileCopyrightText: 1995-2021 SEGGER Microcontroller GmbH
*
* SPDX-License-Identifier: BSD-1-Clause
*
* SPDX-FileContributor: 2023-2024 Espressif Systems (Shanghai) CO LTD
*/
/*********************************************************************
* SEGGER Microcontroller GmbH *
* The Embedded Experts *
**********************************************************************
* *
* (c) 1995 - 2024 SEGGER Microcontroller GmbH *
* *
* www.segger.com Support: support@segger.com *
* *
**********************************************************************
* *
* SEGGER SystemView * Real-time application analysis *
* *
**********************************************************************
* *
* All rights reserved. *
* *
* SEGGER strongly recommends to not make any changes *
* to or modify the source code of this software in order to stay *
* compatible with the SystemView and RTT protocol, and J-Link. *
* *
* Redistribution and use in source and binary forms, with or *
* without modification, are permitted provided that the following *
* condition is met: *
* *
* o Redistributions of source code must retain the above copyright *
* notice, this condition and the following disclaimer. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR *
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
* DAMAGE. *
* *
**********************************************************************
* *
* SystemView version: 3.56 *
* *
**********************************************************************
-------------------------- END-OF-HEADER -----------------------------
File : SEGGER_SYSVIEW.h
Purpose : System visualization API.
Revision: $Rev: 28768 $
*/
#ifndef SEGGER_SYSVIEW_H
#define SEGGER_SYSVIEW_H
/*********************************************************************
*
* #include Section
*
**********************************************************************
*/
#include "SEGGER.h"
#include "SEGGER_SYSVIEW_ConfDefaults.h"
#ifdef __cplusplus
extern "C" {
#endif
/*********************************************************************
*
* Defines, fixed
*
**********************************************************************
*/
#define SEGGER_SYSVIEW_MAJOR 3
#define SEGGER_SYSVIEW_MINOR 32
#define SEGGER_SYSVIEW_REV 0
#define SEGGER_SYSVIEW_VERSION ((SEGGER_SYSVIEW_MAJOR * 10000) + (SEGGER_SYSVIEW_MINOR * 100) + SEGGER_SYSVIEW_REV)
#define SEGGER_SYSVIEW_INFO_SIZE 9 // Minimum size, which has to be reserved for a packet. 1-2 byte of message type, 0-2 byte of payload length, 1-5 bytes of timestamp.
#define SEGGER_SYSVIEW_QUANTA_U32 5 // Maximum number of bytes to encode a U32, should be reserved for each 32-bit value in a packet.
#define SEGGER_SYSVIEW_LOG (0u)
#define SEGGER_SYSVIEW_WARNING (1u)
#define SEGGER_SYSVIEW_ERROR (2u)
#define SEGGER_SYSVIEW_FLAG_APPEND (1u << 6)
#define SEGGER_SYSVIEW_PREPARE_PACKET(p) (p) + 4
//
// SystemView events. First 32 IDs from 0 .. 31 are reserved for these
//
#define SYSVIEW_EVTID_NOP 0 // Dummy packet.
#define SYSVIEW_EVTID_OVERFLOW 1
#define SYSVIEW_EVTID_ISR_ENTER 2
#define SYSVIEW_EVTID_ISR_EXIT 3
#define SYSVIEW_EVTID_TASK_START_EXEC 4
#define SYSVIEW_EVTID_TASK_STOP_EXEC 5
#define SYSVIEW_EVTID_TASK_START_READY 6
#define SYSVIEW_EVTID_TASK_STOP_READY 7
#define SYSVIEW_EVTID_TASK_CREATE 8
#define SYSVIEW_EVTID_TASK_INFO 9
#define SYSVIEW_EVTID_TRACE_START 10
#define SYSVIEW_EVTID_TRACE_STOP 11
#define SYSVIEW_EVTID_SYSTIME_CYCLES 12
#define SYSVIEW_EVTID_SYSTIME_US 13
#define SYSVIEW_EVTID_SYSDESC 14
#define SYSVIEW_EVTID_MARK_START 15
#define SYSVIEW_EVTID_MARK_STOP 16
#define SYSVIEW_EVTID_IDLE 17
#define SYSVIEW_EVTID_ISR_TO_SCHEDULER 18
#define SYSVIEW_EVTID_TIMER_ENTER 19
#define SYSVIEW_EVTID_TIMER_EXIT 20
#define SYSVIEW_EVTID_STACK_INFO 21
#define SYSVIEW_EVTID_MODULEDESC 22
#define SYSVIEW_EVTID_DATA_SAMPLE 23
#define SYSVIEW_EVTID_INIT 24
#define SYSVIEW_EVTID_NAME_RESOURCE 25
#define SYSVIEW_EVTID_PRINT_FORMATTED 26
#define SYSVIEW_EVTID_NUMMODULES 27
#define SYSVIEW_EVTID_END_CALL 28
#define SYSVIEW_EVTID_TASK_TERMINATE 29
#define SYSVIEW_EVTID_EX 31
//
// SystemView extended events. Sent with ID 31.
//
#define SYSVIEW_EVTID_EX_MARK 0
#define SYSVIEW_EVTID_EX_NAME_MARKER 1
#define SYSVIEW_EVTID_EX_HEAP_DEFINE 2
#define SYSVIEW_EVTID_EX_HEAP_ALLOC 3
#define SYSVIEW_EVTID_EX_HEAP_ALLOC_EX 4
#define SYSVIEW_EVTID_EX_HEAP_FREE 5
#define SYSVIEW_EVTID_EX_REGISTER_DATA 6
//
// Event masks to disable/enable events
//
#define SYSVIEW_EVTMASK_NOP (1 << SYSVIEW_EVTID_NOP)
#define SYSVIEW_EVTMASK_OVERFLOW (1 << SYSVIEW_EVTID_OVERFLOW)
#define SYSVIEW_EVTMASK_ISR_ENTER (1 << SYSVIEW_EVTID_ISR_ENTER)
#define SYSVIEW_EVTMASK_ISR_EXIT (1 << SYSVIEW_EVTID_ISR_EXIT)
#define SYSVIEW_EVTMASK_TASK_START_EXEC (1 << SYSVIEW_EVTID_TASK_START_EXEC)
#define SYSVIEW_EVTMASK_TASK_STOP_EXEC (1 << SYSVIEW_EVTID_TASK_STOP_EXEC)
#define SYSVIEW_EVTMASK_TASK_START_READY (1 << SYSVIEW_EVTID_TASK_START_READY)
#define SYSVIEW_EVTMASK_TASK_STOP_READY (1 << SYSVIEW_EVTID_TASK_STOP_READY)
#define SYSVIEW_EVTMASK_TASK_CREATE (1 << SYSVIEW_EVTID_TASK_CREATE)
#define SYSVIEW_EVTMASK_TASK_INFO (1 << SYSVIEW_EVTID_TASK_INFO)
#define SYSVIEW_EVTMASK_TRACE_START (1 << SYSVIEW_EVTID_TRACE_START)
#define SYSVIEW_EVTMASK_TRACE_STOP (1 << SYSVIEW_EVTID_TRACE_STOP)
#define SYSVIEW_EVTMASK_SYSTIME_CYCLES (1 << SYSVIEW_EVTID_SYSTIME_CYCLES)
#define SYSVIEW_EVTMASK_SYSTIME_US (1 << SYSVIEW_EVTID_SYSTIME_US)
#define SYSVIEW_EVTMASK_SYSDESC (1 << SYSVIEW_EVTID_SYSDESC)
#define SYSVIEW_EVTMASK_USER_START (1 << SYSVIEW_EVTID_USER_START)
#define SYSVIEW_EVTMASK_USER_STOP (1 << SYSVIEW_EVTID_USER_STOP)
#define SYSVIEW_EVTMASK_IDLE (1 << SYSVIEW_EVTID_IDLE)
#define SYSVIEW_EVTMASK_ISR_TO_SCHEDULER (1 << SYSVIEW_EVTID_ISR_TO_SCHEDULER)
#define SYSVIEW_EVTMASK_TIMER_ENTER (1 << SYSVIEW_EVTID_TIMER_ENTER)
#define SYSVIEW_EVTMASK_TIMER_EXIT (1 << SYSVIEW_EVTID_TIMER_EXIT)
#define SYSVIEW_EVTMASK_STACK_INFO (1 << SYSVIEW_EVTID_STACK_INFO)
#define SYSVIEW_EVTMASK_MODULEDESC (1 << SYSVIEW_EVTID_MODULEDESC)
#define SYSVIEW_EVTMASK_DATA_SAMPLE (1 << SYSVIEW_EVTID_DATA_SAMPLE)
#define SYSVIEW_EVTMASK_INIT (1 << SYSVIEW_EVTID_INIT)
#define SYSVIEW_EVTMASK_NAME_RESOURCE (1 << SYSVIEW_EVTID_NAME_RESOURCE)
#define SYSVIEW_EVTMASK_PRINT_FORMATTED (1 << SYSVIEW_EVTID_PRINT_FORMATTED)
#define SYSVIEW_EVTMASK_NUMMODULES (1 << SYSVIEW_EVTID_NUMMODULES)
#define SYSVIEW_EVTMASK_END_CALL (1 << SYSVIEW_EVTID_END_CALL)
#define SYSVIEW_EVTMASK_TASK_TERMINATE (1 << SYSVIEW_EVTID_TASK_TERMINATE)
#define SYSVIEW_EVTMASK_EX (1 << SYSVIEW_EVTID_EX)
#define SYSVIEW_EVTMASK_ALL_INTERRUPTS ( SYSVIEW_EVTMASK_ISR_ENTER \
| SYSVIEW_EVTMASK_ISR_EXIT \
| SYSVIEW_EVTMASK_ISR_TO_SCHEDULER)
#define SYSVIEW_EVTMASK_ALL_TASKS ( SYSVIEW_EVTMASK_TASK_START_EXEC \
| SYSVIEW_EVTMASK_TASK_STOP_EXEC \
| SYSVIEW_EVTMASK_TASK_START_READY \
| SYSVIEW_EVTMASK_TASK_STOP_READY \
| SYSVIEW_EVTMASK_TASK_CREATE \
| SYSVIEW_EVTMASK_TASK_INFO \
| SYSVIEW_EVTMASK_STACK_INFO \
| SYSVIEW_EVTMASK_TASK_TERMINATE)
/*********************************************************************
*
* Structures
*
**********************************************************************
*/
typedef struct {
U32 TaskID;
const char* sName;
U32 Prio;
U32 StackBase;
U32 StackSize;
U32 StackUsage;
} SEGGER_SYSVIEW_TASKINFO;
typedef struct {
U32 TaskID;
U32 StackBase;
U32 StackSize;
U32 StackUsage;
} SEGGER_SYSVIEW_STACKINFO;
typedef struct {
U32 ID;
union {
U32* pU32_Value;
I32* pI32_Value;
float* pFloat_Value;
};
} SEGGER_SYSVIEW_DATA_SAMPLE;
typedef enum {
SEGGER_SYSVIEW_TYPE_U32 = 0,
SEGGER_SYSVIEW_TYPE_I32 = 1,
SEGGER_SYSVIEW_TYPE_FLOAT = 2
} SEGGER_SYSVIEW_DATA_TYPE;
typedef struct {
U32 ID;
SEGGER_SYSVIEW_DATA_TYPE DataType;
I32 Offset;
I32 RangeMin;
I32 RangeMax;
float ScalingFactor;
const char* sName;
const char* sUnit;
} SEGGER_SYSVIEW_DATA_REGISTER;
typedef struct SEGGER_SYSVIEW_MODULE_STRUCT SEGGER_SYSVIEW_MODULE;
struct SEGGER_SYSVIEW_MODULE_STRUCT {
const char* sModule;
U32 NumEvents;
U32 EventOffset;
void (*pfSendModuleDesc)(void);
SEGGER_SYSVIEW_MODULE* pNext;
};
typedef void (SEGGER_SYSVIEW_SEND_SYS_DESC_FUNC)(void);
/*********************************************************************
*
* Global data
*
**********************************************************************
*/
#ifdef EXTERN
#undef EXTERN
#endif
#ifndef SEGGER_SYSVIEW_C // Defined in SEGGER_SYSVIEW.c which includes this header beside other C-files
#define EXTERN extern
#else
#define EXTERN
#endif
EXTERN unsigned int SEGGER_SYSVIEW_TickCnt;
EXTERN unsigned int SEGGER_SYSVIEW_InterruptId;
#undef EXTERN
/*********************************************************************
*
* API functions
*
**********************************************************************
*/
typedef struct {
U64 (*pfGetTime) (void);
void (*pfSendTaskList) (void);
} SEGGER_SYSVIEW_OS_API;
/*********************************************************************
*
* Control and initialization functions
*/
void SEGGER_SYSVIEW_Init (U32 SysFreq, U32 CPUFreq, const SEGGER_SYSVIEW_OS_API *pOSAPI, SEGGER_SYSVIEW_SEND_SYS_DESC_FUNC pfSendSysDesc);
void SEGGER_SYSVIEW_SetRAMBase (U32 RAMBaseAddress);
void SEGGER_SYSVIEW_Start (void);
void SEGGER_SYSVIEW_Stop (void);
void SEGGER_SYSVIEW_GetSysDesc (void);
void SEGGER_SYSVIEW_SendTaskList (void);
void SEGGER_SYSVIEW_SendTaskInfo (const SEGGER_SYSVIEW_TASKINFO* pInfo);
void SEGGER_SYSVIEW_SendStackInfo (const SEGGER_SYSVIEW_STACKINFO* pInfo);
void SEGGER_SYSVIEW_SendSysDesc (const char* sSysDesc);
int SEGGER_SYSVIEW_IsStarted (void);
int SEGGER_SYSVIEW_GetChannelID (void);
void SEGGER_SYSVIEW_SampleData (const SEGGER_SYSVIEW_DATA_SAMPLE *pInfo);
// Checks whether tracing has been started
U8 SEGGER_SYSVIEW_Started(void);
/*********************************************************************
*
* Event recording functions
*/
void SEGGER_SYSVIEW_RecordVoid (unsigned int EventId);
void SEGGER_SYSVIEW_RecordU32 (unsigned int EventId, U32 Para0);
void SEGGER_SYSVIEW_RecordU32x2 (unsigned int EventId, U32 Para0, U32 Para1);
void SEGGER_SYSVIEW_RecordU32x3 (unsigned int EventId, U32 Para0, U32 Para1, U32 Para2);
void SEGGER_SYSVIEW_RecordU32x4 (unsigned int EventId, U32 Para0, U32 Para1, U32 Para2, U32 Para3);
void SEGGER_SYSVIEW_RecordU32x5 (unsigned int EventId, U32 Para0, U32 Para1, U32 Para2, U32 Para3, U32 Para4);
void SEGGER_SYSVIEW_RecordU32x6 (unsigned int EventId, U32 Para0, U32 Para1, U32 Para2, U32 Para3, U32 Para4, U32 Para5);
void SEGGER_SYSVIEW_RecordU32x7 (unsigned int EventId, U32 Para0, U32 Para1, U32 Para2, U32 Para3, U32 Para4, U32 Para5, U32 Para6);
void SEGGER_SYSVIEW_RecordU32x8 (unsigned int EventId, U32 Para0, U32 Para1, U32 Para2, U32 Para3, U32 Para4, U32 Para5, U32 Para6, U32 Para7);
void SEGGER_SYSVIEW_RecordU32x9 (unsigned int EventId, U32 Para0, U32 Para1, U32 Para2, U32 Para3, U32 Para4, U32 Para5, U32 Para6, U32 Para7, U32 Para8);
void SEGGER_SYSVIEW_RecordU32x10 (unsigned int EventId, U32 Para0, U32 Para1, U32 Para2, U32 Para3, U32 Para4, U32 Para5, U32 Para6, U32 Para7, U32 Para8, U32 Para9);
void SEGGER_SYSVIEW_RecordString (unsigned int EventId, const char* pString);
void SEGGER_SYSVIEW_RecordSystime (void);
void SEGGER_SYSVIEW_RecordEnterISR (U32 IrqId);
void SEGGER_SYSVIEW_RecordExitISR (void);
void SEGGER_SYSVIEW_RecordExitISRToScheduler (void);
void SEGGER_SYSVIEW_RecordEnterTimer (U32 TimerId);
void SEGGER_SYSVIEW_RecordExitTimer (void);
void SEGGER_SYSVIEW_RecordEndCall (unsigned int EventID);
void SEGGER_SYSVIEW_RecordEndCallU32 (unsigned int EventID, U32 Para0);
void SEGGER_SYSVIEW_OnIdle (void);
void SEGGER_SYSVIEW_OnTaskCreate (U32 TaskId);
void SEGGER_SYSVIEW_OnTaskTerminate (U32 TaskId);
void SEGGER_SYSVIEW_OnTaskStartExec (U32 TaskId);
void SEGGER_SYSVIEW_OnTaskStopExec (void);
void SEGGER_SYSVIEW_OnTaskStartReady (U32 TaskId);
void SEGGER_SYSVIEW_OnTaskStopReady (U32 TaskId, unsigned int Cause);
void SEGGER_SYSVIEW_MarkStart (unsigned int MarkerId);
void SEGGER_SYSVIEW_MarkStop (unsigned int MarkerId);
void SEGGER_SYSVIEW_Mark (unsigned int MarkerId);
void SEGGER_SYSVIEW_NameMarker (unsigned int MarkerId, const char* sName);
void SEGGER_SYSVIEW_HeapDefine (void* pHeap, void* pBase, unsigned int HeapSize, unsigned int MetadataSize);
void SEGGER_SYSVIEW_HeapAlloc (void* pHeap, void* pUserData, unsigned int UserDataLen);
void SEGGER_SYSVIEW_HeapAllocEx (void* pHeap, void* pUserData, unsigned int UserDataLen, unsigned int Tag);
void SEGGER_SYSVIEW_HeapFree (void* pHeap, void* pUserData);
void SEGGER_SYSVIEW_NameResource (U32 ResourceId, const char* sName);
void SEGGER_SYSVIEW_RegisterData ( SEGGER_SYSVIEW_DATA_REGISTER* pInfo);
int SEGGER_SYSVIEW_SendPacket (U8* pPacket, U8* pPayloadEnd, unsigned int EventId);
/*********************************************************************
*
* Event parameter encoding functions
*/
U8* SEGGER_SYSVIEW_EncodeU32 (U8* pPayload, U32 Value);
U8* SEGGER_SYSVIEW_EncodeData (U8* pPayload, const char* pSrc, unsigned int Len);
U8* SEGGER_SYSVIEW_EncodeString (U8* pPayload, const char* s, unsigned int MaxLen);
U8* SEGGER_SYSVIEW_EncodeId (U8* pPayload, U32 Id);
U32 SEGGER_SYSVIEW_ShrinkId (U32 Id);
/*********************************************************************
*
* Middleware module registration
*/
void SEGGER_SYSVIEW_RegisterModule (SEGGER_SYSVIEW_MODULE* pModule);
void SEGGER_SYSVIEW_RecordModuleDescription (const SEGGER_SYSVIEW_MODULE* pModule, const char* sDescription);
void SEGGER_SYSVIEW_SendModule (U8 ModuleId);
void SEGGER_SYSVIEW_SendModuleDescription (void);
void SEGGER_SYSVIEW_SendNumModules (void);
/*********************************************************************
*
* printf-Style functions
*/
#ifndef SEGGER_SYSVIEW_EXCLUDE_PRINTF // Define in project to avoid warnings about variable parameter list
void SEGGER_SYSVIEW_PrintfHostEx (const char* s, U32 Options, ...);
void SEGGER_SYSVIEW_VPrintfHostEx (const char* s, U32 Options, va_list* pParamList);
void SEGGER_SYSVIEW_PrintfTargetEx (const char* s, U32 Options, ...);
void SEGGER_SYSVIEW_VPrintfTargetEx (const char* s, U32 Options, va_list* pParamList);
void SEGGER_SYSVIEW_PrintfHost (const char* s, ...);
void SEGGER_SYSVIEW_VPrintfHost (const char* s, va_list* pParamList);
void SEGGER_SYSVIEW_PrintfTarget (const char* s, ...);
void SEGGER_SYSVIEW_VPrintfTarget (const char* s, va_list* pParamList);
void SEGGER_SYSVIEW_WarnfHost (const char* s, ...);
void SEGGER_SYSVIEW_VWarnfHost (const char* s, va_list* pParamList);
void SEGGER_SYSVIEW_WarnfTarget (const char* s, ...);
void SEGGER_SYSVIEW_VWarnfTarget (const char* s, va_list* pParamList);
void SEGGER_SYSVIEW_ErrorfHost (const char* s, ...);
void SEGGER_SYSVIEW_VErrorfHost (const char* s, va_list* pParamList);
void SEGGER_SYSVIEW_ErrorfTarget (const char* s, ...);
void SEGGER_SYSVIEW_VErrorfTarget (const char* s, va_list* pParamList);
#endif
void SEGGER_SYSVIEW_Print (const char* s);
void SEGGER_SYSVIEW_Warn (const char* s);
void SEGGER_SYSVIEW_Error (const char* s);
/*********************************************************************
*
* Run-time configuration functions
*/
void SEGGER_SYSVIEW_EnableEvents (U32 EnableMask);
void SEGGER_SYSVIEW_DisableEvents (U32 DisableMask);
/*********************************************************************
*
* Application-provided functions
*/
void SEGGER_SYSVIEW_Conf (void);
U32 SEGGER_SYSVIEW_X_GetTimestamp (void);
U32 SEGGER_SYSVIEW_X_GetInterruptId (void);
void SEGGER_SYSVIEW_X_StartComm (void);
void SEGGER_SYSVIEW_X_OnEventRecorded (unsigned NumBytes);
#ifdef __cplusplus
}
#endif
/*********************************************************************
*
* Compatibility API defines
*/
#define SEGGER_SYSVIEW_OnUserStart SEGGER_SYSVIEW_MarkStart
#define SEGGER_SYSVIEW_OnUserStop SEGGER_SYSVIEW_MarkStop
#endif
/*************************** End of file ****************************/

View File

@@ -1,592 +0,0 @@
/*
* SPDX-FileCopyrightText: 1995-2021 SEGGER Microcontroller GmbH
*
* SPDX-License-Identifier: BSD-1-Clause
*
* SPDX-FileContributor: 2023-2024 Espressif Systems (Shanghai) CO LTD
*/
/*********************************************************************
* SEGGER Microcontroller GmbH *
* The Embedded Experts *
**********************************************************************
* *
* (c) 1995 - 2024 SEGGER Microcontroller GmbH *
* *
* www.segger.com Support: support@segger.com *
* *
**********************************************************************
* *
* SEGGER SystemView * Real-time application analysis *
* *
**********************************************************************
* *
* All rights reserved. *
* *
* SEGGER strongly recommends to not make any changes *
* to or modify the source code of this software in order to stay *
* compatible with the SystemView and RTT protocol, and J-Link. *
* *
* Redistribution and use in source and binary forms, with or *
* without modification, are permitted provided that the following *
* condition is met: *
* *
* o Redistributions of source code must retain the above copyright *
* notice, this condition and the following disclaimer. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR *
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
* DAMAGE. *
* *
**********************************************************************
* *
* SystemView version: 3.56 *
* *
**********************************************************************
-------------------------- END-OF-HEADER -----------------------------
File : SEGGER_SYSVIEW_ConfDefaults.h
Purpose : Defines defaults for configurable defines used in
SEGGER SystemView.
Revision: $Rev: 26230 $
*/
#ifndef SEGGER_SYSVIEW_CONFDEFAULTS_H
#define SEGGER_SYSVIEW_CONFDEFAULTS_H
/*********************************************************************
*
* #include Section
*
**********************************************************************
*/
#include "SEGGER_SYSVIEW_Conf.h"
#include "SEGGER_RTT_Conf.h"
#include "esp_assert.h"
#ifdef __cplusplus
extern "C" {
#endif
/*********************************************************************
*
* Defines, fixed
*
**********************************************************************
*/
//
// Use auto-detection for SEGGER_SYSVIEW_CORE define
// based on compiler-/toolchain-specific defines
// to define SEGGER_SYSVIEW_GET_INTERRUPT_ID and SEGGER_SYSVIEW_GET_TIMESTAMP
//
#define SEGGER_SYSVIEW_CORE_OTHER 0
#define SEGGER_SYSVIEW_CORE_CM0 1 // Cortex-M0/M0+/M1
#define SEGGER_SYSVIEW_CORE_CM3 2 // Cortex-M3/M4/M7
#define SEGGER_SYSVIEW_CORE_RX 3 // Renesas RX
#ifndef SEGGER_SYSVIEW_CORE
#if (defined __SES_ARM) || (defined __CROSSWORKS_ARM) || (defined __SEGGER_CC__) || (defined __GNUC__) || (defined __clang__)
#if (defined __ARM_ARCH_6M__) || (defined __ARM_ARCH_8M_BASE__)
#define SEGGER_SYSVIEW_CORE SEGGER_SYSVIEW_CORE_CM0
#elif (defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_8M_MAIN__))
#define SEGGER_SYSVIEW_CORE SEGGER_SYSVIEW_CORE_CM3
#endif
#elif defined(__ICCARM__)
#if (defined (__ARM6M__) && (__CORE__ == __ARM6M__)) \
|| (defined (__ARM8M_BASELINE__) && (__CORE__ == __ARM8M_BASELINE__))
#define SEGGER_SYSVIEW_CORE SEGGER_SYSVIEW_CORE_CM0
#elif (defined (__ARM7EM__) && (__CORE__ == __ARM7EM__)) \
|| (defined (__ARM7M__) && (__CORE__ == __ARM7M__)) \
|| (defined (__ARM8M_MAINLINE__) && (__CORE__ == __ARM8M_MAINLINE__)) \
|| (defined (__ARM8M_MAINLINE__) && (__CORE__ == __ARM8M_MAINLINE__))
#define SEGGER_SYSVIEW_CORE SEGGER_SYSVIEW_CORE_CM3
#endif
#elif defined(__CC_ARM)
#if (defined(__TARGET_ARCH_6S_M))
#define SEGGER_SYSVIEW_CORE SEGGER_SYSVIEW_CORE_CM0
#elif (defined(__TARGET_ARCH_7_M) || defined(__TARGET_ARCH_7E_M))
#define SEGGER_SYSVIEW_CORE SEGGER_SYSVIEW_CORE_CM3
#endif
#elif defined(__TI_ARM__)
#ifdef __TI_ARM_V6M0__
#define SEGGER_SYSVIEW_CORE SEGGER_SYSVIEW_CORE_CM0
#elif (defined(__TI_ARM_V7M3__) || defined(__TI_ARM_V7M4__))
#define SEGGER_SYSVIEW_CORE SEGGER_SYSVIEW_CORE_CM3
#endif
#elif defined(__ICCRX__)
#define SEGGER_SYSVIEW_CORE SEGGER_SYSVIEW_CORE_RX
#elif defined(__RX)
#define SEGGER_SYSVIEW_CORE SEGGER_SYSVIEW_CORE_RX
#endif
#ifndef SEGGER_SYSVIEW_CORE
#define SEGGER_SYSVIEW_CORE SEGGER_SYSVIEW_CORE_OTHER
#endif
#endif
/*********************************************************************
*
* Defines, defaults
*
**********************************************************************
*/
/*********************************************************************
*
* Define: SEGGER_SYSVIEW_APP_NAME
*
* Description
* The application name to be displayed in SystemView.
* Default
* "SystemView-enabled Application"
* Notes
* Convenience define to be used for SEGGER_SYSVIEW_SendSysDesc().
*/
#ifndef SEGGER_SYSVIEW_APP_NAME
#define SEGGER_SYSVIEW_APP_NAME "SystemView-enabled Application"
#endif
/*********************************************************************
*
* Define: SEGGER_SYSVIEW_DEVICE_NAME
*
* Description
* The target device name to be displayed in SystemView.
* Default
* "undefined device"
* Notes
* Convenience define to be used for SEGGER_SYSVIEW_SendSysDesc().
*/
#ifndef SEGGER_SYSVIEW_DEVICE_NAME
#define SEGGER_SYSVIEW_DEVICE_NAME "undefined device"
#endif
/*********************************************************************
*
* Define: SEGGER_SYSVIEW_GET_INTERRUPT_ID()
*
* Description
* Function macro to retrieve the Id of the currently active
* interrupt.
* Default
* Call user-supplied function SEGGER_SYSVIEW_X_GetInterruptId().
* Notes
* For some known compilers and cores, a ready-to-use, core-specific
* default is set.
* ARMv7M: Read ICSR[8:0] (active vector)
* ARMv6M: Read ICSR[5:0] (active vector)
*/
#ifndef SEGGER_SYSVIEW_GET_INTERRUPT_ID
#if SEGGER_SYSVIEW_CORE == SEGGER_SYSVIEW_CORE_CM3
#define SEGGER_SYSVIEW_GET_INTERRUPT_ID() ((*(U32*)(0xE000ED04)) & 0x1FF) // Get the currently active interrupt Id. (i.e. read Cortex-M ICSR[8:0] = active vector)
#elif SEGGER_SYSVIEW_CORE == SEGGER_SYSVIEW_CORE_CM0
#if defined(__ICCARM__)
#if (__VER__ > 6010000)
#define SEGGER_SYSVIEW_GET_INTERRUPT_ID() (__get_IPSR()) // Workaround for IAR, which might do a byte-access to 0xE000ED04. Read IPSR instead.
#else
#define SEGGER_SYSVIEW_GET_INTERRUPT_ID() ((*(U32*)(0xE000ED04)) & 0x3F) // Older versions of IAR do not include __get_IPSR, but might also not optimize to byte-access.
#endif
#else
#define SEGGER_SYSVIEW_GET_INTERRUPT_ID() ((*(U32*)(0xE000ED04)) & 0x3F) // Get the currently active interrupt Id. (i.e. read Cortex-M ICSR[5:0] = active vector)
#endif
#else
#define SEGGER_SYSVIEW_GET_INTERRUPT_ID() SEGGER_SYSVIEW_X_GetInterruptId() // Get the currently active interrupt Id from the user-provided function.
#endif
#endif
/*********************************************************************
*
* Define: SEGGER_SYSVIEW_GET_TIMESTAMP()
*
* Description
* Function macro to retrieve a system timestamp for SYSVIEW events.
* Default
* Call user-supplied function SEGGER_SYSVIEW_X_GetTimestamp().
* Notes
* For some known compilers and cores, a ready-to-use, core-specific
* default is set.
* ARMv7M: Read Cortex-M Cycle Count register.
*
* The system timestamp clock frequency has to be passed in
* SEGGER_SYSVIEW_Init().
*/
#ifndef SEGGER_SYSVIEW_GET_TIMESTAMP
#if defined (SEGGER_SYSVIEW_CORE) && (SEGGER_SYSVIEW_CORE == SEGGER_SYSVIEW_CORE_CM3)
#define SEGGER_SYSVIEW_GET_TIMESTAMP() (*(U32 *)(0xE0001004)) // Retrieve a system timestamp. Cortex-M cycle counter.
#else
#define SEGGER_SYSVIEW_GET_TIMESTAMP() SEGGER_SYSVIEW_X_GetTimestamp() // Retrieve a system timestamp via user-defined function
#endif
#endif
/*********************************************************************
*
* Define: SEGGER_SYSVIEW_TIMESTAMP_BITS
*
* Description
* Number of valid (low-order) bits delivered in system timestamp.
* Default
* 32
* Notes
* Value has to match system timestamp clock source.
*/
// Define number of valid bits low-order delivered by clock source.
#ifndef SEGGER_SYSVIEW_TIMESTAMP_BITS
#define SEGGER_SYSVIEW_TIMESTAMP_BITS 32
#endif
/*********************************************************************
*
* Define: SEGGER_SYSVIEW_RTT_CHANNEL
*
* Description
* The RTT channel that SystemView will use.
* Default
* 0: Auto selection.
* Notes
* Value has to be lower than SEGGER_RTT_MAX_NUM_UP_BUFFERS.
*/
#ifndef SEGGER_SYSVIEW_RTT_CHANNEL
#define SEGGER_SYSVIEW_RTT_CHANNEL 1
#endif
// Sanity check of RTT channel
#if (SEGGER_SYSVIEW_RTT_CHANNEL == 0) && (SEGGER_RTT_MAX_NUM_UP_BUFFERS < 2)
#error "SEGGER_RTT_MAX_NUM_UP_BUFFERS in SEGGER_RTT_Conf.h has to be > 1!"
#elif (SEGGER_SYSVIEW_RTT_CHANNEL >= SEGGER_RTT_MAX_NUM_UP_BUFFERS)
#error "SEGGER_RTT_MAX_NUM_UP_BUFFERS in SEGGER_RTT_Conf.h has to be > SEGGER_SYSVIEW_RTT_CHANNEL!"
#endif
/*********************************************************************
*
* Define: SEGGER_SYSVIEW_RTT_BUFFER_SIZE
*
* Description
* Number of bytes that SystemView uses for the RTT buffer.
* Default
* 1024
*/
#ifndef SEGGER_SYSVIEW_RTT_BUFFER_SIZE
#define SEGGER_SYSVIEW_RTT_BUFFER_SIZE 1024
#endif
/*********************************************************************
*
* Define: SEGGER_SYSVIEW_SECTION
*
* Description
* Section to place the SystemView RTT Buffer into.
* Default
* undefined: Do not place into a specific section.
* Notes
* If SEGGER_RTT_SECTION is defined, the default changes to use
* this section for the SystemView RTT Buffer, too.
*/
#if !(defined SEGGER_SYSVIEW_SECTION) && (defined SEGGER_RTT_SECTION)
#define SEGGER_SYSVIEW_SECTION SEGGER_RTT_SECTION
#endif
/*********************************************************************
*
* Define: SEGGER_SYSVIEW_CPU_CACHE_LINE_SIZE
*
* Description
* Largest cache line size (in bytes) in the target system.
* Default
* 0
* Notes
* Required in systems with caches to make sure that the SystemView
* RTT buffer can be aligned accordingly.
*/
#ifndef SEGGER_SYSVIEW_CPU_CACHE_LINE_SIZE
#define SEGGER_SYSVIEW_CPU_CACHE_LINE_SIZE 0
#endif
/*********************************************************************
*
* Define: SEGGER_SYSVIEW_ID_BASE
*
* Description
* Lowest Id reported by the application.
* Default
* 0
* Notes
* Value is usually subtracted from mailboxes, semaphores, tasks,
* .... addresses, to compress event parameters.
* Should be the lowest RAM address of the system.
*/
#ifndef SEGGER_SYSVIEW_ID_BASE
#define SEGGER_SYSVIEW_ID_BASE 0
#endif
/*********************************************************************
*
* Define: SEGGER_SYSVIEW_ID_SHIFT
*
* Description
* Number of bits to shift Ids.
* Default
* 0
* Notes
* Ids are shifted to compress event parameters.
* Should match the alignment of Ids (addresses),
* e.g. 2 when Ids are 4 byte aligned.
*/
#ifndef SEGGER_SYSVIEW_ID_SHIFT
#define SEGGER_SYSVIEW_ID_SHIFT 0
#endif
/*********************************************************************
*
* Define: SEGGER_SYSVIEW_MAX_ARGUMENTS
*
* Description
* Maximum number of arguments which are handled with SystemView
* print routines or may be encoded in one recording function.
* routines.
* Default
* 16
*/
#ifndef SEGGER_SYSVIEW_MAX_ARGUMENTS
#define SEGGER_SYSVIEW_MAX_ARGUMENTS 16
#endif
/*********************************************************************
*
* Define: SEGGER_SYSVIEW_MAX_STRING_LEN
*
* Description
* Maximum string length which can be used in SystemView print and
* system description routines.
* Default
* 128
*/
#ifndef SEGGER_SYSVIEW_MAX_STRING_LEN
#define SEGGER_SYSVIEW_MAX_STRING_LEN 128
#endif
ESP_STATIC_ASSERT(SEGGER_SYSVIEW_MAX_STRING_LEN < 255, "SEGGER Sysview string length must be less than 255.");
/*********************************************************************
*
* Define: SEGGER_SYSVIEW_SUPPORT_LONG_ID
*
* Description
* It set, support encoding Evend Ids longer than 14 bit.
* Default
* 1
*/
#ifndef SEGGER_SYSVIEW_SUPPORT_LONG_ID
#define SEGGER_SYSVIEW_SUPPORT_LONG_ID 1
#endif
/*********************************************************************
*
* Define: SEGGER_SYSVIEW_SUPPORT_LONG_DATA
*
* Description
* It set, support encoding event data longer than 14 bit.
* Default
* 0
*/
#ifndef SEGGER_SYSVIEW_SUPPORT_LONG_DATA
#define SEGGER_SYSVIEW_SUPPORT_LONG_DATA 0
#endif
/*********************************************************************
*
* Define: SEGGER_SYSVIEW_PRINTF_IMPLICIT_FORMAT
*
* Description
* If enabled, on SEGGER_SYSVIEW_PrintHost, check the format string
* and if it includes unsupported formatters, use formatting on the
* target instead.
* Default
* 0: Disabled.
*/
#ifndef SEGGER_SYSVIEW_PRINTF_IMPLICIT_FORMAT
#define SEGGER_SYSVIEW_PRINTF_IMPLICIT_FORMAT 0
#endif
/*********************************************************************
*
* Define: SEGGER_SYSVIEW_USE_INTERNAL_RECORDER
*
* Description
* If set, an internal recorder, such as UART or IP is used.
* Default
* 0: Disabled.
* Notes
* Convenience define to be used by SEGGER_SYSVIEW_Conf(),
* such as in embOS configuration to enable Cortex-M cycle counter.
*/
#ifndef SEGGER_SYSVIEW_USE_INTERNAL_RECORDER
#define SEGGER_SYSVIEW_USE_INTERNAL_RECORDER 0
#endif
/*********************************************************************
*
* Define: SEGGER_SYSVIEW_CAN_RESTART
*
* Description
* If enabled, send the SystemView start sequence on every start
* command, not just on the first one.
* Enables restart when SystemView disconnected unexpectedly.
* Default
* 1: Enabled
*/
#ifndef SEGGER_SYSVIEW_CAN_RESTART
#define SEGGER_SYSVIEW_CAN_RESTART 1
#endif
/*********************************************************************
*
* Define: SEGGER_SYSVIEW_START_ON_INIT
*
* Description
* Enable calling SEGGER_SYSVIEW_Start() after initialization.
* Default
* 0: Disabled.
* Notes
* Convenience define to be used by SEGGER_SYSVIEW_Conf(),
* such as in embOS configuration.
*/
#ifndef SEGGER_SYSVIEW_START_ON_INIT
#define SEGGER_SYSVIEW_START_ON_INIT 0
#endif
/*********************************************************************
*
* Define: SEGGER_SYSVIEW_USE_STATIC_BUFFER
*
* Description
* If enabled, use a static buffer instead of a buffer on the stack
* for SystemView event packets.
* Default
* 1: Enabled.
* Notes
* If enabled, the static memory use by SystemView is increased by
* the maximum packet size. SystemView is locked on entry of a
* recording function.
* If disabled, the stack usage by SystemView recording functions
* might be increased by up to the maximum packet size. SystemView
* is locked when writing the packet to the RTT buffer.
*/
#ifndef SEGGER_SYSVIEW_USE_STATIC_BUFFER
#define SEGGER_SYSVIEW_USE_STATIC_BUFFER 1
#endif
/*********************************************************************
*
* Define: SEGGER_SYSVIEW_MAX_PACKET_SIZE
*
* Description
* Maximum packet size for a SystemView event.
* Default
* Automatically calculated.
* Notes
* The maximum packet size is mainly defined by the maximum string
* length and the maximum number of arguments.
*/
#ifndef SEGGER_SYSVIEW_MAX_PACKET_SIZE
#define SEGGER_SYSVIEW_MAX_PACKET_SIZE (SEGGER_SYSVIEW_INFO_SIZE + SEGGER_SYSVIEW_MAX_STRING_LEN + 2 * SEGGER_SYSVIEW_QUANTA_U32 + SEGGER_SYSVIEW_MAX_ARGUMENTS * SEGGER_SYSVIEW_QUANTA_U32)
#endif
/*********************************************************************
*
* Define: SEGGER_SYSVIEW_POST_MORTEM_MODE
*
* Description
* If enabled, SystemView records for post-mortem analysis instead
* of real-time analysis.
* Default
* 0: Disabled.
* Notes
* For more information refer to
* https://www.segger.com/products/development-tools/systemview/technology/post-mortem-mode
*/
#ifndef SEGGER_SYSVIEW_POST_MORTEM_MODE
#define SEGGER_SYSVIEW_POST_MORTEM_MODE 0
#endif
/*********************************************************************
*
* Define: SEGGER_SYSVIEW_SYNC_PERIOD_SHIFT
*
* Description
* Configure how frequently synchronization is sent in post-mortem
* mode.
* Default
* 8: (1 << 8) = Every 256 Events.
* Notes
* In post-mortem mode, at least one sync has to be in the RTT buffer.
* Recommended sync frequency: Buffer Size / 16
* For more information refer to
* https://www.segger.com/products/development-tools/systemview/technology/post-mortem-mode
*/
#ifndef SEGGER_SYSVIEW_SYNC_PERIOD_SHIFT
#define SEGGER_SYSVIEW_SYNC_PERIOD_SHIFT 8
#endif
/*********************************************************************
*
* Define: SEGGER_SYSVIEW_ON_EVENT_RECORDED()
*
* Description
* Function macro to notify recorder about a new event in buffer.
* Default
* undefined: Do not notify recorder.
* Notes
* Used for non-J-Link recorder,
* such as to enable transmission via UART or notify IP task.
*/
#ifndef SEGGER_SYSVIEW_ON_EVENT_RECORDED
#define SEGGER_SYSVIEW_ON_EVENT_RECORDED(NumBytes)
#endif
/*********************************************************************
*
* Define: SEGGER_SYSVIEW_LOCK()
*
* Description
* Function macro to (nestable) lock SystemView recording.
* Default
* Use RTT Locking mechanism (defined by SEGGER_RTT_LOCK()).
* Notes
* If SystemView recording is not locked, recording events from
* interrupts and tasks may lead to unpredictable, undefined, event
* data.
*/
#ifndef SEGGER_SYSVIEW_LOCK
unsigned SEGGER_SYSVIEW_X_SysView_Lock(void);
#define SEGGER_SYSVIEW_LOCK() unsigned _SYSVIEW_int_state = SEGGER_SYSVIEW_X_SysView_Lock()
#endif
/*********************************************************************
*
* Define: SEGGER_SYSVIEW_UNLOCK
*
* Description
* Function macro to unlock SystemView recording.
* Default
* Use RTT Unlocking mechanism (defined by SEGGER_RTT_UNLOCK()).
*/
#ifndef SEGGER_SYSVIEW_UNLOCK
void SEGGER_SYSVIEW_X_SysView_Unlock(unsigned int_state);
#define SEGGER_SYSVIEW_UNLOCK() SEGGER_SYSVIEW_X_SysView_Unlock(_SYSVIEW_int_state)
#endif
#ifdef __cplusplus
}
#endif
#endif
/*************************** End of file ****************************/

View File

@@ -1,104 +0,0 @@
/*
* SPDX-FileCopyrightText: 1995-2021 SEGGER Microcontroller GmbH
*
* SPDX-License-Identifier: BSD-1-Clause
*/
/*********************************************************************
* SEGGER Microcontroller GmbH *
* The Embedded Experts *
**********************************************************************
* *
* (c) 1995 - 2024 SEGGER Microcontroller GmbH *
* *
* www.segger.com Support: support@segger.com *
* *
**********************************************************************
* *
* SEGGER SystemView * Real-time application analysis *
* *
**********************************************************************
* *
* All rights reserved. *
* *
* SEGGER strongly recommends to not make any changes *
* to or modify the source code of this software in order to stay *
* compatible with the SystemView and RTT protocol, and J-Link. *
* *
* Redistribution and use in source and binary forms, with or *
* without modification, are permitted provided that the following *
* condition is met: *
* *
* o Redistributions of source code must retain the above copyright *
* notice, this condition and the following disclaimer. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR *
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
* DAMAGE. *
* *
**********************************************************************
* *
* SystemView version: 3.56 *
* *
**********************************************************************
-------------------------- END-OF-HEADER -----------------------------
File : SEGGER_SYSVIEW_Int.h
Purpose : SEGGER SystemView internal header.
Revision: $Rev: 21281 $
*/
#ifndef SEGGER_SYSVIEW_INT_H
#define SEGGER_SYSVIEW_INT_H
/*********************************************************************
*
* #include Section
*
**********************************************************************
*/
#include "SEGGER_SYSVIEW.h"
#ifdef __cplusplus
extern "C" {
#endif
/*********************************************************************
*
* Private data types
*
**********************************************************************
*/
//
// Commands that Host can send to target
//
typedef enum {
SEGGER_SYSVIEW_COMMAND_ID_START = 1,
SEGGER_SYSVIEW_COMMAND_ID_STOP,
SEGGER_SYSVIEW_COMMAND_ID_GET_SYSTIME,
SEGGER_SYSVIEW_COMMAND_ID_GET_TASKLIST,
SEGGER_SYSVIEW_COMMAND_ID_GET_SYSDESC,
SEGGER_SYSVIEW_COMMAND_ID_GET_NUMMODULES,
SEGGER_SYSVIEW_COMMAND_ID_GET_MODULEDESC,
SEGGER_SYSVIEW_COMMAND_ID_HEARTBEAT = 127,
// Extended commands: Commands >= 128 have a second parameter
SEGGER_SYSVIEW_COMMAND_ID_GET_MODULE = 128
} SEGGER_SYSVIEW_COMMAND_ID;
#ifdef __cplusplus
}
#endif
#endif
/*************************** End of file ****************************/

View File

@@ -1,6 +0,0 @@
name: 'SystemView'
version: '3.56'
cpe: cpe:2.3:a:segger:systemview:{}:*:*:*:*:*:*:*
supplier: 'Organization: Espressif Systems (Shanghai) CO LTD'
originator: 'Organization: SEGGER Microcontroller GmbH'
description: Real-time recording and visualization tool for embedded systems.

View File

@@ -1,287 +0,0 @@
/*
* SPDX-FileCopyrightText: 1995-2021 SEGGER Microcontroller GmbH
*
* SPDX-License-Identifier: BSD-1-Clause
*
* SPDX-FileContributor: 2017-2025 Espressif Systems (Shanghai) CO LTD
*/
/*********************************************************************
* SEGGER Microcontroller GmbH *
* The Embedded Experts *
**********************************************************************
* *
* (c) 1995 - 2021 SEGGER Microcontroller GmbH *
* *
* www.segger.com Support: support@segger.com *
* *
**********************************************************************
* *
* SEGGER SystemView * Real-time application analysis *
* *
**********************************************************************
* *
* All rights reserved. *
* *
* SEGGER strongly recommends to not make any changes *
* to or modify the source code of this software in order to stay *
* compatible with the SystemView and RTT protocol, and J-Link. *
* *
* Redistribution and use in source and binary forms, with or *
* without modification, are permitted provided that the following *
* condition is met: *
* *
* o Redistributions of source code must retain the above copyright *
* notice, this condition and the following disclaimer. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR *
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
* DAMAGE. *
* *
**********************************************************************
* *
* SystemView version: 3.42 *
* *
**********************************************************************
-------------------------- END-OF-HEADER -----------------------------
File : SEGGER_SYSVIEW_Config_FreeRTOS.c
Purpose : Sample setup configuration of SystemView with FreeRTOS.
Revision: $Rev: 7745 $
*/
#include <string.h>
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "SEGGER_SYSVIEW.h"
#include "esp_app_trace.h"
#include "esp_app_trace_util.h"
#include "esp_intr_alloc.h"
#include "esp_clk_tree.h"
#include "esp_cpu.h"
#include "soc/soc.h"
#include "soc/interrupts.h"
#include "esp_private/esp_clk.h"
extern const SEGGER_SYSVIEW_OS_API SYSVIEW_X_OS_TraceAPI;
/*********************************************************************
*
* Defines, configurable
*
**********************************************************************
*/
// The application name to be displayed in SystemViewer
#define SYSVIEW_APP_NAME "FreeRTOS Application"
// The target device name
#define SYSVIEW_DEVICE_NAME CONFIG_IDF_TARGET
// The target core name
#define SYSVIEW_CORE_NAME "core0" // In dual core, this will be renamed by OpenOCD as core1
// Determine which timer to use as timestamp source
#if CONFIG_APPTRACE_SV_TS_SOURCE_CCOUNT
#define TS_USE_CCOUNT 1
#elif CONFIG_APPTRACE_SV_TS_SOURCE_ESP_TIMER
#define TS_USE_ESP_TIMER 1
#else
#define TS_USE_TIMERGROUP 1
#endif
#if TS_USE_TIMERGROUP
#include "driver/gptimer.h"
// Timer group timer divisor
#define SYSVIEW_TIMER_DIV 2
// GPTimer handle
gptimer_handle_t s_sv_gptimer;
#endif // TS_USE_TIMERGROUP
#if TS_USE_ESP_TIMER
// esp_timer provides 1us resolution
#define SYSVIEW_TIMESTAMP_FREQ (1000000)
#endif // TS_USE_ESP_TIMER
#if TS_USE_CCOUNT
// CCOUNT is incremented at CPU frequency
#define SYSVIEW_TIMESTAMP_FREQ (CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ * 1000000)
#endif // TS_USE_CCOUNT
// System Frequency.
#define SYSVIEW_CPU_FREQ (esp_clk_cpu_freq())
// The lowest RAM address used for IDs (pointers)
#define SYSVIEW_RAM_BASE (SOC_DROM_LOW)
#ifdef CONFIG_FREERTOS_TICK_SUPPORT_CORETIMER
#if CONFIG_FREERTOS_CORETIMER_0
#define SYSTICK_INTR_ID (ETS_INTERNAL_TIMER0_INTR_SOURCE+ETS_INTERNAL_INTR_SOURCE_OFF)
#endif
#if CONFIG_FREERTOS_CORETIMER_1
#define SYSTICK_INTR_ID (ETS_INTERNAL_TIMER1_INTR_SOURCE+ETS_INTERNAL_INTR_SOURCE_OFF)
#endif
#elif CONFIG_FREERTOS_SYSTICK_USES_SYSTIMER
#define SYSTICK_INTR_ID (ETS_SYSTIMER_TARGET0_INTR_SOURCE)
#endif // CONFIG_FREERTOS_TICK_SUPPORT_CORETIMER
// SystemView is single core specific: it implies that SEGGER_SYSVIEW_LOCK()
// disables IRQs (disables rescheduling globally). So we can not use finite timeouts for locks and return error
// in case of expiration, because error will not be handled and SEGGER's code will go further implying that
// everything is fine, so for multi-core env we have to wait on underlying lock forever
#define SEGGER_LOCK_WAIT_TMO ESP_APPTRACE_TMO_INFINITE
static esp_apptrace_lock_t s_sys_view_lock = {.mux = portMUX_INITIALIZER_UNLOCKED, .int_state = 0};
/*********************************************************************
*
* _cbSendSystemDesc()
*
* Function description
* Sends SystemView description strings.
*/
static void _cbSendSystemDesc(void) {
char irq_str[32] = "I#";
SEGGER_SYSVIEW_SendSysDesc("N="SYSVIEW_APP_NAME",D="SYSVIEW_DEVICE_NAME",C="SYSVIEW_CORE_NAME",O=FreeRTOS");
strcat(itoa(SYSTICK_INTR_ID, irq_str + 2, 10), "=SysTick");
SEGGER_SYSVIEW_SendSysDesc(irq_str);
size_t isr_count = sizeof(esp_isr_names)/sizeof(esp_isr_names[0]);
for (size_t i = 0; i < isr_count; ++i) {
if (esp_isr_names[i] == NULL || (ETS_INTERNAL_INTR_SOURCE_OFF + i) == SYSTICK_INTR_ID)
continue;
strcat(itoa(ETS_INTERNAL_INTR_SOURCE_OFF + i, irq_str + 2, 10), "=");
strncat(irq_str, esp_isr_names[i], sizeof(irq_str) - strlen(irq_str) - 1);
SEGGER_SYSVIEW_SendSysDesc(irq_str);
}
}
/*********************************************************************
*
* Global functions
*
**********************************************************************
*/
static int SEGGER_SYSVIEW_TS_Init(void)
{
/* We only need to initialize something if we use Timer Group.
* esp_timer and ccount can be used as is.
*/
#if TS_USE_TIMERGROUP
// get clock source frequency
uint32_t counter_src_hz = 0;
ESP_ERROR_CHECK(esp_clk_tree_src_get_freq_hz(
(soc_module_clk_t)GPTIMER_CLK_SRC_DEFAULT,
ESP_CLK_TREE_SRC_FREQ_PRECISION_CACHED, &counter_src_hz));
gptimer_config_t config = {
.clk_src = GPTIMER_CLK_SRC_DEFAULT,
.direction = GPTIMER_COUNT_UP,
.resolution_hz = counter_src_hz / SYSVIEW_TIMER_DIV,
};
// pick any free GPTimer instance
ESP_ERROR_CHECK(gptimer_new_timer(&config, &s_sv_gptimer));
/* Start counting */
gptimer_enable(s_sv_gptimer);
gptimer_start(s_sv_gptimer);
return config.resolution_hz;
#else
return SYSVIEW_TIMESTAMP_FREQ;
#endif // TS_USE_TIMERGROUP
}
void SEGGER_SYSVIEW_Conf(void) {
U32 disable_evts = 0;
int timestamp_freq = SEGGER_SYSVIEW_TS_Init();
SEGGER_SYSVIEW_Init(timestamp_freq, SYSVIEW_CPU_FREQ,
&SYSVIEW_X_OS_TraceAPI, _cbSendSystemDesc);
SEGGER_SYSVIEW_SetRAMBase(SYSVIEW_RAM_BASE);
#if !CONFIG_APPTRACE_SV_EVT_OVERFLOW_ENABLE
disable_evts |= SYSVIEW_EVTMASK_OVERFLOW;
#endif
#if !CONFIG_APPTRACE_SV_EVT_ISR_ENTER_ENABLE
disable_evts |= SYSVIEW_EVTMASK_ISR_ENTER;
#endif
#if !CONFIG_APPTRACE_SV_EVT_ISR_EXIT_ENABLE
disable_evts |= SYSVIEW_EVTMASK_ISR_EXIT;
#endif
#if !CONFIG_APPTRACE_SV_EVT_TASK_START_EXEC_ENABLE
disable_evts |= SYSVIEW_EVTMASK_TASK_START_EXEC;
#endif
#if !CONFIG_APPTRACE_SV_EVT_TASK_STOP_EXEC_ENABLE
disable_evts |= SYSVIEW_EVTMASK_TASK_STOP_EXEC;
#endif
#if !CONFIG_APPTRACE_SV_EVT_TASK_START_READY_ENABLE
disable_evts |= SYSVIEW_EVTMASK_TASK_START_READY;
#endif
#if !CONFIG_APPTRACE_SV_EVT_TASK_STOP_READY_ENABLE
disable_evts |= SYSVIEW_EVTMASK_TASK_STOP_READY;
#endif
#if !CONFIG_APPTRACE_SV_EVT_TASK_CREATE_ENABLE
disable_evts |= SYSVIEW_EVTMASK_TASK_CREATE;
#endif
#if !CONFIG_APPTRACE_SV_EVT_TASK_TERMINATE_ENABLE
disable_evts |= SYSVIEW_EVTMASK_TASK_TERMINATE;
#endif
#if !CONFIG_APPTRACE_SV_EVT_IDLE_ENABLE
disable_evts |= SYSVIEW_EVTMASK_IDLE;
#endif
#if !CONFIG_APPTRACE_SV_EVT_ISR_TO_SCHED_ENABLE
disable_evts |= SYSVIEW_EVTMASK_ISR_TO_SCHEDULER;
#endif
#if !CONFIG_APPTRACE_SV_EVT_TIMER_ENTER_ENABLE
disable_evts |= SYSVIEW_EVTMASK_TIMER_ENTER;
#endif
#if !CONFIG_APPTRACE_SV_EVT_TIMER_EXIT_ENABLE
disable_evts |= SYSVIEW_EVTMASK_TIMER_EXIT;
#endif
SEGGER_SYSVIEW_DisableEvents(disable_evts);
}
U32 SEGGER_SYSVIEW_X_GetTimestamp(void)
{
#if TS_USE_TIMERGROUP
uint64_t ts = 0;
gptimer_get_raw_count(s_sv_gptimer, &ts);
return (U32) ts; // return lower part of counter value
#elif TS_USE_CCOUNT
return esp_cpu_get_cycle_count();
#elif TS_USE_ESP_TIMER
return (U32) esp_timer_get_time(); // return lower part of counter value
#endif
}
void SEGGER_SYSVIEW_X_RTT_Lock(void)
{
}
void SEGGER_SYSVIEW_X_RTT_Unlock(void)
{
}
unsigned SEGGER_SYSVIEW_X_SysView_Lock(void)
{
esp_apptrace_tmo_t tmo;
esp_apptrace_tmo_init(&tmo, SEGGER_LOCK_WAIT_TMO);
esp_apptrace_lock_take(&s_sys_view_lock, &tmo);
// to be recursive save IRQ status on the stack of the caller to keep it from overwriting
return s_sys_view_lock.int_state;
}
void SEGGER_SYSVIEW_X_SysView_Unlock(unsigned int_state)
{
s_sys_view_lock.int_state = int_state;
esp_apptrace_lock_give(&s_sys_view_lock);
}
/*************************** End of file ****************************/

View File

@@ -1,270 +0,0 @@
/*
* SPDX-FileCopyrightText: 1995-2021 SEGGER Microcontroller GmbH
*
* SPDX-License-Identifier: BSD-1-Clause
*
* SPDX-FileContributor: 2023 Espressif Systems (Shanghai) CO LTD
*/
/*********************************************************************
* SEGGER Microcontroller GmbH *
* The Embedded Experts *
**********************************************************************
* *
* (c) 1995 - 2021 SEGGER Microcontroller GmbH *
* *
* www.segger.com Support: support@segger.com *
* *
**********************************************************************
* *
* SEGGER SystemView * Real-time application analysis *
* *
**********************************************************************
* *
* All rights reserved. *
* *
* SEGGER strongly recommends to not make any changes *
* to or modify the source code of this software in order to stay *
* compatible with the SystemView and RTT protocol, and J-Link. *
* *
* Redistribution and use in source and binary forms, with or *
* without modification, are permitted provided that the following *
* condition is met: *
* *
* o Redistributions of source code must retain the above copyright *
* notice, this condition and the following disclaimer. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR *
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
* DAMAGE. *
* *
**********************************************************************
* *
* SystemView version: 3.42 *
* *
**********************************************************************
-------------------------- END-OF-HEADER -----------------------------
File : SEGGER_SYSVIEW_FreeRTOS.c
Purpose : Interface between FreeRTOS and SystemView.
Revision: $Rev: 7947 $
*/
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "SEGGER_SYSVIEW.h"
#include "SEGGER_SYSVIEW_FreeRTOS.h"
#include "string.h" // Required for memset
typedef struct SYSVIEW_FREERTOS_TASK_STATUS SYSVIEW_FREERTOS_TASK_STATUS;
struct SYSVIEW_FREERTOS_TASK_STATUS {
U32 xHandle;
const char* pcTaskName;
unsigned uxCurrentPriority;
U32 pxStack;
unsigned uStackHighWaterMark;
};
static SYSVIEW_FREERTOS_TASK_STATUS _aTasks[SYSVIEW_FREERTOS_MAX_NOF_TASKS];
static unsigned _NumTasks;
/*********************************************************************
*
* _cbSendTaskList()
*
* Function description
* This function is part of the link between FreeRTOS and SYSVIEW.
* Called from SystemView when asked by the host, it uses SYSVIEW
* functions to send the entire task list to the host.
*/
static void _cbSendTaskList(void) {
unsigned n;
for (n = 0; n < _NumTasks; n++) {
#if INCLUDE_uxTaskGetStackHighWaterMark // Report Task Stack High Watermark
_aTasks[n].uStackHighWaterMark = uxTaskGetStackHighWaterMark((TaskHandle_t)_aTasks[n].xHandle);
#endif
SYSVIEW_SendTaskInfo((U32)_aTasks[n].xHandle, _aTasks[n].pcTaskName, (unsigned)_aTasks[n].uxCurrentPriority, (U32)_aTasks[n].pxStack, (unsigned)_aTasks[n].uStackHighWaterMark);
}
}
/*********************************************************************
*
* _cbGetTime()
*
* Function description
* This function is part of the link between FreeRTOS and SYSVIEW.
* Called from SystemView when asked by the host, returns the
* current system time in micro seconds.
*/
__attribute__((unused)) static U64 _cbGetTime(void) {
U64 Time;
Time = xTaskGetTickCountFromISR();
Time *= portTICK_PERIOD_MS;
Time *= 1000;
return Time;
}
/*********************************************************************
*
* Global functions
*
**********************************************************************
*/
/*********************************************************************
*
* SYSVIEW_AddTask()
*
* Function description
* Add a task to the internal list and record its information.
*/
void SYSVIEW_AddTask(U32 xHandle, const char* pcTaskName, unsigned uxCurrentPriority, U32 pxStack, unsigned uStackHighWaterMark) {
/* On multi-core we have several idle tasks with 'IDLEx' names
Not best solution, because we can filter out user tasks starting with 'IDLE'.
But we can not use 'xTaskGetIdleTaskHandle' because at the moment when this
function is called array of idle tasks handles are not initialized yet. */
if (memcmp(pcTaskName, "IDLE", 4) == 0) {
return;
}
if (_NumTasks >= SYSVIEW_FREERTOS_MAX_NOF_TASKS) {
SEGGER_SYSVIEW_Warn("SYSTEMVIEW: Could not record task information. Maximum number of tasks reached.");
return;
}
_aTasks[_NumTasks].xHandle = xHandle;
_aTasks[_NumTasks].pcTaskName = pcTaskName;
_aTasks[_NumTasks].uxCurrentPriority = uxCurrentPriority;
_aTasks[_NumTasks].pxStack = pxStack;
_aTasks[_NumTasks].uStackHighWaterMark = uStackHighWaterMark;
_NumTasks++;
SYSVIEW_SendTaskInfo(xHandle, pcTaskName,uxCurrentPriority, pxStack, uStackHighWaterMark);
}
/*********************************************************************
*
* SYSVIEW_UpdateTask()
*
* Function description
* Update a task in the internal list and record its information.
*/
void SYSVIEW_UpdateTask(U32 xHandle, const char* pcTaskName, unsigned uxCurrentPriority, U32 pxStack, unsigned uStackHighWaterMark) {
unsigned n;
/* On multi-core we have several idle tasks with 'IDLEx' names
Not best solution, because we can filter out user tasks starting with 'IDLE'.
But we can not use 'xTaskGetIdleTaskHandle' because at the moment when this
function is called array of idle tasks handles are not initialized yet. */
if (memcmp(pcTaskName, "IDLE", 4) == 0) {
return;
}
for (n = 0; n < _NumTasks; n++) {
if (_aTasks[n].xHandle == xHandle) {
break;
}
}
if (n < _NumTasks) {
_aTasks[n].pcTaskName = pcTaskName;
_aTasks[n].uxCurrentPriority = uxCurrentPriority;
_aTasks[n].pxStack = pxStack;
_aTasks[n].uStackHighWaterMark = uStackHighWaterMark;
SYSVIEW_SendTaskInfo(xHandle, pcTaskName, uxCurrentPriority, pxStack, uStackHighWaterMark);
} else {
SYSVIEW_AddTask(xHandle, pcTaskName, uxCurrentPriority, pxStack, uStackHighWaterMark);
}
}
/*********************************************************************
*
* SYSVIEW_DeleteTask()
*
* Function description
* Delete a task from the internal list.
*/
void SYSVIEW_DeleteTask(U32 xHandle) {
unsigned n;
if (_NumTasks == 0) {
return; // Early out
}
for (n = 0; n < _NumTasks; n++) {
if (_aTasks[n].xHandle == xHandle) {
break;
}
}
if (n == (_NumTasks - 1)) {
//
// Task is last item in list.
// Simply zero the item and decrement number of tasks.
//
memset(&_aTasks[n], 0, sizeof(_aTasks[n]));
_NumTasks--;
} else if (n < _NumTasks) {
//
// Task is in the middle of the list.
// Move last item to current position and decrement number of tasks.
// Order of tasks does not really matter, so no need to move all following items.
//
_aTasks[n].xHandle = _aTasks[_NumTasks - 1].xHandle;
_aTasks[n].pcTaskName = _aTasks[_NumTasks - 1].pcTaskName;
_aTasks[n].uxCurrentPriority = _aTasks[_NumTasks - 1].uxCurrentPriority;
_aTasks[n].pxStack = _aTasks[_NumTasks - 1].pxStack;
_aTasks[n].uStackHighWaterMark = _aTasks[_NumTasks - 1].uStackHighWaterMark;
memset(&_aTasks[_NumTasks - 1], 0, sizeof(_aTasks[_NumTasks - 1]));
_NumTasks--;
}
}
/*********************************************************************
*
* SYSVIEW_SendTaskInfo()
*
* Function description
* Record task information.
*/
void SYSVIEW_SendTaskInfo(U32 TaskID, const char* sName, unsigned Prio, U32 StackBase, unsigned StackSize) {
SEGGER_SYSVIEW_TASKINFO TaskInfo;
memset(&TaskInfo, 0, sizeof(TaskInfo)); // Fill all elements with 0 to allow extending the structure in future version without breaking the code
TaskInfo.TaskID = TaskID;
TaskInfo.sName = sName;
TaskInfo.Prio = Prio;
TaskInfo.StackBase = StackBase;
TaskInfo.StackSize = StackSize;
SEGGER_SYSVIEW_SendTaskInfo(&TaskInfo);
}
/*********************************************************************
*
* Public API structures
*
**********************************************************************
*/
// Callbacks provided to SYSTEMVIEW by FreeRTOS
const SEGGER_SYSVIEW_OS_API SYSVIEW_X_OS_TraceAPI = {
/* Callback _cbGetTime locks xKernelLock inside xTaskGetTickCountFromISR, this can cause deadlock on multi-core.
To prevent deadlock, always lock xKernelLock before s_sys_view_lock. Omitting the callback here results in sending
SYSVIEW_EVTID_SYSTIME_CYCLES events instead of SYSVIEW_EVTID_SYSTIME_US */
NULL,
_cbSendTaskList,
};
/*************************** End of file ****************************/

View File

@@ -1,367 +0,0 @@
/*
* SPDX-FileCopyrightText: 1995-2021 SEGGER Microcontroller GmbH
*
* SPDX-License-Identifier: BSD-1-Clause
*
* SPDX-FileContributor: 2023 Espressif Systems (Shanghai) CO LTD
*/
/*********************************************************************
* SEGGER Microcontroller GmbH *
* The Embedded Experts *
**********************************************************************
* *
* (c) 1995 - 2021 SEGGER Microcontroller GmbH *
* *
* www.segger.com Support: support@segger.com *
* *
**********************************************************************
* *
* SEGGER SystemView * Real-time application analysis *
* *
**********************************************************************
* *
* All rights reserved. *
* *
* SEGGER strongly recommends to not make any changes *
* to or modify the source code of this software in order to stay *
* compatible with the SystemView and RTT protocol, and J-Link. *
* *
* Redistribution and use in source and binary forms, with or *
* without modification, are permitted provided that the following *
* condition is met: *
* *
* o Redistributions of source code must retain the above copyright *
* notice, this condition and the following disclaimer. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR *
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
* DAMAGE. *
* *
**********************************************************************
* *
* SystemView version: 3.42 *
* *
**********************************************************************
-------------------------- END-OF-HEADER -----------------------------
File : SEGGER_SYSVIEW_FreeRTOS.h
Purpose : Interface between FreeRTOS and SystemView.
Tested with FreeRTOS V10.4.3
Revision: $Rev: 7745 $
Notes:
(1) Include this file at the end of FreeRTOSConfig.h
*/
#ifndef SYSVIEW_FREERTOS_H
#define SYSVIEW_FREERTOS_H
#include "SEGGER_SYSVIEW.h"
/*********************************************************************
*
* Defines, configurable
*
**********************************************************************
*/
#define SYSVIEW_FREERTOS_MAX_NOF_TASKS CONFIG_APPTRACE_SV_MAX_TASKS
/*********************************************************************
*
* Defines, fixed
*
**********************************************************************
*/
// for dual-core targets we use event ID to keep core ID bit (0 or 1)
// use the highest - 1 bit of event ID to indicate core ID
// the highest bit can not be used due to event ID encoding method
// this reduces supported ID range to [0..63] (for 1 byte IDs) plus [128..16383] (for 2 bytes IDs)
// so original continuous event IDs range is split into two sub-ranges for 1-bytes IDs and 2-bytes ones
// events which use apiFastID_OFFSET will have 1 byte ID,
// so for the sake of bandwidth economy events which are generated more frequently should use this ID offset
// currently all used events fall into this range
#define apiFastID_OFFSET (32u)
#define apiID_VTASKDELETE (1u)
#define apiID_VTASKDELAY (2u)
#define apiID_VTASKDELAYUNTIL (3u)
#define apiID_VTASKSUSPEND (4u)
#define apiID_ULTASKNOTIFYTAKE (5u)
#define apiID_VTASKNOTIFYGIVEFROMISR (6u)
#define apiID_VTASKPRIORITYINHERIT (7u)
#define apiID_VTASKRESUME (8u)
#define apiID_VTASKSTEPTICK (9u)
#define apiID_XTASKPRIORITYDISINHERIT (10u)
#define apiID_XTASKRESUMEFROMISR (11u)
#define apiID_XTASKGENERICNOTIFY (12u)
#define apiID_XTASKGENERICNOTIFYFROMISR (13u)
#define apiID_XTASKNOTIFYWAIT (14u)
#define apiID_XQUEUEGENERICCREATE (15u)
#define apiID_VQUEUEDELETE (16u)
#define apiID_XQUEUEGENERICRECEIVE (17u)
#define apiID_XQUEUEPEEKFROMISR (18u)
#define apiID_XQUEUERECEIVEFROMISR (19u)
#define apiID_VQUEUEADDTOREGISTRY (20u)
#define apiID_XQUEUEGENERICSEND (21u)
#define apiID_XQUEUEGENERICSENDFROMISR (22u)
#define apiID_VTASKPRIORITYSET (23u)
#define apiID_UXTASKPRIORITYGETFROMISR (24u)
#define apiID_XTASKGETTICKCOUNTFROMISR (25u)
#define apiID_XEVENTGROUPCLEARBITSFROMISR (26u)
#define apiID_XEVENTGROUPSETBITSFROMISR (27u)
#define apiID_XEVENTGROUPGETBITSFROMISR (28u)
#define apiID_XQUEUEGIVEFROMISR (29u)
#define apiID_XQUEUEISQUEUEEMPTYFROMISR (30u)
#define apiID_XQUEUEISQUEUEFULLFROMISR (31u) // the maximum allowed apiID for the first ID range
// events which use apiSlowID_OFFSET will have 2-bytes ID
#define apiSlowID_OFFSET (127u)
#define apiID_VTASKALLOCATEMPUREGIONS (1u)
#define apiID_UXTASKPRIORITYGET (2u)
#define apiID_ETASKGETSTATE (3u)
#define apiID_VTASKSTARTSCHEDULER (4u)
#define apiID_VTASKENDSCHEDULER (5u)
#define apiID_VTASKSUSPENDALL (6u)
#define apiID_XTASKRESUMEALL (7u)
#define apiID_XTASKGETTICKCOUNT (8u)
#define apiID_UXTASKGETNUMBEROFTASKS (9u)
#define apiID_PCTASKGETTASKNAME (10u)
#define apiID_UXTASKGETSTACKHIGHWATERMARK (11u)
#define apiID_VTASKSETAPPLICATIONTASKTAG (12u)
#define apiID_XTASKGETAPPLICATIONTASKTAG (13u)
#define apiID_VTASKSETTHREADLOCALSTORAGEPOINTER (14u)
#define apiID_PVTASKGETTHREADLOCALSTORAGEPOINTER (15u)
#define apiID_XTASKCALLAPPLICATIONTASKHOOK (16u)
#define apiID_XTASKGETIDLETASKHANDLE (17u)
#define apiID_UXTASKGETSYSTEMSTATE (18u)
#define apiID_VTASKLIST (19u)
#define apiID_VTASKGETRUNTIMESTATS (20u)
#define apiID_XTASKNOTIFYSTATECLEAR (21u)
#define apiID_XTASKGETCURRENTTASKHANDLE (22u)
#define apiID_VTASKSETTIMEOUTSTATE (23u)
#define apiID_XTASKCHECKFORTIMEOUT (24u)
#define apiID_VTASKMISSEDYIELD (25u)
#define apiID_XTASKGETSCHEDULERSTATE (26u)
#define apiID_XTASKGENERICCREATE (27u)
#define apiID_UXTASKGETTASKNUMBER (28u)
#define apiID_VTASKSETTASKNUMBER (29u)
#define apiID_ETASKCONFIRMSLEEPMODESTATUS (30u)
#define apiID_XTIMERCREATE (31u)
#define apiID_PVTIMERGETTIMERID (32u)
#define apiID_VTIMERSETTIMERID (33u)
#define apiID_XTIMERISTIMERACTIVE (34u)
#define apiID_XTIMERGETTIMERDAEMONTASKHANDLE (35u)
#define apiID_XTIMERPENDFUNCTIONCALLFROMISR (36u)
#define apiID_XTIMERPENDFUNCTIONCALL (37u)
#define apiID_PCTIMERGETTIMERNAME (38u)
#define apiID_XTIMERCREATETIMERTASK (39u)
#define apiID_XTIMERGENERICCOMMAND (40u)
#define apiID_UXQUEUEMESSAGESWAITING (41u)
#define apiID_UXQUEUESPACESAVAILABLE (42u)
#define apiID_UXQUEUEMESSAGESWAITINGFROMISR (43u)
#define apiID_XQUEUEALTGENERICSEND (44u)
#define apiID_XQUEUEALTGENERICRECEIVE (45u)
#define apiID_XQUEUECRSENDFROMISR (46u)
#define apiID_XQUEUECRRECEIVEFROMISR (47u)
#define apiID_XQUEUECRSEND (48u)
#define apiID_XQUEUECRRECEIVE (49u)
#define apiID_XQUEUECREATEMUTEX (50u)
#define apiID_XQUEUECREATECOUNTINGSEMAPHORE (51u)
#define apiID_XQUEUEGETMUTEXHOLDER (52u)
#define apiID_XQUEUETAKEMUTEXRECURSIVE (53u)
#define apiID_XQUEUEGIVEMUTEXRECURSIVE (54u)
#define apiID_VQUEUEUNREGISTERQUEUE (55u)
#define apiID_XQUEUECREATESET (56u)
#define apiID_XQUEUEADDTOSET (57u)
#define apiID_XQUEUEREMOVEFROMSET (58u)
#define apiID_XQUEUESELECTFROMSET (59u)
#define apiID_XQUEUESELECTFROMSETFROMISR (60u)
#define apiID_XQUEUEGENERICRESET (61u)
#define apiID_VLISTINITIALISE (62u)
#define apiID_VLISTINITIALISEITEM (63u)
#define apiID_VLISTINSERT (64u)
#define apiID_VLISTINSERTEND (65u)
#define apiID_UXLISTREMOVE (66u)
#define apiID_XEVENTGROUPCREATE (67u)
#define apiID_XEVENTGROUPWAITBITS (68u)
#define apiID_XEVENTGROUPCLEARBITS (69u)
#define apiID_XEVENTGROUPSETBITS (70u)
#define apiID_XEVENTGROUPSYNC (71u)
#define apiID_VEVENTGROUPDELETE (72u)
#define apiID_UXEVENTGROUPGETNUMBER (73u)
#define apiID_XSTREAMBUFFERCREATE (74u)
#define apiID_VSTREAMBUFFERDELETE (75u)
#define apiID_XSTREAMBUFFERRESET (76u)
#define apiID_XSTREAMBUFFERSEND (77u)
#define apiID_XSTREAMBUFFERSENDFROMISR (78u)
#define apiID_XSTREAMBUFFERRECEIVE (79u)
#define apiID_XSTREAMBUFFERRECEIVEFROMISR (80u)
#ifdef CONFIG_FREERTOS_SMP
#define traceQUEUE_SEND( pxQueue ) SEGGER_SYSVIEW_RecordU32x4(apiFastID_OFFSET + apiID_XQUEUEGENERICSEND, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue), 0u, 0u, 0u)
#else // CONFIG_FREERTOS_SMP
#if ( configUSE_QUEUE_SETS != 1 )
#define traceQUEUE_SEND( pxQueue ) SEGGER_SYSVIEW_RecordU32x4(apiFastID_OFFSET + apiID_XQUEUEGENERICSEND, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue), (U32)pvItemToQueue, xTicksToWait, xCopyPosition)
#else
#define traceQUEUE_SEND( pxQueue ) SEGGER_SYSVIEW_RecordU32x4(apiFastID_OFFSET + apiID_XQUEUEGENERICSEND, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue), 0u, 0u, 0u)
#endif
#endif // CONFIG_FREERTOS_SMP
#define traceSTART() SEGGER_SYSVIEW_Conf()
#define traceTASK_NOTIFY_TAKE(uxIndexToWait) SEGGER_SYSVIEW_RecordU32x2(apiFastID_OFFSET + apiID_ULTASKNOTIFYTAKE, xClearCountOnExit, xTicksToWait)
#define traceTASK_DELAY() SEGGER_SYSVIEW_RecordU32 (apiFastID_OFFSET + apiID_VTASKDELAY, xTicksToDelay)
#define traceTASK_DELAY_UNTIL(xTimeToWake) SEGGER_SYSVIEW_RecordVoid (apiFastID_OFFSET + apiID_VTASKDELAYUNTIL)
#define traceTASK_NOTIFY_GIVE_FROM_ISR(uxIndexToNotify) SEGGER_SYSVIEW_RecordU32x2(apiFastID_OFFSET + apiID_VTASKNOTIFYGIVEFROMISR, SEGGER_SYSVIEW_ShrinkId((U32)pxTCB), (U32)pxHigherPriorityTaskWoken)
#define traceTASK_PRIORITY_INHERIT( pxTCB, uxPriority ) SEGGER_SYSVIEW_RecordU32 (apiFastID_OFFSET + apiID_VTASKPRIORITYINHERIT, (U32)pxMutexHolder)
#define traceTASK_RESUME( pxTCB ) SEGGER_SYSVIEW_RecordU32 (apiFastID_OFFSET + apiID_VTASKRESUME, SEGGER_SYSVIEW_ShrinkId((U32)pxTCB))
#define traceINCREASE_TICK_COUNT( xTicksToJump ) SEGGER_SYSVIEW_RecordU32 (apiFastID_OFFSET + apiID_VTASKSTEPTICK, xTicksToJump)
#define traceTASK_SUSPEND( pxTCB ) SEGGER_SYSVIEW_RecordU32 (apiFastID_OFFSET + apiID_VTASKSUSPEND, SEGGER_SYSVIEW_ShrinkId((U32)pxTCB))
#define traceTASK_PRIORITY_DISINHERIT( pxTCB, uxBasePriority ) SEGGER_SYSVIEW_RecordU32 (apiFastID_OFFSET + apiID_XTASKPRIORITYDISINHERIT, (U32)pxMutexHolder)
#define traceTASK_RESUME_FROM_ISR( pxTCB ) SEGGER_SYSVIEW_RecordU32 (apiFastID_OFFSET + apiID_XTASKRESUMEFROMISR, SEGGER_SYSVIEW_ShrinkId((U32)pxTCB))
#define traceTASK_NOTIFY(uxIndexToNotify) SEGGER_SYSVIEW_RecordU32x4(apiFastID_OFFSET + apiID_XTASKGENERICNOTIFY, SEGGER_SYSVIEW_ShrinkId((U32)pxTCB), ulValue, eAction, (U32)pulPreviousNotificationValue)
#define traceTASK_NOTIFY_FROM_ISR(uxIndexToWait) SEGGER_SYSVIEW_RecordU32x5(apiFastID_OFFSET + apiID_XTASKGENERICNOTIFYFROMISR, SEGGER_SYSVIEW_ShrinkId((U32)pxTCB), ulValue, eAction, (U32)pulPreviousNotificationValue, (U32)pxHigherPriorityTaskWoken)
#define traceTASK_NOTIFY_WAIT(uxIndexToWait) SEGGER_SYSVIEW_RecordU32x4(apiFastID_OFFSET + apiID_XTASKNOTIFYWAIT, ulBitsToClearOnEntry, ulBitsToClearOnExit, (U32)pulNotificationValue, xTicksToWait)
#define traceQUEUE_CREATE( pxNewQueue ) SEGGER_SYSVIEW_RecordU32x3(apiFastID_OFFSET + apiID_XQUEUEGENERICCREATE, uxQueueLength, uxItemSize, ucQueueType)
#define traceQUEUE_DELETE( pxQueue ) SEGGER_SYSVIEW_RecordU32 (apiFastID_OFFSET + apiID_VQUEUEDELETE, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue))
#define traceQUEUE_PEEK( pxQueue ) SEGGER_SYSVIEW_RecordU32x4(apiFastID_OFFSET + apiID_XQUEUEGENERICRECEIVE, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue), SEGGER_SYSVIEW_ShrinkId((U32)pvBuffer), xTicksToWait, 1)
#define traceQUEUE_PEEK_FROM_ISR( pxQueue ) SEGGER_SYSVIEW_RecordU32x2(apiFastID_OFFSET + apiID_XQUEUEPEEKFROMISR, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue), SEGGER_SYSVIEW_ShrinkId((U32)pvBuffer))
#define traceQUEUE_PEEK_FROM_ISR_FAILED( pxQueue ) SEGGER_SYSVIEW_RecordU32x2(apiFastID_OFFSET + apiID_XQUEUEPEEKFROMISR, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue), SEGGER_SYSVIEW_ShrinkId((U32)pvBuffer))
#define traceQUEUE_RECEIVE( pxQueue ) SEGGER_SYSVIEW_RecordU32x4(apiFastID_OFFSET + apiID_XQUEUEGENERICRECEIVE, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue), SEGGER_SYSVIEW_ShrinkId((U32)0), xTicksToWait, 1)
#define traceQUEUE_RECEIVE_FAILED( pxQueue ) SEGGER_SYSVIEW_RecordU32x4(apiFastID_OFFSET + apiID_XQUEUEGENERICRECEIVE, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue), SEGGER_SYSVIEW_ShrinkId((U32)0), xTicksToWait, 1)
#define traceQUEUE_SEMAPHORE_RECEIVE( pxQueue ) SEGGER_SYSVIEW_RecordU32x4(apiFastID_OFFSET + apiID_XQUEUEGENERICRECEIVE, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue), SEGGER_SYSVIEW_ShrinkId((U32)0), xTicksToWait, 0)
#define traceQUEUE_RECEIVE_FROM_ISR( pxQueue ) SEGGER_SYSVIEW_RecordU32x3(apiFastID_OFFSET + apiID_XQUEUERECEIVEFROMISR, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue), SEGGER_SYSVIEW_ShrinkId((U32)pvBuffer), (U32)pxHigherPriorityTaskWoken)
#define traceQUEUE_RECEIVE_FROM_ISR_FAILED( pxQueue ) SEGGER_SYSVIEW_RecordU32x3(apiFastID_OFFSET + apiID_XQUEUERECEIVEFROMISR, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue), SEGGER_SYSVIEW_ShrinkId((U32)pvBuffer), (U32)pxHigherPriorityTaskWoken)
#define traceQUEUE_REGISTRY_ADD( xQueue, pcQueueName ) SEGGER_SYSVIEW_RecordU32x2(apiFastID_OFFSET + apiID_VQUEUEADDTOREGISTRY, SEGGER_SYSVIEW_ShrinkId((U32)xQueue), (U32)pcQueueName)
#define traceQUEUE_SEND_FAILED( pxQueue ) SEGGER_SYSVIEW_RecordU32x4(apiFastID_OFFSET + apiID_XQUEUEGENERICSEND, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue), (U32)pvItemToQueue, xTicksToWait, xCopyPosition)
#define traceQUEUE_SEND_FROM_ISR( pxQueue ) SEGGER_SYSVIEW_RecordU32x4(apiFastID_OFFSET + apiID_XQUEUEGENERICSENDFROMISR, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue), (U32)pvItemToQueue, (U32)pxHigherPriorityTaskWoken, xCopyPosition)
#define traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue ) SEGGER_SYSVIEW_RecordU32x4(apiFastID_OFFSET + apiID_XQUEUEGENERICSENDFROMISR, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue), (U32)pvItemToQueue, (U32)pxHigherPriorityTaskWoken, xCopyPosition)
#define traceQUEUE_GIVE_FROM_ISR( pxQueue ) SEGGER_SYSVIEW_RecordU32x2(apiFastID_OFFSET + apiID_XQUEUEGIVEFROMISR, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue), (U32)pxHigherPriorityTaskWoken)
#define traceQUEUE_GIVE_FROM_ISR_FAILED( pxQueue ) SEGGER_SYSVIEW_RecordU32x2(apiFastID_OFFSET + apiID_XQUEUEGIVEFROMISR, SEGGER_SYSVIEW_ShrinkId((U32)pxQueue), (U32)pxHigherPriorityTaskWoken)
#define traceSTREAM_BUFFER_CREATE( pxStreamBuffer, xIsMessageBuffer ) SEGGER_SYSVIEW_RecordU32x2(apiSlowID_OFFSET + apiID_XSTREAMBUFFERCREATE, (U32)xIsMessageBuffer, (U32)pxStreamBuffer)
#define traceSTREAM_BUFFER_CREATE_FAILED( xIsMessageBuffer ) SEGGER_SYSVIEW_RecordU32x2(apiSlowID_OFFSET + apiID_XSTREAMBUFFERCREATE, (U32)xIsMessageBuffer, 0u)
#define traceSTREAM_BUFFER_DELETE( xStreamBuffer ) SEGGER_SYSVIEW_RecordU32 (apiSlowID_OFFSET + apiID_VSTREAMBUFFERDELETE, (U32)xStreamBuffer)
#define traceSTREAM_BUFFER_RESET( xStreamBuffer ) SEGGER_SYSVIEW_RecordU32 (apiSlowID_OFFSET + apiID_XSTREAMBUFFERRESET, (U32)xStreamBuffer)
#define traceSTREAM_BUFFER_SEND( xStreamBuffer, xBytesSent ) SEGGER_SYSVIEW_RecordU32x2(apiSlowID_OFFSET + apiID_XSTREAMBUFFERSEND, (U32)xStreamBuffer, (U32)xBytesSent)
#define traceSTREAM_BUFFER_SEND_FAILED( xStreamBuffer ) SEGGER_SYSVIEW_RecordU32x2(apiSlowID_OFFSET + apiID_XSTREAMBUFFERSEND, (U32)xStreamBuffer, 0u)
#define traceSTREAM_BUFFER_SEND_FROM_ISR( xStreamBuffer, xBytesSent ) SEGGER_SYSVIEW_RecordU32x2(apiSlowID_OFFSET + apiID_XSTREAMBUFFERSENDFROMISR, (U32)xStreamBuffer, (U32)xBytesSent)
#define traceSTREAM_BUFFER_RECEIVE( xStreamBuffer, xReceivedLength ) SEGGER_SYSVIEW_RecordU32x2(apiSlowID_OFFSET + apiID_XSTREAMBUFFERRECEIVE, (U32)xStreamBuffer, (U32)xReceivedLength)
#define traceSTREAM_BUFFER_RECEIVE_FAILED( xStreamBuffer ) SEGGER_SYSVIEW_RecordU32x2(apiSlowID_OFFSET + apiID_XSTREAMBUFFERRECEIVE, (U32)xStreamBuffer, 0u)
#define traceSTREAM_BUFFER_RECEIVE_FROM_ISR( xStreamBuffer, xReceivedLength ) SEGGER_SYSVIEW_RecordU32x2(apiSlowID_OFFSET + apiID_XSTREAMBUFFERRECEIVEFROMISR, (U32)xStreamBuffer, (U32)xReceivedLength)
#define traceTASK_DELETE( pxTCB ) do { \
SEGGER_SYSVIEW_RecordU32(apiFastID_OFFSET + apiID_VTASKDELETE, SEGGER_SYSVIEW_ShrinkId((U32)pxTCB)); \
SYSVIEW_DeleteTask((U32)pxTCB); \
} while(0)
#if( portSTACK_GROWTH < 0 )
#define traceTASK_CREATE(pxNewTCB) if (pxNewTCB != NULL) { \
SEGGER_SYSVIEW_OnTaskCreate((U32)pxNewTCB); \
SYSVIEW_AddTask((U32)pxNewTCB, \
&(pxNewTCB->pcTaskName[0]), \
pxNewTCB->uxPriority, \
(U32)pxNewTCB->pxStack, \
((U32)pxNewTCB->pxTopOfStack - (U32)pxNewTCB->pxStack) \
); \
}
#else
#define traceTASK_CREATE(pxNewTCB) if (pxNewTCB != NULL) { \
SEGGER_SYSVIEW_OnTaskCreate((U32)pxNewTCB); \
SYSVIEW_AddTask((U32)pxNewTCB, \
&(pxNewTCB->pcTaskName[0]), \
pxNewTCB->uxPriority, \
(U32)pxNewTCB->pxStack, \
(U32)(pxNewTCB->pxStack-pxNewTCB->pxTopOfStack) \
); \
}
#endif
#define traceTASK_PRIORITY_SET(pxTask, uxNewPriority) { \
SEGGER_SYSVIEW_RecordU32x2(apiFastID_OFFSET+apiID_VTASKPRIORITYSET, \
SEGGER_SYSVIEW_ShrinkId((U32)pxTCB), \
uxNewPriority \
); \
SYSVIEW_UpdateTask((U32)pxTask, \
&(pxTask->pcTaskName[0]), \
uxNewPriority, \
(U32)pxTask->pxStack, \
0 \
); \
}
//
// Define INCLUDE_xTaskGetIdleTaskHandle as 1 in FreeRTOSConfig.h to allow identification of Idle state.
//
// SMP FreeRTOS uses unpinned IDLE tasks, so sometimes IDEL0 runs on CPU1, IDLE1 runs on CPU0 and so on.
// So IDLE state detection based on 'xTaskGetIdleTaskHandle' does not work for SMP kernel.
// We could compare current task handle with every element of the array returned by 'xTaskGetIdleTaskHandle',
// but it deos not seem to be efficient enough to be worth of making code more complex and less readabl.
// So always use task name comparison mechanism for SMP kernel.
#if ( INCLUDE_xTaskGetIdleTaskHandle == 1 && !defined(CONFIG_FREERTOS_SMP))
#define traceTASK_SWITCHED_IN() if(prvGetTCBFromHandle(NULL) == xTaskGetIdleTaskHandle()) { \
SEGGER_SYSVIEW_OnIdle(); \
} else { \
SEGGER_SYSVIEW_OnTaskStartExec((U32)prvGetTCBFromHandle(NULL)); \
}
#else
#define traceTASK_SWITCHED_IN() { \
if (memcmp(prvGetTCBFromHandle(NULL)->pcTaskName, "IDLE", 4) != 0) { \
SEGGER_SYSVIEW_OnTaskStartExec((U32)prvGetTCBFromHandle(NULL)); \
} else { \
SEGGER_SYSVIEW_OnIdle(); \
} \
}
#endif
#define traceMOVED_TASK_TO_READY_STATE(pxTCB) SEGGER_SYSVIEW_OnTaskStartReady((U32)pxTCB)
#define traceREADDED_TASK_TO_READY_STATE(pxTCB)
#define traceMOVED_TASK_TO_DELAYED_LIST() SEGGER_SYSVIEW_OnTaskStopReady((U32)prvGetTCBFromHandle(NULL), (1u << 2))
#define traceMOVED_TASK_TO_OVERFLOW_DELAYED_LIST() SEGGER_SYSVIEW_OnTaskStopReady((U32)prvGetTCBFromHandle(NULL), (1u << 2))
#define traceMOVED_TASK_TO_SUSPENDED_LIST(pxTCB) SEGGER_SYSVIEW_OnTaskStopReady((U32)pxTCB, ((3u << 3) | 3))
#define traceISR_EXIT_TO_SCHEDULER() SEGGER_SYSVIEW_RecordExitISRToScheduler()
#define traceISR_EXIT() SEGGER_SYSVIEW_RecordExitISR()
#define traceISR_ENTER(n) SEGGER_SYSVIEW_RecordEnterISR(n)
/*********************************************************************
*
* API functions
*
**********************************************************************
*/
#ifdef __cplusplus
extern "C" {
#endif
void SYSVIEW_AddTask (U32 xHandle, const char* pcTaskName, unsigned uxCurrentPriority, U32 pxStack, unsigned uStackHighWaterMark);
void SYSVIEW_UpdateTask (U32 xHandle, const char* pcTaskName, unsigned uxCurrentPriority, U32 pxStack, unsigned uStackHighWaterMark);
void SYSVIEW_DeleteTask (U32 xHandle);
void SYSVIEW_SendTaskInfo (U32 TaskID, const char* sName, unsigned Prio, U32 StackBase, unsigned StackSize);
#ifdef __cplusplus
}
#endif
#endif
/*************************** End of file ****************************/

View File

@@ -1,300 +0,0 @@
/*
* SPDX-FileCopyrightText: 2017-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "string.h"
#include "freertos/FreeRTOS.h"
#include "SEGGER_RTT.h"
#include "SEGGER_SYSVIEW.h"
#include "SEGGER_SYSVIEW_Conf.h"
#include "esp_app_trace.h"
#include "esp_log.h"
#include "esp_cpu.h"
#include "esp_private/startup_internal.h"
const static char *TAG = "segger_rtt";
#define SYSVIEW_EVENTS_BUF_SZ 255U
// size of down channel data buf
#define SYSVIEW_DOWN_BUF_SIZE 32
#define SEGGER_STOP_WAIT_TMO 1000000 //us
#if CONFIG_APPTRACE_SV_BUF_WAIT_TMO == -1
#define SEGGER_HOST_WAIT_TMO ESP_APPTRACE_TMO_INFINITE
#else
#define SEGGER_HOST_WAIT_TMO CONFIG_APPTRACE_SV_BUF_WAIT_TMO
#endif
static uint8_t s_events_buf[SYSVIEW_EVENTS_BUF_SZ];
static uint16_t s_events_buf_filled;
static uint8_t s_down_buf[SYSVIEW_DOWN_BUF_SIZE];
#if CONFIG_APPTRACE_SV_DEST_CPU_0 || CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE
#define APPTRACE_SV_DEST_CPU 0
#else
#define APPTRACE_SV_DEST_CPU 1
#endif // CONFIG_APPTRACE_SV_DEST_CPU_0
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* SEGGER_RTT_ESP_FlushNoLock()
*
* Function description
* Flushes buffered events.
*
* Parameters
* min_sz Threshold for flushing data. If current filling level is above this value, data will be flushed. JTAG destinations only.
* tmo Timeout for operation (in us). Use ESP_APPTRACE_TMO_INFINITE to wait indefinitely.
*
* Return value
* None.
*/
void SEGGER_RTT_ESP_FlushNoLock(unsigned long min_sz, unsigned long tmo)
{
esp_err_t res;
if (s_events_buf_filled > 0) {
res = esp_apptrace_write(s_events_buf, s_events_buf_filled, tmo);
if (res != ESP_OK) {
ESP_LOGE(TAG, "Failed to flush buffered events (%d)!", res);
}
}
// flush even if we failed to write buffered events, because no new events will be sent after STOP
res = esp_apptrace_flush_nolock(min_sz, tmo);
if (res != ESP_OK) {
ESP_LOGE(TAG, "Failed to flush apptrace data (%d)!", res);
}
s_events_buf_filled = 0;
}
/*********************************************************************
*
* SEGGER_RTT_ESP_Flush()
*
* Function description
* Flushes buffered events.
*
* Parameters
* min_sz Threshold for flushing data. If current filling level is above this value, data will be flushed. JTAG destinations only.
* tmo Timeout for operation (in us). Use ESP_APPTRACE_TMO_INFINITE to wait indefinitely.
*
* Return value
* None.
*/
void SEGGER_RTT_ESP_Flush(unsigned long min_sz, unsigned long tmo)
{
SEGGER_SYSVIEW_LOCK();
SEGGER_RTT_ESP_FlushNoLock(min_sz, tmo);
SEGGER_SYSVIEW_UNLOCK();
}
/*********************************************************************
*
* SEGGER_RTT_ReadNoLock()
*
* Function description
* Reads characters from SEGGER real-time-terminal control block
* which have been previously stored by the host.
* Do not lock against interrupts and multiple access.
*
* Parameters
* BufferIndex Index of Down-buffer to be used (e.g. 0 for "Terminal").
* pBuffer Pointer to buffer provided by target application, to copy characters from RTT-down-buffer to.
* BufferSize Size of the target application buffer.
*
* Return value
* Number of bytes that have been read.
*/
unsigned SEGGER_RTT_ReadNoLock(unsigned BufferIndex, void* pData, unsigned BufferSize)
{
uint32_t size = BufferSize;
esp_err_t res = esp_apptrace_read(pData, &size, 0);
if (res != ESP_OK) {
return 0;
}
return size;
}
/*********************************************************************
*
* SEGGER_RTT_WriteSkipNoLock
*
* Function description
* Stores a specified number of characters in SEGGER RTT
* control block which is then read by the host.
* SEGGER_RTT_WriteSkipNoLock does not lock the application and
* skips all data, if the data does not fit into the buffer.
*
* Parameters
* BufferIndex Index of "Up"-buffer to be used (e.g. 0 for "Terminal").
* pBuffer Pointer to character array. Does not need to point to a \0 terminated string.
* NumBytes Number of bytes to be stored in the SEGGER RTT control block.
*
* Return value
* Number of bytes which have been stored in the "Up"-buffer.
*
* Notes
* (1) If there is not enough space in the "Up"-buffer, all data is dropped.
* (2) For performance reasons this function does not call Init()
* and may only be called after RTT has been initialized.
* Either by calling SEGGER_RTT_Init() or calling another RTT API function first.
*/
unsigned SEGGER_RTT_WriteSkipNoLock(unsigned BufferIndex, const void* pBuffer, unsigned NumBytes)
{
uint8_t *pbuf = (uint8_t *)pBuffer;
uint8_t event_id = *pbuf;
if (esp_apptrace_get_destination() == ESP_APPTRACE_DEST_UART) {
if (
(APPTRACE_SV_DEST_CPU != esp_cpu_get_core_id()) &&
(
(event_id == SYSVIEW_EVTID_ISR_ENTER) ||
(event_id == SYSVIEW_EVTID_ISR_EXIT) ||
(event_id == SYSVIEW_EVTID_TASK_START_EXEC) ||
(event_id == SYSVIEW_EVTID_TASK_STOP_EXEC) ||
(event_id == SYSVIEW_EVTID_TASK_START_READY) ||
(event_id == SYSVIEW_EVTID_TASK_STOP_READY) ||
(event_id == SYSVIEW_EVTID_MARK_START) ||
(event_id == SYSVIEW_EVTID_MARK_STOP) ||
(event_id == SYSVIEW_EVTID_TIMER_ENTER) ||
(event_id == SYSVIEW_EVTID_TIMER_EXIT) ||
(event_id == SYSVIEW_EVTID_STACK_INFO) ||
(event_id == SYSVIEW_EVTID_MODULEDESC)
)
) {
return NumBytes;
}
// This is workaround for SystemView!
// Without this line SystemView will hangs on when heap tracing enabled.
if (event_id == SYSVIEW_EVTID_MODULEDESC) {
return NumBytes;
}
}
if (NumBytes > SYSVIEW_EVENTS_BUF_SZ) {
ESP_LOGE(TAG, "Too large event %u bytes!", NumBytes);
return 0;
}
if (esp_apptrace_get_destination() == ESP_APPTRACE_DEST_JTAG) {
if (esp_cpu_get_core_id()) { // dual core specific code
// use the highest - 1 bit of event ID to indicate core ID
// the highest bit can not be used due to event ID encoding method
// this reduces supported ID range to [0..63] (for 1 byte IDs) plus [128..16383] (for 2 bytes IDs)
if (*pbuf & 0x80) { // 2 bytes ID
*(pbuf + 1) |= (1 << 6);
} else if (NumBytes != 10 || *pbuf != 0) { // ignore sync sequence
*pbuf |= (1 << 6);
}
}
if (s_events_buf_filled + NumBytes > SYSVIEW_EVENTS_BUF_SZ) {
esp_err_t res = esp_apptrace_write(s_events_buf, s_events_buf_filled, SEGGER_HOST_WAIT_TMO);
if (res != ESP_OK) {
return 0; // skip current data buffer only, accumulated events are kept
}
s_events_buf_filled = 0;
}
}
memcpy(&s_events_buf[s_events_buf_filled], pBuffer, NumBytes);
s_events_buf_filled += NumBytes;
if (esp_apptrace_get_destination() == ESP_APPTRACE_DEST_UART) {
esp_err_t res = esp_apptrace_write(pBuffer, NumBytes, SEGGER_HOST_WAIT_TMO);
if (res != ESP_OK) {
return 0; // skip current data buffer only, accumulated events are kept
}
s_events_buf_filled = 0;
}
if (event_id == SYSVIEW_EVTID_TRACE_STOP) {
SEGGER_RTT_ESP_FlushNoLock(0, SEGGER_STOP_WAIT_TMO);
}
return NumBytes;
}
/*********************************************************************
*
* SEGGER_RTT_ConfigUpBuffer
*
* Function description
* Run-time configuration of a specific up-buffer (T->H).
* Buffer to be configured is specified by index.
* This includes: Buffer address, size, name, flags, ...
*
* Parameters
* BufferIndex Index of the buffer to configure.
* sName Pointer to a constant name string.
* pBuffer Pointer to a buffer to be used.
* BufferSize Size of the buffer.
* Flags Operating modes. Define behavior if buffer is full (not enough space for entire message).
*
* Return value
* >= 0 - O.K.
* < 0 - Error
*
* Additional information
* Buffer 0 is configured on compile-time.
* May only be called once per buffer.
* Buffer name and flags can be reconfigured using the appropriate functions.
*/
int SEGGER_RTT_ConfigUpBuffer(unsigned BufferIndex, const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags)
{
s_events_buf_filled = 0;
return 0;
}
/*********************************************************************
*
* SEGGER_RTT_ConfigDownBuffer
*
* Function description
* Run-time configuration of a specific down-buffer (H->T).
* Buffer to be configured is specified by index.
* This includes: Buffer address, size, name, flags, ...
*
* Parameters
* BufferIndex Index of the buffer to configure.
* sName Pointer to a constant name string.
* pBuffer Pointer to a buffer to be used.
* BufferSize Size of the buffer.
* Flags Operating modes. Define behavior if buffer is full (not enough space for entire message).
*
* Return value
* >= 0 O.K.
* < 0 Error
*
* Additional information
* Buffer 0 is configured on compile-time.
* May only be called once per buffer.
* Buffer name and flags can be reconfigured using the appropriate functions.
*/
int SEGGER_RTT_ConfigDownBuffer(unsigned BufferIndex, const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags)
{
return esp_apptrace_down_buffer_config(s_down_buf, sizeof(s_down_buf));
}
/*************************** Init hook ****************************
*
* This init function is placed here because this port file will be linked whenever SystemView is used.
* It is used to initialize SystemView and app trace configuration by the init hook function.
* Otherwise, SystemView and app trace initialization needs to be done later in the app_main.
*/
ESP_SYSTEM_INIT_FN(sysview_early_init, SECONDARY, BIT(0), 120)
{
esp_apptrace_set_header_size(ESP_APPTRACE_HEADER_SIZE_16);
SEGGER_SYSVIEW_Conf();
return ESP_OK;
}
/*************************** End of file ****************************/

View File

@@ -1,91 +0,0 @@
/*
* SPDX-FileCopyrightText: 2018-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdint.h>
#include <sdkconfig.h>
#include "SEGGER_SYSVIEW.h"
#include "SEGGER_RTT.h"
#include "esp_app_trace.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_log.h"
const static char *TAG = "sysview_heap_trace";
#ifdef CONFIG_HEAP_TRACING_STACK_DEPTH
#define CALLSTACK_SIZE CONFIG_HEAP_TRACING_STACK_DEPTH
#else
#define CALLSTACK_SIZE 0
#endif
static SEGGER_SYSVIEW_MODULE s_esp_sysview_heap_module = {
.sModule = "M=ESP32 SystemView Heap Tracing Module",
.NumEvents = 2,
};
static bool s_mod_registered;
esp_err_t esp_sysview_heap_trace_start(uint32_t tmo)
{
uint32_t tmo_ticks = tmo / (1000 * portTICK_PERIOD_MS);
ESP_EARLY_LOGV(TAG, "%s", __func__);
do {
if (tmo != (uint32_t) -1) {
// Currently timeout implementation is simple and has granularity of 1 OS tick,
// so just count down the number of times to call vTaskDelay
if (tmo_ticks-- == 0) {
return ESP_ERR_TIMEOUT;
}
}
vTaskDelay(1);
} while (!SEGGER_SYSVIEW_Started());
SEGGER_SYSVIEW_RegisterModule(&s_esp_sysview_heap_module);
s_mod_registered = true;
return ESP_OK;
}
esp_err_t esp_sysview_heap_trace_stop(void)
{
ESP_EARLY_LOGV(TAG, "%s", __func__);
SEGGER_RTT_ESP_Flush(0, ESP_APPTRACE_TMO_INFINITE);
return ESP_OK;
}
void esp_sysview_heap_trace_alloc(const void *addr, uint32_t size, const void *callers)
{
U8 aPacket[SEGGER_SYSVIEW_INFO_SIZE + (2 + CALLSTACK_SIZE)*SEGGER_SYSVIEW_QUANTA_U32];
U8* pPayload = SEGGER_SYSVIEW_PREPARE_PACKET(aPacket);
U32 *calls = (U32 *)callers;
if (!s_mod_registered) {
return;
}
ESP_EARLY_LOGV(TAG, "%s %p %lu", __func__, addr, size);
pPayload = SEGGER_SYSVIEW_EncodeU32(pPayload, (U32)addr);
pPayload = SEGGER_SYSVIEW_EncodeU32(pPayload, size);
for (int i = 0; i < CALLSTACK_SIZE; i++) {
pPayload = SEGGER_SYSVIEW_EncodeU32(pPayload, calls[i]);
}
SEGGER_SYSVIEW_SendPacket(&aPacket[0], pPayload, s_esp_sysview_heap_module.EventOffset + 0);
}
void esp_sysview_heap_trace_free(const void *addr, const void *callers)
{
U8 aPacket[SEGGER_SYSVIEW_INFO_SIZE + (1 + CALLSTACK_SIZE)*SEGGER_SYSVIEW_QUANTA_U32];
U8* pPayload = SEGGER_SYSVIEW_PREPARE_PACKET(aPacket);
U32 *calls = (U32 *)callers;
if (!s_mod_registered) {
return;
}
ESP_EARLY_LOGV(TAG, "%s %p", __func__, addr);
pPayload = SEGGER_SYSVIEW_EncodeU32(pPayload, (U32)addr);
for (int i = 0; i < CALLSTACK_SIZE; i++) {
pPayload = SEGGER_SYSVIEW_EncodeU32(pPayload, calls[i]);
}
SEGGER_SYSVIEW_SendPacket(&aPacket[0], pPayload, s_esp_sysview_heap_module.EventOffset + 1);
}

View File

@@ -1,26 +0,0 @@
/*
* SPDX-FileCopyrightText: 2018-2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdio.h>
#include <stdarg.h>
#include <sdkconfig.h>
#include "SEGGER_SYSVIEW_Int.h"
#include "freertos/FreeRTOS.h"
static portMUX_TYPE s_log_mutex = portMUX_INITIALIZER_UNLOCKED;
int esp_sysview_vprintf(const char * format, va_list args)
{
static char log_buffer[SEGGER_SYSVIEW_MAX_STRING_LEN];
portENTER_CRITICAL(&s_log_mutex);
size_t len = vsnprintf(log_buffer, sizeof(log_buffer), format, args);
if (len > sizeof(log_buffer) - 1) {
log_buffer[sizeof(log_buffer) - 1] = 0;
}
SEGGER_SYSVIEW_Print(log_buffer);
portEXIT_CRITICAL(&s_log_mutex);
return len;
}

View File

@@ -2,11 +2,7 @@
components/app_trace/test_apps:
depends_components:
- app_trace
- esp_timer
- soc
- esp_hw_support
- esp_driver_uart
- esp_trace
- esp_driver_gptimer
disable:
- if: IDF_TARGET in ["esp32h21", "esp32h4"]

View File

@@ -8,9 +8,4 @@ To build and run this test app for app_trace related tests:
IDF_TARGET=esp32 idf.py @app_trace build flash monitor
```
To build and run this test app for SystemView related tests:
```bash
IDF_TARGET=esp32 idf.py @sysview build flash monitor
```
`@app_trace` and `@sysview` arguments apply additional `idf.py` options, from [app_trace](app_trace) and [sysview](sysview) files.
`@app_trace` argument apply additional `idf.py` options, from [app_trace](app_trace) and file.

View File

@@ -1,4 +1,4 @@
idf_component_register(SRCS "test_app_trace_main.c" "test_trace.c"
INCLUDE_DIRS "."
PRIV_REQUIRES app_trace unity esp_driver_gptimer
PRIV_REQUIRES esp_trace unity esp_driver_gptimer
WHOLE_ARCHIVE)

View File

@@ -16,10 +16,10 @@
#include "freertos/FreeRTOS.h"
#include "freertos/semphr.h"
#include "freertos/task.h"
#include "esp_app_trace.h"
#define LOG_LOCAL_LEVEL ESP_LOG_VERBOSE
#include "esp_log.h"
#include "esp_app_trace.h"
#define ESP_APPTRACE_TEST_USE_PRINT_LOCK 0
#define ESP_APPTRACE_TEST_PRN_WRERR_MAX 5
@@ -65,7 +65,6 @@ const static char *TAG = "esp_apptrace_test";
#define ESP_APPTRACE_TEST_LOGV( format, ... ) ESP_APPTRACE_TEST_LOG_LEVEL(V, ESP_LOG_VERBOSE, format, ##__VA_ARGS__)
#define ESP_APPTRACE_TEST_LOGO( format, ... ) ESP_APPTRACE_TEST_LOG_LEVEL(E, ESP_LOG_NONE, format, ##__VA_ARGS__)
#if CONFIG_APPTRACE_SV_ENABLE == 0
#define ESP_APPTRACE_TEST_WRITE(_b_, _s_) esp_apptrace_write(_b_, _s_, ESP_APPTRACE_TMO_INFINITE)
#define ESP_APPTRACE_TEST_WRITE_FROM_ISR(_b_, _s_) esp_apptrace_write(_b_, _s_, 0UL)
#define ESP_APPTRACE_TEST_WRITE_NOWAIT(_b_, _s_) esp_apptrace_write(_b_, _s_, 0)
@@ -693,233 +692,3 @@ TEST_CASE("Log trace test (2 tasks)", "[trace][ignore]")
xSemaphoreTake(arg2.done, portMAX_DELAY);
vSemaphoreDelete(arg2.done);
}
#else // #if CONFIG_APPTRACE_SV_ENABLE == 0
typedef struct {
gptimer_handle_t gptimer;
uint32_t period;
int flags;
uint32_t id;
} esp_sysviewtrace_timer_arg_t;
typedef struct {
SemaphoreHandle_t done;
SemaphoreHandle_t *sync;
esp_sysviewtrace_timer_arg_t *timer;
uint32_t work_count;
uint32_t sleep_tmo;
uint32_t id;
} esp_sysviewtrace_task_arg_t;
static bool esp_sysview_test_timer_isr(gptimer_handle_t timer, const gptimer_alarm_event_data_t *edata, void *user_ctx)
{
esp_sysviewtrace_timer_arg_t *tim_arg = (esp_sysviewtrace_timer_arg_t *)user_ctx;
(void) tim_arg;
return false;
}
static void esp_sysviewtrace_test_task(void *p)
{
esp_sysviewtrace_task_arg_t *arg = (esp_sysviewtrace_task_arg_t *) p;
volatile uint32_t tmp = 0;
printf("%p: run sysview task\n", xTaskGetCurrentTaskHandle());
if (arg->timer) {
gptimer_alarm_config_t alarm_config = {
.reload_count = 0,
.alarm_count = arg->timer->period,
.flags.auto_reload_on_alarm = true,
};
gptimer_event_callbacks_t cbs = {
.on_alarm = esp_sysview_test_timer_isr,
};
TEST_ESP_OK(gptimer_register_event_callbacks(arg->timer->gptimer, &cbs, arg->timer));
TEST_ESP_OK(gptimer_enable(arg->timer->gptimer));
TEST_ESP_OK(gptimer_set_alarm_action(arg->timer->gptimer, &alarm_config));
TEST_ESP_OK(gptimer_start(arg->timer->gptimer));
}
int i = 0;
while (1) {
static uint32_t count;
printf("%" PRIu32, arg->id);
if ((++count % 80) == 0) {
printf("\n");
}
if (arg->sync) {
xSemaphoreTake(*arg->sync, portMAX_DELAY);
}
for (uint32_t k = 0; k < arg->work_count; k++) {
tmp++;
}
vTaskDelay(arg->sleep_tmo / portTICK_PERIOD_MS);
i++;
if (arg->sync) {
xSemaphoreGive(*arg->sync);
}
}
ESP_APPTRACE_TEST_LOGI("%p: finished", xTaskGetCurrentTaskHandle());
xSemaphoreGive(arg->done);
vTaskDelay(1);
vTaskDelete(NULL);
}
TEST_CASE("SysView trace test 1", "[trace][ignore]")
{
TaskHandle_t thnd;
esp_sysviewtrace_timer_arg_t tim_arg1 = {
.flags = ESP_INTR_FLAG_SHARED,
.id = 0,
.period = 500,
};
esp_sysviewtrace_task_arg_t arg1 = {
.done = xSemaphoreCreateBinary(),
.sync = NULL,
.work_count = 10000,
.sleep_tmo = 1,
.timer = &tim_arg1,
.id = 0,
};
esp_sysviewtrace_timer_arg_t tim_arg2 = {
.flags = 0,
.id = 1,
.period = 100,
};
esp_sysviewtrace_task_arg_t arg2 = {
.done = xSemaphoreCreateBinary(),
.sync = NULL,
.work_count = 10000,
.sleep_tmo = 1,
.timer = &tim_arg2,
.id = 1,
};
gptimer_config_t timer_config = {
.clk_src = GPTIMER_CLK_SRC_DEFAULT,
.direction = GPTIMER_COUNT_UP,
.resolution_hz = 1000000,
};
timer_config.flags.intr_shared = (tim_arg1.flags & ESP_INTR_FLAG_SHARED) == ESP_INTR_FLAG_SHARED;
TEST_ESP_OK(gptimer_new_timer(&timer_config, &tim_arg1.gptimer));
timer_config.flags.intr_shared = (tim_arg2.flags & ESP_INTR_FLAG_SHARED) == ESP_INTR_FLAG_SHARED;
TEST_ESP_OK(gptimer_new_timer(&timer_config, &tim_arg2.gptimer));
xTaskCreatePinnedToCore(esp_sysviewtrace_test_task, "svtrace0", 2048, &arg1, 3, &thnd, 0);
ESP_APPTRACE_TEST_LOGI("Created task %p", thnd);
#if CONFIG_FREERTOS_UNICORE == 0
xTaskCreatePinnedToCore(esp_sysviewtrace_test_task, "svtrace1", 2048, &arg2, 5, &thnd, 1);
#else
xTaskCreatePinnedToCore(esp_sysviewtrace_test_task, "svtrace1", 2048, &arg2, 5, &thnd, 0);
#endif
ESP_APPTRACE_TEST_LOGI("Created task %p", thnd);
xSemaphoreTake(arg1.done, portMAX_DELAY);
vSemaphoreDelete(arg1.done);
xSemaphoreTake(arg2.done, portMAX_DELAY);
vSemaphoreDelete(arg2.done);
TEST_ESP_OK(gptimer_stop(tim_arg1.gptimer));
TEST_ESP_OK(gptimer_disable(tim_arg1.gptimer));
TEST_ESP_OK(gptimer_del_timer(tim_arg1.gptimer));
TEST_ESP_OK(gptimer_stop(tim_arg2.gptimer));
TEST_ESP_OK(gptimer_disable(tim_arg2.gptimer));
TEST_ESP_OK(gptimer_del_timer(tim_arg2.gptimer));
}
TEST_CASE("SysView trace test 2", "[trace][ignore]")
{
TaskHandle_t thnd;
esp_sysviewtrace_timer_arg_t tim_arg1 = {
.flags = ESP_INTR_FLAG_SHARED,
.id = 0,
.period = 500,
};
esp_sysviewtrace_task_arg_t arg1 = {
.done = xSemaphoreCreateBinary(),
.sync = NULL,
.work_count = 10000,
.sleep_tmo = 1,
.timer = &tim_arg1,
.id = 0,
};
esp_sysviewtrace_timer_arg_t tim_arg2 = {
.flags = 0,
.id = 1,
.period = 100,
};
esp_sysviewtrace_task_arg_t arg2 = {
.done = xSemaphoreCreateBinary(),
.sync = NULL,
.work_count = 10000,
.sleep_tmo = 1,
.timer = &tim_arg2,
.id = 1,
};
SemaphoreHandle_t test_sync = xSemaphoreCreateBinary();
xSemaphoreGive(test_sync);
esp_sysviewtrace_task_arg_t arg3 = {
.done = xSemaphoreCreateBinary(),
.sync = &test_sync,
.work_count = 1000,
.sleep_tmo = 1,
.timer = NULL,
.id = 2,
};
esp_sysviewtrace_task_arg_t arg4 = {
.done = xSemaphoreCreateBinary(),
.sync = &test_sync,
.work_count = 10000,
.sleep_tmo = 1,
.timer = NULL,
.id = 3,
};
gptimer_config_t timer_config = {
.clk_src = GPTIMER_CLK_SRC_DEFAULT,
.direction = GPTIMER_COUNT_UP,
.resolution_hz = 1000000,
};
timer_config.flags.intr_shared = (tim_arg1.flags & ESP_INTR_FLAG_SHARED) == ESP_INTR_FLAG_SHARED;
TEST_ESP_OK(gptimer_new_timer(&timer_config, &tim_arg1.gptimer));
timer_config.flags.intr_shared = (tim_arg2.flags & ESP_INTR_FLAG_SHARED) == ESP_INTR_FLAG_SHARED;
TEST_ESP_OK(gptimer_new_timer(&timer_config, &tim_arg2.gptimer));
xTaskCreatePinnedToCore(esp_sysviewtrace_test_task, "svtrace0", 2048, &arg1, 3, &thnd, 0);
printf("Created task %p\n", thnd);
#if CONFIG_FREERTOS_UNICORE == 0
xTaskCreatePinnedToCore(esp_sysviewtrace_test_task, "svtrace1", 2048, &arg2, 4, &thnd, 1);
#else
xTaskCreatePinnedToCore(esp_sysviewtrace_test_task, "svtrace1", 2048, &arg2, 4, &thnd, 0);
#endif
printf("Created task %p\n", thnd);
xTaskCreatePinnedToCore(esp_sysviewtrace_test_task, "svsync0", 2048, &arg3, 3, &thnd, 0);
printf("Created task %p\n", thnd);
#if CONFIG_FREERTOS_UNICORE == 0
xTaskCreatePinnedToCore(esp_sysviewtrace_test_task, "svsync1", 2048, &arg4, 5, &thnd, 1);
#else
xTaskCreatePinnedToCore(esp_sysviewtrace_test_task, "svsync1", 2048, &arg4, 5, &thnd, 0);
#endif
printf("Created task %p\n", thnd);
xSemaphoreTake(arg1.done, portMAX_DELAY);
vSemaphoreDelete(arg1.done);
xSemaphoreTake(arg2.done, portMAX_DELAY);
vSemaphoreDelete(arg2.done);
xSemaphoreTake(arg3.done, portMAX_DELAY);
vSemaphoreDelete(arg3.done);
xSemaphoreTake(arg4.done, portMAX_DELAY);
vSemaphoreDelete(arg4.done);
vSemaphoreDelete(test_sync);
TEST_ESP_OK(gptimer_stop(tim_arg1.gptimer));
TEST_ESP_OK(gptimer_disable(tim_arg1.gptimer));
TEST_ESP_OK(gptimer_del_timer(tim_arg1.gptimer));
TEST_ESP_OK(gptimer_stop(tim_arg2.gptimer));
TEST_ESP_OK(gptimer_disable(tim_arg2.gptimer));
TEST_ESP_OK(gptimer_del_timer(tim_arg2.gptimer));
}
#endif // #if CONFIG_APPTRACE_SV_ENABLE == 0

View File

@@ -1 +1,3 @@
# app_trace is already enabled by sdkconfig.defaults, so no options are needed here
CONFIG_ESP_TRACE_LIB_NONE=y
CONFIG_ESP_TRACE_TRANSPORT_APPTRACE=y
CONFIG_APPTRACE_DEST_JTAG=y

View File

@@ -1 +0,0 @@
CONFIG_APPTRACE_SV_ENABLE=y

View File

@@ -1,3 +1,2 @@
CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0=n
CONFIG_APPTRACE_ENABLE=y
CONFIG_APPTRACE_DEST_JTAG=y
CONFIG_ESP_TRACE_ENABLE=y

View File

@@ -1 +0,0 @@
-DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.ci.sysview" -B build/sysview -DSDKCONFIG=build/sysview/sdkconfig

View File

@@ -15,6 +15,9 @@ components/app_update/test_apps:
- if: IDF_TARGET == "esp32c61" and CONFIG_NAME == "xip_psram_with_rom_impl"
temporary: true
reason: not supported yet # TODO: [ESP32C61] IDF-12784
- if: IDF_TARGET == "esp32p4"
temporary: true
reason: p4 rev3 migration # TODO: IDF-14401
disable_test:
- if: CONFIG_NAME == "recovery_bootloader" and SOC_RECOVERY_BOOTLOADER_SUPPORTED == 1 and IDF_TARGET == "esp32c61"
temporary: true

View File

@@ -1,2 +1,2 @@
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-C61 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 |
| ----------------- | ----- | -------- | -------- | -------- | -------- | --------- | -------- | -------- | -------- | -------- |
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-C61 | ESP32-H2 | ESP32-S2 | ESP32-S3 |
| ----------------- | ----- | -------- | -------- | -------- | -------- | --------- | -------- | -------- | -------- |

View File

@@ -139,7 +139,7 @@ TEST_CASE_MULTIPLE_STAGES("OTA update of partition_table via primary partition",
TEST_CASE("OTA update of NVS partition", "[nvs_ota]")
{
// intilaize "nvs" partition and define a var (magic_value).
// initialize "nvs" partition and define a var (magic_value).
TEST_ESP_OK(nvs_flash_erase());
TEST_ESP_OK(nvs_flash_init());
nvs_handle_t my_handle;
@@ -220,7 +220,7 @@ TEST_CASE_MULTIPLE_STAGES("OTA update of partition_table via a free ota partitio
TEST_CASE("OTA update of NVS partition via a free ota partition", "[nvs_ota]")
{
// intilaize "nvs" partition and define a var (magic_value).
// initialize "nvs" partition and define a var (magic_value).
const esp_partition_t *nvs_part = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_NVS, "nvs");
TEST_ESP_OK(nvs_flash_erase());
TEST_ESP_OK(nvs_flash_init());

View File

@@ -35,4 +35,9 @@ if(NOT CONFIG_SECURE_BOOT OR CONFIG_SECURE_BOOT_FLASH_BOOTLOADER_DEFAULT)
# Add bootloader as a dependency to the flash target
add_dependencies(flash bootloader)
if(CONFIG_SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT)
# Also add bootloader as a dependency to the encrypted-flash target
add_dependencies(encrypted-flash bootloader)
endif()
endif()

View File

@@ -839,6 +839,26 @@ menu "Security features"
Read https://docs.espressif.com/projects/esp-idf/en/latest/security/flash-encryption.html
before enabling.
choice SECURE_FLASH_ENCRYPTION_KEY_SOURCE
bool "Flash Encryption Key Source"
depends on SECURE_FLASH_ENC_ENABLED
default SECURE_FLASH_ENCRYPTION_KEY_SOURCE_EFUSES
help
Specify the key source for the Flash Encryption Key
config SECURE_FLASH_ENCRYPTION_KEY_SOURCE_EFUSES
bool "eFuse Key Block"
help
Use a key that is stored in the eFuses key blocks.
config SECURE_FLASH_ENCRYPTION_KEY_SOURCE_KEY_MGR
bool "Key Manager"
depends on SOC_KEY_MANAGER_SUPPORTED && SOC_KEY_MANAGER_FE_KEY_DEPLOY && \
!(IDF_TARGET_ESP32P4 && ESP32P4_SELECTS_REV_LESS_V3)
help
Use a key that is deployed using the Key Manager
endchoice
choice SECURE_FLASH_ENCRYPTION_KEYSIZE
bool "Size of generated XTS-AES key"
default SECURE_FLASH_ENCRYPTION_AES128
@@ -860,11 +880,16 @@ menu "Security features"
config SECURE_FLASH_ENCRYPTION_AES128
bool "AES-128 (256-bit key)"
depends on SOC_FLASH_ENCRYPTION_XTS_AES_128 && !(IDF_TARGET_ESP32C2 && SECURE_BOOT)
depends on SOC_FLASH_ENCRYPTION_XTS_AES_128 && \
((SECURE_FLASH_ENCRYPTION_KEY_SOURCE_EFUSES && SOC_EFUSE_XTS_AES_KEY_128) || \
(SECURE_FLASH_ENCRYPTION_KEY_SOURCE_KEY_MGR && SOC_KEY_MANAGER_FE_KEY_DEPLOY_XTS_AES_128)) && \
!(IDF_TARGET_ESP32C2 && SECURE_BOOT)
config SECURE_FLASH_ENCRYPTION_AES256
bool "AES-256 (512-bit key)"
depends on SOC_FLASH_ENCRYPTION_XTS_AES_256
depends on SOC_FLASH_ENCRYPTION_XTS_AES_256 && \
((SECURE_FLASH_ENCRYPTION_KEY_SOURCE_EFUSES && SOC_EFUSE_XTS_AES_KEY_256) || \
(SECURE_FLASH_ENCRYPTION_KEY_SOURCE_KEY_MGR && SOC_KEY_MANAGER_FE_KEY_DEPLOY_XTS_AES_256))
endchoice
choice SECURE_FLASH_ENCRYPTION_MODE
@@ -974,7 +999,7 @@ menu "Security features"
config SECURE_BOOT_SKIP_WRITE_PROTECTION_SCA
bool "Skip write-protection of SECURE_FLASH_PSEUDO_ROUND_FUNC_STRENGTH"
default y if SECURE_FLASH_PSEUDO_ROUND_FUNC
default y if SECURE_FLASH_PSEUDO_ROUND_FUNC && !SECURE_FLASH_ENCRYPTION_MODE_RELEASE
default n
depends on SOC_ECDSA_SUPPORT_CURVE_P384 && SOC_FLASH_ENCRYPTION_XTS_AES_SUPPORT_PSEUDO_ROUND
help

View File

@@ -91,6 +91,11 @@ SECTIONS
*libhal.a:cache_hal.*(.literal .text .literal.* .text.*)
*libhal.a:efuse_hal.*(.literal .text .literal.* .text.*)
*libesp_hal_wdt.a:wdt_hal_iram.*(.literal .text .literal.* .text.*)
*libhal.a:huk_hal.*(.literal .text .literal.* .text.*)
*libhal.a:key_mgr_hal.*(.literal .text .literal.* .text.*)
*libesp_security.a:esp_key_mgr.*(.literal .text .literal.* .text.*)
*libesp_security.a:esp_crypto_periph_clk.*(.literal .text .literal.* .text.*)
*libesp_security.a:esp_crypto_lock.*(.literal .text .literal.* .text.*)
*libesp_hw_support.a:rtc_clk.*(.literal .text .literal.* .text.*)
*libesp_hw_support.a:rtc_time.*(.literal .text .literal.* .text.*)
*libesp_hw_support.a:regi2c_ctrl.*(.literal .text .literal.* .text.*)

View File

@@ -90,6 +90,7 @@ SECTIONS
*libhal.a:cache_hal.*(.literal .text .literal.* .text.*)
*libhal.a:efuse_hal.*(.literal .text .literal.* .text.*)
*libhal.a:key_mgr_hal.*(.literal.key_mgr_hal_set_key_usage .text.key_mgr_hal_set_key_usage)
*libesp_security.a:esp_crypto_periph_clk.*(.literal .text .literal.* .text.*)
*libesp_hal_wdt.a:wdt_hal_iram.*(.literal .text .literal.* .text.*)
*libesp_hw_support.a:rtc_clk.*(.literal .text .literal.* .text.*)
*libesp_hw_support.a:rtc_time.*(.literal .text .literal.* .text.*)

View File

@@ -89,8 +89,12 @@ SECTIONS
*libhal.a:mmu_hal.*(.literal .text .literal.* .text.*)
*libhal.a:cache_hal.*(.literal .text .literal.* .text.*)
*libhal.a:efuse_hal.*(.literal .text .literal.* .text.*)
*libhal.a:key_mgr_hal.*(.literal.key_mgr_hal_set_key_usage .text.key_mgr_hal_set_key_usage)
*libesp_hal_wdt.a:wdt_hal_iram.*(.literal .text .literal.* .text.*)
*libhal.a:huk_hal.*(.literal .text .literal.* .text.*)
*libhal.a:key_mgr_hal.*(.literal .text .literal.* .text.*)
*libesp_security.a:esp_key_mgr.*(.literal .text .literal.* .text.*)
*libesp_security.a:esp_crypto_periph_clk.*(.literal .text .literal.* .text.*)
*libesp_security.a:esp_crypto_lock.*(.literal .text .literal.* .text.*)
*libesp_hw_support.a:rtc_clk.*(.literal .text .literal.* .text.*)
*libesp_hw_support.a:rtc_time.*(.literal .text .literal.* .text.*)
*libesp_hw_support.a:regi2c_ctrl.*(.literal .text .literal.* .text.*)

View File

@@ -93,6 +93,8 @@ endif()
if(BOOTLOADER_BUILD)
list(APPEND srcs "src/bootloader_panic.c")
list(APPEND priv_requires esp_security)
if(CONFIG_SECURE_FLASH_ENC_ENABLED)
list(APPEND srcs "src/flash_encryption/flash_encrypt.c"
"src/${IDF_TARGET}/flash_encryption_secure_features.c")

View File

@@ -217,13 +217,10 @@ static uint32_t current_mapped_size;
// Current bootloader mapping (ab)used for bootloader_read()
static uint32_t current_read_mapping = UINT32_MAX;
#if ESP_TEE_BUILD && CONFIG_IDF_TARGET_ESP32C6
extern void spi_common_set_dummy_output(esp_rom_spiflash_read_mode_t mode);
extern void spi_dummy_len_fix(uint8_t spi, uint8_t freqdiv);
/* TODO: [ESP-TEE] Workarounds for the ROM read API
*
* The esp_rom_spiflash_read API requires two workarounds on ESP32-C6 ECO0:
#if ESP_TEE_BUILD
/* [ESP-TEE] Workarounds for the ROM SPI flash APIs */
/*
* TODO: The esp_rom_spiflash_read API requires two workarounds on ESP32-C6 ECO0 -
*
* 1. [IDF-7199] Call esp_rom_spiflash_write API once before reading.
* Without this, reads return corrupted data.
@@ -231,10 +228,14 @@ extern void spi_dummy_len_fix(uint8_t spi, uint8_t freqdiv);
* 2. Configure ROM flash parameters before each read using the function below.
* Without this, the first byte read is corrupted.
*
* Note: These workarounds are not needed for ESP32-C6 ECO1 and later versions.
* NOTE: These workarounds are not needed for ESP32-C6 ECO1 and later versions.
*/
static void rom_read_api_workaround(void)
{
#if CONFIG_ESP32C6_REV_MIN_0
extern void spi_common_set_dummy_output(esp_rom_spiflash_read_mode_t mode);
extern void spi_dummy_len_fix(uint8_t spi, uint8_t freqdiv);
static bool is_first_call = true;
if (is_first_call) {
uint32_t dummy_val = UINT32_MAX;
@@ -268,6 +269,43 @@ static void rom_read_api_workaround(void)
spi_dummy_len_fix(1, freqdiv);
esp_rom_spiflash_config_readmode(read_mode);
spi_common_set_dummy_output(read_mode);
#endif
}
/*
* TODO: [IDF-13582]
*
* When `esp_flash_read()` is invoked from REE, it enables SPI1 WB (write-back) mode
* via `spi_flash_ll_wb_mode_enable()`. The ROM flash APIs used by TEE do not support
* WB mode, causing failures when TEE later accesses flash.
*
* Workaround applied in TEE flash layer:
* 1. Save the current WB mode state.
* 2. Temporarily disable WB mode before calling ROM flash APIs.
* 3. Restore WB mode state after the ROM API call completes.
*
* NOTE: This workaround will become removed once IDF-13582 is implemented.
*/
static inline bool spi1_wb_mode_save_and_disable(void)
{
#if SOC_SPI_MEM_SUPPORT_WB_MODE_INDEPENDENT_CONTROL
if (REG_GET_BIT(SPI_MEM_RD_STATUS_REG(1), SPI_MEM_WB_MODE_EN)) {
REG_CLR_BIT(SPI_MEM_RD_STATUS_REG(1), SPI_MEM_WB_MODE_EN);
return true;
}
#endif
return false;
}
static inline void spi1_wb_mode_restore(bool saved_state)
{
#if SOC_SPI_MEM_SUPPORT_WB_MODE_INDEPENDENT_CONTROL
if (saved_state) {
REG_SET_BIT(SPI_MEM_RD_STATUS_REG(1), SPI_MEM_WB_MODE_EN);
}
#else
(void)saved_state;
#endif
}
#endif
@@ -416,8 +454,9 @@ static esp_err_t bootloader_flash_read_no_decrypt(size_t src_addr, void *dest, s
#else
#if !ESP_TEE_BUILD
cache_hal_disable(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL);
#elif CONFIG_ESP32C6_REV_MIN_0
#else
rom_read_api_workaround();
bool is_wb_saved = spi1_wb_mode_save_and_disable();
#endif
#endif
@@ -428,6 +467,8 @@ static esp_err_t bootloader_flash_read_no_decrypt(size_t src_addr, void *dest, s
#else
#if !ESP_TEE_BUILD
cache_hal_enable(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL);
#else
spi1_wb_mode_restore(is_wb_saved);
#endif
#endif
@@ -550,6 +591,10 @@ esp_err_t bootloader_flash_write(size_t dest_addr, void *src, size_t size, bool
return err;
}
#if ESP_TEE_BUILD
bool is_wb_saved = spi1_wb_mode_save_and_disable();
#endif
esp_rom_spiflash_result_t rc = ESP_ROM_SPIFLASH_RESULT_OK;
if (write_encrypted && !ENCRYPTION_IS_VIRTUAL) {
@@ -564,6 +609,7 @@ esp_err_t bootloader_flash_write(size_t dest_addr, void *src, size_t size, bool
* from being read from already memory-mapped addresses that were modified.
*/
#if ESP_TEE_BUILD
spi1_wb_mode_restore(is_wb_saved);
spi_flash_check_and_flush_cache(dest_addr, size);
#endif

View File

@@ -382,13 +382,6 @@ static void IRAM_ATTR bootloader_init_flash_configure(void)
esp_err_t bootloader_init_spi_flash(void)
{
bootloader_init_flash_configure();
#ifndef CONFIG_SPI_FLASH_ROM_DRIVER_PATCH
const uint32_t spiconfig = esp_rom_efuse_get_flash_gpio_info();
if (spiconfig != ESP_ROM_EFUSE_FLASH_DEFAULT_SPI && spiconfig != ESP_ROM_EFUSE_FLASH_DEFAULT_HSPI) {
ESP_EARLY_LOGE(TAG, "SPI flash pins are overridden. Enable CONFIG_SPI_FLASH_ROM_DRIVER_PATCH in menuconfig");
return ESP_FAIL;
}
#endif
if ((void*)bootloader_flash_unlock != (void*)bootloader_flash_unlock_default) {
ESP_EARLY_LOGD(TAG, "Using overridden bootloader_flash_unlock");

View File

@@ -101,10 +101,10 @@ void IRAM_ATTR bootloader_configure_spi_pins(int drv)
esp_rom_gpio_pad_set_drv(q_gpio_num, drv);
esp_rom_gpio_pad_set_drv(d_gpio_num, drv);
esp_rom_gpio_pad_set_drv(cs0_gpio_num, drv);
if (hd_gpio_num <= MAX_PAD_GPIO_NUM) {
if (hd_gpio_num < SOC_GPIO_PIN_COUNT) {
esp_rom_gpio_pad_set_drv(hd_gpio_num, drv);
}
if (wp_gpio_num <= MAX_PAD_GPIO_NUM) {
if (wp_gpio_num < SOC_GPIO_PIN_COUNT) {
esp_rom_gpio_pad_set_drv(wp_gpio_num, drv);
}
}

View File

@@ -112,10 +112,10 @@ void IRAM_ATTR bootloader_configure_spi_pins(int drv)
esp_rom_gpio_pad_set_drv(q_gpio_num, drv);
esp_rom_gpio_pad_set_drv(d_gpio_num, drv);
esp_rom_gpio_pad_set_drv(cs0_gpio_num, drv);
if (hd_gpio_num <= MAX_PAD_GPIO_NUM) {
if (hd_gpio_num < SOC_GPIO_PIN_COUNT) {
esp_rom_gpio_pad_set_drv(hd_gpio_num, drv);
}
if (wp_gpio_num <= MAX_PAD_GPIO_NUM) {
if (wp_gpio_num < SOC_GPIO_PIN_COUNT) {
esp_rom_gpio_pad_set_drv(wp_gpio_num, drv);
}
}
@@ -256,13 +256,6 @@ static void bootloader_spi_flash_resume(void)
esp_err_t bootloader_init_spi_flash(void)
{
bootloader_init_flash_configure();
#ifndef CONFIG_SPI_FLASH_ROM_DRIVER_PATCH
const uint32_t spiconfig = esp_rom_efuse_get_flash_gpio_info();
if (spiconfig != ESP_ROM_EFUSE_FLASH_DEFAULT_SPI && spiconfig != ESP_ROM_EFUSE_FLASH_DEFAULT_HSPI) {
ESP_EARLY_LOGE(TAG, "SPI flash pins are overridden. Enable CONFIG_SPI_FLASH_ROM_DRIVER_PATCH in menuconfig");
return ESP_FAIL;
}
#endif
bootloader_spi_flash_resume();
if ((void*)bootloader_flash_unlock != (void*)bootloader_flash_unlock_default) {

View File

@@ -237,6 +237,12 @@ esp_err_t bootloader_init_spi_flash(void)
bootloader_init_mspi_clock();
bootloader_init_flash_configure();
#if CONFIG_BOOTLOADER_FLASH_DC_AWARE
// Reset flash, clear volatile bits DC[0:1]. Make it work under default mode to boot.
bootloader_spi_flash_reset();
#endif
bootloader_spi_flash_resume();
if ((void*)bootloader_flash_unlock != (void*)bootloader_flash_unlock_default) {
ESP_EARLY_LOGD(TAG, "Using overridden bootloader_flash_unlock");

View File

@@ -114,10 +114,10 @@ void IRAM_ATTR bootloader_configure_spi_pins(int drv)
esp_rom_gpio_pad_set_drv(q_gpio_num, drv);
esp_rom_gpio_pad_set_drv(d_gpio_num, drv);
esp_rom_gpio_pad_set_drv(cs0_gpio_num, drv);
if (hd_gpio_num <= MAX_PAD_GPIO_NUM) {
if (hd_gpio_num < SOC_GPIO_PIN_COUNT) {
esp_rom_gpio_pad_set_drv(hd_gpio_num, drv);
}
if (wp_gpio_num <= MAX_PAD_GPIO_NUM) {
if (wp_gpio_num < SOC_GPIO_PIN_COUNT) {
esp_rom_gpio_pad_set_drv(wp_gpio_num, drv);
}
}
@@ -254,13 +254,6 @@ static void IRAM_ATTR bootloader_init_flash_configure(void)
esp_err_t bootloader_init_spi_flash(void)
{
bootloader_init_flash_configure();
#ifndef CONFIG_SPI_FLASH_ROM_DRIVER_PATCH
const uint32_t spiconfig = esp_rom_efuse_get_flash_gpio_info();
if (spiconfig != ESP_ROM_EFUSE_FLASH_DEFAULT_SPI && spiconfig != ESP_ROM_EFUSE_FLASH_DEFAULT_HSPI) {
ESP_EARLY_LOGE(TAG, "SPI flash pins are overridden. Enable CONFIG_SPI_FLASH_ROM_DRIVER_PATCH in menuconfig");
return ESP_FAIL;
}
#endif
if ((void*)bootloader_flash_unlock != (void*)bootloader_flash_unlock_default) {
ESP_EARLY_LOGD(TAG, "Using overridden bootloader_flash_unlock");

View File

@@ -125,10 +125,10 @@ void IRAM_ATTR bootloader_configure_spi_pins(int drv)
esp_rom_gpio_pad_set_drv(q_gpio_num, drv);
esp_rom_gpio_pad_set_drv(d_gpio_num, drv);
esp_rom_gpio_pad_set_drv(cs0_gpio_num, drv);
if (hd_gpio_num <= MAX_PAD_GPIO_NUM) {
if (hd_gpio_num < SOC_GPIO_PIN_COUNT) {
esp_rom_gpio_pad_set_drv(hd_gpio_num, drv);
}
if (wp_gpio_num <= MAX_PAD_GPIO_NUM) {
if (wp_gpio_num < SOC_GPIO_PIN_COUNT) {
esp_rom_gpio_pad_set_drv(wp_gpio_num, drv);
}
}
@@ -272,13 +272,6 @@ static void bootloader_spi_flash_resume(void)
esp_err_t bootloader_init_spi_flash(void)
{
bootloader_init_flash_configure();
#ifndef CONFIG_SPI_FLASH_ROM_DRIVER_PATCH
const uint32_t spiconfig = esp_rom_efuse_get_flash_gpio_info();
if (spiconfig != ESP_ROM_EFUSE_FLASH_DEFAULT_SPI && spiconfig != ESP_ROM_EFUSE_FLASH_DEFAULT_HSPI) {
ESP_EARLY_LOGE(TAG, "SPI flash pins are overridden. Enable CONFIG_SPI_FLASH_ROM_DRIVER_PATCH in menuconfig");
return ESP_FAIL;
}
#endif
#if CONFIG_BOOTLOADER_FLASH_DC_AWARE
// Reset flash, clear volatile bits DC[0:1]. Make it work under default mode to boot.

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -9,7 +9,6 @@
#include "esp_attr.h"
#include "esp_err.h"
#include "soc/soc_caps.h"
#include "hal/efuse_ll.h"
#include "sdkconfig.h"
#ifdef __cplusplus
@@ -184,14 +183,14 @@ void esp_flash_encryption_init_checks(void);
*/
esp_err_t esp_flash_encryption_enable_secure_features(void);
#if CONFIG_SOC_KEY_MANAGER_FE_KEY_DEPLOY
#if SOC_KEY_MANAGER_FE_KEY_DEPLOY
/** @brief Enable the key manager for flash encryption
*
* @return
* - ESP_OK - On success
*/
esp_err_t esp_flash_encryption_enable_key_mgr(void);
#endif // CONFIG_SOC_KEY_MANAGER_FE_KEY_DEPLOY
esp_err_t esp_flash_encryption_use_efuse_key(void);
#endif // SOC_KEY_MANAGER_FE_KEY_DEPLOY
#endif /* BOOTLOADER_BUILD && CONFIG_SECURE_FLASH_ENC_ENABLED */

View File

@@ -263,7 +263,11 @@ rtc_retain_mem_t* bootloader_common_get_rtc_retain_mem(void)
#ifdef BOOTLOADER_BUILD
#if ESP_ROM_HAS_LP_ROM
#if CONFIG_IDF_TARGET_ESP32P4
#define RTC_RETAIN_MEM_ADDR (SOC_RTC_DRAM_LOW + CONFIG_P4_REV3_MSPI_WORKAROUND_SIZE)
#else
#define RTC_RETAIN_MEM_ADDR (SOC_RTC_DRAM_LOW)
#endif
#else
/* Since the structure containing the retain_mem_t is aligned on 8 by the linker, make sure we align this
* structure size here too */

View File

@@ -30,6 +30,7 @@ static void __attribute__((unused)) release_default_console_io(void)
{
// Default console is UART0 with TX and RX on their IOMUX pins
gpio_ll_output_disable(&GPIO, U0TXD_GPIO_NUM);
gpio_ll_func_sel(&GPIO, U0TXD_GPIO_NUM, PIN_FUNC_GPIO); // Set TX pin to GPIO function to truly disable output
esp_rom_gpio_connect_in_signal(GPIO_MATRIX_CONST_ONE_INPUT, UART_PERIPH_SIGNAL(UART_NUM_0, SOC_UART_PERIPH_SIGNAL_RX), 0);
}

View File

@@ -9,7 +9,8 @@
#include "soc/sens_reg.h"
#include "soc/syscon_reg.h"
#include "soc/dport_reg.h"
#include "soc/i2s_periph.h"
#include "soc/i2s_reg.h"
#include "soc/periph_defs.h"
#include "esp_log.h"
#include "soc/io_mux_reg.h"

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -12,56 +12,60 @@
#include "soc/system_reg.h"
#include "esp_private/regi2c_ctrl.h"
#include "soc/regi2c_saradc.h"
#include "hal/adc_ll.h"
#include "hal/sar_ctrl_ll.h"
#include "hal/clk_gate_ll.h"
#define ADC_RNG_CLKM_DIV_NUM 15
#define ADC_RNG_CLKM_DIV_B 0
#define ADC_RNG_CLKM_DIV_A 0
void bootloader_random_enable(void)
{
/* RNG module is always clock enabled */
REG_SET_FIELD(RTC_CNTL_SENSOR_CTRL_REG, RTC_CNTL_FORCE_XPD_SAR, 0x3);
sar_ctrl_ll_set_power_mode(SAR_CTRL_LL_POWER_ON);
SET_PERI_REG_MASK(RTC_CNTL_ANA_CONF_REG, RTC_CNTL_SAR_I2C_PU_M);
// Bridging sar2 internal reference voltage
REGI2C_WRITE_MASK(I2C_SAR_ADC, ADC_SARADC2_ENCAL_REF_ADDR, 1);
REGI2C_WRITE_MASK(I2C_SAR_ADC, ADC_SARADC_DTEST_RTC_ADDR, 0);
REGI2C_WRITE_MASK(I2C_SAR_ADC, ADC_SARADC_ENT_RTC_ADDR, 0);
REGI2C_WRITE_MASK(I2C_SAR_ADC, ADC_SARADC_ENT_TSENS_ADDR, 0);
#ifndef BOOTLOADER_BUILD
regi2c_saradc_enable();
#else
regi2c_ctrl_ll_i2c_sar_periph_enable();
#endif
ANALOG_CLOCK_ENABLE();
adc_ll_regi2c_init();
// Enable SAR ADC2 internal channel to read adc2 ref voltage for additional entropy
SET_PERI_REG_MASK(SYSTEM_PERIP_CLK_EN0_REG, SYSTEM_APB_SARADC_CLK_EN_M);
CLEAR_PERI_REG_MASK(SYSTEM_PERIP_RST_EN0_REG, SYSTEM_APB_SARADC_RST_M);
REG_SET_FIELD(APB_SARADC_APB_ADC_CLKM_CONF_REG, APB_SARADC_REG_CLK_SEL, 0x2);
SET_PERI_REG_MASK(APB_SARADC_APB_ADC_CLKM_CONF_REG, APB_SARADC_CLK_EN_M);
SET_PERI_REG_MASK(APB_SARADC_CTRL_REG, APB_SARADC_SAR_CLK_GATED_M);
REG_SET_FIELD(APB_SARADC_CTRL_REG, APB_SARADC_XPD_SAR_FORCE, 0x3);
REG_SET_FIELD(APB_SARADC_CTRL_REG, APB_SARADC_SAR_CLK_DIV, 1);
_adc_ll_enable_bus_clock(true);
_adc_ll_reset_register();
adc_ll_digi_clk_sel(ADC_DIGI_CLK_SRC_PLL_F80M);
adc_ll_digi_controller_clk_div(ADC_RNG_CLKM_DIV_NUM, ADC_RNG_CLKM_DIV_B, ADC_RNG_CLKM_DIV_A);
adc_ll_digi_set_power_manage(ADC_LL_POWER_SW_ON);
adc_ll_digi_set_clk_div(1);
REG_SET_FIELD(APB_SARADC_FSM_WAIT_REG, APB_SARADC_RSTB_WAIT, 8);
REG_SET_FIELD(APB_SARADC_FSM_WAIT_REG, APB_SARADC_XPD_WAIT, 5);
REG_SET_FIELD(APB_SARADC_FSM_WAIT_REG, APB_SARADC_STANDBY_WAIT, 100);
adc_ll_digi_set_fsm_time(ADC_LL_FSM_RSTB_WAIT_DEFAULT, ADC_LL_FSM_START_WAIT_DEFAULT,
ADC_LL_FSM_STANDBY_WAIT_DEFAULT);
SET_PERI_REG_MASK(APB_SARADC_CTRL_REG, APB_SARADC_SAR_PATT_P_CLEAR_M);
CLEAR_PERI_REG_MASK(APB_SARADC_CTRL_REG, APB_SARADC_SAR_PATT_P_CLEAR_M);
REG_SET_FIELD(APB_SARADC_CTRL_REG, APB_SARADC_SAR_PATT_LEN, 0);
REG_SET_FIELD(APB_SARADC_SAR_PATT_TAB1_REG, APB_SARADC_SAR_PATT_TAB1, 0x9cffff);// Set adc2 internal channel & atten
REG_SET_FIELD(APB_SARADC_SAR_PATT_TAB2_REG, APB_SARADC_SAR_PATT_TAB2, 0xffffff);
// Set ADC sampling frequency
REG_SET_FIELD(APB_SARADC_CTRL2_REG, APB_SARADC_TIMER_TARGET, 100);
REG_SET_FIELD(APB_SARADC_APB_ADC_CLKM_CONF_REG, APB_SARADC_REG_CLKM_DIV_NUM, 15);
CLEAR_PERI_REG_MASK(APB_SARADC_CTRL2_REG, APB_SARADC_MEAS_NUM_LIMIT);
SET_PERI_REG_MASK(APB_SARADC_DMA_CONF_REG, APB_SARADC_APB_ADC_TRANS_M);
SET_PERI_REG_MASK(APB_SARADC_CTRL2_REG, APB_SARADC_TIMER_EN);
adc_digi_pattern_config_t pattern_config = {};
pattern_config.unit = ADC_UNIT_2;
pattern_config.atten = ADC_ATTEN_DB_12;
pattern_config.channel = ADC_CHANNEL_1; //Use reserved channel 1 to get internal voltage
adc_ll_digi_set_pattern_table(ADC_UNIT_2, 0, pattern_config);
adc_ll_digi_set_pattern_table_len(ADC_UNIT_2, 1);
adc_ll_digi_set_trigger_interval(100);
adc_ll_digi_convert_limit_enable(false);
adc_ll_digi_dma_enable();
adc_ll_digi_trigger_enable();
}
void bootloader_random_disable(void)
{
/* Restore internal I2C bus state */
REGI2C_WRITE_MASK(I2C_SAR_ADC, ADC_SARADC2_ENCAL_REF_ADDR, 0);
/* Restore SARADC to default mode */
CLEAR_PERI_REG_MASK(APB_SARADC_CTRL2_REG, APB_SARADC_TIMER_EN);
CLEAR_PERI_REG_MASK(APB_SARADC_DMA_CONF_REG, APB_SARADC_APB_ADC_TRANS_M);
REG_SET_FIELD(APB_SARADC_SAR_PATT_TAB1_REG, APB_SARADC_SAR_PATT_TAB1, 0xffffff);
REG_SET_FIELD(APB_SARADC_SAR_PATT_TAB2_REG, APB_SARADC_SAR_PATT_TAB2, 0xffffff);
CLEAR_PERI_REG_MASK(APB_SARADC_APB_ADC_CLKM_CONF_REG, APB_SARADC_CLK_EN_M);
REG_SET_FIELD(APB_SARADC_CTRL_REG, APB_SARADC_XPD_SAR_FORCE, 0);
REG_SET_FIELD(RTC_CNTL_SENSOR_CTRL_REG, RTC_CNTL_FORCE_XPD_SAR, 0);
_adc_ll_enable_bus_clock(false);
adc_ll_digi_trigger_disable();
adc_ll_digi_reset_pattern_table();
adc_ll_regi2c_adc_deinit();
#ifndef BOOTLOADER_BUILD
regi2c_saradc_disable();
#endif
// disable analog i2c master clock
ANALOG_CLOCK_DISABLE();
}

View File

@@ -8,11 +8,16 @@
#include "hal/regi2c_ctrl_ll.h"
#include "hal/adc_ll.h"
#include "hal/adc_types.h"
#include "hal/config.h"
#include "esp_private/periph_ctrl.h"
#include "esp_private/adc_share_hw_ctrl.h"
#include "esp_private/sar_periph_ctrl.h"
#if HAL_CONFIG(CHIP_SUPPORT_MIN_REV) >= 300
#include "hal/trng_ll.h"
#endif
#define I2C_SAR_ADC_INIT_CODE_VAL 2166
#define ADC_RNG_CLKM_DIV_NUM 0
#define ADC_RNG_CLKM_DIV_B 0
@@ -60,6 +65,9 @@ void bootloader_random_enable(void)
adc_ll_digi_set_clk_div(15);
adc_ll_digi_set_trigger_interval(100);
adc_ll_digi_trigger_enable();
#if HAL_CONFIG(CHIP_SUPPORT_MIN_REV) >= 300
trng_ll_enable();
#endif
}
void bootloader_random_disable(void)
@@ -80,4 +88,8 @@ void bootloader_random_disable(void)
adc_ll_digi_clk_sel(ADC_DIGI_CLK_SRC_XTAL);
adc_ll_set_controller(ADC_UNIT_1, ADC_LL_CTRL_ULP);
#if HAL_CONFIG(CHIP_SUPPORT_MIN_REV) >= 300
trng_ll_disable();
#endif
}

View File

@@ -9,7 +9,6 @@
#include "soc/sens_reg.h"
#include "soc/dport_reg.h"
#include "soc/syscon_reg.h"
#include "soc/i2s_periph.h"
#include "esp_log.h"
#include "soc/io_mux_reg.h"
#include "soc/apb_saradc_reg.h"

View File

@@ -717,25 +717,7 @@ static void load_image(const esp_image_metadata_t *image_data)
*/
ESP_LOGI(TAG, "Checking flash encryption...");
bool flash_encryption_enabled = esp_flash_encrypt_state();
if (flash_encryption_enabled) {
#if BOOTLOADER_BUILD
/* Ensure security eFuses are burnt */
esp_efuse_batch_write_begin();
esp_err_t err = esp_flash_encryption_enable_secure_features();
if (err != ESP_OK) {
ESP_LOGE(TAG, "Error setting security eFuses (err=0x%x).", err);
esp_efuse_batch_write_cancel();
return;
}
err = esp_efuse_batch_write_commit();
if (err != ESP_OK) {
ESP_LOGE(TAG, "Error programming security eFuses (err=0x%x).", err);
return;
}
ESP_LOGI(TAG, "Security eFuses are burnt");
#endif // BOOTLOADER_BUILD
} else {
if (!flash_encryption_enabled) {
#ifdef CONFIG_SECURE_FLASH_REQUIRE_ALREADY_ENABLED
ESP_LOGE(TAG, "flash encryption is not enabled, and SECURE_FLASH_REQUIRE_ALREADY_ENABLED is set, refusing to boot.");
return;

View File

@@ -11,10 +11,13 @@
#include "esp_efuse.h"
#include "esp_efuse_table.h"
#include "esp_log.h"
#include "hal/key_mgr_ll.h"
#include "esp_crypto_periph_clk.h"
#include "esp_key_mgr.h"
#include "hal/key_mgr_hal.h"
#include "hal/mspi_ll.h"
#include "soc/soc_caps.h"
#include "sdkconfig.h"
#include "hal/key_mgr_ll.h"
ESP_LOG_ATTR_TAG(TAG, "flash_encrypt");
@@ -69,18 +72,12 @@ esp_err_t esp_flash_encryption_enable_secure_features(void)
return ESP_OK;
}
esp_err_t esp_flash_encryption_enable_key_mgr(void)
esp_err_t esp_flash_encryption_use_efuse_key(void)
{
_key_mgr_ll_enable_bus_clock(true);
_key_mgr_ll_enable_peripheral_clock(true);
_key_mgr_ll_reset_register();
while (key_mgr_ll_get_state() != ESP_KEY_MGR_STATE_IDLE) {
};
esp_crypto_key_mgr_enable_periph_clk(true);
// Force Key Manager to use eFuse key for XTS-AES operation
key_mgr_ll_set_key_usage(ESP_KEY_MGR_XTS_AES_128_KEY, ESP_KEY_MGR_USE_EFUSE_KEY);
_mspi_timing_ll_reset_mspi();
key_mgr_hal_set_key_usage(ESP_KEY_MGR_FLASH_XTS_AES_KEY, ESP_KEY_MGR_USE_EFUSE_KEY);
return ESP_OK;
}

View File

@@ -108,7 +108,6 @@ static inline void bootloader_config_dcache(void)
static inline void bootloader_config_icache1(void)
{
// TODO: [ESP32H4] IDF-12289
#if CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE
REG_CLR_BIT(LP_AON_SRAM_USAGE_CONF_REG, LP_AON_ICACHE1_USAGE);
#else

View File

@@ -11,6 +11,9 @@
#include "esp_efuse_table.h"
#include "esp_log.h"
#include "sdkconfig.h"
#include "esp_crypto_periph_clk.h"
#include "esp_key_mgr.h"
#include "hal/key_mgr_hal.h"
#include "hal/key_mgr_ll.h"
#include "hal/mspi_ll.h"
@@ -51,18 +54,12 @@ esp_err_t esp_flash_encryption_enable_secure_features(void)
return ESP_OK;
}
esp_err_t esp_flash_encryption_enable_key_mgr(void)
esp_err_t esp_flash_encryption_use_efuse_key(void)
{
_key_mgr_ll_enable_bus_clock(true);
_key_mgr_ll_enable_peripheral_clock(true);
_key_mgr_ll_reset_register();
while (key_mgr_ll_get_state() != ESP_KEY_MGR_STATE_IDLE) {
};
esp_crypto_key_mgr_enable_periph_clk(true);
// Force Key Manager to use eFuse key for XTS-AES operation
key_mgr_ll_set_key_usage(ESP_KEY_MGR_XTS_AES_128_KEY, ESP_KEY_MGR_USE_EFUSE_KEY);
_mspi_timing_ll_reset_mspi();
key_mgr_hal_set_key_usage(ESP_KEY_MGR_FLASH_XTS_AES_KEY, ESP_KEY_MGR_USE_EFUSE_KEY);
return ESP_OK;
}

View File

@@ -24,6 +24,7 @@
#include "hal/cache_ll.h"
#include "spi_flash_mmap.h"
#include "hal/efuse_hal.h"
#include "sdkconfig.h"
#define ALIGN_UP(num, align) (((num) + ((align) - 1)) & ~((align) - 1))
@@ -141,6 +142,22 @@ static bool is_bootloader(uint32_t offset)
);
}
#if BOOTLOADER_BUILD && (SECURE_BOOT_CHECK_SIGNATURE == 1)
#if CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP
static bool skip_verify(esp_image_load_mode_t mode, bool verify_sha)
{
// Multi level check to ensure that its a legit exit from deep sleep case
return (esp_rom_get_reset_reason(0) == RESET_REASON_CORE_DEEP_SLEEP &&
mode == ESP_IMAGE_LOAD_NO_VALIDATE &&
!verify_sha) ? true : false;
}
#else
#define skip_verify(mode, verify_sha) (false)
#endif
#endif // BOOTLOADER_BUILD && (SECURE_BOOT_CHECK_SIGNATURE == 1)
static esp_err_t image_load(esp_image_load_mode_t mode, const esp_partition_pos_t *part, esp_image_metadata_t *data)
{
#ifdef BOOTLOADER_BUILD
@@ -236,9 +253,9 @@ static esp_err_t image_load(esp_image_load_mode_t mode, const esp_partition_pos_
"only verify signature in bootloader" into the macro so it's tested multiple times.
*/
#if CONFIG_SECURE_BOOT_V2_ENABLED
ESP_FAULT_ASSERT(!esp_secure_boot_enabled() || memcmp(image_digest, verified_digest, ESP_SECURE_BOOT_DIGEST_LEN) == 0);
ESP_FAULT_ASSERT(!esp_secure_boot_enabled() || skip_verify(mode, verify_sha) || memcmp(image_digest, verified_digest, ESP_SECURE_BOOT_DIGEST_LEN) == 0);
#else // Secure Boot V1 on ESP32, only verify signatures for apps not bootloaders
ESP_FAULT_ASSERT(is_bootloader(data->start_addr) || memcmp(image_digest, verified_digest, HASH_LEN) == 0);
ESP_FAULT_ASSERT(is_bootloader(data->start_addr) || skip_verify(mode, verify_sha) || memcmp(image_digest, verified_digest, HASH_LEN) == 0);
#endif
#endif // SECURE_BOOT_CHECK_SIGNATURE

View File

@@ -16,6 +16,10 @@
#include "hal/spi_flash_encrypt_hal.h"
#include "soc/soc_caps.h"
#if SOC_KEY_MANAGER_SUPPORTED
#include "esp_key_mgr.h"
#endif /* SOC_KEY_MANAGER_SUPPORTED */
#if CONFIG_IDF_TARGET_ESP32
#define CRYPT_CNT ESP_EFUSE_FLASH_CRYPT_CNT
#define WR_DIS_CRYPT_CNT ESP_EFUSE_WR_DIS_FLASH_CRYPT_CNT
@@ -444,12 +448,13 @@ bool esp_flash_encryption_cfg_verify_release_mode(void)
}
#endif
#if CONFIG_SECURE_FLASH_ENCRYPTION_KEY_SOURCE_EFUSES
esp_efuse_purpose_t purposes[] = {
#if SOC_FLASH_ENCRYPTION_XTS_AES_256
#if SOC_EFUSE_XTS_AES_KEY_256
ESP_EFUSE_KEY_PURPOSE_XTS_AES_256_KEY_1,
ESP_EFUSE_KEY_PURPOSE_XTS_AES_256_KEY_2,
#endif
#if SOC_FLASH_ENCRYPTION_XTS_AES_128
#if SOC_EFUSE_XTS_AES_KEY_128
ESP_EFUSE_KEY_PURPOSE_XTS_AES_128_KEY,
#endif
};
@@ -482,6 +487,23 @@ bool esp_flash_encryption_cfg_verify_release_mode(void)
}
}
result &= secure;
#elif CONFIG_SECURE_FLASH_ENCRYPTION_KEY_SOURCE_KEY_MGR
#if CONFIG_SECURE_FLASH_ENCRYPTION_AES128
secure = esp_efuse_read_field_bit(ESP_EFUSE_KM_XTS_KEY_LENGTH_256);
result &= secure;
if (!secure) {
ESP_LOGW(TAG, "Not enabled Key Manager XTS-AES-128 key (set KM_XTS_KEY_LENGTH_256->1)");
}
#endif
const uint32_t force_key_mgr_key = esp_efuse_read_field_bit(ESP_EFUSE_FORCE_USE_KEY_MANAGER_KEY);
secure = (force_key_mgr_key & (1 << ESP_KEY_MGR_FORCE_USE_KM_XTS_AES_KEY));
result &= secure;
if (!secure) {
ESP_LOGW(TAG, "Not forcing Key Manager to use XTS-AES key (set FORCE_USE_KEY_MANAGER_KEY->1)");
}
#endif
#if SOC_FLASH_ENCRYPTION_XTS_AES_SUPPORT_PSEUDO_ROUND
if (spi_flash_encrypt_ll_is_pseudo_rounds_function_supported()) {

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -16,6 +16,14 @@
#include "esp_log.h"
#include "hal/wdt_hal.h"
#include "sdkconfig.h"
#include "soc/soc_caps.h"
#if SOC_KEY_MANAGER_SUPPORTED
#include "esp_key_mgr.h"
#include "hal/key_mgr_ll.h"
#include "rom/key_mgr.h"
#include "esp_rom_crc.h"
#endif
#ifdef CONFIG_SOC_EFUSE_CONSISTS_OF_ONE_KEY_BLOCK
#include "soc/sensitive_reg.h"
@@ -124,8 +132,158 @@ esp_err_t esp_flash_encrypt_check_and_update(void)
return ESP_OK;
}
#if CONFIG_SECURE_FLASH_ENCRYPTION_KEY_SOURCE_KEY_MGR
static esp_err_t key_manager_read_key_recovery_info(esp_key_mgr_key_recovery_info_t *key_recovery_info)
{
esp_err_t err = ESP_FAIL;
uint32_t crc = 0;
for (int i = 0; i < 2; i++) {
err = bootloader_flash_read(KEY_HUK_SECTOR_OFFSET(i), (uint32_t *)key_recovery_info, sizeof(esp_key_mgr_key_recovery_info_t), false);
if (err != ESP_OK) {
ESP_LOGD(TAG, "Failed to read key recovery info from Key Manager sector %d: %x", i, err);
continue;
}
// check Key Recovery Info magic
if (key_recovery_info->magic != KEY_HUK_SECTOR_MAGIC) {
ESP_LOGD(TAG, "Key Manager sector %d Magic %08x failed", i, key_recovery_info->magic);
continue;
}
if (key_recovery_info->key_type != ESP_KEY_MGR_FLASH_XTS_AES_KEY) {
ESP_LOGD(TAG, "Key Manager sector %d has incorrect key type %d", i, key_recovery_info->key_type);
continue;
}
#if CONFIG_SECURE_FLASH_ENCRYPTION_AES256
if (key_recovery_info->key_len != ESP_KEY_MGR_XTS_AES_LEN_256) {
ESP_LOGD(TAG, "Key Manager sector %d has incorrect key length %d", i, key_recovery_info->key_len);
continue;
}
#else
if (key_recovery_info->key_len != ESP_KEY_MGR_XTS_AES_LEN_128) {
ESP_LOGD(TAG, "Key Manager sector %d has incorrect key length %d", i, key_recovery_info->key_len);
continue;
}
#endif
// check HUK Info CRC
crc = esp_rom_crc32_le(0, key_recovery_info->huk_info.info, HUK_INFO_LEN);
if (crc != key_recovery_info->huk_info.crc) {
ESP_LOGD(TAG, "Key Manager sector %d HUK Info CRC error", i);
continue;
}
// check Key Info 0 CRC
crc = esp_rom_crc32_le(0, key_recovery_info->key_info[0].info, KEY_INFO_LEN);
if (crc != key_recovery_info->key_info[0].crc) {
ESP_LOGD(TAG, "Key Manager sector %d Key Info 0 CRC error", i);
continue;
}
#if CONFIG_SECURE_FLASH_ENCRYPTION_AES256
// check Key Info 1 CRC
crc = esp_rom_crc32_le(0, key_recovery_info->key_info[1].info, KEY_INFO_LEN);
if (crc != key_recovery_info->key_info[1].crc) {
ESP_LOGD(TAG, "Key Manager sector %d Key Info 1 CRC error", i);
continue;
}
#endif
ESP_LOGI(TAG, "Valid Key Manager key recovery info found in sector %d", i);
return ESP_OK;
}
ESP_LOGD(TAG, "No valid key recovery info found");
return ESP_ERR_NOT_FOUND;
}
static esp_err_t key_manager_generate_key(esp_key_mgr_key_recovery_info_t *key_recovery_info)
{
ESP_LOGI(TAG, "Deploying new flash encryption key using Key Manager");
esp_key_mgr_random_key_config_t key_config;
memset(&key_config, 0, sizeof(esp_key_mgr_random_key_config_t));
key_config.key_type = ESP_KEY_MGR_FLASH_XTS_AES_KEY;
#if CONFIG_SECURE_FLASH_ENCRYPTION_AES256
key_config.key_len = ESP_KEY_MGR_XTS_AES_LEN_256;
#else
key_config.key_len = ESP_KEY_MGR_XTS_AES_LEN_128;
#endif
// Generate a new key and load it into Key Manager
esp_err_t err = esp_key_mgr_deploy_key_in_random_mode(&key_config, key_recovery_info);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Failed to generate key for Key Manager: %x", err);
return err;
}
ESP_LOGV(TAG, "Successfully deployed new flash encryption key using Key Manager");
// Write the key recovery info of the newly generated key into the flash
for (int i = 0; i < 2; i++) {
err = bootloader_flash_erase_sector(i);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Failed to erase sector %d: %x", i, err);
return err;
}
}
// Write the key recovery info of the newly generated key into the flash
err = bootloader_flash_write(KEY_HUK_SECTOR_OFFSET(0), (uint32_t *)key_recovery_info, sizeof(esp_key_mgr_key_recovery_info_t), false);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Failed to write key recovery info to flash: %x", err);
return err;
}
ESP_LOGV(TAG, "Successfully wrote the newly generated Flash Encryption key recovery info into the flash");
return ESP_OK;
}
static esp_err_t key_manager_check_and_generate_key(void)
{
/*
1. Check if we have a valid key info in the first two sectors of the flash
2. If we have a valid key info, check if it is valid
1. If the key is valid, use it
2. If the key is not valid, generate a new key and load it into key manager
3. If not, generate a new key and load it into key manager
*/
esp_key_mgr_key_recovery_info_t key_recovery_info;
memset(&key_recovery_info, 0, sizeof(esp_key_mgr_key_recovery_info_t));
esp_err_t err = key_manager_read_key_recovery_info(&key_recovery_info);
if (err == ESP_ERR_NOT_FOUND) {
// No valid key recovery info found, generate a new key
err = key_manager_generate_key(&key_recovery_info);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Failed to generate key for Key Manager: %x", err);
return err;
}
} else {
// Valid key recovery info found, use it
ESP_LOGI(TAG, "Using pre-deployed Key Manager key for flash encryption");
}
// Recover key using the key recovery info
err = esp_key_mgr_activate_key(&key_recovery_info);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Failed to activate Key Manager key: %x", err);
return err;
}
return ESP_OK;
}
#endif
static esp_err_t check_and_generate_encryption_keys(void)
{
#if CONFIG_SECURE_FLASH_ENCRYPTION_KEY_SOURCE_EFUSES
size_t key_size = 32;
#ifdef CONFIG_IDF_TARGET_ESP32
enum { BLOCKS_NEEDED = 1 };
@@ -214,12 +372,60 @@ static esp_err_t check_and_generate_encryption_keys(void)
ESP_LOGI(TAG, "Using pre-loaded flash encryption key in efuse");
}
#if SOC_KEY_MANAGER_FE_KEY_DEPLOY
// In the case of Key Manager supported targets, the default XTS-AES key source is set to Key Manager.
esp_flash_encryption_use_efuse_key();
#endif
#elif CONFIG_SECURE_FLASH_ENCRYPTION_KEY_SOURCE_KEY_MGR
esp_err_t err = key_manager_check_and_generate_key();
if (err != ESP_OK) {
ESP_LOGE(TAG, "Failed to check and generate key using Key Manager: %x", err);
return err;
}
#if CONFIG_SECURE_FLASH_ENCRYPTION_AES128
err = esp_efuse_write_field_bit(ESP_EFUSE_KM_XTS_KEY_LENGTH_256);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Failed to set the efuse bit KM_XTS_KEY_LENGTH_256: %x", err);
return err;
}
#endif
const uint32_t force_key_mgr_key_for_fe = 1 << ESP_KEY_MGR_FORCE_USE_KM_XTS_AES_KEY;
err = esp_efuse_write_field_blob(ESP_EFUSE_FORCE_USE_KEY_MANAGER_KEY, &force_key_mgr_key_for_fe, ESP_EFUSE_FORCE_USE_KEY_MANAGER_KEY[0]->bit_count);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Failed to set the efuse bit %d (XTS-AES key) of FORCE_USE_KEY_MANAGER_KEY: %x", ESP_KEY_MGR_FORCE_USE_KM_XTS_AES_KEY, err);
return err;
}
ESP_LOGV(TAG, "Successfully activated the flash encryption key using Key Manager");
#endif
return ESP_OK;
}
esp_err_t esp_flash_encrypt_init(void)
{
if (esp_flash_encryption_enabled() || esp_flash_encrypt_initialized_once()) {
if (esp_flash_encryption_enabled()) {
return ESP_OK;
}
#if CONFIG_SECURE_FLASH_ENCRYPTION_KEY_SOURCE_KEY_MGR
if (!(key_mgr_ll_is_supported() && key_mgr_ll_flash_encryption_supported())) {
ESP_LOGE(TAG, "Flash Encryption using Key Manager is not supported, please use efuses instead");
return ESP_ERR_NOT_SUPPORTED;
}
#endif
if (esp_flash_encrypt_initialized_once()) {
#if CONFIG_SECURE_FLASH_ENCRYPTION_KEY_SOURCE_KEY_MGR
// Allow generating a new key if the key recovery info is not present in the flash
esp_err_t err = key_manager_check_and_generate_key();
if (err != ESP_OK) {
ESP_LOGE(TAG, "Failed to recover key using Key Manager: %x", err);
return err;
}
#endif
return ESP_OK;
}
@@ -260,10 +466,6 @@ esp_err_t esp_flash_encrypt_contents(void)
REG_WRITE(SENSITIVE_XTS_AES_KEY_UPDATE_REG, 1);
#endif
#if CONFIG_SOC_KEY_MANAGER_FE_KEY_DEPLOY
esp_flash_encryption_enable_key_mgr();
#endif
err = encrypt_bootloader(); // PART_SUBTYPE_BOOTLOADER_PRIMARY
if (err != ESP_OK) {
return err;

View File

@@ -562,7 +562,6 @@ if(CONFIG_BT_ENABLED)
"esp_ble_mesh/core/storage/settings.c"
"esp_ble_mesh/core/access.c"
"esp_ble_mesh/core/adv_common.c"
"esp_ble_mesh/core/ble_adv.c"
"esp_ble_mesh/core/beacon.c"
"esp_ble_mesh/core/cfg_cli.c"
"esp_ble_mesh/core/cfg_srv.c"
@@ -619,6 +618,7 @@ if(CONFIG_BT_ENABLED)
"esp_ble_mesh/common/tinycrypt/src/sha256.c"
"esp_ble_mesh/common/tinycrypt/src/utils.c")
endif()
if(CONFIG_BLE_MESH_V11_SUPPORT)
list(APPEND include_dirs ${ble_mesh_v11_include_dirs})
@@ -655,24 +655,27 @@ if(CONFIG_BT_ENABLED)
"esp_ble_mesh/v1.1/dfu/dfu_slot.c"
"esp_ble_mesh/v1.1/dfu/dfu_metadata.c"
"esp_ble_mesh/lib/ext.c")
if(CONFIG_BLE_MESH_SAR_ENHANCEMENT)
list(APPEND srcs "esp_ble_mesh/core/transport.enh.c")
else()
list(APPEND srcs "esp_ble_mesh/core/transport.c")
endif()
else()
list(APPEND srcs
"esp_ble_mesh/core/transport.c")
list(APPEND srcs "esp_ble_mesh/core/transport.c")
endif()
if(CONFIG_BLE_MESH_SUPPORT_MULTI_ADV)
list(APPEND srcs "esp_ble_mesh/core/ext_adv.c")
else()
list(APPEND srcs "esp_ble_mesh/core/adv.c")
endif()
if(CONFIG_BLE_MESH_SUPPORT_BLE_ADV)
list(APPEND srcs "esp_ble_mesh/core/ble_adv.c")
endif()
endif()
if(CONFIG_BT_LE_CONTROLLER_NPL_OS_PORTING_SUPPORT)
list(APPEND srcs
"porting/npl/freertos/src/npl_os_freertos.c"
@@ -980,7 +983,7 @@ set(bt_priv_requires
)
if(CONFIG_BLE_COMPRESSED_LOG_ENABLE)
set(BT_ROOT_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
set(CODE_BASE_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
# When log compression is enabled, selected logs are replaced
# by auto-generated macros that emit pre-encoded data.
# This eliminates the original format strings, reducing firmware size and

View File

@@ -5,6 +5,14 @@ config BLE_LOG_ENABLED
Enable BLE Log Module
if BLE_LOG_ENABLED
config BLE_LOG_TASK_STACK_SIZE
int "Stack size for BLE Log Task"
default 1024 if IDF_TARGET_ARCH_RISCV
default 2048 if IDF_TARGET_ARCH_XTENSA
default 1024
help
Stack size for BLE Log Task
config BLE_LOG_LBM_TRANS_SIZE
int "Buffer size for each peripheral transport"
default 512

View File

@@ -41,7 +41,14 @@
#define SPI_OUT_LOG_STR_BUF_SIZE (100)
#define SPI_OUT_MALLOC(size) heap_caps_malloc(size, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT)
#define SPI_OUT_TASK_PRIORITY (ESP_TASK_PRIO_MAX - 1)
#if CONFIG_IDF_TARGET_ARCH_RISCV
#define SPI_OUT_TASK_STACK_SIZE (1024)
#elif CONFIG_IDF_TARGET_ARCH_XTENSA
#define SPI_OUT_TASK_STACK_SIZE (2048)
#else
static_assert(false, "BLE Log SPI Out: Unsupported target architecture");
#endif /* CONFIG_IDF_TARGET_ARCH_RISCV */
#if SPI_OUT_TS_SYNC_ENABLED
#define SPI_OUT_TS_SYNC_TIMEOUT_MS (1000)
@@ -247,9 +254,9 @@ extern uint32_t r_ble_lll_timer_current_tick_get(void);
#elif defined(CONFIG_IDF_TARGET_ESP32C2)
extern uint32_t r_os_cputime_get32(void);
#define SPI_OUT_GET_LC_TIME r_os_cputime_get32()
// #elif defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S3)
// extern uint32_t lld_read_clock_us(void);
// #define SPI_OUT_GET_LC_TIME lld_read_clock_us()
#elif defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S3)
extern uint32_t lld_read_clock_us(void);
#define SPI_OUT_GET_LC_TIME lld_read_clock_us()
#else
#define SPI_OUT_GET_LC_TIME esp_timer_get_time()
#endif
@@ -1365,12 +1372,13 @@ int ble_log_spi_out_hci_write(uint8_t source, const uint8_t *addr, uint16_t len)
return -1;
}
if (source == BLE_LOG_SPI_OUT_SOURCE_HCI_UPSTREAM) {
#if SPI_OUT_LL_ENABLED
if (source == BLE_LOG_SPI_OUT_SOURCE_HCI_UPSTREAM) {
ble_log_spi_out_ll_write(len, addr, 0, NULL, BIT(LL_LOG_FLAG_HCI_UPSTREAM));
#endif // SPI_OUT_LL_ENABLED
}
if (source == BLE_LOG_SPI_OUT_SOURCE_HCI_DOWNSTREAM) {
if (source == BLE_LOG_SPI_OUT_SOURCE_HCI_DOWNSTREAM)
#endif /* SPI_OUT_LL_ENABLED */
{
spi_out_log_cb_t *log_cb;
bool fallback = false;
if (!spi_out_get_task_mapping(LOG_MODULE_TASK_MAP(hci),

View File

@@ -1,6 +1,6 @@
set(LOG_COMPRESSED_MODULE "")
set(LOG_COMPRESSED_MODULE_CODE_PATH "")
set(BT_ROOT_PATH $ENV{IDF_PATH}/components/bt)
set(LOG_COMPRESSED_SRCS_DIR "${CMAKE_BINARY_DIR}/ble_log/.compressed_srcs")
# default config value for ble mesh module
@@ -17,32 +17,62 @@ set(BLE_HOST_TAGS_PRESERVE "")
if(CONFIG_BLE_MESH_COMPRESSED_LOG_ENABLE)
list(APPEND LOG_COMPRESSED_MODULE "BLE_MESH")
if(NOT EXISTS "${CMAKE_BINARY_DIR}/ble_log/include/mesh_log_index.h")
file(WRITE "${CMAKE_BINARY_DIR}/ble_log/include/mesh_log_index.h" "")
endif()
list(APPEND LOG_COMPRESSED_MODULE_CODE_PATH "esp_ble_mesh")
# update config file
set(BLE_MESH_CODE_PATH "esp_ble_mesh")
set(BLE_MESH_LOG_INDEX_HEADER "mesh_log_index.h")
set(BLE_MESH_LOG_SCRIPT_PATH
"${CMAKE_CURRENT_LIST_DIR}/scripts/module_scripts/ble_mesh/make_mesh_log_macro.py")
# update BLE_MESH_TAGS and BLE_MESH_TAGS_PRESERVE
include(${CMAKE_CURRENT_LIST_DIR}/cmake/ble_mesh_log_tags.cmake)
if(NOT EXISTS "${CMAKE_BINARY_DIR}/ble_log/include/${BLE_MESH_LOG_INDEX_HEADER}")
file(WRITE "${CMAKE_BINARY_DIR}/ble_log/include/${BLE_MESH_LOG_INDEX_HEADER}" "")
endif()
list(APPEND LOG_COMPRESSED_MODULE_CODE_PATH ${BLE_MESH_CODE_PATH})
endif()
if(CONFIG_BLE_HOST_COMPRESSED_LOG_ENABLE AND CONFIG_BT_BLUEDROID_ENABLED)
list(APPEND LOG_COMPRESSED_MODULE "BLE_HOST")
list(APPEND LOG_COMPRESSED_MODULE_CODE_PATH "host/bluedroid/stack")
if(NOT EXISTS "${CMAKE_BINARY_DIR}/ble_log/include/host_log_index.h")
file(WRITE "${CMAKE_BINARY_DIR}/ble_log/include/host_log_index.h" "")
endif()
# update config file
set(HOST_CODE_PATH "host/bluedroid/stack")
set(HOST_LOG_INDEX_HEADER "host_log_index.h")
set(BLE_HOST_LOG_SCRIPT_PATH
"${CMAKE_CURRENT_LIST_DIR}/scripts/module_scripts/bluedroid/make_bluedroid_log_macro.py")
include(${CMAKE_CURRENT_LIST_DIR}/cmake/ble_host_bluedroid_tags.cmake)
if(NOT EXISTS "${CMAKE_BINARY_DIR}/ble_log/include/${HOST_LOG_INDEX_HEADER}")
file(WRITE "${CMAKE_BINARY_DIR}/ble_log/include/${HOST_LOG_INDEX_HEADER}" "")
endif()
list(APPEND LOG_COMPRESSED_MODULE_CODE_PATH ${HOST_CODE_PATH})
endif()
if(BLE_COMPRESSED_LIB_LOG_BUILD)
if(NOT (BLE_COMPRESSED_LIB_NAME AND BLE_COMPRESSED_LIB_CODE_DIR AND BLE_COMPRESSED_LIB_LOG_TAGS))
message(FATAL_ERROR "Invalid settings")
else()
message("Building compressed log for ${BLE_COMPRESSED_LIB_NAME}")
endif()
list(APPEND LOG_COMPRESSED_MODULE ${BLE_COMPRESSED_LIB_NAME})
if(NOT EXISTS "${CMAKE_BINARY_DIR}/ble_log/include/${BLE_COMPRESSED_LIB_LOG_INDEX_HEADER}")
file(WRITE "${CMAKE_BINARY_DIR}/ble_log/include/${BLE_COMPRESSED_LIB_LOG_INDEX_HEADER}" "")
endif()
list(APPEND LOG_COMPRESSED_MODULE_CODE_PATH ${BLE_COMPRESSED_LIB_CODE_DIR})
string(REPLACE ";" "," BLE_COMPRESSED_LIB_CODE_DIR "${BLE_COMPRESSED_LIB_CODE_DIR}")
string(REPLACE ";" "," BLE_COMPRESSED_LIB_LOG_TAGS "${BLE_COMPRESSED_LIB_LOG_TAGS}")
string(REPLACE ";" "," BLE_COMPRESSED_LIB_LOG_TAGS_PRESERVE "${BLE_COMPRESSED_LIB_LOG_TAGS_PRESERVE}")
else()
set(BLE_COMPRESSED_LIB_NAME "placeholder")
endif()
if(LOG_COMPRESSED_MODULE)
list(APPEND srcs "common/ble_log/extension/log_compression/ble_log_compression.c")
list(APPEND include_dirs "${CMAKE_BINARY_DIR}/ble_log/include")
# When building the library, ble_log_compression.c and its dependencies are not needed
if(NOT BLE_COMPRESSED_LIB_LOG_BUILD)
list(APPEND srcs "common/ble_log/extension/log_compression/ble_log_compression.c")
list(APPEND include_dirs "${CMAKE_BINARY_DIR}/ble_log/include")
endif()
if(NOT CMAKE_VERSION VERSION_LESS 3.15.0)
set(Python3_FIND_STRATEGY LOCATION)
find_package(Python3 COMPONENTS Interpreter)
@@ -111,19 +141,39 @@ if(LOG_COMPRESSED_MODULE)
"host/nimble/nimble/nimble/host/store/config/src")
endif()
add_custom_target(ble_log_compression ALL
COMMAND ${BLE_PYTHON_EXECUTABLE} ${PYTHON_SCRIPT}
compress
--compressed_srcs_path "${LOG_COMPRESSED_SRCS_DIR}"
--build_path "${CMAKE_BINARY_DIR}"
--module "'${LOG_COMPRESSED_MODULE}'"
--bt_path "${BT_ROOT_PATH}"
--srcs "'${compressed_srcs}'"
DEPENDS ${compressed_srcs_with_abs_path} ${PYTHON_SCRIPT}
COMMENT "Log compression is being performed, please wait..."
WORKING_DIRECTORY ${BT_ROOT_PATH}
USES_TERMINAL
)
if(BLE_COMPRESSED_LIB_LOG_BUILD)
execute_process(COMMAND ${BLE_PYTHON_EXECUTABLE} ${PYTHON_SCRIPT}
compress
--compressed_srcs_path "${LOG_COMPRESSED_SRCS_DIR}"
--build_path "${CMAKE_BINARY_DIR}"
--module "${LOG_COMPRESSED_MODULE}"
--code_base_path "${CODE_BASE_PATH}"
--srcs "${compressed_srcs}"
RESULT_VARIABLE result
OUTPUT_VARIABLE out
ERROR_VARIABLE err)
if(NOT ${result} EQUAL 0)
message(WARNING "${err}")
message(WARNING "Exit this log compression due to failure of compression")
set(LOG_COMPRESS_INCLUDE_DIRS ${include_dirs} PARENT_SCOPE)
set(LOG_COMPRESSION_TARGET "" PARENT_SCOPE)
return()
endif()
else()
add_custom_target(ble_log_compression ALL
COMMAND ${BLE_PYTHON_EXECUTABLE} ${PYTHON_SCRIPT}
compress
--compressed_srcs_path "${LOG_COMPRESSED_SRCS_DIR}"
--build_path "${CMAKE_BINARY_DIR}"
--module "'${LOG_COMPRESSED_MODULE}'"
--code_base_path "${CODE_BASE_PATH}"
--srcs "'${compressed_srcs}'"
DEPENDS ${compressed_srcs_with_abs_path} ${PYTHON_SCRIPT}
COMMENT "Log compression is being performed, please wait..."
WORKING_DIRECTORY ${BT_ROOT_PATH}
USES_TERMINAL
)
endif()
function(add_flags_if_in_list file file_list compile_flags)
set(PROCESSED OFF PARENT_SCOPE)
@@ -190,7 +240,10 @@ if(LOG_COMPRESSED_MODULE)
set(LOG_COMPRESSION_TARGET ble_log_compression PARENT_SCOPE)
# set(LOG_COMPRESSION_TARGET "" PARENT_SCOPE)
set(LOG_COMPRESS_SRCS "${compressed_srcs_with_abs_path};${uncompressed_srcs}" PARENT_SCOPE)
list(APPEND include_dirs "common/ble_log/extension/log_compression/include")
if(NOT BLE_COMPRESSED_LIB_LOG_BUILD)
list(APPEND include_dirs "common/ble_log/extension/log_compression/include")
endif()
list(APPEND include_dirs "${CMAKE_BINARY_DIR}/ble_log/include")
set(LOG_COMPRESS_INCLUDE_DIRS ${include_dirs} PARENT_SCOPE)
else()
set(LOG_COMPRESSION_TARGET "" PARENT_SCOPE)

View File

@@ -19,6 +19,7 @@ This script processes Bluetooth source files to compress logging statements.
import argparse
import enum
import importlib.util
import logging
import os
import re
@@ -33,6 +34,7 @@ from typing import Dict
from typing import List
from typing import Tuple
from typing import Union
from typing import cast
import tree_sitter_c as tsc
import yaml
@@ -72,10 +74,16 @@ CLANG_PARSER: Union[Parser, None] = None
SOURCE_ENUM_MAP = {
'BLE_HOST': 0,
'BLE_MESH': 1,
'BLE_MESH_LIB': 2,
}
# Functions that require hex formatting
HEX_FUNCTIONS = ['bt_hex'] # Used in Mesh and Audio modules
HEX_FUNCTIONS = {
# func_name: (arg_cnt, buf_idx, buf_len)
# Negative buf_len indicates constant buffer size
'bt_hex': (2, 0, 1), # Used in Mesh and Audio modules
'MAC2STR': (1, 0, -6), # Used in Bluedroid Host
}
# C keywords to exclude from function names
C_KEYWORDS = {
@@ -119,15 +127,6 @@ LINE_MACROS = {
'__LINE__',
}
BLUEDROID_LOG_MODE_LEVEL_GET = {
'BTM': 'btm_cb.trace_level',
'L2CAP': 'l2cb.l2cap_trace_level',
'GAP': 'gap_cb.trace_level',
'GATT': 'gatt_cb.trace_level',
'SMP': 'smp_cb.trace_level',
'APPL': 'appl_trace_level',
}
class ARG_SIZE_TYPE(enum.IntEnum):
U32 = 0
@@ -174,11 +173,12 @@ class LogCompressor:
"""Main class for BLE log compression."""
def __init__(self) -> None:
self.bt_component_path = Path()
self.code_base_path = Path()
self.build_dir = Path()
self.bt_compressed_srcs_path = Path()
self.config: dict[str, Any] = {}
self.module_info: dict[str, Any] = {}
self.module_mod: dict[str, Any] = {}
def init_parser(self) -> Parser:
"""Initialize tree-sitter parser for C."""
@@ -371,15 +371,20 @@ class LogCompressor:
if (
arg_node.type == 'call_expression'
and arg_node.child_by_field_name('function')
and arg_node.child_by_field_name('function').text.decode('utf-8') in HEX_FUNCTIONS
and arg_node.child_by_field_name('function').text.decode('utf-8') in HEX_FUNCTIONS.keys()
):
# Extract arguments of the hex function
hex_func_name = arg_node.child_by_field_name('function').text.decode('utf-8')
hex_args = arg_node.child_by_field_name('arguments')
if hex_args and hex_args.named_child_count >= 2:
buf_node = hex_args.named_children[0]
len_node = hex_args.named_children[1]
hex_func_info = HEX_FUNCTIONS[hex_func_name]
if hex_args and hex_args.named_child_count == hex_func_info[0]:
buf_node = hex_args.named_children[hex_func_info[1]].text.decode('utf-8')
if hex_func_info[2] < 0:
len_node = abs(hex_func_info[2])
else:
len_node = hex_args.named_children[hex_func_info[2]].text.decode('utf-8')
token_list = list(token)
token_list[6] = f'@hex_func@{buf_node.text.decode("utf-8")}@{len_node.text.decode("utf-8")}'
token_list[6] = f'@hex_func@{buf_node}@{len_node}'
tokens[tokens_tuple_map[i]] = tuple(token_list)
log_info['argu_tokens'] = tokens
@@ -419,7 +424,7 @@ class LogCompressor:
if (
node.type == 'call_expression'
and node.child_by_field_name('function')
and node.child_by_field_name('function').text.decode('utf-8') in HEX_FUNCTIONS
and node.child_by_field_name('function').text.decode('utf-8') in HEX_FUNCTIONS.keys()
):
return True
@@ -462,53 +467,6 @@ class LogCompressor:
if not log_idx:
return ''
def generate_mesh_log_prefix(source: str, tag: str, print_statm: str) -> str:
level = tag.split('_')[-1]
mod = tag.split('_')[0]
if level == 'ERR':
level = 'ERROR'
log_level = 'BLE_MESH_LOG_LEVEL_ERROR'
elif level == 'WARN':
level = 'WARN'
log_level = 'BLE_MESH_LOG_LEVEL_WARN'
elif level == 'INFO':
level = 'INFO'
log_level = 'BLE_MESH_LOG_LEVEL_INFO'
elif level == 'DBG':
level = 'DEBUG'
log_level = 'BLE_MESH_LOG_LEVEL_DEBUG'
else:
LOGGER.error(f'Invalid log level {level}')
return ''
if mod == 'NET':
used_log_levl = 'BLE_MESH_NET_BUF_LOG_LEVEL'
used_log_mod = 'BLE_MESH_NET_BUF'
else:
used_log_levl = 'BLE_MESH_LOG_LEVEL'
used_log_mod = 'BLE_MESH'
return (
f'{{do {{ if (({used_log_levl} >= {log_level}) &&'
f' BLE_MESH_LOG_LEVEL_CHECK({used_log_mod}, {level})) {print_statm};}} while (0);}}\\\n'
)
def generate_bluedroid_log_prefix(source: str, tag: str, print_statm: str) -> str:
tag_info = tag.split('_')
mod = tag_info[0]
return (
f'{{if ({BLUEDROID_LOG_MODE_LEVEL_GET[mod]} >= BT_TRACE_LEVEL_{tag_info[-1]} &&'
f' BT_LOG_LEVEL_CHECK({mod}, {tag_info[-1]})) {print_statm};}}\\\n'
)
def generate_log_lvl_prefix(source: str, tag: str, print_statm: str) -> str:
if source == 'BLE_MESH':
return ' ' + generate_mesh_log_prefix(source, tag, print_statm)
elif source == 'BLE_HOST': # only bluedroid host supported for now
return ' ' + generate_bluedroid_log_prefix(source, tag, print_statm)
else:
LOGGER.error(f'Unknown source {source}')
return ''
source_value = SOURCE_ENUM_MAP.get(source.upper())
if source_value is None:
raise ValueError(f'Invalid source: {source}')
@@ -551,41 +509,22 @@ class LogCompressor:
else:
sizes.append(f'{int(ARG_SIZE_TYPE.U32)}')
if arg_count > 0:
size_str = ', '.join(sizes)
arg_str = ', '.join(arguments).replace('\n', '')
macro += generate_log_lvl_prefix(
source,
tag,
(f'BLE_LOG_COMPRESSED_HEX_PRINT({source_value}, {log_idx}, {arg_count}, {size_str}, {arg_str})'),
)
stmt = self.module_mod[source].gen_compressed_stmt(
log_idx,
source_value,
tag,
log_info['arguments'][0],
[{'name': arg, 'size_type': size_type} for arg, size_type in zip(arguments, sizes)],
[
{
'buffer': hex_str.split('@')[2],
'length': hex_str.split('@')[3],
}
for hex_str in hex_func
],
)
macro += cast(str, stmt)
for idx, item in enumerate(hex_func):
# hex_func format: @hex_func@buf@len
parts = item.split('@')
if len(parts) >= 4:
buf = parts[2]
buf_len = parts[3]
macro += generate_log_lvl_prefix(
source,
tag,
(f'BLE_LOG_COMPRESSED_HEX_PRINT_BUF({source_value}, {log_idx}, {idx}, {buf}, {buf_len})'),
)
else:
macro += generate_log_lvl_prefix(
source, tag, f'BLE_LOG_COMPRESSED_HEX_PRINT_WITH_ZERO_ARGUMENTS({source_value}, {log_idx})'
)
for idx, item in enumerate(hex_func):
# hex_func format: @hex_func@buf@len
parts = item.split('@')
if len(parts) >= 4:
buf = parts[2]
buf_len = parts[3]
macro += generate_log_lvl_prefix(
source,
tag,
(f'BLE_LOG_COMPRESSED_HEX_PRINT_BUF({source_value}, {log_idx}, {idx}, {buf}, {buf_len})'),
)
if (
'tags_with_preserve' in self.module_info[source]
and tag in self.module_info[source]['tags_with_preserve']
@@ -593,8 +532,7 @@ class LogCompressor:
macro += f' {tag}(fmt, ##__VA_ARGS__);\\\n'
else:
# Non-hexified log
print_fmt = print_fmt or 'NULL'
macro += f' BLE_LOG_COMPRESSED_PRINT({source_value}, {log_idx}, "{print_fmt}", ##__VA_ARGS__); \\\n'
raise ValueError('Hexify convert failed')
macro += '}\n'
return macro
@@ -716,7 +654,7 @@ class LogCompressor:
total_cnt = 0
for src in srcs:
if pattern.match(src):
src_path = self.bt_component_path / src
src_path = self.code_base_path / src
dest_path = self.bt_compressed_srcs_path / src
temp_path = f'{dest_path}.tmp'
total_cnt += 1
@@ -754,7 +692,7 @@ class LogCompressor:
module: Module name
macros: List of (log_id, macro_definition)
"""
# header_path = self.bt_component_path / self.module_info[module]['log_index_path']
# header_path = self.code_base_path / self.module_info[module]['log_index_path']
header_path = self.build_dir / Path('ble_log') / Path('include') / self.module_info[module]['log_index_file']
# Create directory if needed
header_path.parent.mkdir(parents=True, exist_ok=True)
@@ -764,8 +702,7 @@ class LogCompressor:
return
elif update_state == self.db_manager.SOURCE_LOG_UPDATE_FULL:
# Header template
header_content = (
textwrap.dedent(f"""
header_content = textwrap.dedent(f"""
/*
* SPDX-FileCopyrightText: {datetime.now().year} Espressif Systems (Shanghai) CO LTD
*
@@ -778,22 +715,11 @@ class LogCompressor:
#include <stddef.h>
#include <stdlib.h>
// Compression function declarations
extern int ble_log_compressed_hex_print
(uint32_t source, uint32_t log_index, size_t args_size_cnt, ...);
extern int ble_log_compressed_hex_print_buf
(uint8_t source, uint32_t log_index, uint8_t buf_idx, const uint8_t *buf, size_t len);
// Compression macros
#define BLE_LOG_COMPRESSED_HEX_PRINT(source, log_index, args_cnt, ...) \\
ble_log_compressed_hex_print(source, log_index, args_cnt, ##__VA_ARGS__)
#define BLE_LOG_COMPRESSED_HEX_PRINT_BUF(source, log_index, buf_idx, buf, len) \\
ble_log_compressed_hex_print_buf(source, log_index, buf_idx, (const uint8_t *)buf, len)
#define BLE_LOG_COMPRESSED_HEX_PRINT_WITH_ZERO_ARGUMENTS(source, log_index) \\
ble_log_compressed_hex_print(source, log_index, 0)
""").strip()
+ '\n\n'
)
header_content += self.module_mod[module].gen_header_head()
header_content += '\n\n'
# Add sorted macros
for log_id, macro_def in sorted(macros, key=lambda x: x[0]):
header_content += macro_def + '\n'
@@ -852,6 +778,14 @@ class LogCompressor:
for module in module_names:
if module in modules:
self.module_info[module] = modules[module]
module_script_path = self.module_info[module]['script']
spec = self.module_mod[module] = importlib.util.spec_from_file_location(module, module_script_path)
if spec and spec.loader:
self.module_mod[module] = importlib.util.module_from_spec(spec)
spec.loader.exec_module(self.module_mod[module])
else:
LOGGER.error(f"Failed to load module '{module}' script")
raise ImportError(' Failed to load module script')
print(f'Found module {module} for compression\n', flush=True, end='', file=sys.stdout)
else:
LOGGER.warning(f"Skipping module '{module}' - config not found")
@@ -863,7 +797,7 @@ class LogCompressor:
compress_parser = subparsers.add_parser('compress')
compress_parser.add_argument('--srcs', required=True, help='Semicolon-separated source file paths')
compress_parser.add_argument('--bt_path', required=True, help='Bluetooth component root path')
compress_parser.add_argument('--code_base_path', required=True, help='Component base path')
compress_parser.add_argument('--module', required=True, help='Semicolon-separated module names')
compress_parser.add_argument('--build_path', required=True, help='Build output directory')
compress_parser.add_argument('--compressed_srcs_path', required=True, help='Directory for processed sources')
@@ -871,7 +805,7 @@ class LogCompressor:
args = parser.parse_args()
# Setup paths
self.bt_component_path = Path(args.bt_path)
self.code_base_path = Path(args.code_base_path)
self.build_dir = Path(args.build_path)
self.bt_compressed_srcs_path = Path(args.compressed_srcs_path)
@@ -947,7 +881,7 @@ class LogCompressor:
# Mark files as processed
for module, info in self.module_info.items():
for temp_path in info['files_to_process']:
src_path = self.bt_component_path / os.path.relpath(temp_path[:-4], self.bt_compressed_srcs_path)
src_path = self.code_base_path / os.path.relpath(temp_path[:-4], self.bt_compressed_srcs_path)
db_manager.mark_file_processed(module, src_path, temp_path)
for root, _, files in os.walk(self.bt_compressed_srcs_path):
for name in files:

View File

@@ -6,6 +6,7 @@ log_config:
description: "BLE Mesh"
code_path: [@BLE_MESH_CODE_PATH@]
log_index_file: @BLE_MESH_LOG_INDEX_HEADER@
script: @BLE_MESH_LOG_SCRIPT_PATH@
tags: [@BLE_MESH_TAGS@]
tags_with_preserve: [@BLE_MESH_TAGS_PRESERVE@]
@@ -13,5 +14,14 @@ log_config:
description: "BLE Host"
code_path: [@HOST_CODE_PATH@]
log_index_file: @HOST_LOG_INDEX_HEADER@
script: @BLE_HOST_LOG_SCRIPT_PATH@
tags: [@BLE_HOST_TAGS@]
tags_with_preserve: [@BLE_HOST_TAGS_PRESERVE@]
@BLE_COMPRESSED_LIB_NAME@:
description: "@BLE_COMPRESSED_LIB_DESC@"
code_path: [@BLE_COMPRESSED_LIB_CODE_DIR@]
log_index_file: @BLE_COMPRESSED_LIB_LOG_INDEX_HEADER@
script: @BLE_COMPRESSED_LIB_LOG_SCRIPT_PATH@
tags: [@BLE_COMPRESSED_LIB_LOG_TAGS@]
tags_with_preserve: [@BLE_COMPRESSED_LIB_LOG_TAGS_PRESERVE@]

View File

@@ -163,4 +163,5 @@ TYPES_MACRO_MAP = {
'SCNoPTR': __PRIPTR_PREFIX + 'o',
'SCNuPTR': __PRIPTR_PREFIX + 'u',
'SCNxPTR': __PRIPTR_PREFIX + 'x',
'MACSTR': '%s',
}

View File

@@ -0,0 +1,71 @@
# SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
import textwrap
def generate_mesh_log_prefix(tag: str, print_statm: str) -> str:
level = tag.split('_')[-1]
mod = tag.split('_')[0]
if level == 'ERR':
level = 'ERROR'
log_level = 'BLE_MESH_LOG_LEVEL_ERROR'
elif level == 'WARN':
level = 'WARN'
log_level = 'BLE_MESH_LOG_LEVEL_WARN'
elif level == 'INFO':
level = 'INFO'
log_level = 'BLE_MESH_LOG_LEVEL_INFO'
elif level == 'DBG':
level = 'DEBUG'
log_level = 'BLE_MESH_LOG_LEVEL_DEBUG'
else:
return ''
if mod == 'NET':
used_log_levl = 'BLE_MESH_NET_BUF_LOG_LEVEL'
used_log_mod = 'BLE_MESH_NET_BUF'
else:
used_log_levl = 'BLE_MESH_LOG_LEVEL'
used_log_mod = 'BLE_MESH'
return (
f'{{do {{ if (({used_log_levl} >= {log_level}) &&'
f' BLE_MESH_LOG_LEVEL_CHECK({used_log_mod}, {level})) {print_statm};}} while (0);}}\\\n'
)
def gen_header_head() -> str:
head = textwrap.dedent("""
// Compression function declarations
extern int ble_log_compressed_hex_print
(uint8_t source, uint32_t log_index, size_t args_size_cnt, ...);
extern int ble_log_compressed_hex_print_buf
(uint8_t source, uint32_t log_index, uint8_t buf_idx, const uint8_t *buf, size_t len);
""")
return head
def gen_compressed_stmt(
log_index: int, module_id: int, func_name: str, fmt: str, args: list[dict], buffer_args: list[dict]
) -> str:
if len(args) == 0:
stmt = f' ble_log_compressed_hex_print({module_id}, {log_index}, 0);'
for idx, buffer_arg in enumerate(buffer_args):
stmt += '\\\n'
stmt += (
f' ble_log_compressed_hex_print_buf('
f'{module_id}, {log_index}, {idx}, '
f'(const uint8_t *){buffer_arg["buffer"]}, {buffer_arg["length"]});'
)
stmt += '\\\n'
return ' ' + generate_mesh_log_prefix(func_name, stmt)
size_str = ', '.join([arg['size_type'] for arg in args])
args_str = ', '.join([arg['name'] for arg in args]).replace('\n', '')
stmt = f' ble_log_compressed_hex_print({module_id}, {log_index}, {len(args)}, {size_str}, {args_str});'
for idx, buffer_arg in enumerate(buffer_args):
stmt += '\\\n'
stmt += (
f' ble_log_compressed_hex_print_buf('
f'{module_id}, {log_index}, {idx}, '
f'(const uint8_t *){buffer_arg["buffer"]}, {buffer_arg["length"]});'
)
stmt += '\\\n'
return ' ' + generate_mesh_log_prefix(func_name, stmt)

View File

@@ -0,0 +1,61 @@
# SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
import textwrap
BLUEDROID_LOG_MODE_LEVEL_GET = {
'BTM': 'btm_cb.trace_level',
'L2CAP': 'l2cb.l2cap_trace_level',
'GAP': 'gap_cb.trace_level',
'GATT': 'gatt_cb.trace_level',
'SMP': 'smp_cb.trace_level',
'APPL': 'appl_trace_level',
}
def generate_bluedroid_log_prefix(tag: str, print_statm: str) -> str:
tag_info = tag.split('_')
mod = tag_info[0]
return (
f'{{if ({BLUEDROID_LOG_MODE_LEVEL_GET[mod]} >= BT_TRACE_LEVEL_{tag_info[-1]} &&'
f' BT_LOG_LEVEL_CHECK({mod}, {tag_info[-1]})) {print_statm};}}\\\n'
)
def gen_header_head() -> str:
head = textwrap.dedent("""
// Compression function declarations
extern int ble_log_compressed_hex_print
(uint8_t source, uint32_t log_index, size_t args_size_cnt, ...);
extern int ble_log_compressed_hex_print_buf
(uint8_t source, uint32_t log_index, uint8_t buf_idx, const uint8_t *buf, size_t len);
""")
return head
def gen_compressed_stmt(
log_index: int, module_id: int, func_name: str, fmt: str, args: list[dict], buffer_args: list[dict]
) -> str:
if len(args) == 0:
stmt = f' ble_log_compressed_hex_print({module_id},{log_index}, 0);'
for idx, buffer_arg in enumerate(buffer_args):
stmt += '\\\n'
stmt += (
f' ble_log_compressed_hex_print_buf('
f'{module_id}, {log_index}, {idx}, '
f'(const uint8_t *){buffer_arg["buffer"]}, {buffer_arg["length"]});'
)
stmt += '\\\n'
return ' ' + generate_bluedroid_log_prefix(func_name, stmt)
size_str = ', '.join([arg['size_type'] for arg in args])
args_str = ', '.join([arg['name'] for arg in args]).replace('\n', '')
stmt = f' ble_log_compressed_hex_print({module_id},{log_index}, {len(args)}, {size_str}, {args_str});'
for idx, buffer_arg in enumerate(buffer_args):
stmt += '\\\n'
stmt += (
f' ble_log_compressed_hex_print_buf('
f'{module_id}, {log_index}, {idx}, '
f'(const uint8_t *){buffer_arg["buffer"]}, {buffer_arg["length"]});'
)
stmt += '\\\n'
return ' ' + generate_bluedroid_log_prefix(func_name, stmt)

View File

@@ -21,7 +21,7 @@
/* MACRO */
#define BLE_LOG_TASK_PRIO (ESP_TASK_PRIO_MAX - 1)
#define BLE_LOG_TASK_STACK_SIZE (1024)
#define BLE_LOG_TASK_STACK_SIZE CONFIG_BLE_LOG_TASK_STACK_SIZE
#define BLE_LOG_TASK_HOOK_TIMEOUT_MS (1000)
/* INTERFACE */

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -32,6 +32,7 @@
#include "esp_bt_device.h"
#include "esp_err.h"
#include "esp_blufi.h"
#include <esp_gap_ble_api.h>
#if (BLUFI_INCLUDED == TRUE)
@@ -70,12 +71,155 @@ static esp_ble_adv_params_t blufi_adv_params = {
.adv_filter_policy = ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY,
};
#ifdef CONFIG_BT_BLUFI_BLE_SMP_ENABLE
static char *esp_auth_req_to_str(esp_ble_auth_req_t auth_req)
{
char *auth_str = NULL;
switch(auth_req) {
case ESP_LE_AUTH_NO_BOND:
auth_str = "ESP_LE_AUTH_NO_BOND";
break;
case ESP_LE_AUTH_BOND:
auth_str = "ESP_LE_AUTH_BOND";
break;
case ESP_LE_AUTH_REQ_MITM:
auth_str = "ESP_LE_AUTH_REQ_MITM";
break;
case ESP_LE_AUTH_REQ_BOND_MITM:
auth_str = "ESP_LE_AUTH_REQ_BOND_MITM";
break;
case ESP_LE_AUTH_REQ_SC_ONLY:
auth_str = "ESP_LE_AUTH_REQ_SC_ONLY";
break;
case ESP_LE_AUTH_REQ_SC_BOND:
auth_str = "ESP_LE_AUTH_REQ_SC_BOND";
break;
case ESP_LE_AUTH_REQ_SC_MITM:
auth_str = "ESP_LE_AUTH_REQ_SC_MITM";
break;
case ESP_LE_AUTH_REQ_SC_MITM_BOND:
auth_str = "ESP_LE_AUTH_REQ_SC_MITM_BOND";
break;
default:
auth_str = "INVALID BLE AUTH REQ";
break;
}
return auth_str;
}
static char *esp_key_type_to_str(esp_ble_key_type_t key_type)
{
char *key_str = NULL;
switch(key_type) {
case ESP_LE_KEY_NONE:
key_str = "ESP_LE_KEY_NONE";
break;
case ESP_LE_KEY_PENC:
key_str = "ESP_LE_KEY_PENC";
break;
case ESP_LE_KEY_PID:
key_str = "ESP_LE_KEY_PID";
break;
case ESP_LE_KEY_PCSRK:
key_str = "ESP_LE_KEY_PCSRK";
break;
case ESP_LE_KEY_PLK:
key_str = "ESP_LE_KEY_PLK";
break;
case ESP_LE_KEY_LLK:
key_str = "ESP_LE_KEY_LLK";
break;
case ESP_LE_KEY_LENC:
key_str = "ESP_LE_KEY_LENC";
break;
case ESP_LE_KEY_LID:
key_str = "ESP_LE_KEY_LID";
break;
case ESP_LE_KEY_LCSRK:
key_str = "ESP_LE_KEY_LCSRK";
break;
default:
key_str = "INVALID BLE KEY TYPE";
break;
}
return key_str;
}
#endif
void esp_blufi_gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param)
{
BLUFI_TRACE_DEBUG("GAP_EVT, event %d", event);
switch (event) {
case ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT:
esp_ble_gap_start_advertising(&blufi_adv_params);
break;
case ESP_GAP_BLE_ADV_START_COMPLETE_EVT:
//advertising start complete event to indicate advertising start successfully or failed
if (param->adv_start_cmpl.status != ESP_BT_STATUS_SUCCESS) {
BTC_TRACE_ERROR("Advertising start failed, status %x", param->adv_start_cmpl.status);
break;
}
BLUFI_TRACE_API("Advertising start successfully");
break;
#ifdef CONFIG_BT_BLUFI_BLE_SMP_ENABLE
case ESP_GAP_BLE_PASSKEY_REQ_EVT: /* passkey request event */
BLUFI_TRACE_API("Passkey request");
break;
case ESP_GAP_BLE_OOB_REQ_EVT: {
BLUFI_TRACE_API("OOB request");
uint8_t tk[16] = {1}; //If you paired with OOB, both devices need to use the same tk
esp_ble_oob_req_reply(param->ble_security.ble_req.bd_addr, tk, sizeof(tk));
break;
}
case ESP_GAP_BLE_LOCAL_IR_EVT: /* BLE local IR event */
BLUFI_TRACE_API("Local identity root");
break;
case ESP_GAP_BLE_LOCAL_ER_EVT: /* BLE local ER event */
BLUFI_TRACE_API("Local encryption root");
break;
case ESP_GAP_BLE_NC_REQ_EVT:
/* The app will receive this evt when the IO has DisplayYesNO capability and the peer device IO also has DisplayYesNo capability.
show the passkey number to the user to confirm it with the number displayed by peer device. */
esp_ble_confirm_reply(param->ble_security.ble_req.bd_addr, true);
BLUFI_TRACE_WARNING("Numeric Comparison request, passkey %" PRIu32, param->ble_security.key_notif.passkey);
break;
case ESP_GAP_BLE_SEC_REQ_EVT:
/* send the positive(true) security response to the peer device to accept the security request.
If not accept the security request, should send the security response with negative(false) accept value*/
esp_ble_gap_security_rsp(param->ble_security.ble_req.bd_addr, true);
break;
case ESP_GAP_BLE_PASSKEY_NOTIF_EVT: ///the app will receive this evt when the IO has Output capability and the peer device IO has Input capability.
///show the passkey number to the user to input it in the peer device.
BLUFI_TRACE_WARNING("Passkey notify, passkey %06" PRIu32, param->ble_security.key_notif.passkey);
break;
case ESP_GAP_BLE_KEY_EVT:
//shows the ble key info share with peer device to the user.
BLUFI_TRACE_API("Key exchanged, key_type %s", esp_key_type_to_str(param->ble_security.ble_key.key_type));
break;
case ESP_GAP_BLE_AUTH_CMPL_EVT: {
esp_bd_addr_t bd_addr;
memcpy(bd_addr, param->ble_security.auth_cmpl.bd_addr, sizeof(esp_bd_addr_t));
BLUFI_TRACE_API("Authentication complete, addr_type %u, addr "ESP_BD_ADDR_STR"",
param->ble_security.auth_cmpl.addr_type, ESP_BD_ADDR_HEX(bd_addr));
if(!param->ble_security.auth_cmpl.success) {
BLUFI_TRACE_WARNING("Pairing failed, reason 0x%x",param->ble_security.auth_cmpl.fail_reason);
} else {
BLUFI_TRACE_WARNING("Pairing successfully, auth_mode %s",esp_auth_req_to_str(param->ble_security.auth_cmpl.auth_mode));
}
break;
}
case ESP_GAP_BLE_REMOVE_BOND_DEV_COMPLETE_EVT: {
BLUFI_TRACE_DEBUG("Bond device remove, status %d, device "ESP_BD_ADDR_STR"",
param->remove_bond_dev_cmpl.status, ESP_BD_ADDR_HEX(param->remove_bond_dev_cmpl.bd_addr));
break;
}
case ESP_GAP_BLE_SET_LOCAL_PRIVACY_COMPLETE_EVT:
if (param->local_privacy_cmpl.status != ESP_BT_STATUS_SUCCESS){
BLUFI_TRACE_WARNING("Local privacy config failed, status %x", param->local_privacy_cmpl.status);
}
break;
#endif // CONFIG_BT_BLUFI_BLE_SMP_ENABLE
default:
break;
}
@@ -251,10 +395,16 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
break;
case BTA_GATTS_CREATE_EVT:
blufi_env.handle_srvc = p_data->create.service_id;
#if CONFIG_BT_BLUFI_BLE_SMP_ENABLE
BLUFI_TRACE_WARNING("BLE SMP support in BLUFI is ENABLED!");
#endif // CONFIG_BT_BLUFI_BLE_SMP_ENABLE
//add the first blufi characteristic --> write characteristic
BTA_GATTS_AddCharacteristic(blufi_env.handle_srvc, &blufi_char_uuid_p2e,
(GATT_PERM_WRITE),
#if CONFIG_BT_BLUFI_BLE_SMP_ENABLE
GATT_PERM_WRITE_ENC_MITM,
#else
GATT_PERM_WRITE,
#endif
(GATT_CHAR_PROP_BIT_WRITE),
NULL, NULL);
break;
@@ -398,6 +548,16 @@ void esp_blufi_adv_stop(void)
esp_ble_gap_stop_advertising();
}
esp_err_t esp_blufi_start_security_request(esp_blufi_bd_addr_t remote_bda)
{
#ifdef CONFIG_BT_BLUFI_BLE_SMP_ENABLE
return esp_ble_set_encryption(remote_bda, ESP_BLE_SEC_ENCRYPT_MITM);
#else
return ESP_ERR_INVALID_STATE;
#endif // CONFIG_BT_BLUFI_BLE_SMP_ENABLE
}
void esp_blufi_send_encap(void *arg)
{
struct blufi_hdr *hdr = (struct blufi_hdr *)arg;

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -90,6 +90,22 @@ void esp_blufi_adv_start_with_name(const char *name);
void esp_blufi_send_encap(void *arg);
/*
* @brief Initiate BLE security request with the connected peer device.
*
* This function triggers the BLE Security Manager Protocol (SMP) procedure
* to establish a secure, encrypted connection with the specified remote device.
* It should be called after a BLE connection is established.
*
* @param[in] remote_bda Bluetooth device address of the connected peer.
*
* @return
* - ESP_OK: Security request initiated successfully
* - ESP_FAIL: Security request failed
* - ESP_ERR_INVALID_STATE: BluFi BLE SMP is not enabled
*/
esp_err_t esp_blufi_start_security_request(esp_blufi_bd_addr_t remote_bda);
#ifdef CONFIG_BT_NIMBLE_ENABLED
/**
* @brief Handle gap event for BluFi.

View File

@@ -61,6 +61,16 @@
#define HEAP_MEMORY_DEBUG FALSE
#endif
#if UC_BT_BLUEDROID_THREAD_DEBUG
#define OSI_THREAD_DEBUG TRUE
#else
#define OSI_THREAD_DEBUG FALSE
#endif
#define OSI_THREAD_BLOCK_TIME UC_BT_BLUEDROID_THREAD_BLOCK_TIME
#define OSI_THREAD_BLOCK_MSG UC_BT_BLUEDROID_THREAD_BLOCK_MSG
#ifndef BT_BLE_DYNAMIC_ENV_MEMORY
#define BT_BLE_DYNAMIC_ENV_MEMORY FALSE
#endif
@@ -240,6 +250,7 @@ typedef uint64_t UINT64;
typedef bool BOOLEAN;
/* Maximum UUID size - 16 bytes, and structure to hold any type of UUID. */
#define MAX_UUID_SIZE 16
#define MAX_UUID_NUM 32
typedef struct {
#define LEN_UUID_16 2

View File

@@ -107,6 +107,24 @@
#define UC_BT_BLUEDROID_MEM_DEBUG FALSE
#endif
#ifdef CONFIG_BT_BLUEDROID_THREAD_DEBUG
#define UC_BT_BLUEDROID_THREAD_DEBUG TRUE
#else
#define UC_BT_BLUEDROID_THREAD_DEBUG FALSE
#endif
#ifdef CONFIG_BT_BLUEDROID_THREAD_BLOCK_TIME
#define UC_BT_BLUEDROID_THREAD_BLOCK_TIME CONFIG_BT_BLUEDROID_THREAD_BLOCK_TIME
#else
#define UC_BT_BLUEDROID_THREAD_BLOCK_TIME 1000
#endif
#ifdef CONFIG_BT_BLUEDROID_THREAD_BLOCK_MSG
#define UC_BT_BLUEDROID_THREAD_BLOCK_MSG CONFIG_BT_BLUEDROID_THREAD_BLOCK_MSG
#else
#define UC_BT_BLUEDROID_THREAD_BLOCK_MSG 50
#endif
#ifdef CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST
#define UC_HEAP_ALLOCATION_FROM_SPIRAM_FIRST CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST
#else

Some files were not shown because too many files have changed in this diff Show More