Commit Graph

283 Commits

Author SHA1 Message Date
Song Ruo Jing
1575b9e43a ci: Disable all currently failed target tests for esp32c6 2022-11-28 12:09:08 +08:00
Guillaume Souchere
1d16ca6a26 Merge branch 'feature/lower-iram-utilization-of-heap-component' into 'master'
heap: lower the utilization of IRAM by the heap component binary

Closes IDF-2282 and IDFGH-6233

See merge request espressif/esp-idf!20926
2022-11-25 15:22:05 +08:00
C.S.M
28b2deaf24 Merge branch 'feature/add_target_esp32h2' into 'master'
ESP32-H2: Introduce new target for ESP32H2

See merge request espressif/esp-idf!21190
2022-11-24 18:31:19 +08:00
Guillaume Souchere
b496bab0f6 heap: fix linker issues and remove spi flash dependencies 2022-11-24 10:31:14 +01:00
Guillaume Souchere
e31e6d4de8 feat: remove tlsf_fls and tlsf_ffs from linker as they are inlined. 2022-11-24 10:31:14 +01:00
Guillaume Souchere
ab1bd08ab9 tools: update list of references to not include symbold used by __assert_func calls
On xtensa architecture, the call to __assert_func uses a reference to __func__ that can
sometimes be placed in flash. Since the __asert_func can be called from functions in IRAM
the check_callgraph script can report an error when checking for invalid calls from IRAM
to flash sections. However, the __asert_func prevents this scenario at runtime so the
check_callgraph script reports a 'flas positive' situation. For this reasson, all references
to __func__$x found prior to a call to __assert_func are droped in the parsing of the rtl files.
2022-11-24 10:31:14 +01:00
Guillaume Souchere
0376e6ec79 heap: add check for usage of flash content from iram
this commits:
- adds build-time test to check that no call to flash regions are done from IRAM functions

- resolves problems related to IRAM function using content in flash memory

- update heap_caps_alloc_failed to use a default function name in DRAM
  when necessary instead of creating a function name variable in DRAM for
  each call of heap_caps_alloc_failed. This allows to save some extra bytes
  in RAM.
2022-11-24 10:31:14 +01:00
Guillaume Souchere
5dc0481d21 heap: add documentation about the function placement in IRAM and its usage in ISR
This commits adds a internal.md file in the heap directory to clarify the idea behind
which functions is placed in IRAM or in flash.

A section in mem_alloc.rst documentation is added to specify which functions from the
heap component API can be used in interrupt handlers.
2022-11-24 10:31:14 +01:00
Guillaume Souchere
7fcd964b1d heap: add selective placement of function in IRAM
This commit aims to place in the IRAM section only the functions that
are relevent for performance instead of placing the entire content of
multi_heap.c, mullti_heap_poisoning.c and tlsf.c in the IRAM.
2022-11-24 10:31:14 +01:00
Cao Sen Miao
86aa4df5b5 ESP32-H2: Introduce new target for ESP32H2 2022-11-23 14:38:05 +08:00
Omar Chebib
cd21058097 C/Cxx: unify static assertions with the macro ESP_STATIC_ASSERT
Closes https://github.com/espressif/esp-idf/issues/9938
2022-11-21 16:18:08 +08:00
laokaiyao
8677216576 esp32h2: renaming esp32h2 to esp32h4 2022-11-08 17:05:33 +08:00
Song Ruo Jing
be0fdfa176 soc: Add a soc cap, SOC_CLK_RC_FAST_D256_SUPPORTED, for whether the target has the RC_FAST_D256 clock 2022-11-01 11:23:26 +08:00
Laukik Hase
d0b1b5a8aa
heap: Added note to increase INT_WDT timeout for integrity-check APIs
- When PSRAM is enabled, the heap integrity check APIs
  (`heap_caps_check_integrity` and `heap_caps_check_integrity_all`)
  take more time to execute and keep the interrupts disabled for a
  longer time.
2022-10-30 10:36:01 +05:30
Guillaume Souchere
ce895b87ab Merge branch 'feature/tlsf-dynamic-control-size' into 'master'
heap: Update to the new tlsf implementation of dynamic metadata size

See merge request espressif/esp-idf!20584
2022-10-27 13:54:45 +08:00
Guillaume Souchere
508194be50 heap: Remove size check in multi_heap.c when registering a new heap
The tlsf now checks for size validity when creating a new heap.

The check previously done in multi_heap_register_impl() is no longer
valid since the tlsf_size() is not known at this time (as the metadata
size is linked ot the size of the memory region passed as parameter
when calling tlsf_create_with_pool())

The tlsf_create_with_pool() will return a null pointer if the size
of the memory is not big enough to hold the metadata overhead and
at least a small block.

Update the test according to the changes in TLSF API
2022-10-26 18:15:42 +02:00
Guillaume Souchere
6f11d0f297 heap: Update target and host tests after incorporation of the new TLSF implementation
- update the target and host tests to consider the new TLSF api and the metadata size
  only when the target is not using the rom implementation of the TLSF
2022-10-26 18:15:40 +02:00
Guillaume Souchere
7de6565722 heap: fix comment and return condition in heap_caps_check_add_region_allowed()
(See  cd805a5ab1)
2022-10-26 09:49:43 +02:00
Guillaume Souchere
90ac786cf4 heap: Update the component to incorporate the new TLSF implementation
- remove tlsf_platform.h from esp-idf since the fl_index is now calculated
  based on the size of the requested heap
- update CMakeLists.txt accordingly

* based on the changes made to the TLSF in https://github.com/espressif/esp-idf/pull/7829
* contributes to fix https://github.com/espressif/esp-idf/issues/7822
2022-10-26 09:47:45 +02:00
jiangguangming
932045c980 esp_rom: add rom tlsf function prototype instead of void * 2022-10-19 17:54:50 +08:00
Ivan Grokhotkov
7e2f261a58
freertos, app_trace, heap: use esp_cpu_get_cycle_count to get ccount
portGET_RUN_TIME_COUNTER_VALUE should only be used in the kernel.
2022-10-12 11:20:55 +02:00
Guillaume Souchere
cd805a5ab1 heap: Fix memory boundary condition checks when adding new region
Previously, condition_4 was making impossible the valid scenario
start > heap_start && end == heap_end.

Now, the end == heap_end and start == heap_start case is handled
separately allowing the case start > heap_start && ned == heap_end
to be considered a valid scenario
2022-10-07 13:22:30 +02:00
Guillaume Souchere
2b5a844640 heap: fix the boundary checks when adding a new region 2022-10-05 15:08:21 +02:00
Guillaume Souchere
2cce5e98b1 heap: add dynamic poisoning threshold in pytest env to allow test with known memory leak to pass 2022-10-05 15:07:37 +02:00
Guillaume Souchere
a29627f59d heap: fix the size of buffers in ignored tests
the ignored tests are updated with the minimum required buffer size to create
a new heap using the tlsf heap callocator.
2022-10-05 15:07:06 +02:00
wuzhenghui
357490267a heap: update esp32c6 memory layout 2022-09-29 11:13:06 +08:00
Marius Vikhammer
1327a82b65 heap: fix random alloc test timing out in CI 2022-09-27 16:51:54 +08:00
wuzhenghui
4a86a6a258 esp32c6: add heap support 2022-09-26 20:32:13 +08:00
Guillaume Souchere
bf18a05a5f unit-tests: Move the leak related tests from the heap component to test_utils 2022-09-23 09:49:09 +02:00
Guillaume Souchere
82c98c7f48 heap: Add test_apps configs 2022-09-23 09:49:09 +02:00
Guillaume Souchere
405c26da6d heap: migrate unit tests to pytest 2022-09-23 09:49:07 +02:00
Zim Kalinowski
889b5fbea3 Merge branch 'bugfix/fix_tlsf_patch_esp32c2' into 'master'
TLSF: fix the patch for tlsf_check function in ROM

Closes IDFCI-1442 and IDFCI-1441

See merge request espressif/esp-idf!19839
2022-09-13 18:32:40 +08:00
Marius Vikhammer
e1f27cf31b heap: remove misleading info about malloc being equivalent to heap_caps_malloc(p, MALLOC_CAP_8BIT)
The actual memory allocated for malloc() depends on a lot of factors, see heap_caps_malloc_default()

Closes https://github.com/espressif/esp-idf/issues/7659
2022-09-01 11:39:34 +08:00
Omar Chebib
0b5ab940ae TLSF: fix the patch for tlsf_check function in ROM
tlsf_check in the patch was not called because the the TLSF functions
table in ROM was still pointing to the ROM implementation.
2022-08-31 13:30:10 +08:00
Guillaume Souchere
4571e19387 heap: Add test to check that the corruption of free memory is detected
This commit extends the heap test set by adding a test to check corruption
detection in free memory block.

For each byte of the free block memory, the test changes the value of the byte,
call multi_heap_check(), make sure that the function returns 'corruption detected'
only when comprehensive poisoning is set, restore the good value of the byte, calls
multi_heap_check() again and make sure that it returns 'OK'.
2022-08-26 08:25:39 +02:00
Guillaume Souchere
b9abad7a89 esp-rom: create a patch of tlsf_check() for target(s) supporting ROM implementation of TLSF
The tlsf implementation in the ROM does not provide a mechanism
to register a callback to be called in by tlsf_check().

This commit is creating a patch of the tlsf implementation to provide
a definition of the function allowing to register the callback called
in tlsf_check() and add the call of this callback in tlsf_check().

This patch is only compiled for target(s) with ESP_ROM_HAS_HEAP_TLSF
set and ESP_ROM_TLSF_CHECK_PATCH set. For all the other configurations
the environment remains unchanged by those modifications.
2022-08-26 08:25:38 +02:00
Guillaume Souchere
f051da86e2 heap: Provide definition of the tlsf_check_hook() declared in the tlsf submodule
Add the definition of tlsf_check_hook() in multi_heap if MULTI_HEAP_POISONING
is set. This definition calls the multi_heap_internal_check_block_poisoning()
to check the memory of a free block for corruption. If the light poisoinng is
set this function returns true. If the comprehensive poisoning is set, this
function will check that all byte of memory in the memory chunk passed as parameter
are set to the right FILL pattern.
2022-08-26 08:20:50 +02:00
songruojing
304a8f142d esp32c6: introduce the target
Add esp32c6 target to tools and Kconfig
Create directories and files that are essential for `idf.py --preview set-target esp32c6`
2022-08-19 11:13:02 +08:00
Omar Chebib
d622bcfd46 Merge branch 'contrib/github_pr_9517' into 'master'
fix malloc(0) and heap_caps_alloc_failed() (GitHub PR)

Closes IDFGH-8007

See merge request espressif/esp-idf!19421
2022-08-09 15:49:27 +08:00
Omar Chebib
c6ddf7288c heap: add a unit test for malloc(0) and slightly optimize heap_caps_malloc_prefer 2022-08-09 10:30:36 +08:00
Guillaume Souchere
16c2cb3f1b Merge branch 'feature/replace-heap-tlsf-with-submodule' into 'master'
heap: Remove TLSF related files and replace them with the TLSF submodule

Closes IDF-4967

See merge request espressif/esp-idf!19220
2022-08-08 12:36:02 +08:00
tgotic
ee4d15d02f fix malloc(0) and heap_caps_alloc_failed()
Don't call heap_caps_alloc_failed() for malloc(0) and calloc(0), because it is not an error.
Improve handling of malloc(0) and calloc(0).

Merges https://github.com/espressif/esp-idf/pull/9517
2022-08-08 02:55:50 +00:00
Wu Zheng Hui
4c3322ed60 Merge branch 'bugfix/fix_esp32s3_cache_data_memory_wrong_attr' into 'master'
bugfix: esp32s3 DCache data memory is  retention dma inaccessible

Closes IDFCI-1409, IDFCI-1410, IDFCI-1411, IDFCI-1412, and IDFCI-1413

See merge request espressif/esp-idf!19365
2022-08-05 10:42:52 +08:00
Ivan Grokhotkov
401c10ecfb build system: re-add -Wno-format as private flag for some components 2022-08-03 16:42:47 +04:00
wuzhenghui
65f0b1a821 bugfix: DCache data memory is dma accessible but not retention dma accessible 2022-08-03 20:07:39 +08:00
Guillaume Souchere
2a29cdcb71 heap: Move the declaration of tlsf_poison_fill_pfunc_set() in esp_rom component
- The declaration is moved to esp_rom/include/esp32c2/rom/tlsf.h.
- multi_heap_poisoning.h now includes rom/tlsf.h instead of declaring
tlsf_poison_fill_pfunc_set().

Note: If more targets will support an implementation of the TLSF in ROM,
esp_rom will be extended with new headers in the respective target directories
but multi_heap_poisoning.h will remain unchanged.
2022-08-03 08:28:10 +02:00
Guillaume Souchere
d98bfe1b42 heap: Fix compilation error when CONFIG_SPIRAM is set on esp32s3 target
When CONFIG_SPIRAM is set, the TLSF_MAX_POOL_SIZE is set to SOC_EXTRAM_DATA_SIZE
which caused the TLSF_MAX_POOL_SIZE to be bigger than 16MB.

This commit fixes the issue by adding an extra else if case to cover this configuration.
2022-08-03 08:28:10 +02:00
Guillaume Souchere
594e58e65a heap: Fix compilation errors when CONFIG_HEAP_TLSF_USE_ROM_IMPL is set
- include headers from the tlsf submodule only when CONFIG_HEAP_TLSF_USE_ROM_IMPL is not set
- remove usage of the tlsf_t type in the multi_heap.c
- add missing declaration of tlsf_poison_fill_pfunc_set() in multi_heap_poisoning.c
- define headers from tlsf submodule as private
- update the linker file in the heap component to the new naming of the tlsf file
- update the copyright docuementation to reference the submodule in github (https://github.com/espressif/tlsf)
- remove deleted files from the check_copyright_ignore.txt
2022-08-03 08:28:01 +02:00
Guillaume Souchere
3737bf8322 heap: Remove TLSF related files and replace them with the tlsf submodule
As the tlsf implementation is a fork from https://github.com/mattconte/tlsf,
the sources are moved to a separate repository and used as a submodule in the esp-idf instead.

In this commit:
- Removing TLSF related files and using tlsf submodule instead.

- Adding components/heap/tlsf_platform.h header gathering all IDF specifics.

- The multi_heap_poisoning.c provides the declaration of the
function block_absorb_post_hook() definied weak in the TLSF repository.

- The tlsf_platform.h includes the tlsf_common.h file after the definition
of FL_INDEX_MAX_PLATFORM macro to make sure that this macro will be available
in tlsf_common.h without having to include tlaf_platform.h from IDF in the
tlsf_common.h header from the TLSF repository.

- Add missing include from tlsf_block_functions.h in the multi_heap.c file.
Change related to the changes made in TLSF repository (tlsf_block_functions.h
no longer included in tlsf.h)
2022-08-02 12:55:31 +02:00
wuzhenghui
5e8ba9cea8 use enum and designated initializers in soc_memory_type define 2022-07-29 17:07:41 +08:00