Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am working on an embedded linux system, my aim is to activate ethernet interface at boot time. I am using u-boot as bootloader. I passed ip= and eth= u-boot environment variables to the linux kernel as bootargs and configured linux kernel as IP:kernel level autoconfiguration , enabled. However, that didn't bring the network interface up, as "ifconfig eth0 up" do.

So, I am wondering if it is possible to instruct linux kernel to activate eth0 interface without resorting to user space scripts (ifup and ifconfig)?

share|improve this question

migrated from stackoverflow.com Nov 8 '12 at 13:49

This question came from our site for professional and enthusiast programmers.

    
I think making ONBOOT=yes in this file will solve your problem, file path is /etc/sysconfig/network-scripts/ifcfg-eth0 – max Nov 8 '12 at 13:58

Yes, the Linux kernel can activate eth0 interface without resorting to user space scripts.
You can use the ip= kernel boot parameter to initialize the network interface with a static IP address, for example:

    ip=192.168.1.100:::255.255.255.0:myboard:eth0:on

Of course, the eth0 interface cannot be enabled until drivers have been loaded (as indicated by the freeing of the __init section of memory).
Here's the system log to show when the network interface becomes active:

eth0: link down
IP-Config: Complete:
      device=eth0, addr=192.168.1.100, mask=255.255.255.0, gw=255.255.255.255,
    host=myboard, domain=, nis-domain=(none),
    bootserver=255.255.255.255, rootserver=255.255.255.255, rootpath=
Freeing init memory: 564K
remounting / read-write... done.
mounting /proc... done.
mounting /sys... done.
Creating device nodes manually, running /sbin/makenodes-2.6
eth0: link up, 100Mbps, full-duplex, lpa 0xCDE1
Done.
mounting /home... MTDSB: dev_name "/dev/mtdblock3"

Complete details on the syntax of the ip= boot parameter are in Documentation/filesystems/nfs/nfsroot.txt. Ignore the fact that the original purpose of this capability was to facilitate a networked root filesystem.

I passed ip= and eth= u-boot environment variables to the linux kernel as bootargs

eth= is not a valid boot parameter, and is probably ignored by the kernel.
BTW If you're using Atmel's macb.c driver, then ensure that U-Boot installs the MAC address for the PHY for this to work.

share|improve this answer
    
Thank you for your reply and valuable info. I am not using any of the autoconfiguration protocols: bootp, dhcp or rarp. So, the last parameter would be "off". Also, I am using ramdisk (not nfs) and macb.c driver. I have a u-boot variable called ethaddr that has this value: 00:05:F4:11:22:33. Is this what you meant regarding u-boot to load MAC address for the PHY? How to make sure u-boot installed the MAC? – Aymen Abdelhakim Nov 13 '12 at 13:08
    
I've used that "autoconf" set to "on" simply to enable networking, mostly UDP traffic for the embedded app, and not NFS etc. Like you, I didn't want to have to use an init script. Yes, the ethaddr has to written to the PHY, and U-Boot has to properly initialize the PHY if you expect networking using macb. Please read Atmel's Nicolas Ferre confirm my remarks in at91.com/forum/viewtopic.php/f,12/t,21030 If Ethernet is working in U-Boot, then Linux can also. – sawdust Nov 14 '12 at 20:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .