[FL-2468] Reboot to update with RPC (#1122)

* Added update boot mode for RPC
* Fixed FLIPPER_SYSTEM_APPS_COUNT & updater app arg parsing
* Bumped RPC version
* Moved boot mode
This commit is contained in:
hedger 2022-04-15 19:47:57 +03:00 committed by GitHub
parent c209ec56fc
commit 827e30aa5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 17 additions and 9 deletions

View File

@ -9,6 +9,7 @@ typedef struct Power Power;
typedef enum { typedef enum {
PowerBootModeNormal, PowerBootModeNormal,
PowerBootModeDfu, PowerBootModeDfu,
PowerBootModeUpdateStart,
} PowerBootMode; } PowerBootMode;
typedef enum { typedef enum {

View File

@ -17,6 +17,8 @@ void power_reboot(PowerBootMode mode) {
furi_hal_rtc_set_boot_mode(FuriHalRtcBootModeNormal); furi_hal_rtc_set_boot_mode(FuriHalRtcBootModeNormal);
} else if(mode == PowerBootModeDfu) { } else if(mode == PowerBootModeDfu) {
furi_hal_rtc_set_boot_mode(FuriHalRtcBootModeDfu); furi_hal_rtc_set_boot_mode(FuriHalRtcBootModeDfu);
} else if(mode == PowerBootModeUpdateStart) {
furi_hal_rtc_set_boot_mode(FuriHalRtcBootModePreUpdate);
} }
furi_hal_power_reset(); furi_hal_power_reset();
} }

View File

@ -61,6 +61,8 @@ static void rpc_system_system_reboot_process(const PB_Main* request, void* conte
power_reboot(PowerBootModeNormal); power_reboot(PowerBootModeNormal);
} else if(mode == PB_System_RebootRequest_RebootMode_DFU) { } else if(mode == PB_System_RebootRequest_RebootMode_DFU) {
power_reboot(PowerBootModeDfu); power_reboot(PowerBootModeDfu);
} else if(mode == PB_System_RebootRequest_RebootMode_UPDATE) {
power_reboot(PowerBootModeUpdateStart);
} else { } else {
rpc_send_and_release_empty( rpc_send_and_release_empty(
session, request->command_id, PB_CommandStatus_ERROR_INVALID_PARAMETERS); session, request->command_id, PB_CommandStatus_ERROR_INVALID_PARAMETERS);
@ -274,7 +276,7 @@ static void rpc_system_system_update_request_process(const PB_Main* request, voi
furi_assert(session); furi_assert(session);
bool update_prepare_result = bool update_prepare_result =
update_operation_prepare(request->content.system_update_request.update_folder) == update_operation_prepare(request->content.system_update_request.update_manifest) ==
UpdatePrepareResultOK; UpdatePrepareResultOK;
PB_Main* response = malloc(sizeof(PB_Main)); PB_Main* response = malloc(sizeof(PB_Main));

View File

@ -80,7 +80,9 @@ Updater* updater_alloc(const char* arg) {
#ifdef FURI_RAM_EXEC #ifdef FURI_RAM_EXEC
if(true) { if(true) {
#else #else
if(!arg) { FuriHalRtcBootMode boot_mode = furi_hal_rtc_get_boot_mode();
if(!arg && ((boot_mode == FuriHalRtcBootModePreUpdate) ||
(boot_mode == FuriHalRtcBootModePostUpdate))) {
#endif #endif
updater->update_task = update_task_alloc(); updater->update_task = update_task_alloc();
update_task_set_progress_cb(updater->update_task, status_update_cb, updater->main_view); update_task_set_progress_cb(updater->update_task, status_update_cb, updater->main_view);

View File

@ -12,7 +12,8 @@
/* Enum definitions */ /* Enum definitions */
typedef enum _PB_System_RebootRequest_RebootMode { typedef enum _PB_System_RebootRequest_RebootMode {
PB_System_RebootRequest_RebootMode_OS = 0, PB_System_RebootRequest_RebootMode_OS = 0,
PB_System_RebootRequest_RebootMode_DFU = 1 PB_System_RebootRequest_RebootMode_DFU = 1,
PB_System_RebootRequest_RebootMode_UPDATE = 2
} PB_System_RebootRequest_RebootMode; } PB_System_RebootRequest_RebootMode;
/* Struct definitions */ /* Struct definitions */
@ -59,7 +60,7 @@ typedef struct _PB_System_ProtobufVersionRequest {
} PB_System_ProtobufVersionRequest; } PB_System_ProtobufVersionRequest;
typedef struct _PB_System_UpdateRequest { typedef struct _PB_System_UpdateRequest {
char *update_folder; char *update_manifest;
} PB_System_UpdateRequest; } PB_System_UpdateRequest;
typedef struct _PB_System_DateTime { typedef struct _PB_System_DateTime {
@ -96,8 +97,8 @@ typedef struct _PB_System_SetDateTimeRequest {
/* Helper constants for enums */ /* Helper constants for enums */
#define _PB_System_RebootRequest_RebootMode_MIN PB_System_RebootRequest_RebootMode_OS #define _PB_System_RebootRequest_RebootMode_MIN PB_System_RebootRequest_RebootMode_OS
#define _PB_System_RebootRequest_RebootMode_MAX PB_System_RebootRequest_RebootMode_DFU #define _PB_System_RebootRequest_RebootMode_MAX PB_System_RebootRequest_RebootMode_UPDATE
#define _PB_System_RebootRequest_RebootMode_ARRAYSIZE ((PB_System_RebootRequest_RebootMode)(PB_System_RebootRequest_RebootMode_DFU+1)) #define _PB_System_RebootRequest_RebootMode_ARRAYSIZE ((PB_System_RebootRequest_RebootMode)(PB_System_RebootRequest_RebootMode_UPDATE+1))
#ifdef __cplusplus #ifdef __cplusplus
@ -145,7 +146,7 @@ extern "C" {
#define PB_System_PingResponse_data_tag 1 #define PB_System_PingResponse_data_tag 1
#define PB_System_PowerInfoResponse_key_tag 1 #define PB_System_PowerInfoResponse_key_tag 1
#define PB_System_PowerInfoResponse_value_tag 2 #define PB_System_PowerInfoResponse_value_tag 2
#define PB_System_UpdateRequest_update_folder_tag 1 #define PB_System_UpdateRequest_update_manifest_tag 1
#define PB_System_DateTime_hour_tag 1 #define PB_System_DateTime_hour_tag 1
#define PB_System_DateTime_minute_tag 2 #define PB_System_DateTime_minute_tag 2
#define PB_System_DateTime_second_tag 3 #define PB_System_DateTime_second_tag 3
@ -236,7 +237,7 @@ X(a, STATIC, SINGULAR, UINT32, minor, 2)
#define PB_System_ProtobufVersionResponse_DEFAULT NULL #define PB_System_ProtobufVersionResponse_DEFAULT NULL
#define PB_System_UpdateRequest_FIELDLIST(X, a) \ #define PB_System_UpdateRequest_FIELDLIST(X, a) \
X(a, POINTER, SINGULAR, STRING, update_folder, 1) X(a, POINTER, SINGULAR, STRING, update_manifest, 1)
#define PB_System_UpdateRequest_CALLBACK NULL #define PB_System_UpdateRequest_CALLBACK NULL
#define PB_System_UpdateRequest_DEFAULT NULL #define PB_System_UpdateRequest_DEFAULT NULL

@ -1 +1 @@
Subproject commit 0403ae1ba7a4501274da54b3aa6274f76fdd090c Subproject commit 0ad90705b9434b6f8fb2c4b605069f0d56d8cc70