작업 환경
-메인 OS : Windows 8.1K(Intel Core i5-4590)
-작업 OS : Ubuntu 14.04.5 LTS 64bit(VirtualBox)
-장 비 명 : Hybus-Smart4412
1. 초기설정
- mkdir device --> device 디렉토리에 hello.c 와 Makefile을 만든다.
hello.c
#include<linux/kernel.h>
#include<linux/module.h>
#include<linux/init.h>
MODULE_LICENSE("GPL");
int module_start_te()
{
printk("Hello\n");
return 0;
}
int module_end_te()
{
printk("Bye\n");
return 0;
}
module_init(module_start_te);
module_exit(module_end_te);
Makefile
CC := /usr/local/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-eabi-gcc
obj-m := hello.o
KDIR := ~/Smart4412/Development/Source/Kernel/kernel_4412
all:
make -C $(KDIR) SUBDIRS=$(PWD) modules
clean:
rm -rf *.o *.mod *.ko *.cmd *.mod.c
2. 빌드 및 실행
- make (device 디렉토리에서)
- hello.ko , hello.mod.c , hello.mod.o , hello.o 파일들이 만들어 진다.
- Tera term에 hello.ko파일을 전송한다.
- insmod hello.ko --> 커널(모듈)등록(Hello 출력)
- rmmod hello.ko --> 커널(모듈)에 등록된 것을 지운다(Bye 출력)
'Embedded > Device Driver' 카테고리의 다른 글
[Device Driver] 대소문자 변환 Device Driver 만들기 (0) | 2016.12.28 |
---|---|
[Device Driver] A~Z 출력 (0) | 2016.12.27 |
[Device Driver] 커널에 Device Driver 등록 및 실행 (1) | 2016.12.26 |
[Device Driver] 커널에 Systemcall 등록 및 실행 (0) | 2016.12.26 |