From 67c278cb8c6281475b60ba3630667df958aeb305 Mon Sep 17 00:00:00 2001 From: haskal Date: Mon, 28 Jun 2021 17:08:00 -0400 Subject: [PATCH] bikeshed the host side tooling --- host/.gitignore | 8 +++++ host/10-dragnbus.rules | 7 ++++ host/arch/PKGBUILD | 32 +++++++++++++++++++ dmctl.py => host/dbctl.py | 25 ++++++++------- .../i2c-tiny-usb-misc}/Makefile | 0 .../i2c-tiny-usb-misc}/i2c-tiny-usb-proto.txt | 0 .../i2c-tiny-usb-misc}/i2c-tiny-usb.c | 0 7 files changed, 60 insertions(+), 12 deletions(-) create mode 100644 host/.gitignore create mode 100644 host/10-dragnbus.rules create mode 100644 host/arch/PKGBUILD rename dmctl.py => host/dbctl.py (86%) rename {i2c-tiny-usb-misc => host/i2c-tiny-usb-misc}/Makefile (100%) rename {i2c-tiny-usb-misc => host/i2c-tiny-usb-misc}/i2c-tiny-usb-proto.txt (100%) rename {i2c-tiny-usb-misc => host/i2c-tiny-usb-misc}/i2c-tiny-usb.c (100%) diff --git a/host/.gitignore b/host/.gitignore new file mode 100644 index 0000000..3af3b3e --- /dev/null +++ b/host/.gitignore @@ -0,0 +1,8 @@ +arch/* +!arch/PKGBUILD +i2c-tiny-usb-misc/*.o +i2c-tiny-usb-misc/*.ko +i2c-tiny-usb-misc/*.order +i2c-tiny-usb-misc/*.cmd +i2c-tiny-usb-misc/*.mod* +i2c-tiny-usb-misc/*.symvers diff --git a/host/10-dragnbus.rules b/host/10-dragnbus.rules new file mode 100644 index 0000000..3ff14a7 --- /dev/null +++ b/host/10-dragnbus.rules @@ -0,0 +1,7 @@ +SUBSYSTEMS=="usb", ATTRS{idVendor}=="cafe", ATTRS{idProduct}=="1312", MODE:="0666", ENV{IS_DRAGNBUS}:="yes" +ENV{IS_DRAGNBUS}=="yes", ATTRS{interface}=="stdio CDC interface (debug)", ENV{DRAGNBUS_INTERFACE_TYPE}:="debug" +ENV{IS_DRAGNBUS}=="yes", ATTRS{interface}=="Serprog CDC interface", ENV{DRAGNBUS_INTERFACE_TYPE}:="serprog" +ENV{IS_DRAGNBUS}=="yes", ATTRS{interface}=="CMSIS-DAP HID interface", ENV{DRAGNBUS_INTERFACE_TYPE}:="dap" +ENV{DRAGNBUS_INTERFACE_TYPE}=="debug", SUBSYSTEM=="tty", SYMLINK+="dragnbus-dbg" +ENV{DRAGNBUS_INTERFACE_TYPE}=="serprog", SUBSYSTEM=="tty", SYMLINK+="dragnbus-serprog" +ENV{DRAGNBUS_INTERFACE_TYPE}=="dap", SUBSYSTEM=="usbmisc", SYMLINK+="dragnbus-dap" diff --git a/host/arch/PKGBUILD b/host/arch/PKGBUILD new file mode 100644 index 0000000..393bff5 --- /dev/null +++ b/host/arch/PKGBUILD @@ -0,0 +1,32 @@ +# Maintainer haskal +_pkgbase=dragnbus +pkgname=$_pkgbase-git +pkgver=0.0.1 +pkgrel=1 +pkgdesc="dragnbus host tools" +arch=("any") +url="https://git.lain.faith/sys64738/DapperMime-JTAG" +license=("GPL") +depends=("udev" "python" "python-pyserial") +makedepends=() +source=("file://$PWD/../10-dragnbus.rules" + "file://$PWD/../dbctl.py") +sha256sums=(SKIP SKIP) + +build() { + python -m compileall dbctl.py + python -m compileall -o 2 dbctl.py +} + +package() { + install -dm755 "$pkgdir/usr/share/licenses/dragnbus/" + install -dm755 "$pkgdir/usr/bin/" + ln -s /usr/share/licenses/common/GPL3/license.txt \ + "$pkgdir/usr/share/licenses/dragnbus/license.txt" + + install -Dm755 dbctl.py "$pkgdir/usr/lib/dragnbus/dbctl.py" + install -Dm644 -t "$pkgdir/usr/lib/dragnbus/__pycache__/" __pycache__/* + ln -s "/usr/lib/dragnbus/dbctl.py" "$pkgdir/usr/bin/dbctl" + + install -Dm644 10-dragnbus.rules "$pkgdir/usr/lib/udev/rules.d/10-dragnbus.rules" +} diff --git a/dmctl.py b/host/dbctl.py similarity index 86% rename from dmctl.py rename to host/dbctl.py index c29cadb..876eca5 100755 --- a/dmctl.py +++ b/host/dbctl.py @@ -22,7 +22,9 @@ supportmap = { option_table = { 'ctsrts': RTOpt(bool, 1, "Enable or disable CTS/RTS flow control (--ctsrts [true|false])"), - 'i2ctemp': RTOpt(auto_int, 2, "Control the builtin I2C temperature controller: get (0), disable (-1/0xff) or set/enable (other) the current status and I2C bus address"), + 'i2ctemp': RTOpt(auto_int, 2, + "Control the builtin I2C temperature controller: get (0), disable (-1/0xff) " + "or set/enable (other) the current status and I2C bus address"), 'support': RTOpt(str, 0xff, "Get list of supported/implemented functionality"), } @@ -36,6 +38,7 @@ S_CMD_Q_PGMNAME = b'\x03' S_CMD_SYNCNOP = b'\x10' S_CMD_MAGIC_SETTINGS = b'\x53' + def val2byte(t, v) -> int: if t == bool: return 1 if v else 0 @@ -46,6 +49,7 @@ def val2byte(t, v) -> int: assert False, "unimplemented type %s" % str(t) + def do_xfer(args, cmd:int, arg:int, port: str, baudrate:int=115200) -> Optional[int]: with serial.Serial(port, baudrate, timeout=1) as ser: cmdmap = [0]*32 @@ -105,14 +109,14 @@ def do_xfer(args, cmd:int, arg:int, port: str, baudrate:int=115200) -> Optional[ print("settings command failed") return None -def main(): - parser = argparse.ArgumentParser(prog="dmctl", - description="Runtime configuration control for DapperMime-JTAG") - parser.add_argument('tty', type=str, nargs=1, #'?', #default="/dev/ttyACM1", - help="Path to DapperMime-JTAG Serprog UART device"#+\ - #" [/dev/ttyACM1]" - ) +def main(): + parser = argparse.ArgumentParser( + prog="dbctl", + description="Runtime configuration control for DapperMime-JTAG") + + parser.add_argument('tty', type=str, nargs='?', default="/dev/dragnbus-serprog", + help="Path to DapperMime-JTAG Serprog UART device [/dev/dragnbus-serprog]") parser.add_argument('-v', '--verbose', default=False, action='store_true', help="Verbose logging (for this utility)") @@ -129,7 +133,7 @@ def main(): for k, v in option_table.items(): if args.__dict__[k] is not None: - resp = do_xfer(args, v.optid, val2byte(v.type, args.__dict__[k]), args.tty[0]) + resp = do_xfer(args, v.optid, val2byte(v.type, args.__dict__[k]), args.tty) if resp is None: return 1 if k == "support": @@ -140,9 +144,6 @@ def main(): return 0 -#do_xfer(1, 1, "/dev/ttyACM1") -#do_xfer(1, 0, "/dev/ttyACM1") if __name__ == '__main__': main() - diff --git a/i2c-tiny-usb-misc/Makefile b/host/i2c-tiny-usb-misc/Makefile similarity index 100% rename from i2c-tiny-usb-misc/Makefile rename to host/i2c-tiny-usb-misc/Makefile diff --git a/i2c-tiny-usb-misc/i2c-tiny-usb-proto.txt b/host/i2c-tiny-usb-misc/i2c-tiny-usb-proto.txt similarity index 100% rename from i2c-tiny-usb-misc/i2c-tiny-usb-proto.txt rename to host/i2c-tiny-usb-misc/i2c-tiny-usb-proto.txt diff --git a/i2c-tiny-usb-misc/i2c-tiny-usb.c b/host/i2c-tiny-usb-misc/i2c-tiny-usb.c similarity index 100% rename from i2c-tiny-usb-misc/i2c-tiny-usb.c rename to host/i2c-tiny-usb-misc/i2c-tiny-usb.c