Skip to content

Commit

Permalink
[FL-2468] Reboot to update with RPC (flipperdevices#1122)
Browse files Browse the repository at this point in the history
* Added update boot mode for RPC
* Fixed FLIPPER_SYSTEM_APPS_COUNT & updater app arg parsing
* Bumped RPC version
* Moved boot mode
  • Loading branch information
hedger authored Apr 15, 2022
1 parent c209ec5 commit 827e30a
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 9 deletions.
1 change: 1 addition & 0 deletions applications/power/power_service/power.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ typedef struct Power Power;
typedef enum {
PowerBootModeNormal,
PowerBootModeDfu,
PowerBootModeUpdateStart,
} PowerBootMode;

typedef enum {
Expand Down
2 changes: 2 additions & 0 deletions applications/power/power_service/power_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ void power_reboot(PowerBootMode mode) {
furi_hal_rtc_set_boot_mode(FuriHalRtcBootModeNormal);
} else if(mode == PowerBootModeDfu) {
furi_hal_rtc_set_boot_mode(FuriHalRtcBootModeDfu);
} else if(mode == PowerBootModeUpdateStart) {
furi_hal_rtc_set_boot_mode(FuriHalRtcBootModePreUpdate);
}
furi_hal_power_reset();
}
Expand Down
4 changes: 3 additions & 1 deletion applications/rpc/rpc_system.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ static void rpc_system_system_reboot_process(const PB_Main* request, void* conte
power_reboot(PowerBootModeNormal);
} else if(mode == PB_System_RebootRequest_RebootMode_DFU) {
power_reboot(PowerBootModeDfu);
} else if(mode == PB_System_RebootRequest_RebootMode_UPDATE) {
power_reboot(PowerBootModeUpdateStart);
} else {
rpc_send_and_release_empty(
session, request->command_id, PB_CommandStatus_ERROR_INVALID_PARAMETERS);
Expand Down Expand Up @@ -274,7 +276,7 @@ static void rpc_system_system_update_request_process(const PB_Main* request, voi
furi_assert(session);

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;

PB_Main* response = malloc(sizeof(PB_Main));
Expand Down
4 changes: 3 additions & 1 deletion applications/updater/updater.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ Updater* updater_alloc(const char* arg) {
#ifdef FURI_RAM_EXEC
if(true) {
#else
if(!arg) {
FuriHalRtcBootMode boot_mode = furi_hal_rtc_get_boot_mode();
if(!arg && ((boot_mode == FuriHalRtcBootModePreUpdate) ||
(boot_mode == FuriHalRtcBootModePostUpdate))) {
#endif
updater->update_task = update_task_alloc();
update_task_set_progress_cb(updater->update_task, status_update_cb, updater->main_view);
Expand Down
13 changes: 7 additions & 6 deletions assets/compiled/system.pb.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
/* Enum definitions */
typedef enum _PB_System_RebootRequest_RebootMode {
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;

/* Struct definitions */
Expand Down Expand Up @@ -59,7 +60,7 @@ typedef struct _PB_System_ProtobufVersionRequest {
} PB_System_ProtobufVersionRequest;

typedef struct _PB_System_UpdateRequest {
char *update_folder;
char *update_manifest;
} PB_System_UpdateRequest;

typedef struct _PB_System_DateTime {
Expand Down Expand Up @@ -96,8 +97,8 @@ typedef struct _PB_System_SetDateTimeRequest {

/* Helper constants for enums */
#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_ARRAYSIZE ((PB_System_RebootRequest_RebootMode)(PB_System_RebootRequest_RebootMode_DFU+1))
#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_UPDATE+1))


#ifdef __cplusplus
Expand Down Expand Up @@ -145,7 +146,7 @@ extern "C" {
#define PB_System_PingResponse_data_tag 1
#define PB_System_PowerInfoResponse_key_tag 1
#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_minute_tag 2
#define PB_System_DateTime_second_tag 3
Expand Down Expand Up @@ -236,7 +237,7 @@ X(a, STATIC, SINGULAR, UINT32, minor, 2)
#define PB_System_ProtobufVersionResponse_DEFAULT NULL

#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_DEFAULT NULL

Expand Down
2 changes: 1 addition & 1 deletion assets/protobuf
Submodule protobuf updated 3 files
+6 −0 Changelog
+1 −1 system.options
+2 −1 system.proto

0 comments on commit 827e30a

Please sign in to comment.