参照llg写的关于hharm(e28f128flash)上的jffs2的移植
具体如下:
1.移植环境:
CPU:ARMS3C2410
Linux version:2.4.18
Flash:Intel E28F128
2.修改设备号
由于ROM设备和MTDBlock设备的主设备号(major)都是31,所以如果你不想把JFFS2作为根文件系统的话,必须修改他们之一的major。如果你要修改JFFS2的设备major,在uClinux-dist/linux-2.4.x/include/linux/mtd/mtd.h中把
#define MTD_BLOCK_MAJOR 31
改成
#define MTD_BLOCK_MAJOR 30
3.编写Maps文件
添加在flash上的map文件。在HHARM2410-R3/kernel/drivers/mtd/maps下添加flash(e28f128j3a-150)的map,我把握的文件内容贴上,仅供参考:
S3c2410_wpq.c
- /*
- * Normal mappings of chips on Samsung s3c2410 in physical memory
- */
- #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 0x01000000 //基地址
- #define WINDOW_SIZE 0x01600000 //flash大小 16M
- #define BUSWIDTH 2
- static struct mtd_info *mymtd;
- __u8 s3c2410_read8(struct map_info *map, unsigned long ofs)
- {
- return readb(map->map_priv_1 + ofs);
- }
- __u16 s3c2410_read16(struct map_info *map, unsigned long ofs)
- {
- return readw(map->map_priv_1 + ofs);
- }
- __u32 s3c2410_read32(struct map_info *map, unsigned long ofs)
- {
- return readl(map->map_priv_1 + ofs);
- }
- void s3c2410_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
- {
- memcpy(to, (void *)(map->map_priv_1 + from), len);
- }
- void s3c2410_write8(struct map_info *map, __u8 d, unsigned long adr)
- {
- writeb(d, map->map_priv_1 + adr);
- }
- void s3c2410_write16(struct map_info *map, __u16 d, unsigned long adr)
- {
- writew(d, map->map_priv_1 + adr);
- }
- void s3c2410_write32(struct map_info *map, __u32 d, unsigned long adr)
- {
- writel(d, map->map_priv_1 + adr);
- }
- void s3c2410_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len)
- {
- memcpy((void *)(map->map_priv_1 + to), from, len);
- }
- struct map_info s3c2410_map =
- {
- name: "s3c2410 flash device",
- size: WINDOW_SIZE,
- buswidth: BUSWIDTH,
- read8: s3c2410_read8,
- read16: s3c2410_read16,
- read32: s3c2410_read32,
- copy_from: s3c2410_copy_from,
- write8: s3c2410_write8,
- write16: s3c2410_write16,
- write32: s3c2410_write32,
- copy_to: s3c2410_copy_to,
- map_priv_1: WINDOW_ADDR,
- map_priv_2: -1,
- };
- //以下是分区的内容,当然要根据你自己的需要确定了
- static struct mtd_partition s3c2410_partitions[] =
- {
- {
- name: "reserved for bootloader",
- size: 0x040000,
- offset: 0x0,
- mask_flags: MTD_WRITEABLE,
- },
- {
- name: "reserved for kernel",
- size: 0x0100000,
- offset: 0x040000,
- mask_flags: MTD_WRITEABLE,
- },
- {
- name: "reserved for ramdisk",
- size: 0x400000,
- offset: 0x140000,
- mask_flags: MTD_WRITEABLE,
- },
- {
- name: "jffs2(8M)",
- size: 0x800000,
- offset: 0x800000,
- }
- };
- int __init init_s3c2410(void)
- {
- printk(KERN_NOTICE "s3c2410 flash device: %x at %x\n", WINDOW_SIZE, WINDOW_ADDR);
- s3c2410_map.map_priv_1 = (unsigned long)ioremap(WINDOW_ADDR, WINDOW_SIZE);
- //printk("0\n");
- if (!s3c2410_map.map_priv_1) {
- printk("Failed to ioremap/n");
- return -EIO;
- }
- //printk("1\n");
- mymtd = do_map_probe("jedec_probe", &s3c2410_map);
- if (!mymtd)
- mymtd = do_map_probe("cfi_probe", &s3c2410_map);
- //printk("2\n");
- if (mymtd) {
- mymtd->module = THIS_MODULE;
- mymtd->erasesize = 0x20000; //擦除的大小 INTEL E28F128J3A-150 是128kb
- return add_mtd_partitions(mymtd, s3c2410_partitions, sizeof(s3c2410_partitions) / sizeof(struct mtd_partition));
- }
- //printk("3\n");
- iounmap((void *)s3c2410_map.map_priv_1);
- return -ENXIO;
- }
- static void __exit cleanup_s3c2410(void)
- {
- if (mymtd) {
- del_mtd_partitions(mymtd);
- map_destroy(mymtd);
- }
- if (s3c2410_map.map_priv_1) {
- iounmap((void *)s3c2410_map.map_priv_1);
- s3c2410_map.map_priv_1 = 0;
- }
- }
- module_init(init_s3c2410);
- module_exit(cleanup_s3c2410);
至于其文件内容及语句的含义网上相关的文章也有不少,参考一下吧。
4.将配置加入HHARM2410-R3/kernel/drivers/mtd/maps/Config.in
- if [ "$CONFIG_ARM" = "y" ]; then
- dep_tristate ' CFI Flash device mapped on ARM Integrator/P720T' CONFIG_MTD_ARM_INTEGRATOR $CONFIG_MTD_CFI $CONFIG_ARCH_INTEGRATOR
- dep_tristate ' Cirrus CDB89712 evaluation board mappings' CONFIG_MTD_CDB89712 $CONFIG_MTD_CFI $CONFIG_ARCH_CDB89712
- dep_tristate ' CFI Flash device mapped on StrongARM SA11x0' CONFIG_MTD_SA1100 $CONFIG_MTD_CFI $CONFIG_ARCH_SA1100 $CONFIG_MTD_PARTITIONS
- dep_tristate ' CFI Flash device mapped on DC21285 Footbridge' CONFIG_MTD_DC21285 $CONFIG_MTD_CFI $CONFIG_ARCH_FOOTBRIDGE $CONFIG_MTD_PARTITIONS
- dep_tristate ' CFI Flash device mapped on Lubbock board' CONFIG_MTD_LUBBOCK $CONFIG_MTD_CFI $CONFIG_ARCH_LUBBOCK $CONFIG_MTD_PARTITIONS
- dep_tristate ' CFI Flash device mapped on the FortuNet board' CONFIG_MTD_FORTUNET $CONFIG_MTD_CFI $CONFIG_ARCH_FORTUNET $CONFIG_MTD_PARTITIONS
- dep_tristate ' CFI Flash device mapped on Epxa10db' CONFIG_MTD_EPXA10DB $CONFIG_MTD_CFI $CONFIG_MTD_PARTITIONS $CONFIG_ARCH_CAMELOT
- dep_tristate ' CFI Flash device mapped on PXA CerfBoard' CONFIG_MTD_PXA_CERF $CONFIG_MTD_CFI $CONFIG_ARCH_PXA_CERF $CONFIG_MTD_PARTITIONS
- dep_tristate ' NV-RAM mapping AUTCPU12 board' CONFIG_MTD_AUTCPU12 $CONFIG_ARCH_AUTCPU12
- #wpq add S3C2410 的CFI配置
- dep_tristate ' CFI Flash device mapped on S3C2410' CONFIG_MTD_S3C2410 $CONFIG_MTD_CFI
- fi
5. 修改Makefile文件
在HHARM2410-R3/kernel/drivers/mtd/maps/ Makefile文件中加入如下语句(当然要根据你的实际情况写啊?!):
#wpq add
obj-$(CONFIG_MTD_S3C2410) += s3c2410_wpq.o