ARM嵌入式LINUX设备驱动设计入门学习
经过一段时间的学习之后,也开发了一些小型的驱动,正如我之前一篇中写到得,现在我就来写一下在ARM嵌入式LINUX下如何设计驱动的框架。
在这里我用的板子是micro2440板子,板子上的linux版本是2.6.13。因为我在前一篇介绍了驱动编程的两种框架设计,所以现在我就来分别写一下这两种框架设计的程序。
开发平台:RED HAT LINUX 9(Linux 2.4.18)
开发板:micro2440(友善之臂)(Linux 2.6.13)
交叉编译工具:arm-linux-gcc-3.4.1
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
2.4内核驱动框架:
static int __init leds_init(void)
{
int result;
int i;
result = register_chrdev(LED_MAJOR, DEVICE_NAME, &leds_fops);
if(result < 0){
printk(DEVICE_NAME "can't register major number\n");
return result;
}
// static devfs_handle_t devfs_handle;
// devfs_handle = devfs_register(NULL, DEVICE_NAME, DEVFS_FL_DEFAULT, LED_MAJOR, &leds_fops, NULL);
/*
*之所以不用devfs_register,而用devfs_mk_cdev,原因是因为在linux2.6内核里没有devfs_register函数,而改用*devfs_mk_cdev
*/
devfs_mk_cdev(MKDEV(LED_MAJOR, 0), S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP, DEVICE_NAME);
for(i = 0; i < 4; i++){
s3c2410_gpio_cfgpin(led_table[i], led_cfg_table[i]);
s3c2410_gpio_setpin(led_table[i], 1);
}
printk(DEVICE_NAME "initialized\n");
return 0;
}
static void __exit leds_exit(void)
{
devfs_remove(DEVICE_NAME);
unregister_chrdev(LED_MAJOR, DEVICE_NAME);
}
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
2.6内核驱动框架:
static int __init leds_init(void)
{
int result;
int i;
&nbs
相关文档:
体验一下linux下编写和使用动态库与静态库,范例:helloworld程序。
首先编写静态库:
hellos.h
#ifndef _HELLO_S_H
#define _HELLO_S_H
void prints(char *str);
#endif
hellos.c
#include "hellos.h"
#include <stdio.h>
void prints(char *str)
{
printf("print in sta ......
注:以下内容转自:
http://blog.chinaunix.net/u2/81965/showart_1674967.html
国内站点:
ftp://ftp.altera.com/outgoing/release/
http://www.china-vision.net/blog/user1/6/archives/2006/200696114213.html
http://mail.google.com
shao_华恒公司的主页,里面有很多的相关资料,有待大家去发现
......
<!--
/* Font Definitions */
@font-face
{font-family:宋体;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:"\@宋体" ......
Linux IP设置
修改ip:
编辑文件/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0 //设备名称,不要修改
BOOTPROTO=static //不要修改
BROADCAST=10.10.22.255 //广播地址,一般为本网段的最后一个IP
IPADDR=10.10.22.145 //ip地址
NETMASK=255.255.255.0 //子网掩码
NETWORK=10.10.22.0 //网段地址
ONBOOT ......
一、安装服务器端
(1)、在有两个rmp文件的目录下运行如下命令:
[root@test1 local]# rpm -ivh MySQL-server-5.0.26-0.i386.rpm
显示如下信息:
warning: MySQL-server-5.0.26-0.i386.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5
Preparing…… ##################################### ......