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.

How to reset and erase program in TM4C custom board

Hi,

I am developing on a custom board which is TM4C1294 + 8MB SDRAM + 4 connector(20pins header or 10pins header for gpio)

Not every time happens but it's quite often occurred as .bin is programmed through USB using LM Flash, MCU gets stuck due to diverse reasons such as bugs of interrupt, freeRTOS, misuse of ports..etc.

Afterward,  I can not program anymore thru LM Flash. What the LM Flash says is "Unable to connect the target!".

Even if I press reset button on the custom board, it does not resolve anything.

Sometimes it works after hundred times of power cycling but it does not always work.


Even though I want to erase programs in flash, it does not let me access the target device.

So far What I have done for this issue is re-order new board since I am not sure how to solve problems on tiny custom board.

Is re-order the new board only way? otherwise what can I do better than re-order?

Jin

  • Would not the long standard Stellaris program, "GPIO_JTAG.c" provide a quick/eased means - for you to recover/restore JTAG - thus allowing your reuse of those boards?

    It's normal to employ a single GPIO pin or other mechanism to revert those JTAG pins away from any (likely) repurposing - which usually proves the cause of such, "Unable to connect" dreaded message...

  • Hi,

    USB is used for programming, however I tried to use jtag instead of USB. it is also showed same error message.

    Thanks,
  • Yes - that's as expected - the method I've suggested is, "Preventative" - avoids the misfortune you're now facing.

    Our experience is that an "adequate" JTAG/SWD probe can "clear" your MCU - enabling you (then) to load that preventative program.

    Prevention trumps (lost) hours/stress of any cure...
  • Hello Jin

    Since this is a custom board, I would suggest a few things

    1. Check if the RBIAS is connected to GND with a 4.89K resistor when using external crystal on the board. This is a known errata for the device
    2. Add a small while loop in the beginning of the code before doing any complex function or application, which reads a GPIO Pin. If the Pin is High then it will remain stuck in the loop if not then it will go execute the code. This way if there is an issue, the subsequent reset of the device with Pin at High would cause it stop in a while loop allowing the device to be erased.

    Regards
    Amit
  • May we note the following:

    • Poster is (apparently) "locked out" - thus adding any loop is not possible
    • Small while loop is far more detailed w/in past sample file, "GPIO_JTAG.c" which should be universally employed to "quickly/efficiently" escape from dreaded "lock-out!"

    Inadequate promotion of "GPIO_JTAG.c" causes serious user delay/frustration, lowered morale.   (makes little sense...)

  • Hello cb1

    The intent is to first isolate the cause of the issue, so that it is not one board after another being lost for application development. Hence the suggestion on the custom board. As to what you have mentioned, one method may be to wire a LaunchPad to recover the parts on the locked out boards.

    The second part of my post was to prevent further lock outs.

    Regards
    Amit
  • Re: Second part...prevent further lock outs...

    Indeed for this poster - as had been mentioned previously.

    Better - and to advise/protect/arm FAR MORE Users - remains the ADEQUATE PROMOTION of "GPIO_JTAG.C"   Pity that cannot (still) be allowed!

  • Hi Amit,

    RBIAS is connected with GND with 4.87k, and now I am not able to even program anything.
    I will consider your suggestion of "small while loop", however in the beginning of main() all GPIO ports are configured before getting into any functions.
    I am not sure how the "GPIO pins HIGH" has to do with so-called "Lock-out" in my case.

    Now what I am suffering is I can not even program anything like a simple UARTprintf() in the beginning of main().

    Thanks,
    Jin
  • Hello Jin,

    OK. So RBIAS is not the cause of the lock out. The purpose of the GPIO Pin check is to make sure that if a board does behave again like this, you can make the CPU get stuck in the while loop with the pin held high, so that any further faulty code does not cause the device to become inaccessible.

    What was the last program that you were programming to the device? Do check if main oscillator is oscillating properly on a scope when the device hangs and if your code is using the main oscillator.Also since you mentioned USB, do you mean USB DFU or USB to JTAG?

    Regards
    Amit
  • Hi Amit,

    OSC still runs at 25Mhz although it is still "lock-out".
    USB-JTAG has been used for this project ( channel A: 245 FIFO/D2xx Direct, Ch2: RS232 UART/Virtual COM port)

    It probably was on Thursday last week as I programmed. I usually quite often change and program every day since the project is still under development.

    Thanks,
    Jin
  • Hello Jin,

    OK. So oscillator failure is also weeded out. Probably it is some setting of the device which is causing the issue. Make sure that you are using SysCtlClockFreqSet for configuring the clock frequency and not using SysCtlClockSet or SysCtlClockGet API. Also check if PC0-PC3 pins are not getting re configured.

    Regards
    Amit
  • Hi Amit,

    I use "MAP_SysCtlClockFreqSet()" and store frequency globally not to call SysCtlClockGet().

    For JTAG PC0-3
        /*
         * JTAG/SWD Configurations
         */
        ROM_GPIOPinConfigure(GPIO_PC0_TCK);
        ROM_GPIOPinConfigure(GPIO_PC1_TMS);
        ROM_GPIOPinConfigure(GPIO_PC2_TDI);
        ROM_GPIOPinConfigure(GPIO_PC3_TDO);
    
    
    For EPIO configuration of SDRAM
    
    	//
    	// EPI0S4 ~ EPI0S7: port C4 ~ 7
    	//
    	ui32Val = HWREG(GPIO_PORTC_BASE + GPIO_O_PCTL);
    	ui32Val &= 0x0000FFFF;
    	ui32Val |= 0xFFFF0000;
    	HWREG(GPIO_PORTC_BASE + GPIO_O_PCTL) = ui32Val;


    As you see, PORTC is configured in only above codes.

    Thanks,

    Jin

  • Hello Jin,

    You do not need to configure the JTAG Pins. They are pre configured at reset to be JTAG pins. I would suggest step debugging the code to the point where the debugger loses the connection to the device

    Regards
    Amit
  • Hi Amit,

    Even if JTAG pins configuration is done at reset, but configuration them again should not harm anything.
    "Pins Set Up" function that configures all GPIO pins is called in the beginning of main() in my project.

    Earlier I mentioned, I can not access the custom board. It does not matter whether using LM flash or CCS debug.

    It seems to me hardware issues  but I am not sure which one causes the issue since "lock out" takes places as adding/updating codes that has nothing to do with GPIOs.

    For example, I added

    xTaskGetTickCount();
    

    on the codes that runs well, which has not shown any "lock-out" issue, but right after programming the modified codes "lock out" occurred and does not let me access the custom board anymore. I have tried to rollback codes used to run well, but it hardly responses once "lock out" has occurred.
    Sometimes I can program after hundreds times of power cycling, but it does not always work.

    Afterward, I
    Thanks,
    Jin

  • Hello Jin,

    Can you share your code that causes the issue and the conditions to reproduce the same so that we can see what the root cause may be!

    Regards
    Amit
  • Hi Amit,


    Here is codes that are used in other modules as well.

    unsigned long StartUpTaskInit(int channels, char *cp, long csize,
    		int cbsize, char *dp, long dsize, int dbsize)
    {
    
       portTickType xTime1, xTime2;
    
       xTime1 = xTaskGetTickCount();
    
    /////////////////////////////////////////////////////////////////////////////////////
    //////////////////   do something that runs well before adding     //////////////////
    //////////////////   xTaskGetTickCount()                           //////////////////
    /////////////////////////////////////////////////////////////////////////////////////
       
       xTime2 = xTaskGetTickCount();
       xStartupExecutionTime = xTime2 - xTime1;//xStartupExecutionTime declared extern
    
       return(0);	/* reaching here means success */
    }
    
    
    


    Actually, codes for getting tick count difference are used in other modules without any issues.
    It's one of examples that I have faced with "lock out".
    If 'lock out" continues on after hundreds of power cycling, I usually gives up and re order the new board.

    However, the custom board is pricey and it could be not a good idea to keep changing the board without knowing issues.

    What I assume is that some codes or setting are "latched" and ignore any accesses such as LM Flash or CCS as well as "RESET" attached on the board

  • Hello Jin,

    Then we need to look into the specific example as to what is the cause of the lock out. Did you try to use a LaunchPad to run the unlock sequence by wiring it up to your existing "locked out" board instead of using the JTAG programmer.

    Regards
    Amit
  • Hi Amit,

    I don't have the LaunchPad, but I have got to know how to unlock through LM Flash.
    I did not try to use "Unlock" using LM Flash since it gave me "Unable to connect a target" all the time as programming.

    Now, the custom board is unlocked and get to know where the issue comes from.

    The problem was in a regulator where power source is connected with, and that did not feed a voltage source to DAC stably , which made initializing and setting DAC stuck as re/configuring initially.

    The system had stopped working without clearing or restoring port controls/configurations as configurations of DAC got stuck. Since then it could not allow any access due to unclear of ports values/controls.

    I got an idea to restore factory settings from your above comment. Thank you.

    Jin