LWiP on STM32F746 Nucleo

Report here problems in any of ChibiOS components. This forum is NOT for support.
dflogeras
Posts: 212
Joined: Tue Sep 03, 2013 8:16 pm
Has thanked: 7 times
Been thanked: 19 times

LWiP on STM32F746 Nucleo

Postby dflogeras » Sat Jan 14, 2023 7:04 pm

Hi all, I'm trying to get my feet wet with ChibiOS +LWiP. My end goal is to make a basic TCP server application which waits for a client to connect, and after some light protocol exchange, sends packets of binary data from a sensor in a stream fashion.

I am currently using the NUCLEO144 STM32F746 board, as it had the RJ45 and PHY, but I've also attempted the same on a F769NI discovery with the same outcome and hoping to get some insight before I dig in too deep.

I am starting with a demo for this board (demos/STM32/RT-STM32F746ZG-NUCLEO144) and using the latest 21.11.3 release. I have then enabled the MAC subsystem and added lwip.mk and friends to my Makefile to get the associated pieces compiling. From looking at the forums, I have used the STM32F746xG_ETH.ld script, as well as disabled the DCache on this device for the time being (the latter seemed necessary). I can now initialize the LWiP stack with both a static IP and DHCP and it responds to ping.

If I initialize the pre-canned LWiP httpd server (with httpd_init() ), lo-and-behold I am served with a landing page on port 80. So that should ring out that my hardware is working.

However, I'm not interested in reading that implementation (yet), so I also noticed there are simpler demos such as demos/STM32/RT-STM32F107-OLIMEX_P107-LWIP which implement a _very_ basic web.c server thread which essentially:
  • creates a socket
  • binds to a port
  • calls listen
  • waits on accept()
  • serves the live socket, and then closes it
  • repeats


I am attempting to get that running, but with little success. I can step in the debugger up to the point there the blocking call to accept starts waiting for a socket, but it never returns. Using a python client to connect to it, the connection seems to establish, but if I attempt to send any bytes to it I get "ConnectionResetError: [Errno 104] Connection reset by peer" from Python's implementation.

Any advice would be appreciated. I'm hoping I'm doing something stupid.
Also, if anyone with a board that has a MAC/PHY could double check these demos (especially the latter) that would be great too.

Thanks,
Dave

User avatar
Giovanni
Site Admin
Posts: 14462
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1078 times
Been thanked: 922 times
Contact:

Re: LWiP on STM32F746 Nucleo

Postby Giovanni » Sat Jan 14, 2023 8:09 pm

Hi,

I am not sure if I have one of those boards anymore.

You could try going back in releases and see where that demo broke.

https://osdn.net/projects/chibios/releases/

Note that the MAC driver had a significant change in the very latest release, it is possible something went wrong there.

Giovanni

dflogeras
Posts: 212
Joined: Tue Sep 03, 2013 8:16 pm
Has thanked: 7 times
Been thanked: 19 times

Re: LWiP on STM32F746 Nucleo

Postby dflogeras » Sat Jan 14, 2023 9:58 pm

I did try (but didn't mention) the older 21.6.x series, but since you suggested I went even further back, all with the same outcome:
20.3.4
19.1.4

Then I noticed that the lwipopts.h in the F107 project that I was trying to get running was _very_ short compared to the one included with the HTTPS project (demos/STM32/RT-STM32-LWIP-FATFS-USB-HTTPS). That config seems to define all the options, not relying on defaults.

As a hail-mary I tried using that config, and the simple web.c project begins to work! Not sure which option is required, but I'll try to chop it down so we can fix the demo for the next release.

Thanks for the push,
Dave

dflogeras
Posts: 212
Joined: Tue Sep 03, 2013 8:16 pm
Has thanked: 7 times
Been thanked: 19 times

Re: LWiP on STM32F746 Nucleo

Postby dflogeras » Sun Jan 15, 2023 2:05 pm

The culprit (for this tiny use case anyway) seems to be

Code: Select all

#ifndef DEFAULT_RAW_RECVMBOX_SIZE
#define DEFAULT_RAW_RECVMBOX_SIZE       4
#endif

/**
 * DEFAULT_UDP_RECVMBOX_SIZE: The mailbox size for the incoming packets on a
 * NETCONN_UDP. The queue size value itself is platform-dependent, but is passed
 * to sys_mbox_new() when the recvmbox is created.
 */
#ifndef DEFAULT_UDP_RECVMBOX_SIZE
#define DEFAULT_UDP_RECVMBOX_SIZE       4
#endif

/**
 * DEFAULT_TCP_RECVMBOX_SIZE: The mailbox size for the incoming packets on a
 * NETCONN_TCP. The queue size value itself is platform-dependent, but is passed
 * to sys_mbox_new() when the recvmbox is created.
 */
#ifndef DEFAULT_TCP_RECVMBOX_SIZE
#define DEFAULT_TCP_RECVMBOX_SIZE       40
#endif

/**
 * DEFAULT_ACCEPTMBOX_SIZE: The mailbox size for the incoming connections.
 * The queue size value itself is platform-dependent, but is passed to
 * sys_mbox_new() when the acceptmbox is created.
 */
#ifndef DEFAULT_ACCEPTMBOX_SIZE
#define DEFAULT_ACCEPTMBOX_SIZE         4
#endif



The defaults for these in include/lwip/opt.h are all set to 0, which would explain why my call to accept() was waiting forever. Just defining these in the lwipopts.h file included with the demos/STM32/RT-STM32F107-OLIMEX_P107-LWIP/ seems to make the example work for me. Probably don't require the RAW and UDP settings, but they are all defaulted to 0 so I thought it was saner to define them.

Dave

User avatar
Giovanni
Site Admin
Posts: 14462
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1078 times
Been thanked: 922 times
Contact:

Re: LWiP on STM32F746 Nucleo

Postby Giovanni » Sun Jan 15, 2023 2:12 pm

Moving this to "bug reports" so it is not lost.

Giovanni

steved
Posts: 825
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 12 times
Been thanked: 135 times

Re: LWiP on STM32F746 Nucleo

Postby steved » Wed Feb 15, 2023 2:46 pm

As an example, I've attached the file I use on the 32F767 - TCP/IP, UDP, sockets, HTTP (although not the lwIP server), SNMP - found it pretty solid.

There a a fair number of comments added in the file as I tried to understand things; these may be helpful.

Some of the options are also imported 'in case', but left at defaults.
Attachments
lwipopts_pruned.7z
(21.52 KiB) Downloaded 159 times


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 8 guests