This is an automated email from Gerrit.

"Antonio Borneo <borneo.anto...@gmail.com>" just uploaded a new patch set to 
Gerrit, which you can find at https://review.openocd.org/c/openocd/+/7347

-- gerrit

commit b73da708c6309f53b84793b7efd75b058f0eca4c
Author: Antonio Borneo <borneo.anto...@gmail.com>
Date:   Sun Nov 13 15:46:19 2022 +0100

    tools: add disassembler helper for files .inc
    
    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.anto...@gmail.com>

diff --git a/tools/disassemble_inc.sh b/tools/disassemble_inc.sh
new file mode 100755
index 0000000000..7f823f156d
--- /dev/null
+++ b/tools/disassemble_inc.sh
@@ -0,0 +1,44 @@
+#!/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
+
+tmpfile=$(mktemp --suffix=.bin)
+
+echo "Disassemble $1:"
+echo "${CROSS_COMPILE}objdump ${OBJDUMP_FLAGS} -b binary -D ${tmpfile}"
+
+echo -en "$(sed -nz 's,.*/,,;s/[,\n]*0x/\\x/g;s/,//;p' $1)" > ${tmpfile}
+${CROSS_COMPILE}objdump ${OBJDUMP_FLAGS} -b binary -D ${tmpfile}
+
+rm ${tmpfile}

-- 

Reply via email to