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.

TM4C1294KCPDT: Trouble with loading and reading web page & its content from SD card

Part Number: TM4C1294KCPDT

Hello Everyone,

I am using TM4C1294KCPDT and TivaWare_C_Series-2.1.2.111 for my application. I am trying to implement web server application using lwip httpd (no RTOS) from SD card (i.e. all html, javascript, jpg files are stored in sd card). (I have referred sample code: C:\ti\TivaWare_C_Series-2.1.2.111\examples\boards\dk-tm4c129x\enet_lwip).

By entering IP address of the device from web browser, the "index.html" page of my device should load with its data. My "index.html" page size is approx 70KB and javascript file size is approx. 40KB.

When I try to load the web page, most of the time it fails to load web page and its contents. I tried to debug the web page by going on 'Inspect' option of web page; there it shows me error: "Invalid or unexpected token" in javascript file. It actually make some invalid token (which doesn't exists in my javascript file) while receiving data from server. And every time it gives different error for different token in different files(html/javascript).

I tried to implement web server in my Flash/ROM, it works properly but in case of sd card web server, it failed.

Any help would be appreciated.

  • Hi,

      There is not enough information to pinpoint the cause of the problem. I will suggest you use wireshark to examine the traffic on the Ethernet. That will help you debug the problem. Is there any reason why you want to store your data on the SD card rather than the on-chip memory. I suppose you use SD card with SPI interface, correct? Reading the html and the jpeg image data serially from SPI certainly is much slower than reading from the on-chip memory. I'm not surprised some bottleneck is reached from time to time. What SPI frequency are you operating with? What happens if you increase the SPI clock frequency?

  • Hi Charles,

    Is there any reason why you want to store your data on the SD card rather than the on-chip memory.

    --> Because in future application, web server (i.e. html pages/ javascript files/ image files, etc) size is more which may cause memory issue in case of Flash memory.

    I suppose you use SD card with SPI interface, correct?

    --> Yes. 

    What SPI frequency are you operating with? What happens if you increase the SPI clock frequency?

    --> I tried with 400KB, 1MHz, 2MHz freq. but for all result is same.

    I tried to examine using wireshark: below are the results:

    case-1: 

    error: Uncaught SyntaxError: Unexpected string (index):1542

    when i checked on given line in 'index.html' file it was something like this:  document.getElementById(cityName).style.displayt" tabindex="10">Enable

    But actual line is like this: document.getElementById(cityName).style.display = "block";

    case-2:

    error: Uncaught TypeError: Cannot set property 'value' of null Pscripts.js:139 

    when i checked on given line in 'jscript.js' file it was like this: document.getElementById("tSDCFile").value = spData[index++];

    and the value at the time of data load is null in this variable 'spData[index++]'.

    case-3:

    error: Uncaught SyntaxError: Invalid or unexpected token Pscripts.js:28

    when i checked on given line in 'jscript.js' file it was like this: req.open("GET", "/setnet_data.html?" + document.getElementById("NWd port 2

    actual line is like: req.open("GET", "/setnet_data.html?" + document.getElementById("NW_Mode").value + "?" 

    So everytime it gives some different error. In wireshark i checked no. of data bytes received are same as expected data bytes.

  • Hi,

      The TM4C129 SPI can operate up to 60Mhz. I wonder if that will help as you only configure the SPI at at much lower frequency (e.g. 1Mhz). With that said, I have no idea and no experience on those errors you are seeing on the client side (the browser side). Can you tell from the wireshark if the server (the MCU) is correctly sending the data? You said the no. of data bytes received are same as expected data bytes. I suppose the server is operating correctly. Is that a correct understanding? If this is the case, it is the client side with problem? You will need to debug the client side and do some searches for the meaning for these errors as I really don't have ideas for they are and unable to help although I wish I could. 

  • Hi Charles,

    In 'lwipopts.h' file there is one macro "#define LWIP_HTTPD_SSI    1"  defined in my project due to which i was getting that problem.

    I commented that macro "//#define LWIP_HTTPD_SSI   1" and it resolved my issue...