This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

tiobj2bin.bat with hex6x ?



I'm trying to generate a .bin file using the recommended cg_xml scripts and it isn't working as expected.

First issue was I'm on a linux host and so the tiobj2bin.bat file won't run directly, but as the core of the processing appears to be just 3 commands I'm trying to run them directly, the first steps work but not the last:

%hexcmd% -q -b -image -o %binfile% %hextmp% %outfile%

It seems when I substitute hex6x for %hexcmd% that it insists that %hextmp% have a .out suffix (while the .bat file uses .tmp) ... changing to .out seems to work.

hex6x has a --boot, -boot, --byte and -byte options according to its -help output but no -b option. No error though, is it assuming -b is --byte ?

Has anyone converted the tiobj2bin.bat to a shell script ? (easy enough but if someone already has  ... ;)

... Niall

  • Niall Parker said:
    It seems when I substitute hex6x for %hexcmd% that it insists that %hextmp% have a .out suffix (while the .bat file uses .tmp) ... changing to .out seems to work.

    I can't explain that.  %hextmp% is a temporary text file which holds the output from running mkhex4bin.

    Niall Parker said:
    No error though, is it assuming -b is --byte ?

    No.  The -b option is not documented.  It stands for binary.  You get raw binary output.

    Thanks and regards,

    -George

  • Georgem said:

    It seems when I substitute hex6x for %hexcmd% that it insists that %hextmp% have a .out suffix (while the .bat file uses .tmp) ... changing to .out seems to work.

    I can't explain that.  %hextmp% is a temporary text file which holds the output from running mkhex4bin.

    [/quote]

    Maybe some input checking in hex6x that is too paranoid? It certainly reads as text, containing the ROM directive hex6x is looking for when using -image.

    Georgem said:

    No error though, is it assuming -b is --byte ?

    No.  The -b option is not documented.  It stands for binary.  You get raw binary output.

    [/quote]

    Thanks, the output seems to make sense and match what the simulator puts into memory.

    I ended up hacking the .bat into a script after all, should I post it somewhere ?

              ... Niall

  • Niall Parker said:
    I ended up hacking the .bat into a script after all, should I post it somewhere ?

    I'd appreciate that.  Post it here as an attachment.  Use the paper clip icon in the post edit interface.  Then put a link to this thread in the cg_xml wiki article.  Or, something like that.

    Thanks and regards,

    -George

  • Georgem said:

    I ended up hacking the .bat into a script after all, should I post it somewhere ?

    I'd appreciate that.  Post it here as an attachment.  Use the paper clip icon in the post edit interface.  Then put a link to this thread in the cg_xml wiki article.  Or, something like that.

    [/quote]

    Here's the shell script version, note I had to fiddle with the filename to permit attachment and also set the default tools to match my hex6x, ofd6x.

    #!/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.
    # *
    # */