Chinaunix首页 | 论坛 | 博客
  • 博客访问: 952244
  • 博文数量: 214
  • 博客积分: 10173
  • 博客等级: 上将
  • 技术积分: 1867
  • 用 户 组: 普通用户
  • 注册时间: 2007-06-18 13:48
文章分类

全部博文(214)

文章存档

2012年(1)

2010年(13)

2009年(5)

2008年(98)

2007年(97)

分类: LINUX

2007-08-14 20:56:25

JFFS2 文件系统移植到s3c44b0+sst39vf1601总结 [原创 2006-09-06 11:52:50 ] 发表者: nidenuoruo   
字体变小 字体变大

由于我的arm板是仿照优龙公司的开发板制作,uclinux开发包是优龙的2.4.24版本,可能是由于优龙对uclinux包进行过更改,所以对于norflash的JFFS2文件系统不能按照常规的CFI,JEDEC方式检测通过,花费了我3个星期时间,才调试成功.

总结:总是在满怀信心的时候给你打击,总是在快要放弃的时候给你希望

JFFS2 文件系统移植到s3c44b0+sst39vf1601主要步骤:

1.查看uClinux-dist/linux2.4.x/fs/下面是否存在jffs2文件系统文件夹及内容,如果没有则需要添加。

2.更改设备好,防止mtd设备与blkmen冲突。

3.在uClinux-dist/Vender/SamSung/44B0/Makefile中添加mtd,mtdblock设备。

4.选择flash probe类型,CFI,JEDEC,AMD其中之一。我采用“amd_flash”,在amd_flash.c中添加#define SST39VF1601 0x234B,在amd_flash.c中的amd_flash_probe 函数中的amd_flash_info table[]中添加flsh相关信息。

5.在uClinux-dist/linux2.4.x/drivers/mtd/maps/Config.in中添加
    dep_tristate '  AMD Flash device mapped on s3c44b0' CONFIG_MTD_S3C44B0 $CONFIG_MTD

6.在uClinux-dist/linux2.4.x/drivers/mtd/maps/Makefile中添加
obj-$(CONFIG_MTD_S3C44B0)       += s3c44b0.o

7.在chips/amd_flash.c中修改了指令.
40 #define ADDR_UNLOCK_1 0x5555
41 #define ADDR_UNLOCK_2 0x2AAA

8.中断修改
具体检查的函数是:
429 static struct mtd_info *amd_flash_probe(struct map_info *map)
430 {
431 /* Keep this table on the stack so that it gets deallocated after the
432 * probe is done.
433 */

695 save_flags(flags); cli();
696 if ((table_pos[0] = probe_new_chip(mtd, 0, NULL, &temp, table,
697 sizeof(table)/sizeof(table[0])))
698 == -1) {
699 printk(KERN_WARNING
700 "%s: Found no AMD compatible device at location zero\n",
701 map->name);
702 kfree(mtd);
703 restore_flags(flags);
704
705 return NULL;
706 }
707 restore_flags(flags);

具体检测是调用probe_new_chip这个函数,因此我们在这个之前禁止中断(695行),然后完了就恢复(703,707行).
其中需要定义flags为unsigned long flags,否则会编译报错。

9.在uClinux-dist/linux2.4.x/drivers/mtd/maps/中添加flash相应的检测,分区文件s3c44b0.c,相关代码如下:

 *
 * Normal mappings of chips in physical memory
 */

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include

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


static struct mtd_info *mymtd;

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

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

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

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

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

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

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

void s3c44b0_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 s3c44b0_map = {
 name: "SST39VF1601 flash device",
 size: WINDOW_SIZE,
 buswidth: BUSWIDTH,
 read8: s3c44b0_read8,
 read16: s3c44b0_read16,
 read32: s3c44b0_read32,
 copy_from: s3c44b0_copy_from,
 write8: s3c44b0_write8,
 write16: s3c44b0_write16,
 write32: s3c44b0_write32,
 copy_to: s3c44b0_copy_to
};


/*
 * MTD 'PARTITIONING' STUFF
 */


static struct mtd_partition s3c44b0_partitions[] = {
        {
                name: "bootloader (128K)",
                size: 0x20000,
                offset: 0x0,
                mask_flags: MTD_WRITEABLE,
        },
        {
                name: "uClinux_kernel (896K)",
                size: 0xe0000,
                offset: 0x20000,
                mask_flags: MTD_WRITEABLE,
        },
        {
                name: "jffs2 (1024K)",
                size: 0x100000,
                offset: 0x100000
        }
};


int __init init_s3c44b0(void)
{
 int ret;
        printk(KERN_NOTICE "s3c44b0 flash device: %x at %x\n", WINDOW_SIZE, WINDOW_ADDR);
 s3c44b0_map.map_priv_1 = (unsigned long)ioremap(WINDOW_ADDR, WINDOW_SIZE);
        printk("hahahahahahahahahahaha\n");
 #if 0
        if (!s3c44b0_map.map_priv_1) {
         printk("Failed to ioremap\n");
         return -EIO;
        }
 #endif
        printk("bbbbbbbbbbbbbbbbbbbbbb\n");

 mymtd = do_map_probe("amd_flash", &s3c44b0_map);

 if(!mymtd)
 {
 printk("mymtd=0\n");
 }

 if (mymtd) {
 printk(KERN_NOTICE "s3c44b0 flash device: regions = %d\n",mymtd->numeraseregions);
  mymtd->owner = THIS_MODULE;
                mymtd->erasesize=0x10000;

   ret = add_mtd_partitions(mymtd, s3c44b0_partitions,
    sizeof(s3c44b0_partitions) /
    sizeof(struct mtd_partition));
  printk("ret = d%\n",ret);
 }

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

};


static void __exit cleanup_s3c44b0(void)
{
 if (mymtd) {
  del_mtd_partitions(mymtd);
  map_destroy(mymtd);
 }
 if (s3c44b0_map.map_priv_1) {
  iounmap((void *)s3c44b0_map.map_priv_1);
  s3c44b0_map.map_priv_1 = 0;
 }

}

module_init(init_s3c44b0);
module_exit(cleanup_s3c44b0);

10.内核编译编译选项(以下为我调试通过的选项配置)
linux kernel v2.4.24-uc0 configuration

memory technology device(MTD) support
Debugging
(3)debugging verbosity (0=quiet,3=noisy)
MTD partitioning support
Direct char device access to MTD devices
Caching block device access to MTD devices

RAM/ROM/FLASH chip drivers------->
Detect JEDEC JESD21c compatible flash chips
support for AMD/FUJITSU flash chips
older(theorcticallly obsoleted now) drivers for non_CFI chips
AMD compatible flash chip support (non-CFI)

Mapping drivers for chip access----->
support for non-linear mappings of flash chips
AMD flash device mapped on S3c44b0

FILE system---->
Journalling flash file system v2(JFFS2) support
(2) JFFS2 debugging verbosity(0=quiet,2=noisy) 

UCLINUX user CONFIGURATION
Flash tools--->
----MTD utils
mtd--util
erase
erase all
mkfs.jffs2

参考文章:

 

阅读(1718) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~