Skip to main content
Hammy
Associate III
January 31, 2023
Solved

How to configure ethernet port for direct connect and DHCP

  • January 31, 2023
  • 1 reply
  • 1840 views

I want to be able to have the Ethernet port on my board be configured as a link local address and be able to receive DHCP. How can I accomplish this?

This topic has been closed for replies.
Best answer by Hammy

In Yocto you need to add some configurations to the systemd-networkd recipe. In <my-laye>/recipes/systemd-conf create a systemd-conf_%.bbappend. In that file add

FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"

then make a folder called systemd-conf there and create a file called wired.network (<my-laye>/recipes/systemd-conf/systemd-conf/wired.network). Example contents might be

[Match]
Name=en* eth*
KernelCommandLine=!nfsroot
 
[Network]
DHCP=yes
LinkLocalAddressing=fallback
IPv4LLStartAddress=169.254.1.1
 
[DHCP]
RouteMetric=10
ClientIdentifier=mac
 
[DHCPv4]
MaxAttempts=3

this will overwrite the open embeded default config. You need systemd stable version 252 to get the feature IPv4LLStartAddress so we will need to patch it in since Kirkstone ecosystem 4.1 uses v250.

Create the following file <my-layer>/recipes-core/systemd/systemd_250.5.bbappend with the contents of

FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
 
SRC_URI += "file://0001-Enable-IPv4LLStartAddress.patch"
 

then create the following file <my-layer>/recipes-core/systemd/systemd/0001-Enable-IPv4LLStartAddress.patch with the contents from here https://pastebin.pl/view/4a9f8277

and that should do it

1 reply

Hammy
HammyAuthorBest answer
Associate III
January 31, 2023

In Yocto you need to add some configurations to the systemd-networkd recipe. In <my-laye>/recipes/systemd-conf create a systemd-conf_%.bbappend. In that file add

FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"

then make a folder called systemd-conf there and create a file called wired.network (<my-laye>/recipes/systemd-conf/systemd-conf/wired.network). Example contents might be

[Match]
Name=en* eth*
KernelCommandLine=!nfsroot
 
[Network]
DHCP=yes
LinkLocalAddressing=fallback
IPv4LLStartAddress=169.254.1.1
 
[DHCP]
RouteMetric=10
ClientIdentifier=mac
 
[DHCPv4]
MaxAttempts=3

this will overwrite the open embeded default config. You need systemd stable version 252 to get the feature IPv4LLStartAddress so we will need to patch it in since Kirkstone ecosystem 4.1 uses v250.

Create the following file <my-layer>/recipes-core/systemd/systemd_250.5.bbappend with the contents of

FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
 
SRC_URI += "file://0001-Enable-IPv4LLStartAddress.patch"
 

then create the following file <my-layer>/recipes-core/systemd/systemd/0001-Enable-IPv4LLStartAddress.patch with the contents from here https://pastebin.pl/view/4a9f8277

and that should do it