嵌入式LINUX的内核开发

上传人:飞*** 文档编号:30665192 上传时间:2018-01-31 格式:DOC 页数:8 大小:127.50KB
返回 下载 相关 举报
嵌入式LINUX的内核开发_第1页
第1页 / 共8页
嵌入式LINUX的内核开发_第2页
第2页 / 共8页
嵌入式LINUX的内核开发_第3页
第3页 / 共8页
嵌入式LINUX的内核开发_第4页
第4页 / 共8页
嵌入式LINUX的内核开发_第5页
第5页 / 共8页
点击查看更多>>
资源描述

《嵌入式LINUX的内核开发》由会员分享,可在线阅读,更多相关《嵌入式LINUX的内核开发(8页珍藏版)》请在金锄头文库上搜索。

1、嵌入式 Linux 的内核开发深圳市英贝德科技 1第 6 章 嵌入式 Linux 的内核开发内容简介:我们介绍如何开发 Linux 的内核?通过这一章,大家应该了解 Linux 的配置、编译过程,并且能够形成最后的 Linux 映象文件,掌握自己如何加入驱动程序的方法,真正对嵌入式 Linux 的内核有深刻的了解。1英贝德给你提供的内核开发资源当然,作为产品开发商,英贝德提供你可以对内核操作的所有资源,包括 EBD9200 的内核原码 交叉编译工具(arm-linux- ) 映象文件的形成工具(mkimage) 必不可少的关键性说明这些内容的提供,使得你可以轻松面对内核的操作。2开发 Lin

2、ux 内核的步骤21 应该准备的交叉开发环境的安装在第 5 章中,我们已经介绍了交叉开发环境,我们应该记住位置/usr/local/arm/2.95.3/bin 或者其他位置。内核原码的安装在光盘中找到内核的原码程序 linux-2.4.27.tar.gz,拷贝到 /usr/src/arm 下面,并且解压缩,得到内核原码,你也可以安装到别的地方。22 配置内核前的必要设置主要在内核原码中设置 makefile 文件,主要设置两个地方 ARCH 和CROSS_COMPILE,ARCH :=arm ;表示目标板为 armCROSS_COMPILE=交叉编译工具的地址 ;设置交叉编译工具的地址例如

3、CROSS_COMPILE= /usr/local/arm/2.95.3/bin/arm-linux-). 还要在脚本文件 mkimage 中把路径改为 9200/bootldr/u-bootFor16M/u-boot-1.1.1/tools (具体的路径和你把 u-boot 放的位置有关)一般需要详细阅读 readme 文件23 内核配置make menuconfig ;菜单界面或 make xconfig ;图形界面嵌入式 Linux 的内核开发深圳市英贝德科技 224 内核编译make cleanmake dep./mkimage /运行 mkimage 脚本文件最终编译得到的影象文件

4、 uImage3如何配置和裁剪 Linux 的内核这一节我们来配置 linux 的内核,在 Linux 下,用 make menuconfig 或 make xconfig 进入配置的界面。在内核配置中,一般有四种选择:Y (选种) 、N (不选) 、M (模块)和数字,用户可以根据裁剪需要进行设置,最后配置完毕,选择是否对配置结果进行保存?在Linux 中的图形配置界面如下:Block Devices: Network block device support : n - Ramdisk support: y - Default Ramdisk size: 20000 - Initial R

5、amdisk (initrd) support: yFile System - Network File systems: NFS file system support : n - NFS server support: nConsole drivers - Frame Buffer Support: support for frame buffer devices (exp): y - epson LCD/CR/TV controller support: y - epson S1 D1 3806 support for AT91RM9200DK: y - virtual frame bu

6、ffer support (only for testing!): n嵌入式 Linux 的内核开发深圳市英贝德科技 3 - advanced low level driver option: y - 16 bpp packed pixeld support: y (others n)USB Support: support for USB: y - AT91RM9200 OHCI- compatible host interface: y - USB mass storage support : y - USB Human Interface device (full HID) suppo

7、rt: y - HID input layer support : yKernel configuration when using NFS ramdisk:Below the details of the parameters when typing: make xconfig:General setup:- Default kernel string : Erase its contentsBlock Devices: Network block device support : y - Ramdisk support: n File System: Quota support: n -

8、Kernel automounter support: y - DOS FAT fs support: y - VFAT (Windows 95) fs support: y - Journalling flash file system v2 (JFFS2) support: 0 - /proc file system support: y - /dev file system support (EXP): y - Automatically mount a boot: y - Second extended fs support: y File System - Network File

9、systems: NFS file system support : y - provide NFSv3 client support: y - root file system on NFS: y - NFS server support: n当然,更多的东西,请你恭身入局,实际在 linux 下看看,你才会真正了解4如何添加新的内核配置和驱动英贝德公司为你提供了丰富的驱动和配置,对于很多客户,可能只需要进行裁剪,去掉自己不需要的内容,然后重新编译内核,形成自己的内核映象文件,而对于一些构造复杂系统的客户,可能还需要在原来的基础上添加新的设备和驱动程序,比如:你可能需要增加一个标准并口的支持

10、,以挂接打印机,可能增加 IDE 接口,对系统挂接标准硬盘,当然,还有很多客户开发属于自己接口的各种驱动程序等等,这时,我们在裁剪内核的基础上,可能就需要添加内核和驱动程序。嵌入式 Linux 的内核开发深圳市英贝德科技 4实际上,不论是操作系统还是用户的上层程序,实际上都是程序代码,可以这么说:你可以编写从底层操作系统到上层实现的一系列流程。当然如果你的设备要求不高,你可以把你的驱动初始化就直接写到你的上层程序中,当然,你也可以把两者分开,但是这样你肯定会花更多的精力,我们在此介绍如何添加新的内核配置和驱动?驱动程序的使用可以按照两种方式编译,一种是静态编译进内核,另一种是编译成模块以供动

11、态加载。由于嵌入式 Linux 不能够象桌面 Linux 那样灵活的使用 insmod/rmmod 加载卸载设备驱动程序,因而这里只介绍将设备驱动程序静态编译进 linux 内核的方法。下面以嵌入式 Linux 为例,介绍在一个以字符设备驱动的例子,将其编译进内核的一系列步骤:(1): DEMO 驱动程序(demo_drv.c)/* 演示如何设计一个字符型驱动程序*/#include #include #include #include #include #define DEMO_MAJOR 125#define COMMAND1 1#define COMMAND2 2/* 函数声明/*/st

12、atic int demo_init(void);static int demo_open(struct inode *inode,struct file *file);static int demo_close(struct inode *inode,struct file *file);static ssize_t demo_read(struct file *file,char *buf,size_t count,loff_t *offset);static int demo_ioctl(struct inode *inode,struct file *file,unsigned int

13、 cmd,unsigned long arg);static void demo_cleanup(void);/* 全局变量定义/*/int demo_param =9;static int demo_initialized =0;static volatile int demo_flag =0;static struct file_operations demo_fops=#if LINUX_KERNEL_VERSION=KERNEL_VERSION(2,4,0)ower: THIS_MODULE,#endifllseek: NULL,read:demo_read,write: NULL,嵌

14、入式 Linux 的内核开发深圳市英贝德科技 5ioctl: demo_iocrl,open: demo_open,release:demo_close,;static int demo_init(void)int i;/*确定模块以前未初始化 */if(demo_initialized=1)return 0;/*分配并初始化所有数据结构为缺省状态 */i=register_chrdev(DEMO_MAJOR,demo_drv,if(i#include #include #include #include #define COMMAND1 1#define COMMAND2 2main()int fd;int i;unsigned long data;int retval;fd = open(/dev/demo_drv,O_RDONLY);if(fd = -1)perror(

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 行业资料 > 其它行业文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号