Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to prioritize DRAM allocation over IRAM (GIT8266O-786) #1210

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions components/heap/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,12 @@ menu "Heap memory"
help
Enables heap tracing API.

config HEAP_PRIO_8BIT_RAM
bool "Prioritize allocation of 8-bit access capable RAM"
default n
depends on !HEAP_DISABLE_IRAM
help
Set DRAM region ahead of IRAM region during initialization, so that allocations
can be made against it first.

endmenu
18 changes: 18 additions & 0 deletions components/heap/port/esp8266/esp_heap_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,23 @@ void heap_caps_init(void)
extern char _bss_end;
size_t heap_region_num = 0;

#if CONFIG_HEAP_PRIO_8BIT_RAM
g_heap_region[heap_region_num].start_addr = (uint8_t *)&_bss_end;
g_heap_region[heap_region_num].total_size = ((size_t)(0x40000000 - (uint32_t)&_bss_end));
g_heap_region[heap_region_num].caps = MALLOC_CAP_8BIT | MALLOC_CAP_32BIT | MALLOC_CAP_DMA;
heap_region_num++;

// CONFIG_HEAP_PRIO_8BIT_RAM is only available when CONFIG_HEAP_DISABLE_IRAM=n
extern char _iram_end;
const size_t iram_size = 0x40100000 + CONFIG_SOC_IRAM_SIZE - ((size_t)&_iram_end);

if (iram_size > HEAP_REGION_IRAM_MIN && iram_size < HEAP_REGION_IRAM_MAX) {
g_heap_region[heap_region_num].start_addr = (uint8_t *)&_iram_end;
g_heap_region[heap_region_num].total_size = iram_size;
g_heap_region[heap_region_num].caps = MALLOC_CAP_32BIT | MALLOC_CAP_EXEC;
heap_region_num++;
}
#else
#ifndef CONFIG_HEAP_DISABLE_IRAM
extern char _iram_end;
const size_t iram_size = 0x40100000 + CONFIG_SOC_IRAM_SIZE - ((size_t)&_iram_end);
Expand All @@ -55,6 +72,7 @@ void heap_caps_init(void)
g_heap_region[heap_region_num].total_size = ((size_t)(0x40000000 - (uint32_t)&_bss_end));
g_heap_region[heap_region_num].caps = MALLOC_CAP_8BIT | MALLOC_CAP_32BIT | MALLOC_CAP_DMA;
heap_region_num++;
#endif

esp_heap_caps_init_region(g_heap_region, heap_region_num);
}