From 19e069d9ea0ad4ea44c5213b02b55a7f22557e9a Mon Sep 17 00:00:00 2001 From: fOmey Date: Wed, 31 May 2023 15:14:32 +1000 Subject: [PATCH 01/15] SD_MMC library --- esp32_marauder/Display.cpp | 2 +- esp32_marauder/MenuFunctions.cpp | 8 ++++---- esp32_marauder/SDInterface.cpp | 32 ++++++++++++++++++-------------- esp32_marauder/SDInterface.h | 4 ++-- 4 files changed, 25 insertions(+), 21 deletions(-) diff --git a/esp32_marauder/Display.cpp b/esp32_marauder/Display.cpp index eb40c882c..fafc4f6d1 100644 --- a/esp32_marauder/Display.cpp +++ b/esp32_marauder/Display.cpp @@ -615,7 +615,7 @@ void createArray(const char *filename) { // Open the named file fs::File jpgFile = SPIFFS.open( filename, "r"); // File handle reference for SPIFFS - // File jpgFile = SD.open( filename, FILE_READ); // or, file handle reference for SD library + // File jpgFile = SD_MMC.open( filename, FILE_READ); // or, file handle reference for SD library if ( !jpgFile ) { Serial.print("ERROR: File \""); Serial.print(filename); Serial.println ("\" not found!"); diff --git a/esp32_marauder/MenuFunctions.cpp b/esp32_marauder/MenuFunctions.cpp index e034274ef..7ab3aeaa9 100644 --- a/esp32_marauder/MenuFunctions.cpp +++ b/esp32_marauder/MenuFunctions.cpp @@ -555,7 +555,7 @@ MenuFunctions::MenuFunctions() Serial.println("Writing to target file: " + (String)target_file_name); // Open file with the given name - File script = SD.open(target_file_name, FILE_WRITE); + File script = SD_MMC.open(target_file_name, FILE_WRITE); if (script) { menu_function_obj.loaded_file = target_file_name; @@ -596,7 +596,7 @@ MenuFunctions::MenuFunctions() // Get file content and send to text area if (btn_text != text12) { - File script = SD.open(btn_text); + File script = SD_MMC.open(btn_text); if (script) { while (script.available()) { @@ -648,7 +648,7 @@ MenuFunctions::MenuFunctions() //lv_list_set_anim_time(list1, 0); // Load file names into buttons - File scripts = SD.open("/SCRIPTS"); + File scripts = SD_MMC.open("/SCRIPTS"); // Build list of files from the SD card lv_obj_t * list_btn; @@ -713,7 +713,7 @@ MenuFunctions::MenuFunctions() Serial.println("Writing to file: " + (String)menu_function_obj.loaded_file); - File script = SD.open(menu_function_obj.loaded_file, FILE_WRITE); + File script = SD_MMC.open(menu_function_obj.loaded_file, FILE_WRITE); // Write data to file if (script) { diff --git a/esp32_marauder/SDInterface.cpp b/esp32_marauder/SDInterface.cpp index 5c34b0c7a..fabafdec9 100644 --- a/esp32_marauder/SDInterface.cpp +++ b/esp32_marauder/SDInterface.cpp @@ -5,8 +5,8 @@ bool SDInterface::initSD() { String display_string = ""; #ifdef KIT - pinMode(SD_DET, INPUT); - if (digitalRead(SD_DET) == LOW) { + pinMode(SDMMC_DET, INPUT); + if (digitalRead(SDMMC_DET) == LOW) { Serial.println(F("SD Card Detect Pin Detected")); } else { @@ -20,14 +20,18 @@ bool SDInterface::initSD() { delay(10); - if (!SD.begin(SD_CS)) { + #ifdef SDMMC_CUSTOMPINS + SD_MMC.setPins(SDMMC_CLK, SDMMC_CMD, SDMMC_D0); + #endif + + if (!SD_MMC.begin("/sdcard", true, false, 20000, 5)) { Serial.println(F("Failed to mount SD Card")); this->supported = false; return false; } else { this->supported = true; - this->cardType = SD.cardType(); + this->cardType = SD_MMC.cardType(); //if (cardType == CARD_MMC) // Serial.println(F("SD: MMC Mounted")); //else if(cardType == CARD_SD) @@ -37,7 +41,7 @@ bool SDInterface::initSD() { //else // Serial.println(F("SD: UNKNOWN Card Mounted")); - this->cardSizeMB = SD.cardSize() / (1024 * 1024); + this->cardSizeMB = SD_MMC.cardSize() / (1024 * 1024); //Serial.printf("SD Card Size: %lluMB\n", this->cardSizeMB); @@ -58,10 +62,10 @@ bool SDInterface::initSD() { buffer_obj = Buffer(); - if (!SD.exists("/SCRIPTS")) { + if (!SD_MMC.exists("/SCRIPTS")) { Serial.println("/SCRIPTS does not exist. Creating..."); - SD.mkdir("/SCRIPTS"); + SD_MMC.mkdir("/SCRIPTS"); Serial.println("/SCRIPTS created"); } @@ -71,7 +75,7 @@ bool SDInterface::initSD() { void SDInterface::listDir(String str_dir){ if (this->supported) { - File dir = SD.open(str_dir); + File dir = SD_MMC.open(str_dir); while (true) { File entry = dir.openNextFile(); @@ -100,7 +104,7 @@ void SDInterface::addPacket(uint8_t* buf, uint32_t len) { void SDInterface::openCapture(String file_name) { bool save_pcap = settings_obj.loadSetting("SavePCAP"); if ((this->supported) && (save_pcap)) { - buffer_obj.createPcapFile(&SD, file_name); + buffer_obj.createPcapFile(&SD_MMC, file_name); buffer_obj.open(); } } @@ -115,7 +119,7 @@ void SDInterface::runUpdate() { display_obj.tft.println(F(text15)); #endif - File updateBin = SD.open("/update.bin"); + File updateBin = SD_MMC.open("/update.bin"); if (updateBin) { if(updateBin.isDirectory()){ #ifdef HAS_SCREEN @@ -136,7 +140,7 @@ void SDInterface::runUpdate() { #ifdef HAS_SCREEN display_obj.tft.println(F(text_table2[1])); #endif - Serial.println(F("Starting update over SD. Please wait...")); + Serial.println(F("Starting update over SD_MMC. Please wait...")); this->performUpdate(updateBin, updateSize); } else { @@ -158,7 +162,7 @@ void SDInterface::runUpdate() { display_obj.tft.println(F(text_table2[3])); #endif Serial.println(F("rebooting...")); - //SD.remove("/update.bin"); + //SD_MMC.remove("/update.bin"); delay(1000); ESP.restart(); } @@ -231,7 +235,7 @@ void SDInterface::performUpdate(Stream &updateSource, size_t updateSize) { bool SDInterface::checkDetectPin() { #ifdef KIT - if (digitalRead(SD_DET) == LOW) + if (digitalRead(SDMMC_DET) == LOW) return true; else return false; @@ -243,7 +247,7 @@ bool SDInterface::checkDetectPin() { void SDInterface::main() { if ((this->supported) && (this->do_save)) { //Serial.println("Saving packet..."); - buffer_obj.forceSave(&SD); + buffer_obj.forceSave(&SD_MMC); } else if (!this->supported) { if (checkDetectPin()) { diff --git a/esp32_marauder/SDInterface.h b/esp32_marauder/SDInterface.h index 156e259ca..054b06de1 100644 --- a/esp32_marauder/SDInterface.h +++ b/esp32_marauder/SDInterface.h @@ -4,7 +4,7 @@ #include "configs.h" #include "settings.h" -#include "SD.h" +#include "SD_MMC.h" #include "Buffer.h" #ifdef HAS_SCREEN #include "Display.h" @@ -18,7 +18,7 @@ extern Settings settings_obj; #endif #ifdef KIT - #define SD_DET 4 + #define SDMMC_DET 4 #endif class SDInterface { From 97b7c8a865f5811b06399c47ab421b2e892bcf81 Mon Sep 17 00:00:00 2001 From: fOmey Date: Wed, 31 May 2023 15:29:26 +1000 Subject: [PATCH 02/15] Update configs definitons --- esp32_marauder/SDInterface.cpp | 2 +- esp32_marauder/configs.h | 28 ++++++++++++++++++---------- esp32_marauder/esp32_marauder.ino | 4 ++-- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/esp32_marauder/SDInterface.cpp b/esp32_marauder/SDInterface.cpp index fabafdec9..3eb71e6b5 100644 --- a/esp32_marauder/SDInterface.cpp +++ b/esp32_marauder/SDInterface.cpp @@ -16,7 +16,7 @@ bool SDInterface::initSD() { } #endif - pinMode(SD_CS, OUTPUT); + pinMode(SDMMC_CS, OUTPUT); delay(10); diff --git a/esp32_marauder/configs.h b/esp32_marauder/configs.h index 36e824d12..2d159f2fa 100644 --- a/esp32_marauder/configs.h +++ b/esp32_marauder/configs.h @@ -60,7 +60,7 @@ #define TFT_RST 18 #define TFT_BL 10 #define TOUCH_CS 10 - //#define SD_CS 1 + //#define SDMMC_CS 1 #define SCREEN_BUFFER @@ -294,7 +294,7 @@ #define TFT_RST 5 #define TFT_BL 32 #define TOUCH_CS 21 - #define SD_CS 4 + #define SDMMC_CS 4 #define SCREEN_BUFFER @@ -448,35 +448,43 @@ //// SD DEFINITIONS #ifdef MARAUDER_V4 - #define SD_CS 12 + #define SDMMC_CS 12 #endif #ifdef MARAUDER_V6 - #define SD_CS 12 + #define SDMMC_CS 12 #endif #ifdef MARAUDER_KIT - #define SD_CS 12 + #define SDMMC_CS 12 #endif #ifdef MARAUDER_MINI - #define SD_CS 4 + #define SDMMC_CS 4 #endif #ifdef MARAUDER_M5STICKC - #define SD_CS 10 + #define SDMMC_CS 10 #endif #ifdef MARAUDER_FLIPPER - #define SD_CS 10 + #define SDMMC_CS 10 #endif #ifdef ESP32_LDDB - #define SD_CS 4 + #define SDMMC_CS 4 #endif #ifdef MARAUDER_DEV_BOARD_PRO - #define SD_CS 4 + #define SDMMC_CS 4 + #endif + + #ifdef FLIPPER_ENDGAME_S3 + #define SDMMC_CS 14 + #define SDMMC_CUSTOMPINS + #define SDMMC_CLK 9 + #define SDMMC_D0 11 // MOSI + #define SDMMC_CMD 10 // MISO #endif //// END SD DEFINITIONS diff --git a/esp32_marauder/esp32_marauder.ino b/esp32_marauder/esp32_marauder.ino index 1a811379d..f4041e4a1 100644 --- a/esp32_marauder/esp32_marauder.ino +++ b/esp32_marauder/esp32_marauder.ino @@ -140,11 +140,11 @@ void setup() digitalWrite(TFT_CS, HIGH); #endif - pinMode(SD_CS, OUTPUT); + pinMode(SDMMC_CS, OUTPUT); delay(10); - digitalWrite(SD_CS, HIGH); + digitalWrite(SDMMC_CS, HIGH); delay(10); From 8ac4a3d5c16ca126e24aa369eb2c262ea94ed057 Mon Sep 17 00:00:00 2001 From: fOmey Date: Wed, 31 May 2023 15:47:11 +1000 Subject: [PATCH 03/15] Build push changes --- .github/workflows/build_push.yml | 47 +++++++++++++++++++++++--------- esp32_marauder/configs.h | 3 +- 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build_push.yml b/.github/workflows/build_push.yml index 4e29579cc..5e7239e16 100644 --- a/.github/workflows/build_push.yml +++ b/.github/workflows/build_push.yml @@ -16,12 +16,12 @@ jobs: - name: Checkout Code uses: actions/checkout@v3 - - name: Pull arduino-esp32 v2.0.4 + - name: Pull arduino-esp32 uses: actions/checkout@v2 with: repository: espressif/arduino-esp32 - ref: 2.0.4 - path: 2.0.4arduino-esp32 + ref: master + path: arduino-esp32 - name: Install TFT_eSPI uses: actions/checkout@v2 @@ -79,10 +79,6 @@ jobs: ref: main path: CustomSwitchLib - - name: Search for SD lib in arduino-esp32 v2.0.4 - run: | - find /home/runner/work/ESP32Marauder/ESP32Marauder/2.0.4arduino-esp32 -name "SD" - - name: Configure TFT_eSPI run: | rm -f CustomTFT_eSPI/User_Setup_Select.h @@ -101,12 +97,6 @@ jobs: arduino-board-fqbn: esp32:esp32:esp32s2 platform-url: https://github.com/espressif/arduino-esp32/releases/download/2.0.3/package_esp32_dev_index.json - - name: Replace SD lib - run: | - rm -rf /home/runner/.arduino15/packages/esp32/hardware/esp32/2.0.3/libraries/SD - cp -R /home/runner/work/ESP32Marauder/ESP32Marauder/2.0.4arduino-esp32/libraries/SD /home/runner/.arduino15/packages/esp32/hardware/esp32/2.0.3/libraries/SD - ls -la /home/runner/.arduino15/packages/esp32/hardware/esp32/2.0.3/libraries/SD - - name: Modify platform.txt run: | echo "Chicken" @@ -164,6 +154,30 @@ jobs: run: | mv ./esp32_marauder/build/esp32.esp32.esp32s3/esp32_marauder.ino.bin ./esp32_marauder/build/esp32.esp32.esp32s3/esp32_marauder.multiboardS3.bin + - name: Configure configs.h for End Game Board + run: | + pwd + sed -i 's/^ #define MARAUDER_MINI/ \/\/#define MARAUDER_MINI/' esp32_marauder/configs.h + sed -i 's/^ #define MARAUDER_V4/ \/\/#define MARAUDER_V4/' esp32_marauder/configs.h + sed -i 's/^ #define MARAUDER_V6/ \/\/#define MARAUDER_V6/' esp32_marauder/configs.h + sed -i 's/^ #define MARAUDER_KIT/ \/\/#define MARAUDER_KIT/' esp32_marauder/configs.h + sed -i 's/^ #define GENERIC_ESP32/ \/\/#define GENERIC_ESP32/' esp32_marauder/configs.h + sed -i 's/^ #define MARAUDER_FLIPPER/ \/\/#define MARAUDER_FLIPPER/' esp32_marauder/configs.h + sed -i 's/^ #define ESP32_LDDB/ \/\/#define ESP32_LDDB/' esp32_marauder/configs.h + sed -i 's/^ #define MARAUDER_DEV_BOARD_PRO/ \/\/#define MARAUDER_DEV_BOARD_PRO/' esp32_marauder/configs.h + sed -i 's/^ \/\/#define MARAUDER_ENDGAME_S3/ #define MARAUDER_ENDGAME_S3/' esp32_marauder/configs.h + + - name: Build Marauder for End Game Board + uses: ArminJo/arduino-test-compile@v3.2.0 + with: + sketch-names: esp32_marauder.ino + arduino-board-fqbn: esp32:esp32:esp32s3:PartitionScheme=min_spiffs,FlashSize=8M,PSRAM=enabled + extra-arduino-cli-args: "--warnings none" + + - name: Rename Marauder End Game bin + run: | + mv ./esp32_marauder/build/esp32.esp32.esp32s3/esp32_marauder.ino.bin ./esp32_marauder/build/esp32.esp32.esp32s3/esp32_marauder.endgameS3.bin + - name: Configure TFT_eSPI and configs.h for OG Marauder run: | pwd @@ -178,6 +192,7 @@ jobs: sed -i 's/^ #define MARAUDER_FLIPPER/ \/\/#define MARAUDER_FLIPPER/' esp32_marauder/configs.h sed -i 's/^ #define ESP32_LDDB/ \/\/#define ESP32_LDDB/' esp32_marauder/configs.h sed -i 's/^ #define MARAUDER_DEV_BOARD_PRO/ \/\/#define MARAUDER_DEV_BOARD_PRO/' esp32_marauder/configs.h + sed -i 's/^ #define MARAUDER_ENDGAME_S3/ \/\/#define MARAUDER_ENDGAME_S3/' esp32_marauder/configs.h - name: Build Marauder for OG Marauder uses: ArminJo/arduino-test-compile@v3.2.0 @@ -202,6 +217,7 @@ jobs: sed -i 's/^ #define MARAUDER_FLIPPER/ \/\/#define MARAUDER_FLIPPER/' esp32_marauder/configs.h sed -i 's/^ #define ESP32_LDDB/ \/\/#define ESP32_LDDB/' esp32_marauder/configs.h sed -i 's/^ #define MARAUDER_DEV_BOARD_PRO/ \/\/#define MARAUDER_DEV_BOARD_PRO/' esp32_marauder/configs.h + sed -i 's/^ #define MARAUDER_ENDGAME_S3/ \/\/#define MARAUDER_ENDGAME_S3/' esp32_marauder/configs.h - name: Build Marauder for v6 Marauder uses: ArminJo/arduino-test-compile@v3.2.0 @@ -226,6 +242,7 @@ jobs: sed -i 's/^ #define MARAUDER_FLIPPER/ \/\/#define MARAUDER_FLIPPER/' esp32_marauder/configs.h sed -i 's/^ #define ESP32_LDDB/ \/\/#define ESP32_LDDB/' esp32_marauder/configs.h sed -i 's/^ #define MARAUDER_DEV_BOARD_PRO/ \/\/#define MARAUDER_DEV_BOARD_PRO/' esp32_marauder/configs.h + sed -i 's/^ #define MARAUDER_ENDGAME_S3/ \/\/#define MARAUDER_ENDGAME_S3/' esp32_marauder/configs.h - name: Build Marauder for Marauder Kit uses: ArminJo/arduino-test-compile@v3.2.0 @@ -250,6 +267,7 @@ jobs: sed -i 's/^ #define MARAUDER_FLIPPER/ \/\/#define MARAUDER_FLIPPER/' esp32_marauder/configs.h sed -i 's/^ #define ESP32_LDDB/ \/\/#define ESP32_LDDB/' esp32_marauder/configs.h sed -i 's/^ #define MARAUDER_DEV_BOARD_PRO/ \/\/#define MARAUDER_DEV_BOARD_PRO/' esp32_marauder/configs.h + sed -i 's/^ #define MARAUDER_ENDGAME_S3/ \/\/#define MARAUDER_ENDGAME_S3/' esp32_marauder/configs.h - name: Build Marauder for Marauder Mini uses: ArminJo/arduino-test-compile@v3.2.0 @@ -272,6 +290,7 @@ jobs: sed -i 's/^ #define MARAUDER_FLIPPER/ \/\/#define MARAUDER_FLIPPER/' esp32_marauder/configs.h sed -i 's/^ \/\/#define ESP32_LDDB/ #define ESP32_LDDB/' esp32_marauder/configs.h sed -i 's/^ #define MARAUDER_DEV_BOARD_PRO/ \/\/#define MARAUDER_DEV_BOARD_PRO/' esp32_marauder/configs.h + sed -i 's/^ #define MARAUDER_ENDGAME_S3/ \/\/#define MARAUDER_ENDGAME_S3/' esp32_marauder/configs.h - name: Build Marauder for ESP32 LDDB uses: ArminJo/arduino-test-compile@v3.2.0 @@ -294,6 +313,7 @@ jobs: sed -i 's/^ #define MARAUDER_FLIPPER/ \/\/#define MARAUDER_FLIPPER/' esp32_marauder/configs.h sed -i 's/^ #define ESP32_LDDB/ \/\/#define ESP32_LDDB/' esp32_marauder/configs.h sed -i 's/^ \/\/#define MARAUDER_DEV_BOARD_PRO/ #define MARAUDER_DEV_BOARD_PRO/' esp32_marauder/configs.h + sed -i 's/^ #define MARAUDER_ENDGAME_S3/ \/\/#define MARAUDER_ENDGAME_S3/' esp32_marauder/configs.h - name: Build Marauder for Marauder Dev Board Pro uses: ArminJo/arduino-test-compile@v3.2.0 @@ -320,6 +340,7 @@ jobs: sed -i 's/^ #define MARAUDER_FLIPPER/ \/\/#define MARAUDER_FLIPPER/' esp32_marauder/configs.h sed -i 's/^ #define ESP32_LDDB/ \/\/#define ESP32_LDDB/' esp32_marauder/configs.h sed -i 's/^ #define MARAUDER_DEV_BOARD_PRO/ \/\/#define MARAUDER_DEV_BOARD_PRO/' esp32_marauder/configs.h + sed -i 's/^ #define MARAUDER_ENDGAME_S3/ \/\/#define MARAUDER_ENDGAME_S3/' esp32_marauder/configs.h sed -i 's/^ \/\/#define MARAUDER_M5STICKC/ #define MARAUDER_M5STICKC/' esp32_marauder/configs.h - name: Build Marauder for Marauder M5StickC diff --git a/esp32_marauder/configs.h b/esp32_marauder/configs.h index 2d159f2fa..22cda864b 100644 --- a/esp32_marauder/configs.h +++ b/esp32_marauder/configs.h @@ -17,6 +17,7 @@ #define MARAUDER_FLIPPER //#define ESP32_LDDB //#define MARAUDER_DEV_BOARD_PRO + //#define MARAUDER_ENDGAME_S3 #define MARAUDER_VERSION "v0.10.6" @@ -479,7 +480,7 @@ #define SDMMC_CS 4 #endif - #ifdef FLIPPER_ENDGAME_S3 + #ifdef MARAUDER_ENDGAME_S3 #define SDMMC_CS 14 #define SDMMC_CUSTOMPINS #define SDMMC_CLK 9 From 3bb21502d5b4784920f62606eeac57d85e9696d3 Mon Sep 17 00:00:00 2001 From: fOmey Date: Wed, 31 May 2023 20:04:26 +1000 Subject: [PATCH 04/15] SD_MMC library pt.2 --- esp32_marauder/Display.cpp | 2 +- esp32_marauder/MenuFunctions.cpp | 8 +++--- esp32_marauder/SDInterface.cpp | 48 ++++++++++++++++++++----------- esp32_marauder/SDInterface.h | 9 ++++-- esp32_marauder/configs.h | 36 ++++++++++++++++------- esp32_marauder/esp32_marauder.ino | 8 ------ 6 files changed, 68 insertions(+), 43 deletions(-) diff --git a/esp32_marauder/Display.cpp b/esp32_marauder/Display.cpp index fafc4f6d1..da3fd3637 100644 --- a/esp32_marauder/Display.cpp +++ b/esp32_marauder/Display.cpp @@ -615,7 +615,7 @@ void createArray(const char *filename) { // Open the named file fs::File jpgFile = SPIFFS.open( filename, "r"); // File handle reference for SPIFFS - // File jpgFile = SD_MMC.open( filename, FILE_READ); // or, file handle reference for SD library + // File jpgFile = SD_FS.open( filename, FILE_READ); // or, file handle reference for SD library if ( !jpgFile ) { Serial.print("ERROR: File \""); Serial.print(filename); Serial.println ("\" not found!"); diff --git a/esp32_marauder/MenuFunctions.cpp b/esp32_marauder/MenuFunctions.cpp index 7ab3aeaa9..8d7d785b3 100644 --- a/esp32_marauder/MenuFunctions.cpp +++ b/esp32_marauder/MenuFunctions.cpp @@ -555,7 +555,7 @@ MenuFunctions::MenuFunctions() Serial.println("Writing to target file: " + (String)target_file_name); // Open file with the given name - File script = SD_MMC.open(target_file_name, FILE_WRITE); + File script = SD_FS.open(target_file_name, FILE_WRITE); if (script) { menu_function_obj.loaded_file = target_file_name; @@ -596,7 +596,7 @@ MenuFunctions::MenuFunctions() // Get file content and send to text area if (btn_text != text12) { - File script = SD_MMC.open(btn_text); + File script = SD_FS.open(btn_text); if (script) { while (script.available()) { @@ -648,7 +648,7 @@ MenuFunctions::MenuFunctions() //lv_list_set_anim_time(list1, 0); // Load file names into buttons - File scripts = SD_MMC.open("/SCRIPTS"); + File scripts = SD_FS.open("/SCRIPTS"); // Build list of files from the SD card lv_obj_t * list_btn; @@ -713,7 +713,7 @@ MenuFunctions::MenuFunctions() Serial.println("Writing to file: " + (String)menu_function_obj.loaded_file); - File script = SD_MMC.open(menu_function_obj.loaded_file, FILE_WRITE); + File script = SD_FS.open(menu_function_obj.loaded_file, FILE_WRITE); // Write data to file if (script) { diff --git a/esp32_marauder/SDInterface.cpp b/esp32_marauder/SDInterface.cpp index 3eb71e6b5..914a001f6 100644 --- a/esp32_marauder/SDInterface.cpp +++ b/esp32_marauder/SDInterface.cpp @@ -4,9 +4,9 @@ bool SDInterface::initSD() { String display_string = ""; - #ifdef KIT - pinMode(SDMMC_DET, INPUT); - if (digitalRead(SDMMC_DET) == LOW) { + #ifdef SD_DET + pinMode(SD_DET, INPUT); + if (digitalRead(SD_DET) == LOW) { Serial.println(F("SD Card Detect Pin Detected")); } else { @@ -16,22 +16,36 @@ bool SDInterface::initSD() { } #endif - pinMode(SDMMC_CS, OUTPUT); - - delay(10); + #ifdef SD_CS + pinMode(SD_CS, OUTPUT); + delay(10); + digitalWrite(SD_CS, HIGH); + delay(10); + #endif + #ifdef SDMMC_CS + pinMode(SDMMC_CS, OUTPUT); + delay(10); + digitalWrite(SDMMC_CS, HIGH); + delay(10); + #endif #ifdef SDMMC_CUSTOMPINS SD_MMC.setPins(SDMMC_CLK, SDMMC_CMD, SDMMC_D0); #endif + #ifdef SD_CS + if (!SD.begin(SD_CS)) { + #endif + #ifdef SDMMC_CS if (!SD_MMC.begin("/sdcard", true, false, 20000, 5)) { + #endif Serial.println(F("Failed to mount SD Card")); this->supported = false; return false; } else { this->supported = true; - this->cardType = SD_MMC.cardType(); + this->cardType = SD_FS.cardType(); //if (cardType == CARD_MMC) // Serial.println(F("SD: MMC Mounted")); //else if(cardType == CARD_SD) @@ -41,7 +55,7 @@ bool SDInterface::initSD() { //else // Serial.println(F("SD: UNKNOWN Card Mounted")); - this->cardSizeMB = SD_MMC.cardSize() / (1024 * 1024); + this->cardSizeMB = SD_FS.cardSize() / (1024 * 1024); //Serial.printf("SD Card Size: %lluMB\n", this->cardSizeMB); @@ -62,10 +76,10 @@ bool SDInterface::initSD() { buffer_obj = Buffer(); - if (!SD_MMC.exists("/SCRIPTS")) { + if (!SD_FS.exists("/SCRIPTS")) { Serial.println("/SCRIPTS does not exist. Creating..."); - SD_MMC.mkdir("/SCRIPTS"); + SD_FS.mkdir("/SCRIPTS"); Serial.println("/SCRIPTS created"); } @@ -75,7 +89,7 @@ bool SDInterface::initSD() { void SDInterface::listDir(String str_dir){ if (this->supported) { - File dir = SD_MMC.open(str_dir); + File dir = SD_FS.open(str_dir); while (true) { File entry = dir.openNextFile(); @@ -104,7 +118,7 @@ void SDInterface::addPacket(uint8_t* buf, uint32_t len) { void SDInterface::openCapture(String file_name) { bool save_pcap = settings_obj.loadSetting("SavePCAP"); if ((this->supported) && (save_pcap)) { - buffer_obj.createPcapFile(&SD_MMC, file_name); + buffer_obj.createPcapFile(&SD_FS, file_name); buffer_obj.open(); } } @@ -119,7 +133,7 @@ void SDInterface::runUpdate() { display_obj.tft.println(F(text15)); #endif - File updateBin = SD_MMC.open("/update.bin"); + File updateBin = SD_FS.open("/update.bin"); if (updateBin) { if(updateBin.isDirectory()){ #ifdef HAS_SCREEN @@ -140,7 +154,7 @@ void SDInterface::runUpdate() { #ifdef HAS_SCREEN display_obj.tft.println(F(text_table2[1])); #endif - Serial.println(F("Starting update over SD_MMC. Please wait...")); + Serial.println(F("Starting update over SD. Please wait...")); this->performUpdate(updateBin, updateSize); } else { @@ -162,7 +176,7 @@ void SDInterface::runUpdate() { display_obj.tft.println(F(text_table2[3])); #endif Serial.println(F("rebooting...")); - //SD_MMC.remove("/update.bin"); + //SD_FS.remove("/update.bin"); delay(1000); ESP.restart(); } @@ -235,7 +249,7 @@ void SDInterface::performUpdate(Stream &updateSource, size_t updateSize) { bool SDInterface::checkDetectPin() { #ifdef KIT - if (digitalRead(SDMMC_DET) == LOW) + if (digitalRead(SD_DET) == LOW) return true; else return false; @@ -247,7 +261,7 @@ bool SDInterface::checkDetectPin() { void SDInterface::main() { if ((this->supported) && (this->do_save)) { //Serial.println("Saving packet..."); - buffer_obj.forceSave(&SD_MMC); + buffer_obj.forceSave(&SD_FS); } else if (!this->supported) { if (checkDetectPin()) { diff --git a/esp32_marauder/SDInterface.h b/esp32_marauder/SDInterface.h index 054b06de1..c96783d7b 100644 --- a/esp32_marauder/SDInterface.h +++ b/esp32_marauder/SDInterface.h @@ -4,7 +4,12 @@ #include "configs.h" #include "settings.h" -#include "SD_MMC.h" +#ifdef SD_CS + #include "SD.h" +#endif +#ifdef SDMMC_CS + #include "SD_MMC.h" +#endif #include "Buffer.h" #ifdef HAS_SCREEN #include "Display.h" @@ -18,7 +23,7 @@ extern Settings settings_obj; #endif #ifdef KIT - #define SDMMC_DET 4 + #define SD_DET 4 #endif class SDInterface { diff --git a/esp32_marauder/configs.h b/esp32_marauder/configs.h index 22cda864b..ab8f5677c 100644 --- a/esp32_marauder/configs.h +++ b/esp32_marauder/configs.h @@ -61,7 +61,7 @@ #define TFT_RST 18 #define TFT_BL 10 #define TOUCH_CS 10 - //#define SDMMC_CS 1 + //#define SD_CS 1 #define SCREEN_BUFFER @@ -295,7 +295,7 @@ #define TFT_RST 5 #define TFT_BL 32 #define TOUCH_CS 21 - #define SDMMC_CS 4 + #define SD_CS 4 #define SCREEN_BUFFER @@ -448,44 +448,58 @@ //// END MENU DEFINITIONS //// SD DEFINITIONS + // "SD_FS" is required, used as a filesystem pointer + // ESP32/ESP32-S2 define as "SD_FS SD" + // ESP32-S3 define as "SD_FS SD_MMC" + // "SD_CS" or "SDMMC_CS" are also required, one or the other not both. This is used to determine what SD library is used + // "SDMMC_CUSTOMPINS", is optional. "SDMMC_CLK", "SDMMC_D0", "SDMMC_CMD" are required if "SDMMC_CUSTOMPINS" is used. #ifdef MARAUDER_V4 - #define SDMMC_CS 12 + #define SD_FS SD + #define SD_CS 12 #endif #ifdef MARAUDER_V6 - #define SDMMC_CS 12 + #define SD_FS SD + #define SD_CS 12 #endif #ifdef MARAUDER_KIT - #define SDMMC_CS 12 + #define SD_FS SD + #define SD_CS 12 #endif #ifdef MARAUDER_MINI - #define SDMMC_CS 4 + #define SD_FS SD + #define SD_CS 4 #endif #ifdef MARAUDER_M5STICKC - #define SDMMC_CS 10 + #define SD_FS SD + #define SD_CS 10 #endif #ifdef MARAUDER_FLIPPER - #define SDMMC_CS 10 + #define SD_FS SD + #define SD_CS 10 #endif #ifdef ESP32_LDDB - #define SDMMC_CS 4 + #define SD_FS SD + #define SD_CS 4 #endif #ifdef MARAUDER_DEV_BOARD_PRO - #define SDMMC_CS 4 + #define SD_FS SD + #define SD_CS 4 #endif #ifdef MARAUDER_ENDGAME_S3 + #define SD_FS SD_MMC #define SDMMC_CS 14 #define SDMMC_CUSTOMPINS #define SDMMC_CLK 9 - #define SDMMC_D0 11 // MOSI #define SDMMC_CMD 10 // MISO + #define SDMMC_D0 11 // MOSI #endif //// END SD DEFINITIONS diff --git a/esp32_marauder/esp32_marauder.ino b/esp32_marauder/esp32_marauder.ino index f4041e4a1..fd72d4dfa 100644 --- a/esp32_marauder/esp32_marauder.ino +++ b/esp32_marauder/esp32_marauder.ino @@ -140,14 +140,6 @@ void setup() digitalWrite(TFT_CS, HIGH); #endif - pinMode(SDMMC_CS, OUTPUT); - - delay(10); - - digitalWrite(SDMMC_CS, HIGH); - - delay(10); - Serial.begin(115200); #ifdef WRITE_PACKETS_SERIAL From 195c44801d0a256eac29082657fc0a211e075bc9 Mon Sep 17 00:00:00 2001 From: fOmey Date: Wed, 31 May 2023 20:05:25 +1000 Subject: [PATCH 05/15] Temprature nag fix --- esp32_marauder/TemperatureInterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esp32_marauder/TemperatureInterface.cpp b/esp32_marauder/TemperatureInterface.cpp index 441e376b4..a1073c24d 100644 --- a/esp32_marauder/TemperatureInterface.cpp +++ b/esp32_marauder/TemperatureInterface.cpp @@ -19,7 +19,7 @@ void TemperatureInterface::RunSetup() { } uint8_t TemperatureInterface::getCurrentTemp() { - #ifndef MARAUDER_FLIPPER + #if !defined(MARAUDER_FLIPPER) && !defined(MARAUDER_ENDGAME_S3) return ((temprature_sens_read() - 32) / 1.8); #endif return 0; From 62923f434848e43cd13e6d17ecd2e12773ac76c9 Mon Sep 17 00:00:00 2001 From: fOmey Date: Wed, 31 May 2023 20:16:38 +1000 Subject: [PATCH 06/15] Update build_push ESP32 boards to latest release --- .github/workflows/build_push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_push.yml b/.github/workflows/build_push.yml index 5e7239e16..fca3ef9a0 100644 --- a/.github/workflows/build_push.yml +++ b/.github/workflows/build_push.yml @@ -95,7 +95,7 @@ jobs: with: sketch-names: MarauderOTA.ino arduino-board-fqbn: esp32:esp32:esp32s2 - platform-url: https://github.com/espressif/arduino-esp32/releases/download/2.0.3/package_esp32_dev_index.json + platform-url: https://github.com/espressif/arduino-esp32/releases/download/2.0.9/package_esp32_dev_index.json - name: Modify platform.txt run: | From fef0380b2d6b76f4dc80f9163fd2eed1fd9f9b75 Mon Sep 17 00:00:00 2001 From: fOmey Date: Wed, 31 May 2023 20:43:02 +1000 Subject: [PATCH 07/15] End Game artifact & assets --- .github/workflows/build_push.yml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_push.yml b/.github/workflows/build_push.yml index fca3ef9a0..7181cd7e4 100644 --- a/.github/workflows/build_push.yml +++ b/.github/workflows/build_push.yml @@ -176,7 +176,7 @@ jobs: - name: Rename Marauder End Game bin run: | - mv ./esp32_marauder/build/esp32.esp32.esp32s3/esp32_marauder.ino.bin ./esp32_marauder/build/esp32.esp32.esp32s3/esp32_marauder.endgameS3.bin + mv ./esp32_marauder/build/esp32.esp32.esp32s3/esp32_marauder.ino.bin ./esp32_marauder/build/esp32.esp32.esp32s3/esp32_marauder.end_game_S3.bin - name: Configure TFT_eSPI and configs.h for OG Marauder run: | @@ -379,6 +379,13 @@ jobs: path: ./esp32_marauder/build/esp32.esp32.esp32s3/esp32_marauder.multiboardS3.bin retention-days: 5 + - name: 'Upload End Game Artifact' + uses: actions/upload-artifact@v3 + with: + name: esp32_marauder.end_game_S3.bin + path: ./esp32_marauder/build/esp32.esp32.esp32s3/esp32_marauder.end_game_S3.bin + retention-days: 5 + - name: 'Upload OG Artifact' uses: actions/upload-artifact@v3 with: @@ -476,6 +483,18 @@ jobs: asset_content_type: application/bin if: github.event_name != 'pull_request' + - name: Upload End Game Asset + id: upload-end-game-s3-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./esp32_marauder/build/esp32.esp32.esp32s3/esp32_marauder.end_game_s3.bin + asset_name: esp32_marauder.end_game_s3.bin + asset_content_type: application/bin + if: github.event_name != 'pull_request' + - name: Upload OG Asset id: upload-og-release-asset uses: actions/upload-release-asset@v1 From de21dc11e61c6863377050bc2c8d7377ec3bfa98 Mon Sep 17 00:00:00 2001 From: fOmey Date: Fri, 2 Jun 2023 16:33:50 +1000 Subject: [PATCH 08/15] Dynamically allocate buffer memory --- esp32_marauder/Buffer.cpp | 141 ++++++++++++++++++++++-------------- esp32_marauder/Buffer.h | 13 +++- esp32_marauder/WiFiScan.cpp | 3 +- 3 files changed, 98 insertions(+), 59 deletions(-) diff --git a/esp32_marauder/Buffer.cpp b/esp32_marauder/Buffer.cpp index 1e5e2b2f0..978485db9 100644 --- a/esp32_marauder/Buffer.cpp +++ b/esp32_marauder/Buffer.cpp @@ -1,12 +1,12 @@ #include "Buffer.h" #include "lang_var.h" -Buffer::Buffer(){ - bufA = (uint8_t*)malloc(BUF_SIZE); - bufB = (uint8_t*)malloc(BUF_SIZE); +Buffer::Buffer() { + //bufA = (uint8_t*)malloc(BUF_SIZE); + //bufB = (uint8_t*)malloc(BUF_SIZE); } -void Buffer::createPcapFile(fs::FS* fs, String fn){ +void Buffer::createPcapFile(fs::FS* fs, String fn) { int i=0; do{ fileName = "/"+fn+"_"+(String)i+".pcap"; @@ -19,11 +19,24 @@ void Buffer::createPcapFile(fs::FS* fs, String fn){ file.close(); } -void Buffer::open(){ +void Buffer::open() { + if (bufA == NULL && bufB == NULL) { + bufLength = ((heap_caps_get_largest_free_block(MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM) * 0.95) / 2); + //bufA = (uint8_t*)malloc(bufLength); + //bufB = (uint8_t*)malloc(bufLength); + bufA = (uint8_t*)heap_caps_malloc(bufLength, MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM); + bufB = (uint8_t*)heap_caps_malloc(bufLength, MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM); + //Serial.printf("Allocated: %u bytes for each buffer\n", bufLength); + } + + if (bufA == NULL || bufB == NULL) { + Serial.println("Failed to allocate buffer memory!"); + return; + } + bufSizeA = 0; bufSizeB = 0; - - bufSizeB = 0; + writing = true; write(uint32_t(0xa1b2c3d4)); // magic number @@ -35,28 +48,43 @@ void Buffer::open(){ write(uint32_t(105)); // data link type } -void Buffer::close(fs::FS* fs){ - if(!writing) return; +void Buffer::close(fs::FS* fs) { + if (!writing) return; forceSave(fs); writing = false; Serial.println(text01); } -void Buffer::addPacket(uint8_t* buf, uint32_t len){ - - // buffer is full -> drop packet - if((useA && bufSizeA + len >= BUF_SIZE && bufSizeB > 0) || (!useA && bufSizeB + len >= BUF_SIZE && bufSizeA > 0)){ - //Serial.print(";"); +void Buffer::cleanup() { + if (bufSizeA > 0 || bufSizeB > 0) return; + if (bufA != NULL) { + free(bufA); + bufA = NULL; + } + if (bufB != NULL) { + free(bufB); + bufB = NULL; + } + scheduleCleanup = false; +} + +void Buffer::addPacket(uint8_t* buf, uint32_t len) { + if ((len + 16) > bufLength) { + Serial.println("Buffer overflow.. dropping packet"); + return; + } + if ((useA && bufSizeA + len >= bufLength && bufSizeB > 0) || (!useA && bufSizeB + len >= bufLength && bufSizeA > 0)) { + Serial.println("Buffer is full.. dropping packet"); return; } - if(useA && bufSizeA + len + 16 >= BUF_SIZE && bufSizeB == 0){ + if(useA && bufSizeA + len + 16 >= bufLength && bufSizeB == 0) { useA = false; - //Serial.println("\nswitched to buffer B"); + //Serial.println("Switched to buffer B"); } - else if(!useA && bufSizeB + len + 16 >= BUF_SIZE && bufSizeA == 0){ + else if(!useA && bufSizeB + len + 16 >= bufLength && bufSizeA == 0) { useA = true; - //Serial.println("\nswitched to buffer A"); + //Serial.println("Switched to buffer A"); } uint32_t microSeconds = micros(); // e.g. 45200400 => 45s 200ms 400us @@ -72,48 +100,50 @@ void Buffer::addPacket(uint8_t* buf, uint32_t len){ write(buf, len); // packet payload } -void Buffer::write(int32_t n){ +void Buffer::write(int32_t n) { uint8_t buf[4]; buf[0] = n; buf[1] = n >> 8; buf[2] = n >> 16; buf[3] = n >> 24; - write(buf,4); + write(buf, 4); } -void Buffer::write(uint32_t n){ +void Buffer::write(uint32_t n) { uint8_t buf[4]; buf[0] = n; buf[1] = n >> 8; buf[2] = n >> 16; buf[3] = n >> 24; - write(buf,4); + write(buf, 4); } -void Buffer::write(uint16_t n){ +void Buffer::write(uint16_t n) { uint8_t buf[2]; buf[0] = n; buf[1] = n >> 8; - write(buf,2); + write(buf, 2); } -void Buffer::write(uint8_t* buf, uint32_t len){ - if(!writing) return; - - if(useA){ +void Buffer::write(uint8_t* buf, uint32_t len) { + if (!writing) return; + + if (useA) { memcpy(&bufA[bufSizeA], buf, len); bufSizeA += len; - }else{ + } + else { memcpy(&bufB[bufSizeB], buf, len); bufSizeB += len; } } -void Buffer::save(fs::FS* fs){ +/* +void Buffer::save(fs::FS* fs) { if(saving) return; // makes sure the function isn't called simultaneously on different cores // buffers are already emptied, therefor saving is unecessary - if((useA && bufSizeB == 0) || (!useA && bufSizeA == 0)){ + if((useA && bufSizeB == 0) || (!useA && bufSizeA == 0)) { //Serial.printf("useA: %s, bufA %u, bufB %u\n",useA ? "true" : "false",bufSizeA,bufSizeB); // for debug porpuses return; } @@ -125,7 +155,7 @@ void Buffer::save(fs::FS* fs){ file = fs->open(fileName, FILE_APPEND); if (!file) { - Serial.println(text02 + fileName+"'"); + Serial.printf("Failed to open file: %s", fileName); //useSD = false; return; } @@ -134,12 +164,12 @@ void Buffer::save(fs::FS* fs){ uint32_t len; - if(useA){ + if(useA) { file.write(bufB, bufSizeB); len = bufSizeB; bufSizeB = 0; } - else{ + else { file.write(bufA, bufSizeA); len = bufSizeA; bufSizeA = 0; @@ -154,14 +184,18 @@ void Buffer::save(fs::FS* fs){ saving = false; } +*/ -void Buffer::forceSave(fs::FS* fs){ +void Buffer::forceSave(fs::FS* fs) { uint32_t len = bufSizeA + bufSizeB; + if (scheduleCleanup) { + cleanup(); + } if(len == 0) return; file = fs->open(fileName, FILE_APPEND); if (!file) { - Serial.println(text02+fileName+"'"); + Serial.printf("Failed to open file: %s", fileName); //useSD = false; return; } @@ -169,30 +203,25 @@ void Buffer::forceSave(fs::FS* fs){ saving = true; writing = false; - if(useA){ - - if(bufSizeB > 0){ + if(useA) { + if(bufSizeB > 0) { file.write(bufB, bufSizeB); bufSizeB = 0; } - - if(bufSizeA > 0){ + if(bufSizeA > 0) { file.write(bufA, bufSizeA); bufSizeA = 0; } - - } else { - - if(bufSizeA > 0){ + } + else { + if(bufSizeA > 0) { file.write(bufA, bufSizeA); bufSizeA = 0; } - - if(bufSizeB > 0){ + if(bufSizeB > 0) { file.write(bufB, bufSizeB); bufSizeB = 0; } - } file.close(); @@ -205,26 +234,30 @@ void Buffer::forceSave(fs::FS* fs){ void Buffer::forceSaveSerial() { uint32_t len = bufSizeA + bufSizeB; + if (scheduleCleanup) { + cleanup(); + } if(len == 0) return; saving = true; writing = false; - if(useA){ - if(bufSizeB > 0){ + if (useA) { + if(bufSizeB > 0) { Serial1.write(bufB, bufSizeB); bufSizeB = 0; } - if(bufSizeA > 0){ + if(bufSizeA > 0) { Serial1.write(bufA, bufSizeA); bufSizeA = 0; } - } else { - if(bufSizeA > 0){ + } + else { + if (bufSizeA > 0) { Serial1.write(bufA, bufSizeA); bufSizeA = 0; } - if(bufSizeB > 0){ + if (bufSizeB > 0) { Serial1.write(bufB, bufSizeB); bufSizeB = 0; } diff --git a/esp32_marauder/Buffer.h b/esp32_marauder/Buffer.h index a78ead547..fbe198bf6 100644 --- a/esp32_marauder/Buffer.h +++ b/esp32_marauder/Buffer.h @@ -6,7 +6,7 @@ #include "settings.h" //#include "SD_MMC.h" -#define BUF_SIZE 3 * 1024 // Had to reduce buffer size to save RAM. GG @spacehuhn +//#define BUF_SIZE 32 * 1024 // increase buffer size to reduce amount of dropped packets #define SNAP_LEN 2324 // max len of each recieved packet //extern bool useSD; @@ -23,23 +23,28 @@ class Buffer { void save(fs::FS* fs); void forceSave(fs::FS* fs); void forceSaveSerial(); + + String fileName = "/0.pcap"; + bool scheduleCleanup = false; + private: void write(int32_t n); void write(uint32_t n); void write(uint16_t n); void write(uint8_t* buf, uint32_t len); - + void cleanup(); + uint8_t* bufA; uint8_t* bufB; uint32_t bufSizeA = 0; uint32_t bufSizeB = 0; + uint32_t bufLength = 0; - bool writing = false; // acceppting writes to buffer + bool writing = false; // accepting writes to buffer bool useA = true; // writing to bufA or bufB bool saving = false; // currently saving onto the SD card - String fileName = "/0.pcap"; File file; }; diff --git a/esp32_marauder/WiFiScan.cpp b/esp32_marauder/WiFiScan.cpp index b62a36dd1..b9474277b 100644 --- a/esp32_marauder/WiFiScan.cpp +++ b/esp32_marauder/WiFiScan.cpp @@ -492,7 +492,6 @@ void WiFiScan::StopScan(uint8_t scan_mode) { this->shutdownWiFi(); } - else if ((currentScanMode == BT_SCAN_ALL) || (currentScanMode == BT_SCAN_SKIMMERS)) @@ -502,6 +501,8 @@ void WiFiScan::StopScan(uint8_t scan_mode) #endif } + buffer_obj.scheduleCleanup = true; + #ifdef HAS_SCREEN display_obj.display_buffer->clear(); #ifdef SCREEN_BUFFER From 335cfda56601fb1799cba76e53271dd918af4b36 Mon Sep 17 00:00:00 2001 From: fOmey Date: Fri, 2 Jun 2023 16:39:33 +1000 Subject: [PATCH 09/15] broadcastCustomBeacon malformed packet fix --- esp32_marauder/WiFiScan.cpp | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/esp32_marauder/WiFiScan.cpp b/esp32_marauder/WiFiScan.cpp index b9474277b..944aabec0 100644 --- a/esp32_marauder/WiFiScan.cpp +++ b/esp32_marauder/WiFiScan.cpp @@ -2563,9 +2563,7 @@ void WiFiScan::broadcastCustomBeacon(uint32_t current_time, ssid custom_ssid) { custom_ssid.essid.toCharArray(ESSID, custom_ssid.essid.length() + 1); int ssidLen = strlen(ESSID); - //int rand_len = sizeof(rand_reg); - int fullLen = ssidLen; - packet[37] = fullLen; + packet[37] = ssidLen; // Insert my tag for(int i = 0; i < ssidLen; i++) @@ -2573,21 +2571,20 @@ void WiFiScan::broadcastCustomBeacon(uint32_t current_time, ssid custom_ssid) { ///////////////////////////// - packet[50 + fullLen] = set_channel; - - uint8_t postSSID[13] = {0x01, 0x08, 0x82, 0x84, 0x8b, 0x96, 0x24, 0x30, 0x48, 0x6c, //supported rate - 0x03, 0x01, 0x04 /*DSSS (Current Channel)*/ }; - + packet[50 + ssidLen] = set_channel; + uint8_t postSSID[13] = { 0x01, 0x08, 0x82, 0x84, 0x8b, 0x96, 0x24, 0x30, 0x48, 0x6c, //supported rate + 0x03, 0x01, 0x04 /*DSSS (Current Channel)*/ }; // Add everything that goes after the SSID for(int i = 0; i < 12; i++) - packet[38 + fullLen + i] = postSSID[i]; - + packet[38 + ssidLen + i] = postSSID[i]; - esp_wifi_80211_tx(WIFI_IF_AP, packet, sizeof(packet), false); - esp_wifi_80211_tx(WIFI_IF_AP, packet, sizeof(packet), false); - esp_wifi_80211_tx(WIFI_IF_AP, packet, sizeof(packet), false); + int packetSize = (51 + ssidLen); + + esp_wifi_80211_tx(WIFI_IF_AP, packet, packetSize, false); + esp_wifi_80211_tx(WIFI_IF_AP, packet, packetSize, false); + esp_wifi_80211_tx(WIFI_IF_AP, packet, packetSize, false); packets_sent = packets_sent + 3; } From 4a3d6393d3f62ebcd34c28e5ea658b6a1dbec4f7 Mon Sep 17 00:00:00 2001 From: fOmey Date: Sat, 3 Jun 2023 12:34:55 +1000 Subject: [PATCH 10/15] Neopixel config for end game --- esp32_marauder/configs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esp32_marauder/configs.h b/esp32_marauder/configs.h index ab8f5677c..6c2593155 100644 --- a/esp32_marauder/configs.h +++ b/esp32_marauder/configs.h @@ -558,7 +558,7 @@ //// NEOPIXEL STUFF #if defined(ESP32_LDDB) #define PIN 17 - #elif defined(MARAUDER_DEV_BOARD_PRO) + #elif defined(MARAUDER_DEV_BOARD_PRO) || defined(MARAUDER_ENDGAME_S3) #define PIN 16 #else #define PIN 25 From 24c8fbf741eb8dc7004a848e50007aed13a862f1 Mon Sep 17 00:00:00 2001 From: fOmey Date: Sat, 3 Jun 2023 12:35:45 +1000 Subject: [PATCH 11/15] Skip battery interface for end game --- esp32_marauder/BatteryInterface.cpp | 6 +++--- esp32_marauder/BatteryInterface.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/esp32_marauder/BatteryInterface.cpp b/esp32_marauder/BatteryInterface.cpp index 6de23ad2c..7de3f9146 100644 --- a/esp32_marauder/BatteryInterface.cpp +++ b/esp32_marauder/BatteryInterface.cpp @@ -5,7 +5,7 @@ BatteryInterface::BatteryInterface() { } void BatteryInterface::main(uint32_t currentTime) { - #ifndef MARAUDER_FLIPPER + #if !defined(MARAUDER_FLIPPER) && !defined(MARAUDER_ENDGAME_S3) if (currentTime != 0) { if (currentTime - initTime >= 3000) { //Serial.println("Checking Battery Level"); @@ -22,14 +22,14 @@ void BatteryInterface::main(uint32_t currentTime) { } void BatteryInterface::RunSetup() { - #ifndef MARAUDER_FLIPPER + #if !defined(MARAUDER_FLIPPER) && !defined(MARAUDER_ENDGAME_S3) Wire.begin(I2C_SDA, I2C_SCL); this->initTime = millis(); #endif } int8_t BatteryInterface::getBatteryLevel() { - #ifndef MARAUDER_FLIPPER + #if !defined(MARAUDER_FLIPPER) && !defined(MARAUDER_ENDGAME_S3) Wire.beginTransmission(IP5306_ADDR); Wire.write(0x78); if (Wire.endTransmission(false) == 0 && diff --git a/esp32_marauder/BatteryInterface.h b/esp32_marauder/BatteryInterface.h index 40586fdc8..36fb3cbac 100644 --- a/esp32_marauder/BatteryInterface.h +++ b/esp32_marauder/BatteryInterface.h @@ -5,7 +5,7 @@ #include "configs.h" -#ifndef MARAUDER_FLIPPER +#if !defined(MARAUDER_FLIPPER) && !defined(MARAUDER_ENDGAME_S3) #include #endif From 483b9faea4b1c31eaa38c996146c36d053f3b315 Mon Sep 17 00:00:00 2001 From: fOmey Date: Sat, 3 Jun 2023 12:52:50 +1000 Subject: [PATCH 12/15] checkDetectPin SD_DET --- esp32_marauder/SDInterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esp32_marauder/SDInterface.cpp b/esp32_marauder/SDInterface.cpp index 914a001f6..bffdcbee1 100644 --- a/esp32_marauder/SDInterface.cpp +++ b/esp32_marauder/SDInterface.cpp @@ -248,7 +248,7 @@ void SDInterface::performUpdate(Stream &updateSource, size_t updateSize) { } bool SDInterface::checkDetectPin() { - #ifdef KIT + #ifdef SD_DET if (digitalRead(SD_DET) == LOW) return true; else From 84101efe76e1638412553c3b214a176a86dc5ca6 Mon Sep 17 00:00:00 2001 From: fOmey Date: Wed, 7 Jun 2023 08:33:37 +1000 Subject: [PATCH 13/15] Less greedy buffer memory allocation --- esp32_marauder/Buffer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esp32_marauder/Buffer.cpp b/esp32_marauder/Buffer.cpp index 978485db9..b550fcd58 100644 --- a/esp32_marauder/Buffer.cpp +++ b/esp32_marauder/Buffer.cpp @@ -21,7 +21,7 @@ void Buffer::createPcapFile(fs::FS* fs, String fn) { void Buffer::open() { if (bufA == NULL && bufB == NULL) { - bufLength = ((heap_caps_get_largest_free_block(MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM) * 0.95) / 2); + bufLength = ((heap_caps_get_largest_free_block(MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM) * 0.85) / 2); //bufA = (uint8_t*)malloc(bufLength); //bufB = (uint8_t*)malloc(bufLength); bufA = (uint8_t*)heap_caps_malloc(bufLength, MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM); From a7a092cea6082e8276e25b70c236f38ff34518dc Mon Sep 17 00:00:00 2001 From: fOmey Date: Wed, 7 Jun 2023 09:20:01 +1000 Subject: [PATCH 14/15] Even less greedy buffer memory allocation --- esp32_marauder/Buffer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esp32_marauder/Buffer.cpp b/esp32_marauder/Buffer.cpp index b550fcd58..9d48ba3f2 100644 --- a/esp32_marauder/Buffer.cpp +++ b/esp32_marauder/Buffer.cpp @@ -21,7 +21,7 @@ void Buffer::createPcapFile(fs::FS* fs, String fn) { void Buffer::open() { if (bufA == NULL && bufB == NULL) { - bufLength = ((heap_caps_get_largest_free_block(MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM) * 0.85) / 2); + bufLength = ((heap_caps_get_largest_free_block(MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM) * 0.75) / 2); //bufA = (uint8_t*)malloc(bufLength); //bufB = (uint8_t*)malloc(bufLength); bufA = (uint8_t*)heap_caps_malloc(bufLength, MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM); From 002af56f48f0a29eb62010e2182bb60c27f22e33 Mon Sep 17 00:00:00 2001 From: fOmey Date: Thu, 22 Jun 2023 12:41:21 +1000 Subject: [PATCH 15/15] Workflow action filename fix --- .github/workflows/build_push.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_push.yml b/.github/workflows/build_push.yml index 7181cd7e4..bd489a40d 100644 --- a/.github/workflows/build_push.yml +++ b/.github/workflows/build_push.yml @@ -490,8 +490,8 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./esp32_marauder/build/esp32.esp32.esp32s3/esp32_marauder.end_game_s3.bin - asset_name: esp32_marauder.end_game_s3.bin + asset_path: ./esp32_marauder/build/esp32.esp32.esp32s3/esp32_marauder.end_game_S3.bin + asset_name: esp32_marauder.end_game_S3.bin asset_content_type: application/bin if: github.event_name != 'pull_request'