SLIND Siemens Linux Distribution

From wiki.network-crawler.de
Jump to: navigation, search

Introduction

This How-To refer to the 0.1 version (aka Suffolk) of SLIND: http://www.emdebian.org/slind/. This document describes how to install a SLIND, a Debian based Linux-System, onto a PXE-bootable embedded device. Before performing the installation you must have a host computer running Debian (stable, unstable or testing). Your target device must be connected to the host through a twisted-pair crossover-cable forming a local LAN network. The host is configured as a DHCP server to assign the target an IP address and as a TFTP server to transfer the target a boot loader, PXELINUX, which boots the kernel image via TFTP. The preliminary NFS root file system is a base system generated during the compilation of the SLIND installer. SLIND supports cross development environment, i.e. the target is not necessary of the same architecture as the host, though it's the case in the example described here.

Software requirements on host

Base Packages

The following packages will be needed on the host: gcc-3.3 or gcc-4.0 syslinux xinetd and tftpd-hpa nfs-common and nfs-kernel-server dhcp3-common and dhcp3-server apache2 minicom

apt-get install gcc-3.3 syslinux xinetd tftpd-hpa nfs-common nfs-kernel-server dhcp3-common dhcp3-server apache2 minicom


PXELINUX Boot Loader

To boot up the target, the following are needed:

  • the boot loader binary: pxelinux.0 (from the syslinux package under /usr/lib/syslinux)
  • a corresponding configuration file: /tftpboot/pxelinux.cfg/default
  • a Linux kernel image for the target: bzImage (NOTE: You should build it statically without modules)

They are all put into a directory (e.g. /tftpboot), which is TFTP-exported to the target. In our example PXELINUX is used as the boot loader. The corresponding configuration file (in /tftpboot/pxelinux.cfg/default) could be as following:

For static kernels

serial 0 115200
prompt 1
timeout 20

default linux

label linux
    kernel bzImage
    append rw root=/dev/nfs nfsroot=192.168.1.1:/root/SLIND/installer_image ip=dhcp console=tty0 console=ttyS0,115200

For modularized kernels

serial 0 115200
prompt 1
timeout 20

default linux

label linux
    kernel bzImage
    append rw initrd=initrd root=/dev/nfs nfsroot=192.168.1.1:/root/SLIND/installer_image ip=dhcp console=tty0 console=ttyS0,115200
  • Download your new kernel at: kernel.org
  • Extract it in /usr/src/
cd /usr/src
tar xfvj linux-x.x.x-x.tar.bz2

or

tar xfvz linux-x.x.x-x.tar.gz
  • Create a symlink
ln -s linux-x.x.x-x linux
  • Configure your kernel
vi /usr/src/linux/.config

To compile the kernel for the target NFS root support, network card support, DHCP support and loop device support are must. Others options depend on your needs. Here's the list of the mandatory configuration options:

#
# Networking options
#
CONFIG_IP_PNP=y
CONFIG_IP_PNP_DHCP=y
CONFIG_IP_PNP_BOOTP=y
#
# Block devices
#
CONFIG_BLK_DEV_LOOP=y
#
# Ethernet (10 or 100Mbit)
#
CONFIG_NET_ETHERNET=y
CONFIG_MII=y
CONFIG_my_ethernet_device=y
#
# Network File Systems
#
CONFIG_ROOT_NFS=y
  • Compile kernel
make bzImage

For moularized kernels you also have to:

  • make modules
  • make modules_install

To build a RTAI kernel (for SLIND) look here: RTAI HowTo

Cross-Toolchain

To unpack the uClibc cross-development tool chain for i386 targets install the packages from SLIND host/pool directories in that order:

  • binutils-i486-linux-uclibc_2.16.1-2.slind1_i386.deb
  • libuclibc0-uclibc-i386-cross_0.9.28-1slind0_all.deb
  • libuclibc-dev-uclibc-i386-cross_0.9.28-1slind0_all.deb
  • libgcc1-uclibc-i386-cross_3.4.4-5.slind1_all.deb
  • gcc-3.4-base_3.4.4-5.slind1_i386.deb (NOTE: this package conflicts with Debian gcc-3.4 version, remove the native gcc-3.4 tool chain before installing Slind gcc-3.4-base package.)
  • cpp-3.4-i486-linux-uclibc_3.4.4-5.slind1_i386.deb
  • gcc-3.4-i486-linux-uclibc_3.4.4-5.slind1_i386.deb
  • libstdc++6-uclibc-i386-cross_3.4.4-5.slind1_all.deb
  • libstdc++6-dbg-uclibc-i386-cross_3.4.4-5.slind1_all.deb
  • libstdc++6-dev-uclibc-i386-cross_3.4.4-5.slind1_all.deb
  • g++-3.4-i486-linux-uclibc_3.4.4-5.slind1_i386.deb
  • linux-kernel-headers-uclibc-i386-cross_2.6.12.0-1.slind1_all.deb

Other tool chains should be installed following approximately the same dependencies.

For example add (in /etc/apt/sources.list):

 # SLIND repository
deb http://www.emdebian.org/slind/host suffolk main

Then do:

apt-get update
apt-get install binutils-i486-linux-uclibc \
 libuclibc0-uclibc-i386-cross \
 libuclibc-dev-uclibc-i386-cross \
 libgcc1-uclibc-i386-cross \
 gcc-3.4-base \
 cpp-3.4-i486-linux-uclibc \
 gcc-3.4-i486-linux-uclibc \
 libstdc++6-uclibc-i386-cross \
 libstdc++6-dbg-uclibc-i386-cross \
 libstdc++6-dev-uclibc-i386-cross \
 g++-3.4-i486-linux-uclibc \
 linux-kernel-headers-uclibc-i386-cross

Building SLIND installer

SLIND installer source code locates under http://www.emdebian.org/slind/slind-installer/source/ . To install it:

mkdir ~/SLIND/
cd ~/SLIND/
wget http://www.emdebian.org/slind/slind-installer/source/slind-installer-src-0.1.tar.bz2
tar xjvf slind-installer-src-0.1.tar.bz2
cd slind-installer
make clean
make frontend
make install

Important: You must have connection to the Internet while compiling!
There is a bug too - Bugfix:

vi ~/SLIND/slind-installer-src-0.1/image_packages/e2fsprogs/Makefile

Change E2FSPROGS_SITE=http://dl.sourceforge.net/sourceforge/e2fsprogs to: E2FSPROGS_SITE=http://mesh.dl.sourceforge.net/sourceforge/e2fsprogs/

To do a cross-build (only needed for ARM or PPC targets): either pass ARCH and let Makefile guess a CROSSPREFIX or supply both. One result of the installation above is the preliminary target file system: ~/SLIND/slind-installer/installer_image.

Network configuration

Configure your network interface

with the IP address 192.168.1.1

Configure DHCP Server

Edit the file /etc/dhcp3/dhcpd.conf to make the host a DHCP server which assigns the target an IP-address dynamically on request. As for now, SLIND can only be run with a fixed IP-address, which is specified for the target in the source code. The target will be assigned with the IP 192.168.1.3. The dhcpd-configuration file can look like following:

allow booting;
allow bootp;
option subnet-mask 255.255.255.224;
default-lease-time 600;
max-lease-time 7200;
subnet 192.168.1.0 netmask 255.255.255.0 {
      range 192.168.1.3 192.168.1.3;
      next-server 192.168.1.1;
      option broadcast-address 192.168.1.255;
      filename "pxelinux.0";
}

Configure TFTP Server

Make sure the package tftpd-hpa is installed. Edit xinetd configuration to allow starting TFTP server. Add the following to the file /etc/xinetd.conf:

service tftp
{
     socket_type   = dgram
     protocol      = udp
     wait          = yes
     user          = root
     server        = /usr/sbin/in.tftpd
     server_args   = -s /tftpboot
}

In /etc/default/tftpd-hpa make sure to set

RUN_DAEMON="yes"
OPTIONS="-l -s /tftpboot"

Export NFS-root

To export the tftpboot-directory to the target add the following line to the file /etc/exports:

/root/SLIND/slind-installer/installer_image 192.168.1.3(rw,no_root_squash,sync)

Service Start-up

Do following to start up the corresponding services:

/etc/init.d/xinetd reload
/etc/init.d/xinetd restart
/etc/init.d/nfs-common restart
/etc/init.d/nfs-kernel-server restart
/etc/init.d/dhcp3-server restart

Configure Minicom

echo "pu port /dev/ttyS0" > /etc/minicom/minirc.dfl
echo "pu baudrate 115200" >> /etc/minicom/minirc.dfl
echo "pu bits 8" >> /etc/minicom/minirc.dfl
echo "pu parity N" >> /etc/minicom/minirc.dfl
echo "pu stopbits 1" >> /etc/minicom/minirc.dfl
echo "pu rtscts No" >> /etc/minicom/minirc.dfl

When booting the Target connect it with your serial port and start minicom

Create SLIND mirror

Set up Host as Web-Server

Install package apache2 (i think you already have) and download the packages to the host so that the target would be able to install the SLIND-packages direct from the host.

cd /srv/www
wget -r --no-parent -nH -Pslind http://tux.ww600.siemens.net/pub/slind-iso/suffolk-0.1.files/target/

Or download the slind.iso and do:

mount -t iso9660 -o loop /path/to/slind.iso /mnt
cd /srv/www
ln -s /mnt/target/ slind

Open a web-browser on the host and type in the URL "http://192.168.1.1/slind" you can browse all the SLIND-packages on the host now.

Boot the target

Edit the inittab-file (/etc/inittab) in the NFS root file system to be suitable for the configuration of your serial console (e.g. baudrate 115200) or virtual console if your target is connected to a monitor. Make the line for the serial port in the file ~/SLIND/slind-installer/installer_image/etc/inittab to be:

ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100

or tty0::respawn:/sbin/getty -L tty0 38400

Switch the target on to boot it up. If everything went right during the boot process you should get the following console output:

       ...
       IP-Config: Got DHCP answer from 192.168.1.1, my address is 192.168.1.3
       IP-Config: Complete:
       device=eth0, addr=192.168.1.3, mask=255.255.255.0, gw=192.168.1.1,
       host=192.168.1.3, domain=slind, nis-domain=(none),
       bootserver=192.168.1.1, rootserver=192.168.1.1, rootpath=
       Looking up port of RPC 100003/2 on 192.168.1.1
       Looking up port of RPC 100005/1 on 192.168.1.1
       VFS: Mounted root (nfs filesystem).
       Freeing unused kernel memory: 168k freed


       Welcome to the Erik's uClibc development environment.
       192.168.1.3 login:

Type root and an empty password to login.


Install SLIND

On the host change to the slind-installer source directory for the frontends.

cd ~/SLIND/slind-installer/src/frontends/ncurses/

Run the script "dfuife_curses" to open a frontend for the installation.

./dfuife_curses -r 192.168.1.3:9999

A frontend window is opened for the SLIND installation waiting for the target to connect with it.

Run the script "main.lua" on the target to start up the backend where the selected installation tasks will be carried out and the process on each installation-step will be reported:

cd /usr/share/dfuibe_lua
./main.lua option.booted_from_install_media=true

Backend and frontend communicate through TCP/IP.

After the start-up of the backend one will see the welcome message in the frontend window. As an example, the proceeding in the frontend window can be as following:

  • Choose < Proceed > and press enter.
  • Select < Default (English) > as the language.
  • Input Hostname and Domain name, select < OK > and press enter. For example, input kontron as Hostname and example.com as Domain name.
  • Choose < eth0 > as the network interface.
  • Choose to < DHCP > configure the selected network interface.
  • Choose < Install Linux >
  • Confirm < Install Linux >
  • Select < image: Image Virtual Disk > as the disk on which to install Linux.
  • Choose < Add > to add a partition.
  • Input the following:
       Mountpoint: /
Device: loop
Capacity: 100M
Filesystem: ext2
  • Ignore the WARNING: the / partition should be at least 244M in size or you will risk running out of space during the installation. Proceed anyway by pressing < OK >.
  • It may be possible that some Versions don't have /sbin/mke2fs and needed libs (just cp the files in /lib and /sbin and do a retry)
  • It may also be possible that he can't mount his newly created image - don't panic just mount it for him at the host system ;) like: mount -o loop ~/SLIND/installer_image/slind-installer/[hostname]/image_[Hostname]__slash_.ext2 ~/SLIND/installer_image/mnt/
  • Sit back, light a cigarette and wait a few minutes. TODO: Grid available configurations
  • Select < Busybox >
  • Select < Uclibc >
  • Input the following:
         Mirror URL: http://192.168.1.1/slind
Proxy URL: leave it blank, since all the to-be-installed binaries are on the host which is configure as a web-server.
  • Press < OK > to proceed.
  • Press < Begin Installing Files > to start the installation.
  • Sit back and relax.
  • Linux is now installed. Press < Configure> to configure the system.
  • Select < Exit > if no more configuration is necessary.
  • Choose < Exit > to exit from the installation completely.

A SLIND system image can then be found in the /slind-installer/"Hostname" directory. One is of ext2 file type, the other is jffs2.

Boot SLIND target

Mount the generated ext2 or jffs2 image to a directory which is exported as NFS root, the target can then be started up with the SLIND root file system after a few corresponding configuration. All the following commands are carried out on the host:

cd /tftpboot
mkdir mntroot
mount -o loop ~/SLIND/slind-installer/installer_image/slind-installer/image_Kontron__slash_.ext2 mntroot
cd mntroot
vi etc/fstab //comment out the line for /dev/loop
vi /tftpboot/pxelinux.cfg/default //make sure the /tftpboot/mntroot to be the nfsroot
vi /etc/exports //add one line exporting /tftpboot/mntroot
/etc/init.d/nfs-common restart
/etc/init.d/nfs-kernel-server restart

Boot the target up and login according to you confguration during the installation.

Installing packages are accomplished by the means of the apt package management. All the package-binaries are located in SLIND mirror. An example to install a package named joe, a text editor, is given here. All the commands are carried out on the target:

cd /etc/apt
echo "deb http://tux.ww600.siemens.net/pub/slind-iso/suffolk-0.1.files/target/ slind main" > sources.list
apt-get update
apt-get install joe

Troubleshooting

The target can't configure its network interface:

* Are you using the right network cable (cross-over for direct connection, straight for indicrect connection - for example via a network switch) ?
* Are you connected to the right network interface on host ? Is it configured ?
* Is the kernel configured for your Ethernet device driver (10/100, 1000 or 10000 Mbit) ? Is it compiled in the kernel (not as module) ? 
* Make sure the kernel gets its network configuration either statically from the bootloader or kernel boot parameter "ip=192.168.1.3" or dynamically from the DHCP server (kernel boot parameter "ip=dhcp")

The target can't mount its Root File System via NFS:

* Is "nfsd" running on the host ?
* Is the NFS Root directory exported ?

 host:~# exportfs
 /exports  192.168.1.3
* Is the portmapper using the required RPC services ? 
  
  host:~# rpcinfo -p 192.168.1.1
    program vers proto   port
      100003    2   udp   2049  nfs
      ...    
      100005    1   udp   1003  mountd
      ...


The target doesn't show any initial serial console:

* Are the target's inittab settings for "getty" matching minicom's settings ?
* Is NFS Root configured in the target's /etc/fstab ?
* Embedded shells are optimized for minimal footprint, don't expect too confortable command line interfaces on SLIND devices...

Slind installer can't find any packages:

* Depending on SLIND version, Slind installer may expect/use different URL: http://192.168.1.1/slind or http://192.168.1.1/slind/target. 
* If packages can't be downloaded using a HTTP server try copying a package mirror on the NFS File System and use following URL: file:///mnt/slind/target.

Slind installed couldn't create the file system skeleton or stopped unpacking packages:

* Make sure your installation device is the right size (normaly 50MB). 

TODO: Wartan => graphical admin tool like Webmin
TODO: why no mk2fs in install image
TODO: why no fsck.ext2 in SLIND image
TODO: document SLIND update process

Authors:  Marion Deveaud, Shumin Guo, Philipp Beyer.