微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > arm中驱动模块加载并由应用程序调用

arm中驱动模块加载并由应用程序调用

时间:11-09 来源:互联网 点击:

Makefile文件如下:

# To build modules outside of the kernel tree, we run "make"
# in the kernel source tree; the Makefile these then includes this
# Makefile once again.
# This conditional selects whether we are being included from the
# kernel Makefile or not.
ifeq ($(KERNELRELEASE),)

# Assume the source tree is where the running kernel was built
# You should set KERNELDIR in the environment if its elsewhere
# KERNELDIR ?= /lib/modules/$(shell uname -r)/build
KERNELDIR = /home/wangwei/utu-linux_for_s3c2440_V1.5.3
# KERNELDIR=$(KDIR)
#
# The current directory is passed to sub-makes as argument
PWD := $(shell pwd)
modules:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules

modules_install:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install

clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions

.PHONY: modules modules_install clean

else
# called from kernel build system: just declare what our modules are
obj-m := dev_test1.o
endif

执行顺序:

1.编译驱动模块程序和应用程序,分别生成dev_test1.ko和data_deal1,并用串口烧到开发板

2.加载模块:insmod dev_test1

3.创建设备结点,mknod /dev/dev_test1 c 253 0

4.执行应用程序:./data_deal1(可能需要修改权限)

串口烧写方式简介:

1.启动开发板,进入开发板系统,按ctrl+a并释放,再按z键

2.出现很多选项,选s--传输文件

3.enter键选zmoden

4.按向右方向键,选中[转到],按enter键

5.打入所要传输文件在你主机上的绝对路径,按enter键

6.选中要传输文件,按enter键

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top