WIP: bikeshed the host side tooling #2
|
@ -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
|
|
@ -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"
|
|
@ -0,0 +1,49 @@
|
||||||
|
# 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")
|
||||||
|
provides=("$_pkgbase")
|
||||||
|
conflicts=("$_pkgbase")
|
||||||
|
depends=("udev" "python" "python-pyserial")
|
||||||
|
makedepends=("raspberry-pico-sdk" "ninja")
|
||||||
|
optdepends=("picotool: for flashing the firmware on the CLI")
|
||||||
|
source=("repo::git+file://$PWD/../../")
|
||||||
|
sha256sums=(SKIP)
|
||||||
|
|
||||||
|
prepare() {
|
||||||
|
cd repo
|
||||||
|
git submodule init
|
||||||
|
git submodule update CMSIS_5
|
||||||
|
}
|
||||||
|
|
||||||
|
build() {
|
||||||
|
cd repo
|
||||||
|
export CFLAGS= CPPFLAGS= CXXFLAGS=
|
||||||
|
./scripts/configure_dev.sh
|
||||||
|
cd cmake-build
|
||||||
|
ninja
|
||||||
|
cd ../host
|
||||||
|
python -m compileall dbctl.py
|
||||||
|
python -m compileall -o 2 dbctl.py
|
||||||
|
}
|
||||||
|
|
||||||
|
package() {
|
||||||
|
cd repo
|
||||||
|
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 host/dbctl.py "$pkgdir/usr/lib/dragnbus/dbctl.py"
|
||||||
|
install -Dm644 -t "$pkgdir/usr/lib/dragnbus/__pycache__/" host/__pycache__/*
|
||||||
|
ln -s "/usr/lib/dragnbus/dbctl.py" "$pkgdir/usr/bin/dbctl"
|
||||||
|
|
||||||
|
install -Dm644 host/10-dragnbus.rules "$pkgdir/usr/lib/udev/rules.d/10-dragnbus.rules"
|
||||||
|
|
||||||
|
install -Dm644 cmake-build/repo.uf2 "$pkgdir/usr/share/dragnbus/dragnbus.uf2"
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import argparse, serial, struct
|
import argparse, serial, struct, os
|
||||||
from typing import *
|
from typing import *
|
||||||
|
|
||||||
def auto_int(x):
|
def auto_int(x):
|
||||||
|
@ -22,7 +22,9 @@ supportmap = {
|
||||||
|
|
||||||
option_table = {
|
option_table = {
|
||||||
'ctsrts': RTOpt(bool, 1, "Enable or disable CTS/RTS flow control (--ctsrts [true|false])"),
|
'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"),
|
'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_SYNCNOP = b'\x10'
|
||||||
S_CMD_MAGIC_SETTINGS = b'\x53'
|
S_CMD_MAGIC_SETTINGS = b'\x53'
|
||||||
|
|
||||||
|
|
||||||
def val2byte(t, v) -> int:
|
def val2byte(t, v) -> int:
|
||||||
if t == bool:
|
if t == bool:
|
||||||
return 1 if v else 0
|
return 1 if v else 0
|
||||||
|
@ -46,6 +49,7 @@ def val2byte(t, v) -> int:
|
||||||
|
|
||||||
assert False, "unimplemented type %s" % str(t)
|
assert False, "unimplemented type %s" % str(t)
|
||||||
|
|
||||||
|
|
||||||
def do_xfer(args, cmd:int, arg:int, port: str, baudrate:int=115200) -> Optional[int]:
|
def do_xfer(args, cmd:int, arg:int, port: str, baudrate:int=115200) -> Optional[int]:
|
||||||
with serial.Serial(port, baudrate, timeout=1) as ser:
|
with serial.Serial(port, baudrate, timeout=1) as ser:
|
||||||
cmdmap = [0]*32
|
cmdmap = [0]*32
|
||||||
|
@ -105,18 +109,21 @@ def do_xfer(args, cmd:int, arg:int, port: str, baudrate:int=115200) -> Optional[
|
||||||
print("settings command failed")
|
print("settings command failed")
|
||||||
return None
|
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",
|
def main():
|
||||||
help="Path to DapperMime-JTAG Serprog UART device"#+\
|
parser = argparse.ArgumentParser(
|
||||||
#" [/dev/ttyACM1]"
|
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',
|
parser.add_argument('-v', '--verbose', default=False, action='store_true',
|
||||||
help="Verbose logging (for this utility)")
|
help="Verbose logging (for this utility)")
|
||||||
|
|
||||||
|
parser.add_argument('-f', '--flash', default=False, action='store_true',
|
||||||
|
help="Flash firmware to attached pico")
|
||||||
|
|
||||||
for k, v in option_table.items():
|
for k, v in option_table.items():
|
||||||
if k == "support":
|
if k == "support":
|
||||||
parser.add_argument('--%s'%k, default=None, action='store_true',
|
parser.add_argument('--%s'%k, default=None, action='store_true',
|
||||||
|
@ -127,9 +134,13 @@ def main():
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
if args.flash:
|
||||||
|
os.system("picotool load -x /usr/share/dragnbus/dragnbus.uf2")
|
||||||
|
return
|
||||||
|
|
||||||
for k, v in option_table.items():
|
for k, v in option_table.items():
|
||||||
if args.__dict__[k] is not None:
|
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:
|
if resp is None:
|
||||||
return 1
|
return 1
|
||||||
if k == "support":
|
if k == "support":
|
||||||
|
@ -140,9 +151,6 @@ def main():
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
#do_xfer(1, 1, "/dev/ttyACM1")
|
|
||||||
#do_xfer(1, 0, "/dev/ttyACM1")
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in New Issue