移植Linux内核到norflash 联系客服

发布时间 : 星期二 文章移植Linux内核到norflash更新完毕开始阅读

for(; !mymtd && *type; type++) {

mymtd = do_map_probe(*type, &at91rm9200nor_map); }

if (mymtd) {

mymtd->owner = THIS_MODULE;

#ifdef CONFIG_MTD_PARTITIONS

mtd_parts_nb = parse_mtd_partitions(mymtd, probes, &mtd_parts, 0);

if (mtd_parts_nb > 0) part_type = \;

if (mtd_parts_nb == 0) {

mtd_parts = at91rm9200nor_partitions; mtd_parts_nb = ARRAY_SIZE(at91rm9200nor_partitions);

part_type = \; } #endif

add_mtd_device(mymtd); if (mtd_parts_nb == 0)

printk(KERN_NOTICE MSG_PREFIX \partition info available\\n\);

else {

printk(KERN_NOTICE MSG_PREFIX

\%s partition definition\\n\, part_type);

//mymtd为master mtd_info它不被添加到数组mtd_table[]中,它只用于初始化 //每一个分区的mtd_info。而后将每一个分区对应的mtd_info添加到数组mtd_table[] //供上层调用。MTD原始设备驱动层的主要工作就是向 mtd_table[]中添加mtd_info。

add_mtd_partitions(mymtd, mtd_parts, mtd_parts_nb);

}

return 0; }

iounmap((void *)at91rm9200nor_map.virt); return -ENXIO; }

static void __exit cleanup_at91rm9200nor(void) {

if (mymtd) {

del_mtd_device(mymtd); map_destroy(mymtd); }

if (at91rm9200nor_map.virt) {

iounmap((void *)at91rm9200nor_map.virt); at91rm9200nor_map.virt = 0; } }

module_init(init_at91rm9200nor); module_exit(cleanup_at91rm9200nor);

MODULE_LICENSE(\);

MODULE_AUTHOR(\Groeger \);

MODULE_DESCRIPTION(\configurable MTD map driver\);

(3)配置内核

增加MTD,和相应的文件系统的支持。

Devices Drivers --->

Memory Technology Devices (MTD) --->

<*> Memory Technology Device(MTD) support <*> MTD partitioning support

<*> Direct char device access to MTD devices <*> Caching block device access to MTD devices RAM/ROM/Flash chip drivers --->

<*> Detect flash chips by Common Flash Interface(CFI) probe <*> Support for Intel/Sharp flash chips Mapping drivers for chip access ---> <*> CFI Flash device mapped on AT91RM9200 File Systems --->

Miscellaneous filesystems --->

<*>Journalling Flash File System v2 (JFFS2) support

<*>Compressed ROM file system support (cramfs)

这里选择cramfs或者Jffs2的支持。

(4)编译,然后加载

make Image编译,然后制作成uImage。

这是JFFS2作为根文件系统的信息:

TOPDIR=$($(which pwd)) TMP=$TOPDIR/linux.bin TARGET=$TOPDIR/uImage

arm-linux-objcopy -O binary -S vmlinux $TMP && gzip -v9 $TMP && \\ mkimage -n 'RAM disk' -A arm -O linux -T kernel -C gzip \\

-a 0x20008000 -e 0x20008000 -d $TMP.gz $TARGET && \\ cp $TARGET /mnt/hgfs/common && \\ rm -f $TMP*

可以看到MTD分区信息。进入shell界面,然后查看/proc/mtd,如下:

AT91RM9200-NOR:0x00800000 at 0x10000000

NOR flash on AT91RM9200DK: Found 1 x16 devices at 0x0 in 16-bit bank Intel/Sharp Extended Query Table at 0x0031 Using buffer write method

cfi_cmdset_0001: Erase suspend on write enabled AT91RM9200-NOR:using static partition definition

Creating 5 MTD partitions on \flash on AT91RM9200DK\: 0x00000000-0x00020000 : \ 0x00020000-0x00220000 : \ 0x00220000-0x00520000 : \ 0x00520000-0x007e0000 : \ 0x007e0000-0x00800000 : \

可以看到加载是正确的。