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

    @vignesh
    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

    @Rick
    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.
    http://evertdekker.com/wp/?wpdmact=process&did=My5ob3RsaW5r
    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)

    But…

    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.

    Thanks

  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

    @mohammad
    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 :
    @mohammad
    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

    @Salmen
    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

    @Salmen
    No, the project is made for CooCox CoIDE.

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

    @Andy
    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.

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