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.

LMFLASHPROGRAMMER

Other Parts Discussed in Thread: LMFLASHPROGRAMMER, UNIFLASH, ENERGIA, EK-TM4C123GXL

I have recently designed a custom board with access to UART pins. I have a USB to Serial converter, and have downloaded the LM Flash programmer file. I successfully uploaded a .bin file to the board and it worked as expected. However, I am no longer able to flash the board. Did I miss a step? Am I supposed to flash a bootloader first? 

  • Hello Alex:

    From the Help menu in LM Flash Programmer:

    Serial (UART) Interface

    The Serial Interface is a UART serial interface. You can use a USB connection via a virtual COM port to connect the PC to the Stellaris or Tiva evaluation boards. For a custom board, you must plan for a serial (UART) interface.

    You can use the Serial (UART) Interface to program the internal flash of the Stellaris or Tiva microcontroller. The utilities from the Flash Utilities tab and Other Utilities tab are not available when the Serial (UART) Interface is selected.

    Note: The serial flash loader or a properly configured boot loader needs to be programmed into the internal flash of the microcontroller, or a device with a ROM-enabled boot loader must be selected, prior to programming with the Serial (UART) Interface. Some production Stellaris microcontrollers ship with the serial flash loader preprogrammed into the internal flash. For more information about the serial flash loader and the bootloader, or to determine which devices support ROM boot loaders, visit Stellaris on TI at:

    http://www.ti.com/stellaris_docs

    and

    http://www.ti.com/stellaris_software

     If you want the full programming capability with UART you will need to include or enable a ROM based bootloader. Alternatively, you could use JTAG with an emulator supporting the ICDI interface.

  • Chuck,

    Thank you for the response. I am still a little confused however. Is there anything I can do about my already flashed microcontroller? I'm not sure if by flashing my binary code I somehow overwrote the bootloader, rendering the chip useless for uploading new programs. Is this the case? Or am I still in luck and able to reflash a ROM bootloader?

    Thanks in advance,

    Alex

  • Alex,

    Dependent on the device, there is either a boot loader in ROM or one pre-programmed into the Flash memory. If there is one in ROM, it will run if the there is no image on the board, but, once you program it, your image application would have to enable it. If the boot loader is stored in Flash on a "virgin" device, it would have been overwritten by you binary.

    You need to be able to erase the device to be able to reprogram it. The LMFLASHPROGRAMMER UART interface does not support the erase operation. The only method to erase it is to use an ICDI emulator connected to the JTAG interface of the device.

    Alternatively, you could also use one of the commercially available XDS100v1/v2/v3 or XDS200 emulators with Uniflash to erase and program the device.

    You would have to have or add the JTAG connector to your board.

  • Chuck,

    Thank you for the help. I have since replaced the MCU with a fresh one from factory, and am able to upload my binaries to it, by offsetting the address to 0x800 so as to not overwrite the flash loader. This works great and I can reprogram the board multiple times. However, the binary that I upload doesn't seem to work as expected. In my code, I have configured the stack settings as per http://www.ti.com/lit/an/spma029/spma029.pdf 

    I suspect however, that this is where the problem resides, I just don't know how to debug it. This is the code I am using to test the device (TM4c123) compiling using the Energia software:

    #define STACK_SIZE 32
    unsigned long g_Stack[STACK_SIZE];
    unsigned long const g_ulStackTop =
    (unsigned long)g_Stack + STACK_SIZE;
    void
    ResetVector(void)
    {
    //
    // Set the stack pointer to the "top" of the stack.
    //
    __asm("ldr sp, =g_ulStackTop");

    // the setup routine runs once when you press reset:

    //
    // Other initialization before calling main...
    //
    }

    #define LED_ONE 37
    #define LED_TWO 36
    #define LED_THREE 35

    void setup() {
    // initialize the digital pin as an output.
    pinMode(LED_ONE, OUTPUT);
    pinMode(LED_TWO, OUTPUT);
    pinMode(LED_THREE, OUTPUT);
    }


    void loop(){
    digitalWrite(LED_ONE, HIGH); // turn the LED on (HIGH is the voltage level)
    digitalWrite(LED_TWO, HIGH); // turn the LED on (HIGH is the voltage level)
    digitalWrite(LED_THREE, HIGH); // turn the LED on (HIGH is the voltage level)
    delay(1000); // wait for a second
    digitalWrite(LED_ONE, LOW); // turn the LED off by making the voltage LOW
    digitalWrite(LED_TWO, LOW); // turn the LED on (HIGH is the voltage level)
    digitalWrite(LED_THREE, LOW); // turn the LED off by making the voltage LOW
    delay(1000);

    --------------------------//

    I then use sflash.exe to upload the binary as follows:

    sflash.exe blink.bin -p 0x800 -r 0x800 -c 10

    As far as I understand -p 0x800 is the starting address location (to avoid overwriting the serial flash loader) and -r configures the "RUN COMMAND" to run the application program starting at address 0x800. I receive "Successfully downloaded to devide" message, however, nothing seems to happen however, the LED's do not blink. I have ensured that the hardware is correct, and before replacing the MCU, the same code worked. 

    Any ideas?

    Thank you.

  • Hello Alex,

    What is kept at 0x0 location of flash?

    Regards
    Amit
  • As per: d1.amobbs.com/.../ourdev_553580.pdf the Serial FLash Loader, which also ends at 0x800.
  • Hello Alexander,

    By default all TM4C devices have a ROM Boot Loader. This ROM boot loader is active if the flash is erased (location 0x0 and 0x4). If you flash your application code (as in your previous post) to location 0x800 (causing 0x0 and 0x4 to remain in erased condition), then the ROM boot loader shall always be executed and not your application.

    What you require is one of the following

    (a) A serial boot loader at location 0x0 which can check for application at 0x800 and then jump to it for execution. If an update is required, the application calls the serial boot loader
    (b) The application can reside at 0x0 and then if an update is required, it configures the interface and calls the ROM Boot Loader

    Since I am not sure which TM4C123 device you are using, I would ask to look at the boot_XXX examples where boot_demo1 and boot_demo2 are application code and boot_serial is a serial flash based boot loader. They can be found under the following path in TivaWare.

    D:\ti\TivaWare_C_Series-2.1.2.111\examples\boards\dk-tm4c123g

    Also please do clarify how you intent to call the Boot Loader (switch press, special command over serial, etc...)

    Regards
    Amit
  • Amit,

    Thank you for the help. I want to make sure that I am following correctly, can you verify if my procedure is correct:

    1. Flash the boot_serial.bin to my MCU at flash location 0x0, since I intend to communicate over UART
    2. Write application code that accommodates JumpToBootLoader(void) in some manner (push button, serial command, etc.)
    3. Flash my application binary with register offset equals to APP_START_ADDRESS = 0x2800, and execute code from there

    With those in place, I should be able to reflash to MCU by handing execution over to the bootloader "JumpToBootLoader()". 

    Please let me know if you see any flaws in my procedure.

    Thank you,

    Alex

  • Hello Alex,

    That is correct.

    Regards
    Amit
  • Amit,

    I am not sure what happened but it doesn't seem to work. I flashed the boot_serial.bin to the board using LM Flash, starting at 0x0. When I try to program my application code with an offset using the sflash.exe application, I can't communicate with the board. I try to reflash anything using LM FLash and get the same error I did with my first attempt, not being able to "Synchronize with board". I disabled autobaud and have set the Baud to be 115200 as was set in the bl_config.h file.

    My understanding was that with the boot_serial.bin flashed to 0x0, I would still be able to reprogram it over UART.

    Any ideas?
  • Hello Alex,

    Did you make the change for the device type, since the example bin is for a DK-TM4C123G evaluation board which may be different from the board you have and the device you have. You need to make sure that the crystal frequency parameters are correctly configured.

    Regards
    Amit
  • Amit,

    I followed the bl_config.h file that was present in the boot_serial example code. I made sure to select the right frequency (16MHz), and aside from that, I do not see anything else that would be board or chip exclusive. The chip I am using specifically is thetm4c123gh6pmi.

    - Alex

  • Hello Alex

    Can you please share your project? I can try the same on a EK-TM4C123GXL board tomorrow. Also please let me know which TivaWare version you are using.

    Regards
    Amit
  • Amit,

    I simply flashed the prebuilt boot_serial.bin from the example boot_serial program. I am unable to compile a new binary after switching boards from the EK-TM4C123GXL to the TM4C123PMI, with several errors arising. Is that what I am supposed to do? Compile the boot_serial program with my specific chip selected?

    Thanks,

    Alex