Skip to content

Commit

Permalink
Latest RM0701-1758-0.103.2-35a1752 on PATREON & GitHub - CLEANUP
Browse files Browse the repository at this point in the history
  • Loading branch information
RogueMaster committed Jul 2, 2024
1 parent e35d078 commit ae81452
Show file tree
Hide file tree
Showing 17 changed files with 132 additions and 66 deletions.
1 change: 1 addition & 0 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ This software is for experimental purposes only and is not meant for any illegal
- [Other small tweaks for Bad KB improvement (By Willy-JL)](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/commit/fad0872759b50032fa2a0214d5e1a6fc4f18de3c)
- [BadKB replaces BadUSB on Main Menu (By RogueMaster)](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/commit/fad0872759b50032fa2a0214d5e1a6fc4f18de3c)
- Updated: [FindMy Flipper v3.5 (By MatthewKuKanich)](https://github.com/MatthewKuKanich/FindMyFlipper)
- [FBT: New SKIP_EXTERNAL option & Can set EXTRA_EXT_APPS from config, not only CLI & Improve unit tests QOL & CleanUp (By Willy-JL)](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/commit/)

<a name="release">

Expand Down
4 changes: 2 additions & 2 deletions applications/debug/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ App(
"vibro_test",
"keypad_test",
"usb_test",
"USB_Mouse",
"UART_Echo",
"usb_mouse",
"uart_echo",
"display_test",
"text_box_test",
"file_browser_test",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ Filetype: Flipper SubGhz Key File
Version: 1
Frequency: 433920000
Preset: FuriHalSubGhzPresetOok650Async
Latitute: 0.000000
Longitude: 0.000000
Protocol: Legrand
Bit: 18
Key: 00 00 00 00 00 02 E3 7F
Expand Down

Large diffs are not rendered by default.

56 changes: 52 additions & 4 deletions applications/debug/unit_tests/test_runner.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <toolbox/path.h>
#include <loader/loader.h>
#include <storage/storage.h>
#include <dialogs/dialogs.h>
#include <notification/notification_messages.h>

#include <loader/firmware_api/firmware_api.h>
Expand Down Expand Up @@ -36,6 +37,9 @@ struct TestRunner {
int minunit_assert;
int minunit_fail;
int minunit_status;

// Summary
size_t total_failed;
};

TestRunner* test_runner_alloc(Cli* cli, FuriString* args) {
Expand Down Expand Up @@ -115,6 +119,8 @@ static bool test_runner_run_plugin(TestRunner* instance, const char* path) {
instance->minunit_status += test->get_minunit_status();

result = (instance->minunit_fail == 0);

instance->total_failed += instance->minunit_fail;
} while(false);

flipper_application_free(lib);
Expand Down Expand Up @@ -147,7 +153,7 @@ static void test_runner_run_internal(TestRunner* instance) {
}

while(true) {
if(cli_cmd_interrupt_received(instance->cli)) {
if(instance->cli && cli_cmd_interrupt_received(instance->cli)) {
break;
}

Expand Down Expand Up @@ -178,7 +184,23 @@ static void test_runner_run_internal(TestRunner* instance) {

if(!result) {
printf("Failed to execute test: %s\r\n", file_basename_cstr);
break;

if(!instance->cli) {
notification_message(instance->notification, &sequence_error);

DialogsApp* dialogs = furi_record_open(RECORD_DIALOGS);
DialogMessage* message = dialog_message_alloc();
dialog_message_set_header(
message, "Failed Test:", 64, 30, AlignCenter, AlignBottom);
dialog_message_set_text(
message, file_basename_cstr, 64, 34, AlignCenter, AlignTop);
dialog_message_show(dialogs, message);
dialog_message_free(message);
furi_record_close(RECORD_DIALOGS);

notification_message_block(
instance->notification, &sequence_set_only_blue_255);
}
}
}
} while(false);
Expand All @@ -205,7 +227,7 @@ void test_runner_run(TestRunner* instance) {
test_runner_run_internal(instance);

if(instance->minunit_run != 0) {
printf("\r\nFailed tests: %d\r\n", instance->minunit_fail);
printf("\r\nFailed tests: %d\r\n", instance->total_failed);

// Time report
cycle_counter = (furi_get_tick() - cycle_counter);
Expand All @@ -217,13 +239,39 @@ void test_runner_run(TestRunner* instance) {
printf("Leaked: %ld\r\n", heap_before - heap_after);

// Final Report
if(instance->minunit_fail == 0) {
if(instance->total_failed == 0) {
notification_message(instance->notification, &sequence_success);
printf("Status: PASSED\r\n");
} else {
notification_message(instance->notification, &sequence_error);
printf("Status: FAILED\r\n");
}

if(!instance->cli) {
char text[70];
snprintf(
text,
sizeof(text),
"Failed tests: %d\n"
"Consumed: %lu ms\n"
"Leaked: %ld",
instance->total_failed,
cycle_counter,
heap_before - heap_after);
DialogsApp* dialogs = furi_record_open(RECORD_DIALOGS);
DialogMessage* message = dialog_message_alloc();
dialog_message_set_header(
message,
instance->total_failed == 0 ? "PASSED" : "FAILED",
64,
8,
AlignCenter,
AlignTop);
dialog_message_set_text(message, text, 64, 38, AlignCenter, AlignCenter);
dialog_message_show(dialogs, message);
dialog_message_free(message);
furi_record_close(RECORD_DIALOGS);
}
}
}
}
24 changes: 24 additions & 0 deletions applications/debug/unit_tests/unit_tests.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <furi.h>
#include <furi_hal.h>
#include <cli/cli.h>

#include "test_runner.h"
Expand All @@ -12,10 +13,33 @@ void unit_tests_cli(Cli* cli, FuriString* args, void* context) {
test_runner_free(test_runner);
}

static void unit_tests_pending(void* context, uint32_t arg) {
UNUSED(arg);
FuriThread* thread = context;
furi_thread_join(thread);
furi_thread_free(thread);
}

static int32_t unit_tests_thread(void* context) {
furi_delay_ms(5000);
FuriString* args = furi_string_alloc();
TestRunner* test_runner = test_runner_alloc(NULL, args);
test_runner_run(test_runner);
test_runner_free(test_runner);
furi_string_free(args);
furi_timer_pending_callback(unit_tests_pending, context, 0);
return 0;
}

void unit_tests_on_system_start(void) {
#ifdef SRV_CLI
Cli* cli = furi_record_open(RECORD_CLI);
cli_add_command(cli, "unit_tests", CliCommandFlagParallelSafe, unit_tests_cli, NULL);
furi_record_close(RECORD_CLI);
#endif
if(furi_hal_is_normal_boot()) {
FuriThread* thread = furi_thread_alloc_ex("UnitTests", 4 * 1024, unit_tests_thread, NULL);
furi_thread_set_context(thread, thread);
furi_thread_start(thread);
}
}
2 changes: 2 additions & 0 deletions applications/drivers/subghz/cc1101_ext/cc1101_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include <cc1101.h>
#include <stdio.h>

#include <cfw/cfw.h>

#define TAG "SubGhzDeviceCc1101Ext"

#define SUBGHZ_DEVICE_CC1101_EXT_TX_GPIO (&gpio_ext_pb2)
Expand Down
1 change: 0 additions & 1 deletion applications/drivers/subghz/cc1101_ext/cc1101_ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <stddef.h>
#include <toolbox/level_duration.h>
#include <furi_hal_gpio.h>
#include <cfw/cfw.h>

#ifdef __cplusplus
extern "C" {
Expand Down
17 changes: 17 additions & 0 deletions fbt_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
# If OS environment has DIST_SUFFIX set, it will be used instead
DIST_SUFFIX = "RM420FAP"

# Skip external apps by default
SKIP_EXTERNAL = False

# Appid's to include even when skipping externals
EXTRA_EXT_APPS = []

# Coprocessor firmware
COPRO_OB_DATA = "scripts/ob.data"

Expand Down Expand Up @@ -71,6 +77,17 @@
"settings_apps",
],
"unit_tests": [
# Svc
"basic_services",
# Apps
"main_apps",
"system_apps",
# Settings
"settings_apps",
# Tests
"unit_tests",
],
"unit_tests_min": [
"basic_services",
"updater_app",
"radio_device_cc1101_ext",
Expand Down
7 changes: 6 additions & 1 deletion firmware.scons
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ env = ENV.Clone(
FW_API_TABLE=None,
_APP_ICONS=None,
APPS=_.split(",") if (_ := GetOption("extra_int_apps")) else [],
EXTRA_EXT_APPS=_.split(",") if (_ := GetOption("extra_ext_apps")) else [],
EXTRA_EXT_APPS=_.split(",")
if (_ := GetOption("extra_ext_apps"))
else ENV["EXTRA_EXT_APPS"],
)

env.PreConfigureFwEnvionment()
Expand All @@ -102,6 +104,9 @@ else:
)
env.AppendUnique(CPPDEFINES=["FW_CFG_${FIRMWARE_APP_SET}"])

if env.subst("$FIRMWARE_APP_SET").startswith("unit_tests"):
env.Replace(SKIP_EXTERNAL=True)

env.ConfigureForTarget(env.subst("${TARGET_HW}"))

Export("env")
Expand Down
15 changes: 13 additions & 2 deletions scripts/fbt/appmanifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,14 @@ def filter_apps(
applist: List[str],
ext_applist: List[str],
hw_target: str,
skip_external: bool = False,
):
return AppBuildset(
self,
hw_target=hw_target,
appnames=applist,
extra_ext_appnames=ext_applist,
skip_external=skip_external,
)


Expand Down Expand Up @@ -284,12 +286,14 @@ def __init__(
appnames: List[str],
*,
extra_ext_appnames: List[str],
skip_external: bool = False,
message_writer: Callable | None = None,
):
self.appmgr = appmgr
self.appnames = set(appnames)
self.incompatible_extapps, self.extapps = [], []
self._extra_ext_appnames = extra_ext_appnames
self._skip_external = skip_external
self._orig_appnames = appnames
self.hw_target = hw_target
self._writer = message_writer if message_writer else self.print_writer
Expand Down Expand Up @@ -345,7 +349,11 @@ def _process_ext_apps(self):
extapps = [
app
for (apptype, global_lookup) in self.EXTERNAL_APP_TYPES_MAP.items()
for app in self.get_apps_of_type(apptype, global_lookup)
for app in self.get_apps_of_type(
apptype,
global_lookup
and not (self._skip_external and apptype is FlipperAppType.EXTERNAL),
)
]
extapps.extend(map(self.appmgr.get, self._extra_ext_appnames))

Expand Down Expand Up @@ -414,7 +422,10 @@ def _group_plugins(self):
if (
parent_app.apptype in self.BUILTIN_APP_TYPES
and parent_app_id in self.appnames
) or parent_app.apptype not in self.BUILTIN_APP_TYPES:
) or (
parent_app.apptype not in self.BUILTIN_APP_TYPES
and parent_app in self.extapps
):
keep_app |= True

except FlipperManifestException:
Expand Down
1 change: 1 addition & 0 deletions scripts/fbt_tools/fbt_apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ def PrepareApplicationsBuild(env):
applist=env["APPS"],
ext_applist=env["EXTRA_EXT_APPS"],
hw_target=env.subst("f${TARGET_HW}"),
skip_external=env.subst("$SKIP_EXTERNAL"),
)
except Exception as e:
raise StopError(e)
Expand Down
10 changes: 10 additions & 0 deletions site_scons/commandline.scons
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,16 @@ vars.AddVariables(
"Application set to use from FIRMWARE_APPS",
"default",
),
BoolVariable(
"SKIP_EXTERNAL",
help="Skip external apps unless explicitly selected",
default=False,
),
(
"EXTRA_EXT_APPS",
"List of appids to include regardless of other configuration",
[],
),
(
"APPSRC",
"Application source directory for app to build & upload",
Expand Down
3 changes: 1 addition & 2 deletions targets/f7/api_symbols.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
entry,status,name,type,params
Version,+,67.0,,
Version,+,68.0,,
Header,+,applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h,,
Header,+,applications/main/archive/helpers/archive_helpers_ext.h,,
Header,+,applications/main/subghz/subghz_fap.h,,
Expand Down Expand Up @@ -1744,7 +1744,6 @@ Function,+,furi_hal_switch,void,void*
Function,+,furi_hal_usb_disable,void,
Function,+,furi_hal_usb_enable,void,
Function,+,furi_hal_usb_get_config,FuriHalUsbInterface*,
Function,+,furi_hal_usb_get_config_context,void*,
Function,-,furi_hal_usb_init,void,
Function,+,furi_hal_usb_is_locked,_Bool,
Function,+,furi_hal_usb_lock,void,
Expand Down
2 changes: 1 addition & 1 deletion targets/f7/ble_glue/services/dev_info_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ BleServiceDevInfo* ble_svc_dev_info_start(void) {
sizeof(software_revision),
"%s %s %s %s",
version_get_githash(NULL),
version_get_version(NULL),
version_get_gitbranch(NULL),
version_get_gitbranchnum(NULL),
version_get_builddate(NULL));
snprintf(hardware_revision, sizeof(hardware_revision), "%d", version_get_target(NULL));
Expand Down
19 changes: 0 additions & 19 deletions targets/f7/furi_hal/furi_hal_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
typedef enum {
UsbApiEventTypeSetConfig,
UsbApiEventTypeGetConfig,
UsbApiEventTypeGetConfigContext,
UsbApiEventTypeLock,
UsbApiEventTypeUnlock,
UsbApiEventTypeIsLocked,
Expand Down Expand Up @@ -168,21 +167,6 @@ FuriHalUsbInterface* furi_hal_usb_get_config(void) {
return return_data.void_value;
}

void* furi_hal_usb_get_config_context(void) {
UsbApiEventReturnData return_data = {
.void_value = NULL,
};

UsbApiEventMessage msg = {
.lock = api_lock_alloc_locked(),
.type = UsbApiEventTypeGetConfigContext,
.return_data = &return_data,
};

furi_hal_usb_send_message(&msg);
return return_data.void_value;
}

void furi_hal_usb_lock(void) {
UsbApiEventMessage msg = {
.lock = api_lock_alloc_locked(),
Expand Down Expand Up @@ -426,9 +410,6 @@ static void usb_process_message(UsbApiEventMessage* message) {
case UsbApiEventTypeGetConfig:
message->return_data->void_value = usb.interface;
break;
case UsbApiEventTypeGetConfigContext:
message->return_data->void_value = usb.interface_context;
break;
case UsbApiEventTypeLock:
FURI_LOG_I(TAG, "Mode lock");
usb.mode_lock = true;
Expand Down
Loading

0 comments on commit ae81452

Please sign in to comment.