linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [Fwd: Re: kernel command line for CRAMFS root filesystem]
@ 2002-06-06 14:41 Julien Eyries
  2002-06-06 15:30 ` Michael Fischer
  0 siblings, 1 reply; 7+ messages in thread
From: Julien Eyries @ 2002-06-06 14:41 UTC (permalink / raw)
  To: linuxppc-embedded


-------- Original Message --------
Subject: Re: kernel command line for CRAMFS root filesystem
Date: Thu, 06 Jun 2002 16:40:33 +0200
From: Julien Eyries <julien.eyries@thales-bm.com>
To: acurtis@onz.com
References: <NCBBIINEHIPFGJPLBEIFKEEIDIAA.acurtis@onz.com>


i have never mounted it before .

i am currently booting with initrd (good :-)) from my flash and it works
fine( the commandline was : root=/dev/rd/0 );
but now i want to replace that with a cramfs (better :-)) .

anyway, i know i can acess to the range (start 0xfe100000 - length
2MBytes) via my partition /dev/mtdblock/2 but if i try something like :
   root=/dev/mtdblock/2 then JFFS2 try to mount it as root filesystem and
fails !!!!!!

maybe i should add something to the commandline, in order to tell the
kernel that /dev/mtdblock/2 contains a CRAMFS partition ??






Allen Curtis wrote:

 >>i have a cramfs image in flash, at address 0xfe100000 (length of image
 >>is 2MBytes).
 >>what is the kernel command line "root=..." to use this image as root
 >>filesystem ?
 >>
 >
 > What is the device name when you mount it from a bootp session? The
name is
 > probably the same...
 >
 >


--
Julien Eyries
R&D engineer
Thales Broadcast & Multimedia (ex-thomcast)
email: julien.eyries@thales-bm.com
fax: 33(0) 1 34 90 31 10
tel: 33(0) 1 34 90 31 01





--
Julien Eyries
R&D engineer
Thales Broadcast & Multimedia (ex-thomcast)
email: julien.eyries@thales-bm.com
fax: 33(0) 1 34 90 31 10
tel: 33(0) 1 34 90 31 01


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [Fwd: Re: kernel command line for CRAMFS root filesystem]
  2002-06-06 14:41 [Fwd: Re: kernel command line for CRAMFS root filesystem] Julien Eyries
@ 2002-06-06 15:30 ` Michael Fischer
  2002-06-06 15:41   ` Julien Eyries
  0 siblings, 1 reply; 7+ messages in thread
From: Michael Fischer @ 2002-06-06 15:30 UTC (permalink / raw)
  To: Julien Eyries; +Cc: linuxppc-embedded


Hello,
> i have never mounted it before .
maybe you should try it from shell first to see if the cramfs is ok.

>
> i am currently booting with initrd (good :-)) from my flash and it works
> fine( the commandline was : root=/dev/rd/0 );
> but now i want to replace that with a cramfs (better :-)) .
>
> anyway, i know i can acess to the range (start 0xfe100000 - length
> 2MBytes) via my partition /dev/mtdblock/2 but if i try something like :
>    root=/dev/mtdblock/2 then JFFS2 try to mount it as root filesystem and
> fails !!!!!!
>
> maybe i should add something to the commandline, in order to tell the
> kernel that /dev/mtdblock/2 contains a CRAMFS partition ??
we use cramfs here and it works without additional parameter. How do you
generate the cramfs and on which kind of system are you using it? The
mkcramfs tool has an endianess problem so if you do mkcramfs on 86x platform
to use it on ppc it wont work. (maybe there is some newer version i am not
aware of where that is fixed)

Hope that helps,
good luck and best regards,
Michael


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Fwd: Re: kernel command line for CRAMFS root filesystem]
  2002-06-06 15:30 ` Michael Fischer
@ 2002-06-06 15:41   ` Julien Eyries
  2002-06-06 16:06     ` Steven Hein
  0 siblings, 1 reply; 7+ messages in thread
From: Julien Eyries @ 2002-06-06 15:41 UTC (permalink / raw)
  To: linuxppc-embedded


> we use cramfs here and it works without additional parameter. How do you
> generate the cramfs and on which kind of system are you using it? The
> mkcramfs tool has an endianess problem so if you do mkcramfs on 86x platform
> to use it on ppc it wont work. (maybe there is some newer version i am not
> aware of where that is fixed)



Well it seems it is the problem ... i have generated cramfs on my x86
and my target is ppc .
is there a simple trick to make my cramfs image correct for ppc ?
should i build my cramfs image on the target ?

thanks,

Julien.


details
-------
ok i boot my target over nfs, and i try to mount my cramfs with :

# mount -t cramfs /dev/mtdblock/2 /mnt/temp
wrong magic
......

# dd if=/dev/mtdblock/2 of=/root/toto.dat bs=1024 count=1


then i switch to my PC (x86) to look at what i have :

#hexdump /root/toto.dat | more
0000000 3d45 28cd 0000 0001 0000 0000 0000 0000
0000010 6f43 706d 6572 7373 6465 5220 4d4f 5346
0000020 6344 2423 98f1 b87f daf3 58a0 b74a a046
0000030 6f43 706d 6572 7373 6465 0000 0000 0000

in cramfs.h :
#define CRAMFS_MAGIC		0x28cd3d45	/* some random number */



--
Julien Eyries
R&D engineer
Thales Broadcast & Multimedia (ex-thomcast)
email: julien.eyries@thales-bm.com
fax: 33(0) 1 34 90 31 10
tel: 33(0) 1 34 90 31 01


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Fwd: Re: kernel command line for CRAMFS root filesystem]
  2002-06-06 15:41   ` Julien Eyries
@ 2002-06-06 16:06     ` Steven Hein
  0 siblings, 0 replies; 7+ messages in thread
From: Steven Hein @ 2002-06-06 16:06 UTC (permalink / raw)
  To: Julien Eyries; +Cc: linuxppc-embedded

[-- Attachment #1: Type: text/plain, Size: 1245 bytes --]

Hi Julien,

Attached is a patch to mkcramfs that adds a "-r" option.  This
reverses the endianness of the CRAMFS filesystem when creating it.
I use this patched mkcramfs to do exactly what you are doing.
It should apply to all kernels up to and including 2.4.18.

Steve


Julien Eyries wrote:
>
> > we use cramfs here and it works without additional parameter. How do you
> > generate the cramfs and on which kind of system are you using it? The
> > mkcramfs tool has an endianess problem so if you do mkcramfs on 86x platform
> > to use it on ppc it wont work. (maybe there is some newer version i am not
> > aware of where that is fixed)
>
> Well it seems it is the problem ... i have generated cramfs on my x86
> and my target is ppc .
> is there a simple trick to make my cramfs image correct for ppc ?
> should i build my cramfs image on the target ?
>
> thanks,
>
> Julien.
>

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Steve Hein (ssh@sgi.com)              Engineering Diagnostics/Software
Silicon Graphics, Inc.
1168 Industrial Blvd.                 Phone: (715) 726-8410
Chippewa Falls, WI 54729              Fax:   (715) 726-6715
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[-- Attachment #2: mkcramfs_endian.patch --]
[-- Type: text/plain, Size: 3267 bytes --]

--- linux-2.4.4/scripts/cramfs/mkcramfs.c.orig	Fri May  4 12:36:58 2001
+++ linux-2.4.4/scripts/cramfs/mkcramfs.c	Fri May  4 12:50:33 2001
@@ -52,6 +52,7 @@
 		" -p         pad by %d bytes for boot code\n"
 		" -s         sort directory entries (old option, ignored)\n"
 		" -z         make explicit holes (requires >= 2.3.39)\n"
+		" -r         reverse endian-ness of filesystem\n"
 		" dirname    root of the filesystem to be compressed\n"
 		" outfile    output file\n", progname, PAD_SIZE);

@@ -78,6 +79,7 @@
 static char *opt_image = NULL;

 static int warn_dev, warn_gid, warn_namelen, warn_skip, warn_size, warn_uid;
+static int swap_endian = 0;

 #ifndef MIN
 # define MIN(_a,_b) ((_a) < (_b) ? (_a) : (_b))
@@ -298,6 +300,50 @@
 	return totalsize;
 }

+/* routines to swap endianness/bitfields in inode/superblock block data */
+static void fix_inode(struct cramfs_inode *inode)
+{
+#define wswap(x)    (((x)>>24) | (((x)>>8)&0xff00) | (((x)&0xff00)<<8) | (((x)&0xff)<<24))
+	/* attempt #2 */
+	inode->mode = (inode->mode >> 8) | ((inode->mode&0xff)<<8);
+	inode->uid = (inode->uid >> 8) | ((inode->uid&0xff)<<8);
+	inode->size = (inode->size >> 16) | (inode->size&0xff00) |
+		((inode->size&0xff)<<16);
+	((u32*)inode)[2] = wswap(inode->offset | (inode->namelen<<26));
+}
+
+static void fix_offset(struct cramfs_inode *inode, u32 offset)
+{
+	u32 tmp = wswap(((u32*)inode)[2]);
+	((u32*)inode)[2] = wswap((offset >> 2) | (tmp&0xfc000000));
+}
+
+static void fix_block_pointer(u32 *p)
+{
+	*p = wswap(*p);
+}
+
+static void fix_super(struct cramfs_super *super)
+{
+	u32 *p = (u32*)super;
+
+	/* fix superblock fields */
+	p[0] = wswap(p[0]);	/* magic */
+	p[1] = wswap(p[1]);	/* size */
+	p[2] = wswap(p[2]);	/* flags */
+	p[3] = wswap(p[3]);	/* future */
+
+	/* fix filesystem info fields */
+	p = (u32*)&super->fsid;
+	p[0] = wswap(p[0]);	/* crc */
+	p[1] = wswap(p[1]);	/* edition */
+	p[2] = wswap(p[2]);	/* blocks */
+	p[3] = wswap(p[3]);	/* files */
+
+	fix_inode(&super->root);
+#undef wswap
+}
+
 /* Returns sizeof(struct cramfs_super), which includes the root inode. */
 static unsigned int write_superblock(struct entry *root, char *base, int size)
 {
@@ -333,6 +379,7 @@
 	super->root.gid = root->gid;
 	super->root.size = root->size;
 	super->root.offset = offset >> 2;
+	if (swap_endian) fix_super(super);

 	return offset;
 }
@@ -347,7 +394,10 @@
 		fprintf(stderr, "filesystem too big.  Exiting.\n");
 		exit(1);
 	}
-	inode->offset = (offset >> 2);
+	if (swap_endian)
+		fix_offset(inode, offset);
+	else
+		inode->offset = (offset >> 2);
 }


@@ -403,6 +453,7 @@
 				stack_entries++;
 			}
 			entry = entry->next;
+			if (swap_endian) fix_inode(inode);
 		}

 		/*
@@ -495,6 +546,7 @@
 		}

 		*(u32 *) (base + offset) = curr;
+		if (swap_endian) fix_block_pointer((u32*)(base + offset));
 		offset += 4;
 	} while (size);

@@ -595,7 +646,7 @@
 		progname = argv[0];

 	/* command line options */
-	while ((c = getopt(argc, argv, "hEe:i:n:psz")) != EOF) {
+	while ((c = getopt(argc, argv, "hEe:i:n:psrz")) != EOF) {
 		switch (c) {
 		case 'h':
 			usage(0);
@@ -625,6 +677,10 @@
 			break;
 		case 'z':
 			opt_holes = 1;
+			break;
+		case 'r':
+			swap_endian = 1;
+			printf("Swapping filesystem endian-ness\n");
 			break;
 		}
 	}

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [Fwd: Re: kernel command line for CRAMFS root filesystem]
@ 2002-06-06 16:08 Kári Davíðsson
  2002-06-06 16:51 ` Julien Eyries
  0 siblings, 1 reply; 7+ messages in thread
From: Kári Davíðsson @ 2002-06-06 16:08 UTC (permalink / raw)
  To: Julien Eyries, linuxppc-embedded


Do not use
root=/dev/mtdblock/2
but
root=/dev/mtdblock2
even if you are using devfs

root=/dev/mdtblock/2 will be interpreted as root=/dev/mtdblock0

This is because of how the kernel parses the root argument on the command line.

Hope this helps,

K.D.

> -----Original Message-----
> From: Julien Eyries [mailto:julien.eyries@thales-bm.com]
> Sent: 6. júní 2002 14:41
> To: linuxppc-embedded@lists.linuxppc.org
> Subject: [Fwd: Re: kernel command line for CRAMFS root filesystem]
>
>
>
> -------- Original Message --------
> Subject: Re: kernel command line for CRAMFS root filesystem
> Date: Thu, 06 Jun 2002 16:40:33 +0200
> From: Julien Eyries <julien.eyries@thales-bm.com>
> To: acurtis@onz.com
> References: <NCBBIINEHIPFGJPLBEIFKEEIDIAA.acurtis@onz.com>
>
>
> i have never mounted it before .
>
> i am currently booting with initrd (good :-)) from my flash
> and it works
> fine( the commandline was : root=/dev/rd/0 );
> but now i want to replace that with a cramfs (better :-)) .
>
> anyway, i know i can acess to the range (start 0xfe100000 - length
> 2MBytes) via my partition /dev/mtdblock/2 but if i try
> something like :
>    root=/dev/mtdblock/2 then JFFS2 try to mount it as root
> filesystem and
> fails !!!!!!
>
> maybe i should add something to the commandline, in order to tell the
> kernel that /dev/mtdblock/2 contains a CRAMFS partition ??
>
>
>
>
>
>
> Allen Curtis wrote:
>
>  >>i have a cramfs image in flash, at address 0xfe100000
> (length of image
>  >>is 2MBytes).
>  >>what is the kernel command line "root=..." to use this
> image as root
>  >>filesystem ?
>  >>
>  >
>  > What is the device name when you mount it from a bootp session? The
> name is
>  > probably the same...
>  >
>  >
>
>
> --
> Julien Eyries
> R&D engineer
> Thales Broadcast & Multimedia (ex-thomcast)
> email: julien.eyries@thales-bm.com
> fax: 33(0) 1 34 90 31 10
> tel: 33(0) 1 34 90 31 01
>
>
>
>
>
> --
> Julien Eyries
> R&D engineer
> Thales Broadcast & Multimedia (ex-thomcast)
> email: julien.eyries@thales-bm.com
> fax: 33(0) 1 34 90 31 10
> tel: 33(0) 1 34 90 31 01
>
>


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Fwd: Re: kernel command line for CRAMFS root filesystem]
  2002-06-06 16:08 Kári Davíðsson
@ 2002-06-06 16:51 ` Julien Eyries
  2002-06-06 18:57   ` Wolfgang Denk
  0 siblings, 1 reply; 7+ messages in thread
From: Julien Eyries @ 2002-06-06 16:51 UTC (permalink / raw)
  To: linuxppc-embedded


now it works !!


1) i have applied by hand the mkcramfs_endian.patch ( i have kernel
2.4.4 from denx )

2) i have added { "mtdblock", 0x1f00 } in init/main.c (that line is
missing in my kernel )

3) and the commandline (for me) is "root=/dev/mtdblock2 ..."

once again, thanks for all your advices ,

Julien



--
Julien Eyries
R&D engineer
Thales Broadcast & Multimedia (ex-thomcast)
email: julien.eyries@thales-bm.com
fax: 33(0) 1 34 90 31 10
tel: 33(0) 1 34 90 31 01


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Fwd: Re: kernel command line for CRAMFS root filesystem]
  2002-06-06 16:51 ` Julien Eyries
@ 2002-06-06 18:57   ` Wolfgang Denk
  0 siblings, 0 replies; 7+ messages in thread
From: Wolfgang Denk @ 2002-06-06 18:57 UTC (permalink / raw)
  To: Julien Eyries; +Cc: linuxppc-embedded


In message <3CFF92FC.8070102@thales-bm.com> you wrote:
>
> now it works !!
>
> 1) i have applied by hand the mkcramfs_endian.patch ( i have kernel
> 2.4.4 from denx )

Just for the record: the  mkcramfs  that  comes  with  our  ELDK  has
support for "-r", too.

Wolfgang Denk

--
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88  Email: wd@denx.de
"Everything should be made as simple as possible, but not simpler."
- Albert Einstein

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2002-06-06 18:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-06-06 14:41 [Fwd: Re: kernel command line for CRAMFS root filesystem] Julien Eyries
2002-06-06 15:30 ` Michael Fischer
2002-06-06 15:41   ` Julien Eyries
2002-06-06 16:06     ` Steven Hein
  -- strict thread matches above, loose matches on Subject: below --
2002-06-06 16:08 Kári Davíðsson
2002-06-06 16:51 ` Julien Eyries
2002-06-06 18:57   ` Wolfgang Denk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).