[FL-2527] Updater: Migrating to new manifest path convention (#1213)
* Updater: Migrating to new manifest path convention * RPC: Added update preparation status to RPC * RPC: bumped protobuf submodule * Bumped protobuf_version.h * FuriCore: add missing include. Lib: make mlib smaller * Explicitly tell where we have doubles and fix random in animations * makefile: added -DLFS_NO_DEBUG * Updater: path len constant dedup * Updater: checking for hardware version match before parsing manifest * LD: moved _DRIVER_CONTEXT sections to .bss, where they belong. * LD: avoiding PROBGITS warning, moved _CONTEXT to data * Updater: Added version check on update package - refusing to install outdated Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
@@ -48,7 +48,7 @@ int main() {
|
||||
flipper_boot_update_exec();
|
||||
// if things go nice, we shouldn't reach this point.
|
||||
// But if we do, abandon to avoid bootloops
|
||||
update_operation_disarm();
|
||||
furi_hal_rtc_set_boot_mode(FuriHalRtcBootModeNormal);
|
||||
furi_hal_power_reset();
|
||||
} else {
|
||||
furi_hal_light_sequence("rgb G");
|
||||
|
@@ -11,9 +11,10 @@
|
||||
#include <toolbox/path.h>
|
||||
#include <toolbox/crc32_calc.h>
|
||||
|
||||
static FATFS* pfs = NULL;
|
||||
#define FS_ROOT_PATH "/"
|
||||
#define UPDATE_POINTER_FILE_PATH FS_ROOT_PATH UPDATE_MANIFEST_POINTER_FILE_NAME
|
||||
|
||||
static const char FS_ROOT_PATH[] = "/";
|
||||
static FATFS* pfs = NULL;
|
||||
|
||||
#define CHECK_FRESULT(result) \
|
||||
{ \
|
||||
@@ -100,41 +101,34 @@ static bool flipper_update_load_stage(const string_t work_dir, UpdateManifest* m
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool flipper_update_get_work_directory(string_t out_dir) {
|
||||
const uint32_t update_index = furi_hal_rtc_get_register(FuriHalRtcRegisterUpdateFolderFSIndex);
|
||||
if(update_index == UPDATE_OPERATION_ROOT_DIR_PACKAGE_MAGIC) {
|
||||
string_set(out_dir, UPDATE_DIR_DEFAULT_REL_PATH);
|
||||
return true;
|
||||
}
|
||||
|
||||
DIR dir;
|
||||
UINT entry_idx = 0;
|
||||
FILINFO fno;
|
||||
CHECK_FRESULT(f_opendir(&dir, UPDATE_DIR_DEFAULT_REL_PATH));
|
||||
string_set(out_dir, UPDATE_DIR_DEFAULT_REL_PATH);
|
||||
|
||||
while(f_readdir(&dir, &fno) == FR_OK) {
|
||||
entry_idx++;
|
||||
if(fno.fname[0] == '\0') {
|
||||
return false;
|
||||
}
|
||||
if(entry_idx == update_index) {
|
||||
path_append(out_dir, fno.fname);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
string_reset(out_dir);
|
||||
return false;
|
||||
}
|
||||
|
||||
static UpdateManifest* flipper_update_process_manifest(const string_t work_dir) {
|
||||
static bool flipper_update_get_manifest_path(string_t out_path) {
|
||||
FIL file;
|
||||
FILINFO stat;
|
||||
uint16_t size_read = 0;
|
||||
char manifest_name_buf[UPDATE_OPERATION_MAX_MANIFEST_PATH_LEN] = {0};
|
||||
|
||||
string_t manifest_path;
|
||||
string_init_set(manifest_path, work_dir);
|
||||
path_append(manifest_path, UPDATE_MANIFEST_DEFAULT_NAME);
|
||||
string_reset(out_path);
|
||||
CHECK_FRESULT(f_stat(UPDATE_POINTER_FILE_PATH, &stat));
|
||||
CHECK_FRESULT(f_open(&file, UPDATE_POINTER_FILE_PATH, FA_OPEN_EXISTING | FA_READ));
|
||||
do {
|
||||
if(f_read(&file, manifest_name_buf, UPDATE_OPERATION_MAX_MANIFEST_PATH_LEN, &size_read) !=
|
||||
FR_OK) {
|
||||
break;
|
||||
}
|
||||
|
||||
if((size_read == 0) || (size_read == UPDATE_OPERATION_MAX_MANIFEST_PATH_LEN)) {
|
||||
break;
|
||||
}
|
||||
string_set_str(out_path, manifest_name_buf);
|
||||
string_right(out_path, strlen("/ext"));
|
||||
} while(0);
|
||||
f_close(&file);
|
||||
return !string_empty_p(out_path);
|
||||
}
|
||||
|
||||
static UpdateManifest* flipper_update_process_manifest(const string_t manifest_path) {
|
||||
FIL file;
|
||||
FILINFO stat;
|
||||
|
||||
CHECK_FRESULT(f_stat(string_get_cstr(manifest_path), &stat));
|
||||
CHECK_FRESULT(f_open(&file, string_get_cstr(manifest_path), FA_OPEN_EXISTING | FA_READ));
|
||||
@@ -164,7 +158,7 @@ static UpdateManifest* flipper_update_process_manifest(const string_t work_dir)
|
||||
}
|
||||
} while(false);
|
||||
|
||||
string_clear(manifest_path);
|
||||
f_close(&file);
|
||||
free(manifest_data);
|
||||
return manifest;
|
||||
}
|
||||
@@ -174,22 +168,25 @@ void flipper_boot_update_exec() {
|
||||
return;
|
||||
}
|
||||
|
||||
string_t work_dir;
|
||||
string_t work_dir, manifest_path;
|
||||
string_init(work_dir);
|
||||
string_init(manifest_path);
|
||||
do {
|
||||
if(!flipper_update_get_work_directory(work_dir)) {
|
||||
if(!flipper_update_get_manifest_path(manifest_path)) {
|
||||
break;
|
||||
}
|
||||
|
||||
UpdateManifest* manifest = flipper_update_process_manifest(work_dir);
|
||||
UpdateManifest* manifest = flipper_update_process_manifest(manifest_path);
|
||||
if(!manifest) {
|
||||
break;
|
||||
}
|
||||
|
||||
path_extract_dirname(string_get_cstr(manifest_path), work_dir);
|
||||
if(!flipper_update_load_stage(work_dir, manifest)) {
|
||||
update_manifest_free(manifest);
|
||||
}
|
||||
} while(false);
|
||||
string_clear(manifest_path);
|
||||
string_clear(work_dir);
|
||||
free(pfs);
|
||||
}
|
||||
|
@@ -7,6 +7,8 @@
|
||||
|
||||
#include <hw_conf.h>
|
||||
|
||||
#define TAG "FuriHalRandom"
|
||||
|
||||
uint32_t furi_hal_random_get() {
|
||||
while(LL_HSEM_1StepLock(HSEM, CFG_HW_RNG_SEMID))
|
||||
;
|
||||
@@ -51,9 +53,13 @@ void furi_hal_random_fill_buf(uint8_t* buf, uint32_t len) {
|
||||
}
|
||||
|
||||
void srand(unsigned seed) {
|
||||
UNUSED(seed); // FIXME!
|
||||
UNUSED(seed);
|
||||
}
|
||||
|
||||
int rand() {
|
||||
return (furi_hal_random_get() & RAND_MAX);
|
||||
}
|
||||
|
||||
long random() {
|
||||
return (furi_hal_random_get() & RAND_MAX);
|
||||
}
|
||||
|
@@ -972,9 +972,9 @@ void furi_hal_subghz_stop_async_tx() {
|
||||
FURI_LOG_D(
|
||||
TAG,
|
||||
"Async TX Radio stats: on %0.0fus, off %0.0fus, DutyCycle: %0.0f%%",
|
||||
(float)furi_hal_subghz_async_tx.duty_high,
|
||||
(float)furi_hal_subghz_async_tx.duty_low,
|
||||
duty_cycle);
|
||||
(double)furi_hal_subghz_async_tx.duty_high,
|
||||
(double)furi_hal_subghz_async_tx.duty_low,
|
||||
(double)duty_cycle);
|
||||
|
||||
furi_hal_subghz_state = SubGhzStateIdle;
|
||||
}
|
||||
|
@@ -135,6 +135,7 @@ SECTIONS
|
||||
_sdata = .; /* create a global symbol at data start */
|
||||
*(.data) /* .data sections */
|
||||
*(.data*) /* .data* sections */
|
||||
*(*_DRIVER_CONTEXT)
|
||||
|
||||
. = ALIGN(4);
|
||||
_edata = .; /* define a global symbol at data end */
|
||||
@@ -158,7 +159,7 @@ SECTIONS
|
||||
} >RAM1
|
||||
|
||||
/* User_heap_stack section, used to check that there is enough RAM left */
|
||||
._user_heap_stack :
|
||||
._user_heap_stack(NOLOAD):
|
||||
{
|
||||
. = ALIGN(8);
|
||||
__heap_start__ = .;
|
||||
@@ -173,7 +174,7 @@ SECTIONS
|
||||
{
|
||||
__free_flash_start__ = .;
|
||||
. = ORIGIN(FLASH) + LENGTH(FLASH);
|
||||
} >FLASH
|
||||
} >FLASH
|
||||
|
||||
/* Remove information from the standard libraries */
|
||||
/DISCARD/ :
|
||||
|
@@ -19,9 +19,9 @@ endif
|
||||
MCU_FLAGS = -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard
|
||||
|
||||
# Warnings configuration
|
||||
CFLAGS += -Wall -Wextra -Wredundant-decls
|
||||
CFLAGS += -Wall -Wextra -Wredundant-decls -Wdouble-promotion
|
||||
|
||||
CFLAGS += $(MCU_FLAGS) -DSTM32WB55xx -fdata-sections -ffunction-sections
|
||||
CFLAGS += $(MCU_FLAGS) -DSTM32WB55xx -fdata-sections -ffunction-sections -fsingle-precision-constant
|
||||
LDFLAGS += $(MCU_FLAGS) -specs=nosys.specs -specs=nano.specs
|
||||
|
||||
CPPFLAGS += -fno-rtti -fno-use-cxa-atexit -fno-exceptions
|
||||
|
Reference in New Issue
Block a user