Splitting units and updater benches (#2165)
* test run, moved updated to separate physical runner/flipper/card
* simplified units, removed re-flashing, moved format to beginning of run
* added reboot requence and mini optimizations
* forgot gitadd, added script modifications, workflow changes
* fixed linter issues
* moved updater to unit bench for speed up
* changes to units, flash (not full) on second update, new fbt GDB thread check
* changed serial of second device
* testing pipelines, added failing unit test
* fixed gdb step
* fixed gdb step v2 electric boogaloo
* fixed gdb step v3, fixed target
* reverted while1 in units, tests complete
* testing colored output
* trying different term setting
* debug outputs for terminal
* fixed typo in SConstruct and another terminal test
* reverted changes, no colored output, for production
* fixed log output to readable format
* fixed linter
Co-authored-by: Konstantin Volkov <k.volkov@flipperdevices.com>
Co-authored-by: あく <alleteam@gmail.com>
2022-12-28 14:16:06 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
2023-08-23 12:51:02 +00:00
|
|
|
import time
|
|
|
|
from typing import Optional
|
|
|
|
|
Splitting units and updater benches (#2165)
* test run, moved updated to separate physical runner/flipper/card
* simplified units, removed re-flashing, moved format to beginning of run
* added reboot requence and mini optimizations
* forgot gitadd, added script modifications, workflow changes
* fixed linter issues
* moved updater to unit bench for speed up
* changes to units, flash (not full) on second update, new fbt GDB thread check
* changed serial of second device
* testing pipelines, added failing unit test
* fixed gdb step
* fixed gdb step v2 electric boogaloo
* fixed gdb step v3, fixed target
* reverted while1 in units, tests complete
* testing colored output
* trying different term setting
* debug outputs for terminal
* fixed typo in SConstruct and another terminal test
* reverted changes, no colored output, for production
* fixed log output to readable format
* fixed linter
Co-authored-by: Konstantin Volkov <k.volkov@flipperdevices.com>
Co-authored-by: あく <alleteam@gmail.com>
2022-12-28 14:16:06 +00:00
|
|
|
from flipper.app import App
|
|
|
|
from flipper.storage import FlipperStorage
|
|
|
|
from flipper.utils.cdc import resolve_port
|
|
|
|
|
|
|
|
|
|
|
|
class Main(App):
|
|
|
|
# this is basic use without sub-commands, simply to reboot flipper / power it off, not meant as a full CLI wrapper
|
|
|
|
def init(self):
|
|
|
|
self.parser.add_argument("-p", "--port", help="CDC Port", default="auto")
|
|
|
|
|
|
|
|
self.subparsers = self.parser.add_subparsers(help="sub-command help")
|
|
|
|
|
|
|
|
self.parser_power_off = self.subparsers.add_parser(
|
|
|
|
"power_off", help="Power off command, won't return to CLI"
|
|
|
|
)
|
|
|
|
self.parser_power_off.set_defaults(func=self.power_off)
|
|
|
|
|
|
|
|
self.parser_reboot = self.subparsers.add_parser(
|
|
|
|
"reboot", help="Reboot command help"
|
|
|
|
)
|
|
|
|
self.parser_reboot.set_defaults(func=self.reboot)
|
|
|
|
|
|
|
|
self.parser_reboot2dfu = self.subparsers.add_parser(
|
|
|
|
"reboot2dfu", help="Reboot to DFU, won't return to CLI"
|
|
|
|
)
|
|
|
|
self.parser_reboot2dfu.set_defaults(func=self.reboot2dfu)
|
|
|
|
|
2023-08-23 12:51:02 +00:00
|
|
|
def _get_flipper(self, retry_count: Optional[int] = 1):
|
|
|
|
port = None
|
|
|
|
self.logger.info(f"Attempting to find flipper with {retry_count} attempts.")
|
|
|
|
|
|
|
|
for i in range(retry_count):
|
|
|
|
time.sleep(1)
|
|
|
|
self.logger.info(f"Attempting to find flipper #{i}.")
|
|
|
|
|
|
|
|
if port := resolve_port(self.logger, self.args.port):
|
|
|
|
self.logger.info(f"Found flipper at {port}")
|
|
|
|
break
|
|
|
|
|
|
|
|
if not port:
|
|
|
|
self.logger.info(f"Failed to find flipper")
|
Splitting units and updater benches (#2165)
* test run, moved updated to separate physical runner/flipper/card
* simplified units, removed re-flashing, moved format to beginning of run
* added reboot requence and mini optimizations
* forgot gitadd, added script modifications, workflow changes
* fixed linter issues
* moved updater to unit bench for speed up
* changes to units, flash (not full) on second update, new fbt GDB thread check
* changed serial of second device
* testing pipelines, added failing unit test
* fixed gdb step
* fixed gdb step v2 electric boogaloo
* fixed gdb step v3, fixed target
* reverted while1 in units, tests complete
* testing colored output
* trying different term setting
* debug outputs for terminal
* fixed typo in SConstruct and another terminal test
* reverted changes, no colored output, for production
* fixed log output to readable format
* fixed linter
Co-authored-by: Konstantin Volkov <k.volkov@flipperdevices.com>
Co-authored-by: あく <alleteam@gmail.com>
2022-12-28 14:16:06 +00:00
|
|
|
return None
|
|
|
|
|
|
|
|
flipper = FlipperStorage(port)
|
|
|
|
flipper.start()
|
|
|
|
return flipper
|
|
|
|
|
|
|
|
def power_off(self):
|
2023-08-23 12:51:02 +00:00
|
|
|
if not (flipper := self._get_flipper(retry_count=10)):
|
Splitting units and updater benches (#2165)
* test run, moved updated to separate physical runner/flipper/card
* simplified units, removed re-flashing, moved format to beginning of run
* added reboot requence and mini optimizations
* forgot gitadd, added script modifications, workflow changes
* fixed linter issues
* moved updater to unit bench for speed up
* changes to units, flash (not full) on second update, new fbt GDB thread check
* changed serial of second device
* testing pipelines, added failing unit test
* fixed gdb step
* fixed gdb step v2 electric boogaloo
* fixed gdb step v3, fixed target
* reverted while1 in units, tests complete
* testing colored output
* trying different term setting
* debug outputs for terminal
* fixed typo in SConstruct and another terminal test
* reverted changes, no colored output, for production
* fixed log output to readable format
* fixed linter
Co-authored-by: Konstantin Volkov <k.volkov@flipperdevices.com>
Co-authored-by: あく <alleteam@gmail.com>
2022-12-28 14:16:06 +00:00
|
|
|
return 1
|
|
|
|
|
2023-08-23 12:51:02 +00:00
|
|
|
self.logger.info("Powering off")
|
Splitting units and updater benches (#2165)
* test run, moved updated to separate physical runner/flipper/card
* simplified units, removed re-flashing, moved format to beginning of run
* added reboot requence and mini optimizations
* forgot gitadd, added script modifications, workflow changes
* fixed linter issues
* moved updater to unit bench for speed up
* changes to units, flash (not full) on second update, new fbt GDB thread check
* changed serial of second device
* testing pipelines, added failing unit test
* fixed gdb step
* fixed gdb step v2 electric boogaloo
* fixed gdb step v3, fixed target
* reverted while1 in units, tests complete
* testing colored output
* trying different term setting
* debug outputs for terminal
* fixed typo in SConstruct and another terminal test
* reverted changes, no colored output, for production
* fixed log output to readable format
* fixed linter
Co-authored-by: Konstantin Volkov <k.volkov@flipperdevices.com>
Co-authored-by: あく <alleteam@gmail.com>
2022-12-28 14:16:06 +00:00
|
|
|
flipper.send("power off" + "\r")
|
|
|
|
flipper.stop()
|
|
|
|
return 0
|
|
|
|
|
|
|
|
def reboot(self):
|
2023-08-23 12:51:02 +00:00
|
|
|
if not (flipper := self._get_flipper(retry_count=10)):
|
Splitting units and updater benches (#2165)
* test run, moved updated to separate physical runner/flipper/card
* simplified units, removed re-flashing, moved format to beginning of run
* added reboot requence and mini optimizations
* forgot gitadd, added script modifications, workflow changes
* fixed linter issues
* moved updater to unit bench for speed up
* changes to units, flash (not full) on second update, new fbt GDB thread check
* changed serial of second device
* testing pipelines, added failing unit test
* fixed gdb step
* fixed gdb step v2 electric boogaloo
* fixed gdb step v3, fixed target
* reverted while1 in units, tests complete
* testing colored output
* trying different term setting
* debug outputs for terminal
* fixed typo in SConstruct and another terminal test
* reverted changes, no colored output, for production
* fixed log output to readable format
* fixed linter
Co-authored-by: Konstantin Volkov <k.volkov@flipperdevices.com>
Co-authored-by: あく <alleteam@gmail.com>
2022-12-28 14:16:06 +00:00
|
|
|
return 1
|
|
|
|
|
2023-08-23 12:51:02 +00:00
|
|
|
self.logger.info("Rebooting")
|
Splitting units and updater benches (#2165)
* test run, moved updated to separate physical runner/flipper/card
* simplified units, removed re-flashing, moved format to beginning of run
* added reboot requence and mini optimizations
* forgot gitadd, added script modifications, workflow changes
* fixed linter issues
* moved updater to unit bench for speed up
* changes to units, flash (not full) on second update, new fbt GDB thread check
* changed serial of second device
* testing pipelines, added failing unit test
* fixed gdb step
* fixed gdb step v2 electric boogaloo
* fixed gdb step v3, fixed target
* reverted while1 in units, tests complete
* testing colored output
* trying different term setting
* debug outputs for terminal
* fixed typo in SConstruct and another terminal test
* reverted changes, no colored output, for production
* fixed log output to readable format
* fixed linter
Co-authored-by: Konstantin Volkov <k.volkov@flipperdevices.com>
Co-authored-by: あく <alleteam@gmail.com>
2022-12-28 14:16:06 +00:00
|
|
|
flipper.send("power reboot" + "\r")
|
|
|
|
flipper.stop()
|
|
|
|
return 0
|
|
|
|
|
|
|
|
def reboot2dfu(self):
|
2023-08-23 12:51:02 +00:00
|
|
|
if not (flipper := self._get_flipper(retry_count=10)):
|
Splitting units and updater benches (#2165)
* test run, moved updated to separate physical runner/flipper/card
* simplified units, removed re-flashing, moved format to beginning of run
* added reboot requence and mini optimizations
* forgot gitadd, added script modifications, workflow changes
* fixed linter issues
* moved updater to unit bench for speed up
* changes to units, flash (not full) on second update, new fbt GDB thread check
* changed serial of second device
* testing pipelines, added failing unit test
* fixed gdb step
* fixed gdb step v2 electric boogaloo
* fixed gdb step v3, fixed target
* reverted while1 in units, tests complete
* testing colored output
* trying different term setting
* debug outputs for terminal
* fixed typo in SConstruct and another terminal test
* reverted changes, no colored output, for production
* fixed log output to readable format
* fixed linter
Co-authored-by: Konstantin Volkov <k.volkov@flipperdevices.com>
Co-authored-by: あく <alleteam@gmail.com>
2022-12-28 14:16:06 +00:00
|
|
|
return 1
|
|
|
|
|
2023-08-23 12:51:02 +00:00
|
|
|
self.logger.info("Rebooting to DFU")
|
Splitting units and updater benches (#2165)
* test run, moved updated to separate physical runner/flipper/card
* simplified units, removed re-flashing, moved format to beginning of run
* added reboot requence and mini optimizations
* forgot gitadd, added script modifications, workflow changes
* fixed linter issues
* moved updater to unit bench for speed up
* changes to units, flash (not full) on second update, new fbt GDB thread check
* changed serial of second device
* testing pipelines, added failing unit test
* fixed gdb step
* fixed gdb step v2 electric boogaloo
* fixed gdb step v3, fixed target
* reverted while1 in units, tests complete
* testing colored output
* trying different term setting
* debug outputs for terminal
* fixed typo in SConstruct and another terminal test
* reverted changes, no colored output, for production
* fixed log output to readable format
* fixed linter
Co-authored-by: Konstantin Volkov <k.volkov@flipperdevices.com>
Co-authored-by: あく <alleteam@gmail.com>
2022-12-28 14:16:06 +00:00
|
|
|
flipper.send("power reboot2dfu" + "\r")
|
|
|
|
flipper.stop()
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
Main()()
|