Hello
Today i finally write the bootloader to NAND chumby . The process is:
1. Download modified kernel image Using bunnie hostBoot, The modifications are:
1.1 with the chumby page's kernel the serial port work at 38400 Baud only. If i replace drivers/serial/imx.c with this one: http://coglinux.cvs.sourceforge.net/cog … iew=markup the serial port "accept" the kernel COMMAND LINE options.
1.2 Add ext3 filesystem support, downloading images to internal RAM is very slow, so i use a external storage device for the filesystem, i use a buildroot based linux filesystem and modify:
#define CMDLINE "console=ttyS0,38400 root=/dev/ram0 rootfstype=minix init=/linuxrc rw"
to:
#define CMDLINE "console=ttyS0,115200n8 root=/dev/sda2 rootfstype=ext3 rootdelay=6"
in the file: http://files.chumby.com/hostboot/setupKernel.c
At this point you can boot linux from RAM using a USB flash memory.
2. Write the bootloader binary to the NAND flash. Linux already have the MTD driver for this, but there is a problem, the first nand block (16kb) is marked from factory as a bad block, the mtd linux driver skip the bad blocks for write and erase, so is necessary change this driver for write this "bad block" the changes are:
2.1 in linux-2.6.16/drivers/mtd/nand/nand_base.c :
/* Check if we have a bad block, we do not erase bad blocks ! */
#if 0
if (nand_block_checkbad(mtd, ((loff_t) page) << this->page_shift, 0, allowbbt)) {
printk (KERN_WARNING "nand_erase: attempt to erase a bad block at page 0x%08x\n", page);
instr->state = MTD_ERASE_FAILED;
goto erase_exit;
}
#endif
2.2 In mtd_orig/util/flash_eraseall.c in main function add:
bbtest = 0; //CAIN
2.3 In mtd_orig/util/nandwrite.c :
#if 0
/* Check all the blocks in an erase block for bad blocks */
do {
if ((ret = ioctl(fd, MEMGETBADBLOCK, &offs)) < 0) {
perror("ioctl(MEMGETBADBLOCK)");
goto closeall;
}
if (ret == 1) {
baderaseblock = 1;
if (!quiet)
fprintf (stderr, "Bad block at %x, %u block(s) from %x will be skipped\n", (int) offs, blockalign, blockstart);
}
if (baderaseblock) {
mtdoffset = blockstart + meminfo.erasesize;
}
offs = 0;//+= meminfo.erasesize / blockalign ; CAIN
} while ( offs < blockstart + meminfo.erasesize );
#endif
This ugly changes must be fixed to skip only the first block !!!
finally if you type:
flash_erase_all /dev/mtd0
..
flash_erase_all /dev/mtd7
nandwrite -p /dev/mtd0 bl.bin
nandwrite -p /dev/mtd1 psp.bin
nandwrite -p /dev/mtd2 k1.bin
nandwrite -p /dev/mtd3 rfs1.bin
nandwrite -p /dev/mtd4 k1.bin
nandwrite -p /dev/mtd5 rfs1.bin
You have a funcional chumby !!!
Best Regards
PDTA: Ed Sutter and me are working on nand flash support for chumby with u-mon, at present we can run a U-MON RAM version download binaries to ram and we start to write nand functions..