Skip to contentSkip to conversation

cramfs/jffs2 bootloader code

DISCUSSION Russ Dill 2 participants 2 messages Jun 19, 2001 Memory technology devices (MTD)

lore
Share & tools
lore

Russ Dill

author
#0 lore raw

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.

#1 lore raw

Does this include the changes on:

http://www.wearablegroup.org/software/bootldr/

which add jffs, jffs2, ymodem, etc to the crl bootldr?

I'm about to release tftpboot from CF ether patches for blob to Erik.

Quoted 7 lines · Russ Dill

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:

Signature · 3 lines
Tim Riker - http://rikers.org/ - short SIGs! <g>
All I need to know I could have learned in Kindergarten
... if I'd just been paying attention.