root jffs2 filesystem on blkmtd emulated device

Mike Mattice mike at forestsidingsupply.com
Tue Apr 9 12:42:06 EDT 2002


I've got a flash based ide module which is too small for my needs w/o 
compression.  So, I'm trying to get this to use jffs2 as it's root 
filesystem type.   I've run into a bit of a problem.

After applying the following patch, using the attached config, and passing 
'blkmtd=/dev/hdc2' to the kernel and setting the root device to 
'/dev/mtdblock/0' via lilo, I get this on the console.  (hand typed, but 
should be very close)

Universal TUN/TAP device driver 1.4 (C)1999-2001 Maxim Krasnyansky
blkmtd: device = `/dev/hdc2' erase size = 128K readonly = no queue size = 512
blkmtd: found a block device major = 22, minor = 2
blkmtd: devname = ide1(22,2)
blkmtd: size = 15171584
blkmtd: init: found 3 erase regions
mtd: Giving out device 0 to blkmtd: /dev/hdc2
blkmtd loaded: version = 1.7 using /dev/hdc2 erase_size = 128K
blkmtd writetask: starting (pid = 10)
Net4: Linux TCP/IP 1.0 for NET4.0
<blah, blah>
NET4: Unix domain sockets 1.0/SMP for Linux Net4.0.
mtdblock_open
ok
mtdblock_open
mtdblock_release
invalidating device
ok
writing cached data
ok
mtdblock_open
mtdblock_release
invalidating device


At this point it just hangs.  Does anybody have any idea why it wouldn't be
able to invalidate the device in mtdblock_release?


diff -rNubBw linux-2.4.18.orig/drivers/mtd/devices/blkmtd.c linux-2.4.18.mtddevel/drivers/mtd/devices/blkmtd.c
--- linux-2.4.18.orig/drivers/mtd/devices/blkmtd.c	Tue Apr  9 11:08:22 2002
+++ linux-2.4.18.mtddevel/drivers/mtd/devices/blkmtd.c	Tue Apr  9 09:50:15 2002
@@ -53,6 +53,7 @@
 #include <linux/pagemap.h>
 #include <linux/mtd/compatmac.h>
 #include <linux/mtd/mtd.h>
+#include <linux/ctype.h>
 
 #ifdef CONFIG_MTD_DEBUG
 #ifdef CONFIG_PROC_FS
@@ -130,6 +131,8 @@
 int bs;          /* optionally force the block size (avoid using) */
 int count;       /* optionally force the block count (avoid using) */
 int wqs;         /* optionally set the write queue size */
+char bootdevice[64];
+int bootdevset = 0;
 
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
@@ -1073,9 +1076,13 @@
 
   /* Check args */
   if(device == 0) {
+    if (bootdevset) {
+      device = &bootdevice;
+    } else {
     printk("blkmtd: error, missing `device' name\n");
     return -EINVAL;
   }
+  }
 
   if(ro)
     readonly = 1;
@@ -1312,6 +1319,26 @@
     __free_pages(erase_page, 0);
   return err;
 }
+
+static int __init blkmtd_setup(char *line)
+{
+        int i;
+        char ch;
+
+	bootdevset = 1;
+        memset (bootdevice, 0, sizeof bootdevice);
+        for (i = 0; i < sizeof bootdevice - 1; ++i)
+        {
+            ch = line[i];
+            if ( isspace (ch) || (ch == ',') || (ch == '\0') ) break;  
+	    // don't have to worry about setting the last char to \0, 
+	    // because the memset has taken care of that for us.
+            bootdevice[i] = ch;
+        }
+        return 1;
+}
+
+__setup("blkmtd=", blkmtd_setup);
 
 module_init(init_blkmtd);
 module_exit(cleanup_blkmtd);
diff -rNubBw linux-2.4.18.orig/drivers/mtd/mtdblock.c linux-2.4.18.mtddevel/drivers/mtd/mtdblock.c
--- linux-2.4.18.orig/drivers/mtd/mtdblock.c	Thu Oct 25 15:58:35 2001
+++ linux-2.4.18.mtddevel/drivers/mtd/mtdblock.c	Tue Apr  9 10:57:05 2002
@@ -371,17 +371,24 @@
 	if (inode == NULL)
 		release_return(-ENODEV);
 
+	DEBUG(MTD_DEBUG_LEVEL1, "invalidating device\n");
+	  
 	invalidate_device(inode->i_rdev, 1);
 
+	DEBUG(MTD_DEBUG_LEVEL1, "ok\n");
+
 	dev = MINOR(inode->i_rdev);
 	mtdblk = mtdblks[dev];
 
+	DEBUG(MTD_DEBUG_LEVEL1, "writing cached data\n");
+
 	down(&mtdblk->cache_sem);
 	write_cached_data(mtdblk);
 	up(&mtdblk->cache_sem);
 
 	spin_lock(&mtdblks_lock);
 	if (!--mtdblk->count) {
+	  DEBUG(MTD_DEBUG_LEVEL1, "freeing device\n");
 		/* It was the last usage. Free the device */
 		mtdblks[dev] = NULL;
 		spin_unlock(&mtdblks_lock);
diff -rNubBw linux-2.4.18.orig/fs/jffs2/scan.c linux-2.4.18.mtddevel/fs/jffs2/scan.c
--- linux-2.4.18.orig/fs/jffs2/scan.c	Thu Oct  4 17:13:18 2001
+++ linux-2.4.18.mtddevel/fs/jffs2/scan.c	Tue Apr  9 10:41:30 2002
@@ -171,7 +171,7 @@
 		return 1;	/* special return code */
 	}
 	
-	noise = 10;
+	noise = 0; // mdm - 10
 
 	while(ofs < jeb->offset + c->sector_size) {
 		ssize_t retlen;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clean-config.gz
Type: application/octet-stream
Size: 596 bytes
Desc: not available
Url : http://lists.infradead.org/pipermail/linux-mtd/attachments/20020409/23bdabd9/attachment.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mtddevel.patch.gz
Type: application/octet-stream
Size: 1274 bytes
Desc: not available
Url : http://lists.infradead.org/pipermail/linux-mtd/attachments/20020409/23bdabd9/attachment-0001.obj 


More information about the linux-mtd mailing list