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.

TM4C129ENCPDT: How to clear flash of TM4C129ENCPDT using UART0?

Part Number: TM4C129ENCPDT
Other Parts Discussed in Thread: UNIFLASH, EK-TM4C1294XL, TM4C1294NCPDT, TM4C123GH6PM

Hi,

I have a new TM4C129ENCPDT processor, to which I successfully flashed the blinky code via UART0 using LM Flash Programmer utility.

Now, I want to again flash a new code, but I am facing an error reprogramming the code using LM Flash (error is : Failed to synchronize Baud rate ). I think that the problem is that: for the first time, when I was flashing blinky code, ROM bootloader was invoked (it checked for location 0x04 and it was empty) and the code was flashed using UART0 . But now there is already something present in the flash, due to which ROM bootloader is not working, hence baud rate is not synchronized.

So every time, I want to flash the code using UART0 via ROM bootloader, I will have to erase flash, but I am unable to find any utility to do it.

I tried UNIFLASH, but the board is not getting recognised.

  • Hi Apoorv,

     What you need is to have program the EN bit of the BOOTCFG register cleared. The ROM bootloader checks either the address location at 0x4 equal to 0xFFFFFFFF or the BOOTCFG.EN is 0. If either is true then it will  load your application again. Please refer to the datasheet. Below is the excerpt. Please make sure your commit the BOOTCFG register for it to take effect after power cycle. 

    Register 68: Boot Configuration (BOOTCFG), offset 0x1D0
    Note: Offset is relative to System Control base address of 0x400F.E000.
    Note: The Boot Configuration (BOOTCFG) register requires a POR before the committed
    changes take effect.
    This register is not written directly, but instead uses the FMD register as explained in “Non-Volatile
    Register Programming-- Flash Memory Resident Registers” on page 613. When this register is
    committed, the new value cannot be read back until after the power cycle. This register provides
    configuration of a GPIO pin to enable the ROM Boot Loader as well as a write-once mechanism to
    disable external debugger access to the device. At reset, the user has the opportunity to direct the
    core to execute the ROM Boot Loader or the application in Flash memory by using any GPIO signal
    from Ports A through H as configured by the bits in this register. At reset, the following sequence is
    performed:
    1. The BOOTCFG register is read. If the EN bit is clear, the ROM Boot Loader is executed.
    2. In the ROM Boot Loader, the status of the specified GPIO pin is compared with the specified
    polarity. If the status matches the specified polarity, the ROM is mapped to address 0x0000.0000
    and execution continues out of the ROM Boot Loader.
    3. If the EN bit is set or the status doesn't match the specified polarity, the data at address
    0x0000.0004 is read, and if the data at this address is 0xFFFF.FFFF, the ROM is mapped to
    address 0x0000.0000 and execution continues out of the ROM Boot Loader.
    4. If there is data at address 0x0000.0004 that is not 0xFFFF.FFFF, the stack pointer (SP) is loaded
    from Flash memory at address 0x0000.0000 and the program counter (PC) is loaded from
    address 0x0000.0004. The user application begins executing.

  • Hi Charles,

    Thanks for the answer, but I am not able to flash any code in the board since I don't have any JTAG pins or external encoder like in the Launchpad. and hence I can't configure the bootconfig register. So, the code can only be flashed by ROM bootloader via UART0 since that is the only functionality available in the designed board. But i am not able to flash the code via UART0 using LM Flash programmer, the reason which I think is because the flash is not empty now and hence ROM based bootloader is not running(ROM based bootloader runs if flash is empty or we write to bootconfig register).

    So if I am correct, my problem is reduced to erasing the flash using some external utility or hardware. But I can't erase flash using UNIFLASH also since the device is not getting detected.

    Regards,
    Apoorv
  • Hi Apoorv,

    If you don't have JTAG interface on your board, how do you even debug your application? I think it is not a good idea to build your board without any debug capability.

    You might want to explore the flash based bootloader now. There are flash based bootloader examples using UART in Tivaware. You will first erase the flash. For the first time you use the ROM bootloader to load the flash based bootloader. The flash based bootloader is a small program only. Once the flash based UART bootloader is resident in the flash, it can interact with the LM programmer to load your application image. The flash based bootloader must be permanently present in the flash. Check out the TM4C Bootloader User Guide for details.
  • Hi,

    I have already loaded the blinky program and am not able to clear the flash to load the flash based bootloader using ROM based bootloader. Is there any way to clear the flash?
  • Hi,
    There is no solution that I'm aware of. You should strongly consider adding a JTAG interface into your design.
  • Hi,

    Is there no way of pulling pins using hardware to get the ROM based bootloader running.

  • Yes, there is - if you are willing to become a LQFP surgeon, you can solder tiny jumpers out of the jtag pins of your MCU.
    Then it's a good idea to hot-glue those wires so that they don't shorten or get easily pulled out...
    The work involved is probably more than redesigning the board and get a new spin built... ;)
  • Charles Tsai said:
    If you don't have JTAG interface on your board, how do you even debug your application?

    It's not necessary to have JTAG to debug a program. I do agree that it's foolish not to have some method of programming the micro that does not depend on the internal SW state, and thus agree that JTAG is essential. I'd go so far as to say that those pins should not be re-purposed but rather dedicated to JTAG only.

    Robert

  • As the two (before me) have noted - your (likely) harvesting of either the JTAG or SWD pins - did NOT come w/out high cost!

    Prior to designing a pcb - "ALL such issues" should be "test/verified" - to determine if your (proposed) method (can) work...   And its - "degree of difficulty.)

    Should you have "re-purposed" those JTAG pins - it may be "easier" to solder to their termination point, or trace vias, or (if you are very lucky) connect to those critical pins via your board's header!    (assumes you routed/brought out those JTAG signals for use, "off-board.")

    The most effective strategy firm/I have found is to,  "ALWAYS - route JTAG (including 4 pull-up Rs) to a 0.050" pitch, 10 pin header."    During development you'll "insert & use that header" - once you've mastered some (different, optional technique to program) you'll "DNF" (Do not Fill) that header.

  • Hi,

    I added jtag pins and am using the Stellaris ICDI on EK-TM4C1294XL to Debug my Off-Board TM4C129ENCPDT. I was able to flash the code once using LM Flash Programmer, but sincr then I am always getting the error: Unable to initialise target-0. I also tried unlocking the device. but still I am getting the same error. HOw can I flash the code once more and what can be the mistake?

    I used the foll. link: http://www.ti.com/lit/an/spma075/spma075.pdf

    Also, When i connect to the TM4C1294NCPDT in the eval kit, I am able to flash the code, but as soon as I connect it to the custom made TM4129ENCPDT, I get the error : Unable to initialize target-0. Also, I am getting data in the TDO pins of microcontroller just before I get the error.

    What can be the reason for the error, is it because I have no flash based bootloader?

  • Hi,

      Do you see the Stellaris In-Circuit Debug Interface under the Windows Device Manager? With your custom board disconnected from the LaunchPad can you connect to your LaunchPad and program code into the MCU? Can you also try another PC machine? We need to isolate the problem. 

  • Hi,
    Yes, I could see the Stellaris In-Circuit Debug interface under the windows boot manager in both the cases when I connected it to the external TM4C129ENCPDT and the internal TM4C1294NCPDT.

    If I remove the custom board and short the JTAG jumper configurations with the TM4C1294NCPDT present in the EK-TM4C1294XL Eval kit, I am able to program code in the MCU.

    I was able to flash code once to the external TM4C129ENCPDT using JTAG but after that I started getting the error.

    Regards,
    Apoorv
  • I understand you soldered the jtag traces into the proper pins, correct?
    Were those N/C or being used by some other circuits on your board?
    There are lots of things that can be wrong, including the soldering itself... But other ideas:
    - Did you remove the power from the target mcu on the launchpad used as ICDI?
    - Is there a proper WPU on the reset line?
    - If so, then the last resource: do you have WPU on the other lines? I have not needed such, but some colleagues here defend their benefits.
    - Haven't you fried or shorted you mcu while trying to do the surgery?
    Bruno
  • Hi,
    On top of Bruno's suggestions please also use the scope to check the TDO coming from your custom board? Is it alive or remain same level?
  • Hi,
    1.) I have checked using scope that the TDO pin gives signal until LM Flash Programmer gives the error.
    2.) Do I need to write a bootloader for JTAG communication?
    3.) I powered the Launchpad with a power supply and the external IC with a different power supply. I think that this might have caused the problem.

    Is it a hardware issue or I am not using LM flash programmer correctly or do I have to write a bootloaader?
  • Hi,
    What was the last program you flashed successfully into the target MCU? You said you were able to flash your custom board once via the external LaunchPad as a debug probe. Is that program still running?
  • Hi,
    It is not working. I am getting TDO signal for a very small amount of time. Does'nt that mean that the MCU is responding but due to some synchronization issue, I am facing this error ? Also, I am using TM4C123GH6PM as programmer to program TM4C1294NCPDT (successful) and TM4C129ENCPDT (failed). Can there be some issue in its programming.

    I am using the following configuration in LM Flash Programmer:

  • I also checked that the crystal is not working of the external board.
  • You meant the crystal on the custom board is not working? If this is the case then there is no clock provided to the MCU. Without system clock the emulator is unable to communicate with the MCU albeit the TCK is provide is provided to the JTAG interface. Have you found out why the crystal is not working?
  • Hi,

    I finally found out the problem. When I flash the blinky code, I am able to program multiple times via JTAG. But when I flash my code, the jtag pins get locked. Then as soon as I unlock the device using LM Flash, I am able to program using JTAG again. So, is there any problem in my code which is locking the JTAG pins? I have not used the pins PC0. PC1, PC2 and PC3 in the code. Also, my code uses Ethernet and can the JTAG pins be locked due to some problem in the hardware?

  • It appears you are incorrectly configuring your system clock.
    Triple-check the clock settings, and make sure no other "inherited library" touches those settings somewhere else.
    Bruno
  • Hi,
    Two ways you may lock out the MCU from debug, one is the repurposing the JTAG pins for GPIO and the other is the dead system clock both of which can be caused by software. You already mentioned you didn't reconfigure JTAG pins for GPIO and earlier in your post you mentioned about the bad OSC. So the problem is most likely due to clocking. You can monitor DIVSCLK pin (PQ4) from the MCU. The DIVSCLK is a divided reference clock output based on a selected clock source. You may also modify your code to output a simple PWM which is based on the timebase. If you lose the PWM then it also indicates the clock is somehow lost. Perhaps you already have some PWM in your application. Are they functioning? This is what I was asking last time what was the last code you successfully loaded into the MCU and if it was still running?
    One more thing you can check is if your application wrote to the BOOCFG register to disable debug capability.
  • Hi,
    I have configured system clock as 120MHz. The following code snippet is used to configure system clock. No other library touches these settings.

    //
    // Run from the PLL at configCPU_CLOCK_HZ MHz.
    //
    g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
    SYSCTL_OSC_MAIN | SYSCTL_USE_PLL |
    SYSCTL_CFG_VCO_480),
    configCPU_CLOCK_HZ);

    Also, I am able to program the same code with the Launchpad's internal MCU :TM4C1294NCPDT without any problem. But when I am using the external custom made board: TM4C129ENCPDT, JTAG pins are getting locked.
  • Hi,
    I tried flashing the example enet_lwip code but am facing the same error.
    I found out that configuring the clock is creating the problem. So, I added the configure clock code in the blinky example program which was running successfully and I started facing the same problem in the blinky program also.
    I am adding the following code snippet for configuring clock:

    #define configCPU_CLOCK_HZ ( ( unsigned long ) 120000000 )

    g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
    SYSCTL_OSC_MAIN | SYSCTL_USE_PLL |
    SYSCTL_CFG_VCO_480),
    configCPU_CLOCK_HZ);

    This is the same code which is used in all example programs. What can be the reason that my device is getting locked?
  • Hi,

      I don't spot anything wrong with the code. Which TivaWare version do you have? Can you try the latest TivaWare version if you are not using the latest version? Can you also try without the MAP_ prefix and see if it makes a difference?

  • Hi,

    I am able to flash the code now. There was some problem with the external 25 MHz crystal. But I am facing 1 more problem. I am not getting Ethernet detected on my laptop from the custom board.

    The code is similar to lwip example. It is returning 1 because I am unable to read the MAC address registers.The same code works correctly in TM4C1294XL (microcontroller inside the Launchpad). The code snippet is::

    //
    // Get the MAC address from the user registers.
    //
    MAP_FlashUserGet(&ui32User0, &ui32User1);
    if((ui32User0 == 0xffffffff) || (ui32User1 == 0xffffffff))
    {
    return(1);
    }

    I have 2 doubts:

    1.) Will Ethernet directly be detected on the laptop as soon as custom board is powered.

    2.) Is this because of some issue in hardware that I am not able to read the Ethernet specific registers.

    3.) Is it possible that there is no MAC address in the custom TM4C129EXL board?

    If not any of these, what can be the problem?

  • Could you post this question on a separate thread, please? This new question has nothing to do with the title.
    The cost per thread here remains the same! ;)
    Bruno
  • Beyond, "Cost/thread" - where IS the dramamine?      (remedy for "motion-sickness" as...poster faces (just) ONE MORE PROBLEM!)     (that unlikely)

    This thread REMAINS UNCLEAR as to whether poster's "home-brew pcb" ever achieved, "Clear Flash via UART0."     (which WAS its purported goal!)

  • Hi,
    Only LaunchPad is pre-programmed with the MAC address. Your customer board will not have the MAC address. For a custom design the MAC address must come from the pool of allocated MAC address to the organization/company. Please create new threads for new questions. Thanks.