#!/bin/sh # ========================================================================== # tiobj2bin - Converts TI object file from COFF or ELF to binary # dump format. Intended for use as a post-build step in CCS. # # 16jan12 - modified tiobj2bin.bat to shell script, default to c6x tools # Niall Parker, Starfish Medical # # This code released under a license detailed at the end of this file. # # Invoke: tiobj2bin file.out file.bin [ofd] [hex] [mkhex] # # file.out - The TI .out file to convert to binary. Can be COFF or ELF. # file.bin - Name the binary output file # ofd - The object file display (ofd) utility command to invoke, with # path info as needed. If not given, defaults to ofd470. # hex - The hex utility command to invoke, with path info as needed. # If not given, defaults to hex470. # mkhex - A custom utility which takes XML from OFD and outputs the hex # command file needed for the hex utility. Path info is given # as needed. If not given, defaults to mkhex4bin. # # You may need to put "quotes" around the parameters. # # Here is an example of how this file is invoked as a post-build step in # CCSv4 (not CCSv3.3): # # "${CCE_INSTALL_ROOT}/utils/tiobj2bin/tiobj2bin.bat" "${BuildArtifactFileName}" "${BuildArtifactFileBaseName}.bin" "${CG_TOOL_ROOT}/bin/ofd470.exe" "${CG_TOOL_ROOT}/bin/hex470.exe" "${CCE_INSTALL_ROOT}/utils/tiobj2bin/mkhex4bin.exe" # # ========================================================================== # ========================================================================== # Automated Revision Information # Changed: $Date$ # Revision: $Revision$ # ========================================================================== TI_CGTOOLS_BIN="/opt/ti/ccsv5/tools/compiler/c6000/bin" TI_CGXMLTOOLS="/opt/ti/cg_xml/ofd" # ========================================================================== # Handle command line args # ========================================================================== if [ $# -lt 2 ]; then echo "Usage: $0 file.out file.bin [ofd] [hex] [mkhex]" exit -1 fi outfile=$1 binfile=$2 if [ $3 ]; then ofdcmd=$3 else ofdcmd=$TI_CGTOOLS_BIN/ofd6x fi if [ $4 ]; then hexcmd=$4 else hexcmd=$TI_CGTOOLS_BIN/hex6x fi if [ $5 ]; then mkhexcmd=$5 else mkhexcmd=$TI_CGXMLTOOLS/mkhex4bin.pl fi # ========================================================================== # Compose temporary file names used for ofd and hex cmds # ========================================================================== xmltmp=/tmp/xml_tmp_$RANDOM.xml hextmp=/tmp/hexcmd_$RANDOM.out # ========================================================================== # Paranoid checks on the temp files # ========================================================================== if [ -f $xmltmp ]; then echo "XML temp file exists. Giving up." exit -1 fi if [ -f $hextmp ]; then echo "HEX temp file exists. Giving up." exit -1 fi # ========================================================================== # 1. Create the XML from the .out file # 2. Create the hex command file from the XML # 3. Create the binary from the .out file and hex file # ========================================================================== $ofdcmd -x --xml_indent=0 --obj_display=none,sections,header,segments $outfile > $xmltmp # use perl script version only $mkhexcmd $xmltmp > $hextmp $hexcmd -q -b -image -o $binfile $hextmp $outfile # ========================================================================== # Uncomment to debug # ========================================================================== # cat $hextmp # ========================================================================== # Remove the temp files # ========================================================================== rm $xmltmp rm $hextmp # /* # * # * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ # * # * # * Redistribution and use in source and binary forms, with or without # * modification, are permitted provided that the following conditions # * are met: # * # * Redistributions of source code must retain the above copyright # * notice, this list of conditions and the following disclaimer. # * # * Redistributions in binary form must reproduce the above copyright # * notice, this list of conditions and the following disclaimer in the # * documentation and/or other materials provided with the # * distribution. # * # * Neither the name of Texas Instruments Incorporated nor the names of # * its contributors may be used to endorse or promote products derived # * from this software without specific prior written permission. # * # * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # * # */