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: Static IP assignment using Ethernet Boot

Part Number: EK-TM4C1294XL

Hi,

I have loaded Ethernet bootloader (boot_emac_flash) to MCU (TM4C1294NCPDTI), and I am able to load the program (boot_demo_emac_flash) using Ethernet Boot. In the default demo program, a dynamic IP (DHCP) should be obtained. However, I have modified the program so that a static IP should be assigned. But when I ping the device with the assigned Static IP, the request times out. What could be the problem?

The modification is as follows:

lwIPInit(g_ui32SysClockFreq, pui8MACAddr, (192u << 24) | (168u << 16) | (1u << 8) | (13u),
                                                                        (255u << 24) | (255u << 16) | (255u << 8) | (0u),
                                                                        (192u << 24) | (168u << 16) | (1u << 8) | (11u), IPADDR_USE_STATIC);

#define       LWIP_AUTOIP                     0

#define       LWIP_DHCP                       0

Thanks in advance.

  • Hi,

      Not sure what is wrong. 

     First of all, I assume you define the LWIP_AUTOIP and LWIP_DHCP in the lwipopts.h file, not below or after the call to LwIPInit(), correct?  First look at the lwiplib.c file and see IPADDR_USE_STATIC is actually selected. 

      For your gateway can you change to 255.255.255.0 and see if that works. You currently have 192.168.1.11. 

  • Hi Charles,

    Sorry for the inconvenience. Yes, I made changes to LWIP_AUTOIP and LWIP_DHCP definitions in the lwipopts.h file. 

     IPADDR_USE_STATIC is also selected in the lwiplib.c file. 

    After changing the gateway to 255.255.255.0, it doesn't work either.

    Before loading the bootloader, I load enet_lwip to MCU, the device gets a dynamic IP address shown on the terminal. After loading the bootloader, then the demo program (with DHCP enabled, the default case), I cannot ping either. Does the bootloader take control over ethernet and not allow for the firmware to utilize it? If it is, is there any possible modification that I can make to the bootloader?

    Thanks,

    Ravan.

  • Hi Ravan,

      Is it that you can't ping the address or the boot_demo_emac_flash (after it was changed to static address) will not run correctly?

     I just modified boot_demo_emac_flash to use static address. I first set both the LWIP_AUTOIP and LWIP_DHCP to 0. In the LwIPInit() I use my own static address. I don't have any problem for the boot_demo_emac_flash to jump back to the bootloader and then update the application again. I did for multiple times. 

      See below my IP address and MAC address. Yours will be different. 

  • Hi Charles,

    boot_demo_emac_flash is loaded without a problem. The problem is I cannot ping the address. In the boot_demo_emac_flash I made the changes as you stated, but when I use the ping command in CMD, the request times out.

    After loading boot_demo_emac_flash (with static IP modifications), I entered Client IP as the static IP that I assigned (192.168.1.13 in my case) and Client MAC address, it loads the program without a problem.
    Then I tried to load programs with eth boot with other client IPs in the same subnet(192.168.1.15(16,17,18,19..)), what happens is it again loads the program. The problem is that since the switch remembers the MAC address, as long as the Client IP is in the same subnet (in my case it is 192.168.1.0/24), the packet is forwarded to Tiva. This makes it impossible to understand whether an IP is assigned.

    here the client IP is 192.168.1.199, and it works although that IP is not existing in my network.

    here the client IP is 192.168.1.33.

    here the client IP is 192.168.1.30.

    As can be observed, it has nothing to do with Client IP as long as it is in my subnet. I also changed the MAC address in LM Flash Programmer, it cannot load the program.

    What I just want is to assign a unique IP to the device.

    Regards.

  • The problem is I cannot ping the address.

    Hi Ravin,

    Ping uses broadcast packets, ICMP echo must be loaded & enabled via LWIP v1.4.1 or newer. Seemingly after update firmware exits with SWPOR will Tiva client be able to respond to static ping request with ICMP echo being enabled lwipopts.h. Far as I'm aware UIP does not have ICMP echo ability.

    Regards

  • Hi GI,

      Thanks for your comments. I was thinking along the same line that uIP which is used by the bootloader does not have ICMP to support network diagnostic. I also just tried another experiment.

      - I first modified the TivaWare enet_tcpecho_server for static address.  

      - I load the boot_emac_flash (bootloader) using JTAG

      - I then let the boot_emac_flash load the application enet_tcpecho_server (with static address) through the Ethernet port.

      - Once the application is loaded and running, the ping to the static address is working. 

      Since the enet_tcpecho_server doesn't jump back to the bootloader, it is running with the LwIP stack. I think this should confirm your theory that uIP in the bootloader does not support ICMP. Bootloader is meant for small memory footprint. This is why uIP is chosen for the bootloader rather than the full-fledge LwIP. 

      

  • Dear Charles and GI, 

    Many thanks, the problem is resolved.

    Regards.

  • Hi Charles,

    Sorry, I am again bothering you:)

    I have done the same thing as you did, but the result is not like yours.

    - I first modified the TivaWare enet_tcpecho_server for a static address.  

    - I load the boot_emac_flash (bootloader) using JTAG

    - I then let the boot_emac_flash load the application enet_tcpecho_server (with static address) through the Ethernet port.

     - Once the application is loaded and running, the ping to the static address is not working in my case. Even the LED should turn on/off on the board, but no one turns on.(1)

    My intention is to add the echo feature in boot_demo_emac_flash program. Previously I assigned a static IP to the board in boot_demo_emac_flash, now I want to add a feature to connect with my pc through ethernet.

    I added codes to boot_demo_emac_flash in order to initialize TCP PCB, bind to a port, listen, and accept the same as in enet_tcpecho_server. I then let the boot_emac_flash load the application boot_demo_emac_flash. However, it did not work. Whenever I connect to IP address (with Tera term), the program goes to receive callback and gets stuck there. (2)

    Then I added codes to enet_tcpecho_server to get the software update (SoftwareUpdateInit, SoftwareUpdateBegin) the same as in boot_demo_emac_flash. I let the boot_emac_flash load the application enet_tcpecho_server.(3)

    The result of (3) is no different than that of (1). 

    However, when I loaded the program in (3) through JTAG, the program works.

    Also when I add UARTprintf() function for debugging purposes (from uartstdio.h library), and load the program through the Ethernet port successfully (after loading boot_emac_flash via JTAG), the program gets stuck.

    What could be the problem with ethernet boot?

    Thanks in advance.

  • Hi,

      When you modify enet_tcpecho_server with static address, did you also modify the linker command file to start the application at 0x4000? Please see below linker command file. As you can see the modified enet_tcpecho_server not only has its IP address changed to static but also in the linker command file where the application is relocated to 0x4000. 

    #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
    }
    
    /* Section allocation in memory */
    
    SECTIONS
    {
        .intvecs:   > APP_BASE
        .text   :   > FLASH
        .const  :   > FLASH
        .cinit  :   > FLASH
        .pinit  :   > FLASH
        .init_array : > FLASH
    
        .vtable :   > RAM_BASE
        .data   :   > SRAM
        .bss    :   > SRAM
        .sysmem :   > SRAM
        .stack  :   > SRAM
    #ifdef  __TI_COMPILER_VERSION__
    #if     __TI_COMPILER_VERSION__ >= 15009000
        .TI.ramfunc : {} load=FLASH, run=SRAM, table(BINIT)
    #endif
    #endif
    }
    
    __STACK_TOP = __stack + 2048;
    

    The boot_emac_flash (the bootloader) will start at 0x0. In the bl_config.h file, it specifies 0x4000 as the address to program the application to. See below bl_config.h. Therefore, if you didn't change the application starting address in the linker command meaning the APP_BASE is still at 0x0 then it will not work. You will be asking the bootloader to program the application to the same address where the bootloader is located. The bl_config.h has the #define ENABLE_BL_UPDATE commented out. This mean it will not program application to 0x0 to overwrite the bootloader. 

    //*****************************************************************************
    //
    // The starting address of the application.  This must be a multiple of 1024
    // bytes (making it aligned to a page boundary).  A vector table is expected at
    // this location, and the perceived validity of the vector table (stack located
    // in SRAM, reset vector located in flash) is used as an indication of the
    // validity of the application image.
    //
    // The flash image of the boot loader must not be larger than this value.
    //
    // Depends on: None
    // Exclusive of: None
    // Requires: None
    //
    //*****************************************************************************
    #define APP_START_ADDRESS       0x00004000
    
    //*****************************************************************************
    //
    // The address at which the application locates its exception vector table.
    // This must be a multiple of 1024 bytes (making it aligned to a page
    // boundary).  Typically, an application will start with its vector table and
    // this value should be set to APP_START_ADDRESS.  This option is provided to
    // cater for applications which run from external memory which may not be
    // accessible by the NVIC (the vector table offset register is only 30 bits
    // long).
    //
    // Depends on: None
    // Exclusive of: None
    // Requires: None
    //
    //*****************************************************************************
    #define VTABLE_START_ADDRESS    0x00004000

    If this is not your problem, I really don't know what happened. Again, let me repeat what I did and it is working for me. 

    - I first modified the TivaWare enet_tcpecho_server for a static address.  Make sure the enet_tcpecho_server is relocated to 0x4000 in the linker command file. 

    - I load the boot_emac_flash (bootloader) using JTAG. The boot_emac_flash starts at 0x0. The bl_config.h has APP_START_ADDRESS and VTABLE_START_ADDRESS at 0x4000.

    - I then let the boot_emac_flash load the application enet_tcpecho_server (with static address) through the Ethernet port. 

     - After the application is programmed through ethernet port, you might need to do a reset. You should see LEDs blinking. 

     - Ping the board with whatever static address you use to build enet_tcpecho_server. 

     I will also suggest you do another experiment. 

      - build enet_tcpecho_server with static address but with the application starting at 0x0. 

      - use the JTAG to load the application at 0x0. 

      - Run the application.

      - Ping the board at the specified static address. 

      Does it work? This is to make sure the problem you see is not related to the bootloader but rather maybe your local network issue. In any case, you should use Wireshark to capture traffics between your PC and the board to debug the problem.

  • Dear  Charles,

    Thanks for the detailed explanation.

    I have several times loaded enet_tcpecho_server (base address 0x0) by using JTAG, it works very well.

    I have not made the necessary modification in APP_BASE in enet_tcpecho_server program. I will also check this and note the result here.

    This, at last, is the solution to the problem (1). Do you have any suggestions for problems (2) or (3)?

    I just want to add the TCP echo feature in boot_demo_emac_flash program. I want the program (to be loaded through Ethernet port) to have ethernet connection and receive/write functionality. 

    Best regards. 

  • Hi Ravan,

      I think it is best for you to resolve (1) before moving to (2) and (3). For (1) please change the APP_BASE to 0x4000 for the enet_tcpecho_server program and let the emac_boot_flash load the application through Ethernet port. Once running, the enet_tcpecho_server is a echo program already. You can use tera term to talk to your specified static IP address. Note that enet_tcpecho_server is a server application, not a client application. If you can resolve (1) then the application itself should resolve your (2) (3) by itself. 

  • Hi Charles,

    Thanks for your support, after modifying APP_BASE to 0x00004000, the problem is now resolved. The program is can be loaded by boot_emac_flash through the ethernet port. The program runs without any problem. 

    Now I want to add the functionality to the program so that it can be upgraded through the Ethernet port. For this, I added software SoftwareUpdateRequestCallback() as in boot_demo_emac_flash and SoftwareUpdateInit(SoftwareUpdateRequestCallback); line of code.

     while(!g_bFirmwareUpdate)
        {
            //
            // Wait till the SysTick Interrupt indicates to change the state of the
            // LED.
            //
            while(g_bLED == false)
            {
            }
    
            //
            // Clear the flag.
            //
            g_bLED = false;
    
            //
            // Toggle the LED.
            //
            MAP_GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_1,
                             (MAP_GPIOPinRead(GPIO_PORTN_BASE, GPIO_PIN_1) ^
                              GPIO_PIN_1));
        }
        SoftwareUpdateBegin(g_ui32SysClock);

    I also changed the loop condition and added SoftwareUpdateBegin() function which is the same as in boot_demo_emac_flash. However, I notice that the program never goes to SoftwareUpdateRequestCallback() when I press the program button on the LM Flash Programmer. I also notice nothing related to the BOOTP boot request and TFTP read request in Wireshark.

    How can I attack this problem?

    Thanks in advance.

  • Hi,

      Please refer to the boot_demo_emac_flash.c example code. I think you miss the call to SoftwareUpdateInit(). In boot_demo_emac_flash.c there is a call to  SoftwareUpdateInit(SoftwareUpdateRequestCallback) that will setup the callback. 

  • Hi,

    Exactly, I have included SoftwareUpdateInit(SoftwareUpdateRequestCallback)

  • Hi,

      Why don't you try this attached example. It is a tcpecho server application that uses static address and has the APP_BASE at 0x4000. This application will call SoftwareUpdateInit to set up UDP connection to wait for the magic packet from the BOOTP/TFTP server. My static address 192.168.254.136. You need to modify your own static address. 

      I tries this example and I can send message to the static IP address and also ping the device with no problem. When magic packet is received from LM flash programmer, it will jump to the bootloader and reload the application again. I tried it multiple times and have not issue. 

    enet_tcpecho_server_static_ip.zip

  • Hi Charles,

    Thanks for your great help, I will check this project and note the result here.

    Kindest regards.

  • Dear Charles,

    Sorry for the late reply.

    Thanks for your efforts and time. As you mentioned, this project works properly.

    Best.