1. 固定 RTC 数字人链路使用 ai_chat_ui_eaf,双模式开启后不再回退 LVGL/GIF 旧 RTC UI。 2. 保留电子吧唧 LVGL/SquareLine UI,只在电子吧唧运行模式启动 LVGL,避免与 EAF 抢同一 LCD flush。 3. 拆分 dzbj_hw_display_init 与 dzbj_display_init,AI/配网只初始化 LCD Touch 硬件,电子吧唧再启动 LVGL UI。 4. 配网模式使用 EAF 最小显示栈显示中文提示,请使用APP 蓝牙配网,不加载数字人资源和动画。 5. 开启 CONFIG_BAJI_BADGE_MODE,形成 RTC 数字人对话与电子吧唧图片显示双模式固件。 6. 电子吧唧图片扫描跳过 Background_360x360.jpg,避免 RTC 数字人背景进入吧唧图片列表。 7. BLE 图传在 BLE 5.0 关闭时跳过 2M PHY API,保持 legacy 1M PHY 兼容配网和图传。 8. sdkconfig.defaults 同步 BLE 内存优化,限制连接数和缓存,保留 GATT 与扫描能力。 9. 移除 ota.cc 编译和 app_update 直接依赖,双模式固件不创建 OTA 检查任务。 10. Ota 接口改为禁用 stub,保留接口兼容但不执行升级和版本检查。 11. Board 上报 JSON 的 OTA label 改为 disabled,避免依赖 OTA 运行分区。 12. partitions.csv 改为 factory 单 app 分区,扩大 app 到 0x900000,并扩大 storage 到 0x6F0000。 13. application 去除 OTA 任务句柄和服务器时间依赖,减少运行时资源占用。 14. system_info 去除 esp_ota_ops 依赖,配合无 OTA 分区配置。 15. 同步最新烧录运行日志,记录本轮双模式与配网测试结果。
135 lines
4.2 KiB
C++
135 lines
4.2 KiB
C++
#include "system_info.h"
|
|
|
|
#include <freertos/task.h>
|
|
#include <esp_log.h>
|
|
#include <esp_flash.h>
|
|
#include <esp_mac.h>
|
|
#include <esp_system.h>
|
|
#include <esp_partition.h>
|
|
#include <esp_app_desc.h>
|
|
|
|
|
|
#define TAG "SystemInfo"
|
|
|
|
size_t SystemInfo::GetFlashSize() {
|
|
uint32_t flash_size;
|
|
if (esp_flash_get_size(NULL, &flash_size) != ESP_OK) {
|
|
ESP_LOGE(TAG, "Failed to get flash size");
|
|
return 0;
|
|
}
|
|
return (size_t)flash_size;
|
|
}
|
|
|
|
size_t SystemInfo::GetMinimumFreeHeapSize() {
|
|
return esp_get_minimum_free_heap_size();
|
|
}
|
|
|
|
size_t SystemInfo::GetFreeHeapSize() {
|
|
return esp_get_free_heap_size();
|
|
}
|
|
|
|
std::string SystemInfo::GetMacAddress() {
|
|
uint8_t mac[6];
|
|
esp_read_mac(mac, ESP_MAC_WIFI_STA);
|
|
char mac_str[18];
|
|
snprintf(mac_str, sizeof(mac_str), "%02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
|
return std::string(mac_str);
|
|
}
|
|
|
|
std::string SystemInfo::GetBleMacAddress() {
|
|
uint8_t mac[6];
|
|
esp_read_mac(mac, ESP_MAC_BT);
|
|
char mac_str[18];
|
|
snprintf(mac_str, sizeof(mac_str), "%02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
|
return std::string(mac_str);
|
|
}
|
|
|
|
std::string SystemInfo::GetChipModelName() {
|
|
return std::string(CONFIG_IDF_TARGET);
|
|
}
|
|
|
|
esp_err_t SystemInfo::PrintRealTimeStats(TickType_t xTicksToWait) {
|
|
#define ARRAY_SIZE_OFFSET 5
|
|
TaskStatus_t *start_array = NULL, *end_array = NULL;
|
|
UBaseType_t start_array_size, end_array_size;
|
|
configRUN_TIME_COUNTER_TYPE start_run_time, end_run_time;
|
|
esp_err_t ret;
|
|
uint32_t total_elapsed_time;
|
|
|
|
//Allocate array to store current task states
|
|
start_array_size = uxTaskGetNumberOfTasks() + ARRAY_SIZE_OFFSET;
|
|
start_array = (TaskStatus_t*)malloc(sizeof(TaskStatus_t) * start_array_size);
|
|
if (start_array == NULL) {
|
|
ret = ESP_ERR_NO_MEM;
|
|
goto exit;
|
|
}
|
|
//Get current task states
|
|
start_array_size = uxTaskGetSystemState(start_array, start_array_size, &start_run_time);
|
|
if (start_array_size == 0) {
|
|
ret = ESP_ERR_INVALID_SIZE;
|
|
goto exit;
|
|
}
|
|
|
|
vTaskDelay(xTicksToWait);
|
|
|
|
//Allocate array to store tasks states post delay
|
|
end_array_size = uxTaskGetNumberOfTasks() + ARRAY_SIZE_OFFSET;
|
|
end_array = (TaskStatus_t*)malloc(sizeof(TaskStatus_t) * end_array_size);
|
|
if (end_array == NULL) {
|
|
ret = ESP_ERR_NO_MEM;
|
|
goto exit;
|
|
}
|
|
//Get post delay task states
|
|
end_array_size = uxTaskGetSystemState(end_array, end_array_size, &end_run_time);
|
|
if (end_array_size == 0) {
|
|
ret = ESP_ERR_INVALID_SIZE;
|
|
goto exit;
|
|
}
|
|
|
|
//Calculate total_elapsed_time in units of run time stats clock period.
|
|
total_elapsed_time = (end_run_time - start_run_time);
|
|
if (total_elapsed_time == 0) {
|
|
ret = ESP_ERR_INVALID_STATE;
|
|
goto exit;
|
|
}
|
|
|
|
printf("| Task | Run Time | Percentage\n");
|
|
//Match each task in start_array to those in the end_array
|
|
for (int i = 0; i < start_array_size; i++) {
|
|
int k = -1;
|
|
for (int j = 0; j < end_array_size; j++) {
|
|
if (start_array[i].xHandle == end_array[j].xHandle) {
|
|
k = j;
|
|
//Mark that task have been matched by overwriting their handles
|
|
start_array[i].xHandle = NULL;
|
|
end_array[j].xHandle = NULL;
|
|
break;
|
|
}
|
|
}
|
|
//Check if matching task found
|
|
if (k >= 0) {
|
|
uint32_t task_elapsed_time = end_array[k].ulRunTimeCounter - start_array[i].ulRunTimeCounter;
|
|
uint32_t percentage_time = (task_elapsed_time * 100UL) / (total_elapsed_time * CONFIG_FREERTOS_NUMBER_OF_CORES);
|
|
printf("| %-16s | %8lu | %4lu%%\n", start_array[i].pcTaskName, task_elapsed_time, percentage_time);
|
|
}
|
|
}
|
|
|
|
//Print unmatched tasks
|
|
for (int i = 0; i < start_array_size; i++) {
|
|
if (start_array[i].xHandle != NULL) {
|
|
printf("| %s | Deleted\n", start_array[i].pcTaskName);
|
|
}
|
|
}
|
|
for (int i = 0; i < end_array_size; i++) {
|
|
if (end_array[i].xHandle != NULL) {
|
|
printf("| %s | Created\n", end_array[i].pcTaskName);
|
|
}
|
|
}
|
|
ret = ESP_OK;
|
|
|
|
exit: //Common return path
|
|
free(start_array);
|
|
free(end_array);
|
|
return ret;
|
|
}
|