Skip to content

Commit 7f6be2f

Browse files
committed
Merge branch 'feature/usb_device_msc_support_v4.4' into 'master'
device msc: Support release/v4.4 See merge request ae_group/esp-iot-solution!804
2 parents 26b03e9 + c955edc commit 7f6be2f

File tree

9 files changed

+63
-14
lines changed

9 files changed

+63
-14
lines changed

.gitlab/ci/build.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -336,9 +336,12 @@ build_example_usb_device_usb_msc_wireless_disk:
336336
extends:
337337
- .build_examples_template
338338
- .rules:build:example_usb_device_usb_msc_wireless_disk
339+
parallel:
340+
matrix:
341+
- IMAGE: espressif/idf:release-v4.4
342+
- IMAGE: espressif/idf:release-v5.0
339343
variables:
340344
EXAMPLE_DIR: examples/usb/device/usb_msc_wireless_disk
341-
IMAGE: espressif/idf:release-v5.0
342345

343346
build_example_usb_device_usb_surface_dial:
344347
extends:

.gitlab/ci/docs.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ variables:
1010
script:
1111
- cd docs
1212
- python -m pip install -r requirements.txt
13-
- build-docs -t $DOCTGT -bs $DOC_BUILDERS -l $DOCLANG build
13+
- build-docs -bs $DOC_BUILDERS -l $DOCLANG build
1414
- ./check_lang_folder_sync.sh
1515

1616
build_docs_html:
@@ -28,6 +28,4 @@ build_docs_html:
2828
parallel:
2929
matrix:
3030
- DOCLANG: "en"
31-
DOCTGT: "esp32"
3231
- DOCLANG: "zh_CN"
33-
DOCTGT: "esp32"

docs/conf_common.py

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
html_context['github_user'] = 'espressif'
2424
html_context['github_repo'] = 'esp-iot-solution'
2525

26-
idf_targets = ['esp32']
2726
languages = ['en', 'zh_CN']
2827

2928
project_homepage = 'https://github.com/espressif/esp-iot-solution'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
## USB MSC 无线磁盘
2+
3+
使用 ESP32-Sx 作为带有无线访问功能的 USB 磁盘。HTTP 文件服务器可用于上传和下载文件。
4+
5+
**此演示仅用于功能预览,如果您发现错误请不要感到意外**
6+
7+
### 硬件
8+
9+
- 开发板:ESP32-S3-USB-OTG,或任何 ESP32-Sx 开发板
10+
- 微控制器(MCU):ESP32-S2,ESP32-S3
11+
- Flash 存储:4MB NOR Flash
12+
- 硬件连接:
13+
- GPIO19 连接到 D-
14+
- GPIO20 连接到 D+
15+
- SD 卡 IO 根据不同的开发板而异,您可以在代码中自定义定义。
16+
17+
注意:如果您使用的是自供电设备,请参考[自供电设备](https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/api-reference/peripherals/usb_device.html#self-powered-device)
18+
19+
### 功能
20+
21+
1. 支持 USB MSC,可以通过主机读写板载 Flash 或 SD 卡;
22+
2. 通过 Wi-Fi 下载和上传数据,ESP32-SX 可以作为 Wi-Fi AP 或 STA。
23+
24+
### 如何使用
25+
26+
1. 使用微型 USB 电缆直接插入主机的 USB 端口;
27+
2. 默认情况下,在您的“文件资源管理器”中可以找到一个大小为 `1.5MB` 的磁盘;
28+
3. 通过 Wi-Fi 连接到 ESP32S2,SSID:`ESP-Wireless-Disk`,默认没有密码;
29+
4. 在浏览器中输入 `192.168.4.1`,您可以查看磁盘上的文件列表;
30+
5. 拖放到磁盘的任何文件都将显示在网页中;
31+
6. 从网页上传的任何文件也会显示在磁盘中(此演示中文件大小必须小于 20MB)。
32+
33+
### 配置 Wi-Fi
34+
35+
* 您可以在 `menuconfig → USB MSC Device Demo → Wi-Fi Settings` 中配置 Wi-Fi AP 的 SSID 和密码,以更改 esp32-sx 的热点名称。
36+
* 您也可以设置 Wi-Fi STA 的 SSID 和密码,以使 esp32-sx 同时连接到路由器。
37+
38+
### 已知问题
39+
40+
1. 通过 Web 上传的文件无法被主机自动感知,因此 Windows 的“文件资源管理器”无法自动更新文件列表。请重新挂载磁盘以更新文件列表(弹出重新加载)。此问题将在后续修复。
41+
2. 通过 USB 磁盘添加或删除的文件,有时无法通过 Web 刷新找到。

examples/usb/device/usb_msc_wireless_disk/main/app_main.c

+9-7
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6+
#include <inttypes.h>
7+
#include "ff.h"
68
#include "diskio.h"
79
#include "esp_vfs_fat.h"
810
#include "driver/sdmmc_defs.h"
911
#include "tinyusb.h"
1012
#include "sdmmc_cmd.h"
13+
#include "esp_idf_version.h"
1114

1215
static const char *TAG = "usb_msc_wireless";
1316

@@ -50,7 +53,11 @@ static esp_err_t init_fat(sdmmc_card_t **card_handle, const char *base_path)
5053
.max_files = 9,
5154
.allocation_unit_size = CONFIG_WL_SECTOR_SIZE
5255
};
56+
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
5357
ret = esp_vfs_fat_spiflash_mount_rw_wl(base_path, "storage", &mount_config, &wl_handle_1);
58+
#else
59+
ret = esp_vfs_fat_spiflash_mount(base_path, "storage", &mount_config, &wl_handle_1);
60+
#endif
5461

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

156163
ESP_LOGI(TAG, "USB MSC initialization");
157-
const tinyusb_config_t tusb_cfg = {
158-
.device_descriptor = NULL,
159-
.string_descriptor = NULL,
160-
.external_phy = false,
161-
.configuration_descriptor = NULL,
162-
.self_powered = false,
163-
};
164+
165+
const tinyusb_config_t tusb_cfg = {0};
164166

165167
ESP_ERROR_CHECK(tinyusb_driver_install(&tusb_cfg));
166168
ESP_LOGI(TAG, "USB MSC initialization DONE");

examples/usb/device/usb_msc_wireless_disk/main/app_wifi.c

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6+
#include <string.h>
67
#include "rom/ets_sys.h"
78
#include "esp_wifi.h"
89
#include "esp_log.h"
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
## IDF Component Manager Manifest File
22
dependencies:
3-
espressif/esp_tinyusb: "~1.1.0"
4-
idf: ">=5.0.0"
3+
espressif/esp_tinyusb:
4+
version: "~1.1.0"
5+
rules:
6+
- if: "idf_version >=5.0"
7+
idf: ">=4.4.0"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CONFIG_USE_EXTERNAL_SDCARD=y
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CONFIG_USE_INTERNAL_FLASH=y

0 commit comments

Comments
 (0)