caolingzi 发表于 2004-3-21 18:45:31

mtd question!

Hi all,

I am working in idt 79EB438 board(mips 4000 core), os is linux(mips kernel), the
board have a 4M flash, i want to use two partitions .At:shock: linux/drivers/mtd/maps, i wrote a file eb438.c for idt 79EB438 board, the file and my .config is in appendage. I think kernel
can not find the address of cramfs-fs, but i do not how to do that!

--------------------- start --------------------
Please Wait. Scanning Memory ...   63 MB free memory

WARNING: en0: $ethaddr0 is not set, using default 08:00:06:05:70:ff

WARNING: en1: $ethaddr1 is not set, using default 08:00:06:05:75:ff

WARNING: Network interface en1 unusable until $netaddr1 is set

IDT System Integration Manager Ver. 11.1 January 2003
Copyright 1994-2002 Integrated Device Technology, Inc.

RC32438 CPU, 32-bit, Little Endian, MIPS-II, Write-Through, no write allocate ce
Console: 9600 baud

Used for Ethernet Storage: 0xA3800000 - 0xA3FFFFFF
Instruction Cache: 16 KB,   Data Cache: 16 KB
Memory Configuration: SDRAM only.
Primary User Memory: 0xA008C1A8 to 0xA37FFFFF. Size: 56783 KB

CAUTION: "C" time functions such as clock() depend on the frequency of
the crystal in socket Y3. Please compare against wall-clock to obtain
a scaling factor if needed!

          For HELP enter '?'

Press any key To Enter IDT/sim1
Serial console port initialized
CPU revision is: 00018009
Primary instruction cache 16kb, linesize 16 bytes (4 ways)
Primary data cache 16kb, linesize 16 bytes (4 ways)
Linux version 2.4.18-mips (root@zhengjie) (gcc version 2.95.4 20010319 (prerele4
PCI: Initializing PCI
Determined physical RAM map:
memory: 04000000 @ 00000000 (usable)
On node 0 totalpages: 16384
zone(0): 16384 pages.
zone(1): 0 pages.
zone(2): 0 pages.
Kernel command line: root=/dev/mtdblock1 rootfstype=cramfs init=linuxrc
Initializing IRQ's: 168 out of 256
calculating r4koff... 000f4240(1000000)
CPU frequency 200.00 MHz
Calibrating delay loop... 199.88 BogoMIPS
Memory: 60968k/65536k available (1128k kernel code, 4568k reserved, 156k data, )
Dentry-cache hash table entries: 8192 (order: 4, 65536 bytes)
Inode-cache hash table entries: 4096 (order: 3, 32768 bytes)
Mount-cache hash table entries: 1024 (order: 1, 8192 bytes)
Buffer-cache hash table entries: 4096 (order: 2, 16384 bytes)
Page-cache hash table entries: 16384 (order: 4, 65536 bytes)
Checking for 'wait' instruction...unavailable.
POSIX conformance testing by UNIFIX
Autoconfig PCI channel 0x803579ac
Scanning bus 00, I/O 0x18800000:0x18900000, Mem 0x50000000:0x60000000
Linux NET4.0 for Linux 2.4
Based upon Swansea University Computer Society NET3.039
Initializing RT netlink socket
Starting kswapd
AttyS00 at 0xb8050000x (irq = 104) is a 16550AMANY_PORTS SHARE_IRQ
SERIAL_PCI ed
block: 128 slots per queue, batch=32
eth0: RC32438 ethernet0 found at 0x18058000
eth0: HW Address 08:00:06:05:40:01
eth0: Rx IRQ 42, Tx IRQ 43
eth1: RC32438 ethernet1 found at 0x18060000
eth1: HW Address 08:00:06:05:50:01
eth1: Rx IRQ 44, Tx IRQ 45
cstm_mips_ixx flash device: 400000 at 11000000
Amd/Fujitsu Extended Query Table v1.2 at 0x0040
MTD flash: Swapping erase regions for broken CFI table.
number of CFI chips: 1
Creating 2 MTD partitions on "MTD flash":
0x00000000-0x00200000 : "main partition"
0x00200000-0x00400000 : "cramfs partition"
NET4: Linux TCP/IP 1.0 for NET4.0
IP Protocols: ICMP, UDP, TCP
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP: Hash tables configured (established 4096 bind 4096)
ip_conntrack (512 buckets, 4096 max)
ip_tables: (C) 2000-2002 Netfilter core team
NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.
NET4: Ethernet Bridge 008 for NET4.0
cramfs: wrong magic
Kernel panic: VFS: Unable to mount root fs on 1f:01
-------------------- end ------------------------------

caolingzi 发表于 2004-3-21 18:46:30

--------my eb438.c----------------------
#include <linux/module.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <asm/io.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/map.h>
#include <linux/mtd/partitions.h>
#include <linux/config.h>

#define WINDOW_ADDR 0x11000000
#define WINDOW_SIZE 0x200000
#define BUSWIDTH 2

static struct mtd_info *mymtd;

__u8 eb438_read8(struct map_info *map, unsigned long ofs)
{
return __raw_readb(map->map_priv_1 + ofs);
}


__u16 eb438_read16(struct map_info *map, unsigned long ofs)
{
return __raw_readw(map->map_priv_1 + ofs);
}


__u32 eb438_read32(struct map_info *map, unsigned long ofs)
{
return __raw_readl(map->map_priv_1 + ofs);
}


void eb438_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
{
memcpy_fromio(to, map->map_priv_1 + from, len);
}


void eb438_write8(struct map_info *map, __u8 d, unsigned long adr)
{
__raw_writeb(d, map->map_priv_1 + adr);
mb();
}


void eb438_write16(struct map_info *map, __u16 d, unsigned long adr)
{
__raw_writew(d, map->map_priv_1 + adr);
mb();
}


void eb438_write32(struct map_info *map, __u32 d, unsigned long adr)
{
__raw_writel(d, map->map_priv_1 + adr);
mb();
}


void eb438_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len)
{
memcpy_toio(map->map_priv_1 + to, from, len);
}


struct map_info eb438_map = {

name: "eb438 flash device",
size: WINDOW_SIZE,
buswidth: BUSWIDTH,
read8: eb438_read8,
read16: eb438_read16,
read32: eb438_read32,
copy_from: eb438_copy_from,
write8: eb438_write8,
write16: eb438_write16,
write32: eb438_write32,
copy_to: eb438_copy_to
};


/****************************************************************************/

/*
* MTD 'PARTITIONING' STUFF
*/

static struct mtd_partition eb438_partitions[] = {
{
name: "kernel",
offset: 0x0,
size: 0x200000,
},
{
name: "cramfs",
offset: 0x200000,
size: 0x200000,
}
};


int __init init_eb438(void)
{

struct mtd_info *mtd;
printk(KERN_NOTICE "eb438 flash device: %x at %x\n", WINDOW_SIZE, WINDOW_ADDR);

eb438_map.map_priv_1 = (unsigned long)ioremap(WINDOW_ADDR, WINDOW_SIZE);

if (!eb438_map.map_priv_1) {
printk("Failed to ioremap\n");
return -EIO;
}

mymtd = do_map_probe("cfi_probe", &eb438_map);

if (mymtd) {
mymtd->module = THIS_MODULE;
mymtd->erasesize = 0x40000;
return add_mtd_partitions(mymtd, eb438_partitions,
sizeof(eb438_partitions) /
sizeof(eb438_partitions) );
}


iounmap((void *)eb438_map.map_priv_1);
return -ENXIO;

}


static void __exit cleanup_eb438(void)
{
if (mymtd) {
del_mtd_partitions(mymtd);
map_destroy(mymtd);
}


if (eb438_map.map_priv_1) {
iounmap((void *)eb438_map.map_priv_1);
eb438_map.map_priv_1 = 0;
}

}

module_init(init_eb438);
module_exit(cleanup_eb438);

caolingzi 发表于 2004-3-21 18:47:04

chenyu,LINUX是不是有两种加载根文件系统的方法,一种是嵌入内核一起编译,另一种是以模块加载? 上面的错误, 通过跟踪, 错误是从mount_root---->read_super---->insert_super------>cramfs_read_super(),就在cramfs_read_super中的错的,我的文件系统的MAJOR是1F:O1,我在内核插入的打印信息也是对的, 好象是不知道文件系统的正确读写地址, 我的根目录是/dev/mtdblock1 , 我烧写的文件系统的地址是0X200000,我想内核是在什么地方把 /dev/mtdblock1 和地址0x200000 相联系上的?
通过在register_filesystem插入打印信息,发现在 我的根文件系统注册之前已经有好几个文件系统注册了, 如 proc-fs, temp-fs, 他们的fs type 的owner 指针都为
00000000, 也就是嵌入加载了!还有就是在这些文件系统前面, 居然还有 root_fs被注册,IDT公司原来提供的ramdisk文件系统也是嵌入和内核编译在一起的,我想如何设置静态嵌入加载文件系统和 动态加载,是不是有一个这两种方式切换的地方?
root_fs是个什么东东呢?

ksh 发表于 2004-3-30 11:17:48

前面加在很多文件系统是正常的。内核处代码有一个读出文件系统超级块,并和系统中已注册的文件系统进行匹配的代码。如果不匹配,就会出现上面的错误。你的mtdblock1到底是什么格式的文件系统呢?
就是说内核读取你的mtdblock的第一个块,和你指定的rootfstype=cramfs比较,发现不是cramfs,建议你换一个rootfstype试试

caolingzi 发表于 2004-3-30 11:40:36

谢谢,我的文件系统是CRAMFS+JFFS2,现在已经搞定了,是IDT内核的一个BUG,地址影射BUG.

caolingzi 发表于 2004-3-30 11:42:48

谢谢,我的文件系统是CRAMFS+JFFS2,现在已经搞定了,是IDT内核的一个BUG,地址影射BUG.
页: [1]
查看完整版本: mtd question!