Ethernet server using STM32F4-Discovery and SD card

It’s been a while since my last library on the web. I’m making ethernet library with TCP client and TCP server support using external PHYs (currently testing with DP83848, but it will support any PHY you want).

I have some troubles yet with code, so library is not prepared for download. It will be as soon as I made it clear and stable.

Library is available here.

Library key features:

  • Currently support only for RMII interface with PHY and STM32F4 ETH interface
  • Built on LwIP TCP/IP stack
  • Support for TCP client and TCP server
    • 4 TCP client connections at a time
  • Built-in support for opening files from SD card or any other source
  • Support to disable server access to IP address
  • DNS support for receive IP from domain
  • DHCP support for receive IP in your network
    • Support for custom device name on router
  • Support for callbacks with full control on your work
    • Callbacks for client (when connected, disconnected, data available, create headers)
    • Callbacks for server (new client connected to server, disconnected)
    • Callbacks for DNS (DNS has started, DNS has found IP)
    • Callbacks for DHCP (DHCP has IP for us, DHCP error)
    • Callbacks for link status (Link down, link up)
  • Support for dynamic MAC address
  • Support for STATIC/DYNAMIC IP address
  • Support for monitoring how many bytes we sent/received over client/server mode
  • Enable/Disable server mode
  • User selectable PORT for server
  • Support for SSI tags and CGI handlers
    • SSI: You can display variables from MCU (RTC clock for example, LEDs status, etc)
    • CGI: You can control MCU from web (control leds)
  • Support for POST request
  • Support for TCP communication between 2 STM devices without router using crossover cable
  • and more…

Working preview

Currently, I have a working example on my home network, and it is also available on link below. Source code, which you see on site is located on SD card and is not loaded in flash memory of STM.

Preview does not work anymore, because library is available for download.

STM32F4-Discovery ethernet server and SD card

STM32F4-Discovery ethernet server and SD card

More features

Waiting for you..

tilz0R

Owner of this site. Also electronic enthusiasts, web developer, 3D printer fan, handball player and more. Big fan of STM32F4 devices. In anticipation of the new Discovery board for STM32F7 lines.

You may also like...

Read before commenting!

Before you make a new comment, make sure you agree with things listed below:

  • - Read post to make sure if it is already posted what you are asking for,
  • - Make sure you have the latest version of libraries used in your project,
  • - Make a clean and grammatically correct written message,
  • - Report as many details as possible, including what have you done so far,
  • - Do NOT post any code here. Use Pastebin,
  • - Do NOT post any error codes here. Use Pastebin,
  • - Specify STM32Fxxx family and used Discovery/EVAL/Nucleo or custom made board,
  • - Make sure your clock is set correct for PLL,
  • - If you are using my HAL drivers, please check this post how to start.
Comment will be deleted on breaking these rules without notification!
  • dcrystalj

    Can’t wait to see this project online! I will donate for sure if it will be useful for me. Is this project using some OS? FreeRTOS?

    • No, this is not used with RTOS, but ti can’t be so hard to make it working.
      You need one thread which will handle ethernet stuff and you need to change timing inside.
      I’m still having some small problems, but I will fix them soon, I’m a little bit hard with time right now.

      PS: Which feature you need? Maybe I can try to add it inside.

      • dcrystalj

        actually… im looking very hard to find working project with FreeRTOS and Ethernet and LCD for some free IDE like Coocox. STM cubeMX is generating starting code just for IAR or Keil

        • Ok, this is quite BIG project, with A LOT of features for my opinion.
          For this purpose, I’ve made test project for Coocox. I just have to implement printf function which I use for testing and it worked from first try 😀

          So, on my Github, I will upload coocox and keil example.
          Unfortunatelly without RTOS.

          • dcrystalj

            But do you have plan to add RTOS? I hate this dirty job adding files to project instead of coding things I need.

          • You still need to add files in project and code things you need with or without RTOS.

    • I dont know if you see, but library is available now.

      • dcrystalj

        nice, i will take a look ASAP.

  • james

    hi

    i used two stm32f407 board’s as udp server that connected to one client

    pc(as client)(ethernet hub switch)|server-1(stm32f407 as udp server)

    ip=192.168.0.3,port=1200)

    |server-2(stm32f407 as udp server)

    ip=192.168.0.4,port=2302)

    when i connect them to a ethernet hub switch .server-1 & server-2 not work correct but when i connect them to router with gateway address (192.168.0.1 ).two servers work Properly

    pc(as client)( router “192.168.0.1”)|server-1(stm32f407 as udp server)

    ip=192.168.0.3,port=1200)

    |server-2(stm32f407 as udp server)

    ip=192.168.0.4,port=2302)

    do need ethernet communication between 2 STMf407 devices need to router modem?

    • Well, if you have crossover cable, then just connect them with cable, without anything there.
      I’m not sure about that. I don’t have hub for testing this. Sorry.

  • Mohamed El Shenawy

    waiting for the final release!

  • winston1777

    Hi! When installing sketch to your Board stm32f429, I was faced with 2 problems. The first hid gamepad1 when you press the button a few quick times, the device hangs and does not respond. The second problem gamepad2 just do not respond to the touch of a button.