cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeMX and LWIP on STM32F107

balazs
Associate II
Posted on October 08, 2015 at 17:00

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 #stm32f1
14 REPLIES 14
Nesrine M_O
Lead II
Posted on October 09, 2015 at 11:31

Hi Balas,

I'd highly recommend you to have a look to the paragraph B.3.6 LwIP in the

http://www.st.com/st-web-ui/static/active/en/resource/technical/document/user_manual/DM00104712.pdf

User manual.

Also you find LwIP examples under  

http://www.st.com/web/en/catalog/tools/PF260820

 package: STM32Cube_FW_F1_V1.2.0\Projects\STM3210C_EVAL\Applications\LwIP

-Syrine 

balazs
Associate II
Posted on October 09, 2015 at 13:17

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,

Balas

balazs
Associate II
Posted on October 09, 2015 at 14:32

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,

Balas

Bino
Senior
Posted on October 09, 2015 at 14:46

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.

/Eric

balazs
Associate II
Posted on October 09, 2015 at 16:15

Hi Eric,

Sure, the version is 4.0

I have also attached the ioc file.

Thanks,

Balazs

________________

Attachments :

F107-eth-MDK.ioc : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HtpU&d=%2Fa%2F0X0000000aXO%2FoFGC0kOoR5gRZaVacqy7bHhWBB1_AGMGTZevLk7_DXk&asPdf=false
balazs
Associate II
Posted on October 09, 2015 at 16:58

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,

Balas

Bino
Senior
Posted on October 12, 2015 at 17:55

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,

/Eric

balazs
Associate II
Posted on October 12, 2015 at 18:35

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,

Balazs

balazs
Associate II
Posted on October 13, 2015 at 11:11

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