Created
October 25, 2015 10:58
-
-
Save shanna/11cf68b80181487d5b55 to your computer and use it in GitHub Desktop.
jlink wrapper script for debugging and flashing.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
command=$1 | |
TARGET="STM32F405RG" | |
TARGET_IF="swd" | |
TARGET_ADDRESS="0x08000000" | |
BUILD="build" | |
PROJECT="ChibiFlight_Sparky2" | |
TARGET_BINARY=$BUILD/$PROJECT.bin | |
TARGET_ELF=$BUILD/$PROJECT.elf | |
TARGET_JLINK=$BUILD/$PROJECT.jlink | |
TARGET_GDB=$BUILD/$PROJECT.gdb | |
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT | |
function command_flash() { | |
cat <<EOF > $TARGET_JLINK | |
speed 1000 | |
r | |
loadbin ${TARGET_BINARY} ${TARGET_ADDRESS} | |
r | |
g | |
exit | |
EOF | |
JLinkExe -device $TARGET -speed 1000 -if $TARGET_IF < $TARGET_JLINK | |
} | |
function command_debug() { | |
cat <<EOF > $TARGET_GDB | |
target extended-remote 127.0.0.1:2331 | |
add-symbol-file ${TARGET_ELF} ${TARGET_ADDRESS} | |
monitor reset | |
b main | |
EOF | |
JLinkGDBServer -device $TARGET -speed 1000 -if $TARGET_IF > /dev/null & | |
arm-none-eabi-gdb -tui -command=$TARGET_GDB | |
} | |
if [ "`type -t command_$command`" = 'function' ]; then | |
"command_$command" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment