2015-10-08 08:00 AM
My goal is to build a very simple HTTP server provided by the MCU.
With CubeMX I generated out an MDK-ARM project using the LWIP stack on Ethernet PHY with RMII.Ethernet links up with 10Mb/s, but on some reason the DHCP request (generated by CubeMX) does not succeed, so my board does not acquires an IP address.Also if I set a fix IP (through the CubeMX interface) - it is still not getting applied.I have not done any modifications on the generated codes yet, just compiled and uploaded to the MCU board.Do I need to add any additional start-up codes to enable DHCP or at least the FIX IP to work?Unfortunatelly all of the application notes are for the standard libs, saying that it is already superseeded by CubeMX ... However I cannot find a usable tutorial/documentation/example for CubeMX on howto build a simple HTTP server on LWIP and Ethernet MAC+PHY.Please advise!Thanks,Balas #cubemx #lwip #ethernet #stm32f12015-10-09 02:31 AM
Hi Balas,
I'd highly recommend you to have a look to the paragraph B.3.6 LwIP in thehttp://www.st.com/st-web-ui/static/active/en/resource/technical/document/user_manual/DM00104712.pdf
User manual.Also you find LwIP examples under package: STM32Cube_FW_F1_V1.2.0\Projects\STM3210C_EVAL\Applications\LwIP-Syrine2015-10-09 04:17 AM
Hi Syrine,
Many thanks for your answer.I checked out the UM1718 manual, but to be honest it has a very limited information on how CubeMX is working with LWIP, and what do I need to add/change to make it work with either DHCP or fix ip. The generated code (without modifications) simply does not work with DHCP.I'm checking out the F1 package now - hopefully I can get more information from that.In case you can point me to further documentations/tutorials, I would really appreciate.Regards,Balas2015-10-09 05:32 AM
Hi Syrine,
Also I could not find an example in the F1 package on using DHCP.Do you know where I can find a working example or documentations for that as well?Many thanks,Balas2015-10-09 05:46 AM
Hello,
Could you please tell us which STM32CubeMX version you are using so that It will possible to try to reproduce your bug. If you can also attach your ioc file it would be helpful. Thanks and regards. /Eric2015-10-09 07:15 AM
2015-10-09 07:58 AM
Eric,
Also it is an important piece of the situation that I have a LAN8720A PHY ic connected to the 107 MCU. Not sure if that matters or not, but I have a feeling that the problem is the mismatching ethernet driver?And just to confirm, the ioc file is containing a fix ip configured as I was making tests with this configuration as well. But of course I also tried with DHCP enabled.Thanks,Balas2015-10-12 08:55 AM
Hello,
I checked the ioc file ; everything seems ok. Probably the changes done for configuring PHY are causing the trouble. Is it possible to get the zip of the project with the code modified/added. Do you have an eval board F107? If yes ,did you try your code on this board? Thanks and regards, /Eric2015-10-12 09:35 AM
Hi Eric,
Sure, I zipped up the whole project folder, you can reach it here:https://drive.google.com/file/d/0B7wD9W-LalWNbjc5RjJud0lucmM/view?usp=sharing
This is 24 Megs, if you would just check the sources modified, please let me know.I have mostly touched ethernetif.c and the HAL eth libraries (e.g. stm32f1xx_hal_eth.c, etc.) and also added LAN8720A_eth_dal_conf.h.I'm using an easy-stm32 eval board (compatible with Mikroe EasyMX Pro board). With the same hardware the Mikroe Ethernet test app is working smoothly, but unfortunatelly sources for its ethernet drivers are not open ...I spent the whole weekend (days and nights) trying to resolve this without success... really appreciate your help!Kind regards,Balazs2015-10-13 02:11 AM
Hi Eric,
I think finally I found the root cause of the issue.I configured 25MHz on the MCO output as with 50MHz MCO output the MAC was not working.However I found that the PHY needed 50 MHz for its operation. So I checked why the MAC was not working with 50MHz MCO, and realised that CubeMX generated a wrong GPIO setup for the MCO pin. It was configuring the pin to LOW speed, even with the 50MHz MCO output.So when I manually changed the pin output speed to HIGH, the MAC started to work on 50MHz, and also the PHY got the necessary 50MHz clock input and started to communicate properly.With this change now the negotiation is working, link is configured with 100 Mb Full.I'm wondering if I can submit a bug ticket for ST, raising that CubeMX is generating a wrong GPIO speed config (LOW) for the MCO? Please let me know.Thanks,Balazs