Skip to main content
Explorer
March 19, 2024
Solved

FREERTOS, LWIP, HTTPD set up

  • March 19, 2024
  • 3 replies
  • 7250 views

Hi,

Im currently trying to set up a project where Freertos controls a webserver via lwip.
I tried following these tutorials/guides and managed to be able to ping the board but not get it to host the webserver.

https://github.com/MayaPosch/FreeRTOS_HTTP_server/tree/master

https://community.st.com/t5/stm32-mcus/how-to-create-project-for-stm32h7-with-ethernet-and-lwip-stack/ta-p/49308/show-comments/true

Both of these are not for the STM32F429ZITx board So I copied what I thought I needed.
Right now I have it set up like this:

WilliamVR_0-1710840794056.png

WilliamVR_1-1710840885011.pngWilliamVR_2-1710840894308.png

WilliamVR_3-1710840904622.png

for the code:

The default task calls http_server_netconn_init that cretes a thread. Then this thread is the same as in this tutorial:

https://github.com/MayaPosch/FreeRTOS_HTTP_server/tree/master

I also coppied the exact same files over for the fsdata.
Im connected via a static ip and when I type the IP in the browser or any link to a page it refuses the connection. I also used Advanced IP scanner to check If it was hosting something, but there was nothing.

Does anyone know what I could have forgotten or doing wrong?

Kind Regards,

William

 

 

 

 

    This topic has been closed for replies.
    Best answer by WilliamVR

    So I got it to work, here are my findings for anyone who has the same problem.
    - You don't need to activate HTTPD in your ioc file for this to work.

    - On this github page: https://github.com/MayaPosch/FreeRTOS_HTTP_server/tree/master

    There are two ways: just a static page with fsdate or dynamicly generate the page.

    Staticly I didn't get it to work but its probably possible, dynamicly however works fine. 

    - It possible that you can't transfer the entire website in one netconn write, I have done it with multiple netconn writes.

     

    There are probably better ways of doing it. But this works.

    static const char head[] =
    		"<!DOCTYPE html>"
    		"<html lang=\"en\">"
    		"<head>"
    		"<meta charset=\"UTF-8\">"
    		"<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">"
    		//"<meta http-equiv=\"refresh\" content=\"5\">"
    		"<title>IRIS</title>";
    
    //rest of page ...
    netconn_write(conn, head, strlen((char*)head), NETCONN_COPY);
    //netconn_writes for rest of page

     

     

     

    3 replies

    Super User
    March 19, 2024

    Ask the author of that github project to kindly help?

    Instrument the http server code with debug prints to understand why it refuses connection?

     

    WilliamVRAuthor
    Explorer
    March 19, 2024

    I'll if I can get in touch.
    Thats what im currently trying. But im new to freertos so its not exactly printing eveything just yet :).

    Super User
    March 19, 2024

    @WilliamVR wrote:

     it refuses the connection.


    What do you mean, "refuses" ?

    Do you get an HTTP 4xx failure status?

    https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#4xx_client_errors

     

    WilliamVRAuthor
    Explorer
    March 19, 2024

    Well Chrome is being a bit vague, I get this:

    WilliamVR_1-1710858841063.png

    so there is probably an error somewhere with the TCP transmission.



    Super User
    March 19, 2024

    I think ERR_CONNECTION_REFUSED is probably at the TCP layer - so it's not even getting to your webserver?

    WilliamVRAuthorAnswer
    Explorer
    March 27, 2024

    So I got it to work, here are my findings for anyone who has the same problem.
    - You don't need to activate HTTPD in your ioc file for this to work.

    - On this github page: https://github.com/MayaPosch/FreeRTOS_HTTP_server/tree/master

    There are two ways: just a static page with fsdate or dynamicly generate the page.

    Staticly I didn't get it to work but its probably possible, dynamicly however works fine. 

    - It possible that you can't transfer the entire website in one netconn write, I have done it with multiple netconn writes.

     

    There are probably better ways of doing it. But this works.

    static const char head[] =
    		"<!DOCTYPE html>"
    		"<html lang=\"en\">"
    		"<head>"
    		"<meta charset=\"UTF-8\">"
    		"<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">"
    		//"<meta http-equiv=\"refresh\" content=\"5\">"
    		"<title>IRIS</title>";
    
    //rest of page ...
    netconn_write(conn, head, strlen((char*)head), NETCONN_COPY);
    //netconn_writes for rest of page

     

     

     

    Super User
    March 27, 2024

    Thanks for updating.

     


    @WilliamVR wrote:

    But this works.

    WilliamVR_0-1711528664830.png

    WilliamVR_1-1711528677654.png


    You screenshot has cut off some of the code!

    Please don't post code as screenshots - use this button:

    AndrewNeil_0-1711533268616.png