移植Linux内核到norflash
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
开发板上只有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 "CFI Flash device mapped on AT91RM9200"
depends on ARM &&MTD_CFI
help
This enables access to the CFI Flash on the ATMEL AT91RM9200 DK 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 "cfi_probe", "jedec_probe", "map_rom", NULL }; */
#define PROBETYPES {"cfi_probe",NULL}
#define MSG_PREFIX "AT91RM9200-NOR:"/* prefix for our printk()'s */
#define MTDID "at91rm9200-%d"/* for mtdparts= partitioning */
static struct mtd_info *mymtd;
struct map_info at91rm9200nor_map ={
.name ="NOR 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 ="U-boot",
.size =0x20000,
.offset =0
},
{
// uImage 2MB
.name ="Kernel",
.size =0x200000,
.offset =0x20000
},
{
// RootFS 3MB
.name ="RootFS",
.size =0x300000,
.offset =0x220000
},
{
// UserFS
.name ="Jffs2",
.size =0x2C0000,
.offset =0x520000
},
{
// Parameters
.name ="Parameters",
.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 "0x%08x at 0x%08x\n",
WINDOW_SIZE,WINDOW_ADDR);
at91rm9200nor_map.virt =ioremap(WINDOW_ADDR,WINDOW_SIZE);
if(!at91rm9200nor_map.virt){
printk(MSG_PREFIX "failed to ioremap\n");
return-EIO;
}
simple_map_init(&at91rm9200nor_map);
mymtd =0;
type =rom_probe_types;