linux之NOR FLASH驱动程序
来源:互联网 发布:互联网金融 数据挖掘 编辑:程序博客网 时间:2024/04/29 15:18
使用UBOOT体验NOR FLASH的操作(开发板设为NOR启动,进入UBOOT)先使用OpenJTAG烧写UBOOT到NOR FLASH1. 读数据md.b 0 2. 读IDNOR手册上:往地址555H写AAH往地址2AAH写55H往地址555H写90H读0地址得到厂家ID: C2H读1地址得到设备ID: 22DAH或225BH退出读ID状态: 给任意地址写F0H2440的A1接到NOR的A0,所以2440发出(555h<<1), NOR才能收到555h这个地址UBOOT怎么操作?往地址AAAH写AAH mw.w aaa aa往地址554写55H mw.w 554 55往地址AAAH写90H mw.w aaa 90读0地址得到厂家ID: C2H md.w 0 1读2地址得到设备ID: 22DAH或225BH md.w 2 1退出读ID状态: mw.w 0 f03. NOR有两种规范, jedec, cfi(common flash interface) 读取CFI信息NOR手册: 进入CFI模式 往55H写入98H读数据: 读10H得到0051 读11H得到0052 读12H得到0059 读27H得到容量2440的A1接到NOR的A0,所以2440发出(555h<<1), NOR才能收到555h这个地址UBOOT怎么操作?进入CFI模式 往AAH写入98H mw.w aa 98读数据: 读20H得到0051 md.w 20 1 读22H得到0052 md.w 22 1 读24H得到0059 md.w 24 1 读4EH得到容量 md.w 4e 1 退出CFI模式 mw.w 0 f04. 写数据: 在地址0x100000写入0x1234md.w 100000 1 // 得到ffffmw.w 100000 1234md.w 100000 1 // 还是ffffNOR手册:往地址555H写AAH 往地址2AAH写55H 往地址555H写A0H 往地址PA写PD2440的A1接到NOR的A0,所以2440发出(555h<<1), NOR才能收到555h这个地址UBOOT怎么操作?往地址AAAH写AAH mw.w aaa aa往地址554H写55H mw.w 554 55往地址AAAH写A0H mw.w aaa a0往地址0x100000写1234h mw.w 100000 1234NOR FLASH驱动程序框架测试1:通过配置内核支持NOR FLASH1. make menuconfig-> Device Drivers -> Memory Technology Device (MTD) support -> Mapping drivers for chip access <M> CFI Flash device in physical memory map (0x0) Physical start address of flash mapping // 物理基地址 (0x1000000) Physical length of flash mapping // 长度 (2) Bank width in octets (NEW) // 位宽 2. make modules cp drivers/mtd/maps/physmap.ko /work/nfs_root/first_fs3. 启动开发板 ls /dev/mtd* insmod physmap.ko ls /dev/mtd* cat /proc/mtd测试2: 使用自己写的驱动程序:1. ls /dev/mtd*2. insmod s3c_nor.ko3. ls /dev/mtd*4. 格式化: flash_eraseall -j /dev/mtd15. mount -t jffs2 /dev/mtdblock1 /mnt 在/mnt目录下操作文件 NOR FLASH识别过程:do_map_probe("cfi_probe", s3c_nor_map); drv = get_mtd_chip_driver(name) ret = drv->probe(map); // cfi_probe.c cfi_probe mtd_do_chip_probe(map, &cfi_chip_probe); cfi = genprobe_ident_chips(map, cp); genprobe_new_chip(map, cp, &cfi) cp->probe_chip(map, 0, NULL, cfi) cfi_probe_chip // 进入CFI模式 cfi_send_gen_cmd(0x98, 0x55, base, map, cfi, cfi->device_type, NULL); // 看是否能读出"QRY" qry_present(map,base,cfi) ..... do_map_probe("jedec_probe", s3c_nor_map); drv = get_mtd_chip_driver(name) ret = drv->probe(map); // jedec_probe jedec_probe mtd_do_chip_probe(map, &jedec_chip_probe); genprobe_ident_chips(map, cp); genprobe_new_chip(map, cp, &cfi) cp->probe_chip(map, 0, NULL, cfi) jedec_probe_chip // 解锁 cfi_send_gen_cmd(0xaa, cfi->addr_unlock1, base, map, cfi, cfi->device_type, NULL); cfi_send_gen_cmd(0x55, cfi->addr_unlock2, base, map, cfi, cfi->device_type, NULL); // 读ID命令 cfi_send_gen_cmd(0x90, cfi->addr_unlock1, base, map, cfi, cfi->device_type, NULL); // 得到厂家ID,设备ID cfi->mfr = jedec_read_mfr(map, base, cfi); cfi->id = jedec_read_id(map, base, cfi); // 和数组比较 jedec_table
驱动程序源码:
/* * 参考 drivers\mtd\maps\physmap.c */#include <linux/module.h>#include <linux/types.h>#include <linux/kernel.h>#include <linux/init.h>#include <linux/slab.h>#include <linux/device.h>#include <linux/platform_device.h>#include <linux/mtd/mtd.h>#include <linux/mtd/map.h>#include <linux/mtd/partitions.h>#include <asm/io.h>static struct map_info *s3c_nor_map;static struct mtd_info *s3c_nor_mtd;static struct mtd_partition s3c_nor_parts[] = {[0] = { .name = "bootloader_nor", .size = 0x00040000,.offset= 0,},[1] = { .name = "root_nor", .offset = MTDPART_OFS_APPEND, .size = MTDPART_SIZ_FULL,}};static int s3c_nor_init(void){/* 1. 分配map_info结构体 */s3c_nor_map = kzalloc(sizeof(struct map_info), GFP_KERNEL);;/* 2. 设置: 物理基地址(phys), 大小(size), 位宽(bankwidth), 虚拟基地址(virt) */s3c_nor_map->name = "s3c_nor";s3c_nor_map->phys = 0;s3c_nor_map->size = 0x1000000; /* >= NOR的真正大小 */s3c_nor_map->bankwidth = 2;s3c_nor_map->virt = ioremap(s3c_nor_map->phys, s3c_nor_map->size);simple_map_init(s3c_nor_map);/* 3. 使用: 调用NOR FLASH协议层提供的函数来识别 */printk("use cfi_probe\n");s3c_nor_mtd = do_map_probe("cfi_probe", s3c_nor_map);if (!s3c_nor_mtd){printk("use jedec_probe\n");s3c_nor_mtd = do_map_probe("jedec_probe", s3c_nor_map);}if (!s3c_nor_mtd){iounmap(s3c_nor_map->virt);kfree(s3c_nor_map);return -EIO;}/* 4. add_mtd_partitions */add_mtd_partitions(s3c_nor_mtd, s3c_nor_parts, 2);return 0;}static void s3c_nor_exit(void){del_mtd_partitions(s3c_nor_mtd);iounmap(s3c_nor_map->virt);kfree(s3c_nor_map);}module_init(s3c_nor_init);module_exit(s3c_nor_exit);MODULE_LICENSE("GPL");
0 0
- linux之NOR FLASH驱动程序
- linux设备驱动程序之SPI nor flash
- linux驱动之NOR FLASH驱动程序
- linux块设备驱动程序分析之 nor flash驱动分析 以及使用内存模拟 nor flash
- NOR FLASH驱动程序
- NOR FLASH驱动程序
- NOR FLASH 的驱动程序
- NOR FLASH驱动程序
- 友善之臂Mini2440之嵌入式Linux下Nor Flash驱动程序设计
- Nor Flash电路与驱动程序
- 嵌入式linux之NOR FLASH驱动
- Linux块设备驱动之NOR FLASH
- linux之NAND FLASH驱动程序
- linux nor flash 驱动
- linux nor flash 读写
- 2440之NOR FLASH
- 嵌入式linux之Nor/Nand FLASH的读写
- 嵌入式linux之Nand flash驱动程序框架
- 好的用户体验需要做到的5点要求
- TimesTen数据库迁移工具 - ttMigrate
- 【POJ 3617】【贪心】Best Cow Line
- 创建TimesTen 数据库
- C 语言字符串 与数字转换
- linux之NOR FLASH驱动程序
- Linux操作系统的Configure参数解释说明
- HDU1969:Pie(二分)
- 名企动态网站开发--广告轮播效果
- Java反射机制
- 外网访问XAMPP失败 解决方案 XAMPP1.8.3
- 总结径向基函数,径向基网络,计算过程,训练过程介绍(参考+翻译)
- 字符消除(外内2层判断+递归)
- poj1753 flip game