add filesystem format()

This commit is contained in:
hathach committed 2018-10-25 17:21:23 +07:00
1 parent d97818faed
commit 70305da5e7
9 files changed
+156 -13

No files matched your search

+14 -5
View File
@@ -39,6 +39,7 @@
#include <Arduino.h>
#include <string.h>
#include "ExternalFS.h"
#include "flash/flash_qspi.h"
// up to 11 characters
#define VOLUME_LABEL "BLUEFRUIT"
@@ -135,11 +136,7 @@ bool FatFS::begin (void)
if ( FR_NO_FILESYSTEM == err )
{
LOG_LV1("FATFS", "No file system, format it");
uint8_t workbuf[FF_MAX_SS];
VERIFY_FAT(f_mkfs("", FM_FAT | FM_SFD, 4096, workbuf, FF_MAX_SS), false);
VERIFY_FAT(f_setlabel(VOLUME_LABEL), false);
this->format(false);
// FatFile readme;
// readme.open("readme.txt", FAT_FILE_WRITE | FAT_FILE_CREATE_ALWAYS);
@@ -156,6 +153,18 @@ bool FatFS::begin (void)
return true;
}
bool FatFS::format (bool eraseall)
{
if ( eraseall ) VERIFY(flash_qspi_chiperase());
uint8_t workbuf[FF_MAX_SS];
VERIFY_FAT(f_mkfs("", FM_FAT | FM_SFD, 4096, workbuf, FF_MAX_SS), false);
VERIFY_FAT(f_setlabel(VOLUME_LABEL), false);
VERIFY_FAT(f_mount(_fs, "", 1), false);
return true;
}
File FatFS::_open_file (char const *filepath, uint8_t mode)
{
BluefuritLib::File file(*this);