From: Robin Krens Date: Tue, 19 Mar 2024 22:59:36 +0000 (+0100) Subject: RAFlasher: add SCI (UART) method X-Git-Url: https://robinkrens.nl/gitweb/?a=commitdiff_plain;p=renesas-ra-flasher RAFlasher: add SCI (UART) method --- diff --git a/raflash/RAConnect.py b/raflash/RAConnect.py index d2f47bf..44bc50b 100644 --- a/raflash/RAConnect.py +++ b/raflash/RAConnect.py @@ -25,7 +25,7 @@ MAX_TRANSFER_SIZE = 2048 + 6 # include header and footer class RAConnect: - def __init__(self, vendor_id, product_id): + def __init__(self, vendor_id, product_id, port=None): self.vendor_id = vendor_id self.product_id = product_id self.max_tries = 20 @@ -34,7 +34,7 @@ class RAConnect: self.chip_layout = [] self.sel_area = 0 # default to Area 0 - self.find_device() + self.find_device(port) status_conn = self.inquire_connection() if not status_conn: self.confirm_connection() @@ -47,8 +47,9 @@ class RAConnect: return None - def find_device(self): - port = self.find_port() + def find_device(self, port): + if port is None: + port = self.find_port() try: self.dev = serial.Serial(port, 9600) except Exception as err: diff --git a/raflash/RAFlasher.py b/raflash/RAFlasher.py index 077b976..f7f4190 100644 --- a/raflash/RAFlasher.py +++ b/raflash/RAFlasher.py @@ -207,22 +207,26 @@ def main(): write_parser.add_argument("--start_address", type=hex_type, default='0x0000', help="Start address") write_parser.add_argument("--size", type=hex_type, default=None, help="Size in bytes") write_parser.add_argument("--verify", action="store_true", help="Verify after writing") + write_parser.add_argument("--port", type=str, default=None, help="Port location") write_parser.add_argument("file_name", type=str, help="File name") read_parser = subparsers.add_parser("read", help="Read data from flash") read_parser.add_argument("--start_address", type=hex_type, default='0x0000', help="Start address") read_parser.add_argument("--size", type=hex_type, default=None, help="Size in bytes") + read_parser.add_argument("--port", type=str, default=None, help="Port location") read_parser.add_argument("file_name", type=str, help="File name") erase_parser = subparsers.add_parser("erase", help="Erase sectors") erase_parser.add_argument("--start_address", default='0x0000', type=hex_type, help="Start address") erase_parser.add_argument("--size", type=hex_type, help="Size") + erase_parser.add_argument("--port", type=str, default=None, help="Port location") - subparsers.add_parser("info", help="Show flasher information") + info_parser = subparsers.add_parser("info", help="Show flasher information") + info_parser.add_argument("--port", type=str, default=None, help="Port location") args = parser.parse_args() if args.command in commands: - dev = RAConnect(VENDOR_ID, PRODUCT_ID) + dev = RAConnect(VENDOR_ID, PRODUCT_ID, args.port) area_cfg = get_area_info(dev) dev.set_chip_layout(area_cfg) commands[args.command](dev, args)