* ufbt: added "dolphin_ext" target (expects "external" subfolder in cwd with dolphin assets); cleaned up unused code * ufbt: codestyle fixes * scripts: fixed style according to ruff linter * scripts: additional cleanup & codestyle fixes * github: pass target hw code when installing local SDK with ufbt * ufbt: added error message for missing folder in dolphin builder * scripts: more linter fixes * sdk: added flipper_format_stream; ufbt: support for --extra-define * fbt: reduced amount of global defines * scripts, fbt: rearranged imports Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
		
			
				
	
	
		
			81 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			81 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
	
	
#!/usr/bin/env python3
 | 
						|
 | 
						|
from os import path
 | 
						|
 | 
						|
from flipper.app import App
 | 
						|
from flipper.utils.programmer_openocd import OpenOCDProgrammer
 | 
						|
 | 
						|
 | 
						|
class Main(App):
 | 
						|
    def init(self):
 | 
						|
        # Subparsers
 | 
						|
        self.subparsers = self.parser.add_subparsers(help="sub-command help")
 | 
						|
 | 
						|
        # Check command
 | 
						|
        self.parser_check = self.subparsers.add_parser(
 | 
						|
            "check", help="Check Option Bytes"
 | 
						|
        )
 | 
						|
        self._add_args(self.parser_check)
 | 
						|
        self.parser_check.set_defaults(func=self.check)
 | 
						|
 | 
						|
        # Set command
 | 
						|
        self.parser_set = self.subparsers.add_parser("set", help="Set Option Bytes")
 | 
						|
        self._add_args(self.parser_set)
 | 
						|
        self.parser_set.set_defaults(func=self.set)
 | 
						|
 | 
						|
    def _add_args(self, parser):
 | 
						|
        parser.add_argument(
 | 
						|
            "--port-base", type=int, help="OpenOCD port base", default=3333
 | 
						|
        )
 | 
						|
        parser.add_argument(
 | 
						|
            "--interface",
 | 
						|
            type=str,
 | 
						|
            help="OpenOCD interface",
 | 
						|
            default="interface/cmsis-dap.cfg",
 | 
						|
        )
 | 
						|
        parser.add_argument(
 | 
						|
            "--serial", type=str, help="OpenOCD interface serial number"
 | 
						|
        )
 | 
						|
        parser.add_argument(
 | 
						|
            "--ob-path",
 | 
						|
            type=str,
 | 
						|
            help="Option bytes file",
 | 
						|
            default=path.join(path.dirname(__file__), "ob.data"),
 | 
						|
        )
 | 
						|
 | 
						|
    def check(self):
 | 
						|
        self.logger.info("Checking Option Bytes")
 | 
						|
 | 
						|
        # OpenOCD
 | 
						|
        openocd = OpenOCDProgrammer(
 | 
						|
            self.args.interface,
 | 
						|
            self.args.port_base,
 | 
						|
            self.args.serial,
 | 
						|
        )
 | 
						|
 | 
						|
        return_code = 1
 | 
						|
        if openocd.option_bytes_validate(self.args.ob_path):
 | 
						|
            return_code = 0
 | 
						|
 | 
						|
        return return_code
 | 
						|
 | 
						|
    def set(self):
 | 
						|
        self.logger.info("Setting Option Bytes")
 | 
						|
 | 
						|
        # OpenOCD
 | 
						|
        openocd = OpenOCDProgrammer(
 | 
						|
            self.args.interface,
 | 
						|
            self.args.port_base,
 | 
						|
            self.args.serial,
 | 
						|
        )
 | 
						|
 | 
						|
        return_code = 1
 | 
						|
        if openocd.option_bytes_set(self.args.ob_path):
 | 
						|
            return_code = 0
 | 
						|
 | 
						|
        return return_code
 | 
						|
 | 
						|
 | 
						|
if __name__ == "__main__":
 | 
						|
    Main()()
 |