¿ª·¢°åÉÏÖ»ÓÐNor Flash£¬ËùÒÔΪÁËʵÏÖ²ã´ÎÎļþϵͳ£¬ÐèҪΪLinux2.6.20Ôö¼ÓNor Flash MTDÇý¶¯Ö§³Ö¡£Æäʵ¹¤×÷Á¿²¢²»´ó£¬ÒòΪÒѾÓÐÏֳɵijÌÐò¿É¹©²Î¿¼¡£
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
#ifdef CONFIG_MTD_PARTITIONS #include
#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;
Ïà¹ØÍÆ¼ö£º