4

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     

2 Answers2

1

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.

Fred
  • 4,592
  • 19
  • 29
0

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.