@@ -40,16 +40,20 @@ const esp_partition_t *check_ffat_partition(const char* label)
40
40
41
41
bool F_Fat::begin (bool formatOnFail, const char * basePath, uint8_t maxOpenFiles, const char * partitionLabel)
42
42
{
43
- if (_wl_handle){
43
+ if (_wl_handle != WL_INVALID_HANDLE ){
44
44
log_w (" Already Mounted!" );
45
45
return true ;
46
46
}
47
47
48
- if (!check_ffat_partition (partitionLabel)) return false ;
48
+ if (!check_ffat_partition (partitionLabel)){
49
+ log_e (" No fat partition found on flash" );
50
+ return false ;
51
+ }
49
52
50
53
esp_vfs_fat_mount_config_t conf = {
51
54
.format_if_mount_failed = formatOnFail,
52
- .max_files = maxOpenFiles
55
+ .max_files = maxOpenFiles,
56
+ .allocation_unit_size = CONFIG_WL_SECTOR_SIZE
53
57
};
54
58
esp_err_t err = esp_vfs_fat_spiflash_mount (basePath, partitionLabel, &conf, &_wl_handle);
55
59
if (err){
@@ -62,13 +66,13 @@ bool F_Fat::begin(bool formatOnFail, const char * basePath, uint8_t maxOpenFiles
62
66
63
67
void F_Fat::end ()
64
68
{
65
- if (_wl_handle){
69
+ if (_wl_handle != WL_INVALID_HANDLE ){
66
70
esp_err_t err = esp_vfs_fat_spiflash_unmount (_impl->mountpoint (), _wl_handle);
67
71
if (err){
68
72
log_e (" Unmounting FFat partition failed! Error: %d" , err);
69
73
return ;
70
74
}
71
- _wl_handle = 0 ;
75
+ _wl_handle = WL_INVALID_HANDLE ;
72
76
_impl->mountpoint (NULL );
73
77
}
74
78
}
@@ -77,7 +81,7 @@ bool F_Fat::format(bool full_wipe, char* partitionLabel)
77
81
{
78
82
esp_err_t result;
79
83
bool res = true ;
80
- if (_wl_handle){
84
+ if (_wl_handle != WL_INVALID_HANDLE ){
81
85
log_w (" Already Mounted!" );
82
86
return false ;
83
87
}
@@ -102,7 +106,8 @@ bool F_Fat::format(bool full_wipe, char* partitionLabel)
102
106
// Now do a mount with format_if_fail (which it will)
103
107
esp_vfs_fat_mount_config_t conf = {
104
108
.format_if_mount_failed = true ,
105
- .max_files = 1
109
+ .max_files = 1 ,
110
+ .allocation_unit_size = CONFIG_WL_SECTOR_SIZE
106
111
};
107
112
result = esp_vfs_fat_spiflash_mount (" /format_ffat" , partitionLabel, &conf, &temp_handle);
108
113
esp_vfs_fat_spiflash_unmount (" /format_ffat" , temp_handle);
0 commit comments