From 67fa433efa23d9d0b3067d20f7ae39602be19254 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Wed, 5 Jan 2022 16:04:31 +0100 Subject: [PATCH] tools: Switch most the tools to argparse.ArgumentDefaultsHelpFormatter and uniformize help style. --- litex/tools/litex_client.py | 8 +++--- litex/tools/litex_gen.py | 36 +++++++++++++-------------- litex/tools/litex_json2dts_linux.py | 10 ++++---- litex/tools/litex_server.py | 38 ++++++++++++++--------------- litex/tools/litex_term.py | 26 ++++++++++---------- 5 files changed, 59 insertions(+), 59 deletions(-) diff --git a/litex/tools/litex_client.py b/litex/tools/litex_client.py index 3e0a0b5b5..96a7d0da8 100644 --- a/litex/tools/litex_client.py +++ b/litex/tools/litex_client.py @@ -140,14 +140,14 @@ def write_memory(port, addr, data): # Run ---------------------------------------------------------------------------------------------- def main(): - parser = argparse.ArgumentParser(description="LiteX Client utility.") + parser = argparse.ArgumentParser(description="LiteX Client utility.", formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument("--port", default="1234", help="Host bind port.") parser.add_argument("--ident", action="store_true", help="Dump SoC identifier.") parser.add_argument("--regs", action="store_true", help="Dump SoC registers.") parser.add_argument("--filter", default=None, help="Registers filter (to be used with --regs).") - parser.add_argument("--read", default=None, help="Do a MMAP Read to SoC bus (--read addr)") - parser.add_argument("--write", default=None, nargs=2, help="Do a MMAP Write to SoC bus (--write addr data)") - parser.add_argument("--length", default="4", help="MMAP access length") + parser.add_argument("--read", default=None, help="Do a MMAP Read to SoC bus (--read addr).") + parser.add_argument("--write", default=None, nargs=2, help="Do a MMAP Write to SoC bus (--write addr data).") + parser.add_argument("--length", default="4", help="MMAP access length.") args = parser.parse_args() port = int(args.port, 0) diff --git a/litex/tools/litex_gen.py b/litex/tools/litex_gen.py index f6595fbff..0ebb855e1 100755 --- a/litex/tools/litex_gen.py +++ b/litex/tools/litex_gen.py @@ -131,7 +131,7 @@ class LiteXCore(SoCMini): self.add_csr("gpio") # Wishbone Master - if kwargs["bus"] == "wishbone": + if kwargs["bus"] in ["wishbone"]: wb_bus = wishbone.Interface() self.bus.add_master(master=wb_bus) platform.add_extension(wb_bus.get_ios("wb")) @@ -139,7 +139,7 @@ class LiteXCore(SoCMini): self.comb += wb_bus.connect_to_pads(wb_pads, mode="slave") # AXI-Lite Master - if kwargs["bus"] == "axi": + if kwargs["bus"] in ["axi", "axi_lite"]: axi_bus = axi.AXILiteInterface(data_width=32, address_width=32) wb_bus = wishbone.Interface() axi2wb = axi.AXILite2Wishbone(axi_bus, wb_bus) @@ -180,29 +180,29 @@ def soc_argdict(args): return ret def main(): - parser = argparse.ArgumentParser(description="LiteX standalone core generator") + parser = argparse.ArgumentParser(description="LiteX standalone core generator", formatter_class=argparse.ArgumentDefaultsHelpFormatter) builder_args(parser) # Bus - parser.add_argument("--bus", default="wishbone", type=str, help="Type of Bus (wishbone, axi)") + parser.add_argument("--bus", default="wishbone", type=str, help="Bus Standard (wishbone, or axi-lite).") # Cores - parser.add_argument("--with-pwm", action="store_true", help="Add PWM core") - parser.add_argument("--with-mmcm", action="store_true", help="Add MMCM (Xilinx 7-series) core") - parser.add_argument("--with-uart", action="store_true", help="Add UART core") - parser.add_argument("--uart-fifo-depth", default=16, type=int, help="UART FIFO depth (default=%(default)d)") - parser.add_argument("--with-ctrl", action="store_true", help="Add bus controller core") - parser.add_argument("--with-timer", action="store_true", help="Add timer core") - parser.add_argument("--with-spi-master", action="store_true", help="Add SPI master core") - parser.add_argument("--spi-master-data-width", default=8, type=int, help="SPI master data width") - parser.add_argument("--spi-master-clk-freq", default=8e6, type=int, help="SPI master output clock frequency") - parser.add_argument("--with-gpio", action="store_true", help="Add GPIO core") - parser.add_argument("--gpio-width", default=32, type=int, help="GPIO signals width") + parser.add_argument("--with-pwm", action="store_true", help="Add PWM core.") + parser.add_argument("--with-mmcm", action="store_true", help="Add MMCM (Xilinx 7-series) core.") + parser.add_argument("--with-uart", action="store_true", help="Add UART core.") + parser.add_argument("--uart-fifo-depth", default=16, type=int, help="UART FIFO depth.") + parser.add_argument("--with-ctrl", action="store_true", help="Add bus controller core.") + parser.add_argument("--with-timer", action="store_true", help="Add timer core.") + parser.add_argument("--with-spi-master", action="store_true", help="Add SPI master core.") + parser.add_argument("--spi-master-data-width", default=8, type=int, help="SPI master data width.") + parser.add_argument("--spi-master-clk-freq", default=8e6, type=int, help="SPI master output clock frequency.") + parser.add_argument("--with-gpio", action="store_true", help="Add GPIO core.") + parser.add_argument("--gpio-width", default=32, type=int, help="GPIO signals width.") # CSR settings - parser.add_argument("--csr-data-width", default=8, type=int, help="CSR bus data-width (8 or 32, default=%(default)d)") - parser.add_argument("--csr-address-width", default=14, type=int, help="CSR bus address-width") - parser.add_argument("--csr-paging", default=0x800, type=int, help="CSR bus paging") + parser.add_argument("--csr-data-width", default=8, type=int, help="CSR bus data-width (8 or 32).") + parser.add_argument("--csr-address-width", default=14, type=int, help="CSR bus address-width.") + parser.add_argument("--csr-paging", default=0x800, type=int, help="CSR bus paging.") args = parser.parse_args() diff --git a/litex/tools/litex_json2dts_linux.py b/litex/tools/litex_json2dts_linux.py index 1d21e32c4..4348a2183 100755 --- a/litex/tools/litex_json2dts_linux.py +++ b/litex/tools/litex_json2dts_linux.py @@ -660,11 +660,11 @@ def main(): parser = argparse.ArgumentParser(description="LiteX's CSR JSON to Linux DTS generator") parser.add_argument("csr_json", help="CSR JSON file") - parser.add_argument("--initrd-start", type=int, help="Location of initrd in RAM (relative, default depends on CPU)") - parser.add_argument("--initrd-size", type=int, help="Size of initrd (default=8MB)") - parser.add_argument("--initrd", type=str, help="Supports arguments 'enabled', 'disabled' or a file name. Set to 'disabled' if you use a kernel built in rootfs or have your rootfs on an SD card partition. If a file name is provied the size of the file will be used instead of --initrd-size. (default=enabled)") - parser.add_argument("--root-device", type=str, help="Device that has our rootfs, if using initrd use the default. For SD card's use something like mmcblk0p3. (default=ram0)") - parser.add_argument("--polling", action="store_true", help="Force polling mode on peripherals") + parser.add_argument("--initrd-start", type=int, help="Location of initrd in RAM (relative, default depends on CPU).") + parser.add_argument("--initrd-size", type=int, help="Size of initrd (default=8MB).") + parser.add_argument("--initrd", type=str, help="Supports arguments 'enabled', 'disabled' or a file name. Set to 'disabled' if you use a kernel built in rootfs or have your rootfs on an SD card partition. If a file name is provied the size of the file will be used instead of --initrd-size. (default=enabled).") + parser.add_argument("--root-device", type=str, help="Device that has our rootfs, if using initrd use the default. For SD card's use something like mmcblk0p3. (default=ram0).") + parser.add_argument("--polling", action="store_true", help="Force polling mode on peripherals.") args = parser.parse_args() d = json.load(open(args.csr_json)) diff --git a/litex/tools/litex_server.py b/litex/tools/litex_server.py index 89a5d8085..549a5b3dd 100755 --- a/litex/tools/litex_server.py +++ b/litex/tools/litex_server.py @@ -164,37 +164,37 @@ class RemoteServer(EtherboneIPC): # Run ---------------------------------------------------------------------------------------------- def main(): - parser = argparse.ArgumentParser(description="LiteX Server utility") + parser = argparse.ArgumentParser(description="LiteX Server utility", formatter_class=argparse.ArgumentDefaultsHelpFormatter) # Common arguments - parser.add_argument("--bind-ip", default="localhost", help="Host bind address") - parser.add_argument("--bind-port", default=1234, help="Host bind port") - parser.add_argument("--debug", action="store_true", help="Enable debug") + parser.add_argument("--bind-ip", default="localhost", help="Host bind address.") + parser.add_argument("--bind-port", default=1234, help="Host bind port.") + parser.add_argument("--debug", action="store_true", help="Enable debug.") # UART arguments - parser.add_argument("--uart", action="store_true", help="Select UART interface") - parser.add_argument("--uart-port", default=None, help="Set UART port") - parser.add_argument("--uart-baudrate", default=115200, help="Set UART baudrate") + parser.add_argument("--uart", action="store_true", help="Select UART interface.") + parser.add_argument("--uart-port", default=None, help="Set UART port.") + parser.add_argument("--uart-baudrate", default=115200, help="Set UART baudrate.") # JTAG arguments - parser.add_argument("--jtag", action="store_true", help="Select JTAG interface") - parser.add_argument("--jtag-config", default="openocd_xc7_ft232.cfg", help="OpenOCD JTAG configuration file") - parser.add_argument("--jtag-chain", default=1, help="JTAG chain") + parser.add_argument("--jtag", action="store_true", help="Select JTAG interface.") + parser.add_argument("--jtag-config", default="openocd_xc7_ft232.cfg", help="OpenOCD JTAG configuration file.") + parser.add_argument("--jtag-chain", default=1, help="JTAG chain.") # UDP arguments - parser.add_argument("--udp", action="store_true", help="Select UDP interface") - parser.add_argument("--udp-ip", default="192.168.1.50", help="Set UDP remote IP address") - parser.add_argument("--udp-port", default=1234, help="Set UDP remote port") + parser.add_argument("--udp", action="store_true", help="Select UDP interface.") + parser.add_argument("--udp-ip", default="192.168.1.50", help="Set UDP remote IP address.") + parser.add_argument("--udp-port", default=1234, help="Set UDP remote port.") parser.add_argument("--udp-scan", action="store_true", help="Scan network for available UDP devices.") # PCIe arguments - parser.add_argument("--pcie", action="store_true", help="Select PCIe interface") - parser.add_argument("--pcie-bar", default=None, help="Set PCIe BAR") + parser.add_argument("--pcie", action="store_true", help="Select PCIe interface.") + parser.add_argument("--pcie-bar", default=None, help="Set PCIe BAR.") # USB arguments - parser.add_argument("--usb", action="store_true", help="Select USB interface") - parser.add_argument("--usb-vid", default=None, help="Set USB vendor ID") - parser.add_argument("--usb-pid", default=None, help="Set USB product ID") - parser.add_argument("--usb-max-retries", default=10, help="Number of USB reconecting retries") + parser.add_argument("--usb", action="store_true", help="Select USB interface.") + parser.add_argument("--usb-vid", default=None, help="Set USB vendor ID.") + parser.add_argument("--usb-pid", default=None, help="Set USB product ID.") + parser.add_argument("--usb-max-retries", default=10, help="Number of USB reconecting retries.") args = parser.parse_args() diff --git a/litex/tools/litex_term.py b/litex/tools/litex_term.py index cbcef414f..f9856943f 100755 --- a/litex/tools/litex_term.py +++ b/litex/tools/litex_term.py @@ -603,21 +603,21 @@ class LiteXTerm: # Run ---------------------------------------------------------------------------------------------- def _get_args(): - parser = argparse.ArgumentParser() - parser.add_argument("port", help="Serial port (eg /dev/tty*, bridge, jtag)") - parser.add_argument("--speed", default=115200, help="Serial baudrate") - parser.add_argument("--serial-boot", default=False, action='store_true', help="Automatically initiate serial boot") - parser.add_argument("--kernel", default=None, help="Kernel image") - parser.add_argument("--kernel-adr", default="0x40000000", help="Kernel address") - parser.add_argument("--images", default=None, help="JSON description of the images to load to memory") - parser.add_argument("--safe", action="store_true", help="Safe serial boot mode, disable upload speed optimizations") + parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter) + parser.add_argument("port", help="Serial port (eg /dev/tty*, bridge, jtag).") + parser.add_argument("--speed", default=115200, help="Serial baudrate.") + parser.add_argument("--serial-boot", default=False, action='store_true', help="Automatically initiate serial boot.") + parser.add_argument("--kernel", default=None, help="Kernel image.") + parser.add_argument("--kernel-adr", default="0x40000000", help="Kernel address.") + parser.add_argument("--images", default=None, help="JSON description of the images to load to memory.") + parser.add_argument("--safe", action="store_true", help="Safe serial boot mode, disable upload speed optimizations.") - parser.add_argument("--csr-csv", default=None, help="SoC CSV file") - parser.add_argument("--base-address", default=None, help="CSR base address") - parser.add_argument("--bridge-name", default="uart_xover", help="Bridge UART name to use (present in design/csr.csv)") + parser.add_argument("--csr-csv", default=None, help="SoC CSV file.") + parser.add_argument("--base-address", default=None, help="CSR base address.") + parser.add_argument("--bridge-name", default="uart_xover", help="Bridge UART name to use (present in design/csr.csv).") - parser.add_argument("--jtag-name", default="jtag_uart", help="JTAG UART type: jtag_uart (default), jtag_atlantic") - parser.add_argument("--jtag-config", default="openocd_xc7_ft2232.cfg", help="OpenOCD JTAG configuration file for jtag_uart") + parser.add_argument("--jtag-name", default="jtag_uart", help="JTAG UART type (jtag_uart or jtag_atlantic).") + parser.add_argument("--jtag-config", default="openocd_xc7_ft2232.cfg", help="OpenOCD JTAG configuration file for jtag_uart.") parser.add_argument("--jtag-chain", default=1, help="JTAG chain.") return parser.parse_args()