Tips to get Ethernet working on NuttX

I want to share here my experience to get Ethernet working on Bambino 200E board. In fact after you realize what needs to be done life become easy.

Almost all microcontroller with Ethernet MAC needs an external PHY chip to convert its signal to the physical media’s signal (in the twister pair cable). Normally this PHY communicate with the microcontroller using MII (Media-Independent Interface) or RMII (Reduced Media-Independent Interface) protocol.

So the first thing you need to find is the PHY Address used for your board’s PHY. The Bambino 200E uses the Micrel KSZ8031RNL and because there is not a Pull-UP resistor in the CRS_DV/PHYAD[1:0] the PHY Address will be 0, then you need to define it in your configuration:

CONFIG_LPC43_PHYADDR=0

And since the KSZ8031 support Auto Negotiation to detect the Ethernet mode and speed you need to define it:

CONFIG_LPC43_AUTONEG=y

Now comes the trick part, you need to setup the PHYSR (Status Register). The PHYSR is basically the address of the register where the PHY informs about the Auto Negotiation status.

So initially you could think it is the Basic Status register (at 1h), but the Basic Status is used to inform which modes and speeds your Ethernet router/hub/switch supports.

The right register in in fact the “PHY Control 1” (1Eh = 30). See the Operation Mode Indication field bits (1E.2:0) :

[000] = still in auto-negotiation
[001] = 10Base-T half-duplex
[010] = 100Base-TX half-duplex
[011] = reserved
[100] = reserved
[101] = 10Base-T full-duplex
[110] = 100Base-TX full-duplex
[111] = reserved

So, we need to define the following configuration to get Ethernet working:

CONFIG_LPC43_PHYSR=30
CONFIG_LPC43_PHYSR_ALTCONFIG=y
CONFIG_LPC43_PHYSR_ALTMODE=0x7
CONFIG_LPC43_PHYSR_10HD=0x1
CONFIG_LPC43_PHYSR_100HD=0x2
CONFIG_LPC43_PHYSR_10FD=0x5
CONFIG_LPC43_PHYSR_100FD=0x6
CONFIG_LPC43_RMII=y

I spent almost a working day to get Ethernet working, if I was aware of the above information it should matter of few minutes to get everything working.