mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2025-10-03 18:05:50 +02:00
Fix attaching debugger while paused
This commit is contained in:
@@ -433,7 +433,13 @@ distenv.PhonyTarget(
|
||||
# Find blackmagic probe
|
||||
distenv.PhonyTarget(
|
||||
"get_blackmagic",
|
||||
"@echo $( ${BLACKMAGIC_ADDR} $)",
|
||||
[
|
||||
[
|
||||
"${PYTHON3}",
|
||||
"${FBT_SCRIPT_DIR}/enable_debug.py",
|
||||
],
|
||||
"@echo $( ${BLACKMAGIC_ADDR} $)",
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
|
36
scripts/enable_debug.py
Normal file
36
scripts/enable_debug.py
Normal file
@@ -0,0 +1,36 @@
|
||||
import serial.tools.list_ports as list_ports
|
||||
import serial
|
||||
|
||||
|
||||
def main():
|
||||
try:
|
||||
flippers = list(list_ports.grep("flip_"))
|
||||
if len(flippers) != 1:
|
||||
return
|
||||
|
||||
port = serial.Serial()
|
||||
port.port = flippers[0].device
|
||||
port.timeout = 0.1
|
||||
port.write_timeout = 0.1
|
||||
port.baudrate = 115200 # Doesn't matter for VCP
|
||||
port.open()
|
||||
except Exception:
|
||||
return
|
||||
|
||||
try:
|
||||
port.write(
|
||||
b"sysctl debug 1\r"
|
||||
b"sysctl sleep_mode legacy\r"
|
||||
b"sysctl log_level debug\r"
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
finally:
|
||||
try:
|
||||
port.close()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
@@ -1,6 +1,4 @@
|
||||
from SCons.Errors import StopError
|
||||
from flipper.storage import FlipperStorage
|
||||
import serial.tools.list_ports as list_ports
|
||||
|
||||
|
||||
class BlackmagicResolver:
|
||||
@@ -32,18 +30,6 @@ 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
|
||||
@@ -57,7 +43,6 @@ 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