trying to configure the ethernet PHY I noticed a strange behaviour with the function smi_configure().
If I change the link speed or enable/disable the auto-negotiation and then compile, the values passed to the function remain as before the modification (I tested this adding a couple of printf inside the smi_configure function).
But if I clean the project and then compile again it works.
I identified the issue in the fact that link speed and auto-negotiation are passed to the function as constants.
The compiler has some level of optimization that strips the costant parameters from smi_configure() prototype and compiles directly the smi_configure() with "harcoded values".
Thus cleaning the project results in recompiling everything with updated values, whilst compiling only the module calling smi_configure() misses to recompile everything mantaining former values.
I tried to disable optimization by setting -O0 in makefile and disable also -falways-inline but without any changes in the behaviour.
Does anyone know how to avoid this behaviour of the compiler? Maybe some pragma or compiler option?
This can be annoying in debug, if one want to change the link speed. Obviously, initializing two variables and passing them to smi_configure() fixes this problem.
Code: Select all
ethernet_speed_t my_speed = LINK_1000_MBPS_FULL_DUPLEX; smi_autoneg_t my_autoneg = SMI_ENABLE_AUTONEG; smi_configure(smi, phy_address, my_speed, my_autoneg);