Configuring PHY speed and auto-negotiation issue

Technical questions regarding the XTC tools and programming with XMOS.
Post Reply
nick
Active Member
Posts: 42
Joined: Tue Jan 07, 2020 10:35 am

Configuring PHY speed and auto-negotiation issue

Post by nick »

Hi,
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);


User avatar
akp
XCore Expert
Posts: 578
Joined: Thu Nov 26, 2015 11:47 pm

Post by akp »

Hi nick,

This just appears to be the behaviour of the compiler. I don't know why it can't see you've changed the call to smi_configure() so it should recompile smi.xc. I pretty much always clean and build when I make a change.

Good luck!
Post Reply