Skip to contentSkip to conversation

MTD, generic physmap memory, MTD_BLOCK

DISCUSSION Michael Stumpf 4 participants 7 messages Dec 13, 2000 – Dec 19, 2000

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

I'm working in embedded LinuxPPC on a system with low RAM and ROM -- 6 meg RAM, 8 meg flash ROM. It seems like that MTD may provide (or almost so) a method for mapping memory space in as a block device. It already appears to sort-of do that, but I was wondering if full support for booting off of non-CFI compliant, but transparently mapped in, memories is either in place now (doesn't seem to be there) or is planned for the future.

It's a trivial driver, and I'll write it / modify existing MTD code if desired/needed, but it really seems important to have so that I can execute-in-place from a cramfs partition in ROM (and also have this as my root partition).

Thoughts? Am I way off the mark here?

Regards-
Michael Stumpf

=====
=====================================================================
Michael J. Stumpf
LinuxPPC enablement
IBM-Austin, TX 512.838.1524 [lab] 512.838.5335 [work]
http://www.pobox.com/~mstumpf

__________________________________________________
Do You Yahoo!?
Yahoo! Shopping - Thousands of Stores. Millions of Products.
http://shopping.yahoo.com/

To unsubscribe, send "unsubscribe mtd" to [email protected]

#1 lore raw
Quoted 7 lines · Michael Stumpf

I'm working in embedded LinuxPPC on a system with low RAM and ROM -- 6 meg RAM, 8 meg flash ROM. It seems like that MTD may provide (or almost so) a method for mapping memory space in as a block device. It already appears to sort-of do that, but I was wondering if full support for booting off of non-CFI compliant, but transparently mapped in, memories is either in place now (doesn't seem to be there) or is planned for the future.

Look at mtdram.c. It might require verylittle modifications to do just what you want.

Quoted 4 lines

It's a trivial driver, and I'll write it / modify existing MTD code if desired/needed, but it really seems important to have so that I can execute-in-place from a cramfs partition in ROM (and also have this as my root partition).

It's impossible to execute_in_place from a cramfs partition since the in-place code is compressed.

Nicolas

To unsubscribe, send "unsubscribe mtd" to [email protected]

#2 lore raw
Quoted 8 lines
Quoted 5 lines

It's a trivial driver, and I'll write it / modify existing MTD code if desired/needed, but it really seems important to have so that I can execute-in-place from a cramfs partition in ROM (and also have this as my root partition).

It's impossible to execute_in_place from a cramfs partition since the in-place code is compressed.

Unless you expand the inode and mark things as uncompressed and aligned and others as compressed. Attached is a patch to cramfs that allows it to access the memory locations that are mapped in directly rather than buffering compressed data..., which is a big fat waste and is a "first step" towards XIPable cramfs. We're working on a cramfs that is XIPable, but only for MIPs. The increased performance of a linearly addressed cramfs partition is pretty decent..., although I haven't figured out a smart way to bootstrap right into the cramfs stuff... (I'm thinking init.c or around there is where I should be looking)

Thanks,
Shane.

Oh, BTW, I finished "a version" of mtd for XIP kernel writable for cfi_cmdset_0001.c, and cfi_probe. I haven't figured out a smart way to deal with having two versions of stuff yet..., because most of the code is the same. You can find it on ftp.agendacomputing.com/pub/kernel/*someversion*/patches . Once I figure out a smart way to do this, and forward port to CVS I'll put it in the mainline MTD code unless there are any nay-sayers.

fs/Config.in +4 -0
diff -urN linux.orig/fs/Config.in linux/fs/Config.in
@@ -29,6 +29,10 @@
 	int 'JFFS debugging verbosity (0 = quiet, 3 = noisy)' CONFIG_JFFS_FS_VERBOSE 0
 fi
 tristate 'Compressed ROM file system support' CONFIG_CRAMFS
+dep_mbool 'Linear addressing for CRAMFS' CONFIG_CRAMFS_LINEAR_ADDRESSING $CONFIG_CRAMFS
+if [ "$CONFIG_CRAMFS_LINEAR_ADDRESSING" != "n" ] ; then
+	hex 'Starting address for CRAMFS filesystem' CONFIG_CRAMFS_LA_ADDRESS bf200008
+fi
 tristate 'Simple RAM-based file system support' CONFIG_RAMFS
 
 tristate 'ISO 9660 CDROM file system support' CONFIG_ISO9660_FS
fs/cramfs/inode.c +35 -0
diff -urN linux.orig/fs/cramfs/inode.c linux/fs/cramfs/inode.c
@@ -11,6 +11,20 @@
  * The actual compression is based on zlib, see the other files.
  */
 
+/* Linear Addressing code
+ *
+ * Copyright (C) 2000 Shane Nay.
+ *
+ * Allows you to have a linearly addressed cramfs filesystem.
+ * Saves the need for buffer, and the munging of the buffer.
+ * Savings a bit over 32k with default PAGE_SIZE, BUFFER_SIZE
+ * etc.  Usefull on embedded platform with ROM :-).
+ *
+ * Downsides- Currently linear addressed cramfs partitions
+ * don't co-exist with block cramfs partitions.
+ *
+ */
+
 #include <linux/module.h>
 #include <linux/fs.h>
 #include <linux/pagemap.h>
@@ -68,6 +82,23 @@
 	return inode;
 }
 
+#if defined(CONFIG_CRAMFS_CRAMFS_LINEAR_ADDRESSING) && defined (CONFIG_CRAMFS_LA_ADDRESS)
+
+/*
+ * Returns a pointer to the linearly addressed filesystem.
+ * Simple byte size pointer addition.
+ */
+static unsigned char* romdisk_top=(unsigned char*) CONFIG_CRAMFS_LA_ADDRESS;
+
+static void *cramfs_read(struct super_block *sb, unsigned int offset, unsigned int len)
+{
+	if (!len)
+		return NULL;
+	return romdisk_top + offset;
+}
+
+#else /* !CONFIG_CRAMFS_LINEAR_ADDRESSING aka Regular block mode */
+
 /*
  * We have our own block cache: don't fill up the buffer cache
  * with the rom-image, because the way the filesystem is set
@@ -149,6 +180,8 @@
 	}
 	return read_buffers[buffer] + offset;
 }
+
+#endif
 			
 
 static struct super_block * cramfs_read_super(struct super_block *sb, void *data, int silent)
@@ -161,10 +194,11 @@
 	set_blocksize(sb->s_dev, PAGE_CACHE_SIZE);
 	sb->s_blocksize = PAGE_CACHE_SIZE;
 	sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
 
+#if !( defined(CONFIG_CRAMFS_CRAMFS_LINEAR_ADDRESSING) && defined (CONFIG_CRAMFS_LA_ADDRESS) )
 	/* Invalidate the read buffers on mount: think disk change.. */
 	for (i = 0; i < READ_BUFFERS; i++)
 		buffer_blocknr[i] = -1;
+#endif
 
 	/* Read the first block and get the superblock from it */

memcpy(&super, cramfs_read(sb, 0, sizeof(super)), sizeof(super));

#3 lore raw

Unless there's something missing (or I'm being dim) that code doesn't do XIP. It still copies from the cramfs into the page provided to cramfs_readpage.

What you want to do is make up some struct pages to represent the pages of the ROM chip and pre-populate the page cache with those pages directly
- marked readonly, of course.

Signature · 6 lines
dwmw2




To unsubscribe, send "unsubscribe mtd" to [email protected]
#4 lore raw
Quoted 7 lines · David Woodhouse

Unless there's something missing (or I'm being dim) that code doesn't do XIP. It still copies from the cramfs into the page provided to cramfs_readpage.

What you want to do is make up some struct pages to represent the pages of the ROM chip and pre-populate the page cache with those pages directly
- marked readonly, of course.

Hehe, no, it's not an XIP implementation. I think I mentioned in my message, even if I didn't make it clear (probably not) that this only made cramfs read directly off of the flash, taking one layer of abstraction out. It kills the buffer, and the copy to buffer that would usually be associated with a dev device, so it speeds up performance of cramfs on a flash device. It's _only_ a performance hack at this point.

But we are working on XIP for cramfs. But this requires either expanding the inode, or stealing a bit or two away from GIDS, or UIDs. This is only a "linear addressing" patch.

Thanks,
Shane.

To unsubscribe, send "unsubscribe mtd" to [email protected]

#5 lore raw
Quoted 3 lines · [email protected] said:

But we are working on XIP for cramfs. But this requires either
expanding the inode, or stealing a bit or two away from GIDS, or UIDs. This is only a "linear addressing" patch.

I was looking at doing it in romfs. You can't have compression anyway, for obvious reasons, and it looked a little easier. But I suppose that wouldn't allow you to mix XIP-able and compressed files in the same fs.

--
dwmw2

To unsubscribe, send "unsubscribe mtd" to [email protected]

#6 lore raw
Quoted 4 lines

I was looking at doing it in romfs. You can't have compression anyway, for obvious reasons, and it looked a little easier. But I suppose that wouldn't allow you to mix XIP-able and compressed files in the same fs.

We *should* have it done this week in romfs. That's our testbed for the first implementation. I'm going on vacation on Wednesday, but if it's done before that I'll point folks to patches on this list. If not I should have them for the next Thursday..., bug me if I don't send it out by then.

Thanks,
Shane.

To unsubscribe, send "unsubscribe mtd" to [email protected]