Skip to content

Commit 16bc28a

Browse files
authored
Merge pull request #667 from adafruit/patch-usb-msc-bug
Fix USB-MSC not re-attaching
2 parents b5dd8ed + 2409c85 commit 16bc28a

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

src/provisioning/tinyusb/Wippersnapper_FS.cpp

+13-16
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S3_REVTFT) || \
2929
defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S2_REVTFT) || \
3030
defined(ARDUINO_ADAFRUIT_QTPY_ESP32S3_N4R2)
31-
#include "print_dependencies.h"
3231
#include "Wippersnapper_FS.h"
32+
#include "print_dependencies.h"
3333
// On-board external flash (QSPI or SPI) macros should already
3434
// defined in your board variant if supported
3535
// - EXTERNAL_FLASH_USE_QSPI
@@ -92,11 +92,11 @@ bool setVolumeLabel() {
9292
/**************************************************************************/
9393
Wippersnapper_FS::Wippersnapper_FS() {
9494
#if PRINT_DEPENDENCIES
95-
WS_DEBUG_PRINTLN("Build Dependencies:");
96-
WS_DEBUG_PRINTLN("*********************");
97-
WS_DEBUG_PRINTLN(project_dependencies);
98-
WS_DEBUG_PRINTLN("*********************");
99-
WS_PRINTER.flush();
95+
WS_DEBUG_PRINTLN("Build Dependencies:");
96+
WS_DEBUG_PRINTLN("*********************");
97+
WS_DEBUG_PRINTLN(project_dependencies);
98+
WS_DEBUG_PRINTLN("*********************");
99+
WS_PRINTER.flush();
100100
#endif
101101
// Detach USB device during init.
102102
TinyUSBDevice.detach();
@@ -291,15 +291,15 @@ bool Wippersnapper_FS::createBootFile() {
291291
bootFile.println(project_dependencies);
292292
#endif
293293

294-
// Print ESP-specific info to boot file
295-
#ifdef ARDUINO_ARCH_ESP32
294+
// Print ESP-specific info to boot file
295+
#ifdef ARDUINO_ARCH_ESP32
296296
// Get version of ESP-IDF
297297
bootFile.print("ESP-IDF Version: ");
298298
bootFile.println(ESP.getSdkVersion());
299299
// Get version of this core
300300
bootFile.print("ESP32 Core Version: ");
301301
bootFile.println(ESP.getCoreVersion());
302-
#endif
302+
#endif
303303

304304
bootFile.flush();
305305
bootFile.close();
@@ -327,19 +327,13 @@ void Wippersnapper_FS::createSecretsFile() {
327327
strcpy(secretsConfig.network.pass, "YOUR_WIFI_PASS_HERE");
328328
secretsConfig.status_pixel_brightness = 0.2;
329329

330-
// Create and fill JSON document from secretsConfig
330+
// Serialize the struct to a JSON document
331331
JsonDocument doc;
332332
doc.set(secretsConfig);
333-
334-
// Serialize JSON to file
335333
serializeJsonPretty(doc, secretsFile);
336-
337-
// Flush and close file
338334
secretsFile.flush();
339335
secretsFile.close();
340-
delay(2500);
341336

342-
// Signal to user that action must be taken (edit secrets.json)
343337
writeToBootOut(
344338
"ERROR: Please edit the secrets.json file. Then, reset your board.\n");
345339
#ifdef USE_DISPLAY
@@ -349,6 +343,9 @@ void Wippersnapper_FS::createSecretsFile() {
349343
"Please edit it to reflect your Adafruit IO and network credentials. "
350344
"When you're done, press RESET on the board.");
351345
#endif
346+
// Re-attach the USB device for file access
347+
delay(500);
348+
initUSBMSC();
352349
fsHalt("ERROR: Please edit the secrets.json file. Then, reset your board.");
353350
}
354351

0 commit comments

Comments
 (0)