Disconnect SDCard if it shares the pins with the flasher

Signed-off-by: Mimoja <git@mimoja.de>
This commit is contained in:
Mimoja
2023-06-19 16:34:33 +02:00
committed by Mimoja
parent 48b2925b9f
commit 93639ff8ac
3 changed files with 25 additions and 0 deletions

View File

@@ -25,6 +25,7 @@ class DynStorage {
public:
DynStorage();
void begin();
void end();
void listFiles();
size_t freeSpace();

View File

@@ -3,6 +3,7 @@
#include <Arduino.h>
#include <ArduinoJson.h>
#include "storage.h"
#include "LittleFS.h"
#include <MD5Builder.h>
// #include <FS.h>
@@ -109,9 +110,11 @@ class flasher {
flasher::flasher() {
zbs = new ZBS_interface;
Storage.end();
}
flasher::~flasher() {
delete zbs;
Storage.begin();
}
bool flasher::connectTag(uint8_t port) {

View File

@@ -141,6 +141,27 @@ void DynStorage::begin() {
}
}
void DynStorage::end() {
#ifdef HAS_SDCARD
initLittleFS();
if (SD_CARD_CLK == FLASHER_AP_CLK ||
SD_CARD_MISO == FLASHER_AP_MISO ||
SD_CARD_MOSI == FLASHER_AP_MOSI) {
Serial.println("Tearing down SD card connection");
copyBetweenFS(*contentFS, "/tag_md5_db.json", LittleFS);
copyBetweenFS(*contentFS, "/AP_FW_Pack.bin", LittleFS);
if (contentFS->exists("/AP_force_flash.bin")) {
copyBetweenFS(*contentFS, "/AP_force_flash.bin", LittleFS);
contentFS->remove("/AP_force_flash.bin");
}
Serial.println("Swapping to LittleFS");
contentFS = &LittleFS;
}
#endif
}
void listDir(fs::FS& fs, const char* dirname, uint8_t levels) {
Storage.begin();