Skip to content

Commit 6515dd3

Browse files
andrew-mtkkv2019i
authored andcommitted
zephyr: alloc: Limit heap size on MTK platforms
MTK platforms are built with CONFIG_SYS_HEAP_SMALL_ONLY. If heap size is greater than 0x7fff chunk units, it throws an assert at boot. Signed-off-by: Andrew Perepech <andrew.perepech@mediatek.com>
1 parent 9f48a3a commit 6515dd3

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

zephyr/lib/alloc.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,13 @@ extern char _mtk_adsp_sram_end;
124124
#define SRAM_SIZE DT_REG_SIZE(DT_NODELABEL(sram0))
125125
#define SRAM_END (SRAM_START + SRAM_SIZE)
126126
#define heapmem ((uint8_t *)ALIGN_UP((uintptr_t)&_mtk_adsp_sram_end, PLATFORM_DCACHE_ALIGN))
127+
128+
/* Heap size is limited to 0x7fffU chunk units when CONFIG_SYS_HEAP_SMALL_ONLY is set */
129+
#if defined(CONFIG_SYS_HEAP_SMALL_ONLY)
130+
#define HEAPMEM_SIZE MIN(((uint8_t *)SRAM_END - heapmem), 0x7fff * 8)
131+
#else
127132
#define HEAPMEM_SIZE ((uint8_t *)SRAM_END - heapmem)
133+
#endif /* CONFIG_SYS_HEAP_SMALL_ONLY */
128134

129135
#else
130136

0 commit comments

Comments
 (0)