Skip to main content
Visitor II
April 5, 2025
Question

TCP Socket bare-metal, can it be done?

  • April 5, 2025
  • 3 replies
  • 1959 views

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.

 

    This topic has been closed for replies.

    3 replies

    Super User
    April 5, 2025
    AndrewSTAuthor
    Visitor II
    April 5, 2025

    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.

     

    Technical Moderator
    April 5, 2025

    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

    Graduate
    April 6, 2025

    With blocking code, everything that needs to be done to unblock must happen “by magic” - in other threads or by interrupt service routines. And things like semaphores, thrrad-safe queues are all helpful.

    An OS will provide calls for those.

    Or you could write them from scratch.

    I use the “Crossworks Tasking library” that comes with the (paid-for) Rowley Crossworks IDE to give me multiple threads, semaphores etc. I don’t regard it as an Operating System. Does that count as an OS or not by your criteria?

    A lot of my decisions are historic - the project started pre-stm32cube. And I like the Rowley Crossworks IDE.

    I use the netconn api of LWIP. Do you specifically want their Socket API?

    I suppose I should add that my system can accept incoming TCP connections.

    So whether or not I have succeeded depends on your specific interpretation of terms like socket an OS

    AndrewSTAuthor
    Visitor II
    April 7, 2025

    Interesting.. Thanks for sharing.

     


    @Danish1 wrote:

    I use the “Crossworks Tasking library” that comes with the (paid-for) Rowley Crossworks IDE to give me multiple threads, semaphores etc. I don’t regard it as an Operating System. Does that count as an OS or not by your criteria?


    The owners themselves call it an RTOS, so I guess it does count as an OS. From Rowley's website: "CTL is a real-time operating system designed for deployment in embedded systems that require a solid foundation to support their application infrastructure.".

     


    @Danish1 wrote:

    So whether or not I have succeeded depends on your specific interpretation of terms like socket an OS


    Forgive me but there isn't any "interpretation of terms" on my end. A TCP socket is a TCP socket. lwIP's Netconn is a broader TCP API and their Socket API relies on it, sure, but it is not socket.

    Your work was definitely in the same realm as the question I asked, but it was not baremetal and it was not socket.

    Visitor II
    April 22, 2025

    I don't know if it's late or not but here is a code i used for a baremal tcp server that handles client (only one but just extend the client to a list)

    You just have to configure the .ioc to work as a tcp server lwip, straightforward.

    I also have a websocket implementation baremetal if needed.

     

    also reach my email if any more question (i don't get any notifications here):

    leo.fresnay@apyretechs.com