Skip to content

Commit

Permalink
Merge branch 'feature/usb_device_msc_support_v4.4' into 'master'
Browse files Browse the repository at this point in the history
device msc: Support release/v4.4

See merge request ae_group/esp-iot-solution!804
  • Loading branch information
leeebo committed Jul 22, 2023
2 parents 26b03e9 + c955edc commit 7f6be2f
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 14 deletions.
5 changes: 4 additions & 1 deletion .gitlab/ci/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,12 @@ build_example_usb_device_usb_msc_wireless_disk:
extends:
- .build_examples_template
- .rules:build:example_usb_device_usb_msc_wireless_disk
parallel:
matrix:
- IMAGE: espressif/idf:release-v4.4
- IMAGE: espressif/idf:release-v5.0
variables:
EXAMPLE_DIR: examples/usb/device/usb_msc_wireless_disk
IMAGE: espressif/idf:release-v5.0

build_example_usb_device_usb_surface_dial:
extends:
Expand Down
4 changes: 1 addition & 3 deletions .gitlab/ci/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ variables:
script:
- cd docs
- python -m pip install -r requirements.txt
- build-docs -t $DOCTGT -bs $DOC_BUILDERS -l $DOCLANG build
- build-docs -bs $DOC_BUILDERS -l $DOCLANG build
- ./check_lang_folder_sync.sh

build_docs_html:
Expand All @@ -28,6 +28,4 @@ build_docs_html:
parallel:
matrix:
- DOCLANG: "en"
DOCTGT: "esp32"
- DOCLANG: "zh_CN"
DOCTGT: "esp32"
1 change: 0 additions & 1 deletion docs/conf_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
html_context['github_user'] = 'espressif'
html_context['github_repo'] = 'esp-iot-solution'

idf_targets = ['esp32']
languages = ['en', 'zh_CN']

project_homepage = 'https://github.com/espressif/esp-iot-solution'
Expand Down
41 changes: 41 additions & 0 deletions examples/usb/device/usb_msc_wireless_disk/README_cn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
## USB MSC 无线磁盘

使用 ESP32-Sx 作为带有无线访问功能的 USB 磁盘。HTTP 文件服务器可用于上传和下载文件。

**此演示仅用于功能预览,如果您发现错误请不要感到意外**

### 硬件

- 开发板:ESP32-S3-USB-OTG,或任何 ESP32-Sx 开发板
- 微控制器(MCU):ESP32-S2,ESP32-S3
- Flash 存储:4MB NOR Flash
- 硬件连接:
- GPIO19 连接到 D-
- GPIO20 连接到 D+
- SD 卡 IO 根据不同的开发板而异,您可以在代码中自定义定义。

注意:如果您使用的是自供电设备,请参考[自供电设备](https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/api-reference/peripherals/usb_device.html#self-powered-device)

### 功能

1. 支持 USB MSC,可以通过主机读写板载 Flash 或 SD 卡;
2. 通过 Wi-Fi 下载和上传数据,ESP32-SX 可以作为 Wi-Fi AP 或 STA。

### 如何使用

1. 使用微型 USB 电缆直接插入主机的 USB 端口;
2. 默认情况下,在您的“文件资源管理器”中可以找到一个大小为 `1.5MB` 的磁盘;
3. 通过 Wi-Fi 连接到 ESP32S2,SSID:`ESP-Wireless-Disk`,默认没有密码;
4. 在浏览器中输入 `192.168.4.1`,您可以查看磁盘上的文件列表;
5. 拖放到磁盘的任何文件都将显示在网页中;
6. 从网页上传的任何文件也会显示在磁盘中(此演示中文件大小必须小于 20MB)。

### 配置 Wi-Fi

* 您可以在 `menuconfig → USB MSC Device Demo → Wi-Fi Settings` 中配置 Wi-Fi AP 的 SSID 和密码,以更改 esp32-sx 的热点名称。
* 您也可以设置 Wi-Fi STA 的 SSID 和密码,以使 esp32-sx 同时连接到路由器。

### 已知问题

1. 通过 Web 上传的文件无法被主机自动感知,因此 Windows 的“文件资源管理器”无法自动更新文件列表。请重新挂载磁盘以更新文件列表(弹出重新加载)。此问题将在后续修复。
2. 通过 USB 磁盘添加或删除的文件,有时无法通过 Web 刷新找到。
16 changes: 9 additions & 7 deletions examples/usb/device/usb_msc_wireless_disk/main/app_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include <inttypes.h>
#include "ff.h"
#include "diskio.h"
#include "esp_vfs_fat.h"
#include "driver/sdmmc_defs.h"
#include "tinyusb.h"
#include "sdmmc_cmd.h"
#include "esp_idf_version.h"

static const char *TAG = "usb_msc_wireless";

Expand Down Expand Up @@ -50,7 +53,11 @@ static esp_err_t init_fat(sdmmc_card_t **card_handle, const char *base_path)
.max_files = 9,
.allocation_unit_size = CONFIG_WL_SECTOR_SIZE
};
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
ret = esp_vfs_fat_spiflash_mount_rw_wl(base_path, "storage", &mount_config, &wl_handle_1);
#else
ret = esp_vfs_fat_spiflash_mount(base_path, "storage", &mount_config, &wl_handle_1);
#endif

if (ret != ESP_OK) {
ESP_LOGE(TAG, "Failed to mount FATFS (%s)", esp_err_to_name(ret));
Expand Down Expand Up @@ -154,13 +161,8 @@ void app_main(void)
#endif

ESP_LOGI(TAG, "USB MSC initialization");
const tinyusb_config_t tusb_cfg = {
.device_descriptor = NULL,
.string_descriptor = NULL,
.external_phy = false,
.configuration_descriptor = NULL,
.self_powered = false,
};

const tinyusb_config_t tusb_cfg = {0};

ESP_ERROR_CHECK(tinyusb_driver_install(&tusb_cfg));
ESP_LOGI(TAG, "USB MSC initialization DONE");
Expand Down
1 change: 1 addition & 0 deletions examples/usb/device/usb_msc_wireless_disk/main/app_wifi.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include <string.h>
#include "rom/ets_sys.h"
#include "esp_wifi.h"
#include "esp_log.h"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
## IDF Component Manager Manifest File
dependencies:
espressif/esp_tinyusb: "~1.1.0"
idf: ">=5.0.0"
espressif/esp_tinyusb:
version: "~1.1.0"
rules:
- if: "idf_version >=5.0"
idf: ">=4.4.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONFIG_USE_EXTERNAL_SDCARD=y
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONFIG_USE_INTERNAL_FLASH=y

0 comments on commit 7f6be2f

Please sign in to comment.