527 Commits

Author SHA1 Message Date
harshal.patil
e1d60fb89f refactor(esp_system): deduplicate ROM fast wake RTC digest reservation
The digest length and the condition that reserves it at the end of RTC RAM were
duplicated in seven places. Hold the reservation in a hidden Kconfig value that
is zero when the feature does not apply, so every consumer subtracts it
unconditionally, and derive ESP_SECURE_BOOT_DIGEST_LEN from it.
2026-07-30 12:20:22 +05:30
wuzhenghui
f2b2bac778 fix(esp_system): support rom secure boot fast wake feature for esp32s31 2026-07-28 21:32:45 +08:00
Konstantin Kondrashov
46fceb2490 fix(heap): trace heap_caps_calloc allocations in standalone heap tracing
heap_caps_calloc_base() calls heap_caps_malloc_base() from the same
translation unit (heap_caps_base.c). GNU ld --wrap only redirects
undefined references, so that intra-object call binds to the real
heap_caps_malloc_base and never enters __wrap_heap_caps_malloc_base.
As a result, allocations made through heap_caps_calloc() were never
recorded by heap tracing, silently hiding potentially large INTERNAL
leaks (e.g. mbedtls SSL buffers via MALLOC_CAP_INTERNAL).

Add heap_caps_calloc_base to the --wrap list and implement
__wrap_heap_caps_calloc_base, which records the allocation via a
noinline trace_calloc helper (mirroring trace_malloc so the recorded
call stack depth stays consistent) and calls __real_heap_caps_calloc_base.
The inner malloc_base call remains same-TU and unwrapped, so each
calloc produces exactly one trace record (no double counting).
2026-07-20 19:17:12 +03:00
wuzhenghui
1b842d163e fix(esp_hw_support): update memory pointer checks for SPM support 2026-07-10 14:05:50 +08:00
Wu Zheng Hui
d26f5682cf Merge branch 'change/change_regdma_malloc_caps' into 'master'
change(heap): reserve DMA pool with low priority MALLOC_CAP_DEFAULT cap

See merge request espressif/esp-idf!50255
2026-07-09 19:32:56 +08:00
morris
651d6a283f refactor(esp_common): centralize ALIGN_UP/ALIGN_DOWN into esp_macros.h
Remove ~50 duplicate local definitions of ALIGN_UP/ALIGN_DOWN/ALIGN_UP_BY/
ALIGN_DOWN_BY across the codebase and replace them with canonical
ESP_ALIGN_UP/ESP_ALIGN_DOWN from esp_macros.h.
2026-07-06 13:36:06 +08:00
wuzhenghui
a3fc0c4b58 change(heap): reserve DMA pool with low priority MALLOC_CAP_DEFAULT caps 2026-07-03 20:54:30 +08:00
Meet Patel
d51e467e7c Merge branch 'feature/add_kasan_support' into 'master'
feat(kasan): add Kernel Address Sanitizer (KASAN) support for ESP-IDF

Closes IDF-13467

See merge request espressif/esp-idf!48106
2026-06-25 11:30:48 +05:30
Meet Patel
383e9adb82 feat(kasan): add Kernel Address Sanitizer (KASAN) support for ESP-IDF
Add KASAN support for detecting heap memory safety bugs (buffer
overflows, underflows, use-after-free) at runtime using compiler
instrumentation and shadow memory. Gated behind
CONFIG_IDF_EXPERIMENTAL_FEATURES, with touch points kept to esp_system
and heap so other components stay untouched.

- Core runtime (esp_system/kasan.c, esp_kasan.h): nibble-based shadow
  memory in DRAM, poison/unpoison, per-access validation, and __asan_*
  stubs; hot-path stubs in IRAM so they stay valid with the flash cache
  off. Shadow init runs before heap bring-up.
- Heap integration (heap/heap_kasan*.c): alloc/free hooks add redzones,
  a quarantine FIFO, and shadow updates.
- Panic handling: disable checks once at the panic handler entry so
  backtrace and stack dumps can read redzones without nested reports.
- Build system: -fsanitize=kernel-address for app code, with HAL, SoC,
  esp_rom, SPI flash, esp_hw_support, bootloader_support, FreeRTOS, and
  heap internals excluded from instrumentation.
- Test app (tools/test_apps/system/kasan_test): Unity tests for
  overflow, underflow, use-after-free, and all sized __asan_* stubs,
  with halt and no-halt configurations.
- Docs: document KASAN in the heap memory debugging guide (EN and CN).
2026-06-24 11:27:00 +05:30
Renz Bagaporo
1fdd4c7258 fix(heap): reset alloc_stat before realloc lookup
Closes https://github.com/espressif/esp-idf/issues/18723
Closes https://github.com/espressif/esp-idf/pull/18724
2026-06-19 10:19:51 +09:00
Ferdinand Bachmann
55936917ef fix(heap_task_info): Fix incorrect current_usage subtraction on realloc() 2026-06-17 15:04:39 +09:00
Renz Bagaporo
9653031165 ci(heap): add task tracking realloc handle reuse test 2026-06-17 14:54:12 +09:00
Guillaume Souchere
177024eeeb fix(heap): Do not consider newly registered heap in minimum free size calcualtion
After startup is done and app_main is reached, all calls to
heap_caps_add_region_with_caps (adding a new heap to the list of registered
heaps) will not affect the minimum free heap size value.

For heaps created before startup, this won't apply and their size will
end up being taken into account in the calculation of the minimum.
2026-05-28 10:30:25 +02:00
Mahavir Jain
23aba459f5 feat(esp_psram): add option to carve unencrypted PSRAM region
Adds CONFIG_SPIRAM_ENC_EXEMPT, available on chips that support per-page
PSRAM encryption configuration (esp32c5, esp32c61, esp32p4). When
enabled, esp_psram carves CONFIG_SPIRAM_ENC_EXEMPT_SIZE off the top of
PSRAM and maps it via the new mmu_hal_map_region_no_enc() helper, which
writes MMU entries without the SENSITIVE bit. The region is registered
as a separate heap pool reachable only through the new
MALLOC_CAP_SPIRAM_NO_ENC capability bit, so default SPIRAM allocations
cannot accidentally land there.

PSRAM encryption imposes alignment constraints that some DMA engines
(e.g. 2D-DMA) cannot satisfy. This option lets such workloads place
their buffers in unencrypted PSRAM while keeping the rest of PSRAM
(and flash) encrypted. Default disabled; security implications are
documented in the Kconfig help text.
2026-05-14 19:21:18 +05:30
Marius Vikhammer
261bd160aa feat(ulp): support placing ULP app in HP-RAM 2026-04-29 09:47:33 +08:00
Guillaume Souchere
a56354e9ab feat(heap): move TLSF ROM patches and related files from esp_rom to heap
The TLSF ROM patch code (rom_patch_tlsf.c, rom_patch_multi_heap.c),
their headers, and the per-target *.rom.heap.ld linker scripts are
semantically owned by the heap component, not esp_rom. Move them
accordingly:

- components/esp_rom/patches/esp_rom_tlsf.c
  → components/heap/rom_patches/rom_patch_tlsf.c
- components/esp_rom/patches/esp_rom_multi_heap.c
  → components/heap/rom_patches/rom_patch_multi_heap.c
- components/esp_rom/include/esp_rom_tlsf.h
  → components/heap/rom_patches/include/rom_patch_tlsf.h
- components/esp_rom/include/esp_rom_multi_heap.h
  → components/heap/rom_patches/include/rom_patch_multi_heap.h
- components/esp_rom/<target>/ld/<target>.rom.heap.ld (×8)
  → components/heap/port/<target>/ld/<target>.rom.heap.ld

Update heap/CMakeLists.txt to:
- use target_linker_script() directly for *.rom.heap.ld
- guard post-registration ROM patch setup with NOT BOOTLOADER_BUILD
- drop stale CONFIG_HEAP_TLSF_CHECK_PATCH symbol reference
- drop esp_rom_include_multi_heap_patch from TLSF_CHECK_PATCH guard

Remove the corresponding entries from esp_rom/CMakeLists.txt.
2026-04-23 12:21:31 +02:00
Guillaume Souchere
da81ec6f47 fix(esp_rom): Set poison check hook for tlsf_walk_pool patch 2026-04-23 07:51:04 +02:00
Marius Vikhammer
10637dbf5e feat(ulp): add support for ulp on esp32s31 2026-04-20 14:45:23 +08:00
Song Ruo Jing
50051b74a5 feat(clk): support for esp32s31 clock tree 2026-04-02 20:39:59 +08:00
Fu Hanxi
ddc7e0cdf7 ci: move qemu test cli args alongside test scripts
remove redundant host_test marker
2026-03-26 10:56:15 +01:00
armando
c60ed4b338 fix(spm): rename scp (scratchpad) to spm (scratchpad memory) 2026-03-17 01:29:34 +00:00
armando
c96f69faef change(mem): deprecated tcm and added scp memory utils 2026-03-11 11:18:15 +08:00
Marius Vikhammer
406d592929 feat(heap): complete ESP32-S31 heap bringup
Remove stale TODO reference from memory_layout.c.
2026-01-28 14:48:02 +08:00
Marius Vikhammer
5f914189c2 ci(core): removed common_components from core test-apps dependencies 2026-01-26 11:47:23 +08:00
igor.udot
4c26ab876b ci: update build-test-rules to use common_components 2026-01-23 10:14:09 +08:00
Sudeep Mohanty
160e1c5bf7 fix(heap): Fixed const qualifier warning in heap_task_info.c
Fixed compilation error when building with -Wwrite-strings or
-Wdiscarded-qualifiers by adding const qualifier to char pointers with
string literals.

Closes https://github.com/espressif/esp-idf/issues/18120
2026-01-21 08:44:50 +01:00
Michael (XIAO Xufeng)
c299c0b749 Merge branch 'refactor/remove_idf_test_component' into 'master'
refactor: Remove idf_test component

Closes IDF-12578

See merge request espressif/esp-idf!43733
2026-01-06 16:20:20 +08:00
Guillaume Souchere
55e9868979 ci(heap): Add depends_components attribute to build-test-rules 2026-01-05 07:44:50 +01:00
Xiao Xufeng
438e07b30e refactor: Remove idf_test component
Split the idf_performance.h and target ver, which hold the performance
thresholds, into the headers of each testing.

In the past pytest also parse the common header to get the thresholds.
Now the logic is also removed. Performance thresholds are supposed to be
in the pytest scripts.
2026-01-01 02:26:42 +08:00
Wu Zheng Hui
0f549fa113 Merge branch 'fix/fix_secure_boot_fast_wake_feature' into 'master'
fix(esp_system): fix ROM secure boot fast wake feature

Closes PM-625

See merge request espressif/esp-idf!44052
2025-12-16 10:24:16 +08:00
wuzhenghui
4125fd68ac fix(esp_system): fix rom secure boot fast wake feature for c5/c6/h2/h21 2025-12-12 16:04:20 +08:00
C.S.M
f405e51784 ci(esp32s31): Add ci build test for esp32s31 2025-12-11 15:17:15 +08:00
Alexey Lapshin
31810ae993 feat(esp_libc): make picolibc default libc 2025-12-03 13:31:42 +07:00
C.S.M
0c4cf75c35 feat(esp32s31): Introduce esp32s31 hello world 2025-12-02 10:44:16 +08:00
C.S.M
a90c93541c feat(esp32s31): Introduce new target esp32s31 2025-11-17 14:48:55 +08:00
armando
a28d9869c1 feat(cache): use icache memroy as diram when single core 2025-11-14 10:35:39 +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
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
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
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
Laukik Hase
b9a503e9ec feat(esp_tee): Support for ESP32-C61 - the rest of the components 2025-11-07 14:54:16 +05:30
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
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
wuzhenghui
e9da2e3606 fix(esp_hw_support): add p4 rev3.0 MSPI workaround for deepsleep 2025-10-30 14:50:27 +08:00
wuzhenghui
bedcf4ad88 change(esp_hw_support): allocate memory with MALLOC_CAP_RETENTION for regdma link 2025-10-14 16:33:29 +08:00
Guillaume Souchere
0f3f44be62 feat(heap): Add hidden Kconfig option to allow exec cap 2025-09-29 10:45:33 +08:00
Guillaume Souchere
da9d8a143a feat(heap): Report prohibited usage of MALLOC_CAPS_EXEC at compile time
Add a condition on the definition of the MALLOC_CAP_EXEC macro to
prevent it from being defined if ESP_SYSTEM_MEMPROT_FEATURE or
ESP_SYSTEM_PMP_IDRAM_SPLIT is enabled, thus throwing a compile time
error when using it.

Closes https://github.com/espressif/esp-idf/issues/14837
2025-09-29 10:45:32 +08:00
Guillaume Souchere
1798034d3f feat(tools): Remove old copy of Catch2 in tools 2025-09-23 08:49:58 +02:00
Guillaume Souchere
f8cb539e29 feat(heap): Update test to CMake and use Catch2 component 2025-09-18 10:07:08 +02:00
Alexey Lapshin
9281e78381 change(esp_libc): rename newlib component to esp_libc 2025-09-09 22:00:44 +08:00