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.

CCS/MSP430FR2355: Use dis430.exe tool from a debug initialization script?

Part Number: MSP430FR2355
Other Parts Discussed in Thread: CCSTUDIO

Tool/software: Code Composer Studio

Hello! 

Is it possible to call the disassembly tool (dis430.exe) found at C:\ti\ccs1000\ccs\tools\compiler\ti-cgt-msp430_20.2.0.LTS\bin in a debug Initialization Script? 

Something like > dis430.exe myprogram.out > disassembly.txt but in a debug initialization script? 

I currently save program binaries using commands in a initialization script. See below

debugSession.memory.saveData(PAGE_PROGRAM,0x8000,"C:\\Users\\blake\\VHD_MEMORY_JS\\hex_output.txt",0x800,IOMEMORY_HEX,false);

This produces the following output saved to a text file which has met my needs so far. 

1651 1 8000 0 800 0
0x4031
0x3000
0x40B2
0x5A80
0x01CC
0x4014

I recently discovered the dis430.exe tool from a forum post which produces a much more descriptive and and useful output for my purposes. See post and output below. Thank you for your help. 

Disassembly of Asm_AddrMode4_Symbolic.out:

TEXT Section .text, 0x20 bytes at 0x00008000
008000: RESET:
008000: 3140 MOV.W #0x3000,SP
008002: 0030
008004: StopWDT:
008004: B240 MOV.W #0x5a80,&WDTCTL_L
008006: 805A
008008: CC01
00800a: main:
00800a: 1440 MOV.W Const1,R4
00800c: F49F
00800e: 8044 MOV.W R4,Var1
008010: F49F
008012: 1540 MOV.W Const2,R5

  • Hi Blake,

    Blake Stanger said:
    Something like > dis430.exe myprogram.out > disassembly.txt but in a debug initialization script? 

    I assume you wish to make a call the dis430.exe executable from your DSS script. If so, then this is indeed possible. See:

    https://e2e.ti.com/support/tools/ccs/f/81/t/210657

    Thanks

    ki

  • Hello Ki,

    Thanks for your help as always. This looks like exactly what I want to do. Could you help a little more with the syntax? I followed the instructions in your link and wasn't able to make any headway. When I run the script with your suggested additions nothing happens. 

    Here is the relevant code from my script. I've also attached the whole file if needed.  

    load("./0407.RuntimeJava.js");

    ret_value = rt.RunSynch("cd C:\\Users\\blake\\VHD_MEMORY_JS");
    ret_value = rt.RunSynch("dis430.exe Asm_AddrMode4_Symbolic.out>disAsm_addrMode4_Symbolic.txt");

    I just want to accomplish two things, changing the current working directory to the location of my file, and run dis430.exe on the file, as below. 

    Whole DDS Script below


    // Import the DSS packages into our namespace to save on typing
    importPackage(Packages.com.ti.debug.engine.scripting)
    importPackage(Packages.com.ti.ccstudio.scripting.environment)
    importPackage(Packages.java.lang)
    importPackage(Packages.java.io.*)
    load("./0407.RuntimeJava.js");

    // Create our scripting environment object - which is the main entry point into any script and
    // the factory for creating other Scriptable ervers and Sessions
    var script = ScriptingEnvironment.instance()

    // Create a log file in the current directory to log script execution
    script.traceBegin("test_scriptTestLog.xml", "DefaultStylesheet.xsl")
    script.traceBegin("real_testscript.xml")
    // Log everything
    script.traceSetConsoleLevel(TraceLevel.ALL)
    script.traceSetFileLevel(TraceLevel.ALL)

    // Get the Debug Server and start a Debug Session
    debugServer = script.getServer("DebugServer.1")

    //set configurations to NewTargetConfiguration
    debugServer.setConfig("./NewTargetConfiguration.ccxml");

    //debugServer.setConfig("C:/Users/blake/ti/CCSTargetConfigurations/NewTargetConfiguration.ccxml");
    debugSession = debugServer.openSession()


    debugSession.target.connect();

    // Set our TimeOut
    script.setScriptTimeout(15000)

    // Load a program
    // (ScriptingEnvironment has a concept of a working folder and for all of the APIs which take
    // path names as arguments you can either pass a relative path or an absolute path)

    // create a new Runtime to call dis430.exe from commandline
    var rt = new Runtime();

    // cmd starts commandline,
    ret_value = rt.RunSynch("cmd cd C:\\Users\\blake\\VHD_MEMORY_JS");
    ret_value = rt.RunSynch("dis430.exe Asm_AddrMode4_Symbolic.out>disAsm_addrMode4_Symbolic.txt");

    /////// COLTER PUT .OUT FILE HERE
    debugSession.memory.loadProgram("Asm_AddrMode4_Symbolic.out"); //C:\\Users\\blake\\workspace_v10\\Asm_AddrMode4_Symbolic\\Debug\\

    //debugSession.memory.loadProgram("C:\\Users\\blake\\VHD_MEMORY_JS\\work_input.out");

    //savedata //COLTER PUT hex.output.txt here
    debugSession.memory.saveData(PAGE_PROGRAM,0x8000,"C:\\Users\\blake\\VHD_MEMORY_JS\\hex_output.txt",0x800,IOMEMORY_HEX,false);


    //var commandToRun = "C:\\ti\\ccs1000\\ccs\\tools\\compiler\\ti-cgt-msp430_20.2.0.LTS\\bin\\dis430.exe Asm_AddrMode4_Symbolic.out>dis_output.txt"
    //oShell.ShellExecute(commandToRun, );
    //debugSession.memory.saveData(PAGE_PROGRAM,0x8000,"C:\\Users\\blake\\VHD_MEMORY_JS\\hex_output.txt",0x800,IOMEMORY_HEX,false);


    var start_memory_dec = 32768;
    var is_it_first = 0;
    //COLTER PUT VHD MEMORY HERE
    var fw = new java.io.FileWriter("C:\\Users\\blake\\VHD_MEMORY_JS\\program_memory.vhd");
    var writer = new java.io.BufferedWriter(fw);

    writer.write("library IEEE;\n");
    writer.write("use IEEE.std_logic_1164.all;\n");
    writer.write("use IEEE.numeric_std.all;\n" );
    writer.write("\n");
    writer.write("\n");
    writer.write("entity program_memory is\n");
    writer.write(" port ( clock\t: in\tstd_logic;\n");
    writer.write("\t MAB\t\t: in\tstd_logic_vector(15 downto 0);\n");
    writer.write("\t MDB_in \t: out\tstd_logic_vector(15 downto 0);\n");
    writer.write("\t MDB_out \t: in\tstd_logic_vector(15 downto 0);\n");
    writer.write("\t write\t : in\tstd_logic);\n");
    writer.write("end entity;\n");
    writer.write("\n");
    writer.write("architecture program_memory_arch of program_memory is\n");
    writer.write("\n");
    writer.write("type rom_type is array (32768 to 65535) of std_logic_vector(7 downto 0); -- this is MAB: x8000 to xFFFF\n");
    writer.write("\n");
    writer.write("constant ROM : rom_type :=(");

    // var dict = {
    // 4031:
    // }


    var FR = new java.io.FileReader("C:\\Users\\blake\\VHD_MEMORY_JS\\hex_output.txt");
    var reader = new java.io.BufferedReader(FR);
    var line = reader.readLine();

    while (line != null) {
    if (line.compareTo("0xFFFF") != 0) {
    //writer.write(line + "\n");
    //writer.write("COMPARE FFFF results =");
    //writer.write((line.compareTo("0xFFFF") != 0) + "\n");

    switch (is_it_first) {

    //Ignore first line
    case 0:
    //writer.write("IGNORE! "+line);
    is_it_first = 1;
    break;

    //Special Case first line needs unique spacing
    case 1:
    // writer.write("FIRST LINE!"+line+"\n");
    // writer.write(line.charAt(0));
    // writer.write(line.charAt(1));
    // writer.write(line.charAt(2));
    // writer.write(line.charAt(3));
    // writer.write(line.charAt(4));
    // writer.write(line.charAt(5));

    is_it_first = 2;
    line = line.replace("\n", "");
    writer.write(start_memory_dec + " => x"+ "\"");
    writer.write(line.charAt(4));
    writer.write(line.charAt(5));
    writer.write( "\""+"," +"\n");

    start_memory_dec++;

    writer.write(" ");

    writer.write(start_memory_dec + " => x\"");
    writer.write(line.charAt(2));
    writer.write(line.charAt(3));
    writer.write("\"");
    writer.write(',');
    writer.write('\n');

    start_memory_dec++;
    break;

    // all other cases fall into this category.
    case 2:
    //writer.write("SECOND LINE! "+line);
    line = line.replace("\n", "");

    writer.write(" ");
    writer.write(start_memory_dec + " => x\"");
    writer.write(line.charAt(4));
    writer.write(line.charAt(5));
    writer.write("\"" + ',' +'\n');

    start_memory_dec++;
    writer.write(" ");
    writer.write(start_memory_dec + " => x\"");
    writer.write(line.charAt(2));
    writer.write(line.charAt(3));
    writer.write("\"" + ',' +'\n');

    start_memory_dec++;

    break;

    default:
    throw new IllegalStateException("Unexpected value: " + is_it_first);

    }
    line = reader.readLine();
    }else break;


    }

    writer.write(" -- IRQ Vectors\n" );
    writer.write(" 65534 => x\"00\", -- Reset Vector = xFFFE:xFFFF\n" );
    writer.write(" 65535 => x\"80\", -- Startup Value = x8000\n" );
    writer.write("\n" );
    writer.write(" others => x\"00\");\t\n" );
    writer.write("\n" );
    writer.write(" signal EN : std_logic;\n" );
    writer.write("\n" );
    writer.write(" begin\n" );
    writer.write(" -- Note 1: The bus system uses a 16-bit Address (MAB)\n" );
    writer.write(" -- This address size can access locations from x0000 to xFFFF\n" );
    writer.write(" -- But our array is only defined from x8000 to xFFFF and\n" );
    writer.write(" -- if we try to access it with any other address, it will crash.\n" );
    writer.write(" -- So the first thing we need to do is create a local enable that\n" );
    writer.write(" -- will only assert when MAB is within x8000 to xFFFF.\n" );
    writer.write(" \n" );
    writer.write(" LOCAL_EN : process (MAB) \n" );
    writer.write(" begin\n" );
    writer.write(" if ( (to_integer(unsigned(MAB)) >= 32768) and (to_integer(unsigned(MAB)) <= 65535)) then\n" );
    writer.write(" EN <= '1';\n" );
    writer.write(" else \n" );
    writer.write(" EN <= '0';\n" );
    writer.write(" end if;\n" );
    writer.write(" end process;\n" );
    writer.write("\n" );
    writer.write("\n" );
    writer.write(" -- Note 2: The bus system uses a 16-bit Address (MAB)\n" );
    writer.write(" -- The MDB_out is also provided as a 16-bit word\n" );
    writer.write(" -- However, the memory array is actually built as 8-bit bytes.\n" );
    writer.write(" -- So for a given 16-bit MAB, we give MDB_out = HB : LB\n" );
    writer.write(" -- or = ROM(MAB);1) : ROM(MAB)\n" );
    writer.write("\n" );
    writer.write(" MEMORY_ROM : process (clock) \n" );
    writer.write(" begin\n" );
    writer.write(" if (rising_edge(clock)) then\n" );
    writer.write(" if (EN='1' and write='0') then \n" );
    writer.write(" MDB_in <= ROM(to_integer(unsigned(MAB)) ); 1 ) & ROM(to_integer(unsigned(MAB))); \n" );
    writer.write(" end if;\n" );
    writer.write(" end if;\n" );
    writer.write(" end process;\n" );
    writer.write("\n" );
    writer.write("\n" );
    writer.write("end architecture;");
    //

    writer.flush();
    writer.close();
    reader.close();


    // } catch (IOException e) {
    //
    // e.printStackTrace();

    // Stop logging and exit.
    script.traceEnd()

    function addHex(c1, c2) {
    var hexStr = (parseInt(c1, 16) + parseInt(c2, 16)).toString(16);
    while (hexStr.length < 6) { hexStr = '0' + hexStr; } // Zero pad.
    return hexStr;
    }

  • Blake Stanger said:
    ret_value = rt.RunSynch("cd C:\\Users\\blake\\VHD_MEMORY_JS");

    This will not really have any impact. This is because you are not really changing the current working directory for the script. There isn't an easy way to do this.

    Hence for:

    Blake Stanger said:
    ret_value = rt.RunSynch("dis430.exe Asm_AddrMode4_Symbolic.out>disAsm_addrMode4_Symbolic.txt");

    If the exe and out files are not in same directory as the script, then you'll need to pass in absolute paths to all the files. Also, call the command preceded with "cmd /c"

    ex:

    ret_value = rt.RunSynch("cmd /c c:/path/dis430.exe C:/path/Asm_AddrMode4_Symbolic.out > c:/path/disAsm_addrMode4_Symbolic.txt");

  • Ki,

    Thank you for your patient detailed explanations they are always very helpful.

    I made the suggested changes with no effect. When I have given other absolute file paths in this script I had to use \\ instead of / 

    I have tried both (see below), as well as executing the command from C:\ti\ccs1000\ccs\tools\compiler\ti-cgt-msp430_20.2.0.LTS\bin where I suspect the DSS script is called. Any help you can offer is much appreciated. 

    ret_value = rt.RunSynch(" cmd /c C:/Users/blake/VHD_MEMORY_JS/dis430.exe C:/Users/blake/VHD_MEMORY_JS/Asm_AddrMode4_Symbolic.out > C:/Users/blake/VHD_MEMORY_JS/dis_Asm_addrMode4_Symbolic.txt")


    ret_value = rt.RunSynch("cmd \\c C:Users\\blake\\VHD_MEMORY_JS\\dis430.exe C:\\Users\\blake\\VHD_MEMORY_JS\\Asm_AddrMode4_Symbolic.out > C:\\Users\\blake\\VHD_MEMORY_JS\\dis_Asm_addrMode4_Symbolic.txt");

    I am sure you already know this but my measure of success is below. I need the same behavior from my script as this command prompt command.  

  • Blake Stanger said:
    ret_value = rt.RunSynch(" cmd /c C:/Users/blake/VHD_MEMORY_JS/dis430.exe C:/Users/blake/VHD_MEMORY_JS/Asm_AddrMode4_Symbolic.out > C:/Users/blake/VHD_MEMORY_JS/dis_Asm_addrMode4_Symbolic.txt")

    The syntax above looks correct to me. I don't see any issue with it. 

    I created a simple script like below:

    // Import the DSS packages into our namespace to save on typing
    load("RuntimeJava.js");

    // create a new Runtime to call dis430.exe from commandline
    var rt = new Runtime();

    // cmd starts commandline,
    ret_value = rt.runSynch("cmd /c C:/ti/ccs1011/ccs/tools/compiler/ti-cgt-msp430_20.2.1.LTS/bin/dis430.exe C:/Temp/runsynchtest/files/2013.out > C:/Temp/runsynchtest/dis.txt");

    When I run it, it creates a text file like below (attached)

    /cfs-file/__key/communityserver-discussions-components-files/81/dis.txt

  • Ki, 

    This solved the issue! I also found I needed to use the absolute file path with the 

    load("RuntimeJava.js");

    to 

    load("C:/PATH/RuntimeJava.js");

    Thanks for all your help!

    Blake

  • Yep, you would need that full path to the include js file if it is not in the same directory as the main script

    Glad to hear everything is working now.

    ki