tools: add disassembler helper for files .inc 47/7347/3
authorAntonio Borneo <borneo.antonio@gmail.com>
Sun, 13 Nov 2022 14:46:19 +0000 (15:46 +0100)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sun, 15 Jan 2023 15:06:56 +0000 (15:06 +0000)
We are moving the binary helpers in files .inc in contrib/loaders/
but we have no support to disassemble them for checking their
content, nor documentation to give any hint.

Add a simple script that uses objdump to directly disassemble a
file .inc
Use Cortex-M settings as default, but provide the flexibility to
reuse the script for any other target CPU.

Change-Id: I12e79580f2936b1622fb7231d9a2484a763ba72a
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7347
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
tools/disassemble_inc.sh [new file with mode: 0755]

diff --git a/tools/disassemble_inc.sh b/tools/disassemble_inc.sh
new file mode 100755 (executable)
index 0000000..d4b5f80
--- /dev/null
@@ -0,0 +1,50 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+# Simple script to disassemble a file .inc generated by
+# src/helper/bin2char.sh
+# Can be useful to check the correctness of the file .inc
+#
+# By default it decodes ARM thumb little-endian, e.g. cortex-m.
+# Set CROSS_COMPILE for other toolchains.
+# Set OBJDUMP_FLAGS for different objdump flags.
+#
+# Usage:
+#   contrib/loaders/disassemble_inc.sh file.inc
+
+default_CROSS_COMPILE="arm-none-eabi-"
+default_OBJDUMP_FLAGS="-m arm -EL -M force-thumb"
+
+if [ $# != 1 -o ! -f "$1" ]; then
+       echo "Usage:"
+       echo "    $0 path/to/file.inc"
+       echo ""
+       echo "Set CROSS_COMPILE and/or OBJDUMP_FLAGS to override current default:"
+       echo "    export CROSS_COMPILE=\"${default_CROSS_COMPILE}\""
+       echo "    export OBJDUMP_FLAGS=\"${default_OBJDUMP_FLAGS}\""
+       exit 1
+fi
+
+if [ -z "${CROSS_COMPILE}" ]; then
+       CROSS_COMPILE="${default_CROSS_COMPILE}"
+fi
+
+if [ -z "${OBJDUMP_FLAGS}" ]; then
+       OBJDUMP_FLAGS="${default_OBJDUMP_FLAGS}"
+fi
+
+perl -v > /dev/null 2>&1
+if [ $? != 0 ]; then
+       echo "Error: 'perl' interpreter not available."
+       exit 1
+fi
+
+tmpfile=$(mktemp --suffix=.bin)
+
+echo "Disassemble $1:"
+echo "${CROSS_COMPILE}objdump ${OBJDUMP_FLAGS} -b binary -D ${tmpfile}"
+
+perl -e 'while (<>){while ($_=~/(0x..)/g){print chr(hex($1));}}' $1 > ${tmpfile}
+${CROSS_COMPILE}objdump ${OBJDUMP_FLAGS} -b binary -D ${tmpfile}
+
+rm ${tmpfile}

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)