File tree 2 files changed +26
-0
lines changed
2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -13,4 +13,12 @@ menu "Heap memory"
13
13
help
14
14
Enables heap tracing API.
15
15
16
+ config HEAP_PRIO_8BIT_RAM
17
+ bool "Prioritize allocation of 8-bit access capable RAM"
18
+ default n
19
+ depends on !HEAP_DISABLE_IRAM
20
+ help
21
+ Set DRAM region ahead of IRAM region during initialization, so that allocations
22
+ can be made against it first.
23
+
16
24
endmenu
Original file line number Diff line number Diff line change @@ -39,6 +39,23 @@ void heap_caps_init(void)
39
39
extern char _bss_end ;
40
40
size_t heap_region_num = 0 ;
41
41
42
+ #if CONFIG_HEAP_PRIO_8BIT_RAM
43
+ g_heap_region [heap_region_num ].start_addr = (uint8_t * )& _bss_end ;
44
+ g_heap_region [heap_region_num ].total_size = ((size_t )(0x40000000 - (uint32_t )& _bss_end ));
45
+ g_heap_region [heap_region_num ].caps = MALLOC_CAP_8BIT | MALLOC_CAP_32BIT | MALLOC_CAP_DMA ;
46
+ heap_region_num ++ ;
47
+
48
+ // CONFIG_HEAP_PRIO_8BIT_RAM is only available when CONFIG_HEAP_DISABLE_IRAM=n
49
+ extern char _iram_end ;
50
+ const size_t iram_size = 0x40100000 + CONFIG_SOC_IRAM_SIZE - ((size_t )& _iram_end );
51
+
52
+ if (iram_size > HEAP_REGION_IRAM_MIN && iram_size < HEAP_REGION_IRAM_MAX ) {
53
+ g_heap_region [heap_region_num ].start_addr = (uint8_t * )& _iram_end ;
54
+ g_heap_region [heap_region_num ].total_size = iram_size ;
55
+ g_heap_region [heap_region_num ].caps = MALLOC_CAP_32BIT | MALLOC_CAP_EXEC ;
56
+ heap_region_num ++ ;
57
+ }
58
+ #else
42
59
#ifndef CONFIG_HEAP_DISABLE_IRAM
43
60
extern char _iram_end ;
44
61
const size_t iram_size = 0x40100000 + CONFIG_SOC_IRAM_SIZE - ((size_t )& _iram_end );
@@ -55,6 +72,7 @@ void heap_caps_init(void)
55
72
g_heap_region [heap_region_num ].total_size = ((size_t )(0x40000000 - (uint32_t )& _bss_end ));
56
73
g_heap_region [heap_region_num ].caps = MALLOC_CAP_8BIT | MALLOC_CAP_32BIT | MALLOC_CAP_DMA ;
57
74
heap_region_num ++ ;
75
+ #endif
58
76
59
77
esp_heap_caps_init_region (g_heap_region , heap_region_num );
60
78
}
You can’t perform that action at this time.
0 commit comments