Home > ARM, Development boards > Ethernet on STM32F4DISCOVERY using external PHY

Ethernet on STM32F4DISCOVERY using external PHY

For you who have read about the STM32F4 Cortex-M4 processor you might know that this processor family includes a 10/100 Ethernet MAC with dedicated DMA that supports supports IEEE 1588v2 hardware, MII/RMII.
This means that the only electronics needed to enable the ethernet capability is an external PHY and the Magjack connector.

On the STM3240G-EVAL evaluation board the DP83848 PHY is used and luckily for us we were able to find a simple breakout board for this chip on eBay.

DP83848 Phy breakout board

To hook up this Phy to the STM32F4DISCOVERY board a slight change in the pins, compared to the connections on the evaluation board, had to be made. Because the STM32F4DISCOVERY board only contains the 100-pin version some of the full MII pins are missing so we have to use the PHY in RMII mode.

So by taking the example project files for the Webpage example on the evaluation board, changing the GPIO initialization and Ethernet BSP file a bit to match the Discovery board, we were able to get the example running on our board.
The connections between the PHY module and the STM32F4DISCOVERY board can be seen in the image below.

Ethernet PHY connections

On the PHY Breakout board there is space for a jumper. This jumper is used for external reset and should not be installed to work in this project.

To see the Ethernet functionality in use with the webpage example loaded on the Discovery board have a look at our video below.

The GCC project for the Webpage demonstration on the STM32F4DISCOVERY board, shown in the video, together with a CooCox CoIDE project file can be downloaded from the following link: STM32F4DISCOVERY Ethernet-Phy – Webpage example

Thanks to a comment from @P_K there is a very simple way to generate your own new HTML files using the “makefsdata.exe” file found inside the “STM32F4x7_ETH_LwIP_V1.0.0\Utilities\Third_Party\PC_Software” folder.
Please read more about how to do so at the following page: http://www.aimagin.com/tgr/tgr12/amgf4connect/doc/HTML/index.html?webpage_configuration.htm

You can eventually also see the following forum post on how to get ChibiOS and their Ethernet example to work with the setup described in this post: http://forum.chibios.org/phpbb/viewtopic.php?f=3&t=23&p=8017#p8017

Categories: ARM, Development boards Tags:
  1. Ginny
    May 13th, 2015 at 09:56 | #1

    Hi Thomas !
    I have a question ! I builted successfully, but t cann’t connect to httpserver , help me ! thanks…

  2. vignesh
    July 11th, 2015 at 06:10 | #2

    where can i download makefsdata.exe… help me out..
    thanks in advance

  3. July 12th, 2015 at 14:29 | #3

    Please read the bottom section of the post which says:
    …there is a very simple way to generate your own new HTML files using the ?makefsdata.exe? file found inside the ?STM32F4x7_ETH_LwIP_V1.0.0\Utilities\Third_Party\PC_Software? folder.
    Please read more about how to do so at the following page: http://www.aimagin.com/tgr/tgr12/amgf4connect/doc/HTML/index.html?webpage_configuration.htm

  4. Rick
    July 18th, 2015 at 05:39 | #4

    I tried with STM32F107VCT6, but I can’t ping the board,
    I use STM32CubeMx…..

    I don’t understand why…? any clues ?thanks

  5. July 18th, 2015 at 10:46 | #5

    This project has not been prepared for use with STM32CubeMx due to the updated libraries included in this toolset.

  6. Mattias Norlander
    September 21st, 2015 at 14:15 | #6

    Ed :
    I Have updated (most) of the drivers to Ver 1.1.0 and fixed some minor issues.
    Dynamic IP is now working and even more important the webpage is now loading in a blink of an eye.
    It?s compiled with Coide 1.7.7. In the zip file is also Em::Blocks (ebp) project file for those who want to use this compiler.

    Hi guys,
    I am currently struggling with hooking up the Phy and getting FreeRTOS +LwIP running on the STM32F4-Discovery board. So far failing miserably. As a start template I have tried converting the STM32F4Cube project called “LwIP_HTTP_Server_Socket_RTOS” (\STM32Cube_FW_F4_V1.7.0\Projects\STM324xG_EVAL\Applications\LwIP\LwIP_HTTP_Server_Socket_RTOS).
    I am doing this with Atollic TrueSTUDIO. So far I can build the project and debug it. I am setting up a static IP but I cannot ping it, not browse the website. Does not matter if I go trhough my LAN or correct directly to laptop.

    I downloaded your Coocox project Ed and migrated it to TrueSTUDIO. It now works! I can ping the device and browse the http-server. It is good to know that the PHY module and the wiring is correct. Now I just need to get this FreeRTOS+LwIP project going. Anyone who have tried?

    Thanks for a good blog post!

  7. September 21st, 2015 at 15:12 | #7

    @Mattias Norlander
    Hi Mattias.
    Taking the STM32F4Cube project made for the STM324xG_EVAL board is made for the DP83848 Phy chip but connected in the full MII mode, where you are only able to use the RMII mode with the breakout board and the STM32F4DISCOVERY board.
    As I did to this specific project, made in CooCox CoIDE, I changed the low-level Phy hardware drivers to match the reduced MII interface, so it could be used with the DISCOVERY board.

    If you are migrating the STM32F4Cube project to the DISCOVERY board you would have to do the same change in the low level driver parts.

    Good luck.

    Best regards
    Thomas Jespersen

  8. mohammad
    October 28th, 2015 at 10:44 | #8

    hi, i downloaded ur project, but it has 1 err,
    I cant fix it, the err is :
    colect2.exe : error :ld returned 1 exit status
    please help me, tnks.

  9. mohammad
    October 28th, 2015 at 13:47 | #9

    I fixed it, its really good

  10. MathieuCALDEIRA
    November 21st, 2015 at 22:44 | #10

    Hi guy’s

    Just for help the people who try to make pings:

    You need to add -DLWIP_ICMP=1 to your compiler flags or

    #define LWIP_ICMP 1

    You have to enable everything you need.
    Also i doesnt try dhcp but if you have problems wity that, check the lwip configuration (if dhcp is over udp, enable it)


    With prototypes wires like in the video, we get really bad pings. With the webpage you doest see how bad it is..

    Actually i do 140ms pings and i loose a lot of data..
    The mchdrv_poll is called in polling so it’s not a lwip problem

    With freertos +enc28j60 +stm32f407 i get pings around 1ms (with a delay of 1ms in the task who call mchdrv_poll) so lwip work fastly.

    Maybe the problems are around the wires, i will check it when i have some time ..
    I will also check the pll settings..

    I come back soon

  11. MathieuCALDEIRA
    November 21st, 2015 at 22:46 | #11

    Note : i will also check the schematic of discovery board, check if the pins are not used by something else

  12. Mathieu
    November 22nd, 2015 at 13:44 | #12

    I have made some changes to my circuit, and now i can ping at 1ms and it’s realy stable!!

    1/ Put the STM32f4Discovery on a proto board, and solder the cables, with the minimal length to the PHY board ! Proto cable (15cm) are bad !!!
    Consequence : Now the pings request are stable: 140ms everytimes and no packets lost ! (but ping stay too high ..)

    2/ I have remove the U5 component for see if it change something, result : It doesn’t reduce the high ping. So don’t remove U5

    3/ I have check the PLL settings: they are correct for the STM32F4Discovery board.

    4/ Remove the DEBUG in LWIP : The debug was using USART to transmit the printf(), it’s really slow!. (i have set LWIP_DEBUG to 0 but doesn’t realy work) so I have comment everything in stdio/printf.c at the function void PrintChar(char c)

    5/ Enjoy, now you can ping the board around 1ms (really stable)

    Another information :
    You need to set “1” in Ethernet/include/lwipopts.h at the line where is :
    #define LWIP_ICMP 1

    This is for enable ICMP (ping request for exemple)
    If you need to set something specific check the lwipopts.h file, or if that you search is not set, check the “opt.h” file but do the modification’s in the lwipopts.h file (witch is for user settings)

  13. stewie
    December 5th, 2015 at 01:47 | #13

    @Thomas Jespersen
    Hello Thomas Jespersen,

    I have been working on trying to port the STM324xG_EVAL Ethernet to STM32F407 for the STM32CubeMX. I have made some progress, but I cannot get it to work. I was wondering if you had a working example.


  14. tpd
  15. January 29th, 2016 at 14:27 | #15

    Hi TPD.
    This module is the exact same module as ours (please notice that the image is mirrored).
    So you should indeed be able to use this module and get the HTTP example working.
    Regards Thomas

  16. Marcelo
    March 2nd, 2016 at 14:42 | #16

    How do you fix it? I have the same error: [cc] collect2.exe: error: ld returned 1 exit status
    when I tried to build the proyect

  17. Marcelo
    March 3rd, 2016 at 13:23 | #17

    Marcelo :
    How do you fix it? I have the same error: [cc] collect2.exe: error: ld returned 1 exit status
    when I tried to build the proyect

    Sorry, now I read all the comments and I fixed it.

    I have problems with the ping command because I lose a lot of packets and the time of response is really high. I read that some people have the same problems, I will try to find a solution and tell how

  18. Salmen
    April 27th, 2016 at 21:20 | #18

    where I can find makefsdata.exe in the project folder

  19. April 28th, 2016 at 21:41 | #19

    The ?makefsdata.exe? file is found inside the ?STM32F4x7_ETH_LwIP_V1.0.0\Utilities\Third_Party\PC_Software? folder.
    Please read more about how to make your own HTML files at the following page: http://www.aimagin.com/tgr/tgr12/amgf4connect/doc/HTML/index.html?webpage_configuration.htm

  20. Salmen
    April 30th, 2016 at 18:27 | #20

    do I open the project with keil uVision4,. if yes how to do that

  21. April 30th, 2016 at 18:41 | #21

    No, the project is made for CooCox CoIDE.

  22. June 7th, 2016 at 10:11 | #22

    hi ,

    same probelm occur me in coocox 1.7.8 version , but there is no option to eselect Exclude from build option

  23. June 8th, 2016 at 15:58 | #23

    @rameshwar kakade
    Yes, they have removed the “Exclude from build” option in the latest versions.
    Instead you would manually have to remove the C-file from the project to remove it from the build to avoid the linker error.

  24. Vitaliy
    August 1st, 2016 at 15:37 | #24

    Hello! I am newbie! From Kazakhstan!
      my problem!
    [Cc] collect2.exe: error: ld returned 1 exit status
    help fix the problem.

  25. August 1st, 2016 at 16:02 | #25

    You have to manually remove some of the webpage content C-files to avoid this linker error.
    Please read some of the comments above yours as the solution has already been explained.

  26. Jairo
    August 31st, 2016 at 21:32 | #26

    Hi Tomas,

    I downloaded your source and I compile in Coocox. But after software run, i receive repeating message on the debug serial “no active pcbstcp_slowtmr:”

    I could not understand. Does the hardware is right?

    I can test the hardware in some other way?

    Thank you

  27. September 16th, 2016 at 06:26 | #27

    This sound like the External PHY has not been connected probably with the RMII interface, or at least that it does not seem to be able to communicate properly and regularly.
    Can you please check all connections and make sure that the wires between the processor and the Phy is not too long?

  28. emreist
    October 7th, 2016 at 17:19 | #28

    i want to use http socket more than 4 or 5 sockets at the same time without http_connection_close. how can i arrange my code. ??

  29. mahdi
    January 29th, 2017 at 17:00 | #29

    hi how are
    thank you for your project
    i have problem with this
    1: i connected dp83848 to stmf4 discovery and see terminal for debug i recieved = tcp_slowtmr : no active pcbs?
    2: i connectes dp83848 and my pc to a modem ( have a router) but don?t get ip and MAC of dp83848?

    can you help me??

  30. February 9th, 2017 at 11:57 | #30

    Hi Mahdi.

    Can you confirm that you have wired and connected the Ethernet Phy module correctly?
    Please notice that the cables can not be too long otherwise it will affect the connection due to induced noise between the signal wires.

    The error indicates that the STM32 is not able to communicate with the Phy over the RMII interface, or at least that it does not seem to be able to communicate properly and regularly.

  31. Tommaso
    February 23rd, 2017 at 14:04 | #31

    Hi at all,
    I confirm the setting:
    PHY_ADDRESS 0x00
    for the STM32F4-BB ( discovery with Ethernet Board ) use.

  32. Lobisomem
    March 30th, 2017 at 19:14 | #32

    Hi. I downloaded the coocox coide, downloaded the project but CooCox CoIDE does not open the project.

    Version downloaded:

    CooCox CoIDE
    Version: 2.0.6
    Build id: 20170117-2.0.6

    S.O.:Windows7 Professional.

    Other then download and unzip it, do I need to do something else to make CooCox open it?


  33. March 31st, 2017 at 11:31 | #33

    CooCox CoIDE have been undergoing tremendous changes throughout the past 3 years why this project is no longer supported.
    I am no longer using CoIDE as I mainly work with ST devices now, why I have decided to move to “System Workbench for STM32”.

  34. Lobisomem
    March 31st, 2017 at 13:50 | #34

    @Thomas Kølbæk Jespersen
    I see. So … do you have a link to download the project on System Workbench for STM32 ?

    thx again

  35. March 31st, 2017 at 20:42 | #35

    I have not converted this project to System Workbench yet. So unfortunately there is no download link for the System Workbench project.

  36. Gedas
    April 5th, 2017 at 16:54 | #36


    hello, how did u fix it?

  37. Gedas
    April 17th, 2017 at 21:30 | #37

    I cant make this thing working. I put library in the place, used pin layout from stm to PHY ,compiling, seems ok, but i can’t reach http. What’s the problem. All the leds in PHY blinking perfectly. My router doest seems to see the device

  38. ABVF
    April 20th, 2017 at 15:28 | #38

    How did you fixed the error?
    [cc] collect2.exe: error: ld returned 1 exit status

Comment pages
1 2 3 4 3400
  1. No trackbacks yet.