unleashed-firmware/scripts/dist.py
hedger 7ce305fca3
[FL-2269] Core2 OTA (#1144)
* C2OTA: wip
* Update Cube to 1.13.3
* Fixed prio
* Functional Core2 updater
* Removed hardware CRC usage; code cleanup & linter fixes
* Moved hardcoded stack params to copro.mk
* Fixing CI bundling of core2 fw
* Removed last traces of hardcoded radio stack
* OB processing draft
* Python scripts cleanup
* Support for comments in ob data
* Sacrificed SD card icon in favor of faster update. Waiting for Storage fix
* Additional handling for OB mismatched values
* Description for new furi_hal apis; spelling fixes
* Rework of OB write, WIP
* Properly restarting OB verification loop
* Split update_task_workers.c
* Checking OBs after enabling post-update mode
* Moved OB verification before flashing
* Removed ob.data for custom stacks
* Fixed progress calculation for OB
* Removed unnecessary OB mask cast

Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2022-04-27 18:53:48 +03:00

104 lines
3.5 KiB
Python
Executable file

#!/usr/bin/env python3
from flipper.app import App
from os.path import join, exists
from os import makedirs
from update import Main as UpdateMain
import shutil
class Main(App):
def init(self):
self.subparsers = self.parser.add_subparsers(help="sub-command help")
self.parser_copy = self.subparsers.add_parser(
"copy", help="Copy firmware binaries & metadata"
)
self.parser_copy.add_argument("-t", dest="target", required=True)
self.parser_copy.add_argument("-p", dest="projects", nargs="+", required=True)
self.parser_copy.add_argument("-s", dest="suffix", required=True)
self.parser_copy.add_argument("-r", dest="resources", required=False)
self.parser_copy.add_argument(
"--bundlever",
dest="version",
help="If set, bundle update package for self-update",
required=False,
)
self.parser_copy.add_argument(
"--noclean",
dest="noclean",
action="store_true",
help="Don't clean output directory",
required=False,
)
self.parser_copy.set_defaults(func=self.copy)
def get_project_filename(self, project, filetype):
# Temporary fix
if project == "firmware" and filetype != "elf":
project = "full"
return f"flipper-z-{self.args.target}-{project}-{self.args.suffix}.{filetype}"
def get_dist_filepath(self, filename):
return join(self.output_dir_path, filename)
def copy_single_project(self, project):
target_project = f"{self.args.target}-{project}"
obj_directory = join("firmware", ".obj", target_project)
for filetype in ("elf", "bin", "dfu", "json"):
shutil.copyfile(
join(obj_directory, f"{project}.{filetype}"),
self.get_dist_filepath(self.get_project_filename(project, filetype)),
)
def copy(self):
self.output_dir_path = join("dist", self.args.target)
if exists(self.output_dir_path) and not self.args.noclean:
shutil.rmtree(self.output_dir_path)
if not exists(self.output_dir_path):
makedirs(self.output_dir_path)
for project in self.args.projects:
self.copy_single_project(project)
self.logger.info(
f"Firmware binaries can be found at:\n\t{self.output_dir_path}"
)
if self.args.version:
bundle_dir = join(
self.output_dir_path, f"{self.args.target}-update-{self.args.suffix}"
)
bundle_args = [
"generate",
"-d",
bundle_dir,
"-v",
self.args.version,
"-t",
self.args.target,
"--dfu",
self.get_dist_filepath(self.get_project_filename("firmware", "dfu")),
"--stage",
self.get_dist_filepath(self.get_project_filename("updater", "bin")),
]
if self.args.resources:
bundle_args.extend(
(
"-r",
self.args.resources,
)
)
bundle_args.extend(self.other_args)
self.logger.info(
f"Use this directory to self-update your Flipper:\n\t{bundle_dir}"
)
return UpdateMain(no_exit=True)(bundle_args)
return 0
if __name__ == "__main__":
Main()()