Start storage service first to load xtreme early

This commit is contained in:
Willy-JL
2023-05-10 12:13:38 +01:00
parent efe6dbf008
commit 33ff8e4506
13 changed files with 31 additions and 45 deletions

View File

@@ -15,7 +15,6 @@
#include "desktop/views/desktop_view_pin_timeout.h"
#include "desktop_i.h"
#include "helpers/pin_lock.h"
#include <xtreme/private.h>
#define TAG "Desktop"
@@ -347,9 +346,6 @@ int32_t desktop_srv(void* p) {
furi_hal_rtc_reset_flag(FuriHalRtcFlagResetPin);
}
XTREME_SETTINGS_LOAD();
XTREME_ASSETS_LOAD();
Desktop* desktop = desktop_alloc();
bool loaded = DESKTOP_SETTINGS_LOAD(&desktop->settings);

View File

@@ -80,7 +80,7 @@ Dolphin* dolphin_alloc() {
dolphin->state = dolphin_state_alloc();
dolphin->event_queue = furi_message_queue_alloc(8, sizeof(DolphinEvent));
dolphin->pubsub = furi_pubsub_alloc();
int32_t butthurt = XTREME_SETTINGS_WAIT()->butthurt_timer;
int32_t butthurt = XTREME_SETTINGS()->butthurt_timer;
dolphin->butthurt_timer = xTimerCreate(
NULL,
(butthurt > 0) ? (butthurt * 1000) : -1,

View File

@@ -1,6 +1,8 @@
#include <xtreme.h>
#include "gui_i.h"
#include <assets_icons.h>
#include <storage/storage.h>
#include <storage/storage_i.h>
#define TAG "GuiSrv"
@@ -589,6 +591,10 @@ Gui* gui_alloc() {
furi_check(gui->input_events);
furi_pubsub_subscribe(gui->input_events, gui_input_events_callback, gui);
Storage* storage = furi_record_open(RECORD_STORAGE);
gui_add_view_port(gui, storage->sd_gui.view_port, GuiLayerStatusBarLeft);
furi_record_close(RECORD_STORAGE);
return gui;
}

View File

@@ -3,6 +3,7 @@ App(
name="RGB Backlight",
apptype=FlipperAppType.SERVICE,
entry_point="rgb_backlight_srv",
order=10,
sdk_headers=[
"rgb_backlight.h",
],

View File

@@ -7,7 +7,7 @@ App(
requires=["storage_settings"],
provides=["storage_start"],
stack_size=3 * 1024,
order=44,
order=0,
sdk_headers=["storage.h"],
)

View File

@@ -54,10 +54,6 @@ Storage* storage_app_alloc() {
view_port_draw_callback_set(app->sd_gui.view_port, storage_app_sd_icon_draw_callback, app);
view_port_enabled_set(app->sd_gui.view_port, false);
Gui* gui = furi_record_open(RECORD_GUI);
gui_add_view_port(gui, app->sd_gui.view_port, GuiLayerStatusBarLeft);
furi_record_close(RECORD_GUI);
return app;
}

View File

@@ -12,7 +12,7 @@ App(
conflicts=["desktop"],
entry_point="updater_srv",
stack_size=2 * 1024,
order=130,
order=120,
)
App(

View File

@@ -325,7 +325,6 @@ Function,-,SystemInit,void,
Function,+,XTREME_ASSETS,XtremeAssets*,
Function,+,XTREME_SETTINGS,XtremeSettings*,
Function,+,XTREME_SETTINGS_SAVE,void,
Function,+,XTREME_SETTINGS_WAIT,XtremeSettings*,
Function,-,_Exit,void,int
Function,-,__assert,void,"const char*, int, const char*"
Function,+,__assert_func,void,"const char*, int, const char*, const char*"
1 entry status name type params
325 Function + XTREME_ASSETS XtremeAssets*
326 Function + XTREME_SETTINGS XtremeSettings*
327 Function + XTREME_SETTINGS_SAVE void
Function + XTREME_SETTINGS_WAIT XtremeSettings*
328 Function - _Exit void int
329 Function - __assert void const char*, int, const char*
330 Function + __assert_func void const char*, int, const char*, const char*

View File

@@ -4,6 +4,7 @@
#include <furi_hal_version.h>
#include <furi_hal_memory.h>
#include <furi_hal_rtc.h>
#include <xtreme/private.h>
#define TAG "Flipper"
@@ -27,23 +28,31 @@ static void flipper_print_version(const char* target, const Version* version) {
}
}
void flipper_start_service(const FlipperApplication* service) {
FURI_LOG_D(TAG, "Starting service %s", service->name);
FuriThread* thread =
furi_thread_alloc_ex(service->name, service->stack_size, service->app, NULL);
furi_thread_mark_as_service(thread);
furi_thread_set_appid(thread, service->appid);
furi_thread_start(thread);
}
void flipper_init() {
flipper_print_version("Firmware", furi_hal_version_get_firmware_version());
FURI_LOG_I(TAG, "Boot mode %d, starting services", furi_hal_rtc_get_boot_mode());
for(size_t i = 0; i < FLIPPER_SERVICES_COUNT; i++) {
FURI_LOG_D(TAG, "Starting service %s", FLIPPER_SERVICES[i].name);
// Start storage service first, thanks OFW :/
flipper_start_service(&FLIPPER_SERVICES[0]);
FuriThread* thread = furi_thread_alloc_ex(
FLIPPER_SERVICES[i].name,
FLIPPER_SERVICES[i].stack_size,
FLIPPER_SERVICES[i].app,
NULL);
furi_thread_mark_as_service(thread);
furi_thread_set_appid(thread, FLIPPER_SERVICES[i].appid);
XTREME_SETTINGS_LOAD();
XTREME_ASSETS_LOAD();
furi_thread_start(thread);
// Everything else
for(size_t i = 1; i < FLIPPER_SERVICES_COUNT; i++) {
flipper_start_service(&FLIPPER_SERVICES[i]);
}
FURI_LOG_I(TAG, "Startup complete");

View File

@@ -148,13 +148,6 @@ void XTREME_ASSETS_LOAD() {
xtreme_assets.is_nsfw = strncmp(xtreme_settings->asset_pack, "NSFW", strlen("NSFW")) == 0;
Storage* storage = furi_record_open(RECORD_STORAGE);
int32_t timeout = 5000;
while(timeout > 0) {
if(storage_sd_status(storage) == FSE_OK) break;
furi_delay_ms(250);
timeout -= 250;
}
FileInfo info;
FuriString* path = furi_string_alloc();
furi_string_printf(path, XTREME_ASSETS_PATH "/%s", xtreme_settings->asset_pack);

View File

@@ -1,4 +1,4 @@
#pragma once
void XTREME_ASSETS_LOAD();
void XTREME_SETTINGS_LOAD();
void XTREME_ASSETS_LOAD();

View File

@@ -6,7 +6,6 @@
#define TAG "XtremeSettings"
XtremeSettings xtreme_settings = {
.loaded = false,
.asset_pack = "",
.anim_speed = 100, // 100%
.cycle_anims = 0, // Meta.txt
@@ -89,8 +88,6 @@ void XTREME_SETTINGS_LOAD() {
}
flipper_format_free(file);
furi_record_close(RECORD_STORAGE);
xtreme_settings.loaded = true;
}
void XTREME_SETTINGS_SAVE() {
@@ -131,12 +128,3 @@ void XTREME_SETTINGS_SAVE() {
XtremeSettings* XTREME_SETTINGS() {
return &xtreme_settings;
}
XtremeSettings* XTREME_SETTINGS_WAIT() {
if(furi_hal_is_normal_boot()) {
while(!xtreme_settings.loaded) {
furi_delay_ms(50);
}
}
return &xtreme_settings;
}

View File

@@ -13,7 +13,6 @@ extern "C" {
#define XTREME_ASSETS_PACK_NAME_LEN 32
typedef struct {
bool loaded;
char asset_pack[XTREME_ASSETS_PACK_NAME_LEN];
uint32_t anim_speed;
int32_t cycle_anims;
@@ -41,7 +40,6 @@ typedef struct {
void XTREME_SETTINGS_SAVE();
XtremeSettings* XTREME_SETTINGS();
XtremeSettings* XTREME_SETTINGS_WAIT();
typedef struct {
bool is_nsfw;