Skip to content

Commit

Permalink
Merge pull request #667 from adafruit/patch-usb-msc-bug
Browse files Browse the repository at this point in the history
Fix USB-MSC not re-attaching
  • Loading branch information
brentru authored Dec 10, 2024
2 parents b5dd8ed + 2409c85 commit 16bc28a
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions src/provisioning/tinyusb/Wippersnapper_FS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S3_REVTFT) || \
defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S2_REVTFT) || \
defined(ARDUINO_ADAFRUIT_QTPY_ESP32S3_N4R2)
#include "print_dependencies.h"
#include "Wippersnapper_FS.h"
#include "print_dependencies.h"
// On-board external flash (QSPI or SPI) macros should already
// defined in your board variant if supported
// - EXTERNAL_FLASH_USE_QSPI
Expand Down Expand Up @@ -92,11 +92,11 @@ bool setVolumeLabel() {
/**************************************************************************/
Wippersnapper_FS::Wippersnapper_FS() {
#if PRINT_DEPENDENCIES
WS_DEBUG_PRINTLN("Build Dependencies:");
WS_DEBUG_PRINTLN("*********************");
WS_DEBUG_PRINTLN(project_dependencies);
WS_DEBUG_PRINTLN("*********************");
WS_PRINTER.flush();
WS_DEBUG_PRINTLN("Build Dependencies:");
WS_DEBUG_PRINTLN("*********************");
WS_DEBUG_PRINTLN(project_dependencies);
WS_DEBUG_PRINTLN("*********************");
WS_PRINTER.flush();
#endif
// Detach USB device during init.
TinyUSBDevice.detach();
Expand Down Expand Up @@ -291,15 +291,15 @@ bool Wippersnapper_FS::createBootFile() {
bootFile.println(project_dependencies);
#endif

// Print ESP-specific info to boot file
#ifdef ARDUINO_ARCH_ESP32
// Print ESP-specific info to boot file
#ifdef ARDUINO_ARCH_ESP32
// Get version of ESP-IDF
bootFile.print("ESP-IDF Version: ");
bootFile.println(ESP.getSdkVersion());
// Get version of this core
bootFile.print("ESP32 Core Version: ");
bootFile.println(ESP.getCoreVersion());
#endif
#endif

bootFile.flush();
bootFile.close();
Expand Down Expand Up @@ -327,19 +327,13 @@ void Wippersnapper_FS::createSecretsFile() {
strcpy(secretsConfig.network.pass, "YOUR_WIFI_PASS_HERE");
secretsConfig.status_pixel_brightness = 0.2;

// Create and fill JSON document from secretsConfig
// Serialize the struct to a JSON document
JsonDocument doc;
doc.set(secretsConfig);

// Serialize JSON to file
serializeJsonPretty(doc, secretsFile);

// Flush and close file
secretsFile.flush();
secretsFile.close();
delay(2500);

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

Expand Down

0 comments on commit 16bc28a

Please sign in to comment.