From 0a3e82204a23402924a87c6df43652b7769be294 Mon Sep 17 00:00:00 2001 From: brentru Date: Mon, 9 Dec 2024 11:53:24 -0500 Subject: [PATCH 1/2] re-attach USB msc bug --- src/provisioning/tinyusb/Wippersnapper_FS.cpp | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/provisioning/tinyusb/Wippersnapper_FS.cpp b/src/provisioning/tinyusb/Wippersnapper_FS.cpp index d99c6098..e8f3038a 100644 --- a/src/provisioning/tinyusb/Wippersnapper_FS.cpp +++ b/src/provisioning/tinyusb/Wippersnapper_FS.cpp @@ -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 @@ -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(); @@ -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(); @@ -327,19 +327,17 @@ 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) + // Re-attach the USB device for file access + delay(500); + initUSBMSC(); + writeToBootOut( "ERROR: Please edit the secrets.json file. Then, reset your board.\n"); #ifdef USE_DISPLAY From 2409c85e293b540ca32e63395662102856b52cf9 Mon Sep 17 00:00:00 2001 From: brentru Date: Tue, 10 Dec 2024 13:07:06 -0500 Subject: [PATCH 2/2] Address feedback --- src/provisioning/tinyusb/Wippersnapper_FS.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/provisioning/tinyusb/Wippersnapper_FS.cpp b/src/provisioning/tinyusb/Wippersnapper_FS.cpp index e8f3038a..e4fa0ee7 100644 --- a/src/provisioning/tinyusb/Wippersnapper_FS.cpp +++ b/src/provisioning/tinyusb/Wippersnapper_FS.cpp @@ -334,10 +334,6 @@ void Wippersnapper_FS::createSecretsFile() { secretsFile.flush(); secretsFile.close(); - // Re-attach the USB device for file access - delay(500); - initUSBMSC(); - writeToBootOut( "ERROR: Please edit the secrets.json file. Then, reset your board.\n"); #ifdef USE_DISPLAY @@ -347,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."); }