Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shellcheck examples #362

Merged
merged 2 commits into from
Apr 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions examples/lock-app/nrf5/start-gdb.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
:
#!/usr/bin/env bash

SCRIPT_ROOT=`dirname "$0"`
SCRIPT_ROOT=$(dirname "$0")
GNU_INSTALL_ROOT=${GNU_INSTALL_ROOT:-${HOME}/tools/arm/gcc-arm-none-eabi-7-2018-q2-update/bin}
GDB=${GNU_INSTALL_ROOT}/arm-none-eabi-gdb
GDB=$GNU_INSTALL_ROOT/arm-none-eabi-gdb
DEFAULT_APP=./build/chip-nrf52840-lock-example.out
STARTUP_CMDS=${SCRIPT_ROOT}/gdb-startup-cmds.txt
STARTUP_CMDS=$SCRIPT_ROOT/gdb-startup-cmds.txt

if [ $# -eq 0 ]; then
APP=${DEFAULT_APP}
if [[ $# -eq 0 ]]; then
APP=$DEFAULT_APP
else
APP=$1
APP=$1
fi

EXTRA_STARTUP_CMDS=()
if [[ ! -z "$OPENTHREAD_ROOT" ]]; then
EXTRA_STARTUP_CMDS+=(
"set substitute-path /build/KNGP-TOLL1-JOB1/openthread/examples/.. ${OPENTHREAD_ROOT}"
)
if [[ -n $OPENTHREAD_ROOT ]]; then
EXTRA_STARTUP_CMDS+=(
"set substitute-path /build/KNGP-TOLL1-JOB1/openthread/examples/.. $OPENTHREAD_ROOT"
)
fi

exec ${GDB} -q -x ${STARTUP_CMDS} "${EXTRA_STARTUP_CMDS[@]/#/-ex=}" ${APP}
exec "$GDB" -q -x "$STARTUP_CMDS" "${EXTRA_STARTUP_CMDS[@]/#/-ex=}" "$APP"
47 changes: 22 additions & 25 deletions examples/lock-app/nrf5/start-jlink-gdb-server.sh
Original file line number Diff line number Diff line change
@@ -1,44 +1,41 @@
:
#!/usr/bin/env bash

JLINK_GDB_SERVER=JLinkGDBServer
DEVICE_TYPE=NRF52840_XXAA
RTT_PORT=19021

which ${JLINK_GDB_SERVER} || {
echo "ERROR: ${JLINK_GDB_SERVER} not found"
echo "Please install SEGGER J-Link software package"
exit 1
command -v "$JLINK_GDB_SERVER" || {
echo "ERROR: $JLINK_GDB_SERVER not found"
echo "Please install SEGGER J-Link software package"
exit 1
}

which nc || {
echo "ERROR: nc command not found"
exit 1
command -v nc || {
echo "ERROR: nc command not found"
exit 1
}

# Launch JLink GDB Server in background; redirect output thru sed to add prefix.
${JLINK_GDB_SERVER} -device ${DEVICE_TYPE} -if SWD -speed 4000 -rtos GDBServer/RTOSPlugin_FreeRTOS $* > >(exec sed -e 's/^/JLinkGDBServer: /') 2>&1 &
"$JLINK_GDB_SERVER" -device "$DEVICE_TYPE" -if SWD -speed 4000 -rtos GDBServer/RTOSPlugin_FreeRTOS "$@" > >(exec sed -e 's/^/JLinkGDBServer: /') 2>&1 &
GDB_SERVER_PID=$!

# Repeatedly open a connection to the GDB server's RTT port until
# the user kills the GDB server with an interrupt character.
while true;
do
# Wait for GDB server to begin listening on RTT port
while ! lsof -nP -i4TCP:${RTT_PORT} -sTCP:LISTEN > /dev/null;
do
# Quit if the GDB server exits.
if ! (kill -0 ${GDB_SERVER_PID} >/dev/null 2>&1); then
echo ""
exit
fi
while true; do
# Wait for GDB server to begin listening on RTT port
while ! lsof -nP -i4TCP:"$RTT_PORT" -sTCP:LISTEN >/dev/null; do
# Quit if the GDB server exits.
if ! kill -0 "$GDB_SERVER_PID" >/dev/null 2>&1; then
echo ""
exit
fi

# Wait a bit.
sleep 0.1
# Wait a bit.
sleep 0.1

done
done

# Connect to RTT port.
nc localhost ${RTT_PORT}
# Connect to RTT port.
nc localhost "$RTT_PORT"

done