Smart210学习记录------nor flash驱动
nor flash驱动与nand flash驱动的差别不大,只是设置不同的结构体而已,,
nor flash驱动代码:
#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 <linux/mtd/physmap.h>
#include <linux/mtd/concat.h>
#include <linux/io.h> static struct map_info *nor_map;
static struct mtd_info *nor_mtd;
static unsigned char nr_parts = ;
static struct mtd_partition nor_mtd_partition[] = {
[] = {
.name = "bootloader_nor",
.size = 0x00040000,
.offset = ,
},
[] = {
.name = "root_nor",
.offset = MTDPART_OFS_APPEND,
.size = MTDPART_SIZ_FULL,
}
}; static int __init my_nor_flash_init(void)
{
/*分配一个mtd_info结构体*/
int err;
nor_map = kzalloc(sizeof(struct map_info), GFP_KERNEL);
if(nor_map == NULL) {
printk(KERN_ALERT"map_info kzalloc error\n");
return -ENOMEM;
} /*设置: 物理基地址(phys), 大小(size), 位宽(bankwidth), 虚拟基地址(virt)*/
nor_map->name = "nor flash";
nor_map->phys = ;
nor_map->size = 0x100000; //大于真实nor flash的大小
nor_map->bankwidth = ; //16位 nor_map->virt = ioremap(nor_map->phys,nor_map->size);
if (nor_map->virt == NULL) {
printk(KERN_ALERT"Failed to ioremap flash region\n");
err = -EIO;
goto err_out;
} simple_map_init(nor_map); printk(KERN_ALERT"do_map_probe cfi_probe\n");
nor_mtd = do_map_probe("cfi_probe", nor_map);
if(nor_mtd = NULL) {
printk(KERN_ALERT" do_map_probe jedec_probe\n");
nor_mtd = do_map_probe("jedec_probe", nor_map);
} if(!nor_mtd) {
iounmap(nor_map->virt);
kfree(nor_map);
return -EIO;
}
nor_mtd->owner = THIS_MODULE; /*添加分区*/
if(mtd_device_register(nor_mtd, nor_mtd_partition, nr_parts) != ) {
printk(KERN_ALERT" mtd_device_register error\n");
return -EINVAL;
} return ; err_out:
kfree(nor_map);
return err;
} static void __exit my_nor_flash_exit(void)
{
iounmap(nor_map->virt);
kfree(nor_map);
} module_init(my_nor_flash_init);
module_exit(my_nor_flash_exit);
MODULE_LICENSE("GPL");
Smart210学习记录------nor flash驱动的更多相关文章
- Smart210学习记录----nand flash驱动
[详解]如何编写Linux下Nand Flash驱动 :http://www.cnblogs.com/linux-rookie/articles/3016990.html 当读写文件请求到来的时候, ...
- Smart210学习记录-----Linux i2c驱动
一:Linux i2c子系统简介: 1.Linux 的 I2C 体系结构分为 3 个组成部分: (1) I2C 核心. I2C 核心提供了 I2C 总线驱动和设备驱动的注册.注销方法,I2C 通信方法 ...
- Smart210学习记录------linux串口驱动
转自:http://blog.chinaunix.net/xmlrpc.php?r=blog/article&uid=27025492&id=327609 一.核心数据结构 串口驱动有 ...
- Smart210学习记录-------Linux设备驱动结构
cdev结构体 1 struct cdev { 2 struct kobject kobj; /* 内嵌的 kobject 对象 */ 3 struct module *owner; /*所属模块*/ ...
- Smart210学习记录-----SD/MMC/SDIO驱动
转自:http://jingpin.jikexueyuan.com/article/23369.html http://blog.csdn.net/evilcode/article/details/7 ...
- Smart210学习记录-------linux驱动中断
Linux中断 Linux 的中断处理分为两个半部,顶半部处理紧急的硬件操作,底半部处理不紧急的耗时操作.tasklet 和工作队列都是调度中断底半部的良好机制,tasklet 基于软中断实现.内核定 ...
- Smart210学习记录----beep linux字符设备驱动
今天搞定了beep linux字符设备驱动,心里还是很开心的,哈哈...但在完成的过程中却遇到了一个非常棘手的问题,花费了我大量的时间,,,, 还是把问题描述一下吧,好像这个问题很普遍的,网上许多解决 ...
- Smart210学习记录------块设备
转自:http://bbs.chinaunix.net/thread-2017377-1-1.html 本章的目的用尽可能最简单的方法写出一个能用的块设备驱动.所谓的能用,是指我们可以对这个驱动生成的 ...
- Smart210学习记录-------内存初始化
买了Smart210的板子,开始学习中,,,,, 今天看了重定位DRAM ,然而内存需要初始化,早上信心满满的我到现在崩溃的我....也不知遭受了什么样的蹂躏 ,,还是记下一点学到的知识吧.. 数据手 ...
随机推荐
- 【iOS】我的Objective-C学习笔记
1.代码中增加标记 #pragma mark - #pragma mark 2.点语法 Person *p = [Person new]; // 点语法的本质还是方法调用 p.age = 10; // ...
- Sqrt(x) - LintCode
examination questions Implement int sqrt(int x). Compute and return the square root of x. Example sq ...
- Zabbix 3.0.3 SQL Injection
Zabbix version 3.0.3 suffers from a remote SQL injection vulnerability. ============================ ...
- Java 集合 - LinkedList
一.源码解析 (1). 属性 // 链表长度 transient int size = 0; // 链首和链尾 transient Node<E> first; transient Nod ...
- 物联网安全拔“牙”实战——低功耗蓝牙(BLE)初探
物联网安全拔“牙”实战——低功耗蓝牙(BLE)初探 唐朝实验室 · 2015/10/30 10:22 Author: FengGou 0x00 目录 0x00 目录 0x01 前言 0x02 BLE概 ...
- tcp/ip详解-ip头部选项字段
IP头部的选项字段 作用:用于网络调试和测试 IP首部的可变部分就是一个可选字段.选项字段用来支持排错.测量以及安全等措施,内容很丰富.此字段的长度可变,从1个字节到40个字节不等,取决于所选择的项目 ...
- 【转】linux命令详解:md5sum命令
[转]linux命令详解:md5sum命令 转自:http://blog.itpub.net/29320885/viewspace-1710218/ 前言 在网络传输.设备之间转存.复制大文件等时,可 ...
- 关于tomcat会在url末尾自动追加斜杠(/)
今天,突然发现一个问题, 比如我的请求路径为 http://ip:port/my_project/myapp, 在浏览器中敲入这个地址,然后会显示 http://ip:port/my_project ...
- MPICH3 配置安装问题列表
问题列表 1: configure: error: F90 and F90FLAGS are replaced by FC and FCFLAGS respectively in this confi ...
- 错误信息:System.Resources.MissingManifestResourceException: 未能找到任何适合于指定的区域或非特定区域性的资源。请确保在编译时已将“****.****.Resource.resources”正确嵌入或链接到程序集"****",或者确保所有需要的附属程序集都可加载并已进行了完全签名
在网上搜索了N久都没看到几篇解决的文章,最后在不懈的努力下终于解决了,所以决定写下解决方法方便以后遇到同样问题的朋友: 其实这个错误的主要问题就是没有找到需要的资源文件(该文件为Resources.r ...