Skip to content

Commit 296e037

Browse files
boards/lckfb-szpi-esp32s3: add ES7210 board support
Add board-level support for ES7210 4-ch ADC on lckfb-szpi-esp32s3: - configs/es7210/defconfig: Board configuration with I2C0, I2S0, ES7210 driver enabled. I2S pins: BCLK=14, DIN=12, MCLK=38, WS=13, sample rate 48kHz. - src/esp32s3_board_es7210.c: Board init registering ES7210 on I2C0 bus with I2S0 as audio transport - src/esp32s3_bringup.c: Call ES7210 board init on startup; skip generic I2S audio device registration on I2S0 when ES7210 is enabled to avoid conflicting audio device on the same port - src/esp32s3-szpi.h: ES7210 I2C address and device path defines - src/Make.defs: Build integration for CONFIG_AUDIO_ES7210 Tested: 48kHz/2ch/16bit recording on ESP32-S3 (lckfb-szpi N16R8), verified with nxrecorder and es7210_test. Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
1 parent 7365733 commit 296e037

6 files changed

Lines changed: 291 additions & 15 deletions

File tree

Documentation/platforms/xtensa/esp32s3/boards/lckfb-szpi-esp32s3/index.rst

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,43 @@ Then run the adb command::
116116
nsh> uname -a
117117
NuttX 0.0.0 Mar 21 2025 14:25:36 xtensa lckfb-szpi-esp32s3
118118

119+
es7210
120+
------
121+
122+
Basic NuttShell configuration with ES7210 4-channel ADC audio codec support
123+
over USB ADB. The ES7210 is connected via I2C0 (address 0x41) and I2S0 RX,
124+
enabling audio recording through the on-board microphones.
125+
126+
The I2S0 RX pin mapping is as follows:
127+
128+
======= ======
129+
Signal GPIO
130+
======= ======
131+
BCLK GPIO14
132+
DIN GPIO12
133+
MCLK GPIO38
134+
WS GPIO13
135+
======= ======
136+
137+
You can run the configuration and compilation procedure::
138+
139+
$ ./tools/configure.sh lckfb-szpi-esp32s3:es7210
140+
$ make flash ESPTOOL_PORT=/dev/ttyUSB0 -j
141+
142+
Then record audio using nxrecorder::
143+
144+
$ adb -s 1234 shell
145+
nsh> nxrecorder
146+
nxrecorder> device /dev/audio/pcm_in0
147+
nxrecorder> recordraw /tmp/test.pcm 2 16 48000
148+
nxrecorder> stop
149+
nxrecorder> q
150+
151+
Pull the recorded file to the host and convert to WAV::
152+
153+
$ adb -s 1234 pull /tmp/test.pcm .
154+
$ ffmpeg -f s16le -ar 48000 -ac 2 -i test.pcm test.wav
155+
119156
txtable
120157
-------
121158

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#
2+
# This file is autogenerated: PLEASE DO NOT EDIT IT.
3+
#
4+
# You can use "make menuconfig" to make any modifications to the installed .config file.
5+
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
6+
# modifications.
7+
#
8+
# CONFIG_ARCH_LEDS is not set
9+
# CONFIG_ESPRESSIF_I2S0_TX is not set
10+
# CONFIG_NSH_ARGCAT is not set
11+
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
12+
CONFIG_ADBD_FILE_SERVICE=y
13+
CONFIG_ADBD_SHELL_SERVICE=y
14+
CONFIG_ADBD_STACKSIZE=8192
15+
CONFIG_ADBD_USB_BOARDCTL=y
16+
CONFIG_ADBD_USB_SERVER=y
17+
CONFIG_ARCH="xtensa"
18+
CONFIG_ARCH_BOARD="lckfb-szpi-esp32s3"
19+
CONFIG_ARCH_BOARD_COMMON=y
20+
CONFIG_ARCH_BOARD_ESP32S3_LCKFB_SZPI=y
21+
CONFIG_ARCH_CHIP="esp32s3"
22+
CONFIG_ARCH_CHIP_ESP32S3=y
23+
CONFIG_ARCH_CHIP_ESP32S3WROOM1N16R8=y
24+
CONFIG_ARCH_INTERRUPTSTACK=2048
25+
CONFIG_ARCH_IRQ_TO_NDX=y
26+
CONFIG_ARCH_MINIMAL_VECTORTABLE_DYNAMIC=y
27+
CONFIG_ARCH_NUSER_INTERRUPTS=2
28+
CONFIG_ARCH_STACKDUMP=y
29+
CONFIG_ARCH_XTENSA=y
30+
CONFIG_AUDIO=y
31+
CONFIG_AUDIO_ES7210=y
32+
CONFIG_AUDIO_EXCLUDE_BALANCE=y
33+
CONFIG_AUDIO_EXCLUDE_FFORWARD=y
34+
CONFIG_AUDIO_EXCLUDE_TONE=y
35+
CONFIG_AUDIO_I2S=y
36+
CONFIG_BOARDCTL_RESET=y
37+
CONFIG_BOARD_LOOPSPERMSEC=16717
38+
CONFIG_BUILTIN=y
39+
CONFIG_DRIVERS_AUDIO=y
40+
CONFIG_ESP32S3_I2C0=y
41+
CONFIG_ESP32S3_OTG=y
42+
CONFIG_ESP32S3_OTG_ENDPOINT_NUM=2
43+
CONFIG_ESP32S3_SPIRAM=y
44+
CONFIG_ESP32S3_SPIRAM_MODE_OCT=y
45+
CONFIG_ESP32S3_UART0=y
46+
CONFIG_ESPRESSIF_I2S0=y
47+
CONFIG_ESPRESSIF_I2S0_BCLKPIN=14
48+
CONFIG_ESPRESSIF_I2S0_DINPIN=12
49+
CONFIG_ESPRESSIF_I2S0_MCLK=y
50+
CONFIG_ESPRESSIF_I2S0_MCLKPIN=38
51+
CONFIG_ESPRESSIF_I2S0_SAMPLE_RATE=48000
52+
CONFIG_ESPRESSIF_I2S0_WSPIN=13
53+
CONFIG_ETC_ROMFS=y
54+
CONFIG_FS_PROCFS=y
55+
CONFIG_FS_ROMFS=y
56+
CONFIG_FS_TMPFS=y
57+
CONFIG_HAVE_CXX=y
58+
CONFIG_HAVE_CXXINITIALIZE=y
59+
CONFIG_I2C_DRIVER=y
60+
CONFIG_I2C_POLLED=y
61+
CONFIG_I2S_DMADESC_NUM=16
62+
CONFIG_IDLETHREAD_STACKSIZE=3072
63+
CONFIG_INIT_ENTRYPOINT="nsh_main"
64+
CONFIG_INIT_STACKSIZE=4096
65+
CONFIG_INTELHEX_BINARY=y
66+
CONFIG_LIBC_EXECFUNCS=y
67+
CONFIG_LIBUV=y
68+
CONFIG_LINE_MAX=64
69+
CONFIG_MM_BACKTRACE=0
70+
CONFIG_MM_REGIONS=2
71+
CONFIG_NSH_ARCHINIT=y
72+
CONFIG_NSH_BUILTIN_APPS=y
73+
CONFIG_NSH_FILEIOSIZE=512
74+
CONFIG_NSH_READLINE=y
75+
CONFIG_NXRECORDER_RECORDTHREAD_STACKSIZE=16384
76+
CONFIG_POSIX_SPAWN_DEFAULT_STACKSIZE=4096
77+
CONFIG_PREALLOC_TIMERS=4
78+
CONFIG_PSEUDOTERM=y
79+
CONFIG_PTHREAD_MUTEX_TYPES=y
80+
CONFIG_RAM_SIZE=114688
81+
CONFIG_RAM_START=0x20000000
82+
CONFIG_RR_INTERVAL=200
83+
CONFIG_SCHED_BACKTRACE=y
84+
CONFIG_SCHED_CHILD_STATUS=y
85+
CONFIG_SCHED_HAVE_PARENT=y
86+
CONFIG_SCHED_HPWORKSTACKSIZE=8192
87+
CONFIG_SCHED_LPWORK=y
88+
CONFIG_SCHED_LPWORKSTACKSIZE=8192
89+
CONFIG_SCHED_WAITPID=y
90+
CONFIG_STACK_COLORATION=y
91+
CONFIG_STACK_USAGE=y
92+
CONFIG_START_DAY=6
93+
CONFIG_START_MONTH=12
94+
CONFIG_START_YEAR=2011
95+
CONFIG_SYSLOG_BUFFER=y
96+
CONFIG_SYSLOG_CHARDEV=y
97+
CONFIG_SYSLOG_CONSOLE=y
98+
CONFIG_SYSTEM_ADBD=y
99+
CONFIG_SYSTEM_NSH=y
100+
CONFIG_SYSTEM_NXRECORDER=y
101+
CONFIG_TLS_NCLEANUP=4
102+
CONFIG_TLS_NELEM=4
103+
CONFIG_TLS_TASK_NELEM=4
104+
CONFIG_TTY_FORCE_PANIC=y
105+
CONFIG_UART0_SERIAL_CONSOLE=y
106+
CONFIG_USBADB=y

boards/xtensa/esp32s3/lckfb-szpi-esp32s3/src/Make.defs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,7 @@ endif
6060
ifeq ($(CONFIG_ESP32S3_CAM),y)
6161
CSRCS += esp32s3_board_camera.c
6262
endif
63+
64+
ifeq ($(CONFIG_AUDIO_ES7210),y)
65+
CSRCS += esp32s3_board_es7210.c
66+
endif

boards/xtensa/esp32s3/lckfb-szpi-esp32s3/src/esp32s3-szpi.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@
4949
#define QMI8658_I2C_PORT (0)
5050
#define QMI8658_I2C_ADDR (0x6A)
5151

52+
#define ES7210_I2C_ADDR (0x41)
53+
#define ES7210_I2C_FREQ (100000)
54+
#define ES7210_DEVPATH "/dev/audio/pcm_in0"
55+
5256
/****************************************************************************
5357
* Public Types
5458
****************************************************************************/
@@ -167,5 +171,9 @@ int esp32s3_qmi8658_initialize(void);
167171
int esp32s3_camera_initialize(void);
168172
#endif
169173

174+
#ifdef CONFIG_AUDIO_ES7210
175+
int esp32s3_es7210_initialize(int i2c_port, int i2s_port);
176+
#endif
177+
170178
#endif /* __ASSEMBLY__ */
171179
#endif /* __BOARDS_XTENSA_ESP32S3_LCKFB_SZPI_ESP32S3_SRC_ESP32S3_DEVKIT_H */
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
/****************************************************************************
2+
* boards/xtensa/esp32s3/lckfb-szpi-esp32s3/src/esp32s3_board_es7210.c
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Licensed to the Apache Software Foundation (ASF) under one or more
7+
* contributor license agreements. See the NOTICE file distributed with
8+
* this work for additional information regarding copyright ownership. The
9+
* ASF licenses this file to you under the Apache License, Version 2.0 (the
10+
* "License"); you may not use this file except in compliance with the
11+
* License. You may obtain a copy of the License at
12+
*
13+
* http://www.apache.org/licenses/LICENSE-2.0
14+
*
15+
* Unless required by applicable law or agreed to in writing, software
16+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18+
* License for the specific language governing permissions and limitations
19+
* under the License.
20+
*
21+
****************************************************************************/
22+
23+
/****************************************************************************
24+
* Included Files
25+
****************************************************************************/
26+
27+
#include <nuttx/config.h>
28+
29+
#include <stdbool.h>
30+
#include <stdio.h>
31+
#include <debug.h>
32+
#include <assert.h>
33+
#include <errno.h>
34+
35+
#include <nuttx/i2c/i2c_master.h>
36+
#include <nuttx/audio/i2s.h>
37+
#include <nuttx/audio/es7210.h>
38+
#include <nuttx/audio/audio.h>
39+
40+
#include <arch/board/board.h>
41+
42+
#include "esp32s3_i2c.h"
43+
#include "espressif/esp_i2s.h"
44+
#include "esp32s3-szpi.h"
45+
46+
/****************************************************************************
47+
* Public Functions
48+
****************************************************************************/
49+
50+
/****************************************************************************
51+
* Name: esp32s3_es7210_initialize
52+
*
53+
* Description:
54+
* This function is called by board-specific setup logic to configure
55+
* and register the ES7210 audio ADC device.
56+
*
57+
* Input Parameters:
58+
* i2c_port - The I2C port number for the ES7210 control interface
59+
* i2s_port - The I2S port number for the ES7210 audio data interface
60+
*
61+
* Returned Value:
62+
* Zero is returned on success. Otherwise, a negated errno value is
63+
* returned to indicate the nature of the failure.
64+
*
65+
****************************************************************************/
66+
67+
int esp32s3_es7210_initialize(int i2c_port, int i2s_port)
68+
{
69+
FAR struct i2c_master_s *i2c;
70+
FAR struct i2s_dev_s *i2s;
71+
FAR struct audio_lowerhalf_s *es7210;
72+
struct es7210_lower_s lower;
73+
static bool initialized = false;
74+
char devname[] = "pcm_in0";
75+
int ret;
76+
77+
if (initialized)
78+
{
79+
return OK;
80+
}
81+
82+
/* Get I2C bus instance */
83+
84+
i2c = esp32s3_i2cbus_initialize(i2c_port);
85+
if (i2c == NULL)
86+
{
87+
auderr("ERROR: Failed to initialize I2C%d\n", i2c_port);
88+
return -ENODEV;
89+
}
90+
91+
/* Get I2S bus instance (RX only) */
92+
93+
i2s = esp_i2sbus_initialize(i2s_port);
94+
if (i2s == NULL)
95+
{
96+
auderr("ERROR: Failed to initialize I2S%d\n", i2s_port);
97+
return -ENODEV;
98+
}
99+
100+
/* Configure ES7210 lower half */
101+
102+
lower.frequency = ES7210_I2C_FREQ;
103+
lower.address = ES7210_I2C_ADDR;
104+
105+
/* Initialize the ES7210 codec */
106+
107+
es7210 = es7210_initialize(i2c, i2s, &lower);
108+
if (es7210 == NULL)
109+
{
110+
auderr("ERROR: Failed to initialize ES7210\n");
111+
return -ENODEV;
112+
}
113+
114+
/* Register the audio device as /dev/audio/pcm_in0 */
115+
116+
ret = audio_register(devname, es7210);
117+
if (ret < 0)
118+
{
119+
auderr("ERROR: Failed to register %s: %d\n", devname, ret);
120+
return ret;
121+
}
122+
123+
initialized = true;
124+
audinfo("ES7210 registered as %s\n", devname);
125+
return OK;
126+
}

boards/xtensa/esp32s3/lckfb-szpi-esp32s3/src/esp32s3_bringup.c

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ int esp32s3_bringup(void)
173173
}
174174
#endif
175175

176-
#if defined(CONFIG_ESPRESSIF_I2S0) || defined(CONFIG_ESPRESSIF_I2S1)
176+
#ifdef CONFIG_ESPRESSIF_I2S1
177177
bool i2s_enable_tx;
178178
bool i2s_enable_rx;
179179
#endif
@@ -345,25 +345,20 @@ int esp32s3_bringup(void)
345345
#endif
346346

347347
#ifdef CONFIG_ESPRESSIF_I2S
348-
#ifdef CONFIG_ESPRESSIF_I2S0_TX
349-
i2s_enable_tx = true;
350-
#else
351-
i2s_enable_tx = false;
352-
#endif /* CONFIG_ESPRESSIF_I2S0_TX */
353-
354-
#ifdef CONFIG_ESPRESSIF_I2S0_RX
355-
i2s_enable_rx = true;
356-
#else
357-
i2s_enable_rx = false;
358-
#endif /* CONFIG_ESPRESSIF_I2S0_RX */
359348

360-
/* Configure I2S generic audio on I2S0 */
349+
/* On lckfb-szpi-esp32s3, I2S0 is wired to dedicated codec chips
350+
* (ES7210 ADC + ES8311 DAC) which register their own audio devices.
351+
* Generic audio_i2s is not used on I2S0 — skip board_i2sdev_initialize
352+
* for port 0.
353+
*/
361354

362-
ret = board_i2sdev_initialize(ESP32S3_I2S0, i2s_enable_tx, i2s_enable_rx);
355+
#ifdef CONFIG_AUDIO_ES7210
356+
ret = esp32s3_es7210_initialize(0, 0);
363357
if (ret < 0)
364358
{
365-
syslog(LOG_ERR, "Failed to initialize I2S0 driver: %d\n", ret);
359+
syslog(LOG_ERR, "ERROR: Failed to initialize ES7210: %d\n", ret);
366360
}
361+
#endif
367362

368363
#ifdef CONFIG_ESPRESSIF_I2S1
369364

0 commit comments

Comments
 (0)