当前位置:首页 » 《随便一记》 » 正文

【ESP32S2】使用ESP32S2开发板制作U盘,支持无线访问_rentong123的博客

21 人参与  2021年11月10日 10:43  分类 : 《随便一记》  评论

点击全文阅读


文章目录

  • 前言
  • 一、开发环境
  • 二、硬件介绍
  • 三、下载esp-idf
  • 四、下载esp-iot-solution
  • 五、配置idf
    • 1、执行下载脚本
    • 2、设置环境变量
    • 3、声明外部组件
  • 六、构建例程
  • 七、烧写Flash
  • 八、使用方法
  • 九、感谢

前言

使用官方例程"usb_msc_wireless_disk",将ESP32S2开发板制作成一个支持wifi无线访问的U盘设备。


一、开发环境

SDKhttps://github.com/espressif/esp-idf.git
方案https://github.com/espressif/esp-iot-solution
开发板安信可ESP-12K开发板NodeMCU-32-S2
OSWindows 10

二、硬件介绍

	- Board:ESP32-S3-USB-OTG, or any ESP32-Sx board 
	- MCU:ESP32-S2, ESP32-S3
	- Flash:4MB NOR Flash
	- Hardware Connection: 
	- GPIO19 to D-				// 我用的是安信可ESP32S2-12K开发板,可根据自己的开发板确认管脚
	- GPIO20 to D+
	- SDCard IO varies from boards, you can defined your own in code.	// 如MSC要映射到外部SDCARD时需要

三、下载esp-idf

	cd esp										// 是我的根目录
	git clone -b master --recursive https://github.com/espressif/esp-idf.git esp-idf  // 下载master分支
	cd esp-idf
	git pull
	git checkout d5f58ab13551cd8				// check到指定节点
	git submodule update --init --recursive		// 要确保各个子模块更新成功

修改esp-idf/components/driver/spi_master.c:

diff --git a/components/driver/spi_master.c b/components/driver/spi_master.c
	index 15cfceb9ac..c076ed631c 100644
	--- a/components/driver/spi_master.c
	+++ b/components/driver/spi_master.c
	@@ -563,6 +563,7 @@ static void SPI_MASTER_ISR_ATTR spi_new_trans(spi_device_t *dev, spi_trans_priv_

		 //Call pre-transmission callback, if any
		 if (dev->cfg.pre_cb) dev->cfg.pre_cb(trans);
	+    ets_delay_us(10);		// 加上这一行
		 //Kick off transfer
		 spi_hal_user_start(hal);
	 }

四、下载esp-iot-solution

	cd esp
	git clone -b usb/add_usb_solutions --recursive https://github.com/espressif/esp-iot-solution
	cd esp-iot-solution
	xcopy /e /i examples\usb\device\usb_msc_wireless_disk usb_msc_wireless_disk		
	// 拷贝一份出来,不污染原文件。

五、配置idf

1、执行下载脚本

	cd esp
	esp-idf\install.bat	

如速度慢,添加一个新的环境变量(类型为用户或系统都可以,名称为 IDF_GITHUB_ASSETS,值为dl.espressif.com/github_assets);

如果之前安装过其它版本的idf环境,可能会报错,可以把.espressif\python_env删掉。.espressif一般位于用户根目录,即打开一个命令行窗口所在的位置。

2、设置环境变量

	cd esp
	esp-idf\export.bat

3、声明外部组件

	cd esp
	set IOT_SOLUTION_PATH=D:\xxx\code\esp\esp-iot-solution	// 我们要使用esp-iot-solution中的组件

六、构建例程

	cd esp-iot-solution\usb_msc_wireless_disk
	idf.py set-target esp32s2	// 如果遇到报错“找不到xxx文件”、“xxx is not a directory”,很可能是子模块没有下载成功,可以进入对应目录,手动checkout 出来(git checkout commitid) 
	idf.py menuconfig			// 这步可选,如使用默认配置,则可跳过。
	idf.py build				// 如果之前有build失败过,手动删除build目录。

七、烧写Flash

	idf.py -p com5 flash		// com序号根据实际情况

八、使用方法

1)将开发板的USB_D+、USB_D-、VCC_5V、GND分别连接USB插头的绿、白、红、黑线;
2)将USB插头插入PC,能识别到一个1.5M左右的U盘;
2)PC连接热点“ESP-Wireless-Disk”,无密码;
3)连接成功后,PC浏览器打开“192.168.4.1”,即可访问U盘;

九、感谢

使用ESP32S2原生USB自制U盘,可支持无线访问
MIT 女极客 ESP32-S2 TinyUSB 直播教学,All about the ESP32-S2 by Espressif Systems
https://github.com/espressif/esp-iot-solution/tree/usb/add_usb_solutions/examples/usb/device/usb_msc_wireless_disk/README.md


点击全文阅读


本文链接:http://zhangshiyu.com/post/30724.html

下载  开发板  组件  
<< 上一篇 下一篇 >>

  • 评论(0)
  • 赞助本站

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

关于我们 | 我要投稿 | 免责申明

Copyright © 2020-2022 ZhangShiYu.com Rights Reserved.豫ICP备2022013469号-1