Yocto Setting the Default Ethernet address and disable DHCP on boot.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Yocto Setting the Default Ethernet address and disable DHCP on boot.

Jump to solution
53,668 Views
michaeldiamond
Contributor III

I have not found anything real concrete on this.  In LTIB there were settings in the menuconfig to be able to set a default IP address, subnet, etc... and turn the dhcp server off.  The kernel uses the UDHCPC and gives the following while booting.

IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready

udhcpc (v1.22.1) started

Sending discover...

Sending discover...

Sending discover...

No lease, forking to background

done.

I am not sure if this can be done from the machine conf file or if I need an .bbappend file somewhere.

Thanks

Michael

Labels (5)
1 Solution
17,317 Views
michaeldiamond
Contributor III

I was able to include the updated interfaces file in yocto by doing the following so others can do this as well.  I added recipes-core in my layer and then added an init-ifupdown folder. Inside that folder I added an init-ifupdown_1.0.bbappend file that contains only;

FILESEXTRAPATHS_prepend := "${THISDIR}/init-ifupdown-1.0:"

Then I put a init-ifupdown-1.0 folder that contains my updated interfaces file for yocto to include.

This is what my interfaces file contains where I set the eth0 to static and manually set it's address.

# /etc/network/interfaces -- configuration file for ifup(8), ifdown(8)

# The loopback interface

auto lo

iface lo inet loopback

# Wireless interfaces

iface wlan0 inet dhcp

  wireless_mode managed

  wireless_essid any

  wpa-driver wext

  wpa-conf /etc/wpa_supplicant.conf

iface atml0 inet dhcp

# Wired or wireless interfaces

auto eth0

iface eth0 inet static

  address 10.254.253.1

  netmask 255.255.255.0

iface eth1 inet dhcp

# Ethernet/RNDIS gadget (g_ether)

# ... or on host side, usbnet and random hwaddr

iface usb0 inet static

  address 192.168.7.2

  netmask 255.255.255.0

  network 192.168.7.0

  gateway 192.168.7.1

# Bluetooth networking

iface bnep0 inet dhcp

Hope this is helpful for someone else.

View solution in original post

6 Replies
17,318 Views
michaeldiamond
Contributor III

I was able to include the updated interfaces file in yocto by doing the following so others can do this as well.  I added recipes-core in my layer and then added an init-ifupdown folder. Inside that folder I added an init-ifupdown_1.0.bbappend file that contains only;

FILESEXTRAPATHS_prepend := "${THISDIR}/init-ifupdown-1.0:"

Then I put a init-ifupdown-1.0 folder that contains my updated interfaces file for yocto to include.

This is what my interfaces file contains where I set the eth0 to static and manually set it's address.

# /etc/network/interfaces -- configuration file for ifup(8), ifdown(8)

# The loopback interface

auto lo

iface lo inet loopback

# Wireless interfaces

iface wlan0 inet dhcp

  wireless_mode managed

  wireless_essid any

  wpa-driver wext

  wpa-conf /etc/wpa_supplicant.conf

iface atml0 inet dhcp

# Wired or wireless interfaces

auto eth0

iface eth0 inet static

  address 10.254.253.1

  netmask 255.255.255.0

iface eth1 inet dhcp

# Ethernet/RNDIS gadget (g_ether)

# ... or on host side, usbnet and random hwaddr

iface usb0 inet static

  address 192.168.7.2

  netmask 255.255.255.0

  network 192.168.7.0

  gateway 192.168.7.1

# Bluetooth networking

iface bnep0 inet dhcp

Hope this is helpful for someone else.

17,317 Views
sergi1
Contributor I

Let me take up this question again. I have performed the steps that you indicate and the problem is when restarting the board does not assign static ip until it does not launch:

Ifdown eth0
Ifup eth0

Do you know what the problem may be?

Thank you.

0 Kudos
17,317 Views
firex
Contributor I

i have the same behavior. i guess it do this because the actual default configuration is systemd. and init.d scripts are not executed. 

0 Kudos
17,317 Views
dariuszzawisko
Contributor II

This is really helpful. Thank you.

0 Kudos
17,317 Views
Yuri
NXP Employee
NXP Employee

  The Yocto does not provide additional pseudo-graphical configuration tool, as
the menuconfig for kernel, which was used under LTIB.
Looks like the only solution is to prepare proper file (manually), that should be located
in /etc/network/interfaces of rootfs.

Template is located in

<Yocto_dir>/fsl-release-bsp/sources/poky/meta-yocto-bsp/recipes-core/init-ifupdown


Please use Linux command

$ man 5 interfaces

for more details about file “interfaces”

Have a great day,
Yuri

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

17,317 Views
michaeldiamond
Contributor III

Thank you for this information.  I was able to adjust the interfaces file and that worked.  Now I just need yocto to place the modified one in my image.