Take the 2-minute tour ×
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It's 100% free, no registration required.

So I have a custom minimal kernel I have created which boots fine on the RPI. I'm using busybox for my init process. However I am having some trouble with the ethernet port. (This is on the model B RPI). In my init scripts I have the interface being configured with an IP address I know. (At some point in the future I'll enable DHCP on it.) The problem is the calls to ifconfig are failing. The reason they are failing is because the smsc95xx ethernet interface is not up yet. A few lines down in the boot up process (after I see the ifconfig fail) I see the ethernet interface come up. If I continue on with the command line I can manually configure the ethernet port.

I thought this might be due to me not calling ifconfig at the right runlevel but it seems the busybox inittab does not use runlevels.

Anyways does anyone have an idea how I can run this configuration at the correct moment? I have reproduced a few parts of my script that make my image. Specifically the inittab portion:

# Setup the inittab                                                             
mkdir ${ROOTFS}/etc                                                             
echo "::sysinit:/etc/init.d/rcS                                                 
:1:wait:/etc/init.d/rc1                                                         
:2:wait:/etc/init.d/rc2                                                         
:3:wait:/etc/init.d/rc3                                                         
:4:wait:/etc/init.d/rc4                                                         
:5:wait:/etc/init.d/rc5                                                         
:6:wait:/etc/init.d/rc6                                                         
::askfirst:-/bin/sh                                                             
::restart:/sbin/init                                                            
::ctrlaltdel:/sbin/reboot                                                       
::shutdown:/bin/umount -a -r" > ${ROOTFS}/etc/inittab                           

mkdir ${ROOTFS}/etc/init.d                                                      

echo "#!/bin/sh                                                                 
mount -t proc proc /proc" > ${ROOTFS}/etc/init.d/rcS                            
chmod +x ${ROOTFS}/etc/init.d/rcS                                               

echo "#!/bin/sh                                                                 
" > ${ROOTFS}/etc/init.d/rc1                                                    
chmod +x ${ROOTFS}/etc/init.d/rc1                                               
echo "#!/bin/sh                                                                 

" > ${ROOTFS}/etc/init.d/rc2                                                    
chmod +x ${ROOTFS}/etc/init.d/rc2                                               
echo "#!/bin/sh                                                                 

" > ${ROOTFS}/etc/init.d/rc3                                                    
chmod +x ${ROOTFS}/etc/init.d/rc3                                               
echo "#!/bin/sh                                                                 

" > ${ROOTFS}/etc/init.d/rc4                                                    
chmod +x ${ROOTFS}/etc/init.d/rc4                                               

echo "#!/bin/sh                                                                 
ifconfig eth0 up                                                                
ifconfig eth0 192.168.1.100 netmask 255.255.255.0 broadcast 192.168.1.255       
route add default gw 192.168.1.1                                                
telnetd -l /bin/login                                                           
/bin/sh" > ${ROOTFS}/etc/init.d/rc5                                             
chmod +x ${ROOTFS}/etc/init.d/rc5                                               

echo "#!/bin/sh                                                                 
" > ${ROOTFS}/etc/init.d/rc6                                                    
chmod +x ${ROOTFS}/etc/init.d/rc6     
share|improve this question
1  
I have not done much with busybox so I can't answer your question directly but as you said busybox doesn't use runlevels so I don't know how it is running your scripts at all. See man.he.net/man1/busybox for details. Try putting your ifconfig stuff in rcS. –  Craig Jan 23 '13 at 23:21
    
Yeah, thanks for the suggestion. I had in fact originally had it all in rcS but then I was thinking it might be runlevels... then I realized busybox doesn't do them. Any other ideas? –  David Mokon Bond Jan 24 '13 at 0:56
2  
cron job in the place where the acual ifconfig is to run ifconfig 3~4 seconds later? –  ppumkin Jan 24 '13 at 8:51
    
Yeah, I suppose that would work just fine, but it seems to be a hack. –  David Mokon Bond Jan 24 '13 at 14:22
    
Do the normal distros just have some network daemon that monitors and applies configuration to interfaces when they come up? –  David Mokon Bond Jan 24 '13 at 14:22
show 3 more comments

2 Answers 2

up vote 1 down vote accepted

Have you considered having the kernel configure the interface? This might actually make more sense in a minimalist environment anyway. It requires the "kernel level autoconfiguration" option, CONFIG_IP_PNP. The bootloader then parses the ip= option for the IP address.

ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf>:<dns0-ip>:<dns1-ip>

You can also get it to do DHCP.

share|improve this answer
    
I have not tried this, but I don't have the setup to try it quickly anymore but this looks like what I wanted if it can be done with DHCP. Thanks –  David Mokon Bond Mar 4 at 8:02
    
It will work with DHCP, but that'll need to be enabled in the kernel with CONFIG_IP_PNP_DHCP. Then you set ip=dhcp. –  Fred Mar 4 at 16:47
add comment

In my case, the solution given by Fred works only partially: DNS configuration wasn't set even with <dns0-ip>:<dns1-ip>

I finally just add a sleep 5 command in /etc/init.d/S40network.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.