以移植自己制作的驱动,学习内核移植中的驱动移植,及 驱动程序的动态编译和静态编译
硬件环境:
Linux 内核版本:Linux 3.14
主机:Ubuntu 12.04发行版
目标机:FS4412平台
交叉编译工具:arm-none-linux-gnueabi-gcc
一、静态编译
1、添加驱动文件
将写好的实验代码fs4412_led_drv.c 拷贝到 drivers/char 下
fs4412_led_drv.c 如下:
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/cdev.h>
#include <asm/io.h>
#include <asm/uaccess.h>
MODULE_LICENSE("Dual BSD/GPL");
#define LED_MAGIC 'L'
/*
* need arg = 1/2
*/
#define LED_ON _IOW(LED_MAGIC, 0, int)
#define LED_OFF _IOW(LED_MAGIC, 1, int)
#define LED_MA 500
#define LED_MI 0
#define LED_NUM 1
#define FS4412_GPX2CON 0x11000C40
#define FS4412_GPX2DAT 0x11000C44
static unsigned int *gpx2con;
static unsigned int *gpx2dat;
struct cdev cdev;
static int s5pv210_led_open(struct inode *inode, struct file *file)
{
return 0;
}
static int s5pv210_led_release(struct inode *inode, struct file *file)
{
return 0;
}
static long s5pv210_led_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
int nr;
switch (cmd) {
case LED_ON:
writel(readl(gpx2dat) | 1 << 7, gpx2dat);
break;
c