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.

EK-TM4C1294XL: TM4C1294

Part Number: EK-TM4C1294XL

Dear TI Support,

I have a EK-TM4C1294XL evaluation kit. I downloaded SPMA072 (Serial to Ethernet Converter for TM4C129x).

I am able to compile using CCS 11.2.0. The application is running fine and I am able to open webserver.

I made a few changes to webserver to target our application.

One of the new requirements is ability to do Tiva firmware updates using webserver and Ethernet channel. I started reading TivaWare Boot Loader document (SPMU301E).

I would like to know if you have existing code that I could use or if you can give me some guidance.

I appreciate your help,

Felix V.

  • Hi Felix,

      Please refer to the example project boot_emac_flash in  C:\ti\TivaWare_C_Series-2.2.0.295\examples\boards\ek-tm4c1294xl\boot_emac_flash. boot_emac_flash is a bootloader. You will load this bootloader to the flash at 0x0 via JTAG interface. Once it is running, it will bootload the application firmware through the Ethernet port. There is also an example application firmware at C:\ti\TivaWare_C_Series-2.2.0.295\examples\boards\ek-tm4c1294xl\boot_demo_emac_flash. The bootloader will load the application firmware (boot_demo_emac_flash) to address 0x4000. Once the application is loaded, it will jump back to the bootloader when the remote host requests to update the firmware. The remote host will send a magic packet to the client (the MCU). When the magic packet is detected by the client application, it will jump to the bootloader to update the application firmware again.

  • Thanks Charles, how do I specify to download boot_emac_flash to address0x0 using CCS? Do I need a utility to send a magic packet and donwload boot_demo_emac_flash? Where can I download it from?

    Thanks for your help.

    Felix

  • Hi Felix,

      Loading boot_emac_flash via JTAG is no different than any program like the blinky example. The utility to run is the LM flash programmer (GUI based) that runs on the PC side. You can download from https://www.ti.com/tool/LMFLASHPROGRAMMER. Or you can use the command line eflash.exe from C:\ti\TivaWare_C_Series-2.2.0.295\tools\bin\eflash.exe. 

    Below are the steps you need to take.

    1. Program the TivaWare example such as enet_lwip into the MCU flash via the JTAG interface using CCS or LM flash programmer. 

    2. Run the enet_lwip and you should see the IP addressed printed out on the terminal window. You need to record this IP address. This IP address is dynamically generated by the DHCP server. This IP address needs to be used later when you run the emac_boot_flash example. The reason is that the PC running the LM flash programmer is also a BootP server as well as the TFTP server. The BootP server is static in nature. You need to manually associate a client's IP address with the client's MAC address in a fixed table in the BootP server.  Note the only purpose to run the enet_lwip is to obtain an IP address. Once the dynamic address is acquired it is leased on your network for some hours. You might be able to configure your router to lease an IP address indefinitely. Check with your IT department. 

    3. Program the emac_boot_flash into the MCU's flash via the JTAG interface. You can use the CCS or LM flash programmer to load the code. Note the emac_boot_flash starts at 0x0.

    4. Run the emac_boot_flash bootloader. The emac_boot_flash is supposed to send the BootP request now. However, since you have not yet launched the BootP server, the client will just keep sending the request. If you have a wireshark you should see the BootP requests at 1s, 2s, 4s, 8s and so on. 

    5. Open the LM flash programmer. See below. Enter the IP address that you just acquired from running the enet_lwip into the Client IP address field. Next enter the MAC address of your client. If you are using the LaunchPad you should see the MAC address on the sticker at the back of the board. What you are doing here is more like manually updating the BootP server's table of IP address and MAC address association. 

    6. Go to the Program tab and specify the boot_demo_emac_flash.bin as your application program image and hit the Program button. See below. 

    7. Give some time and you should see the download happening via the Ethernet. 

  • Thanks a lot Charles for your response. I followed the steps and it worked! Firmware was updated to boot_demo_emac_flash.

    What is not clear to me is what happens next. I wanted to update firmware again. I cycled the power. I expected boot_demo_emac_flash to be running. I didn't get the IP address shown on debug screen this time. I opened LM Flash and tried to update firmware using previous IP address but didn't work. LM Flash kept trying unsuccessfully to establish connection. I guess IP address was wrong. After installing boot_emac_flash, my goal is to download my own application, run it, open LM Flash and be able to update firmware. How can I achieve this? 

    Thanks for your support,

    Felix

  • Hi Felix,

      I just test multiple times by hitting the "Program" button on LM flash programmer and it always works for me. 

    The demo app (the boot_demo_emac_flash.bin program) will listen for a magic packet from the server.  When the magic packet is received, the firmware will transfer control to the boot loader to perform the upgrade. In the LM Flash Program, when you hit the 'Program' button it sends out the magic packet. The magic packet comprises 6 bytes of 0xAA followed by the target MAC address repeated 4 times. Once the bootloader runs again, it will send out the bootP requests. You should see that on the wireshark. The demo program is a simple blinky program with additional code to listen for the magic packet. While the demo is running, you should see the LED blinking. Once you hit the "Program" button, the LED should turn off to indicate that it has transferred the control to the bootloader. 

     The bootloader sends out bootP requests not periodically but incrementally. For example, the bootloader will first send the bootP request. If there is no reply from the server, it will wait one second to send another bootP request. If still no reply from the server, it will wait 2 seconds and then 4 seconds and then 8 seconds and so on in an incremental fashion as not to flood the network. If you wait long enough before you hit the "program" button, you may need to wait up to 64 seconds before the next bootP request will be sent. Therefore, the question is if you wait long enough after you hit the "Program" button. The best way is to immediately hit the "Program" button after you transfer control to the bootloader. If you hit the program button and wait for several minutes and there is still nothing then that is a different problem. Use the wireshark to see what is going on. 

  • After the boot_demo_emac_flash.bin is successfully programmed the first time, please use CCS memory browser to see the content on addresses starting 0x4000. Do you see the program image there? If the application is running, you will see LED blinking. 

  • Charles, the sequence of steps you wrote above works consistently. The problem is after boot_demo_emac flash is downloaded. Led blinks, so I know boot_demo-emac is running, however when I open LM Flash, led never stops blinking, in other words, execution is never transferred to boot_emac_flash.

    Felix 

  • Hi Felix,

      If LED never turns off then it means the client never received the magic packet. Do you know if you have more than one NIC (network interface card) on your PC? I'm aware that LM flash programmer has an issue that it may incorrectly send the bootP reply and magic packet to the wrong NIC. If you have more than one NICs on your PC, please disable all NIC in the Windows control panel except the one that is connected with the MCU. On my own setup, if I plug my PC directly to the network switch with a ethernet cable then it will find the correct NIC. However, if I have my PC connected to a docking station from which connect to the network then the LM flash programmer will use the NIC inside the docking station which is wrong. Please let me know if that will solve the problem. 

  • Thanks Charles, I will try this. I have two NICs. Another reason I suspect for the LED not turning off is that boot_demo_emac_flash overwrites boot_emac_flash. In memory browser, after I installed boot_demo_emac_flash, address 0x4000 doesn't appear to contain image data while 0x00 does. How do I specify in Code Composer start address? I would like to check this for boot_demo_emac_flash.

    Felix

  • Thanks Charles, I will try this. I have two NICs

    Yes, please remove one of the NICs, just keep that one that is on the same network as the MCU. 

    Another reason I suspect for the LED not turning off is that boot_demo_emac_flash overwrites boot_emac_flash. In memory browser, after I installed boot_demo_emac_flash, address 0x4000 doesn't appear to contain image data while 0x00 does.

    That is weird. If you use the stock TivaWare examples (both boot_emac_flash and boot_demo_emac_flash) then it will not overwrite the bootloader. This is what should happen.

    1. When you load boot_emac_flash the first time through JTAG, you will see bootloader at 0x0. Use memory browser to confirm that bootloader exists at 0x0 and all 0xF's at 0x4000.

    2. After the firmware is programmed, you should still see bootloader at 0x0 and the firmware at 0x4000. Again, use memory browser to confirm. LED should blink. With a power cycle, the bootloader will first run and check if there is already a valid firmware image at 0x4000. If yes, it will simply jump to the application at 0x4000. 

    3. In LM flash programmer, if you hit the "Program" button while the application is running, it sends a magic packet to the MCU firmware. Once received the magic packet, the firmware jumps to the bootloader and step 1 will repeat. In no time will it erase itself (the bootloader at 0x0). It will only update the firmware at 0x4000. Use the memory browser. If you say that application is no sitting at 0x0 and overwrite the bootloader then that is not possible in my opinion. 

    Did you at anytime modify boot_demo_emac_flash linker command file? See below. The only thing I can think of is that you modify the linker command file to start the application at 0x0 instead of 0x4000 that may inadvertently overwrite the bootloader. But this is still not possible. The reason is that the bootloader has the ENABLE_BL_UPDATE disabled by default so the region from 0x0 to 0x4000 is not allowed. See below. 

    At this moment I really don't understand if you use the examples as is (no modification whatsoever) and not able to update the firmware again. 

    #define APP_BASE 0x00004000
    #define RAM_BASE 0x20000000
    
    /* System memory map */
    
    MEMORY
    {
        /* Application stored in and executes from internal flash */
        FLASH (RX) : origin = APP_BASE, length = 0x000fc000
        /* Application uses internal RAM for data */
        SRAM (RWX) : origin = 0x20000000, length = 0x00040000
    }

    //*****************************************************************************
    //
    // Enables updates to the boot loader.  Updating the boot loader is an unsafe
    // operation since it is not fully fault tolerant (losing power to the device
    // part way through could result in the boot loader no longer being present in
    // flash).
    //
    // Depends on: None
    // Exclusive of: None
    // Requires: None
    //
    //*****************************************************************************
    //#define ENABLE_BL_UPDATE

  • Hi Charles, thanks for the information. I disabled all network cards and left the one connecting to MCU. But still I am not able to boot load. Led keeps flashing.

    I verified boot_demo_emac_flash is downloaded to 0x4000 address and shouldn't interfere with  boot_emac_flash which is downloaded to 0x0000.

    I didn't modify linker command. As I mentioned before, everything works if I follow the steps you described above. However, If I cycle the power and bring  

    LM Flash Programmer up, I cannot repeat firmware update. LM Flash Programmer keeps trying to connect. Led never goes out. It keeps flasing.

    I opened Wireshark and verified LM Flash Programmer sends magic package correctly using UDP port 9. However, it  seems that boot_demo_emac_flash doesn't detect it. 

    One thing I noticed is this: when I download boot_demo_emac_flash through ethernet  using LM Flash programmer, led blinks. Even if I power off on back on, Led blinks, which indicates download was successful. However, when I download boot_demo_emac_flash using Code composer and run it, led doesn't blink. It is like boot_demo_emac_flash gets stuck somewhere. I have not been able to detect where it stops because the debug probe is having a hard time breakpointing when running boot_demo_flash_. Have you seen this? 

    Felix 

  • Hi Felix,

      I really run out of ideas. I just try to run the example again. After the firmware is bootloaded the first time, it starts to run and the LED will blink. If I hit the 'Program' button it will just reprogram again. I could reset the board and then hit the 'Program' or power cycle the board and then hit the 'Program' and at no time am I having any problem updating the firmware. 

      Do you have the correct MAC address? I will suppose so. If not, you would not be able to bootload the first time. 

      You say you could see the bootP request sent to the client (MCU) but MCU is not detecting the magic packet. Can you show the wireshark capture?

    As I mentioned before, everything works if I follow the steps you described above. However, If I cycle the power and bring  

    LM Flash Programmer up, I cannot repeat firmware update.

    What if you don't cycle the board and instead just hit the reset button on the board and then hit the 'Program' button? 

    LM Flash Programmer keeps trying to connect. Led never goes out. It keeps flasing.

    This means the client never received the magic packet? If you believe the server sent the magic packet, please  show the wireshark capture with the packet that contains the magic packet. The magic packet comprises 6 bytes of 0xAA followed by the target MAC address repeated 4 times. Please confirm if the MAC address in the packet is matching the MAC address printed on the label on the backside of your LaunchPad. Are they matching?

    However, when I download boot_demo_emac_flash using Code composer and run it, led doesn't blink. It is like boot_demo_emac_flash gets stuck somewhere.

      The boot_demo_emac_flash starts at 0x4000. When you use CCS to load the program, it most likely erases the bootloader at 0x0. You can use the memory browser to confirm that. The reason is that by default, CCS will first erase the entire flash before it loads the new program. You need to change the setting that it will not erase the entire flash but only erase the application space starting at 0x4000. See below to not erase the entire flash. When the bootloader at 0x0 is erased, the processor will not find the stack pointer and reset vector at 0x0 and 0x4 and therefore, not able to jump to the application at 0x4000 after a power cycle. 

      

  • Hi Charles,  to answer your question:

    What if you don't cycle the board and instead just hit the reset button on the board and then hit the 'Program' button? 

    Even if I don't cycle the power and just hit "Program" button it won't work.

    I noticed the following: when I download enet_lwip and see in debug screen assigned IP address, using command prompt I can ping that address (in my case is 169.254.94.8). After I download boot_demo_emac_flash and run it, led blinks, however if I ping same IP address I get no response. This means that boot_demo_emac_flash somehow disrupted assigned IP address. This explains why LM_Flash Programmer doesn't work since this is the same IP address that I use to download again. I assume you use the same IP address, correct?

    Can you verify in your setup, when boot_demo_emac_flash is running that you can ping the originally assigned IP address?

    Felix

  • Hi Felix,

      Here is a description about magic packet from wikipedia. Magic packet is a broadcast message. In another, when the magic is sent by LM flash programmer, it does not really need to know the IP address of the destination. I'm interested to know what type of network are you having? Broadcast messages cannot work outside of LAN network. If your MCU IP address is not in the same subnet as your PC then the broadcast message will likely not work as it needs to cross the subnet and the switch on your network will block it to avoid broadcast messages. Please check with your IT department as I'm not the expert in the network systems myself. Check with your IT department if it is possible to have the DHCP server assign IP addresses for the client to be on the same subnet with your PC. See if that will resolve the problem. Another easier way may be to try the example on your home network. I think home network will be a simpler network that your PC and the MCU will be on the same subnet.  

  • Hi Charles, thanks so much for the insightful information. You were correct. The problem seems related to the type of network configuration, specifically how DHCP and subnet mask are configured in the network. I tried a laptop computer which is disconnected from the company's network and it worked right away. I can consistently update firmware. I will bring in my application now and continue testing.

    I appreciate your great support.!

    Felix

  • Charles, quick question. If I want to download my application I need to do the following:

    Re-compile my application using Code Composer and change start address to 0x4000.

    Run  enet_lwip and find out IP address

    Install boot_emac_flash at adress 0x0000

    Run boot_emac_flash and using LM_Flash programmer download my application

    Is above sequence correct?

    Thanks

    Felix

  • Hi Felix,

      Yes, that is correct.