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.

Flash Error while programming F28M35 Concerto

Other Parts Discussed in Thread: CCSTUDIO

Hello

I get the following error while trying to load the Concerto F28M35H52C1 C28x Core for the first time after a flash erase. 

SEVERE: C28xx_0: Error occurred during flash operation: Timed out waiting for target to halt while executing pwrite_en.alg SEVERE: C28xx_0: Flash operation timed out waiting for the algorithm to complete. Operation cancelled. 

My device is an experimental F28M35x, does this play a role in such a behavior?

Regards

Sandeep

  • Sandeep,

    Is M3 connected to debugger and halted when you got this error on C28x?
    What is the boot mode pin configuration used?

    Thanks and regards,
    Vamsi
  • Hello Vamsi

    Yes the M3 is connected to the debugger and halted. I used the DSS Script to do this. 

    However when i use CCS to halt the M3 and program the C28x, i do not get the error. 

    Is there something wrong in the DSS Script then. 

    Can i share the same with you to have a look?

    Regards

    Sandeep

  • Sandeep,

    You can share the script.

    What is the device revision?

    What is the boot mode pin configuration used?

    Thanks and regards,
    Vamsi
  • Sandeep,

    Do you still have this issue?

    Thanks and regards,
    Vamsi
  • Hello Vamsi
    I am sorry for the delay in my reply. I was not actively looking into this issue as there was other issues which i was stuck with.
    I am still getting this issue. It is not resolved yet.
    Find below the file. I didnt know how to attach it as is so i have snipped it.

    Thanks and Regards
    Sandeep


    /*******************************************************************
    * This sample script loads and runs a specified program on a
    * specified target.
    *
    * Usages:
    * dss runProgram.js myTargetConfig.ccxml myProgramFile.out
    * dss runProgram.js myTargetConfig.ccxml myProgramFile.out <BoardName>
    * dss runProgram.js myTargetConfig.ccxml myProgramFile.out <BoardName> <CPUName>
    *
    * Requirement:
    * <INSTALL DIR>\ccsv4\scripting\bin must be in your system path.
    *
    * You can copy and modify this script to suit your needs.
    *******************************************************************
    * Copyright 2010-2014 The MathWorks, Inc.
    *******************************************************************/

    // Import the DSS packages into the namespace;
    importPackage(Packages.com.ti.debug.engine.scripting);
    importPackage(Packages.com.ti.ccstudio.scripting.environment);
    importPackage(Packages.java.lang);

    // Define parameters ----------------------------

    var targetConfig; // (user input) target configuration file
    var programName; // (user input) program to load
    var boardName; // (user input) board to use (optional)
    var cpuName; // (user input) CPU to use (optional)

    var waitForHalt = 0; // wait for program to halt before exiting

    var enableLogging = 0; // enable logging
    var logFile = "RunProgramLog.xml"; // file where trace info is stored

    // Get the input parameters ---------------------
    var input = getArgs();
    programName = input.programName;
    targetConfig = input.targetConfig;
    boardName = ".*C28.*";
    cpuName = input.cpuName;
    boardNameM3 = ".*M3.*";


    // Create/configure scripting object -------------

    // Create the scripting environment object
    var script = ScriptingEnvironment.instance();

    // Set the time out to 90 seconds
    // (comment this if you want to wait indefinitely)
    script.setScriptTimeout(90000);

    // Set up logging -------------------------------

    if (enableLogging) {
    // Create a log file in the current directory to log script execution
    script.traceBegin(logFile, "DefaultStylesheet.xsl");
    // Log everything
    script.traceSetConsoleLevel(TraceLevel.ALL);
    script.traceSetFileLevel(TraceLevel.ALL);
    }

    // Set up the debug session ----------------------

    print("\n*** Starting debug session...");

    // Get the Debug Server
    debugServer = script.getServer("DebugServer.1");
    debugServer.setConfig(targetConfig);

    // Start a Debug Session for C28
    try {
    // debugSession = debugServer.openSession(boardName, cpuName);
    debugSession = debugServer.openSession(boardName);
    }
    catch (ex) {
    print("*** Cannot create a valid debug session for Board/CPU=" + boardName + "/" + cpuName + ".\n" +
    " Make sure this matches only one board and one CPU.\n" +
    " Exiting...\n");
    exitScript();
    }

    // Start a Debug Session for M3
    try {
    debugSessionM3 = debugServer.openSession(boardNameM3);
    }
    catch (ex) {
    print("*** Cannot create a valid debug session for Board/CPU=" + boardNameM3 + "/" + cpuName + ".\n" +
    " Make sure this matches only one board and one CPU.\n" +
    " Exiting...\n");
    exitScript();
    }

    print("*** Debug Session Name: " + debugSession.getName());
    print("*** Board Name: " + debugSession.getBoardName());
    print("*** CPU Name: " + debugSession.getCPUName());

    // Connect to the target -------------------------
    try {
    print("\n*** Connecting to target...")
    debugSessionM3.target.connect(); //Connect to M3
    debugSession.target.connect(); //Connect to C28
    }
    catch (ex) {
    // ignore if connect() fails - it may not be supported
    print("\n*** Error: Unable to connect to the board, please ensure that the board is connected.")
    }

    try{
    debugSession.flash.options.setBoolean("FlashBackupClock",true);
    }
    catch (ex) {
    print("\n*** Warning: The clock backup and restore functionality is not supported with this CCS version. When using 'Boot from flash', perform a board power cycle after flashing to ensure that the program executes at the desired clock frequency.")
    }

    // Erase only Necessary Flash Sectors -------------
    debugSession.options.setString("FlashEraseSelection", "Necessary Sectors Only (for Program Load)");
    // debugSession.options.setString("VerifyAfterProgramLoad","No verification");

    // Reset the target -------------------------------
    debugSession.target.reset();
    debugSessionM3.target.reset();
    // Load the program -------------------------------
    print("\n*** Loading the program to the target...")
    debugSession.memory.loadProgram(programName);

    // Restart the program ----------------------------
    debugSession.target.restart();

    // Run the program --------------------------------

    // runAsynch() returns control immediately - it does not wait for program to halt
    debugSessionM3.target.runAsynch();//Run the M3
    debugSession.target.runAsynch();

    if (debugSessionM3.target.isHalted()) {
    print("\n*** Program failed to run. Exiting...");
    exitScript();
    }
    else {
    print("*** M3 Program is running.");
    }

    if (debugSession.target.isHalted()) {
    print("\n*** Program failed to run. Exiting...");
    exitScript();
    }
    else {
    print("*** Program is running.");
    }

    // Wait for the program to halt -------------------

    if (waitForHalt) {
    print("\n*** Waiting for program to halt...");

    // Wait for the program to halt
    debugSession.target.waitForHalt();

    if (debugSession.target.isHalted()) {
    print("\n*** Program is now halted.");
    }
    }

    // Disconnect from target --------------------------

    try {
    print("\n*** Disconnecting from target...");
    debugSession.target.disconnect();
    }
    catch (ex) {
    // ignore if disconnect() fails - it may not be supported
    }

    // All done -----------------------------

    print("\n*** Terminating debug session...");
    debugSession.terminate();
    debugServer.stop();

    print("\n*** LOAD & RUN DONE.");
    exitScript();

    /**************************************
    * Get arguments from the command-line.
    **************************************/
    function getArgs()
    {
    var args = {};
    var arguments = this.arguments;

    if ((arguments.length<2) && (arguments.length>4))
    {
    print(
    "ERROR: You did not specify the correct number of arguments.\n" +
    "Usage: dss runProgram.js <targetConfigurationFile> <programFile>\n" +
    "Usage: dss runProgram.js <targetConfigurationFile> <programFile> <boardName>\n" +
    "Usage: dss runProgram.js <targetConfigurationFile> <programFile> <boardName> <cpuName>\n");
    delete args;
    java.lang.System.exit(0);
    }
    // Required inputs
    args.targetConfig = arguments[0];
    args.programName = arguments[1];

    print("\n*** User inputs: ");
    print(" Target Configuration: " + args.targetConfig);
    print(" Program Name: " + args.programName);

    if (arguments.length >= 3) {
    args.boardName = arguments[2];
    print(" Board Name: " + args.boardName);
    }
    else {
    args.boardName = "*"; // first board
    print(" Board Name: unspecified (connect to first board)");
    }
    if (arguments.length == 4) {
    args.cpuName = arguments[3];
    print(" CPU Name: " + args.cpuName);
    }
    else {
    args.cpuName = "*"; // first CPU on first board
    print(" CPU Name: unspecified (connect to first CPU)");
    }
    return args;
    }

    /**************************************
    * Exit the script
    **************************************/
    function exitScript()
    {
    if (enableLogging)
    {
    script.traceSetConsoleLevel(TraceLevel.INFO);
    script.traceEnd(); // stop logging
    }
    java.lang.System.exit(0);
    }
  • Sandeep,

    Will check the script.
    What is the device revision?
    What is the boot mode pin configuration used?

    Thanks and regards,
    Vamsi
  • Hi Vamsi

    It is an experimental board. 

    Boot mode pins are set to all 0's.

    Regards

    Sandeep

  • Sandeep,

    Try these.

    Open the M3 debug session first and then for C28x.

    Connect to M3 first and reset M3.  Then Connect to C28x and reset C28x.

    Also, try removing the resets.

    If above does not help, try loading some code to M3 first and then to C28x.

    Let me know how it goes.  

    Make sure to check for CCS updates and install all of them.

    Thanks and regards,

    Vamsi 

  • Hi Vamsi,

    I tried all the steps suggested by you.

    For all the trials, I made sure I follow these steps:
    1. Open the M3 debug session
    2. Open the C28x debug session
    3. Connect to M3
    4. Reset M3 (I may or may not do this - to follow your suggestion)
    5. Connect to C28x
    6. Reset C28x (I may or may not do this - to follow your suggestion)

    Exp1:
    1. Reset M3 and C28x
    2. Load the program to C28x

    I observed the error

    Exp2:
    1. Do not reset M3 and C28x
    2. Load the program to C28x

    I observed the error.

    Exp3:
    1. Do not reset M3 and C28x
    2. Load a program to M3
    3. Load a program to C28x

    For the very first time I did this experiment, loading program to M3 failed. I got the following error.
    SEVERE: Cortex_M3_0: Error occurred during flash operation: Timed out waiting for target to halt while executing erasew.alg
    SEVERE: Cortex_M3_0: Trouble Removing Breakpoint with the Action "Remain Halted" at 0x20004744: (Error -2044 @ 0x96) Internal error: Requested breakpoint does not exist. Restart the application. If error persists, please report the error. (Emulation package 6.0.222.0)
    SEVERE: Cortex_M3_0: Flash Programmer: Error erasing Sector N. Operation Cancelled.
    SEVERE: Cortex_M3_0: File Loader: Memory write failed: Unknown error
    SEVERE: Cortex_M3_0: GEL: File:

    I have made the script to exit in case of any error so it did not load the C28x program. From the second time onwards, irrespective of whether I power off and power on the board, I never observed this error for M3.

    However, during the power off and power on cycle, even if the program load is successful for M3, it is not successful for C28x. I still get the error.
    SEVERE: C28xx_0: Error occurred during flash operation: Timed out waiting for target to halt while executing pwrite_en.alg
    SEVERE: C28xx_0: Flash operation timed out waiting for the algorithm to complete. Operation cancelled.

    Exp4:
    1. Reset M3 and C28x
    2. Load a program to M3
    3. Load a program to C28x

    I still observe the error.

    I would like to mention again that, while I am working with CCS, just connecting the M3 is fixing this issue. So i just have to connect to M3 and then if I load the program to C28x it works. I am facing this issue only with dss.

    I have pasted the script for your reference.

    /*******************************************************************
    * This sample script loads and runs a specified program on a
    * specified target.
    *
    * Usages:
    * dss runProgram.js myTargetConfig.ccxml myProgramFile.out
    * dss runProgram.js myTargetConfig.ccxml myProgramFile.out <BoardName>
    * dss runProgram.js myTargetConfig.ccxml myProgramFile.out <BoardName> <CPUName>
    *
    * Requirement:
    * <INSTALL DIR>\ccsv4\scripting\bin must be in your system path.
    *
    * You can copy and modify this script to suit your needs.
    *******************************************************************
    * Copyright 2010-2014 The MathWorks, Inc.
    *******************************************************************/

    // Import the DSS packages into the namespace;
    importPackage(Packages.com.ti.debug.engine.scripting);
    importPackage(Packages.com.ti.ccstudio.scripting.environment);
    importPackage(Packages.java.lang);

    // Define parameters ----------------------------

    var targetConfig; // (user input) target configuration file
    var programName; // (user input) program to load
    var boardName; // (user input) board to use (optional)
    var cpuName; // (user input) CPU to use (optional)

    var waitForHalt = 0; // wait for program to halt before exiting

    var enableLogging = 0; // enable logging
    var logFile = "RunProgramLog.xml"; // file where trace info is stored

    // Get the input parameters ---------------------
    var input = getArgs();
    programName = input.programName;
    targetConfig = input.targetConfig;
    boardName = ".*C28.*";
    cpuName = input.cpuName;
    boardNameM3 = ".*M3.*";

    // Create/configure scripting object -------------

    // Create the scripting environment object
    var script = ScriptingEnvironment.instance();

    // Set the time out to 90 seconds
    // (comment this if you want to wait indefinitely)
    script.setScriptTimeout(90000);

    // Set up logging -------------------------------

    if (enableLogging) {
    // Create a log file in the current directory to log script execution
    script.traceBegin(logFile, "DefaultStylesheet.xsl");
    // Log everything
    script.traceSetConsoleLevel(TraceLevel.ALL);
    script.traceSetFileLevel(TraceLevel.ALL);
    }

    // Set up the debug session ----------------------

    print("\n*** Starting debug session...");

    // Get the Debug Server
    debugServer = script.getServer("DebugServer.1");
    debugServer.setConfig(targetConfig);

    // Start a Debug Session for M3
    try {
    debugSessionM3 = debugServer.openSession(boardNameM3);
    }
    catch (ex) {
    print("*** Cannot create a valid debug session for Board/CPU=" + boardNameM3 + "/" + cpuName + ".\n" +
    " Make sure this matches only one board and one CPU.\n" +
    " Exiting...\n");
    exitScript();
    }
    print("*** Debug Session M3 Name: " + debugSessionM3.getName());
    print("*** Board Name: " + debugSessionM3.getBoardName());
    print("*** CPU Name: " + debugSessionM3.getCPUName());

    // Start a Debug Session
    try {
    // debugSession = debugServer.openSession(boardName, cpuName);
    debugSession = debugServer.openSession(boardName);
    }
    catch (ex) {
    print("*** Cannot create a valid debug session for Board/CPU=" + boardName + "/" + cpuName + ".\n" +
    " Make sure this matches only one board and one CPU.\n" +
    " Exiting...\n");
    exitScript();
    }

    print("*** Debug Session C28x Name: " + debugSession.getName());
    print("*** Board Name: " + debugSession.getBoardName());
    print("*** CPU Name: " + debugSession.getCPUName());

    // Connect to the M3 target -------------------------
    try {
    print("\n*** Connecting to M3 target...")
    debugSessionM3.target.connect(); //Connect to M3
    }
    catch (ex) {
    // ignore if connect() fails - it may not be supported
    print("\n*** Error: Unable to connect to the board, please ensure that the board is connected.")
    }
    print("\n*** Resetting M3 target...")
    debugSessionM3.target.reset();

    // Connect to the target -------------------------
    try {
    print("\n*** Connecting to C28x target...")
    debugSession.target.connect(); //Connect to C28x
    }
    catch (ex) {
    // ignore if connect() fails - it may not be supported
    print("\n*** Error: Unable to connect to the board, please ensure that the board is connected.")
    }
    print("\n*** Resetting C28x target...")
    debugSession.target.reset();

    try{
    debugSession.flash.options.setBoolean("FlashBackupClock",true);
    }
    catch (ex) {
    print("\n*** Warning: The clock backup and restore functionality is not supported with this CCS version. When using 'Boot from flash', perform a board power cycle after flashing to ensure that the program executes at the desired clock frequency.")
    }

    // Erase only Necessary Flash Sectors -------------
    debugSession.options.setString("FlashEraseSelection", "Necessary Sectors Only (for Program Load)");

    // Load the program into M3 first--------------
    print("\n*** Loading a sample program to the M3 target...")
    try{
    debugSessionM3.memory.loadProgram(programNameM3);
    }
    catch (ex) {
    print("\n*** Program not loaded into M3 properly");
    exitScript();
    }
    print("\n*** Successfully loaded a sample program to the M3 target...")
    // Load the program into C28x -------------------------------
    print("\n*** Loading the program to the c28xtarget...")
    debugSession.memory.loadProgram(programName);

    // Restart the program ----------------------------
    debugSession.target.restart();

    // Run the program --------------------------------

    // runAsynch() returns control immediately - it does not wait for program to halt
    debugSession.target.runAsynch();

    if (debugSession.target.isHalted()) {
    print("\n*** Program failed to run. Exiting...");
    exitScript();
    }
    else {
    print("*** Program is running.");
    }

    // Wait for the program to halt -------------------

    if (waitForHalt) {
    print("\n*** Waiting for program to halt...");

    // Wait for the program to halt
    debugSession.target.waitForHalt();

    if (debugSession.target.isHalted()) {
    print("\n*** Program is now halted.");
    }
    }

    // Disconnect from target --------------------------

    try {
    print("\n*** Disconnecting from target...");
    debugSession.target.disconnect();
    }
    catch (ex) {
    // ignore if disconnect() fails - it may not be supported
    }

    // All done -----------------------------

    print("\n*** Terminating debug session...");
    debugSession.terminate();
    debugServer.stop();

    print("\n*** LOAD & RUN DONE.");
    exitScript();

    /**************************************
    * Get arguments from the command-line.
    **************************************/
    function getArgs()
    {
    var args = {};
    var arguments = this.arguments;

    if ((arguments.length<2) && (arguments.length>4))
    {
    print(
    "ERROR: You did not specify the correct number of arguments.\n" +
    "Usage: dss runProgram.js <targetConfigurationFile> <programFile>\n" +
    "Usage: dss runProgram.js <targetConfigurationFile> <programFile> <boardName>\n" +
    "Usage: dss runProgram.js <targetConfigurationFile> <programFile> <boardName> <cpuName>\n");
    delete args;
    java.lang.System.exit(0);
    }
    // Required inputs
    args.targetConfig = arguments[0];
    args.programName = arguments[1];

    print("\n*** User inputs: ");
    print(" Target Configuration: " + args.targetConfig);
    print(" Program Name: " + args.programName);

    if (arguments.length >= 3) {
    args.boardName = arguments[2];
    print(" Board Name: " + args.boardName);
    }
    else {
    args.boardName = "*"; // first board
    print(" Board Name: unspecified (connect to first board)");
    }
    if (arguments.length == 4) {
    args.cpuName = arguments[3];
    print(" CPU Name: " + args.cpuName);
    }
    else {
    args.cpuName = "*"; // first CPU on first board
    print(" CPU Name: unspecified (connect to first CPU)");
    }
    return args;
    }

    /**************************************
    * Exit the script
    **************************************/
    function exitScript()
    {
    if (enableLogging)
    {
    script.traceSetConsoleLevel(TraceLevel.INFO);
    script.traceEnd(); // stop logging
    }
    java.lang.System.exit(0);
    }
  • The error while loading program to M3 occurs sporadically.
  • Sandeep,

    Can you try inserting the unlock sequence before loading the code?

    Thanks and regards,

    Vamsi

  • Hello Vamsi
    What is an unlock sequence?
    Regards
    Sandeep
  • Hi Sandeep,

    Please refer "1.10.3.2 CSM Password Match Flow" in device TRM to know how to unlock the device. This is only needed if you have security enabled by programming the password values in flash at password locations. If not then this step should not be needed.

    Regards,

    Vivek Singh

  • Hello Vamsi/Vivek
    Then my original thread then remains unanswered on why that pwrite_en.alg error could come up.
    Regards
    Sandeep
  • I would also like to mention that this error happens with only F28M35x and with the same script file as mentioned above, this issue is not reproducible with F28M36x.
    Is there something specific to F28M35x which we are perhaps missing.
    Regards
    Sandeep
  • Sandeep,

    We are able to program C28x in F28M35x successfully using your script.

    To help debug further, I asked our tools team to generate logs for GUI operation and script operation and compare them to see if there is any difference between the two in terms of initialization or sequence of steps. They will try that next week after the long weekend.

    Device revision info will be present on the package (like YFB or YFC). Can you tell what is there on your device?

    What is the PLL config that you are using to program C28x?

    Thanks and regards,
    Vamsi
  • Sandeep,

    Any update on this?
    Can you tell the device revision and the PLL config that you are using?

    Thanks and regards,
    Vamsi
  • Hello Vamsi

    Yeah we are still facing this issue. 

    The device is an experimental board. Can you let me know how to check the PLL Configuration. 

    I am unsure about this. 

    Regards

    Sandeep

  • Sandeep,

    Looks like you are not configuring the PLL in your script.  That should cause the Plugin to use the default settings, which is fine.

    1) Can you send a snapshot of your device?

    2) When you try the CCS, did you change any GUI settings?  If yes, you have to set them in DSS script as well.

    3) Based on the error that you got, I feel that the device is either secured or is not initialized properly.  If we execute BootROM (issue a reset -> then resume ->  then halt after a minor delay like 500us) after the reset and before loading the code, the device should get initialized properly and this might get solved.  

    You can accomplish this in your script.

    (a) After the reset in script, run the bootROM by calling session.target.runAysch();

    This is same as hitting the resume button in CCS.

    (b) You can put a delay using Java Thread like below

    Thread.sleep(1000);

    (c) And then you can issue a halt as below:

    session.target.halt();

    Then load the code.

    4) Also, can you generate logs for us (since we are not able to make your script fail in our setup) when using both CCS and script?

    (a) In CCS, you can enable logging via "CCS Help menu ->  CCS Support -> Select Debug Server Log -> Click on Properties ->  Select Enable Debug Server Logging + Choose a log file location -> Click Ok".

    (b) When using DSS, you can enable log generation by setting the following environment variables in your command prompt before running the script. 

    set TI_DS_ENABLE_LOGGING=1

    set TI_DS_LOGGING_OUTPUT=c:/path/file.log

    Thanks and regards,
    Vamsi 

  • Sandeep,

    Any update on this?  

    Thanks and regards,
    Vamsi  

  • Hello Vamsi

    thanks for your detailed reply. I will look into the steps you proposed later today. I am sorry i was debugging some other issues with the latest version of TI Compiler so i got stuck with this. 

    Will check and revert back before EOD today along with the snapshots. 

    Thanks and Regards

    Sandeep