Project

General

Profile

How to add ifplugd to Busybox

Added by Mary Frantz over 10 years ago

I want to add ifplugd to Busybox so that the system can detect ethernet cable plug/unplug events and reinitialize the network when the cable is plugged in.

I read this page:
https://support.criticallink.com/redmine/projects/arm9-platforms/wiki/Modifying_Busybox

but have some questions.

1) I am using MDK_2012-08-10. Can I get the version of Busybox used in that distribution and the configuration?

The instructions in the above link say (after compiling):

 Copy Busybox to target. You need to copy to an intermediate file (ie. busybox.new) since busybox will be in use.

2) Do I compile busybox to create only the utility I want to add and then put it in a new file on the target? Or, am I adding the utility to an existing version of Busybox and overwriting? If so, how/when is the overwrite achieved? How does the intermediate file become the 'real' file?

Mary


Replies (8)

RE: How to add ifplugd to Busybox - Added by Bob Duke over 10 years ago

Mary,

In regards to question (2) either approach should work. If you want to replace busy box you will need to do that with a filesystem that is not in use. If you're using a MMC card you can copy over the replacement from a another computer. If you are using NAND you can add the updated busybox to your filesystem image and then copy it to NAND.

You can also just copy over busybox.new, add the symbolic link for ifplugd, and be done.

-Bob

RE: How to add ifplugd to Busybox - Added by Mary Frantz over 10 years ago

I have done the following:

Download busybox from http://busybox.net/downloads/

Extract:

tar xf busybox-x.xx.xx.tar.bz2

1. Run the environment setup in a shell

    mitydsp@mitydsp-dev:. /usr/local/oecore-i686/environment-setup-armv5te-angstrom-linux-gnueabi

2a. Make with nothing enabled:

    make CROSS_COMPILE=arm-angstrom-linux-gnueabi- allnoconfig

2b. Make with all components enabled:

    make CROSS_COMPILE=arm-angstrom-linux-gnueabi- defconfig

3. Edit the config

    make CROSS_COMPILE=arm-angstrom-linux-gnueabi- menuconfig

Select the applets you want to include: ifplugd

4. Build

    make CROSS_COMPILE=arm-angstrom-linux-gnueabi-

 5. Copy Busybox to target. You need to copy to an intermediate file (ie. busybox.new) since busybox will be in use.  If the new busybox only includes applets to be added to the default, just copy it to busybox.xxx on the target.

mitydsp@mitydsp-dev:~/workspace/ProjectDir/Debug$ scp busybox.xxx root@192.168.0.151:/bin

6.  Make soft links for each of the utilities you want to use, linking to busybox. For example, to use ifplugd:

    ln -s /bin/busybox.xxx /bin/ifplugd

For ifplugd applet:

7. Create configuration scripts:

/etc/ifplugd/ifplugd.conf
/etc/ifplugd/ifplugd.action

8.  Add startup script

/etc/init.d/ifplugd
ifplugd (373 Bytes) ifplugd Startup script

RE: How to add ifplugd to Busybox - Added by Mary Frantz over 10 years ago

Sorry,... I hit enter before I was done above. Attached are the other script files

To build busybox, I first ran make with nothing enabled (step 2a above), then with menu_config.

I tried starting the ifplugd deamon from the command line, but it does not respond to cable plug/unplug events:

/etc/init.d/ifplugd start

or

/bin/ifplugd -r /etc/ifplugd/ifplugd.action

ps -aux

yields nothing referencing ifplugd

What have I done wrong?

Mary

ifplugd.action (367 Bytes) ifplugd.action script file
ifplugd.conf (41 Bytes) ifplugd.conf script file
busybox.new (14.2 KB) busybox.new executable
config_busybox (30.5 KB) config_busybox .config for busybox, ifplugd only

RE: How to add ifplugd to Busybox - Added by Bob Duke over 10 years ago

Mary,

Based upon a quick review, your method looks OK.

When you remove and reconnect the ethernet cable do you get any messages printed on the console?
What version of the kernel are you running (custom or from which Critical Link MDK)?
Do ifdown and ifup work when you run them manually?

When I needed to get ifplugd working on the MityARM-L138, I compiled it from the source code of the utility itself.

I have attached a file that contains the .action and .conf files I used, along with the .init start script. I've also included the utility source code I used. Inside the src/ directory there are two executables: ifplugd and ifplugstatus. You can try those to see if you have a similar problem.

Please put ifplugd.action and ifplugd.conf in /etc/ifplugd, put the executables in /sbin, and then run # ifplugd.init start.

-Bob

RE: How to add ifplugd to Busybox - Added by Mary Frantz over 10 years ago

When you remove and reconnect the ethernet cable do you get any messages printed on the console?

No messages appear on the console.

What version of the kernel are you running (custom or from which Critical Link MDK)?

MDK_2012-08-10 from Critical Link

Do ifdown and ifup work when you run them manually?

Yes.

RE: How to add ifplugd to Busybox - Added by Mary Frantz over 10 years ago

Sorry about the delay ... other problems to work on, but I finally got back to this.

I copied the files from your archive as suggested by Bob Duke above.

I ran ifplugd.init start and now see it in the process list.

root@mityomapl138:/etc/init.d# ps -aux | grep ifplugd
Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html
root      2482  0.0  0.8   1688   464 ?        S    02:46   0:00 /sbin/ifplugd -
i eth0 -fwI -u0 -d1 -r /etc/ifplugd/ifplugd.action

But still, nothing happens when I disconnect the ethernet cable.

root@mityomapl138:/etc/init.d# PHY: 0:03 - Link is Down

root@mityomapl138:/etc/init.d# ifconfig -a eth0
eth0      Link encap:Ethernet  HWaddr 00:50:C2:BF:8C:0F
          inet addr:192.168.1.89  Bcast:0.0.0.0  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:5064 errors:0 dropped:0 overruns:0 frame:0
          TX packets:461 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:438363 (428.0 KiB)  TX bytes:69017 (67.3 KiB)
          Interrupt:33

Now reconnect the cable:

root@mityomapl138:/etc/init.d# PHY: 0:03 - Link is Up - 100/Full
ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready

root@mityomapl138:/etc/init.d# ifconfig -a eth0
eth0      Link encap:Ethernet  HWaddr 00:50:C2:BF:8C:0F
          inet addr:192.168.1.89  Bcast:0.0.0.0  Mask:255.255.255.0
          inet6 addr: fe80::250:c2ff:febf:8c0f/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:5100 errors:0 dropped:0 overruns:0 frame:0
          TX packets:474 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:440523 (430.1 KiB)  TX bytes:70753 (69.0 KiB)
          Interrupt:33

If I run ifdown from the command line, I see this:

root@mityomapl138:/etc/init.d# ifdown eth0
root@mityomapl138:/etc/init.d# davinci_mdio davinci_mdio.0: resetting idled cont
roller
net eth0: attached PHY driver [Generic PHY] (mii_bus:phy_addr=0:03, id=40005201)

ADDRCONF(NETDEV_UP): eth0: link is not ready
PHY: 0:03 - Link is Up - 100/Full
ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready

root@mityomapl138:/etc/init.d# ifconfig -a eth0
eth0      Link encap:Ethernet  HWaddr 00:50:C2:BF:8C:0F
          inet6 addr: fe80::250:c2ff:febf:8c0f/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:5563 errors:0 dropped:0 overruns:0 frame:0
          TX packets:490 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:471768 (460.7 KiB)  TX bytes:72062 (70.3 KiB)
          Interrupt:33

root@mityomapl138:/etc/init.d#

Now here's ifup from the command line:

root@mityomapl138:/etc/init.d# ifup eth0
udhcpc (v1.19.4) started
Sending discover...
Sending select for 192.168.1.89...
Lease of 192.168.1.89 obtained, lease time 86400
adding dns 192.168.1.254
root@mityomapl138:/etc/init.d# ifconfig -a eth0
eth0      Link encap:Ethernet  HWaddr 00:50:C2:BF:8C:0F
          inet addr:192.168.1.89  Bcast:0.0.0.0  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:5873 errors:0 dropped:0 overruns:0 frame:0
          TX packets:508 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:491731 (480.2 KiB)  TX bytes:76356 (74.5 KiB)
          Interrupt:33

It does not appear that either ifup or ifdown are called. What now?

Mary

RE: How to add ifplugd to Busybox - Added by Mary Frantz over 10 years ago

I added the -sn options in the ifplugd.conf to see debugging messages and found that ifplugd was exiting due to a non 0 return value from the ifplugd.action script. This occurred even though the -I option was set. I changed the last line of ifplugd.action from exit 1 to exit 0 and it now it operates as expected.

Disconnect cable:

root@mityomapl138:/etc/init.d# PHY: 0:03 - Link is Down
davinci_mdio davinci_mdio.0: resetting idled controller
net eth0: attached PHY driver [Generic PHY] (mii_bus:phy_addr=0:03, id=40005201)

ADDRCONF(NETDEV_UP): eth0: link is not ready

root@mityomapl138:/etc/init.d# ifconfig -a eth0
eth0      Link encap:Ethernet  HWaddr 00:50:C2:BF:8C:0F
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:4921 errors:0 dropped:0 overruns:0 frame:0
          TX packets:234 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:304237 (297.1 KiB)  TX bytes:35914 (35.0 KiB)
          Interrupt:33

Reconnect cable:

root@mityomapl138:/etc/init.d# PHY: 0:03 - Link is Up - 100/Full
ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready

root@mityomapl138:/etc/init.d# ifconfig -a eth0
eth0      Link encap:Ethernet  HWaddr 00:50:C2:BF:8C:0F
          inet addr:192.168.1.89  Bcast:0.0.0.0  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4960 errors:0 dropped:0 overruns:0 frame:0
          TX packets:254 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:307726 (300.5 KiB)  TX bytes:40341 (39.3 KiB)
          Interrupt:33

ifplugd.action:

#!/bin/sh
# $Id: ifplugd.action 99 2004-02-08 20:17:59Z lennart $

# This file is part of ifplugd.
#
# ifplugd is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# ifplugd is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with ifplugd; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.

set -e

if [ -z "$1" ] || [ -z "$2" ] ; then
        echo "Wrong arguments" > /dev/stderr
        exit 1
fi

[ "$2" = "up" ] && exec /sbin/ifup $1
[ "$2" = "down" ] && exec /sbin/ifdown $1

exit 0

Is there a reason for using exit 1?
Mary

RE: How to add ifplugd to Busybox - Added by Bob Duke over 10 years ago

Mary, it should be exit 0 at the end of the script, as that indicates successful completion, so the fix you made is OK.

I do not recall making that change in my setup, so it may be a mistake in the original source distribution.

Thanks for the update.

-Bob

    (1-8/8)
    Go to top
    Add picture from clipboard (Maximum size: 1 GB)