易截截图软件、单文件、免安装、纯绿色、仅160KB

Linux设备驱动学习-Davinci开发板上运行的hello模块


Linux设备驱动学习-Davinci开发板上运行的hello模块
 
看了很多个hello world了,自己来写一个在davinci板块上跑的吧。
主体很简单,就是一个C文件hello_davinci.c。
/*================hello_davinci.c==============*/
#include <linux/module.h>  /*所有模块都需要的头文件*/
#include <linux/kernel.h>
#include <linux/init.h>         /* init和exit相关宏*/
MODULE_LICENSE("Dual BSD/GPL");
MODULE_AUTHOR("lintax");
static int hello_init(void)
{
  printk(KERN_ALERT " Hello Davinci!\n");
  return 0;
}
static void hello_exit(void)
{
  printk( KERN_ALERT " Goodbye, Davinci.\n ");
}
module_init(hello_init);
module_exit(hello_exit);
/*================hello_davinci.c end===========*/
给其配个Makefile文件:
/*================Makefile==================*/
obj-m := hello_davinci.o
KERNELDIR := /opt/ti-davinci/
modules:
 $(MAKE) -C $(KERNELDIR) M=$(PWD) modules
clean:
 rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions
/*================Makefile end===============*/
 
好了,编译吧。
我的好心情立马被扑灭了,error,又见error:
说找不到/opt/ti-davinci/include/asm/ 下的某个头文件,查了一下,没这个目录嘛,当然找不到了。记得以前是看见过的,并且与asm-arm是一样的,应该是编译时复制的一份。不巧我前几天觉得硬盘空间有些不够,就把好几个内核都
make clean了一次。那就再make一次嘛,ok,生成了hello_davinci.ko。
转移到davinci开发板上,执行插入模块命令:
 insmod hello_davinci.ko
输出信息:
 Hello Davinci!
通过lsmod查看,也有了hello_davinci 模块。
然后执行移除模块命令:
 rmmod hello_davinci
输出信息:
 Goodbye Davinci.
再用lsmod来查看,就找不到hello_davinci了。
 
有以下几点要注意:
1,所使用的内核环境必须是编译过的,否则,就等着重蹈我的覆辙吧。
2,对于编译过程中类似于:不能创建hello_davinci.o.tmp文件的错误。说明权限不够,可更改hello_davinci.c Makefile文件所在目录的属性,或者是sudo到根用户。
3,hello_davinci.c文件中调用的头文件的作用:
&n


相关文档:

使用Gnu gprof进行Linux平台下的程序分析

O.S 使用Gnu gprof进行Linux平台下的程序分析
关 键 词:gprof callgraph 函数消耗的时间 Linux应用分析
阅读提示:本文介绍了如何使用Gnu gprof 对Linux平台下的现有程序进行优化分析和生成程序调用图。主要偏重于对生成和使用流程图作介绍。
Gprof 简介:
    Gprof功能:打印出程序运行中各个函数消耗 ......

s3c2410平台下linux四键按键驱动程序

#ifndef __KERNEL__
#define __KERNEL__
#endif
#ifndef MODULE
#define MODULE
#endif
#include<linux/config.h>
#include<linux/module.h>
#include<linux/version.h>
#include<linux/init.h>
#include<linux/kernel.h>
#include<linux/errno.h>
#include<linux/sche ......

从硬盘启动linux系统

 -------------------------------------------------------------------------------------------------------
//By:yuyongbao
//QQ:673360056
//平台powerpc mpc8379e linux 2.6.22
1、先用fdisk 给硬盘分一个区,用作文件系统。参照u-boot-ppc编译说明一文。
2、用mke2fs格式化硬盘的一个分区mke2fs /dev/sd ......

Linux执行以及虚拟内存之用

Linux Execution and Virtual Memory Utilization 
Linux执行以及虚拟内存之用
When Linux boots, it starts with the MMU disabled, so initially it deals only with physical 
memory. The kernel image is copied to physical address 0x8000 in DRAM and executed. First a master page table is created ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号