[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:
@@ -68,7 +68,7 @@ static void bt_cli_command_carrier_rx(Cli* cli, string_t args, void* context) {
|
||||
|
||||
while(!cli_cmd_interrupt_received(cli)) {
|
||||
osDelay(250);
|
||||
printf("RSSI: %6.1f dB\r", furi_hal_bt_get_rssi());
|
||||
printf("RSSI: %6.1f dB\r", (double)furi_hal_bt_get_rssi());
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
@@ -140,11 +140,9 @@ static void bt_cli_command_packet_rx(Cli* cli, string_t args, void* context) {
|
||||
printf("Press CTRL+C to stop\r\n");
|
||||
furi_hal_bt_start_packet_rx(channel, datarate);
|
||||
|
||||
float rssi_raw = 0;
|
||||
while(!cli_cmd_interrupt_received(cli)) {
|
||||
osDelay(250);
|
||||
rssi_raw = furi_hal_bt_get_rssi();
|
||||
printf("RSSI: %03.1f dB\r", rssi_raw);
|
||||
printf("RSSI: %03.1f dB\r", (double)furi_hal_bt_get_rssi());
|
||||
fflush(stdout);
|
||||
}
|
||||
uint16_t packets_received = furi_hal_bt_stop_packet_test();
|
||||
|
@@ -99,7 +99,7 @@ static void bt_test_draw_callback(Canvas* canvas, void* _model) {
|
||||
canvas_draw_str(canvas, 6, 60, model->message);
|
||||
if(model->state == BtTestStateStarted) {
|
||||
if(model->rssi != 0.0f) {
|
||||
snprintf(info_str, sizeof(info_str), "RSSI:%3.1f dB", model->rssi);
|
||||
snprintf(info_str, sizeof(info_str), "RSSI:%3.1f dB", (double)model->rssi);
|
||||
canvas_draw_str_aligned(canvas, 124, 60, AlignRight, AlignBottom, info_str);
|
||||
}
|
||||
} else if(model->state == BtTestStateStopped) {
|
||||
|
@@ -1,6 +1,7 @@
|
||||
#include <gui/view_stack.h>
|
||||
#include <stdint.h>
|
||||
#include <furi.h>
|
||||
#include <furi_hal.h>
|
||||
#include <m-string.h>
|
||||
#include <portmacro.h>
|
||||
#include <dolphin/dolphin.h>
|
||||
@@ -391,7 +392,7 @@ static StorageAnimation*
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t lucky_number = random() % whole_weight;
|
||||
uint32_t lucky_number = furi_hal_random_get() % whole_weight;
|
||||
uint32_t weight = 0;
|
||||
|
||||
StorageAnimation* selected = NULL;
|
||||
|
@@ -100,7 +100,8 @@ static const FrameBubble*
|
||||
return NULL;
|
||||
}
|
||||
|
||||
uint8_t index = random() % (active ? model->active_bubbles : model->passive_bubbles);
|
||||
uint8_t index =
|
||||
furi_hal_random_get() % (active ? model->active_bubbles : model->passive_bubbles);
|
||||
const BubbleAnimation* animation = model->current;
|
||||
|
||||
for(int i = 0; i < animation->frame_bubble_sequences_count; ++i) {
|
||||
|
@@ -145,7 +145,7 @@ bool infrared_parser_is_raw_signal_valid(
|
||||
frequency);
|
||||
result = false;
|
||||
} else if((duty_cycle <= 0) || (duty_cycle > 1)) {
|
||||
FURI_LOG_E(TAG, "Duty cycle is out of range (0 - 1): %f", duty_cycle);
|
||||
FURI_LOG_E(TAG, "Duty cycle is out of range (0 - 1): %f", (double)duty_cycle);
|
||||
result = false;
|
||||
} else if((timings_cnt <= 0) || (timings_cnt > MAX_TIMINGS_AMOUNT)) {
|
||||
FURI_LOG_E(
|
||||
|
@@ -29,6 +29,8 @@ void LfRfidViewTuneVM::view_draw_callback(Canvas* canvas, void* _model) {
|
||||
|
||||
constexpr uint8_t buffer_size = 128;
|
||||
char buffer[buffer_size + 1];
|
||||
double freq = ((float)SystemCoreClock / ((float)model->ARR + 1));
|
||||
double duty = ((float)model->CCR + 1) / ((float)model->ARR + 1) * 100.0f;
|
||||
snprintf(
|
||||
buffer,
|
||||
buffer_size,
|
||||
@@ -38,10 +40,10 @@ void LfRfidViewTuneVM::view_draw_callback(Canvas* canvas, void* _model) {
|
||||
"duty = %.4f",
|
||||
model->pos == 0 ? ">" : "",
|
||||
model->ARR,
|
||||
(float)SystemCoreClock / ((float)model->ARR + 1),
|
||||
freq,
|
||||
model->pos == 1 ? ">" : "",
|
||||
model->CCR,
|
||||
((float)model->CCR + 1) / ((float)model->ARR + 1) * 100.0f);
|
||||
duty);
|
||||
elements_multiline_text_aligned(canvas, 2, 2, AlignLeft, AlignTop, buffer);
|
||||
}
|
||||
|
||||
|
@@ -275,15 +275,22 @@ static void rpc_system_system_update_request_process(const PB_Main* request, voi
|
||||
RpcSession* session = (RpcSession*)context;
|
||||
furi_assert(session);
|
||||
|
||||
bool update_prepare_result =
|
||||
update_operation_prepare(request->content.system_update_request.update_manifest) ==
|
||||
UpdatePrepareResultOK;
|
||||
UpdatePrepareResult update_prepare_result =
|
||||
update_operation_prepare(request->content.system_update_request.update_manifest);
|
||||
/* RPC enum does not have such entry; setting to closest one */
|
||||
if(update_prepare_result == UpdatePrepareResultOutdatedManifestVersion) {
|
||||
update_prepare_result = UpdatePrepareResultManifestInvalid;
|
||||
}
|
||||
|
||||
PB_Main* response = malloc(sizeof(PB_Main));
|
||||
response->command_id = request->command_id;
|
||||
response->has_next = false;
|
||||
response->command_status = update_prepare_result ? PB_CommandStatus_OK :
|
||||
PB_CommandStatus_ERROR_INVALID_PARAMETERS;
|
||||
response->command_status = (update_prepare_result == UpdatePrepareResultOK) ?
|
||||
PB_CommandStatus_OK :
|
||||
PB_CommandStatus_ERROR_INVALID_PARAMETERS;
|
||||
response->which_content = PB_Main_system_update_response_tag;
|
||||
response->content.system_update_response.code =
|
||||
(PB_System_UpdateResponse_UpdateResultCode)update_prepare_result;
|
||||
rpc_send_and_release(session, response);
|
||||
free(response);
|
||||
}
|
||||
|
@@ -94,7 +94,7 @@ void subghz_cli_command_rx_carrier(Cli* cli, string_t args, void* context) {
|
||||
|
||||
while(!cli_cmd_interrupt_received(cli)) {
|
||||
osDelay(250);
|
||||
printf("RSSI: %03.1fdbm\r", furi_hal_subghz_get_rssi());
|
||||
printf("RSSI: %03.1fdbm\r", (double)furi_hal_subghz_get_rssi());
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
|
@@ -70,7 +70,7 @@ void unit_tests_cli(Cli* cli, string_t args, void* context) {
|
||||
|
||||
cycle_counter = (furi_hal_get_tick() - cycle_counter);
|
||||
|
||||
FURI_LOG_I(TAG, "Consumed: %0.2fs", (float)cycle_counter / 1000);
|
||||
FURI_LOG_I(TAG, "Consumed: %u us", cycle_counter);
|
||||
|
||||
if(test_result == 0) {
|
||||
furi_hal_delay_ms(200); /* wait for tested services and apps to deallocate */
|
||||
|
@@ -52,7 +52,7 @@ static void updater_cli_restore(string_t args) {
|
||||
static void updater_cli_help(string_t args) {
|
||||
UNUSED(args);
|
||||
printf("Commands:\r\n"
|
||||
"\tinstall /ext/update/PACKAGE/update.fuf - verify & apply update package\r\n"
|
||||
"\tinstall /ext/path/to/update.fuf - verify & apply update package\r\n"
|
||||
"\tbackup /ext/path/to/backup.tar - create internal storage backup\r\n"
|
||||
"\trestore /ext/path/to/backup.tar - restore internal storage backup\r\n");
|
||||
}
|
||||
|
@@ -260,16 +260,18 @@ bool update_task_parse_manifest(UpdateTask* update_task) {
|
||||
string_init(manifest_path);
|
||||
|
||||
do {
|
||||
update_task_set_progress(update_task, UpdateTaskStageProgress, 10);
|
||||
if(!update_operation_get_current_package_path(
|
||||
update_task->storage, update_task->update_path)) {
|
||||
update_task_set_progress(update_task, UpdateTaskStageProgress, 13);
|
||||
if(!furi_hal_version_do_i_belong_here()) {
|
||||
break;
|
||||
}
|
||||
|
||||
path_concat(
|
||||
string_get_cstr(update_task->update_path),
|
||||
UPDATE_MANIFEST_DEFAULT_NAME,
|
||||
manifest_path);
|
||||
update_task_set_progress(update_task, UpdateTaskStageProgress, 20);
|
||||
if(!update_operation_get_current_package_manifest_path(
|
||||
update_task->storage, manifest_path)) {
|
||||
break;
|
||||
}
|
||||
|
||||
path_extract_dirname(string_get_cstr(manifest_path), update_task->update_path);
|
||||
update_task_set_progress(update_task, UpdateTaskStageProgress, 30);
|
||||
|
||||
UpdateManifest* manifest = update_task->manifest;
|
||||
@@ -277,6 +279,16 @@ bool update_task_parse_manifest(UpdateTask* update_task) {
|
||||
break;
|
||||
}
|
||||
|
||||
update_task_set_progress(update_task, UpdateTaskStageProgress, 40);
|
||||
if(manifest->manifest_version < UPDATE_OPERATION_MIN_MANIFEST_VERSION) {
|
||||
break;
|
||||
}
|
||||
|
||||
update_task_set_progress(update_task, UpdateTaskStageProgress, 50);
|
||||
if(manifest->target != furi_hal_version_get_hw_target()) {
|
||||
break;
|
||||
}
|
||||
|
||||
update_task->state.groups = update_task_get_task_groups(update_task);
|
||||
for(size_t stage_counter = 0; stage_counter < COUNT_OF(update_task_stage_progress);
|
||||
++stage_counter) {
|
||||
@@ -286,13 +298,13 @@ bool update_task_parse_manifest(UpdateTask* update_task) {
|
||||
}
|
||||
}
|
||||
|
||||
update_task_set_progress(update_task, UpdateTaskStageProgress, 50);
|
||||
update_task_set_progress(update_task, UpdateTaskStageProgress, 60);
|
||||
if((update_task->state.groups & UpdateTaskStageGroupFirmware) &&
|
||||
!update_task_check_file_exists(update_task, manifest->firmware_dfu_image)) {
|
||||
break;
|
||||
}
|
||||
|
||||
update_task_set_progress(update_task, UpdateTaskStageProgress, 70);
|
||||
update_task_set_progress(update_task, UpdateTaskStageProgress, 80);
|
||||
if((update_task->state.groups & UpdateTaskStageGroupRadio) &&
|
||||
(!update_task_check_file_exists(update_task, manifest->radio_image) ||
|
||||
(manifest->radio_version.version.type == 0))) {
|
||||
|
@@ -63,7 +63,6 @@ static bool update_task_post_update(UpdateTask* update_task) {
|
||||
|
||||
TarArchive* archive = tar_archive_alloc(update_task->storage);
|
||||
do {
|
||||
CHECK_RESULT(update_task_parse_manifest(update_task));
|
||||
path_concat(
|
||||
string_get_cstr(update_task->update_path), LFS_BACKUP_DEFAULT_FILENAME, file_path);
|
||||
|
||||
@@ -114,7 +113,7 @@ int32_t update_task_worker_backup_restore(void* context) {
|
||||
return UPDATE_TASK_NOERR;
|
||||
}
|
||||
|
||||
if(!update_operation_get_current_package_path(update_task->storage, update_task->update_path)) {
|
||||
if(!update_task_parse_manifest(update_task)) {
|
||||
return UPDATE_TASK_FAILED;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user