cramfs/jffs2 bootloader code
Russ Dill
Russ.Dill at asu.edu
Tue Jun 19 16:19:30 EDT 2001
OK, the cramfs/jffs2 bootloader code is finally more or less complete.
These modules allow a bootloader to load a kernel from multiple sources
(ie cramfs, jffs, straight from flash etc). It always load the file
"/linux" right now. Currently included are modules for cramfs, jffs2 and
zImage straight from flash. Currently, the interface is:
struct kernel_loader {
/* Return true if there is a kernel contained at src */
int (* check_magic)(struct part_info *part);
/* load the kernel from the partition part to dst, return the
number
* of bytes copied if successful, zero if not */
u32 (* load_kernel)(u32 *dst, struct part_info *part);
/* A brief description of the module (ie, "cramfs") */
char *name;
};
The bootloader can cycle through the available modules until it finds
one with a matching kernel, at which point it attempts to load the
kernel by that message.
There is a test/ directory for testing the different modules from user
space with debug messages, note that the erasesize is hardcoded.
For the decompressors to function at a decent speed, your bootloader
should enable the i-cache and set flash timings properly. The modules
were written around blob, but should be easily inserted into any
boot_loader, the only file needing specific editing for the boot loader
is load_kernel.c (and possibly some types.h issues).
Example code for within the bootloader below:
void load_kernel(blobStatus *status)
{
int i;
unsigned long size;
struct part_info part;
part.erasesize = MAIN_BLOCK_SIZE;
part.size = KERNEL_LEN;
part.offset = (char *) KERNEL_START;
for (i = 0; loader[i] && !loader[i]->check_magic(&part); i++);
if (!loader[i]) {
SerialOutputString("unable to find kernel, loading raw "
"data and hoping for the
best!\rloading");
size = KERNEL_LEN;
MyMemCpy((u32 *)KERNEL_RAM_BASE,
(u32 *)KERNEL_START, size >> 2);
} else {
SerialOutputString("loading kernel from ");
SerialOutputString(loader[i]->name);
if ((size = loader[i]->load_kernel((u32
*)KERNEL_RAM_BASE,
&part)) == 0) {
SerialOutputString(" error loading kernel!\r");
return;
}
}
SerialOutputString("loaded 0x");
SerialOutputHex(size);
SerialOutputString(" bytes\r");
status->kernelSize = size;
status->kernelType = fromFlash;
}
Current issues (release early, release often)
the cramfs module doesn't follow symlinks when looking for /linux (jffs2
*does* follow symlinks though)
future ideas:
if we can load the kernel from a fs image, why not other things, like a
config, with bootloader parameters (whether or not to load a ramdisk,
etc) as well as append= parameters for the kernel.
I'll also email a patch against blob-1.0.8-pre2 on the lart list.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: load_kernel.tar.bz2
Type: application/octet-stream
Size: 18615 bytes
Desc: not available
Url : http://lists.infradead.org/pipermail/linux-mtd/attachments/20010619/df10c4e9/attachment.obj
More information about the linux-mtd
mailing list