如何使用 lorol/LittleFS 库在 PlatformIO 中于 ESP32 上初始化 LittleFS
***注意:当使用最新版本的 arduino-esp32 框架(如 2.0.5)时,我不推荐使用 loros/LittleFS 库 -***该框架的较新版本带有嵌入式 LittleFS 框架。有关如何初始化库的说明,请参阅 TODO。
目前你需要在 platformio.ini 中添加 LittleFS-ESP32 库(该库作为核心 arduino-espressif32 前沿版本的一部分可用,但你在标准版本中需要该库):
platformio.ini
lib_deps =
lorol/LittleFS_esp32 @ ^1.0.6现在包含 LittleFS:
littlefs_example.cpp
#include <LITTLEFS.h>
#define SPIFFS LITTLEFS使用以下命令初始化它
littlefs_init.cpp
// 初始化 LittleFS
if (!LITTLEFS.begin(false /* false: Do not format if mount failed */)) {
Serial.println("挂载 LittleFS 失败");
if (!LITTLEFS.begin(true /* true: format */)) {
Serial.println("格式化 LittleFS 失败");
} else {
Serial.println("LittleFS 格式化成功");
}
} else { // 初始挂载成功
}Check out similar posts by category:
Arduino, Embedded, ESP8266/ESP32, PlatformIO
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow