Page 1 of 1

esp32 idf 内存段指定问题

Posted: Fri Feb 18, 2022 5:18 am
by abcliuleihua
我想定义一些变量到自定义内存段,链接脚本里已经做了相应修改,目前测试发现很奇怪,只能将变量定义到maic.c中测试是可以的,但如果定义到别的.c中始终不行(map中看不到该变量)
int rr(int argc, char **argv)
{
printf("aaaaaaa\r\n");return 0;
}
const esp_console_cmd_t r __attribute__((section(".console_cmd_lib"))) = {
.command = "heap",
.help = "Get minimum size of free heap memory that was available during program execution",
.hint = NULL,
.func = rr,
};

Re: esp32 idf 内存段指定问题

Posted: Fri Feb 18, 2022 9:28 am
by ESP_morris
因为“别的.c” 并没有函数被实际链接进去,在那里定义的console_cmd_lib section也不会被链进去