Skip to content

Commit f0949c9

Browse files
committed
Merge remote-tracking branch 'upstream/dev' into custom
# Conflicts: # applications/main/subghz/scenes/subghz_scene_rpc.c
2 parents f9dd6ea + 889c80e commit f0949c9

File tree

9 files changed

+86
-27
lines changed

9 files changed

+86
-27
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@
1313
* OFW: iButton ID writing (Enable ID writing for ds1971 and ds1996)
1414
* Apps: **Check out more Apps updates and fixes by following** [this link](https://github.com/xMasterX/all-the-plugins/commits/dev)
1515
## Other changes
16+
* Archive: Fix BadUSB favourite path check
17+
* Settings: Show free flash amount in internal storage info (by @Willy-JL)
1618
* Misc: Fix typo in comment in QueueTools.py (by @eltociear | PR #785)
19+
* OFW PR 3840: GUI: NumberInput small improvements (by @Willy-JL)
20+
* OFW PR 3838: SubGhz: Fix RPC status for ButtonRelease event (by @Skorpionm)
21+
* OFW: scripts: improved size validator for updater image
22+
* OFW: Desktop: seaprate callbacks for dolphin and storage subscriptions
1723
* OFW: Make file extensions case-insensitive
1824
* OFW: Remove internal storage folder if corresponding flag set
1925
* OFW: **Added a text input that only accepts full numbers (int)**

applications/main/archive/helpers/archive_files.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ void archive_set_file_type(ArchiveFile_t* file, const char* path, bool is_folder
1717
if((known_ext[i][0] == '?') || (known_ext[i][0] == '*')) continue;
1818
if(furi_string_end_withi(file->path, known_ext[i])) {
1919
if((i == ArchiveFileTypeBadUsb) || (i == ArchiveFileTypeSubGhzRemote)) {
20-
if(furi_string_search(
21-
file->path, archive_get_default_path(ArchiveTabBadUsb)) == 0) {
20+
if((furi_string_search(file->path, EXT_PATH("badusb")) == 0) ||
21+
(furi_string_search(file->path, ANY_PATH("badusb")) == 0)) {
2222
file->type = ArchiveFileTypeBadUsb;
2323
return; // *.txt file is a BadUSB script only if it is in BadUSB folder
2424
}

applications/main/subghz/scenes/subghz_scene_rpc.c

+4
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ bool subghz_scene_rpc_on_event(void* context, SceneManagerEvent event) {
5959
default: //if(SubGhzTxRxStartTxStateOk)
6060
result = true;
6161
subghz_blink_start(subghz);
62+
scene_manager_set_scene_state(
63+
subghz->scene_manager, SubGhzSceneRpc, SubGhzRpcStateTx);
6264
break;
6365
}
6466
}
@@ -70,6 +72,8 @@ bool subghz_scene_rpc_on_event(void* context, SceneManagerEvent event) {
7072
subghz_blink_stop(subghz);
7173
result = true;
7274
}
75+
scene_manager_set_scene_state(
76+
subghz->scene_manager, SubGhzSceneRpc, SubGhzRpcStateIdle);
7377
rpc_system_app_confirm(subghz->rpc_ctx, result);
7478
} else if(event.event == SubGhzCustomEventSceneRpcLoad) {
7579
bool result = false;

applications/services/desktop/animations/animation_manager.c

+19-3
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ void animation_manager_set_dummy_mode_state(AnimationManager* animation_manager,
104104
}
105105
}
106106

107-
static void animation_manager_check_blocking_callback(const void* message, void* context) {
107+
static void animation_manager_storage_callback(const void* message, void* context) {
108108
const StorageEvent* storage_event = message;
109109

110110
switch(storage_event->type) {
@@ -123,6 +123,22 @@ static void animation_manager_check_blocking_callback(const void* message, void*
123123
}
124124
}
125125

126+
static void animation_manager_dolphin_callback(const void* message, void* context) {
127+
const DolphinPubsubEvent* dolphin_event = message;
128+
129+
switch(*dolphin_event) {
130+
case DolphinPubsubEventUpdate:
131+
furi_assert(context);
132+
AnimationManager* animation_manager = context;
133+
if(animation_manager->check_blocking_callback) {
134+
animation_manager->check_blocking_callback(animation_manager->context);
135+
}
136+
break;
137+
default:
138+
break;
139+
}
140+
}
141+
126142
static void animation_manager_timer_callback(void* context) {
127143
furi_assert(context);
128144
AnimationManager* animation_manager = context;
@@ -300,12 +316,12 @@ AnimationManager* animation_manager_alloc(void) {
300316

301317
Storage* storage = furi_record_open(RECORD_STORAGE);
302318
animation_manager->pubsub_subscription_storage = furi_pubsub_subscribe(
303-
storage_get_pubsub(storage), animation_manager_check_blocking_callback, animation_manager);
319+
storage_get_pubsub(storage), animation_manager_storage_callback, animation_manager);
304320
furi_record_close(RECORD_STORAGE);
305321

306322
Dolphin* dolphin = furi_record_open(RECORD_DOLPHIN);
307323
animation_manager->pubsub_subscription_dolphin = furi_pubsub_subscribe(
308-
dolphin_get_pubsub(dolphin), animation_manager_check_blocking_callback, animation_manager);
324+
dolphin_get_pubsub(dolphin), animation_manager_dolphin_callback, animation_manager);
309325
furi_record_close(RECORD_DOLPHIN);
310326

311327
animation_manager->blocking_shown_sd_ok = true;

applications/services/dolphin/dolphin.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,8 @@ static bool dolphin_process_event(FuriEventLoopObject* object, void* context) {
204204
if(event.type == DolphinEventTypeDeed) {
205205
dolphin_state_on_deed(dolphin->state, event.deed);
206206

207-
DolphinPubsubEvent event = DolphinPubsubEventUpdate;
208-
furi_pubsub_publish(dolphin->pubsub, &event);
207+
DolphinPubsubEvent pubsub_event = DolphinPubsubEventUpdate;
208+
furi_pubsub_publish(dolphin->pubsub, &pubsub_event);
209209
furi_event_loop_timer_start(dolphin->butthurt_timer, BUTTHURT_INCREASE_PERIOD_TICKS);
210210
furi_event_loop_timer_start(dolphin->flush_timer, FLUSH_TIMEOUT_TICKS);
211211

applications/services/gui/modules/number_input.c

+10-4
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ static void number_input_draw_input(Canvas* canvas, NumberInputModel* model) {
9393
const size_t text_x = 8;
9494
const size_t text_y = 25;
9595

96-
elements_slightly_rounded_frame(canvas, 6, 14, 116, 15);
96+
elements_slightly_rounded_frame(canvas, 4, 14, 120, 15);
9797

9898
canvas_draw_str(canvas, text_x, text_y, furi_string_get_cstr(model->text_buffer));
9999
}
@@ -206,7 +206,7 @@ static void number_input_add_digit(NumberInputModel* model, char* newChar) {
206206
}
207207
model->current_number = strtol(furi_string_get_cstr(model->text_buffer), NULL, 10);
208208
if(model->current_number == 0) {
209-
furi_string_reset(model->text_buffer);
209+
furi_string_set(model->text_buffer, "0");
210210
}
211211
}
212212

@@ -417,7 +417,9 @@ void number_input_set_result_callback(
417417
int32_t max_value) {
418418
furi_check(number_input);
419419

420-
current_number = CLAMP(current_number, max_value, min_value);
420+
if(current_number != 0) {
421+
current_number = CLAMP(current_number, max_value, min_value);
422+
}
421423

422424
with_view_model(
423425
number_input->view,
@@ -426,7 +428,11 @@ void number_input_set_result_callback(
426428
model->callback = callback;
427429
model->callback_context = callback_context;
428430
model->current_number = current_number;
429-
furi_string_printf(model->text_buffer, "%ld", current_number);
431+
if(current_number != 0) {
432+
furi_string_printf(model->text_buffer, "%ld", current_number);
433+
} else {
434+
furi_string_set(model->text_buffer, "");
435+
}
430436
model->min_value = min_value;
431437
model->max_value = max_value;
432438
},

applications/settings/storage_settings/scenes/storage_settings_scene_internal_info.c

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "../storage_settings.h"
22
#include <furi_hal_version.h>
3+
#include <furi_hal_flash.h>
34

45
static void
56
storage_settings_scene_internal_info_dialog_callback(DialogExResult result, void* context) {
@@ -27,10 +28,20 @@ void storage_settings_scene_internal_info_on_enter(void* context) {
2728
} else {
2829
furi_string_printf(
2930
app->text_string,
30-
"Name: %s\nType: Virtual\nTotal: %lu KiB\nFree: %lu KiB",
31+
"Name: %s\nType: Virtual (/.int on SD)\nTotal: %lu KiB\nFree: %lu KiB\n",
3132
furi_hal_version_get_name_ptr() ? furi_hal_version_get_name_ptr() : "Unknown",
3233
(uint32_t)(total_space / 1024),
3334
(uint32_t)(free_space / 1024));
35+
36+
uint32_t free_flash =
37+
furi_hal_flash_get_free_end_address() - furi_hal_flash_get_free_start_address();
38+
if(free_flash < 1024) {
39+
furi_string_cat_printf(app->text_string, "Flash: %lu B free", free_flash);
40+
} else {
41+
furi_string_cat_printf(
42+
app->text_string, "Flash: %.2f KiB free", (double)free_flash / 1024);
43+
}
44+
3445
dialog_ex_set_text(
3546
dialog_ex, furi_string_get_cstr(app->text_string), 4, 4, AlignLeft, AlignTop);
3647
}

scripts/imglint.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from pathlib import Path
55

66
from flipper.app import App
7-
from PIL import Image, ImageOps
7+
from PIL import Image
88

99
_logger = logging.getLogger(__name__)
1010

scripts/update.py

+30-14
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
#!/usr/bin/env python3
22

3-
import io
43
import math
54
import os
65
import shutil
76
import tarfile
87
import zlib
98
from os.path import exists, join
109

11-
import heatshrink2
1210
from flipper.app import App
1311
from flipper.assets.coprobin import CoproBinary, get_stack_type
1412
from flipper.assets.heatshrink_stream import HeatshrinkDataStreamHeader
@@ -35,7 +33,12 @@ class Main(App):
3533
)
3634

3735
FLASH_BASE = 0x8000000
38-
MIN_LFS_PAGES = 6
36+
FLASH_PAGE_SIZE = 4 * 1024
37+
MIN_GAP_PAGES = 2
38+
39+
# Update stage file larger than that is not loadable without fix
40+
# https://github.com/flipperdevices/flipperzero-firmware/pull/3676
41+
UPDATER_SIZE_THRESHOLD = 128 * 1024
3942

4043
HEATSHRINK_WINDOW_SIZE = 13
4144
HEATSHRINK_LOOKAHEAD_SIZE = 6
@@ -117,7 +120,7 @@ def generate(self):
117120
self.logger.error(
118121
f"You are trying to bundle a non-standard stack type '{self.args.radiotype}'."
119122
)
120-
self.disclaimer()
123+
self.show_disclaimer()
121124
return 1
122125

123126
if radio_addr == 0:
@@ -130,7 +133,9 @@ def generate(self):
130133
if not exists(self.args.directory):
131134
os.makedirs(self.args.directory)
132135

136+
updater_stage_size = os.stat(self.args.stage).st_size
133137
shutil.copyfile(self.args.stage, join(self.args.directory, stage_basename))
138+
134139
dfu_size = 0
135140
if self.args.dfu:
136141
dfu_size = os.stat(self.args.dfu).st_size
@@ -146,10 +151,10 @@ def generate(self):
146151
):
147152
return 3
148153

149-
if not self.layout_check(dfu_size, radio_addr):
154+
if not self.layout_check(updater_stage_size, dfu_size, radio_addr):
150155
self.logger.warn("Memory layout looks suspicious")
151-
if not self.args.disclaimer == "yes":
152-
self.disclaimer()
156+
if self.args.disclaimer != "yes":
157+
self.show_disclaimer()
153158
return 2
154159

155160
if self.args.splash:
@@ -198,22 +203,33 @@ def generate(self):
198203

199204
return 0
200205

201-
def layout_check(self, fw_size, radio_addr):
206+
def layout_check(self, stage_size, fw_size, radio_addr):
207+
if stage_size > self.UPDATER_SIZE_THRESHOLD:
208+
self.logger.warn(
209+
f"Updater size {stage_size}b > {self.UPDATER_SIZE_THRESHOLD}b and is not loadable on older firmwares!"
210+
)
211+
202212
if fw_size == 0 or radio_addr == 0:
203213
self.logger.info("Cannot validate layout for partial package")
204214
return True
205215

206-
lfs_span = radio_addr - self.FLASH_BASE - fw_size
207-
self.logger.debug(f"Expected LFS size: {lfs_span}")
208-
lfs_span_pages = lfs_span / (4 * 1024)
209-
if lfs_span_pages < self.MIN_LFS_PAGES:
216+
fw2stack_gap = radio_addr - self.FLASH_BASE - fw_size
217+
self.logger.debug(f"Expected reserved space size: {fw2stack_gap}")
218+
fw2stack_gap_pages = fw2stack_gap / self.FLASH_PAGE_SIZE
219+
if fw2stack_gap_pages < 0:
220+
self.logger.warn(
221+
f"Firmware image overlaps C2 region and is not programmable!"
222+
)
223+
return False
224+
225+
elif fw2stack_gap_pages < self.MIN_GAP_PAGES:
210226
self.logger.warn(
211-
f"Expected LFS size is too small (~{int(lfs_span_pages)} pages)"
227+
f"Expected reserved flash size is too small (~{int(fw2stack_gap_pages)} page(s), need >={self.MIN_GAP_PAGES} page(s))"
212228
)
213229
return False
214230
return True
215231

216-
def disclaimer(self):
232+
def show_disclaimer(self):
217233
self.logger.error(
218234
"You might brick your device into a state in which you'd need an SWD programmer to fix it."
219235
)

0 commit comments

Comments
 (0)