第一范文网 - 专业文章范例文档资料分享平台

移植Linux内核到norflash

来源:用户分享 时间:2025/7/30 2:32:40 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

开发板上只有Nor Flash,所以为了实现层次文件系统,需要为Linux2.6.20增加Nor Flash MTD驱动支持。其实工作量并不大,因为已经有现成的程序可供参考。

MTD的驱动程序都集中在drivers/mtd里面。我们需要做的,仅仅是在drivers/mtd/maps下增加自己的分区表。因为有参考的代码,所以比较容易。

(1)构建配置选项

首先,根据edb7312.c构建自己的mtd分区表驱动(根据cfi_flagadm.c

这个文件也可以奥,

看情况吧!)。

$cd drivers/mtd/maps/ $cp edb7312.c at91rm9200.c

然后,修改drivers/mtd/maps/Kconfig,增加自己的配置选项。

//拷贝过EDB7312稍作修改即可 config MTD_AT91RM9200

tristate \Flash device mapped on AT91RM9200\ depends on ARM && MTD_CFI help

This enables access to the CFI Flash on the ATMEL AT91RM9200DK board.

If you have such a board, say 'Y' here.

最后,修改Makefile,增加编译项目。 obj-$(CONFIG_MTD_EDB7312) += edb7312.o obj-$(CONFIG_MTD_AT91RM9200) += at91rm9200.o

这样,自己建立的MTD分区表驱动就可以编译进内核了。

(2)修改分区表信息

因为第一步的工作中,at91rm9200.c实际上还是edb7312.c的内容,所以需要根据自己的开发板nor flash的配置做一下修改。

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

#ifdef CONFIG_MTD_PARTITIONS #include #endif

#define WINDOW_ADDR 0x10000000 /* physical properties of flash */ #define WINDOW_SIZE 0x00800000 /* intel 28F640J3A 8MB */ #define BUSWIDTH 2 /* data bus width 16bits */

/* can be \\\NULL }; */ #define PROBETYPES { \, NULL }

#define MSG_PREFIX \ /* prefix for our printk()'s */ #define MTDID \ /* for mtdparts= partitioning */

static struct mtd_info *mymtd;

struct map_info at91rm9200nor_map = {

.name = \flash on AT91RM9200DK\, .size = WINDOW_SIZE, .bankwidth = BUSWIDTH,

.phys = WINDOW_ADDR, };

#ifdef CONFIG_MTD_PARTITIONS /*

* MTD partitioning stuff */

static struct mtd_partition at91rm9200nor_partitions[5] = {

{

// U-boot 128KB .name = \, .size = 0x20000, .offset = 0 }, {

// uImage 2MB .name = \, .size = 0x200000, .offset = 0x20000 }, {

// RootFS 3MB .name = \, .size = 0x300000, .offset = 0x220000 }, {

// UserFS

.name = \, .size = 0x2C0000, .offset = 0x520000 },

{

// Parameters

.name = \, .size = 0x20000, .offset = 0x7E0000 }, };

static const char *probes[] = { NULL }; #endif

static int mtd_parts_nb = 0;

static struct mtd_partition *mtd_parts = 0;

int __init init_at91rm9200nor(void) {

static const char *rom_probe_types[] = PROBETYPES; const char **type;

const char *part_type = 0;

printk(KERN_NOTICE MSG_PREFIX \at 0xx\\n\, WINDOW_SIZE, WINDOW_ADDR);

at91rm9200nor_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE);

if (!at91rm9200nor_map.virt) {

printk(MSG_PREFIX \to ioremap\\n\); return -EIO; }

simple_map_init(&at91rm9200nor_map);

mymtd = 0;

type = rom_probe_types;

搜索更多关于: 移植Linux内核到norflash 的文档
移植Linux内核到norflash.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c6i7n393xmz9nplx1m54t1j03v4iv5u00auy_1.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top