Skip to content

Commit 6a4ec9d

Browse files
isthaisonn2flowjs-bot78
authored
feat: add support for ESP32-P4-Function-EV-Board (#1210)
* feat: add support for ESP32-P4-Function-EV-Board with configuration and display handling * detect wake word model from index.json * update wait time before entering wifi configure mode * feat: Enhance ESP32-P4 Function EV Board support with LCD and touch initialization * feat: Update ESP32-P4 Function EV Board configuration for improved touch and SD card support * feat: add touch I2C configuration and improve initialization structure * Remove ESP hosted configuration from defaults Removed ESP hosted configuration options. * chore: update documentation for improved clarity * refactor: remove obsolete files for ESP32-P4-Function-EV-Board and add updated configurations * refactor: reintroduce ESP32-P4-Function-EV-Board implementation with updated configurations * refactor: restore esp32_p4_function_ev_board dependency with updated version --------- Co-authored-by: n2flowjs-bot <[email protected]> Co-authored-by: Terrence <[email protected]>
1 parent 7a85430 commit 6a4ec9d

File tree

9 files changed

+215
-2
lines changed

9 files changed

+215
-2
lines changed

main/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,8 @@ elseif(CONFIG_BOARD_TYPE_ESP32P4_WIFI6_Touch_LCD_XC)
303303
set(BUILTIN_TEXT_FONT font_puhui_basic_30_4)
304304
set(BUILTIN_ICON_FONT font_awesome_30_4)
305305
set(DEFAULT_EMOJI_COLLECTION twemoji_64)
306+
elseif(CONFIG_BOARD_TYPE_ESP32P4_Function_EV_Board)
307+
set(BOARD_TYPE "esp-p4-function-ev-board")
306308
elseif(CONFIG_BOARD_TYPE_BREAD_COMPACT_WIFI_LCD)
307309
set(BOARD_TYPE "bread-compact-wifi-lcd")
308310
set(BUILTIN_TEXT_FONT font_puhui_basic_16_4)

main/Kconfig.projbuild

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,9 @@ choice BOARD_TYPE
290290
config BOARD_TYPE_ESP32P4_WIFI6_Touch_LCD_XC
291291
bool "Waveshare ESP32-P4-WIFI6-Touch-LCD-3.4C or ESP32-P4-WIFI6-Touch-LCD-4C"
292292
depends on IDF_TARGET_ESP32P4
293+
config BOARD_TYPE_ESP_P4_Function_EV_Board
294+
bool "ESP-P4-Function-EV-Board"
295+
depends on IDF_TARGET_ESP32P4
293296
config BOARD_TYPE_TUDOUZI
294297
bool "土豆子"
295298
depends on IDF_TARGET_ESP32S3

main/audio/wake_words/custom_wake_word.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ bool CustomWakeWord::Initialize(AudioCodec* codec, srmodel_list_t* models_list)
107107

108108
// 初始化 multinet (命令词识别)
109109
mn_name_ = esp_srmodel_filter(models_, ESP_MN_PREFIX, language_.c_str());
110+
if (mn_name_ == nullptr) {
111+
ESP_LOGW(TAG, "Language '%s' multinet not found, falling back to any multinet model", language_.c_str());
112+
mn_name_ = esp_srmodel_filter(models_, ESP_MN_PREFIX, NULL);
113+
}
110114
if (mn_name_ == nullptr) {
111115
ESP_LOGE(TAG, "Failed to initialize multinet, mn_name is nullptr");
112116
ESP_LOGI(TAG, "Please refer to https://pcn7cs20v8cr.feishu.cn/wiki/CpQjwQsCJiQSWSkYEvrcxcbVnwh to add custom wake word");
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# ESP-P4-Function-EV-Board
2+
3+
Board support for ESP-P4-Function-EV-Board. Wi‑Fi uses ESP‑Hosted via the on‑board ESP32‑C6. LCD is supported via the official MIPI‑DSI LCD adapter.
4+
5+
## Features
6+
- Wi‑Fi: `esp_wifi_remote` + `esp_hosted` (SDIO) with ESP32‑C6 co‑processor
7+
- Display: 7" MIPI‑DSI LCD (1024×600) via adapter; can also run headless
8+
- Audio: Can run with dummy codec; board includes ES8311 + PA if needed
9+
10+
## Configure
11+
In `menuconfig`: Xiaozhi Assistant -> Board Type -> ESP-P4-Function-EV-Board
12+
13+
Ensure these are set (auto-set when building via config.json):
14+
- `CONFIG_SLAVE_IDF_TARGET_ESP32C6=y`
15+
- `CONFIG_ESP_HOSTED_P4_DEV_BOARD_FUNC_BOARD=y`
16+
- `CONFIG_ESP_HOSTED_SDIO_HOST_INTERFACE=y`
17+
- `CONFIG_ESP_HOSTED_SDIO_4_BIT_BUS=y`
18+
19+
## LCD Connection (from Espressif user guide)
20+
- Connect the LCD adapter board J3 to the board’s MIPI DSI connector (reverse ribbon).
21+
- Wire `RST_LCD` (adapter J6) to `GPIO27` (board J1).
22+
- Wire `PWM` (adapter J6) to `GPIO26` (board J1).
23+
- Optionally power the LCD adapter via its USB or provide `5V` and `GND` from the board.
24+
25+
These pins are pre-configured in `config.h` as `PIN_NUM_LCD_RST=GPIO27` and `DISPLAY_BACKLIGHT_PIN=GPIO26`. Resolution is set to 1024×600.
26+
27+
## Build (example)
28+
```powershell
29+
idf.py set-target esp32p4
30+
idf.py menuconfig
31+
idf.py build
32+
```
33+
34+
Tip: In menuconfig, choose Xiaozhi Assistant -> Board Type -> ESP-P4-Function-EV-Board.
35+
If building a release via scripts, the `config.json` in this folder appends the required Hosted options.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#ifndef _BOARD_CONFIG_H_
2+
#define _BOARD_CONFIG_H_
3+
4+
#include "bsp/esp32_p4_function_ev_board.h" // Library for board configs and pins
5+
6+
#define AUDIO_INPUT_SAMPLE_RATE 24000
7+
#define AUDIO_OUTPUT_SAMPLE_RATE 24000
8+
9+
#define DISPLAY_BACKLIGHT_OUTPUT_INVERT false
10+
11+
#endif // _BOARD_CONFIG_H_
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"target": "esp32p4",
3+
"builds": [
4+
{
5+
"name": "esp-p4-function-ev-board",
6+
"sdkconfig_append": [
7+
"CONFIG_SLAVE_IDF_TARGET_ESP32C6=y",
8+
"CONFIG_ESP_HOSTED_P4_DEV_BOARD_FUNC_BOARD=y",
9+
"CONFIG_ESP_HOSTED_SDIO_HOST_INTERFACE=y",
10+
"CONFIG_ESP_HOSTED_SDIO_4_BIT_BUS=y",
11+
"CONFIG_SPI_FLASH_SUPPORT_GD_CHIP=y",
12+
"CONFIG_BSP_LCD_TYPE_1024_600=y"
13+
]
14+
}
15+
]
16+
}
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
#include "wifi_board.h"
2+
#include "audio/codecs/es8311_audio_codec.h"
3+
// Display
4+
#include "display/display.h"
5+
#include "display/lcd_display.h"
6+
// Backlight
7+
// PwmBacklight is declared in backlight headers pulled by display/lcd_display includes via lvgl stack
8+
9+
#include "application.h"
10+
#include "button.h"
11+
#include "config.h"
12+
13+
#include <wifi_station.h>
14+
#include <esp_log.h>
15+
#include <inttypes.h>
16+
#include <driver/i2c_master.h>
17+
#include <esp_lvgl_port.h>
18+
// SD card
19+
#include <esp_vfs_fat.h>
20+
#include <sdmmc_cmd.h>
21+
#include <driver/sdmmc_host.h>
22+
#include <driver/sdspi_host.h>
23+
// SD power control (on-chip LDO)
24+
#include "sd_pwr_ctrl_by_on_chip_ldo.h"
25+
26+
// MIPI-DSI / LCD vendor includes (library may replace some)
27+
#include "esp_lcd_panel_ops.h"
28+
#include "esp_lcd_mipi_dsi.h"
29+
#include "esp_ldo_regulator.h"
30+
#include "esp_lcd_ek79007.h"
31+
#include "esp_lcd_touch_gt911.h"
32+
33+
// Library includes
34+
#include "bsp/esp32_p4_function_ev_board.h"
35+
#include "bsp/touch.h"
36+
37+
#define TAG "ESP32P4FuncEV"
38+
39+
class ESP32P4FunctionEvBoard : public WifiBoard
40+
{
41+
private:
42+
i2c_master_bus_handle_t codec_i2c_bus_ = nullptr;
43+
Button boot_button_;
44+
LcdDisplay *display_ = nullptr;
45+
esp_lcd_touch_handle_t tp_ = nullptr;
46+
47+
void InitializeI2cBuses()
48+
{
49+
ESP_ERROR_CHECK(bsp_i2c_init());
50+
codec_i2c_bus_ = bsp_i2c_get_handle();
51+
}
52+
53+
// Touch I2C bus initialization is not required for this board (handled elsewhere)
54+
void InitializeTouchI2cBus()
55+
{
56+
// No implementation needed
57+
}
58+
59+
void InitializeLCD()
60+
{
61+
bsp_display_config_t config = {
62+
.hdmi_resolution = BSP_HDMI_RES_NONE,
63+
.dsi_bus = {
64+
.phy_clk_src = MIPI_DSI_PHY_CLK_SRC_DEFAULT,
65+
.lane_bit_rate_mbps = 1000,
66+
},
67+
};
68+
69+
bsp_lcd_handles_t handles;
70+
ESP_ERROR_CHECK(bsp_display_new_with_handles(&config, &handles));
71+
72+
display_ = new MipiLcdDisplay(handles.io, handles.panel, 1024, 600, 0, 0, true, true, false);
73+
}
74+
75+
void InitializeButtons()
76+
{
77+
boot_button_.OnClick([this]()
78+
{
79+
auto& app = Application::GetInstance();
80+
if (app.GetDeviceState() == kDeviceStateStarting && !WifiStation::GetInstance().IsConnected()) {
81+
ResetWifiConfiguration();
82+
}
83+
app.ToggleChatState(); });
84+
}
85+
86+
void InitializeTouch()
87+
{
88+
ESP_ERROR_CHECK(bsp_touch_new(NULL, &tp_));
89+
}
90+
91+
public:
92+
93+
ESP32P4FunctionEvBoard() : boot_button_(0)
94+
{
95+
InitializeI2cBuses();
96+
// Audio is initialized by Es8311AudioCodec
97+
InitializeLCD();
98+
InitializeButtons();
99+
InitializeTouch();
100+
GetBacklight()->RestoreBrightness();
101+
}
102+
103+
~ESP32P4FunctionEvBoard()
104+
{
105+
// Clean up display pointer
106+
delete display_;
107+
display_ = nullptr;
108+
// If other resources need cleanup, add here
109+
}
110+
111+
virtual AudioCodec *GetAudioCodec() override
112+
{
113+
static Es8311AudioCodec audio_codec(
114+
codec_i2c_bus_, (i2c_port_t)BSP_I2C_NUM, AUDIO_INPUT_SAMPLE_RATE, AUDIO_OUTPUT_SAMPLE_RATE,
115+
BSP_I2S_MCLK, BSP_I2S_SCLK, BSP_I2S_LCLK, BSP_I2S_DOUT, BSP_I2S_DSIN,
116+
BSP_POWER_AMP_IO, ES8311_CODEC_DEFAULT_ADDR, true, false);
117+
return &audio_codec;
118+
}
119+
120+
virtual Display *GetDisplay() override { return display_; }
121+
122+
virtual Backlight *GetBacklight() override
123+
{
124+
static PwmBacklight backlight(BSP_LCD_BACKLIGHT, DISPLAY_BACKLIGHT_OUTPUT_INVERT);
125+
return &backlight;
126+
}
127+
};
128+
129+
DECLARE_BOARD(ESP32P4FunctionEvBoard);

main/display/lcd_display.cc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,14 @@ SpiLcdDisplay::SpiLcdDisplay(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_h
100100

101101
// Set the display to on
102102
ESP_LOGI(TAG, "Turning display on");
103-
ESP_ERROR_CHECK(esp_lcd_panel_disp_on_off(panel_, true));
103+
{
104+
esp_err_t __err = esp_lcd_panel_disp_on_off(panel_, true);
105+
if (__err == ESP_ERR_NOT_SUPPORTED) {
106+
ESP_LOGW(TAG, "Panel does not support disp_on_off; assuming ON");
107+
} else {
108+
ESP_ERROR_CHECK(__err);
109+
}
110+
}
104111

105112
ESP_LOGI(TAG, "Initialize LVGL library");
106113
lv_init();
@@ -165,6 +172,7 @@ SpiLcdDisplay::SpiLcdDisplay(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_h
165172
SetupUI();
166173
}
167174

175+
168176
// RGB LCD实现
169177
RgbLcdDisplay::RgbLcdDisplay(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_handle_t panel,
170178
int width, int height, int offset_x, int offset_y,

main/idf_component.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ dependencies:
55
espressif/esp_lcd_gc9a01: ==2.0.1
66
espressif/esp_lcd_st77916: ^1.0.1
77
espressif/esp_lcd_axs15231b: ^1.0.0
8+
89
espressif/esp_lcd_st7701:
910
version: ^1.1.4
1011
rules:
@@ -22,7 +23,7 @@ dependencies:
2223
78/esp-ml307: ~3.3.6
2324
78/xiaozhi-fonts: ~1.5.4
2425
espressif/led_strip: ~3.0.1
25-
espressif/esp_codec_dev: ~1.4.0
26+
espressif/esp_codec_dev: ~1.5
2627
espressif/esp-sr: ~2.1.5
2728
espressif/button: ~4.1.3
2829
espressif/knob: ^1.0.0
@@ -65,6 +66,10 @@ dependencies:
6566
version: '*'
6667
rules:
6768
- if: target in [esp32p4]
69+
espressif/esp32_p4_function_ev_board:
70+
version: "^5.0.3"
71+
rules:
72+
- if: target in [esp32p4]
6873
espressif/esp_lcd_ili9881c:
6974
version: ^1.0.1
7075
rules:

0 commit comments

Comments
 (0)