bikeshed the host side tooling

This commit is contained in:
xenia 2021-06-28 17:08:00 -04:00
parent 16ce0e9c8b
commit 67c278cb8c
7 changed files with 60 additions and 12 deletions

8
host/.gitignore vendored Normal file
View File

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

7
host/10-dragnbus.rules Normal file
View File

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

32
host/arch/PKGBUILD Normal file
View File

@ -0,0 +1,32 @@
# Maintainer haskal <haskal@awoo.systems>
_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"
}

View File

@ -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",
parser = argparse.ArgumentParser(
prog="dbctl",
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]"
)
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()