cancel
Showing results for 
Search instead for 
Did you mean: 

Failed to display a simple webserver page without rtos

Brasco72
Associate II

Hello ,

I'm working on a STM32F407VET6 board with integrated ethernet port.
I'm using Stm32CubeIde 1.18.1 with firmware FW_F4 V1.28.2.
I'm just starting out and trying to display a webserver page without rtos for the moment.
I've been going round in circles for quite a long time, even with chatgpt and company...

At the moment I've managed to activate lwip (2.1.2) and it's working because when I start up I ping the address 192.168.0.123 and it responds.
However, as soon as I open my web browser and try to access it, the page doesn't display.

These are the obscure areas for me.
The tutorials I've followed show each time: First of all goto LWIP->Target->lwipopts.h and change the #define HTTPD_USE_CUSTOM_FSDATA 0
or I don't have this define generated automatically by stm32CubeIde so I don't set it.
I've used a tutorial "controllerstech".
I like it (I've even taken fsdata.c directly from it)
Every time I get build errors, so I exclude it.

I don't know where it's going wrong, but I've been failing for hours and hours...
If anyone can help me I'd be very grateful.

7 REPLIES 7
mbarg.1
Senior III

You could have problems:

in file system;

in Http decode;

in tcp receive ;

in tcp send;

in data overflow;

and, last but not least, you have an OS or Ethernet would not work; could be a no-brand one, but something is managing your app, and this is the worst nightmare for my glass ball to try to help you.

Hello,

Thank you for your reply. I know that there can be several sources of problems.
I was thinking that implementing a ‘hello world’ webserver page on my card should be something basic...
In fact, not so much for the uninitiated.

However, I set my pins to ioc, set the memories, enabled lwip and put my fsdata.c

From there the prerequisites seemed solid enough for me to find where the error comes from, I even added some printf on usart1 and I see them on putty, this indicates that ethernet is ok and in addition my ping works, it is when sending the request to get my page that it sticks. ... I don't know how to go about finding where the bug is... my fsdata.c is no good? do I have to include it in the build? or can I add printf to better understand what's going on?

 

Well, you have to look at LwIP and HttpD if they work properly, setting breakpoints and running step by step - unfortunately I do not have any f407 hw to replicate your problem.

You have ping working, than you should be able to see if any SYN packet comes in, if you reply with SYNACK and if HTTP GET is coming and is acked, probably wiresahrk can tell it without digging deeper in code.

But at the end, you must see why your app discard the GET or does not point to correct FS - you will need to go low level.

Brasco72
Associate II

Hello,

Thank you very much for your help!!!. This diagnostic process is helping me to move forward.
So I tested with wireshark as a first step, I've attached the result.
to summarize:

1. TCP handshake - OK
Client (192.168.0.157) sends SYN
Server (192.168.0.123 / STM32) responds with SYN-ACK
Client terminates with ACK
Result: TCP connection established correctly.

2. HTTP GET request
The client sends an HTTP GET / HTTP/1.1 request on port 80
This frame is successfully transmitted, validated and error-free.

3. No response from the server
The STM32 does not respond
No HTTP/1.1 200 OK, no RST, no ACK, nothing
The client waits a while...
...and ends up sending the same request again (→ black frame = TCP retransmission)

So I'm at that stage, as you said: But at the end, you must see why your app discard the GET or does not point to correct FS - you will need to go low level.

Perhaps you have an idea for organizing the diagnostic process so as to gradually pinpoint the problem? At the moment I don't really know where to start in order to go further..., there are still a lot of possible reasons, I'm looking for the test that will enable me to target the source of the problem in more detail.

 

Brasco72
Associate II

I've just spent another whole day trying to display a simple helloworld without success... it's not my habit but I think I'm going to give up, I don't understand why it's so complex...
I've put in printf and validated everything:

Debug SWD OK !
[LwIP] LwIP task in progress
Debug SWD OK !
[LwIP] LwIP task in progress
[ETH] Package received, size: 66
[ETH] Package received, size: 66
[ETH] Packet received, size: 60
>>> http_accept triggered: pcb=0x20009520, arg=0, err=0
[ETH] Packet received, size: 516
>>> http_recv triggered: pcb=0x20009520, pbuf=0x20004520, err=0
>>> http_recv payload (first 40 bytes): GET /FS/index.html HTTP/1.1
Host: 192.1
>>> fs_open called with name: /FS/index.html
fs_open: file known = /FS/index.html
fs_open: file known = /fsdata.c
fs_open: file known = /makefsdata
fs_open: file found: /FS/index. html
fs_open: size = 379
fs_open: first byte = 0x48
Assert: HTTP headers not included in file system

However it looks like a header problem... my static headers are present but apparently the flags were missing, I added that but it still doesn't work...
As I'm just starting out, I don't know if it's me who's off the mark or if it's normal to struggle so much with lwip and makefsdata...

Do you think using mongoose would be easier? Or am I still struggling, even if it means losing days to display a simple page?

I am currently for STM32 devices ThreadX + NetXDuo; if you mind looking at solutions other than LwIP, try it.

In my opinion, today is a better solution, more stable, easier to debug, suitable to build very complex systems; best is with H7 devices that allow to have dozen of threads and reach a stable system even with worse hacker attack, including dos, while keeping open connections to clients in SCADA ayatems.

Brasco72
Associate II

Thank you for your feedback. I've just had another wasted weekend, it's a real nightmare, if anyone can help me?
I've decided to follow an internet tutorial to use mongoose on freertos, without lwip, using the mongoose stack.
My task works, I flash a led but my server page is not displayed, I initialize mongoose, but it does not assign me an ip address, I use the stm32F driver for my card I think it blocks here (see attachment)

I don't understand, after weeks of persistence I can't manage to display a helloworld webserver page on this *** card, it's driving me crazy, so if a kind soul comes around to analyse my code and try to help me he's welcome