From 46dca278ffaf6c48bea86800a412f0a2de04fdec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Rolim?= Date: Tue, 8 Oct 2019 22:20:08 -0300 Subject: [PATCH] Add admin-tasks with (for now) fwupdmgr and openocd initializing access to gdb. --- script/.local/bin/admin-tasks | 43 ++++++++++++++++++++++++++ script/.local/bin/openocd-gdb-stm32f3x | 9 ++++++ 2 files changed, 52 insertions(+) create mode 100755 script/.local/bin/admin-tasks create mode 100755 script/.local/bin/openocd-gdb-stm32f3x diff --git a/script/.local/bin/admin-tasks b/script/.local/bin/admin-tasks new file mode 100755 index 0000000..3b317bd --- /dev/null +++ b/script/.local/bin/admin-tasks @@ -0,0 +1,43 @@ +#!/usr/bin/env bash + +# Formatting: +# https://stackoverflow.com/questions/2924697/how-does-one-output-bold-text-in-bash +bold=$(tput bold) +normal=$(tput sgr0) + +function bold_echo() { + echo "${bold}$1${normal}" +} + + +function print_help() { + echo "This command allows you to quickly run a few adminstrative tasks!" +} + + +# run fwupmgr +function firmware() { + bold_echo "Devices available:" + fwupdmgr get-devices + + bold_echo "Updates available:" + fwupdmgr get-updates + + bold_echo "Use 'fwupdmgr update' to update all firmware" +} + + +# Run function from script: +# https://stackoverflow.com/questions/8818119/how-can-i-run-a-function-from-a-script-in-command-line +# Check if the function exists (bash specific) +if declare -f "$1" > /dev/null +then + # call arguments verbatim + "$@" +else + # Show a helpful error + echo "'$1' is not a known function name" >&2 + print_help + exit 1 +fi + diff --git a/script/.local/bin/openocd-gdb-stm32f3x b/script/.local/bin/openocd-gdb-stm32f3x new file mode 100755 index 0000000..ba6cced --- /dev/null +++ b/script/.local/bin/openocd-gdb-stm32f3x @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +openocd -f interface/stlink.cfg -f target/stm32f3x.cfg >/dev/null 2>/dev/null & +PID=$! + +arm-none-eabi-gdb "$@" + +kill $PID +