From d9f7682b2dc62ccb767c17822b43901df48fde2c Mon Sep 17 00:00:00 2001 From: Xiaoxia Date: Wed, 28 Jan 2026 16:11:26 +0800 Subject: [PATCH] Fix RNDIS board and enhance camera initialization (#1702) * Add support for RNDIS board and enhance camera initialization - Included rndis_board.cc in the build for ESP32S3 and ESP32P4 targets. - Updated camera initialization logic in esp32s3_korvo2_v3_board.cc and esp32s3_korvo2_v3_board.cc to use a more structured camera_config_t setup. - Improved code readability by refining comments and formatting in the camera initialization functions. * Remove outdated camera configuration options from esp32s3-korvo2-v3-rndis config.json to streamline setup and improve clarity. * Update IDF version in build configuration and component dependencies to v5.5.2 for improved compatibility. * update discord links --------- Co-authored-by: Xiaoxia --- .github/workflows/build.yml | 2 +- README.md | 2 +- README_ja.md | 2 +- README_zh.md | 2 +- main/CMakeLists.txt | 5 +- .../esp32s3-korvo2-v3-rndis/config.json | 7 -- .../esp32s3_korvo2_v3_board.cc | 69 +++++++++---------- .../esp32s3_korvo2_v3_board.cc | 6 +- main/idf_component.yml | 7 +- 9 files changed, 48 insertions(+), 54 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0d998214..f22405fd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -92,7 +92,7 @@ jobs: include: ${{ fromJson(needs.prepare.outputs.variants) }} runs-on: ubuntu-latest container: - image: espressif/idf:release-v5.5 + image: espressif/idf:v5.5.2 steps: - name: Checkout uses: actions/checkout@v4 diff --git a/README.md b/README.md index aa126e7f..958958c5 100644 --- a/README.md +++ b/README.md @@ -160,7 +160,7 @@ This is an open-source ESP32 project, released under the MIT license, allowing a We hope this project helps everyone understand AI hardware development and apply rapidly evolving large language models to real hardware devices. -If you have any ideas or suggestions, please feel free to raise Issues or join our [Discord](https://discord.gg/x3S4jgXHk3) or QQ group: 994694848 +If you have any ideas or suggestions, please feel free to raise Issues or join our [Discord](https://discord.gg/bXqgAfRm) or QQ group: 994694848 ## Star History diff --git a/README_ja.md b/README_ja.md index 4df18133..224a0743 100644 --- a/README_ja.md +++ b/README_ja.md @@ -156,7 +156,7 @@ Feishuドキュメントチュートリアルをご覧ください: このプロジェクトを通じて、AIハードウェア開発を理解し、急速に進化する大規模言語モデルを実際のハードウェアデバイスに応用できるようになることを目指しています。 -ご意見やご提案があれば、いつでもIssueを提出するか、[Discord](https://discord.gg/x3S4jgXHk3) または QQグループ:1011329060 にご参加ください。 +ご意見やご提案があれば、いつでもIssueを提出するか、[Discord](https://discord.gg/bXqgAfRm) または QQグループ:1011329060 にご参加ください。 ## スター履歴 diff --git a/README_zh.md b/README_zh.md index 8fb8b8a8..e74bdb44 100644 --- a/README_zh.md +++ b/README_zh.md @@ -156,7 +156,7 @@ v1 的稳定版本为 1.9.2,可以通过 `git checkout v1` 来切换到 v1 版 我们希望通过这个项目,能够帮助大家了解 AI 硬件开发,将当下飞速发展的大语言模型应用到实际的硬件设备中。 -如果你有任何想法或建议,请随时提出 Issues 或加入 [Discord](https://discord.gg/x3S4jgXHk3) 或 QQ 群:1011329060 +如果你有任何想法或建议,请随时提出 Issues 或加入 [Discord](https://discord.gg/bXqgAfRm) 或 QQ 群:1011329060 ## Star History diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index d1c71e28..f6ef2751 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -777,7 +777,9 @@ endif() # Include EspVideo if target is ESP32S3 or ESP32P4 if(CONFIG_IDF_TARGET_ESP32S3 OR CONFIG_IDF_TARGET_ESP32P4) - list(APPEND SOURCES "boards/common/esp_video.cc") + list(APPEND SOURCES "boards/common/esp_video.cc" + "boards/common/rndis_board.cc" + ) endif() # Include Esp32Camera if target is ESP32S3 @@ -792,6 +794,7 @@ idf_component_register(SRCS ${SOURCES} PRIV_REQUIRES esp_pm esp_psram + esp_netif esp_driver_gpio esp_driver_uart esp_driver_spi diff --git a/main/boards/esp32s3-korvo2-v3-rndis/config.json b/main/boards/esp32s3-korvo2-v3-rndis/config.json index c9605569..2bd927cd 100644 --- a/main/boards/esp32s3-korvo2-v3-rndis/config.json +++ b/main/boards/esp32s3-korvo2-v3-rndis/config.json @@ -4,13 +4,6 @@ { "name": "esp32s3-korvo2-v3-rndis", "sdkconfig_append": [ - "CONFIG_CAMERA_OV2640=y", - "CONFIG_CAMERA_OV3660=y", - "CONFIG_CAMERA_OV3660_AUTO_DETECT_DVP_INTERFACE_SENSOR=y", - "CONFIG_CAMERA_OV3660_DVP_RGB565_240X240_24FPS=y", - "CONFIG_CAMERA_OV2640_AUTO_DETECT_DVP_INTERFACE_SENSOR=y", - "CONFIG_CAMERA_OV2640_DVP_RGB565_240X240_25FPS=y", - "CONFIG_XIAOZHI_ENABLE_CAMERA_ENDIANNESS_SWAP=y" ] } ] diff --git a/main/boards/esp32s3-korvo2-v3-rndis/esp32s3_korvo2_v3_board.cc b/main/boards/esp32s3-korvo2-v3-rndis/esp32s3_korvo2_v3_board.cc index 434482a7..6689db56 100644 --- a/main/boards/esp32s3-korvo2-v3-rndis/esp32s3_korvo2_v3_board.cc +++ b/main/boards/esp32s3-korvo2-v3-rndis/esp32s3_korvo2_v3_board.cc @@ -50,6 +50,7 @@ static const ili9341_lcd_init_cmd_t vendor_specific_init[] = { {0, (uint8_t []){0}, 0xff, 0}, }; +// https://github.com/78/xiaozhi-esp32/pull/1655 class Esp32S3Korvo2V3Board : public RndisBoard { private: Button boot_button_; @@ -348,43 +349,41 @@ private: } void InitializeCamera() { - static esp_cam_ctlr_dvp_pin_config_t dvp_pin_config = { - .data_width = CAM_CTLR_DATA_WIDTH_8, - .data_io = { - [0] = CAMERA_PIN_D0, - [1] = CAMERA_PIN_D1, - [2] = CAMERA_PIN_D2, - [3] = CAMERA_PIN_D3, - [4] = CAMERA_PIN_D4, - [5] = CAMERA_PIN_D5, - [6] = CAMERA_PIN_D6, - [7] = CAMERA_PIN_D7, - }, - .vsync_io = CAMERA_PIN_VSYNC, - .de_io = CAMERA_PIN_HREF, - .pclk_io = CAMERA_PIN_PCLK, - .xclk_io = CAMERA_PIN_XCLK, + camera_config_t camera_config = { + .pin_pwdn = CAMERA_PIN_PWDN, + .pin_reset = CAMERA_PIN_RESET, + .pin_xclk = CAMERA_PIN_XCLK, + .pin_sccb_sda = -1, // Use initialized I2C + .pin_sccb_scl = -1, + .pin_d7 = CAMERA_PIN_D7, + .pin_d6 = CAMERA_PIN_D6, + .pin_d5 = CAMERA_PIN_D5, + .pin_d4 = CAMERA_PIN_D4, + .pin_d3 = CAMERA_PIN_D3, + .pin_d2 = CAMERA_PIN_D2, + .pin_d1 = CAMERA_PIN_D1, + .pin_d0 = CAMERA_PIN_D0, + .pin_vsync = CAMERA_PIN_VSYNC, + .pin_href = CAMERA_PIN_HREF, + .pin_pclk = CAMERA_PIN_PCLK, + + .xclk_freq_hz = XCLK_FREQ_HZ, + .ledc_timer = LEDC_TIMER_0, + .ledc_channel = LEDC_CHANNEL_0, + + .pixel_format = PIXFORMAT_RGB565, + .frame_size = FRAMESIZE_QVGA, + .jpeg_quality = 12, + .fb_count = 2, + .fb_location = CAMERA_FB_IN_PSRAM, + .grab_mode = CAMERA_GRAB_WHEN_EMPTY, + .sccb_i2c_port = (i2c_port_t)1, }; - esp_video_init_sccb_config_t sccb_config = { - .init_sccb = false, - .i2c_handle = i2c_bus_, - .freq = 100000, - }; - - esp_video_init_dvp_config_t dvp_config = { - .sccb_config = sccb_config, - .reset_pin = CAMERA_PIN_RESET, - .pwdn_pin = CAMERA_PIN_PWDN, - .dvp_pin = dvp_pin_config, - .xclk_freq = XCLK_FREQ_HZ, - }; - - esp_video_init_config_t video_config = { - .dvp = &dvp_config, - }; - - camera_ = new Esp32Camera(video_config); + camera_ = new Esp32Camera(camera_config); + if (camera_ != nullptr) { + camera_->SetVFlip(true); + } } public: diff --git a/main/boards/esp32s3-korvo2-v3/esp32s3_korvo2_v3_board.cc b/main/boards/esp32s3-korvo2-v3/esp32s3_korvo2_v3_board.cc index 82ecf990..1d867adf 100644 --- a/main/boards/esp32s3-korvo2-v3/esp32s3_korvo2_v3_board.cc +++ b/main/boards/esp32s3-korvo2-v3/esp32s3_korvo2_v3_board.cc @@ -353,12 +353,11 @@ private: } void InitializeCamera() { - // ESP32-S3 使用 esp_camera 组件 camera_config_t camera_config = { .pin_pwdn = CAMERA_PIN_PWDN, .pin_reset = CAMERA_PIN_RESET, .pin_xclk = CAMERA_PIN_XCLK, - .pin_sccb_sda = -1, // 使用已初始化的 I2C + .pin_sccb_sda = -1, // Use initialized I2C .pin_sccb_scl = -1, .pin_d7 = CAMERA_PIN_D7, .pin_d6 = CAMERA_PIN_D6, @@ -386,8 +385,7 @@ private: }; camera_ = new Esp32Camera(camera_config); - if(camera_ != nullptr) - { + if(camera_ != nullptr) { camera_->SetVFlip(true); } } diff --git a/main/idf_component.yml b/main/idf_component.yml index 2256f02e..14c1454b 100644 --- a/main/idf_component.yml +++ b/main/idf_component.yml @@ -114,11 +114,12 @@ dependencies: rules: - if: target in [esp32s3, esp32c5] - ## Required IDF version - idf: - version: '>=5.5.1' espressif/esp_lcd_touch_st7123: ^1.0.0 espressif/iot_usbh_rndis: version: ^0.3.1 rules: - if: target in [esp32s3, esp32p4] + + ## Required IDF version + idf: + version: '>=5.5.2'