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
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.
- WillMarchant
- Posts: 28
- Joined: Thu Sep 21, 2017 4:42 pm
- WillMarchant
- Posts: 28
- Joined: Thu Sep 21, 2017 4:42 pm
Re: Arduino disk drive example for Adafruit ESP32-S2 Feather
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!
- hathach
- Posts: 1271
- Joined: Tue Apr 23, 2013 1:02 am
Re: Arduino disk drive example for Adafruit ESP32-S2 Feather
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
- WillMarchant
- Posts: 28
- Joined: Thu Sep 21, 2017 4:42 pm
Re: Arduino disk drive example for Adafruit ESP32-S2 Feather
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...
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 6 times
- hathach
- Posts: 1271
- Joined: Tue Apr 23, 2013 1:02 am
Re: Arduino disk drive example for Adafruit ESP32-S2 Feather
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.
For the MSC drive, is the name FTHRS2BOOT, if yes, could you post its INFO_UF2.txt contents here.
- WillMarchant
- Posts: 28
- Joined: Thu Sep 21, 2017 4:42 pm
Re: Arduino disk drive example for Adafruit ESP32-S2 Feather
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!
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!
- hathach
- Posts: 1271
- Joined: Tue Apr 23, 2013 1:02 am
Re: Arduino disk drive example for Adafruit ESP32-S2 Feather
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.
- WillMarchant
- Posts: 28
- Joined: Thu Sep 21, 2017 4:42 pm
Re: Arduino disk drive example for Adafruit ESP32-S2 Feather
Excellent, thank you so much!
- hathach
- Posts: 1271
- Joined: Tue Apr 23, 2013 1:02 am
Re: Arduino disk drive example for Adafruit ESP32-S2 Feather
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
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 7 times
- WillMarchant
- Posts: 28
- Joined: Thu Sep 21, 2017 4:42 pm
Re: Arduino disk drive example for Adafruit ESP32-S2 Feather
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
/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
-
- List of installed "fat" libraries
- Screen Shot 2021-12-10 at 13.37.12.png (141.24 KiB) Viewed 430 times
- WillMarchant
- Posts: 28
- Joined: Thu Sep 21, 2017 4:42 pm
Re: Arduino disk drive example for Adafruit ESP32-S2 Feather
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?
- hathach
- Posts: 1271
- Joined: Tue Apr 23, 2013 1:02 am
Re: Arduino disk drive example for Adafruit ESP32-S2 Feather
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).
- WillMarchant
- Posts: 28
- Joined: Thu Sep 21, 2017 4:42 pm
Re: Arduino disk drive example for Adafruit ESP32-S2 Feather
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
"SD" built in by Arduino V1.2.4
"Adafruit SPIFlash" V3.7.1
"SdFat - Adafruit Fork" V1.2.4
- hathach
- Posts: 1271
- Joined: Tue Apr 23, 2013 1:02 am
Re: Arduino disk drive example for Adafruit ESP32-S2 Feather
can you upload your full compile log as txt file for analysis, I could compile them without any issue.
- WillMarchant
- Posts: 28
- Joined: Thu Sep 21, 2017 4:42 pm
Re: Arduino disk drive example for Adafruit ESP32-S2 Feather
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!
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 6 times
Please be positive and constructive with your questions and comments.