From 4bd15d900bdd7bdd578fbf397b2c88f41e5df74c Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Wed, 10 Jul 2019 22:35:29 +0200 Subject: [PATCH] jtag tools: some factorisation --- tools/jtag_openocd/general.cfg | 3 +++ tools/jtag_openocd/interface-armusbocd.cfg | 4 ---- tools/jtag_openocd/interface-busblaster.cfg | 4 ---- tools/jtag_openocd/interface-buspirate.cfg | 4 ---- tools/jtag_openocd/interface-jlink.cfg | 4 ---- tools/jtag_openocd/interface-jtagkey.cfg | 4 ---- tools/jtag_openocd/interface-shikra.cfg | 4 ---- tools/jtag_openocd/interface-wiggler.cfg | 3 --- tools/jtag_openocd/openocd_configuration.sample | 7 +++++++ tools/jtag_openocd/openocd_flash_dump.sh | 9 +++++++++ tools/jtag_openocd/openocd_flash_recovery.sh | 7 ++----- tools/jtag_openocd/openocd_interactive.sh | 8 ++++++++ 12 files changed, 29 insertions(+), 32 deletions(-) create mode 100644 tools/jtag_openocd/general.cfg create mode 100644 tools/jtag_openocd/openocd_configuration.sample create mode 100755 tools/jtag_openocd/openocd_flash_dump.sh create mode 100755 tools/jtag_openocd/openocd_interactive.sh diff --git a/tools/jtag_openocd/general.cfg b/tools/jtag_openocd/general.cfg new file mode 100644 index 000000000..6151d82bc --- /dev/null +++ b/tools/jtag_openocd/general.cfg @@ -0,0 +1,3 @@ +# Ports +telnet_port 4444 +gdb_port 3333 diff --git a/tools/jtag_openocd/interface-armusbocd.cfg b/tools/jtag_openocd/interface-armusbocd.cfg index e4689e21b..4820136f0 100644 --- a/tools/jtag_openocd/interface-armusbocd.cfg +++ b/tools/jtag_openocd/interface-armusbocd.cfg @@ -1,7 +1,3 @@ -# Ports -telnet_port 4444 -gdb_port 3333 - # Commands specific to the Olimex ARM-USB-OCD Dongle interface ft2232 ft2232_device_desc "Olimex OpenOCD JTAG" diff --git a/tools/jtag_openocd/interface-busblaster.cfg b/tools/jtag_openocd/interface-busblaster.cfg index 337e9a2de..bd1df2c5f 100644 --- a/tools/jtag_openocd/interface-busblaster.cfg +++ b/tools/jtag_openocd/interface-busblaster.cfg @@ -1,7 +1,3 @@ -# Ports -telnet_port 4444 -gdb_port 3333 - # Commands specific to the Bus Blaster interface ftdi ftdi_device_desc "Dual RS232-HS" diff --git a/tools/jtag_openocd/interface-buspirate.cfg b/tools/jtag_openocd/interface-buspirate.cfg index 4ed5b88a5..8eccadd79 100644 --- a/tools/jtag_openocd/interface-buspirate.cfg +++ b/tools/jtag_openocd/interface-buspirate.cfg @@ -1,7 +1,3 @@ -# Ports -telnet_port 4444 -gdb_port 3333 - # Commands specific to the BusPirate interface buspirate buspirate_port /dev/ttyUSB0 diff --git a/tools/jtag_openocd/interface-jlink.cfg b/tools/jtag_openocd/interface-jlink.cfg index 56a04fef2..011cb7844 100644 --- a/tools/jtag_openocd/interface-jlink.cfg +++ b/tools/jtag_openocd/interface-jlink.cfg @@ -1,7 +1,3 @@ -# Ports -telnet_port 4444 -gdb_port 3333 - # Commands specific to the Segger J-Link interface jlink transport select jtag diff --git a/tools/jtag_openocd/interface-jtagkey.cfg b/tools/jtag_openocd/interface-jtagkey.cfg index 3e48c08df..420e6e97e 100644 --- a/tools/jtag_openocd/interface-jtagkey.cfg +++ b/tools/jtag_openocd/interface-jtagkey.cfg @@ -1,7 +1,3 @@ -# Ports -telnet_port 4444 -gdb_port 3333 - # Commands specific to the Amontec JTAGKey interface ft2232 ft2232_device_desc "Amontec JTAGkey A" diff --git a/tools/jtag_openocd/interface-shikra.cfg b/tools/jtag_openocd/interface-shikra.cfg index 507c301b4..ba4b21419 100644 --- a/tools/jtag_openocd/interface-shikra.cfg +++ b/tools/jtag_openocd/interface-shikra.cfg @@ -1,7 +1,3 @@ -# Ports -telnet_port 4444 -gdb_port 3333 - # Commands specific to the Shikra interface ftdi transport select jtag diff --git a/tools/jtag_openocd/interface-wiggler.cfg b/tools/jtag_openocd/interface-wiggler.cfg index 88448de82..ce9a1da06 100644 --- a/tools/jtag_openocd/interface-wiggler.cfg +++ b/tools/jtag_openocd/interface-wiggler.cfg @@ -1,6 +1,3 @@ -telnet_port 4444 -gdb_port 3333 - # Commands specific to the Wiggler interface parport parport_port 0x378 diff --git a/tools/jtag_openocd/openocd_configuration.sample b/tools/jtag_openocd/openocd_configuration.sample new file mode 100644 index 000000000..466e28d9b --- /dev/null +++ b/tools/jtag_openocd/openocd_configuration.sample @@ -0,0 +1,7 @@ +CONFIG_GEN=general.cfg +CONFIG_CHIP=chip-at91sam7s.cfg +IMAGE=../../recovery/proxmark3_recovery.bin +DUMP="dump_$(date +'%Y%m%d-%H%M%S').bin" + +# Example using Segger Jlink: +CONFIG_IF=interface-jlink.cfg diff --git a/tools/jtag_openocd/openocd_flash_dump.sh b/tools/jtag_openocd/openocd_flash_dump.sh new file mode 100755 index 000000000..497847dd1 --- /dev/null +++ b/tools/jtag_openocd/openocd_flash_dump.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +. openocd_configuration || exit 1 + +if [ -e "$DUMP" ]; then + echo "$DUMP exists already. Abort!" + exit 1 +fi +openocd -f $CONFIG_GEN -f $CONFIG_IF -f $CONFIG_CHIP -c "init;halt;dump_image $DUMP 0x100000 0x80000;exit" diff --git a/tools/jtag_openocd/openocd_flash_recovery.sh b/tools/jtag_openocd/openocd_flash_recovery.sh index b51076d5a..2e88c52e6 100755 --- a/tools/jtag_openocd/openocd_flash_recovery.sh +++ b/tools/jtag_openocd/openocd_flash_recovery.sh @@ -1,12 +1,9 @@ #!/bin/bash -# Example using Segger Jlink: -CONFIG_CHIP=chip-at91sam7s.cfg -CONFIG_IF=interface-jlink.cfg -IMAGE=../../recovery/proxmark3_recovery.bin +. openocd_configuration || exit 1 if [ ! -e "$IMAGE" ]; then echo "$IMAGE missing. Abort!" exit 1 fi -openocd -f $CONFIG_IF -f $CONFIG_CHIP -c "init;halt;flash erase_sector 0 0 15;flash erase_sector 1 0 15;flash write_image $IMAGE 0x100000;exit" +openocd -f $CONFIG_GEN -f $CONFIG_IF -f $CONFIG_CHIP -c "init;halt;flash erase_sector 0 0 15;flash erase_sector 1 0 15;flash write_image $IMAGE 0x100000;exit" diff --git a/tools/jtag_openocd/openocd_interactive.sh b/tools/jtag_openocd/openocd_interactive.sh new file mode 100755 index 000000000..ea7919da8 --- /dev/null +++ b/tools/jtag_openocd/openocd_interactive.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +. openocd_configuration || exit 1 + +echo "*********************************************" +echo "Connect to OpenOCD via: telnet localhost $(awk '/^telnet_port/{print$2}' $CONFIG_GEN)" +echo "*********************************************" +openocd -f $CONFIG_GEN -f $CONFIG_IF -f $CONFIG_CHIP