【MolunSmartHome】试图教会你编译自己的小智固件
本帖最后由 molun 于 2025-6-11 16:08 编辑【MolunSmartHome】定制属于自己的小智固件
#申请原创#@21小跑堂
最近各类小智AI对话机器人DIY大火,自己也手痒,做了几个版本。
总想着大而全,因此参照多个项目最终的产物就是硬件接线配置不同,不能直接用别人的固件,需要进行定制编译。
【ESP32S3 4M Flash模组成功运行虾哥小智】 https://www.bilibili.com/video/BV1JeAweuEn5/?share_source=copy_web&vd_source=92e5311a7d6802b0f8947ec6908a6883
static/image/hrline/1.gif
源码基于虾哥https://github.com/78/xiaozhi-esp32.githttps://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-14/7853f27c-1aef-4b70-8de5-a9810c63ba96.png
直接下载或者安装git客户端后命令拉取源码gh repo clone 78/xiaozhi-esp32git clone https://github.com/78/xiaozhi-esp32.git选择一种即可https://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-14/c3a8d84e-772c-4e4e-8f02-a72b480a0327.png
https://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-14/c5ab9352-1bfd-4d25-8557-0d513b4bd595.png
在VSCODE中打开文件夹,这里默认已经安装好乐鑫IDFhttps://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-14/af4996f8-b202-45c4-83d2-59237ef94758.png
https://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-14/bf495385-fcd5-45e2-8d1a-8f60dec74652.png
https://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-14/402fd0b7-4997-43c8-8428-25e01fd6dd5f.png
https://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-14/01c3ccaf-0b32-4bd6-81c4-e238692b0be6.png
https://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-14/05383fef-d940-4f44-8494-6bf68dcb649a.png
连接好开发板后,依次选择端口号,设置目标芯片,烧录方式https://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-14/c3405b02-aefb-4150-88e8-5f565c8e783b.png
https://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-14/684e2faf-4032-40c6-82e1-951f29780aec.png
https://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-14/29544e25-84c4-4aa3-86de-6fca8e233b26.png
https://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-14/01a1db26-d049-4b44-8a5f-2364d3865be2.png
https://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-14/cd7a440f-8c12-4b6c-81ce-9eb3f4b6c2e4.png
根据硬件情况选择,如果是通过串口芯片连接的ESP32S3就选择UART,否则选择JTAGhttps://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-14/34bc3933-b278-4019-86f5-f7adb7f4b89a.png
选择SDK配置编辑器,对应命令idf.py menuconfig
https://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-14/8f70ebe1-47ac-48f3-8cd6-8509d8948cd6.png
https://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-14/d30265ac-07ef-4d66-883b-9b3b26ec89ef.png
根据自己开发板情况进行以下修改https://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-14/446108a8-20ad-4521-8d68-82639e2ffdc1.png
修改Flash size,因为我用的模组是ESP32-S3-WROOM-1-N4,即4M版本,没有PSRAM。https://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-14/bdc117cc-4a53-4781-86dd-d447a1016d7b.png
修改Custom partition CSV file分区表partitions.csv 修改为 partitions_4M.csv
https://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-14/d90a01d4-f013-4adf-8c92-e308ba1a1573.png
自己部署后台的可以修改这里,看到已有开源项目。https://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-14/6f6477e4-4923-4b97-8154-64276870af8f.png
这里选择对应的开发板,如果是自己DIY的,就选择默认面包板wifi版本或者4G版本即可https://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-14/df90c941-032c-45a6-85bf-a31a5f7bcf1c.png
https://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-14/7bac6b9f-eded-4d35-84e0-72810b0c8381.png
貌似没有PSRAM,就不能语音唤醒,关掉即可。https://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-14/ec69fb1c-e567-49d5-879c-c6c0a3162c6f.png
切换回源码,进行IO口配置,如果按照虾哥推荐的接线方式就不需要动这里。https://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-14/8137d311-8c26-4fb2-8047-111ebe4152a9.png
#ifndef _BOARD_CONFIG_H_
#define _BOARD_CONFIG_H_
#include <driver/gpio.h>
#define AUDIO_INPUT_SAMPLE_RATE16000
#define AUDIO_OUTPUT_SAMPLE_RATE 24000
// 如果使用 Duplex I2S 模式,请注释下面一行
#define AUDIO_I2S_METHOD_SIMPLEX
#ifdef AUDIO_I2S_METHOD_SIMPLEX
#define AUDIO_I2S_MIC_GPIO_WS GPIO_NUM_5
#define AUDIO_I2S_MIC_GPIO_SCKGPIO_NUM_4
#define AUDIO_I2S_MIC_GPIO_DINGPIO_NUM_6
#define AUDIO_I2S_SPK_GPIO_DOUT GPIO_NUM_7
#define AUDIO_I2S_SPK_GPIO_BCLK GPIO_NUM_15
#define AUDIO_I2S_SPK_GPIO_LRCK GPIO_NUM_16
#else
#define AUDIO_I2S_GPIO_WS GPIO_NUM_5
#define AUDIO_I2S_GPIO_BCLK GPIO_NUM_4
#define AUDIO_I2S_GPIO_DINGPIO_NUM_6
#define AUDIO_I2S_GPIO_DOUT GPIO_NUM_7
#endif
#define BUILTIN_LED_GPIO GPIO_NUM_14
#define BOOT_BUTTON_GPIO GPIO_NUM_0
#define TOUCH_BUTTON_GPIO GPIO_NUM_21
#define VOLUME_UP_BUTTON_GPIO GPIO_NUM_NC
#define VOLUME_DOWN_BUTTON_GPIO GPIO_NUM_NC
#define DISPLAY_SDA_PIN GPIO_NUM_41
#define DISPLAY_SCL_PIN GPIO_NUM_42
#define DISPLAY_WIDTH 128
#define DISPLAY_HEIGHT64
#define DISPLAY_MIRROR_X true
#define DISPLAY_MIRROR_Y true
#endif // _BOARD_CONFIG_H_
以上是我的项目配置https://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-14/cb04b2e1-5b43-4f82-868f-de36f43c9bed.png
https://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-14/951d25cf-a4af-47b3-8a8f-d097c9987235.png这里暂且不关闭试试,上次关闭编译后使用正常。https://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-14/360589e3-2852-4daa-8366-fb02e6d6c4c4.png
这里选择唤醒词,乐鑫官方提供了一些,默认你好小智,还有诸如小爱同学、Hi乐鑫等,当然也可以付费定制优化自己的唤醒词。“白**”模组,实际上就是别的厂商优化唤醒词语料!https://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-01/b1b03fbc-8969-43d7-822d-4c763808872d.jpg
模组“白**”地址在这里,可别说我吃独食。别忘记填写邀*码:RJBGBBhttps://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-01/e25370d3-d72f-422f-85e9-9fd73f8b899f.jpg
https://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-14/b864c220-a3a3-4cad-88fa-5f9666ff696d.png
https://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-14/8a87ea1e-b646-4b99-8e8d-d243794532f1.png
继续往下翻找,或者搜索PSRAM,关闭PSRAM,如果你采用的是带有PSRAM的模组如N8R2之类的,可能需要调整对应的通道https://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-14/e021848d-ac7a-43a0-8302-b5a80f939637.png
https://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-14/b9a51bc7-7b40-42ce-8c6f-5d03da9519f2.png
我这里选择关闭PSRAMhttps://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-14/f4792a47-02aa-4792-8928-3b8df4c5cd59.png
https://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-14/fd980c31-36fe-43e8-8847-55102ed6b588.png
修改完毕之后保存生效,点击构建烧录https://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-14/a8b4a3e1-8129-4414-88a5-ad53991a2fcb.png
耐心等待inghttps://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-14/90565fb4-4c71-4e80-8c90-ae471765053f.png
https://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-14/bffa9230-75bb-4d54-800e-9feb6538e6eb.png
https://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-14/2edea696-8f69-4988-82a0-b433b72e0947.png
https://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-14/6b067d1a-b629-438a-8e72-5675ee21ecd8.png
烧录成功https://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-14/b69c3b0f-6340-49fa-8e0d-9734b0c89f4b.png
至此,可以用手机连接模组热点进行配网。我这里二次烧录后尽然不需要配网,直接接入了。首次烧录后,配网完成会播报验证码,用于小智后台绑定。https://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-14/664a1f34-f9f0-4241-8037-c96c167e7bdb.png
https://xiaozhi.me/console/deviceshttps://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-14/1d81bf74-ab9a-45e4-8c65-fe4a51a9e7a5.png
https://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-14/739aed55-8813-4cb0-8b63-8ed48811557d.png
可以设置备注名称,方便区分不同的设备。https://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-14/31f6506a-42b8-4bef-82ed-ec3f53075343.png
进行智能体配置搞忘记了,没有PSRAM,前面编译设置唤醒词好像没啥卵用。https://xccfriend.oss-cn-shenzhen.aliyuncs.com/pc/2025-02-14/ba21f968-3e3a-4065-8ee4-098b4ca6a416.png
保存后重启设备,开始体验吧!
【使用ESP32-S3和天问ASRPRO核心板制作的AI对话智能管家翻车了!】 https://www.bilibili.com/video/BV11irbYKExo/?share_source=copy_web&vd_source=92e5311a7d6802b0f8947ec6908a6883
页:
[1]