[Peeweelinux] kernel 2.4 mini-howto

Troy Engel [email protected]
Thu, 06 Jun 2002 10:27:52 -0700


Below follows my basic method for integrating a 2.4 kernel into the 
peeweelinux distro; some steps may be missing, so may not be needed, 
some may not be efficient.  Hey, I was winging it. ;)  Adjust as 
appropriate/necessary.

My build scenario is /usr/local/pwl/Embedded_Build/ - referred to as 
$PWL from now on.

Step 1 - Build yourself the new Kernel (2.4.18)
===============================================
1) Build a custom kernel of the existing 2.2.17 sources.  This ensures 
that you can properly build and deploy a custom kernel on your dev box 
(eg, on RedHat 7.2 you have all the compat-* RPMS installed and know how 
to use them).

2) create a subdir in the PWL build scenario to hold all your nifty 
files -- for me, it's:  $PWL/custom_kernel (referred to as $CUSTOM from 
here on)

3) create $CUSTOM/usr/src, and untar the kernel sources into there. 
Rename "linux" to "linux-2.4.18" (eg), and symlink linux to it.  Just 
like you would in a real kernel build.

4) cd to $CUSTOM/usr/src/linux, run "make mrproper"

5) copy $PWL/kernelbuild/usr/src/linux/.config (notice the dot) to 
$CUSTOM/usr/src/linux/

6) run "make oldconfig", then run "make menuconfig".  choose kernel 
options as appropriate.

7) edit "Makefile" and change "gcc" to "kgcc" (I'm on RH72, using the 
RH62 compat packages)

8) run "make dep", "make bzImage", and "make modules" as normal. 
(remember to source the compat-* script if you need to first!)

9) mkdir -p $CUSTOM/kernel-root/boot and mkdir -p 
$CUSTOM/kernel-root/lib/modules

10) cp arch/i386/boot/bzImage $CUSTOM/kernel-root/boot

11) "make INSTALL_MOD_PATH=$CUSTOM/kernel-root modules_install"


Step 2 - Build the kernel package
=================================
1) cd $CUSTOM/kernel-root

2) cp -a $PWL/kernelbuild/kernel-buildroot/dev .  (I don't know what 
these devices are used for, but figured it couldn't hurt to drag 'em 
along for the ride)


NOTE: at this point, add your custom devices -- eg, the watchdog device. 
  For example, "cd $CUSTOM/kernel-root/dev, mknod watchdog c 10 130"


3) find dev > kernel-2.4.18.list, find boot >> kernel-2.4.18.list, find 
lib >> kernel-2.4.18.list

4) edit kernel-2.4.18.list and add trailing slashes to *all* directory 
names!  Very important that you do this.

5) tar -cf kernel-2.4.18.tar boot/ dev/ lib/

6) cp kernel-2.4.18.* $PWL/packages/Kernel_Custom/


Now, at this point all you need to do is run pwlconfig, go into the 
kernel-custom stuff, and use your new kernel instead of the old one. 
Pretty simple.  However, as suggested in the Changes file, you want to 
update some other files as well (eg, "su" from busybox doesn't work as 
well as insmod).  So, I also built custom packages of the following:

   e2fsprogs-1.27
   emlog-0.40
   modutils-2.4.16
   ppp-2.4.1
   util-linux-2.11r

The exact same scenario as above is used to build these custom packages; 
let's use emlog as an example, as many folks will want that with their 
new kernel.

Step 3 - Build supporting packages (emlog used as example)
==========================================================
1) cd $CUSTOM/usr/src

2) untar emlog-0.40 package

3) cd emlog-0.40, edit "Makefile" to set the path to kernel sources 
(eg,/usr/local/pwl/Embedded_Build/custom_kernel/linux).  Also edit "gcc" 
to use "kgcc" like you did for the kernel above -- not sure if it's 
necessary, but I figured it couldn't hurt.

4) run 'make'

5) mkdir -p $CUSTOM/emlog-root/lib/modules/2.4.18/kernel/drivers/misc/, 
mkdir -p $CUSTOM/emlog-root/usr/bin, mkdir -p $CUSTOM/emlog-root/var/log

6) cp emlog.o 
$CUSTOM/emlog-root/lib/modules/2.4.18/kernel/drivers/misc/, cp nbcat 
$CUSTOM/emlog-root/usr/bin

7) cd $CUSTOM/emlog-root/var/log, mknod messages c 241 8

8) find lib > emlog-0.40-2.4.18.list, find usr >> 
emlog-0.40-2.4.18.list, find var >> emlog-0.40-2.4.18.list

9) edit emlog-0.40-2.4.18.list and add trailing slashes to paths

10) tar -cf emlog-0.40-2.4.18.tar lib/ usr/ var/

11) cp emlog-0.40-2.4.18.* $PWL/packages/Kernel_Custom/


Now you can do like you did for the kernel, and just go select the new 
emlog package (don't forget to deselect the old kernel-2.2.17 one!) to 
get the module installed.  You still need to deploy your own 
'rc.modules' script to actually "insmod emlog" on boot.

NOTE: you *must* build the modutils and use that insmod to load emlog.o 
-- I found that trying to use the 'old' one symlinked to busybox didn't 
work due to unresolved dependancies.

The only other real custom thing with the supporting packages was the 
ppp device; you need to make sure you "mknod ppp c 108 0" in a dev/ tree 
and add that to your ppp-2.4.1.list packaging.  This is buried in some 
doc somewhere that I found.

Errors, omissions, etc - please feel free to correct and enhance.  I've 
replaced and rebuilt and customized so much, I'm not sure what I could 
have missed here.... (eg, lots of crap to suppport Unix98 ptys so telnet 
logins work)

-te

-- 
Troy Engel, Systems Engineer
Hockey. Kinda like Figure Skating in a War Zone.