cancel
Showing results for 
Search instead for 
Did you mean: 

TCP Socket bare-metal, can it be done?

AndrewST
Associate II

Hi,

I am running a simple TCP server using the lwIP stack and no RTOS. I got help from the "Echo_Server" example offered in most ST eval board packages, everything works fine.

I need to accept a single socket connection from the outside and maybe also establish one as a client.

I understand that because sockets are sort of blocking, they are often implemented in a multi-thread environment. I am trying to not use any OS. Any type of the F series microC will do.

Has anyone ever implemeted lwIP sockets without any OS? Can it be done?

Thank you.

 

12 REPLIES 12

Yes, of course it can!

https://savannah.nongnu.org/projects/lwip/ - no dependency on any RTOS

https://www.nongnu.org/lwip/2_1_x/index.html

 

STM32, no RTSO - eg, https://community.st.com/t5/stm32-mcus/how-to-use-the-lwip-ethernet-middleware-on-the-stm32h5-series/ta-p/691100

 

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

Forgive me if I am missing your point, but none of those links point to bare metal sockets.

These just show that a large part of the lwIP stack can be used with no OS, but that is not the question.

The standard lwIP socket API relies on the Netconn API

From there, all I see is mentions to "threads" and "semaphores", OS stuff, not bare-metal.

 

Hello @AndrewST ,

The only wrork done (to my knowledge) with ethernet in baremetal on STM32 is described in this article: How to create a bare metal HAL Ethernet application on STM32H563/STM32H723

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

Thanks, but there is a ton more published work that's been done with Ethernet in bare metal than what's in this article. Starting with bare metal TCP server and clients examples provided by ST in the Fxxx Eval or Nucleo packages.

None of what I have seen so far addresses bare metal BSD Sockets, because the default lwIP API implementation requires a OS. I am think this can be done without any RTOS, which is why I am asking.

Sorry I didn't understand.. Do you mean by "baremetal" LWIP without RTOS?

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

Correct, that is the original question:

"Has anyone ever implemented lwIP sockets without any OS? Can it be done?"


@AndrewST wrote:

Can it be done?


It can be done according to this thread.

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

I appreciate your help, but no, the thread you linked does NOT address bare metal SOCKET.

It explains how some of the lwIP stack can be used without RTOS using the RAW API, which is a given fact if you read the first sentence of the post: "I am running a simple TCP server using the lwIP stack and no RTOS."

It looks that this API requires context changes between user "process" and TCP "process", therefore some kind of threads or "tasks", and timers. If this can be called RTOS, then yes, RTOS. Chuck Norris could do it bare-metal but he's retired long long ago.