文章目录
1 ESP32-DevKitC V4(ESP32-WROVER-E&IE)板载信息
2 ESP32-DevKitC V4(ESP32-WROVER-E&IE)板载资源
2.1 在工程中使用函数查询可用堆大小等信息
-
在工程中使用函数查询可用堆大小等信息
esp_chip_info_t chip_info; esp_chip_info(&chip_info); printf("This is %s chip with %d CPU core(s), WiFi%s%s, ", CONFIG_IDF_TARGET, chip_info.cores, (chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "", (chip_info.features & CHIP_FEATURE_BLE) ? "/BLE" : ""); printf("silicon revision %d, ", chip_info.revision); printf("%dMB %s flash\n", spi_flash_get_chip_size() / (1024 * 1024), (chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external"); printf("free heap size: %d bytes\n", esp_get_free_heap_size()); printf("free internal heap size: %d bytes\n", esp_get_free_internal_heap_size()); printf("Minimum free heap size: %d bytes\n", esp_get_minimum_free_heap_size());
串口显示
2.2 在PowerShell使用指令esptool.py -p COM* flash_id
查询模组实际flash大小和芯片信息等数据
- 在PowerShell使用指令
esptool.py -p COM* flash_id
查询模组实际flash大小和芯片信息等数据
2.3 查询外部PSRAM信息
- 查询外部PSRAM信息
先选择支持外部RAM,打开menuconfig
菜单配置
再重新编译,烧录程序并打开串口数据
也可以在工程中调用相应函数查询
2.4 在PowerShell使用指令 idf.py size
打印应用程序相关的大小信息
3 FreeRTOS任务内存使用监控
参考文章
《FreeRTOS 接口: vTaskList() - 可优化内存和 task 栈溢出定位》
《FreeRTOS 接口: vTaskGetRunTimeStats() - 可解决 task watchdog 和调优 task 优先级》
-
如图勾选
-
编写测试程序
void esp_print_tasks(void)
{
char *runtimeinfo = (char *)calloc(1, 512);
char *pbuffer = (char *)calloc(1, 2048);
printf("--------------- heap:%lu ---------------------\r\n", esp_get_free_heap_size());
vTaskList(pbuffer);
printf("%s", pbuffer);
vTaskGetRunTimeStats(runtimeinfo);
printf("%s", runtimeinfo);
printf("----------------------------------------------\r\n");
free(pbuffer);
free(runtimeinfo);
}
void test_task(void *param)
{
while (1)
{
esp_print_tasks();
vTaskDelay(3000 / portTICK_PERIOD_MS);
}
}
void app_user_log_main(void)
{
xTaskCreate(test_task, "test_task", 2048, NULL, 5, NULL);
}
- 编译烧录并打开串口
注意,该方法要长时间监控才比较准确
第一列表示 task name, 即 xTaskCreate 传递进去的第二个参数, 如果名称过长, 会根据 configMAX_TASK_NAME_LEN 截断
第二列表示 task 当前执行状态
X: running
B: blocked
R: ready
D: deleted
S: suspended
详细参考 task.c 中
第三列表示 task 优先级, 即 xTaskCreate 传递进去的第四个参数
第四列表示该 task 运行过程中, 最小时候还剩余多少内存, 字节为单位.
如果剩余内存较多, 修改 xTaskCreate 第三个参数, 即可节省内存
第五列表示 task 创建顺序