# Notes about the ethernet interface

<abstract>
This article collects some notes regarding the use of the ethernet port on the various Acme Systems cards
</abstract>


If you are usign a Linux Debian or a Buildroot distribution
the ethernet port if configurable starting from this directory <code>/etc/network/interfaces.d</code>.

Here usualy are available files for eth0, wlan0 and usb0 gadget port configuration.

## Set a static IP address for eth0 port

Inside the <code>eth0</code> save these lines: 

	allow-hotplug eth0
	iface eth0 inet static
		address 192.168.1.90
		netmask 255.255.255.0
		gateway 192.168.1.1

## Set a dynamic IP address for eth0 port

Inside the <code>eth0</code> save these lines: 

	allow-hotplug eth0
	iface eth0 inet dhcp

## Set the MAC address

If your card does not have a dedicated MAC chip (available only on Acqua SOM) you can fix the MAC address saving it inside the <code>eth0</code> file using a line like this:

	hwaddress ca:d1:e0:35:fd:ef

If you don't have a your own MAC address but prefere to use a random MAC address you can use these lines instead:

	pre-up if [ ! -f /etc/eth0.macaddress ]; then ifconfig eth0 | perl -ne'/^ +ether (.*?) / && print "$1\n"' > /etc/eth0.macaddress; fi
	hwaddress $(cat /etc/eth0.macaddress)
	up udhcpc -n -q -F `hostname`

At first boot Linux will generate a random MAC address. This script will save this MAC address on the file <code>/etc/eth0.macaddress</code> and will use the same value at any boot.

## Device tree configuration on RoadRunner SOM

	macb0: ethernet@f8008000 {
		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_macb0_default &pinctrl_macb0_phy_irq>;
		phy-mode = "rmii";
		status = "okay";
	
		ethernet-phy@1 {
			reg = <0x1>;
			interrupt-parent = <&pioA>;
			interrupts = <73 IRQ_TYPE_LEVEL_LOW>;
		};
	};

...

	pinctrl_macb0_default: macb0_default {
		pinmux = <PIN_PB14__GTXCK>,
			 <PIN_PB15__GTXEN>,
			 <PIN_PB16__GRXDV>,
			 <PIN_PB17__GRXER>,
			 <PIN_PB18__GRX0>,
			 <PIN_PB19__GRX1>,
			 <PIN_PB20__GTX0>,
			 <PIN_PB21__GTX1>,
			 <PIN_PB22__GMDC>,
			 <PIN_PB23__GMDIO>;
		bias-disable;
	};

<!--
If you are using a XTERM-02 board use this alternative configuration:

	pinctrl_macb0_default: macb0_default {
		pinmux = <PIN_PB14__GTXCK>,
			 <PIN_PB15__GTXEN>,
			 <PIN_PB16__GRXDV>,
			 <PIN_PB17__GRXER>,
			 <PIN_PB18__GRX0>,
			 <PIN_PD14__GRX1>,
			 <PIN_PD15__GTX0>,
			 <PIN_PB21__GTX1>,
			 <PIN_PB22__GMDC>,
			 <PIN_PB23__GMDIO>;
		bias-disable;
	};
-->

@include='bio_tanzilli'