Due to high demand expect some shipping delays at this time, orders may not ship for 3-4 business days. On MLK Day no orders will be shipped.
0

Arduino disk drive example for Adafruit ESP32-S2 Feather wit
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Arduino disk drive example for Adafruit ESP32-S2 Feather wit

by WillMarchant on Fri Nov 26, 2021 4:38 pm

The getting started guide at https://learn.adafruit.com/adafruit-esp32-s2-feather says "Native USB means they can act like a keyboard or a disk drive" but only seems to explain this for CircuitPython.

Is there an Arduino example of setting up this Feather as a USB disk drive?

My application is to create Arduino code that collects data from the BME280 and writes it to text file(s) for the user to later download by plugging the board into a USB port on their computer.

Thanks in advance for any pointers.
Happy holidays,
Will

WillMarchant
 
Posts: 17
Joined: Thu Sep 21, 2017 4:42 pm

Re: Arduino disk drive example for Adafruit ESP32-S2 Feather

by WillMarchant on Mon Dec 06, 2021 5:20 pm

Just checking in to see if anyone has a suggestion for using this board, in the Arduino environment, as a USB memory stick. Thanks in advance!

WillMarchant
 
Posts: 17
Joined: Thu Sep 21, 2017 4:42 pm

Re: Arduino disk drive example for Adafruit ESP32-S2 Feather

by hathach on Wed Dec 08, 2021 12:42 am

you could run this msc example with esp32s2 on latest arduino core 2.0.1 and latest TinyUSB lib https://github.com/adafruit/Adafruit_Ti ... rnal_flash

hathach
 
Posts: 1187
Joined: Tue Apr 23, 2013 1:02 am

Re: Arduino disk drive example for Adafruit ESP32-S2 Feather

by WillMarchant on Thu Dec 09, 2021 6:03 pm

Thanks very much! I was able to load that and it indeed puts a USB drive onto my computer's desktop.

But it makes the serial port disappear so I can't get any of the diagnostic messages generated by that project. Any suggestions about that?

The compile is generating some warnings. See attached, please. So perhaps I have the wrong libraries loaded? They're all current, nothing is listed as needing an update...
Attachments
errors.txt
Compile time warnings from the USB example
(27.65 KiB) Downloaded 3 times

WillMarchant
 
Posts: 17
Joined: Thu Sep 21, 2017 4:42 pm

Re: Arduino disk drive example for Adafruit ESP32-S2 Feather

by hathach on Fri Dec 10, 2021 11:50 am

the warnings is not a problem, it is due to redefined symbol of libraries SdFatand esp32 core SD lib. They have the same value so it is harmless, we will fix the warnings later on in SdFat later on.

For the MSC drive, is the name FTHRS2BOOT, if yes, could you post its INFO_UF2.txt contents here.

hathach
 
Posts: 1187
Joined: Tue Apr 23, 2013 1:02 am

Re: Arduino disk drive example for Adafruit ESP32-S2 Feather

by WillMarchant on Fri Dec 10, 2021 12:11 pm

Yes, that's the name. The INFO_UF2.TXT contents are:
TinyUF2 Bootloader 0.5.2 - tinyusb (0.10.1-109-g9b3ec69b)
Model: Adafruit Feather ESP32-S2
Board-ID: ESP32S2-Feather-revA
Date: Sep 8 2021


The example code has a "while ( !Serial ) delay(10); // wait for native usb" after the "Serial.begin(115200);" in setup. Those are basically the last thing in setup. Uncommenting that "while ... delay" doesn't seem to do anything. Moving the serial begin and wait up to the front of setup results in a working serial port, with messages from the example, but the code keeps resetting, and each time it does, macOS complains that the USB disk is unreadable. So no joy there...

Thanks for helping out with this!

WillMarchant
 
Posts: 17
Joined: Thu Sep 21, 2017 4:42 pm

Re: Arduino disk drive example for Adafruit ESP32-S2 Feather

by hathach on Fri Dec 10, 2021 12:17 pm

thanks for confirmation, it is actually not your issue but ours. The bootloader in the arduino esp32 core is out of date and has issue with mini module on esp32s2. I am working on a fix, and will make an patch to arduino esp32 core as well as local fix for you (so that you don't have to wait for the next release). Please stay tuned.

hathach
 
Posts: 1187
Joined: Tue Apr 23, 2013 1:02 am

Re: Arduino disk drive example for Adafruit ESP32-S2 Feather

by WillMarchant on Fri Dec 10, 2021 1:25 pm

Excellent, thank you so much!

WillMarchant
 
Posts: 17
Joined: Thu Sep 21, 2017 4:42 pm

Re: Arduino disk drive example for Adafruit ESP32-S2 Feather

by hathach on Fri Dec 10, 2021 1:50 pm

Update: here is the fix
1. Download and replace the attached boards.txt and replace the one in your installed core at /Users/marchant/Library/Arduino15/packages/esp32/hardware/esp32/2.0.1/ . This updates feather esp32s2 to have correct native USB by default.
2. the issue isn't with bootloader, it seems to be caused when your flash isn't formatted previously. It somehow cause reset to bootloader. To fix this, you only need to format the flash first by running this sketch https://github.com/adafruit/Adafruit_SP ... Fat_format (type "OK" then enter).
3. Try again with msc_external_flash, if everything goes well, an msc drive "EXT FLASH" will show up with 960KB
Attachments
boards.txt
(429.81 KiB) Downloaded 5 times

hathach
 
Posts: 1187
Joined: Tue Apr 23, 2013 1:02 am

Re: Arduino disk drive example for Adafruit ESP32-S2 Feather

by WillMarchant on Fri Dec 10, 2021 2:44 pm

Thanks! Compiling the formater gives me this error:
/Users/marchant/Documents/Arduino/SdFat_format/SdFat_format.ino:102: undefined reference to `f_setlabel'
Maybe I have the wrong (or an extra) libraries installed? I've included a snapshot of the installed "fat" libraries.
Best wishes,
Will
Attachments
Screen Shot 2021-12-10 at 13.37.12.png
List of installed "fat" libraries
Screen Shot 2021-12-10 at 13.37.12.png (141.24 KiB) Viewed 376 times

WillMarchant
 
Posts: 17
Joined: Thu Sep 21, 2017 4:42 pm

Re: Arduino disk drive example for Adafruit ESP32-S2 Feather

by WillMarchant on Sat Dec 11, 2021 5:34 pm

I tried with a clean install of the Arduino API and got that same error. Perhaps the "Adafruit SdFat" and Adafruit_SPIFlash aren't the right libraries?

WillMarchant
 
Posts: 17
Joined: Thu Sep 21, 2017 4:42 pm

Re: Arduino disk drive example for Adafruit ESP32-S2 Feather

by hathach on Mon Dec 13, 2021 6:24 am

Adafruit SdFat and Adafruit_SPIFlash are the correct libraries. I think there is a lib conflict, could you temporarily remove your 'FatFs' by stm32duino and try again. I think Arduino IDE include the ffconfig.h from that library instead of the one in the format example (which has the SET_LABEL enabled).

hathach
 
Posts: 1187
Joined: Tue Apr 23, 2013 1:02 am

Re: Arduino disk drive example for Adafruit ESP32-S2 Feather

by WillMarchant on Mon Dec 13, 2021 10:46 am

I did a clean install of the Arduino IDE and 'FatFs' by stm32duino did not get reinstalled. The library manager shows the following "Data Storage" libraries when I query things that are installed:
"SD" built in by Arduino V1.2.4
"Adafruit SPIFlash" V3.7.1
"SdFat - Adafruit Fork" V1.2.4

WillMarchant
 
Posts: 17
Joined: Thu Sep 21, 2017 4:42 pm

Re: Arduino disk drive example for Adafruit ESP32-S2 Feather

by hathach on Mon Dec 13, 2021 11:25 am

can you upload your full compile log as txt file for analysis, I could compile them without any issue.

hathach
 
Posts: 1187
Joined: Tue Apr 23, 2013 1:02 am

Re: Arduino disk drive example for Adafruit ESP32-S2 Feather

by WillMarchant on Mon Dec 13, 2021 11:44 am

Bummer, I must have messed up when loading libraries.

The compile log was 2.5MB, so I gziped it before attaching below.

Thanks again for looking at this!
Attachments
verbosecompile.txt.gz
(47.33 KiB) Downloaded 3 times

WillMarchant
 
Posts: 17
Joined: Thu Sep 21, 2017 4:42 pm

Please be positive and constructive with your questions and comments.