mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
Enable debug on flipper when attaching blackmagic --nobuild
This commit is contained in:
@@ -446,6 +446,37 @@ void cli_command_sysctl_heap_track(Cli* cli, FuriString* args, void* context) {
|
||||
}
|
||||
}
|
||||
|
||||
void cli_command_sysctl_sleep_mode(Cli* cli, FuriString* args, void* context) {
|
||||
UNUSED(cli);
|
||||
UNUSED(context);
|
||||
if(!furi_string_cmp(args, "default")) {
|
||||
furi_hal_rtc_reset_flag(FuriHalRtcFlagLegacySleep);
|
||||
printf("Deep sleep enabled");
|
||||
} else if(!furi_string_cmp(args, "legacy")) {
|
||||
furi_hal_rtc_set_flag(FuriHalRtcFlagLegacySleep);
|
||||
printf("Deep sleep disabled");
|
||||
} else {
|
||||
cli_print_usage("sysctl sleep_mode", "<default|legacy>", furi_string_get_cstr(args));
|
||||
}
|
||||
}
|
||||
|
||||
void cli_command_sysctl_log_level(Cli* cli, FuriString* args, void* context) {
|
||||
UNUSED(cli);
|
||||
UNUSED(context);
|
||||
FuriLogLevel log_level;
|
||||
if(!furi_log_level_from_string(furi_string_get_cstr(args), &log_level)) {
|
||||
cli_print_usage(
|
||||
"sysctl log_level",
|
||||
"<error|warn|info|default|debug|trace>",
|
||||
furi_string_get_cstr(args));
|
||||
return;
|
||||
}
|
||||
furi_hal_rtc_set_log_level(log_level);
|
||||
const char* log_level_str;
|
||||
furi_log_level_to_string(log_level, &log_level_str);
|
||||
printf("Set log level to %s", log_level_str);
|
||||
}
|
||||
|
||||
void cli_command_sysctl_print_usage(void) {
|
||||
printf("Usage:\r\n");
|
||||
printf("sysctl <cmd> <args>\r\n");
|
||||
@@ -457,6 +488,8 @@ void cli_command_sysctl_print_usage(void) {
|
||||
#else
|
||||
printf("\theap_track <none|main>\t - Set heap allocation tracking mode\r\n");
|
||||
#endif
|
||||
printf("\tsleep_mode <default|legacy>\t - Enable or disable deep sleep\r\n");
|
||||
printf("\tlog_level <error|warn|info|default|debug|trace>\t - Set system log level\r\n");
|
||||
}
|
||||
|
||||
void cli_command_sysctl(Cli* cli, FuriString* args, void* context) {
|
||||
@@ -479,6 +512,16 @@ void cli_command_sysctl(Cli* cli, FuriString* args, void* context) {
|
||||
break;
|
||||
}
|
||||
|
||||
if(furi_string_cmp_str(cmd, "sleep_mode") == 0) {
|
||||
cli_command_sysctl_sleep_mode(cli, args, context);
|
||||
break;
|
||||
}
|
||||
|
||||
if(furi_string_cmp_str(cmd, "log_level") == 0) {
|
||||
cli_command_sysctl_log_level(cli, args, context);
|
||||
break;
|
||||
}
|
||||
|
||||
cli_command_sysctl_print_usage();
|
||||
} while(false);
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
from SCons.Errors import StopError
|
||||
from flipper.storage import FlipperStorage
|
||||
import serial.tools.list_ports as list_ports
|
||||
|
||||
|
||||
class BlackmagicResolver:
|
||||
@@ -30,6 +32,18 @@ class BlackmagicResolver:
|
||||
# print("\n".join([f"{p.device} {vars(p)}" for p in ports]))
|
||||
return sorted(ports, key=lambda p: f"{p.location}_{p.name}")[0]
|
||||
|
||||
def _enable_flipper_debug(self):
|
||||
flippers = list(list_ports.grep("flip_"))
|
||||
if len(flippers) != 1:
|
||||
return
|
||||
with FlipperStorage(flippers[0].device) as storage:
|
||||
storage.send_and_wait_eol("sysctl debug 1\r")
|
||||
storage.read.until(storage.CLI_EOL)
|
||||
storage.send_and_wait_eol("sysctl sleep_mode legacy\r")
|
||||
storage.read.until(storage.CLI_EOL)
|
||||
storage.send_and_wait_eol("sysctl log_level debug\r")
|
||||
storage.read.until(storage.CLI_EOL)
|
||||
|
||||
# Look up blackmagic probe hostname with dns
|
||||
def _resolve_hostname(self):
|
||||
import socket
|
||||
@@ -43,6 +57,7 @@ class BlackmagicResolver:
|
||||
def get_serial(self):
|
||||
if not (probe := self._find_probe()):
|
||||
return None
|
||||
self._enable_flipper_debug()
|
||||
# print(f"Found Blackmagic probe on {probe.device}")
|
||||
if self.env.subst("$PLATFORM") == "win32":
|
||||
return f"\\\\.\\{probe.device}"
|
||||
|
||||
Reference in New Issue
Block a user