1.移植环境:
CPU:S Flash:Intel E 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下添加自己mcu的map,我把握的文件内容贴上,仅供参考: S /* * Normal mappings of chips on Samsung s */ #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大小 #define BUSWIDTH 2 static struct mtd_info *mymtd; __u8 s { return readb(map->map_priv_1 + ofs); } __u16 s { return readw(map->map_priv_1 + ofs); } __u32 s { return readl(map->map_priv_1 + ofs); } void s { memcpy(to, (void *)(map->map_priv_1 + from), len); } void s { writeb(d, map->map_priv_1 + adr); } void s { writew(d, map->map_priv_1 + adr); } void s { writel(d, map->map_priv_1 + adr); } void s { memcpy((void *)(map->map_priv_1 + to), from, len); } struct map_info s name: "s size: WINDOW_SIZE, buswidth: BUSWIDTH, read8: s read16: s read32: s copy_from: s write8: s write16: s write32: s copy_to: s map_priv_1: WINDOW_ADDR, map_priv_2: -1, };
//以下是分区的内容,当然要根据你自己的需要确定了 static struct mtd_partition s { 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( size: 0x800000, offset: 0x800000, } }; int __init init_s { printk(KERN_NOTICE "s s //printk("0\n"); if (!s printk("Failed to ioremap/n"); return -EIO; } //printk("1\n"); mymtd = do_map_probe("jedec_probe", &s if (!mymtd) mymtd = do_map_probe("cfi_probe", &s //printk("2\n"); if (mymtd) { mymtd->module = THIS_MODULE; mymtd->erasesize = 0x20000; //擦除的大小 INTEL E return add_mtd_partitions(mymtd, s } //printk("3\n"); iounmap((void *)s return -ENXIO; } static void __exit cleanup_s { if (mymtd) { del_mtd_partitions(mymtd); map_destroy(mymtd); } if (s iounmap((void *)s s } } module_init(init_s module_exit(cleanup_s 至于其文件内容及语句的含义不想多说了,网上相关的文章也有不少,参考一下吧。 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 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 #llg add S dep_tristate ' CFI Flash device mapped on S fi 5. 编译内核、下载
1)make menuconfig将4加入的内容选中 2)在make menuconfig下配置选项。(抄的。可能不太一样,只要你配置对了就可以了) 在linux Kernel v Memory Technology Devices(MTD)下 CONFIG_MTD=Y CONFIG_MTD_DEBUG=Y CONFIG_MTD_DEBUG_VERBOSE=3 CONFIG_MTD_PARTITIONS=Y CONFIG_MTD_CHAR=Y CONFIG_MTD_BLOCK=Y RAM/ROM/Flash chip drivers下 CONFIG_MTD_CFI=Y CONFIG_MTD_JEDECPROBE=Y CONFIG_MTD_CFI_AMDSTD=Y Mapping drivers for chip access下 CONFIG_S File systems下 CONFIG_JFFS2_FS=Y CONFIG_JFFS2_FS_DEBUG=2 在uClinux v Flash Tools下 CONFIG_USER_MTDUTILS=Y CONFIG_USER_MTDUTILS_ERASE=Y CONFIG_USER_MTDUTILS_ERASEALL=Y CONFIG_USER_MTDUTILS_MKFSJFFS2=Y 3)make zImage 重新编译内核 4)下载到内存或flash 6.检查jffs2是否配置成功
根据上述的修改,启动armlinux,看一下/proc/mtd的文件内容(当然你的系统要支持proc文件系统) # cat /proc/mtd dev: size erasesize name mtd0: 01000000 00020000 "Physically mapped flash" mtd1: 00040000 00020000 "reserved for bootloader" mtd2: 00100000 00020000 "reserved for kernel" mtd3: 00400000 00020000 "reserved for ramdisk" mtd4: 00800000 00020000 "jffs2" 如果出现上述内容,则说明你的jffs2系统已经配置成功了 7.使用Jffs2文件系统
1)# /erase /dev/mtd/4 MTD_open MTD_ioctl Erasing 128 KibMte @ 0 -- 0 % complete.TD_ioctl Erasing 128 KibMte @ 20000 -- 1 % complete.TD_ioctl Erasing 128 KibMte @ 40000 -- 3 % complete.TD_ioctl …… Erasing 128 KibMte @ 7e0000 -- 98 % complete.TD_ioctl Erased 8192 Kibyte @ 0 -- 100% Complete. MTD_close 这一步应该可以用直接烧些flash的方法代替: [root@llg]#mkfs.jffs2 -d /bin -o jffs2.img (/bin随便的目录) 然后将jffs2.img烧入1800000(根据自己的情况确定地址) 至于上面的删除操作,我也没搞太明白,因为我第一次做的时候直接烧写flash就成功了,但刚刚执行却执行了erase之后才成功了 2)#mkfs.jffs2 -d /bin -o jffs2.img mkfs.jffs2 网上应该可以找到 3)#cp jffs2.img /dev/mtd1 4)#mount -t jffs2 /dev/mtdblock1 /mnt mtdblock_open ok 5)#cd /mnt 6)#ls(如果正确就说明你成功了) 好了,粗粗的写了这些,应该是可以使的,因为所附上的所有代码都是我现在使的,没有任何保留啊!!!我希望大家也经常写些东东,让别人与你一起分享成功的喜悦!(当然是可以共享的东东了!) | ||
—————————— |
共1条
1/1 1 跳转至页
S3C2410上Jffs2的移植
关键词: S3C2410 Jffs2 移植 Flash st
共1条
1/1 1 跳转至页
回复
有奖活动 | |
---|---|
【有奖活动——B站互动赢积分】活动开启啦! | |
【有奖活动】分享技术经验,兑换京东卡 | |
话不多说,快进群! | |
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |