SD card improvements (#214)
- Implement SD card locking logic and helper functions - Fix issue with running ELF apps from SD card: this would crash when launched from the AppList - Reduce Boot app wait time to 1 second - Speed up boot by about 0.1 second by moving app&service registration to the Boot app - Files app now uses proper SD card mount point name (and multiple SD cards) - Removed `TT_SCREENSHOT_MODE`
This commit is contained in:
committed by
GitHub
parent
fd1e31dec4
commit
a7a3b17ff6
@@ -69,7 +69,6 @@ namespace app {
|
||||
static void registerSystemApps() {
|
||||
addApp(app::alertdialog::manifest);
|
||||
addApp(app::applist::manifest);
|
||||
addApp(app::boot::manifest);
|
||||
addApp(app::display::manifest);
|
||||
addApp(app::files::manifest);
|
||||
addApp(app::gpio::manifest);
|
||||
@@ -129,6 +128,17 @@ static void registerAndStartUserServices(const std::vector<const service::Servic
|
||||
}
|
||||
}
|
||||
|
||||
void initFromBootApp() {
|
||||
auto configuration = getConfiguration();
|
||||
// Then we register system apps. They are not used/started yet.
|
||||
registerSystemApps();
|
||||
// Then we register and start user services. They are started after system app
|
||||
// registration just in case they want to figure out which system apps are installed.
|
||||
registerAndStartUserServices(configuration->services);
|
||||
// Now we register the user apps, as they might rely on the user services.
|
||||
registerUserApps(configuration->apps);
|
||||
}
|
||||
|
||||
void run(const Configuration& config) {
|
||||
TT_LOG_D(TAG, "run");
|
||||
|
||||
@@ -142,18 +152,11 @@ void run(const Configuration& config) {
|
||||
|
||||
lvgl::init(hardware);
|
||||
|
||||
// Note: the order of starting apps and services is critical!
|
||||
// System services are registered first so the apps below can find them if needed
|
||||
registerAndStartSystemServices();
|
||||
// Then we register system apps. They are not used/started yet.
|
||||
registerSystemApps();
|
||||
// Then we register and start user services. They are started after system app
|
||||
// registration just in case they want to figure out which system apps are installed.
|
||||
registerAndStartUserServices(config.services);
|
||||
// Now we register the user apps, as they might rely on the user services.
|
||||
registerUserApps(config.apps);
|
||||
|
||||
TT_LOG_I(TAG, "init starting desktop app");
|
||||
TT_LOG_I(TAG, "starting boot app");
|
||||
// The boot app takes care of registering system apps, user services and user apps
|
||||
addApp(app::boot::manifest);
|
||||
service::loader::startApp(app::boot::manifest.id);
|
||||
|
||||
TT_LOG_I(TAG, "init complete");
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <Tactility/Log.h>
|
||||
#include <Tactility/StringUtils.h>
|
||||
#include <Tactility/hal/SdCard.h>
|
||||
|
||||
#include "esp_elf.h"
|
||||
|
||||
@@ -49,7 +50,10 @@ private:
|
||||
assert(elfFileData == nullptr);
|
||||
|
||||
size_t size = 0;
|
||||
elfFileData = file::readBinary(filePath, size);
|
||||
hal::withSdCardLock<void>(filePath, [this, &size](){
|
||||
elfFileData = file::readBinary(filePath, size);
|
||||
});
|
||||
|
||||
if (elfFileData == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "Tactility/service/loader/Loader.h"
|
||||
#include "Tactility/lvgl/Style.h"
|
||||
|
||||
#include <Tactility/Tactility.h>
|
||||
#include <Tactility/TactilityPrivate.h>
|
||||
#include <Tactility/hal/Display.h>
|
||||
#include <Tactility/hal/usb/Usb.h>
|
||||
#include <Tactility/kernel/SystemEvents.h>
|
||||
@@ -51,10 +51,13 @@ private:
|
||||
hal::usb::resetUsbBootMode();
|
||||
hal::usb::startMassStorageWithSdmmc();
|
||||
} else {
|
||||
initFromBootApp();
|
||||
|
||||
TickType_t end_time = tt::kernel::getTicks();
|
||||
TickType_t ticks_passed = end_time - start_time;
|
||||
TickType_t minimum_ticks = (CONFIG_TT_SPLASH_DURATION / portTICK_PERIOD_MS);
|
||||
if (minimum_ticks > ticks_passed) {
|
||||
TT_LOG_I(TAG, "Remaining delay: %lu", minimum_ticks - ticks_passed);
|
||||
kernel::delayTicks(minimum_ticks - ticks_passed);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
|
||||
#include <Tactility/Log.h>
|
||||
#include <Tactility/Partitions.h>
|
||||
#include <Tactility/TactilityHeadless.h>
|
||||
#include <Tactility/hal/SdCard.h>
|
||||
#include <Tactility/kernel/Kernel.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <unistd.h>
|
||||
|
||||
#define TAG "files_app"
|
||||
@@ -44,11 +44,7 @@ bool State::setEntriesForPath(const std::string& path) {
|
||||
* ESP32 does not have a root directory, so we have to create it manually.
|
||||
* We'll add the NVS Flash partitions and the binding for the sdcard.
|
||||
*/
|
||||
#if TT_SCREENSHOT_MODE
|
||||
bool show_custom_root = true;
|
||||
#else
|
||||
bool show_custom_root = (kernel::getPlatform() == kernel::PlatformEsp) && (path == "/");
|
||||
#endif
|
||||
if (show_custom_root) {
|
||||
TT_LOG_I(TAG, "Setting custom root");
|
||||
dir_entries.clear();
|
||||
@@ -63,21 +59,21 @@ bool State::setEntriesForPath(const std::string& path) {
|
||||
.d_name = DATA_PARTITION_NAME
|
||||
});
|
||||
|
||||
#ifndef TT_SCREENSHOT_MODE
|
||||
auto sdcard = tt::hal::getConfiguration()->sdcard;
|
||||
if (sdcard != nullptr) {
|
||||
auto sdcards = tt::hal::findDevices<hal::SdCard>(hal::Device::Type::SdCard);
|
||||
for (auto& sdcard : sdcards) {
|
||||
auto state = sdcard->getState();
|
||||
if (state == hal::SdCard::State::Mounted) {
|
||||
#endif
|
||||
dir_entries.push_back({
|
||||
auto mount_name = sdcard->getMountPath().substr(1);
|
||||
auto dir_entry = dirent {
|
||||
.d_ino = 2,
|
||||
.d_type = TT_DT_DIR,
|
||||
.d_name = TT_SDCARD_MOUNT_NAME
|
||||
});
|
||||
#ifndef TT_SCREENSHOT_MODE
|
||||
.d_name = { 0 }
|
||||
};
|
||||
assert(mount_name.length() < sizeof(dirent::d_name));
|
||||
strcpy(dir_entry.d_name, mount_name.c_str());
|
||||
dir_entries.push_back(dir_entry);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
current_path = path;
|
||||
selected_child_entry = "";
|
||||
|
||||
Reference in New Issue
Block a user