Filesystem improvements and more (#148)
- Rename `assets` and `config` partitions to `system` and `data` - Change partition type from `spiffs` to `fat`, so we can have sub-directories - Fix crash when doing WiFi scan: Increased system event task size to 3kB. - Free up IRAM on ESP32 (it was required for the Core2, but I also freed up the same amount for Yellow Board) - Introduced `Paths` objects that can be retrieved by `AppContext` and `ServiceContext`. Apps and services now have their own relative paths. Assets were re-arranged into the correct paths. - Rename simulator window title to "Tactility" - Refactored statusbar widget so it persists icon paths properly (it kept a const char* reference, but didn't copy it, so it crashed when the related std::string was destroyed) - Created `Partitions.h` to expose some useful variables - Moved USB config in various `sdkconfig` (it was part of the "default" section, but it shouldn't be) - Updated domain name
This commit is contained in:
committed by
GitHub
parent
7187e5e49e
commit
ff4287e2ce
@@ -0,0 +1,54 @@
|
||||
#ifdef ESP_TARGET
|
||||
|
||||
#include "EspPartitions_i.h"
|
||||
#include "Log.h"
|
||||
|
||||
#include <esp_vfs_fat.h>
|
||||
#include <nvs_flash.h>
|
||||
|
||||
namespace tt {
|
||||
|
||||
static const char* TAG = "partitions";
|
||||
|
||||
static esp_err_t initNvsFlashSafely() {
|
||||
esp_err_t result = nvs_flash_init();
|
||||
if (result == ESP_ERR_NVS_NO_FREE_PAGES || result == ESP_ERR_NVS_NEW_VERSION_FOUND) {
|
||||
ESP_ERROR_CHECK(nvs_flash_erase());
|
||||
result = nvs_flash_init();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static wl_handle_t data_wl_handle = WL_INVALID_HANDLE;
|
||||
|
||||
esp_err_t initPartitionsEsp() {
|
||||
ESP_ERROR_CHECK(initNvsFlashSafely());
|
||||
|
||||
const esp_vfs_fat_mount_config_t mount_config = {
|
||||
.format_if_mount_failed = false,
|
||||
.max_files = 4,
|
||||
.allocation_unit_size = CONFIG_WL_SECTOR_SIZE,
|
||||
.disk_status_check_enable = false,
|
||||
.use_one_fat = true,
|
||||
};
|
||||
|
||||
auto system_result = esp_vfs_fat_spiflash_mount_ro("/system", "system", &mount_config);
|
||||
if (system_result != ESP_OK) {
|
||||
TT_LOG_E(TAG, "Failed to mount /system (%s)", esp_err_to_name(system_result));
|
||||
} else {
|
||||
TT_LOG_I(TAG, "Mounted /system");
|
||||
}
|
||||
|
||||
auto data_result = esp_vfs_fat_spiflash_mount_rw_wl("/data", "data", &mount_config, &data_wl_handle);
|
||||
if (data_result != ESP_OK) {
|
||||
TT_LOG_E(TAG, "Failed to mount /data (%s)", esp_err_to_name(data_result));
|
||||
} else {
|
||||
TT_LOG_I(TAG, "Mounted /data");
|
||||
}
|
||||
|
||||
return system_result == ESP_OK && data_result == ESP_OK;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif // ESP_TARGET
|
||||
Reference in New Issue
Block a user