diff options
Diffstat (limited to 'home')
| -rw-r--r-- | home/dot_config/fcitx5/conf/private_notifications.conf | 2 | ||||
| -rw-r--r-- | home/dot_config/fcitx5/private_profile | 6 | ||||
| -rw-r--r-- | home/dot_local/share/bin/executable_dbg | 115 | ||||
| -rw-r--r-- | home/dot_local/share/bin/executable_lsjlink | 11 |
4 files changed, 111 insertions, 23 deletions
diff --git a/home/dot_config/fcitx5/conf/private_notifications.conf b/home/dot_config/fcitx5/conf/private_notifications.conf index 32460db..b4fe5d5 100644 --- a/home/dot_config/fcitx5/conf/private_notifications.conf +++ b/home/dot_config/fcitx5/conf/private_notifications.conf @@ -1,3 +1,3 @@ # 隠す通知 -HiddenNotifications= +# HiddenNotifications= diff --git a/home/dot_config/fcitx5/private_profile b/home/dot_config/fcitx5/private_profile index a3e35fe..55a0a3f 100644 --- a/home/dot_config/fcitx5/private_profile +++ b/home/dot_config/fcitx5/private_profile @@ -10,19 +10,19 @@ DefaultIM=mozc # Name Name=keyboard-us # Layout -Layout= +# Layout= [Groups/0/Items/1] # Name Name=keyboard-us-intl # Layout -Layout= +# Layout= [Groups/0/Items/2] # Name Name=mozc # Layout -Layout= +# Layout= [GroupOrder] 0=Default diff --git a/home/dot_local/share/bin/executable_dbg b/home/dot_local/share/bin/executable_dbg index 7976162..51d9227 100644 --- a/home/dot_local/share/bin/executable_dbg +++ b/home/dot_local/share/bin/executable_dbg @@ -1,27 +1,104 @@ -#!/usr/bin/env sh -GDB="arm-none-eabi-gdb" +#!/usr/bin/env python3 -found_executable=false +from argparse import ArgumentParser +from dataclasses import dataclass +from os import execvp +from pathlib import Path +import importlib.util -while ! $found_executable ; do - [ ! -e build/zephyr ] && break - [ ! -e build/zephyr/zephyr.elf ] && break - set -- --se="build/zephyr/zephyr.elf" "$@" +@dataclass +class Options: + args: list[str] + gdb: str + dev_id: str | None - [ -e build/tfm/bin/tfm_s.elf ] && set -- "$@" --eval-command="add-symbol-file build/tfm/bin/tfm_s.elf" +def parse_arguments() -> Options: + parser = ArgumentParser(prog="dbg", description="GDB wrapper with automatic stuff") - found_executable=true -done + parser.add_argument("--gdb", default="arm-none-eabi-gdb", help="GDB executable to use") + parser.add_argument("-i", "--dev-id", type=str, help="J-Link probe serial number to connect to (USB)") -while ! $found_executable ; do - exec="$(find . -maxdepth 3 -name '*.elf' | head -n1)" - [ -n "$exec" ] && set -- "$@" --se="$exec" - found_executable=true - break -done + options, remainder = parser.parse_known_args() + if len(remainder) > 0 and remainder[0] == "--": + del remainder[0] + return Options(**vars(options), args=remainder) -set -- "$@" --eval-command="set jlink autoconnect on" -set -- "$@" --eval-command="set jlink watchdog on" +def gdbarg_eval(eval_command: str): + return "--eval-command=" + eval_command -exec "$GDB" "$@" +def gdbarg_exec(path: str, secondary: bool = False): + if not secondary: + return "--se=" + path + else: + return gdbarg_eval("add-symbol-file " + path) + + +def find_zephyr_sysbuild_executable() -> list[str]: + # TODO + return [ ] + +def find_zephyr_executable() -> list[str]: + out = [] + + if not Path("build/zephyr").exists(): + return out + + if not out: + zephyr = Path("build/zephyr/zephyr.elf") + if zephyr.exists(): + out.append(gdbarg_exec(str(zephyr), False)) + tfm = Path("build/tfm/bin/tfm_s.elf") + if tfm.exists(): + out.append(gdbarg_exec(str(tfm), True)) + + if not out: + out += find_zephyr_sysbuild_executable() + + return out + +def find_generic_executable(base: Path = Path("."), maxdepth: int = 3) -> list[str]: + if maxdepth == 0: + return [] + out = [] + for child in base.iterdir(): + if child.is_dir(): + out += find_generic_executable(child, maxdepth - 1) + if out: + return out + elif child.is_file(): + if not child.name.endswith(".elf"): + continue + return [gdbarg_exec(str(child))] + else: + continue + return [] + +def find_executable() -> list[str]: + out = [] + + out += find_zephyr_executable() + if out: + return out + + out += find_generic_executable() + if out: + return out + + return out + +if __name__ == "__main__": + options = parse_arguments() + + if len(options.args) == 0: + options.args += find_executable() + + if importlib.util.find_spec("debug_renesas") is not None: + if options.dev_id is not None: + options.args.append(gdbarg_eval(f"jlink server usb {options.dev_id}")) + options.args += [ + gdbarg_eval("set jlink autoconnect on"), + gdbarg_eval("set jlink watchdog on"), + ] + + execvp(options.gdb, [options.gdb] + options.args) diff --git a/home/dot_local/share/bin/executable_lsjlink b/home/dot_local/share/bin/executable_lsjlink new file mode 100644 index 0000000..bb7d8ee --- /dev/null +++ b/home/dot_local/share/bin/executable_lsjlink @@ -0,0 +1,11 @@ +#!/usr/bin/env python3 + +import pylink + +jlink = pylink.JLink() + +emulators = jlink.connected_emulators() + +for emu in emulators: + print(f"{emu.SerialNumber}: {emu.acProduct.decode('ascii')}") + |