EK-TM4C1294XL: How to divert SendBOOTPRequest

Part Number: EK-TM4C1294XL

Tool/software:

I am planning to reuse the BOOTP and TFTP functionalities from the EMACbootloader code in the code I am developing.When I directly reuse the BOOTPThread function and execute the SendBOOTPRequest function, it enters the FaultISR at the line pui8Packet[ui32Idx] = 0;
I suspect that modifying the value of uip_appdata, which is declared in uip.h, is causing the fault. Is there a way to properly initialize uip_appdata
Also, I tried allocating memory at the beginning of SendBOOTPRequest() with uip_appdata = (uint8_t _)malloc(sizeof(uint8_t) _ UIP_APPDATA_SIZE);, but the behavior did not change and it still enters the fault.

static void
SendBOOTPRequest(void)
{

uint8_t *pui8Packet = (uint8_t *)uip_appdata;

tBOOTPPacket *psBOOTP = (tBOOTPPacket *)uip_appdata;

uint32_t ui32Idx;

//
// Zero fill the BOOTP request packet.
//
for(ui32Idx = 0; ui32Idx < sizeof(tBOOTPPacket); ui32Idx++)
{
pui8Packet[ui32Idx] = 0;
}

  • Hi Muneto-san,

      Can you please refer to the:

      uip.h and uip.c files in the C:\ti\TivaWare_C_Series-2.2.0.295\third_party\uip-1.0\uip directory 

      dhcpc.c in C:\ti\TivaWare_C_Series-2.2.0.295\third_party\uip-1.0\apps\dhcpc directory

    Here you will find how uip_data is declared (in uip.h file) and how it is used in dhcpc.c file. Please also refer to the description in uip.c file. See below. 

    /*
    * uIP is a small implementation of the IP, UDP and TCP protocols (as
    * well as some basic ICMP stuff). The implementation couples the IP,
    * UDP, TCP and the application layers very tightly. To keep the size
    * of the compiled code down, this code frequently uses the goto
    * statement. While it would be possible to break the uip_process()
    * function into many smaller functions, this would increase the code
    * size because of the overhead of parameter passing and the fact that
    * the optimizer would not be as efficient.
    *
    * The principle is that we have a small buffer, called the uip_buf,
    * in which the device driver puts an incoming packet. The TCP/IP
    * stack parses the headers in the packet, and calls the
    * application. If the remote host has sent data to the application,
    * this data is present in the uip_buf and the application read the
    * data from there. It is up to the application to put this data into
    * a byte stream if needed. The application will not be fed with data
    * that is out of sequence.
    *
    * If the application wishes to send data to the peer, it should put
    * its data into the uip_buf. The uip_appdata pointer points to the
    * first available byte. The TCP/IP stack will calculate the
    * checksums, and fill in the necessary header fields and finally send
    * the packet back to the peer.
    */

    Snippet of how uip_appdata is declared.

    void *uip_appdata; /* The uip_appdata pointer points to
    application data. */

    Snippet of how uip_appdata is assigned and used in the dhcpc.c file for sending a DISCOVERY packet. 

    /*---------------------------------------------------------------------------*/
    static void
    send_discover(void)
    {
    u8_t *end;
    struct dhcp_msg *m = (struct dhcp_msg *)uip_appdata;

    create_msg(m);

    end = add_msg_type(&m->options[4], DHCPDISCOVER);
    end = add_req_options(end);
    end = add_end(end);

    uip_send(uip_appdata, end - (u8_t *)uip_appdata);
    }

    You can also find examples on how uip_appdata is used to send TFTP packets in C:\ti\TivaWare_C_Series-2.2.0.295\third_party\uip-1.0\apps\telnetd\telnetd.c file. 

    static void
    senddata(void)
    {
    static char *bufptr, *lineptr;
    static int buflen, linelen;

    bufptr = uip_appdata;
    buflen = 0;
    for(s.numsent = 0; s.numsent < TELNETD_CONF_NUMLINES &&
    s.lines[s.numsent] != NULL ; ++s.numsent) {
    lineptr = s.lines[s.numsent];
    linelen = strlen(lineptr);
    if(linelen > TELNETD_CONF_LINELEN) {
    linelen = TELNETD_CONF_LINELEN;
    }
    if(buflen + linelen < uip_mss()) {
    memcpy(bufptr, lineptr, linelen);
    bufptr += linelen;
    buflen += linelen;
    } else {
    break;
    }
    }
    uip_send(uip_appdata, buflen);