Swap out SPIFFS for FFAT, which doesn't suffer from performance issues

This commit is contained in:
Scott Bezek 2023-06-18 14:33:24 -07:00
parent d72621ae00
commit 68a2d89e71
5 changed files with 30 additions and 24 deletions

View File

@ -8,4 +8,4 @@ otadata, data, ota, 0xe000, 8K,
ota_0, 0, ota_0, 0x10000, 1408K,
ota_1, 0, ota_1, 0x170000, 1408K,
uf2, app, factory,0x2d0000, 256K,
spiffs, data, spiffs, 0x310000, 960K,
ffat, data, fat, 0x310000, 960K,
1 # ESP-IDF Partition Table
8 ota_1, 0, ota_1, 0x170000, 1408K,
9 uf2, app, factory,0x2d0000, 256K,
10 spiffs, data, spiffs, 0x310000, 960K, ffat, data, fat, 0x310000, 960K,
11

View File

@ -1,4 +1,4 @@
#include <SPIFFS.h>
#include <FFat.h>
#include "pb_decode.h"
#include "pb_encode.h"
@ -21,12 +21,12 @@ Configuration::~Configuration() {
bool Configuration::loadFromDisk() {
SemaphoreGuard lock(mutex_);
SPIFFSGuard spiffs(logger_);
if (!spiffs.ok_) {
FatGuard fatGuard(logger_);
if (!fatGuard.mounted_) {
return false;
}
File f = SPIFFS.open(CONFIG_PATH);
File f = FFat.open(CONFIG_PATH);
if (!f) {
log("Failed to read config file");
return false;
@ -77,11 +77,11 @@ bool Configuration::saveToDisk() {
return false;
}
SPIFFSGuard spiffs(logger_);
if (!spiffs.ok_) {
FatGuard fatGuard(logger_);
if (!fatGuard.mounted_) {
return false;
}
File f = SPIFFS.open(CONFIG_PATH, FILE_WRITE);
File f = FFat.open(CONFIG_PATH, FILE_WRITE);
if (!f) {
log("Failed to read config file");
return false;

View File

@ -1,6 +1,6 @@
#pragma once
#include <SPIFFS.h>
#include <FFat.h>
#include <PacketSerial.h>
#include "proto_gen/smartknob.pb.h"
@ -31,27 +31,32 @@ class Configuration {
void log(const char* msg);
};
class SPIFFSGuard {
class FatGuard {
public:
SPIFFSGuard(Logger* logger) : logger_(logger) {
if (!SPIFFS.begin(true)) {
if (logger != nullptr) {
logger->log("Failed to mount SPIFFS");
FatGuard(Logger* logger) : logger_(logger) {
if (!FFat.begin(true)) {
if (logger_ != nullptr) {
logger_->log("Failed to mount FFat");
}
return;
}
ok_ = true;
if (logger_ != nullptr) {
logger_->log("Mounted FFat");
}
mounted_ = true;
}
~SPIFFSGuard() {
if (ok_) {
SPIFFS.end();
logger_->log("Unmounted SPIFFS");
~FatGuard() {
if (mounted_) {
FFat.end();
if (logger_ != nullptr) {
logger_->log("Unmounted FFat");
}
}
}
SPIFFSGuard(SPIFFSGuard const&)=delete;
SPIFFSGuard& operator=(SPIFFSGuard const&)=delete;
FatGuard(FatGuard const&)=delete;
FatGuard& operator=(FatGuard const&)=delete;
bool ok_ = false;
bool mounted_ = false;
private:
Logger* logger_;

View File

@ -22,7 +22,7 @@ static const float IDLE_CORRECTION_MAX_ANGLE_RAD = 5 * PI / 180;
static const float IDLE_CORRECTION_RATE_ALPHA = 0.0005;
MotorTask::MotorTask(const uint8_t task_core, Configuration& configuration) : Task("Motor", 3200, 1, task_core), configuration_(configuration) {
MotorTask::MotorTask(const uint8_t task_core, Configuration& configuration) : Task("Motor", 4000, 1, task_core), configuration_(configuration) {
queue_ = xQueueCreate(5, sizeof(Command));
assert(queue_ != NULL);
}

View File

@ -40,6 +40,7 @@ build_flags =
[env:view]
extends = base_config
board = esp32doit-devkit-v1
board_build.partitions = default_ffat.csv
lib_deps =
${base_config.lib_deps}
askuric/Simple FOC @ 2.2.0
@ -130,7 +131,7 @@ build_flags =
extends = base_config
platform = espressif32@6.3.1
board = adafruit_feather_esp32s3
board_build.partitions = firmware/partitions-4MB-spiffs.csv
board_build.partitions = firmware/partitions-4MB-fat.csv
lib_deps =
${base_config.lib_deps}
askuric/Simple FOC@^2.3.0