Merge develop into main (#304)
## New - Read property files with `PropertiesFile` - Support `boot.properties` so the user can specify the launcher app and an optional app to start after the launcher finishes. (see `BootProperties.cpp`) - Create registry for CPU affinity and update code to make use of it - `AppRegistration` and `ServiceRegistration` now also ensure that the `/data` directories always exist for all apps - `Notes` is now the default app for opening text files. `TextViewer` is removed entirely. Created `tt::app::notes::start(path)` function. - WiFi settings moved from NVS to properties file. - Specify `*.ap.properties` file on the SD card for automatic WiFi settings import on start-up. - Added `file::getLock(path)` and `file::withLock(path, function)` to do safe file operations on SD cards ## Improvements - Update TinyUSB to `1.7.6~1` - Improved `Boot.cpp` code. General code quality fixes and some restructuring to improve readability. - `tt::string` functionality improvements - Rename `AppRegistry` to `AppRegistration` - Rename `ServiceRegistry` to `ServiceRegistration` - Cleanup in `Notes.cpp` - `FileTest.cpp` fix for PC - Created `TestFile` helper class for tests, which automatically deletes files after the test. - Renamed `Partitions.h` to `MountPoints.h` - Created `std::string getMountPoints()` function for easy re-use - Other code quality improvements - `SdCardDevice`'s `getState()` and `isMounted()` now have a timeout argument ## Fixes - ELF loading now has a lock so to avoid a bug when 2 ELF apps are loaded in parallel
This commit is contained in:
committed by
GitHub
parent
fbaff8cbac
commit
ee5a5a7181
@@ -8,10 +8,10 @@
|
||||
#include <esp_vfs_fat.h>
|
||||
#include <sdmmc_cmd.h>
|
||||
|
||||
#define TAG "spi_sdcard"
|
||||
|
||||
namespace tt::hal::sdcard {
|
||||
|
||||
constexpr auto* TAG = "SpiSdCardDevice";
|
||||
|
||||
/**
|
||||
* Before we can initialize the sdcard's SPI communications, we have to set all
|
||||
* other SPI pins on the board high.
|
||||
@@ -78,7 +78,7 @@ bool SpiSdCardDevice::mountInternal(const std::string& newMountPath) {
|
||||
|
||||
esp_err_t result = esp_vfs_fat_sdspi_mount(newMountPath.c_str(), &host, &slot_config, &mount_config, &card);
|
||||
|
||||
if (result != ESP_OK) {
|
||||
if (result != ESP_OK || card == nullptr) {
|
||||
if (result == ESP_FAIL) {
|
||||
TT_LOG_E(TAG, "Mounting failed. Ensure the card is formatted with FAT.");
|
||||
} else {
|
||||
@@ -99,6 +99,7 @@ bool SpiSdCardDevice::mount(const std::string& newMountPath) {
|
||||
}
|
||||
|
||||
if (mountInternal(newMountPath)) {
|
||||
TT_LOG_I(TAG, "Mounted at %s", newMountPath.c_str());
|
||||
sdmmc_card_print_info(stdout, card);
|
||||
return true;
|
||||
} else {
|
||||
@@ -113,18 +114,19 @@ bool SpiSdCardDevice::unmount() {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (esp_vfs_fat_sdcard_unmount(mountPath.c_str(), card) == ESP_OK) {
|
||||
mountPath = "";
|
||||
card = nullptr;
|
||||
return true;
|
||||
} else {
|
||||
if (esp_vfs_fat_sdcard_unmount(mountPath.c_str(), card) != ESP_OK) {
|
||||
TT_LOG_E(TAG, "Unmount failed for %s", mountPath.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
TT_LOG_I(TAG, "Unmounted %s", mountPath.c_str());
|
||||
mountPath = "";
|
||||
card = nullptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO: Refactor to "bool getStatus(Status* status)" method so that it can fail when the lvgl lock fails
|
||||
SdCardDevice::State SpiSdCardDevice::getState() const {
|
||||
SdCardDevice::State SpiSdCardDevice::getState(TickType_t timeout) const {
|
||||
if (card == nullptr) {
|
||||
return State::Unmounted;
|
||||
}
|
||||
@@ -134,20 +136,17 @@ SdCardDevice::State SpiSdCardDevice::getState() const {
|
||||
* Writing and reading to the bus from 2 devices at the same time causes crashes.
|
||||
* This work-around ensures that this check is only happening when LVGL isn't rendering.
|
||||
*/
|
||||
auto lock = getLock().asScopedLock();
|
||||
bool locked = lock.lock(50); // TODO: Refactor to a more reliable locking mechanism
|
||||
auto lock = getLock()->asScopedLock();
|
||||
bool locked = lock.lock(timeout);
|
||||
if (!locked) {
|
||||
TT_LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "LVGL");
|
||||
return State::Unknown;
|
||||
return State::Timeout;
|
||||
}
|
||||
|
||||
bool result = sdmmc_get_status(card) == ESP_OK;
|
||||
|
||||
if (result) {
|
||||
return State::Mounted;
|
||||
} else {
|
||||
if (sdmmc_get_status(card) != ESP_OK) {
|
||||
return State::Error;
|
||||
}
|
||||
|
||||
return State::Mounted;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user