43集 ESP32 编译调试出错的解决方法汇总

43集 ESP32 编译调试出错的解决方法汇总

1、提示找不到如下头文件,分别对应adf的component

在这里插入图片描述#include “esp_peripherals.h” esp_peripherals
#include “audio_element.h” audio_pipeline
#include “audio_common.h” audio_pipeline
这几个头文件都是esp-adf里面的控件,所以考虑是esp-adf的环境目录没有加进去。
在这里插入图片描述
解决方法:
在项目根目录中修改CMakeLists.txt
在这里插入图片描述

2、提示error: unknown type name ‘xTimerHandle’; did you mean ‘TimerHandle_t’?

79 | typedef void (*timer_callback)(xTimerHandle tmr);
在这里插入图片描述
这个应该是版本的问题,之前应该有rtos有个patch,我们只打在5.1上,5.2应该没有打。
所以在terminal上打上patch
cd D:\Espressif\v5.2\esp-idf
之后输入git apply D:\Espressif\esp-adf\idf_patches\idf_v5.2_freertos.patch
在这里插入图片描述
出现错误有可能是之前有改动,直接git checkout 更新一下之后在git apply

在这里插入图片描述
patch成功。
之后编译还是有错误,我们看到引用的头文件是d:\Espressif\v5.2\esp-idf\components\freertos\FreeRTOS-Kernel-SMP\include\freertos\FreeRTOS.h ,
所以在重新配置一下menuconfig,配置freertos选项如下:
在这里插入图片描述
之后还要把这个选项打开
在这里插入图片描述
这里面是向前兼容的,
程序里面需要把这个宏打开:
或者在sdkconfig.default 中加入CONFIG_FREERTOS_ENABLE_BACKWARD_COMPATIBILITY=y
在这里插入图片描述

之后在重新编译。

出错assert
在这里插入图片描述

0x40386f8d: __assert_func at D:/Espressif/v5.1/esp-idf/components/newlib/assert.c:81
0x4201466b: esp_lcd_touch_read_data at D:/workspace/esp-idf/ai_chat_esp32c3/managed_components/espressif__esp_lcd_touch/esp_lcd_touch.c:55 (discriminator 1)
这里有个assert,应该是没有初始化成功。

3、fatal error: baidu_access_token.h

在最上层的CMakeLists.txt中加入:
include($ENV{ADF_PATH}/CMakeLists.txt)

4、E (41361) lcd_panel.io.spi: panel_io_spi_tx_color(391): spi transmit (queue) color failed

这个问题是因为task过多,语音检测和屏幕实时刷新冲突

5、 E (37453) cam_hal: cam_dma_config(316): DMA buffer 30720 Byte malloc failed, the current largest free block:1484

8 Byte
E (37473) cam_hal: cam_config(389): cam_dma_config failed
E (37473) gdma: gdma_disconnect(238): no peripheral is connected to the channel
E (37493) camera: Camera config failed with error 0xffffffff
E (37493) esp32_s3_szp: Camera init failed with error 0xffffffff

这个问题是在打开WiFi链接后出现的。
ram不够用了。
修改如下:
bsp_camera_init 中的
config.jpeg_quality = 16;//config.jpeg_quality = 12;
config.fb_count = 1;//config.fb_count = 2;

6、create_ssl_handle failed

E (41765) esp-tls-mbedtls: No server verification option set in esp_tls_cfg_t structure. Check esp_tls API refer
ence
E (41765) esp-tls-mbedtls: Failed to set client configurations, returned [0x8017] (ESP_ERR_MBEDTLS_SSL_SETUP_FAI
LED)
E (41785) esp-tls: create_ssl_handle failed,hostname=openapi.baidu.com,len=17
E (41785) esp-tls: Failed to open new connection
E (41795) transport_base: Failed to open a new connection
E (41805) HTTP_CLIENT: Connection failed, sock < 0
E (41815) BAIDU_AUTH: Error open http request to baidu auth server

这个应该是
CONFIG_ESP_TLS_INSECURE=y
CONFIG_ESP_TLS_SKIP_SERVER_CERT_VERIFY=y