* Introduction

Here is a small kernel module for booting new kernels on Kuro Box without 
flashing. It loads a new kernel into memory and jumps to it directly.

You need kernel header files to build the module.
I put the kernel source came with my Kuro Box in

http://jan.csie.ntu.edu.tw/~jo/kuro/CD2/linux-2.4.17_kuro-box.tar.gz

You also need a configuration file to build the kernel,
I use the one in

ftp://linkstation.yi.org/pub/linkstation/kernel/config_kurobox.040630

* Building the new kernel

cd /usr/src
tar xzvf ~/linux-2.4.17_kuro-box.tar.gz
cd linux-2.4.17_kuro-box
cp ~/config_kurobox.040630 .config
make oldconfig
make dep
make
# the loader need the kernel to be in binary format
objcopy -O binary vmlinux                    

* Building the loader module

tar xzvf loader.tar.gz
cd loader
# change Makefile for your kernel source directory
make

* Loading the new kernel

sync;insmod loader.o kernel=/usr/src/linux-2.4.17_kuro-box/vmlinux

About one minute later or so, you can again telnet in your kuro box
and verify it is running the new kernel by typing "uname -a".

There are three parameters for this module:

kernel: kernel file name (the kernel must be in binary format)
initrd: initrd file name (it can be a gzip'ed file)
cmdline: kernel command line

For example you can use an ramdisk as your root filesystem:

sync;insmod loader.o kernel=/usr/src/linux-2.4.17_kuro-box/vmlinux \
initrd=/root/initrd.gz cmdline="root=/dev/ram0"

The cmdline parameter doesn't work unless a small patch is applied
to the kernel:

--- arch/ppc/platforms/sandpoint_setup.c.orig   Mon Mar 15 00:15:01 2004
+++ arch/ppc/platforms/sandpoint_setup.c        Sun Jan  9 20:54:55 2005
@@ -666,6 +666,12 @@
        }
 #endif
 
+    if ( r6 )
+    {
+        *(char *)(r7+KERNELBASE) = 0;
+        strcpy(cmd_line, (char *)(r6+KERNELBASE));
+    }
+
 #ifdef NAS_DEBUG
        printk("initrd_start: %08X\n",initrd_start);
        printk("initrd_end: %08X\n",initrd_end);

--
Chih-Chung Chang <jochang@gmail.com>

P.S. This module works for me most of the time, but sometimes it
just crashes. I'd be glad to hear if you have any idea why :)
