tools: Switch most the tools to argparse.ArgumentDefaultsHelpFormatter and uniformize help style.

This commit is contained in:
Florent Kermarrec 2022-01-05 16:04:31 +01:00
parent 54a137ef9f
commit 67fa433efa
5 changed files with 59 additions and 59 deletions

View file

@ -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)

View file

@ -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()

View file

@ -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))

View file

@ -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()

View file

@ -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()