Preparing a diskless booted i386 Redhat Enterprise 4 system for an embedded i386 processor

This little page summarises what I had to do to get a standard Redhat Enterprise 4 Linux (Scientific Linux CERN 4) distribution ready for my diskless embedded ELAN SC520. No claim is made that the solutions and workarounds found are the most elegant or efficient or general. All I can say is: "It works for me".

Preliminaries

If you didn't do it already prepare for a user build of the rpms. This will be needed to build customised kernel rpms

mkdir $HOME/rpmbuild; cd $HOME/rpmbuild; mkdir BUILD RPMS SRPMS SPECS SOURCES
cd
cat <<EOF > ~/.rpmmacros
%_topdir $HOME/rpmbuild
EOF

Make the code-base i386

Some packages have been specifically compiled for an i686. You need to replace those with their i386 counterparts. Check which ones need to be replaced:

 rpm -qa --queryformat="%{name}-%{version}-%{release}.%{arch}.rpm\n" | \
	 grep i686

Typically these are very few packages. On my machine:

kernel-smp-2.6.9-11.EL.cern.i686.rpm
kernel-smp-devel-2.6.9-11.EL.cern.i686.rpm
openssl-0.9.7a-43.4.i686.rpm
glibc-2.3.4-2.13.i686.rpm
kernel-module-openafs-2.6.9-11.EL.cern-1.4.1-1.cern.i686.rpm
kernel-2.6.9-11.EL.cern.i686.rpm
kernel-module-openafs-2.6.9-11.EL.cernsmp-1.4.1-1.cern.i686.rpm
Assuming that you will create your own kernel package, right now it is sufficient to replace glibc and openssl. This can be done along these lines:
for pkg in $(rpm -qa \
--queryformat="%{name}-%{version}-%{release}.%{arch}.rpm\n" | \
sed -n '/i686/s/i686/i386/p')
do
rpm -Uhv --force http://linuxsoft.cern.ch/cern/slc4X/updates/i386/RPMS/$pkg
done

Problems with application specific i386 incompatibilities

Unfortunately there are some applications, which are marked i386 yet will still fail, typically with a SIGILL. An example is rpm, which at least in version 4.3.3 uses the rdtsc instruction not supported in IA32 before i586. In this specific case it is not even sufficient to recompile, but the sources themselves need to be patched, since inline assembly instructions are not checked for compatibility by the compiler. Solution: either contact the maintainer, or fix the package or do not use it. (The latter is a good option for surprisingly many things on an embedded sytstem!).

Create a root filsystem

Copy the previously prepared root-filesystem
rsync -a --exclude "/proc" --exclude "/sys" marvin:/ \
/tftpboot/root_i386
mkdir /tftpboot/root_i386/proc /tftpboot/root_i386/sys
The root-filesystem you want to use is on a host called marvin to the NFS server.

Prepare rootfile system and ramdisk

Use Redhat's system-config-netboot package. But be sure to use the very latest version. I used 0.1.33. Earlier versions are full of bugs. The RHEL4 rpm is here.

Modifications to the root filesystem

Some small additional problems I had to fix after using system-config-netboot

Create symlinks for system libraries in ramdisk lib directory

Even the last version of system-config-network seems to be broken in this respect. The libraries are not searched in /lib/tls/ixxx. It's probably better to fix this in ld.so.conf.
for f in $(find tls  -name "lib*")  

do
sudo ln -s $f $(basename $f)
done

Prepare a suitable kernel

This is of course easy to do and there is lots of good documentation around. But for me it was the first time to use the rpm mechanism to do it. Install the kernel.src.rpm
rpm -ihv
/afs/cern.ch/project/linux/cern/slc4X/SRPMS/kernel-2.6.9-11.EL.src.rpm
i386 is not anymore a supported target. You have to modify the .spec file. As an example you can have a look at my kernel-x.y.z/-i386.spec file. It is based on the one used in SLC4.

Unpack the sources

rpmbuild -bp SPECS/kernel-x.y.z-i386.spec
The sources will be unpacked into the BUILD directory. Go to the linux directory. Modify kernel configuration to your liking. Copy .config back into the SOURCES directory to the file, which you have previously defined in the .spec file to be used for i386. You can have a look at my (very stripped down) kernel-2.6.9-i386.config file.
cd BUILD/linux-2.6.9
make menuconfig
cp .config ../../SPECS/kernel-2.6.9.ccpc-i386.config
Build the kernel rpms:
rpmbuild -bb --target i386 SPECS/your_spec_file.spec

SM520PCX specific problems

These are really just relevant if you happen to use the specific single board computer I use.


This page last updated 11-11-2005
Comments & questions to Niko Neufeld CERN, LHCb