Skip to content

Commit b6fc922

Browse files
committed
bugfix(gmf_io): Fixed file io cache memory caps
1 parent ad57c22 commit b6fc922

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

elements/gmf_io/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## v0.7.3
4+
5+
### Bug Fixes
6+
7+
- Fixed cache caps issues for esp32 in `io_file`
8+
39
## v0.7.2
410

511
### Features

elements/gmf_io/esp_gmf_io_file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ static esp_gmf_err_t _file_open(esp_gmf_io_handle_t io)
111111
ESP_GMF_MEM_VERIFY(TAG, file_io->cache, { fclose(file_io->file); return ESP_GMF_ERR_MEMORY_LACK;},
112112
"file stream cache", file_io->cache_size);
113113
setvbuf(file_io->file, (char *)file_io->cache, _IOFBF, file_io->cache_size);
114+
ESP_LOGD(TAG, "File_io cache: %p, size: %d, caps: 0x%x", file_io->cache, file_io->cache_size, file_io->cache_caps);
114115
}
115116

116117
file_io->is_open = true;
@@ -287,10 +288,9 @@ esp_gmf_err_t esp_gmf_io_file_init(file_io_cfg_t *config, esp_gmf_io_handle_t *i
287288
if (cfg->cache_size <= IO_FILE_DEFAULT_CACHE_ALIGN) {
288289
file_io->cache_size = 0;
289290
} else {
290-
file_io->cache_caps = (cfg->cache_caps == 0) ? (MALLOC_CAP_INTERNAL | MALLOC_CAP_CACHE_ALIGNED) : cfg->cache_caps;
291+
file_io->cache_caps = (cfg->cache_caps == 0) ? (MALLOC_CAP_DMA) : cfg->cache_caps;
291292
file_io->cache_size = IO_FILE_ALIGN_UP(cfg->cache_size, IO_FILE_DEFAULT_CACHE_ALIGN);
292293
}
293-
ESP_LOGD(TAG, "Initialization, %s-%p, cache_size: %d", OBJ_GET_TAG(obj), file_io, file_io->cache_size);
294294
return ESP_GMF_ERR_OK;
295295
_file_fail:
296296
esp_gmf_obj_delete(obj);

elements/gmf_io/idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "0.7.2"
1+
version: "0.7.3"
22
description: Espressif GMF IO Module
33
url: https://github.com/espressif/esp-gmf/tree/main/elements/gmf_io
44
documentation: "https://github.com/espressif/esp-gmf/blob/main/elements/gmf_io/README.md"

elements/gmf_io/include/esp_gmf_io_file.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@ typedef struct {
2121
const char *name; /*!< Name for this instance */
2222
int cache_size; /*!< Cache size for file IO operations in bytes. If size <= 512, it will be set to 0.
2323
Note: Larger cache size will improve read and write performance but consume more memory */
24-
int cache_caps; /*!< Cache memory capabilities, if zero then it will be set to (MALLOC_CAP_INTERNAL | MALLOC_CAP_CACHE_ALIGNED).
25-
Note: If chips have SOC_SDMMC_PSRAM_DMA_CAPABLE capability(such as ESP32P4),
26-
then you can set (MALLOC_CAP_SPIRAM | MALLOC_CAP_CACHE_ALIGNED) to save SRAM */
24+
int cache_caps; /*!< Cache memory capabilities, if zero then it will be set to MALLOC_CAP_DMA.
25+
Note:
26+
1. If chips have SOC_SDMMC_PSRAM_DMA_CAPABLE capability(such as ESP32P4),
27+
then you can set (MALLOC_CAP_SPIRAM | MALLOC_CAP_DMA) to save SRAM
28+
2. For ESP32, should use (MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT) or MALLOC_CAP_DMA caps to malloc cache
29+
3. For ESP32Sxx and ESP32Cxx, can also use MALLOC_CAP_INTERNAL caps to malloc cache */
2730
} file_io_cfg_t;
2831

2932
#define FILE_IO_CFG_DEFAULT() { \

0 commit comments

Comments
 (0)