驅動程式之 2 塊裝置 5 Nor Flash 3

2021-09-10 03:18:06 字數 1377 閱讀 1616

nor flash的驅動框架與nand flash類似,協議層基本一樣,都是分配乙個mtd_info結構體,主要區別在於硬體層,nor flash和nand flash的位址、匯流排位寬不同;nor flash可以像記憶體一樣讀,但不能像記憶體一樣寫,寫操作類似nand flash,協議層提供讀寫介面,需要根據硬體特性完善

核心nor flash驅動的硬體層位於drivers/mtd/maps/physmap.c

1、分配physmap_flash_info

2、設定physmap_flash_info(實體地址、大小、位寬、虛擬位址)

3、設定操作函式

4、識別

5、新增分割槽

static int physmap_flash_probe(struct platform_device *dev)

測試方法基本與nand flash驅動相同

區別:nor flash一般使用jffs2格式、nand flash一般使用yaffs格式

使用flash_eraseall格式化時,預設格式化為yaffs格式

本例是nor flash驅動,格式化時應加上-j選項,使之格式化為jffs2格式

掛載時,加上-t jffs2,指定格式

flash_eraseall -j /dev/mtd5

mount -t jffs2 /dev/mtd5 /mnt

附上完整**

#include #include #include #include #include #include #include #include #include #include #include #include struct physmap_flash_info ;

static const char *rom_probe_types = ;

static struct mtd_partition s3c2440_nor_parts = ,

[1] =

};static struct physmap_flash_info *nor_info;

static int nor_init(void)

else

}} printk("\r\n%s probe\r\n\r\n",rom_probe_types[i]);

add_mtd_partitions(nor_info->mtd, nor_info->parts, 2);

return 0;

}static void nor_exit(void)

module_init(nor_init);

module_exit(nor_exit);

module_license("gpl");

裝置驅動 塊裝置驅動程式

塊裝置驅動程式提供對面向塊的裝置的訪問,這種裝置以隨機訪問的方式傳輸資料,並且資料總是具有固定大小的塊。典型的塊裝置是磁碟驅動器,也有其它型別的塊裝置。塊裝置和字元裝置有很大區別。比如塊裝置上可以掛載檔案系統,字元裝置不可以。這是隨機訪問帶來的優勢,因為檔案系統需要能按塊儲存資料,同時更需要能隨機讀...

塊裝置驅動程式

裝置描述 定義於linux genhd.h struct gendisk 裝置註冊 void add disk struct gendisk gd 裝置操作 字元裝置通過file operations結構來定義它所支援的操作。塊裝置通過struct block device operations結構...

塊裝置驅動程式

塊裝置驅動程式 1 塊裝置和字元裝置的區別 1,讀取資料的單元不同,塊裝置讀寫資料的基本單元式塊,字元裝置的基本單元是位元組。2,塊裝置可以隨機訪問,字元裝置只能順序訪問。2 linux核心中塊裝置的描述 struct gendisk 裝置操作 struct block device operati...