环境:
板子:CH32V307VCT6 risc-v
OS:liteos-m
liteos使用外部堆内存会挂住,这是为啥?
修改:
链接脚本:Link.ld .stack段之前新增:
.heap :
{
. = ALIGN(8);
__los_heap_addr_start__ = .;
. = (ORIGIN(RAM) + LENGTH(RAM) - __stack_size - 9);
. = ALIGN(8);
__los_heap_addr_end__ = .;
} >RAM
配置文件:target_config.h 内存配置部分的修改:
#define LOSCFG_SYS_EXTERNAL_HEAP 1
extern uint32_t __los_heap_addr_start__;
extern uint32_t __los_heap_addr_end__;
#define LOSCFG_SYS_HEAP_ADDR (VOID*)(&__los_heap_addr_start__)
#define LOSCFG_SYS_HEAP_END (VOID*)(&__los_heap_addr_end__)
#define LOSCFG_SYS_HEAP_SIZE (LOSCFG_SYS_HEAP_END - LOSCFG_SYS_HEAP_ADDR)
内存初始化:los_memory.c::OsMemSystemInit这个函数里面会挂住