compile error when using MEMREADOOB in do_mounts.c.
Dear All,
I modified the init/do_mounts.c to want to skip the invalid block. and
than make bzImage, that result say: undefined reference to 'ioctl'. What is the problem?
Thank you.
best regards,
Paul
****** part of init/do_mounts.c *********
#include <linux/mtd/mtd.h>
static int __init fill_inbuf(void)
{
static unsigned long curptr=0L;
if (exit_code) return -1;
#if 1 // for mtd read and check valid block
{
#define MTDBLOCKSIZE 16384
unsigned char oobbuf[16];
struct mtd_oob_buf oob;
oob.length = 16;
oob.ptr = (unsigned char*)&oobbuf;
for (;(curptr%MTDBLOCKSIZE)==0;
curptr =lseek(crd_infd,MTDBLOCKSIZE,1))
{
oob.start = curptr;
if (ioctl(crd_infd, MEMREADOOB, &oob) != 0)
{
return -1; }
if (oobbuf[5] == 0xFF)
break;
}
}
#endif
insize = read(crd_infd, inbuf, INBUFSIZ);
if (insize == 0) return -1;
curptr += insize;
inptr = 1;
return inbuf[0];
}
Quoted 5 lines · Paul Wong
Dear All,
I modified the
init/do_mounts.cto want to skip the invalid block. and
than make bzImage, that result say: undefined reference to 'ioctl'. What is the problem?
ioctl is part of userspace library. You can not use glibc functions inside the kernel.
What's the deeper sense of this modification ? Bad block handling is done by the filesystem and the mtd drivers.
Signature · 5 lines
Thomas ____________________________________________________ linutronix - competence in embedded & realtime linux http://www.linutronix.de mail: [email protected]
Firstly, thanks Thomas,
Let me to explain my system: I separate three partitions of NAND flash (16MB),
/dev/mtd0 for kernel image , use dd if=xxx.img of=/dev/mtd0 /dev/mtd1 for rootfs image , use dd if=roofts.img of=/dev/mtd1 /dev/mtd2 for jffs2 filesystem
Firstly, system decompress and run the compressed kernel image in mtd0, then the kernel (kernel 2.4.20)will decompress the rootfs image in mtd1 to ramdisk. ( I modified the do_mounts.c to do it). Finally, I success to boot up and run normal. But, I see fill_inbuf() in do_mounts.c, it only use the read(..) functon to get the content of the rootfs.img (/dev/mtd1), is it care the bad block??
best regards,
Paul
----- Original Message -----
From: "Thomas Gleixner" <[email protected]>
To: "Paul Wong" <[email protected]>; <[email protected]>
Sent: Friday, January 03, 2003 4:52 PM
Subject: Re: compile error when using MEMREADOOB in do_mounts.c.
Quoted 4 lines · Paul Wong
Quoted 3 lines
Dear All,
I modified the
init/do_mounts.cto want to skip the invalid block.
and
Quoted 1 line
Quoted 1 line
than make bzImage, that result say: undefined reference to 'ioctl'. What
is
Quoted 2 lines
Quoted 1 line
the problem?
ioctl is part of userspace library. You can not use glibc functions inside
the
Quoted 3 lines
kernel.
What's the deeper sense of this modification ? Bad block handling is done
by
Quoted 9 lines
the filesystem and the mtd drivers.
--
Thomas
____________________________________________________
linutronix - competence in embedded & realtime linux
http://www.linutronix.de
mail: [email protected]
Quoted 5 lines · Paul Wong
Firstly, thanks Thomas,
Let me to explain my system: I separate three partitions of NAND flash (16MB),
/dev/mtd0for kernel image , use dd if=xxx.img of=/dev/mtd0
This works only, if you have no bad blocks in your mtd0 partition
Quoted 1 line
/dev/mtd1for rootfs image , use dd if=roofts.img of=/dev/mtd1
Same as above
Quoted 1 line
/dev/mtd2for jffs2 filesystem
Where do you boot from ? I assume NOR-FLASH. Do you have a bootloader there ? You should modify your bootloader to program the kernel image either to the NOR-FLASH itself or to the NAND-FLASH with respect to possible bad blocks . Then your bootloader should load the kernel image from NAND bad block aware to RAM for decrompression or you decompress from your NOR-FLASH. There is no need to have a compressed rootfs. You can also put your root fs on JFFS2, which has compression too. This will save you RAM-space. Also for this image you need your NAND and bad block aware bootloader utility to program the image to the NAND chip.
Quoted 6 lines
Firstly, system decompress and run the compressed kernel image in mtd0, then the kernel (kernel 2.4.20)will decompress the rootfs image in mtd1 to ramdisk. ( I modified the
do_mounts.cto do it). Finally, I success to boot up and run normal. But, I seefill_inbuf()indo_mounts.c, it only use the read(..) functon to get the content of the rootfs.img (/dev/mtd1), is it care the bad block??
No
--
Thomas
________________________________________________________________________
linutronix - competence in embedded & realtime linux
http://www.linutronix.de
mail: [email protected]
----- Original Message -----
From: "Thomas Gleixner" <[email protected]>
To: "Paul Wong" <[email protected]>; <[email protected]>
Sent: Sunday, January 05, 2003 4:32 AM
Subject: Re: compile error when using MEMREADOOB in do_mounts.c.
Quoted 6 lines · Paul Wong
Quoted 5 lines
Firstly, thanks Thomas,
Let me to explain my system: I separate three partitions of NAND flash (16MB),
/dev/mtd0for kernel image , use dd if=xxx.img of=/dev/mtd0
Quoted 8 lines
This works only, if you have no bad blocks in your mtd0 partition
Quoted 1 line
/dev/mtd1for rootfs image , use dd if=roofts.img of=/dev/mtd1Same as above
Quoted 1 line
/dev/mtd2for jffs2 filesystemWhere do you boot from ? I assume NOR-FLASH. Do you have a bootloader
there ?
Quoted 1 line
You should modify your bootloader to program the kernel image either to
the
Quoted 1 line
NOR-FLASH itself or to the NAND-FLASH with respect to possible bad blocks
.
Quoted 1 line
Then your bootloader should load the kernel image from NAND bad block
aware
Quoted 2 lines
to RAM for decrompression or you decompress from your NOR-FLASH. There is no need to have a compressed rootfs. You can also put your root
fs on
Quoted 1 line
JFFS2, which has compression too. This will save you RAM-space. Also for
this
Quoted 2 lines
image you need your NAND and bad block aware bootloader utility to program the image to the NAND chip.
Yes, I modifed the bootloader (in NOR-Flash) that can load kernel image in /dev/mtd0 (NAND flash) and bad block handling. and I also tried the rootfs in JFFS2, but the customer do not shutdown the system by keyboard, just directly power off the unit. then the JFFS2 may be corrupted and cannot boot
up again. The ramdisk is a good solution for this case. So, I want to
modify the do_mounts.c to check the bad block to load the rootfs image to ramdisk.
Quoted 3 lines
Quoted 3 lines
Firstly, system decompress and run the compressed kernel image in mtd0, then the kernel (kernel 2.4.20)will decompress the rootfs image in mtd1
to
Quoted 1 line
Quoted 1 line
ramdisk. ( I modified the
do_mounts.cto do it). Finally, I success to
boot
Quoted 1 line
Quoted 1 line
up and run normal. But, I see
fill_inbuf()indo_mounts.c, it only use
the
Quoted 12 lines
Quoted 2 lines
read(..) functon to get the content of the rootfs.img (
/dev/mtd1), is it care the bad block??No
--
Thomas
________________________________________________________________________
linutronix - competence in embedded & realtime linux
http://www.linutronix.de
mail: [email protected]
Quoted 8 lines · Paul Wong
Yes, I modifed the bootloader (in NOR-Flash) that can load kernel image in
/dev/mtd0(NAND flash) and bad block handling. and I also tried the rootfs in JFFS2, but the customer do not shutdown the system by keyboard, just directly power off the unit. then the JFFS2 may be corrupted and cannot
boot up again. The ramdisk is a good solution for this case. So, I want
to modify thedo_mounts.cto check the bad block to load the rootfs image to ramdisk.
JFFS2 can handle a direct power down. The only way you can loose data, is if you are writing to a file exactly in the moment, when you power down. This does not lead to a fs corruption. JFFS2 can handle this.
Signature · 5 lines
Thomas ________________________________________________________________________ linutronix - competence in embedded & realtime linux http://www.linutronix.de mail: [email protected]
Really! this is a good new. I will try this method when I back to office. Thanks a lots.
Paul
----- Original Message -----
From: "Thomas Gleixner" <[email protected]>
To: "Paul Wong" <[email protected]>; <[email protected]>
Sent: Sunday, January 05, 2003 5:37 PM
Subject: Re: compile error when using MEMREADOOB in do_mounts.c.
Quoted 3 lines · Paul Wong
Quoted 2 lines
Yes, I modifed the bootloader (in NOR-Flash) that can load kernel image
in
Quoted 1 line
Quoted 1 line
/dev/mtd0(NAND flash) and bad block handling. and I also tried the
rootfs
Quoted 3 lines
Quoted 3 lines
in JFFS2, but the customer do not shutdown the system by keyboard, just directly power off the unit. then the JFFS2 may be corrupted and cannot
boot up again. The ramdisk is a good solution for this case. So, I
want
Quoted 1 line
Quoted 1 line
to modify the
do_mounts.cto check the bad block to load the rootfs
image
Quoted 2 lines
Quoted 1 line
to ramdisk.
JFFS2 can handle a direct power down. The only way you can loose data, is
if
Quoted 12 lines
you are writing to a file exactly in the moment, when you power down. This does not lead to a fs corruption. JFFS2 can handle this.
--
Thomas
________________________________________________________________________
linutronix - competence in embedded & realtime linux
http://www.linutronix.de
mail: [email protected]