RaspberryPi 커널컴파일및커널모듈 1 제 13 강 커널컴파일및커널모듈 커널컴파일가상주소 (mmap() 함수 ) 에의한디바이스제어커널모듈및커널모듈테스트커널모듈에의한입출력디바이스제어 (LED, BTN) 커널모듈을커널에포함하기

Size: px
Start display at page:

Download "RaspberryPi 커널컴파일및커널모듈 1 제 13 강 커널컴파일및커널모듈 커널컴파일가상주소 (mmap() 함수 ) 에의한디바이스제어커널모듈및커널모듈테스트커널모듈에의한입출력디바이스제어 (LED, BTN) 커널모듈을커널에포함하기"

Transcription

1 RaspberryPi 커널컴파일및커널모듈 1 제 13 강 커널컴파일및커널모듈 커널컴파일가상주소 (mmap() 함수 ) 에의한디바이스제어커널모듈및커널모듈테스트커널모듈에의한입출력디바이스제어 (LED, BTN) 커널모듈을커널에포함하기

2 RaspberryPi 커널컴파일및커널모듈 2 커널컴파일 * 커널소스컴파일 : 가상머신에서 10여분소요 : 라즈베리파이보드에서 90여분소요 따라서, 가상머신에서커널컴파일진행 * 이후진행은, 가상머신에서슈퍼유저로전환하여진행 ifc415@ubuntu $ sudo su root@ubuntu #

3 커널컴파일 ( 계속 ) RaspberryPi 커널컴파일및커널모듈 3 * 커널소스다운로드 (./kernelsrc ) : 커널소스다운로드사이트 : Windows 환경에다운로드하여가상머신으로이동 :./kernelsrc 학습자료 - rpi-4.9.y.tar.gz ( 버전, 현재 ) - rpi tar.gz

4 커널컴파일 ( 계속 ) RaspberryPi 커널컴파일및커널모듈 4 * 커널소스다운로드 ( 기타의방법 ) : git 툴을사용하여다운로드 # apt-get install git // git 패키지설치 # git clone --depth=1 : 현재작업디렉터리에./linux/ 로커널소스다운로드 ( 최신버전 ) : wget 툴을사용하여다운로드 # apt-get install wget // wget 패키지설치 # wget : 현작업디렉터리에 rpi-4.9.y.tar.gz 파일다운로드

5 커널컴파일 ( 계속 ) * 커널소스설치 RaspberryPi 커널컴파일및커널모듈 5 : tar 파일푼후, 커널소스디렉터리 (/usr/src/) 로이동 : 커널소스디렉터리를소프트링크 # tar xvfz rpi-4.9.y.tar.gz // tar파일풀기 // 현작업디렉터리에./linux-rpi-4.9.y/ 디렉터리생성 # mv linux-rpi-4.9.y /usr/src // /usr/src 로이동 # cd /usr/src # ls linux-rpi-4.9.y sense-hat # ln -s linux-rpi-4.9.y linux // 소프트링크 # ls -l linux ->./linux-rpi-4.9.y/ ==> 커널소스의절대경로 /usr/src/linux

6 커널컴파일 ( 계속 ) * 커널소스버전확인 RaspberryPi 커널컴파일및커널모듈 6 : 커널소스홈디렉터리의 Makefile 앞부분참조 # cd /usr/src/linux # head Makefile // 선두 10라인보기 VERSION = 4 PATCHLEVEL = 9 SUBLEVEL = 79 EXTRAVERSION = NAME = Roaring Lionus... : 버전으로확인됨!

7 커널컴파일 ( 계속 ) RaspberryPi 커널컴파일및커널모듈 7 * 커널환경설정 : 커널환경설정파일 (./arch/arm/configs ) # ls -l./arch/arm/configs/bcm* bcm2709_defconfig... 라즈베리파이 2, 3 보드 bcm2835_defconfig... 라즈베리파이 zero 보드 bcmrpi_defconfig... 라즈베리파이 1 보드 # make bcm2709_defconfig //.config 히든파일로설정정보가저장됨 // 커널컴파일할때이히든파일을참조함 # ls -a.con*.config.config.old

8 커널컴파일 ( 계속 ) * 디폴트커널환경설정정보확인 RaspberryPi 커널컴파일및커널모듈 8 :.config 내용이반영된메뉴방식환경에서 # apt-get install libncurses5-dev // 다음명령으로내용을살펴보려면이패키지를설치해야함 # make menuconfig // 내용확인및필요에따라수정가능, 저장시.config 파일로저장

9 커널컴파일 ( 계속 ) * 커널컴파일 : 사전작업 RaspberryPi 커널컴파일및커널모듈 9 # KERNEL=kernel7 // 커널이름설정 // 라즈베리파이1 kernel, 라즈베리파이2,3 kernel7 # apt-get install bc // bc 패키지설치 : 컴파일 -j4 옵션... CPU 의코어수지정 // 라즈베리파이보드, 가상머신은 quad core임 # make -j4 zimage modules dtbs //./arch/arm/boot/zimage 커널이미지파일생성 //./arch/arm/boot/dts/ 관련 //./arch/arm/boot/overlays/ 관련

10 커널컴파일 ( 계속 ) * 커널컴파일 ( 계속 ) RaspberryPi 커널컴파일및커널모듈 10 : 동일버젼의커널모듈설치 ( /lib/modules/ 디렉터리하부에 ) # make modules_install // /lib/modules/ v7/ 를생성하여커널모듈을복사 // build, source 소프트링크파일포함, 커널모듈컴파일시

11 커널컴파일 ( 계속 ) RaspberryPi 커널컴파일및커널모듈 11 * 새커널이미지및커널모듈라이브러리복사 : 커널이미지파일과커널모듈라이브러리를타깃보드로전송 : NFS 서비스사용 # cd./arch/arm/boot # cp zimage /nfs // 커널이미지파일복사 # cp -rf /lib/modules/ v7 /nfs // 커널모듈라이브러리복사 : 참고 ) 관련파일들복사 ( 복사위치는타깃보드기준임 ) // 새커널로부팅시문제가있을경우에한해 # cp./arch/arm/boot/dts/*.dtb /boot/ # cp./arch/arm/boot/dts/overlays/*.dtbo /boot/overlays/ # cp./arch/arm/boot/dts/overlays/readme /boot/overlays/

12 커널컴파일 ( 계속 ) * 라즈베리파이보드에서 RaspberryPi 커널컴파일및커널모듈 12 : NFS 를위한마운트후, 관련파일들복사 $ cd /boot $ sudo mv kernel7.img kernel7_org.img // 기존커널퇴피 $ sudo mount -t nfs :/nfs /share // NFS 마운트 사 $ sudo cp /share/zimage kernel7.img // 새커널이미지복 $ sudo cp -rf /share/ v7 /lib/modules // 라이브러리복사 : 재부팅후커널버전확인 $ sudo reboot // 재부팅 $ uname -r // 커널버전확인 v7

13 RaspberryPi 커널컴파일및커널모듈 13 가상주소에의한디바이스제어 * 입출력디바이스 (GPIO) 제어방법 1) 물리주소에의한제어 ( 부트로더실행방식 ) : 앞장에서이미살펴봄 2) 가상주소에의한제어 ( mmap() 함수활용 ) : OS가실행중인상태에서, 메모리디바이스파일통해 3) 커널모듈 ( 디바이스드라이버 ) 에의한제어 : 가상주소활용한디바이스드라이버통해 : 커널에동적 ( 비포함 ), 혹은정적 ( 포함 ) 링크가능

14 RaspberryPi 커널컴파일및커널모듈 14 가상주소에의한디바이스제어 ( 계속 ) : 커널이부팅된후 mmap() 통한가상주소로접근 : 메모리디바이스 "/dev/mem" 파일접근 * mmap() 함수에의한제어흐름 단계1) open() 함수를사용하여 /dev/mem 파일개방단계2) mmap() 함수를사용하여제어할디바이스의포인터획득단계3) 포인터에서값을읽거나기록 ( 입출력 ) 단계4) munmap() 함수를사용하여메모리공간을해제단계5) close() 함수를사용하여파일닫기 * LED 제어예 fd = open("/dev/mem", O_RDWR); addr=mmap(null, 1, PROT_WRITE, MAP_SHARED, fd, ADDRESSOFLED); *addr = 0xFF; munmap(addr, 1); close(fd);

15 RaspberryPi 커널컴파일및커널모듈 15 가상주소에의한디바이스제어 ( 계속 ) * mmap() 함수 ( 가상주소확보 ) void * mmap(void *start, size_t length, int prot, int flags, start length prot flags fd offset int fd, off_t offset);.. 특정메모리주소를요청하기위해사용, 통상 NULL로설정.. 메모리세그먼트의길이.. 메모리세그먼트의접근허용권한설정 PROT_READ PROT_WRITE PROT_EXEC PROT_NONE 각각, 읽기허용, 쓰기허용, 실행허용, 접근불허.. 페이지에대한변경이다른곳에반영되는방법설정 MAP_PRIVATE MAP_SHARED MAP_FIXED 다른프로세스와대응영역을비공유, 공유, 지정된주소로고정.. 메모리디바이스파일기술자.. 디바이스의물리주소, GPIO의베이스주소 * munmap() 함수 : mmap() 함수로매핑된메모리를반환하는기능 int munmap(void *start, size_t length);

16 RaspberryPi 커널컴파일및커널모듈 16 가상주소에의한디바이스제어 ( 계속 ) [ 실습 1] GPIO LED 제어 (./mmapgpio ) : LED ON/OFF를반복하는프로그램 : BCM_GPIO #18에 LED 회로연결 $ nano ledgpio_01.c //======================================= // ledgpio_01.c // BCM_GPIO #18, LED // using mmap() //======================================= #include <stdio.h> #include <unistd.h> // sleep(), close() #include <fcntl.h> #include <sys/mman.h> #define GPIO_BASE 0x3F // for BCM2836, BCM2837 // address offset of registers for BCM_GPIO #18 #define GPFSEL1 0x04 #define GPSET0 0x1C

17 RaspberryPi 커널컴파일및커널모듈 17 #define GPCLR0 0x28 int main(void) { int fd; char * gpio_mmap; volatile unsigned int * gpio; int i; printf("[mmapgpio testing...led]\n"); if((fd = open("/dev/mem", O_RDWR O_SYNC)) < 0) { printf("/dev/mem open error!!\n" ); return 1; gpio_mmap = (char *)mmap(null, 4096, PROT_READ PROT_WRITE, MAP_SHARED, fd, GPIO_BASE); if(gpio_mmap == MAP_FAILED) { printf("mmap() error!!\n"); return 1; gpio = (volatile unsigned int *)gpio_mmap; // // GPFSEL1 = 0bxx xxx 001 xxx xxx xxx xxx xxx xxx xxx xxx; gpio[gpfsel1 / 4] &= ~(6 << 24); // #18, output, ~(001)=110(6)

18 RaspberryPi 커널컴파일및커널모듈 18 while(1) { // // GPSET0 = 0b ; gpio[gpset0 / 4] = (1 << 18); // LED ON printf("led ON...\n"); sleep(1); // // GPCLR0 = 0b ; gpio[gpclr0 / 4] = (1 << 18); // LED OFF printf("led OFF...\n"); sleep(1); munmap(gpio_mmap, 4096); close(fd); return 0; $ gcc o ledgpio_01 ledgpio_01.c 혹은, $ make ledgpio_01 $ sudo./ledgpio_01 ( /dev/mem 파일열려면슈퍼유저로실행해야함 )

19 RaspberryPi 커널컴파일및커널모듈 19 가상주소에의한디바이스제어 ( 계속 ) [ 실습 2] GPIO LED 및 BTN 제어 : BTN 눌린동안 LED ON하는프로그램 : BCM_GPIO #17에 BTN 연결 : BCM_GPIO #18에 LED 연결 $ nano ledgpio_02.c //======================================= // ledgpio_02.c // BCM_GPIO #18, LED // BCM_GPIO #17, BTN // using mmap() //======================================= #include <stdio.h> #include <unistd.h> // sleep(), close() #include <fcntl.h> #include <sys/mman.h> #define GPIO_BASE 0x3F // for BCM2836, BCM2837

20 // address offset of registers for GPIO #define GPFSEL1 0x04 #define GPSET0 0x1C #define GPCLR0 0x28 #define GPLEV0 0x34 int main(void) { int fd; char * gpio_mmap; volatile unsigned int * gpio; int i, ret; RaspberryPi 커널컴파일및커널모듈 20 printf("[mmapgpio testing...led/btn]\n"); if((fd = open("/dev/mem", O_RDWR O_SYNC)) < 0) { printf("/dev/mem open error!!\n" ); return 1; gpio_mmap = (char *)mmap(null, 4096, PROT_READ PROT_WRITE, MAP_SHARED, fd, GPIO_BASE); if(gpio_mmap == MAP_FAILED) { printf("mmap() error!!\n"); return 1; gpio = (volatile unsigned int *)gpio_mmap;

21 RaspberryPi 커널컴파일및커널모듈 21 gpio[gpfsel1 / 4] &= ~(7 << 21); gpio[gpfsel1 / 4] &= ~(6 << 24); // #17, input // #18, output while(1) { ret = (gpio[gplev0 /4] & (1 << 17)); if(ret) { else { munmap(gpio_mmap, 4096); close(fd); // press? printf("pressed, then LED ON...\n"); gpio[gpset0 / 4] = (1 << 18); // LED ON printf("released, then LED OFF...\n"); gpio[gpclr0 / 4] = (1 << 18); // LED OFF return 0; $ gcc o ledgpio_02 ledgpio_02.c 혹은, $ make ledgpio_02 $ sudo./ledgpio_02

22 커널모듈 * Linux 커널구조 RaspberryPi 커널컴파일및커널모듈 22

23 커널모듈 ( 계속 ) * Character 디바이스 RaspberryPi 커널컴파일및커널모듈 23 : 자료의순차성을지닌장치로서버퍼캐쉬비사용즉, 버퍼를통하지않고순차적으로데이터를읽고쓸수있는장치를의미 : Terminal, Console, Keyboard, Sound card, Scanner, Printer, Serial/Parallel, Mouse, Joystick 등 # ls -al /dev

24 커널모듈 ( 계속 ) * Block 디바이스 RaspberryPi 커널컴파일및커널모듈 24 : 버퍼캐쉬를통해랜덤접근이가능한장치 : 데이터를블록단위 (512B, 혹은 1024B) 로입출력 : 파일시스템을구축가능 : Hard Disk, Floppy Disk, RAMDisk, CD-ROM * Network 디바이스 : 네트워크통신을통해네트워크패킷을송수신할수있는장치 : Ethernet, PPP, Slip, ATM, ISDN NIC 등

25 커널모듈 ( 계속 ) * 커널모듈이란 RaspberryPi 커널컴파일및커널모듈 25 : 디바이스를구동하기위한구동프로그램 ( 디바이스드라이버 ) : 디바이스와가상파일시스템간데이터전송인터페이스제공 : 커널에정적혹은동적으로링크되어사용 ( 모듈화 ) * 구성 : 함수와데이터의집합체 : 디바이스의입출력특성에따른특정함수구현필요

26 커널모듈 ( 계속 ) * 기본구성 ( xxx 디바이스 ) #include <linux/kernel.h> #include <linux/module.h> #include <linux/init.h>... RaspberryPi 커널컴파일및커널모듈 26 //1. Header Files int xxx_open( ) { int xxx_release( ) { ssize_t xxx_write( ) { ssize_t xxx_read( ) { //2. Functions static struct file_operations xxx_fops = { //3. File Operations.open = xxx_open,.release = xxx_release, // 멤버및초기화병행.write = xxx_write,.read = xxx_read, ;.llsek = NULL static int xxx_init() {... static void xxx_exit() {... module_init(xxx_init); module_exit(xxx_exit); //4. 모듈링크시초기화수행 //5. 모듈제거시수행 // 매크로, insmod시수행 // 매크로, rmmod시수행

27 커널모듈 ( 계속 ) * file_operations 구조체 RaspberryPi 커널컴파일및커널모듈 27 : 함수포인터들의구조체 : 커널소스의./include/linux/fs.h 참조 : 라즈베리파이에서는 6개필드제공 static struct file_operations xxx_fops = {.owner = THIS_MODULE,.open = xxx_open,.release = xxx_release,.write = xxx_write,.read = xxx_read,.llsek = NULL // 비정의시 ;

28 모듈링크개념도 * RaspberryPi 커널컴파일및커널모듈 28

29 커널모듈관련명령 * insmod RaspberryPi 커널컴파일및커널모듈 29 : 모듈의 module_init() 호출 : 커널모듈을적재하기위한메모리할당 : 드라이버이름, 메이저번호, file_operations 구조체등록예 ) $ sudo insmod hello.ko // 모듈명을풀네임으로

30 커널모듈관련명령 ( 계속 ) * rmmod RaspberryPi 커널컴파일및커널모듈 30 : 모듈의 module_exit() 호출, 디바이스드라이버를커널에서제거 예 ) $ sudo rmmod hello // 모듈명만 혹은 $ sudo rmmod hello.ko // 혹은, 풀네임으로 * lsmod : 등록된디바이스드라이버목록출력예 ) $ sudo lsmod 혹은 $ sudo lsmod grep hello* * modinfo : 커널모듈의버전확인명령 $ sudo modinfo hello.ko

31 커널모듈관련명령 ( 계속 ) * mknod : 새로운디바이스파일생성명령 : 디바이스파일의위치 /dev/ RaspberryPi 커널컴파일및커널모듈 31 : mknod 장치파일명장치유형 major minor < 장치파일 > : /dev 디렉토리에장치파일로생성 < 장치유형 > : c( 문자디바이스 ), b( 블록디바이스 ) <major> <minor> : 유형별장치식별번호, 0 이면자동할당 : 다수의동일장치간의구별번호 예 ) $ sudo mknod /dev/hello c * 기타관련명령 $ sudo more /proc/devices // 주 (major) 번호확인 $ dmesg // 커널에서출력한메시지확인, printk()

32 커널모듈 ( 계속 ) RaspberryPi 커널컴파일및커널모듈 32 [ 실습 1] 커널모듈테스트 (./hellomodule/hello/ ) : hello 모듈 : 최소한의모듈구성요소를갖춘모듈 : 모듈컴파일및모듈등록및제거를확인 * Makefile : 타깃보드에서커널모듈컴파일시사용하는 Makefile $ nano Makefile #======================================= # Makefile for device module #======================================= CC := /usr/bin/gcc KDIR := /lib/modules/ v7/build obj-m := hello.o

33 RaspberryPi 커널컴파일및커널모듈 33 build: clean: make -C $(KDIR) SUBDIRS=`pwd` modules rm -rf *.o *.ko *.mod.c.*.cmd *.order *.symvers.tmp* 참고 ) 밑줄부분은자신의커널소스버전과일치시킴 (/lib/modules/ v7/build 는커널소스가설치된 /usr/src/linux/ 임 ) * Hello 모듈소스 : 최소한의요소로구성 $ nano hello.c //======================================= // hello.c // Hello MODULE test //======================================= #include <linux/module.h> #include <linux/kernel.h>

34 RaspberryPi 커널컴파일및커널모듈 34 #include <linux/init.h> MODULE_LICENSE("GPL"); int hello_init(void) { printk("hello MODULE is loaded.\n"); return 0; void hello_exit(void) { printk("hello MODULE is unloaded.\n"); module_init(hello_init); module_exit(hello_exit); * 모듈컴파일 ( 슈퍼유저권한으로실행 ) $ sudo make $ ls Makefile hello.c hello.mod.c hello.o modules.order Module.symvers hello.ko hello.mod.o // 생성된 hello.ko 파일이 hello 디바이스드라이버모듈임

35 * 커널모듈정보확인 RaspberryPi 커널컴파일및커널모듈 35 $ modinfo hello.ko // 커널모듈정보확인 filename: license: srcversion: depends: vermagic: /home/pi/ifc415/13_kernel/moduletest/hello/hello.ko GPL B12C7BD57EC69249A v7 SMP mod_unload modversions ARMv7 p2v8 // v7 버전의커널에서동작됨 ( 커널버전과일치시킬것 ) // 블일치시 Invalid module format Error 발생 * 커널모듈동적링크및해제 $ sudo insmod hello.ko // 모듈삽입명령 $ dmesg // 커널출력메시지확인 $ lsmod grep hello // 등록모듈확인 hello $ sudo rmmod hello // 모듈제거, 모듈명만, 혹은전체이름가능 $ dmesg // 커널출력메시지확인 $ lsmod grep hello // 등록모듈확인

36 RaspberryPi 커널컴파일및커널모듈 36 커널모듈 ( 계속 ) * 커널모듈에서의디바이스접근 : 디바이스의물리주소로커널의가상메모리주소확보 : linux/io.h, 혹은 asm/io.h 라이브러리 : ioremap() 함수 // 물리주소 (offset) 에대한가상메모리주소획득 void *ioremap(unsigned long offset, unsigned long size); void *ioremap_nocache(unsign long offset, unsigned long size); : iounmap() 함수 // 가상메모리주소를위한공간해제 void *iounmap(void *addr);

37 커널모듈 ( 계속 ) RaspberryPi 커널컴파일및커널모듈 37 [ 실습 2] ioremap() 에 LED 제어 (./helloled/ ) : 앞의 hello 모듈소스기반 + 링크시 LED 제어 : GPIO #18에연결된 LED를 5회점멸하는모듈구현 $ nano Makefile #======================================= # Makefile for device module #======================================= KERVER := $(shell uname -r) PWD := $(shell pwd) CC KDIR obj-m build: := /usr/bin/gcc := /lib/modules/$(kerver)/build := helloled.o make -C $(KDIR) SUBDIRS=$(PWD) modules clean:

38 RaspberryPi 커널컴파일및커널모듈 38 rm -rf *.o *.ko *.mod.c.*.cmd *.order *.symvers.tmp* $ nano helloled.c //======================================= // helloled.c // hello + LED module //======================================= #include <linux/init.h> #include <linux/module.h> #include <linux/kernel.h> #include <linux/delay.h> #include <linux/io.h> // ioremap(), iounmap() #define GPIO_BASE 0x3F // for BCM2836, BCM2837 #define BLOCK_SIZE 4096 // address offset of registers for BCM_GPIO #18 #define GPIO_LED #define GPFSEL1 18 (0x04/4) // BCD_GPIO #18 // int * #define GPSET0 (0x1C/4) #define GPCLR0 (0x28/4) volatile unsigned int * gpio_addr; // LED blinking

39 static void blinking(void) { int i; RaspberryPi 커널컴파일및커널모듈 39 for(i=0; i<5 ; i++){ // 1C h : 28 dec = 4 * 7 *(gpio_addr+gpset0) = 1 <<(GPIO_LED); mdelay(1000); // 28 h : 40 dec = 4 * 10 *(gpio_addr+gpclr0) = 1 <<(GPIO_LED); mdelay(1000); static int hello_init(void) { printk("insmod : Hello, GPIO LED Module Test...\n"); gpio_addr = ioremap(gpio_base, BLOCK_SIZE); // GPFSEL1 = gpio_addr + 1 *(gpio_addr+gpfsel1) &= ~(6 << (((GPIO_LED)%10)*3)); blinking(); // LED ON/OFF return 0; static void hello_exit(void) {

40 RaspberryPi 커널컴파일및커널모듈 40 iounmap(gpio_addr); printk("rmmod : Hello, GPIO LED Module Test...\n"); module_init(hello_init); module_exit(hello_exit); $ sudo make // 모듈컴파일 $ sudo insmod helloled.ko // 모듈등록시 LED 가 5 회점멸하는것을확인 $ sudo rmmod helloled.ko // 결과확인이종료된후이후에모듈제거

41 RaspberryPi 커널컴파일및커널모듈 41 커널모듈에의한디바이스제어 * 커널모듈에의한디바이스제어응용의흐름 : 모듈명 sk, 응용프로그램 test 인경우

42 RaspberryPi 커널컴파일및커널모듈 42 커널모듈에의한디바이스제어 ( 계속 ) * 커널모듈내함수 xxx_init() // insmod 명령시호출되는함수 // register_chardev(), register_blkdev() 호출하여커널과링크 // 기타모듈등록시처리할사항들 ( 인터럽트처리관련초기화등등 ) xxx_exit() // rmmod 명령시호출되는함수 // unregister_chardev(), unregister_blkdev() 호출하여링크해제 // 기타모듈등록시처리한사항들의해제 ( 인터럽트등등 ) xxx_open() // 디바이스파일 open시 ( open() 호출 ) xxx_release() // 디바이스파일 close시 ( close() 호출 ) xxx_read() // 입력디바이스로부터데이터입력 ( read() 호출 ) xxx_write() // 출력디바이스로데이터출력 ( write() 호출 )

43 RaspberryPi 커널컴파일및커널모듈 43 커널모듈에의한디바이스제어 ( 계속 ) * 커널모듈과응용프로그램간함수호출 커널모듈 (xxx) 응용프로그램 응용프로그램에서함수호출예 xxx_open() open() fd=open( /dev/xxx, O_WRONLY); xxx_release() close() close(fd); xxx_read() read() read(fd, buf, len); xxx_write() write() write(fd, &buf, len);

44 RaspberryPi 커널컴파일및커널모듈 44 커널모듈에의한디바이스제어 ( 계속 ) * 가상메모리보호정책 : 커널영역과사용자영역간교차접근불허 : PAGE_OFFSET (0xC000_0000, BCM2835 데이터시트 ) : 영역간데이터전달은커널관점의시스템함수를호출하여

45 RaspberryPi 커널컴파일및커널모듈 45 커널모듈에의한디바이스제어 ( 계속 ) * 사용자및커널영역간데이터전송함수 : 함수명의명명은커널중심의관점 ( asm/uaccess.h ) : xxx_write() 함수에서 get_user(void *x, const void *addr) // 사용자영역 *addr의값을커널영역인 x로 sizeof(addr) 만큼복사 copy_from_user(void *to, void *from, unsigned long size) // 사용자영역의주소 from으로부터 size만큼커널영역 to로복사 : xxx_read() 함수에서 put_user(void *x, const void *addr) // *x의값을 user 영역인 addr로 sizeof(addr) 만큼복사 copy_to_user(void *to, void *from, unsigned long size) // 커널영역의주소 from으로부터 size만큼사용자영역 to로복사

46 RaspberryPi 커널컴파일및커널모듈 46 커널모듈에의한디바이스제어 ( 계속 ) [ 실습 3] rawgpio 에의한 LED 제어 (./gpioled/ ) : 모듈의메이저번호는 201, 모듈이름은 gpioled : LED 회로는 BCM_GPIO #18에연결 : 커널모듈소스 $ nano gpioled.c //======================================= // gpioled.c // LED Device Driver : Direct Access //======================================= #include <asm/uaccess.h> // copy_to_user(), copy_from_user() #include <linux/ioport.h> #include <linux/module.h> #include <linux/fs.h> // open(), close(), read(), write() #include <linux/cdev.h> #include <linux/io.h> // ioremap(), iounmap() #define GPIO_BASE 0x3F // for BCM2836, BCM2837 #define GPIO_RANGE 1024

47 RaspberryPi 커널컴파일및커널모듈 47 // address offset of registers for BCM_GPIO #18 #define GPFSEL0 (0x00/4) // int * #define GPSET0 (0x1C/4) #define GPCLR0 (0x28/4) //#define MOD_MAJOR 0 // automatic allocation #define MOD_MAJOR 201 #define MOD_NAME "gpioled" #define GPIO_LED 18 // BCM_GPIO #18 volatile unsigned int * gpio_addr; int gpioled_open(struct inode *minode, struct file *mfile) { printk("kernel Module Open(): %s\n", MOD_NAME); return 0; int gpioled_release(struct inode *minode, struct file *mfile) { printk("kernel Module close(): %s\n", MOD_NAME); return 0; ssize_t gpioled_write(struct file *inode, const char *gdata, size_t length, loff_t *off_what) { unsigned char c; get_user(c, gdata); // if c==1 then ON, else OFF

48 RaspberryPi 커널컴파일및커널모듈 48 if (c == 1) *(gpio_addr+gpset0) = 1 << (GPIO_LED); else *(gpio_addr+gpclr0) = 1 << (GPIO_LED); // ON // OFF return length; static struct file_operations gpioled_fops = {.write = gpioled_write,.open = gpioled_open,.release = gpioled_release, ; int gpioled_init(void) { int result; result = register_chrdev(mod_major, MOD_NAME, &gpioled_fops); if(result < 0) { printk("can't get any major\n"); return result; printk("init Module: Major number %d\n", MOD_MAJOR); printk("init Module: Major number %d\n", result); gpio_addr = ioremap(gpio_base, GPIO_RANGE);

49 RaspberryPi 커널컴파일및커널모듈 49 // GPFSELn, #18, out *(gpio_addr + (GPIO_LED/10)) &= ~(6 << (((GPIO_LED)%10)*3)); return 0; void gpioled_exit(void) { unregister_chrdev(mod_major, MOD_NAME); printk("%s DRIVER CLEANUP\n", MOD_NAME); module_init(gpioled_init); module_exit(gpioled_exit); : LED 응용프로그램소스 - 명령행에서 on 혹은 off 문자열을인자로전달받아 LED 제어 $ nano gpioled_test.c //======================================= // gpioled_test.c // //=======================================

50 RaspberryPi 커널컴파일및커널모듈 50 #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> int main(int argc, char **argv) { int fd; char buf; if(argc <= 1) { printf("usage :./gpioled_test on or off\n"); return -1; fd = open("/dev/gpioled", O_WRONLY); if(fd == -1) { printf("device Open ERROR!\n"); exit(-1); if(argv[1][0] == 'o' && argv[1][1] == 'n') buf = 1; else if(argv[1][0]=='o' && argv[1][1]=='f' && argv[1][2]=='f') buf = 0; write(fd, &buf, 1); // LED control

51 RaspberryPi 커널컴파일및커널모듈 51 close(fd); return 0; : Makefile 수정 - 커널모듈과응용프로그램을함께컴파일할수있게작성 $ nano Makefile #======================================= # Makefile for device module #======================================= KERVER := $(shell uname -r) PWD := $(shell pwd) CC KDIR obj-m := /usr/bin/gcc := /lib/modules/$(kerver)/build := gpioled.o TEST_TARGET = gpioled_test TEST_OBJS = gpioled_test.o TEST_SRCS = gpioled_test.c

52 RaspberryPi 커널컴파일및커널모듈 52 build: $(TEST_TARGET) make -C $(KDIR) SUBDIRS=$(PWD) modules $(TEST_TARGET) : $(TEST_OBJS) $(CC) -o $@ $(TEST_OBJS) clean: rm -rf *.o *.ko *.mod.c.*.cmd *.order *.symvers.tmp* rm -f $(TEST_TARGET) : 컴파일 - 디바이스드라이버모듈 gpioled.ko 와응용프로그램 gpioled_test 생성 $ sudo make $ ls Makefile gpioled.ko gpioled.o gpioled_test.c Module.symvers gpioled.mod.c gpioled_test.o gpioled.c gpioled.mod.o gpioled_test modules.order 참고 ) 재컴파일시목적코드들제거위해 $ sudo make clean

53 RaspberryPi 커널컴파일및커널모듈 53 : 디바이스파일생성하고, 접근속성을변경 $ sudo mknod /dev/gpioled c $ sudo chmod 777 /dev/gpioled $ ls /dev/gpio* -al crw-rw root gpio 254, 0 Aug 6 14:10 /dev/gpiochip0 crwxrwxrwx 1 root root 201, 0 Aug 7 12:38 /dev/gpioled crw-rw root gpio 246, 0 Aug 6 14:10 /dev/gpiomem : 드라이버모듈을등록하고, 응용프로그램을실행하여그결과를관찰 $ sudo insmod gpioled.ko $ lsmod grep gpioled gpioled $./gpioled_test on 혹은, $./gpioled_test off

54 RaspberryPi 커널컴파일및커널모듈 54 : 다음의명령을통하여모듈제거, 노드삭제등의역과정을진행 $ sudo rmmod gpioled $ lsmod grep gpioled $ sudo rm /dev/gpioled $ ls /dev/gpio*

55 RaspberryPi 커널컴파일및커널모듈 55 커널모듈에의한디바이스제어 ( 계속 ) * linux/gpio.h 함수를사용한제어 : GPIO 핀의사용요청및해제 int gpio_reqeust(unsigned int gpio, const char *label); void gpio_free(unsigned int gpio); : GPIO 핀의입출력방향지정 int gpio_direction_input(unsigned int gpio); int gpio_direction_output(unsigned int gpio, int value); // value는해당핀으로의초기출력값 : GPIO 핀과의데이터입출력함수 int gpio_get_value(unsigned int gpio); void gpio_set_value(unsigned int gpio, int value);

56 RaspberryPi 커널컴파일및커널모듈 56 커널모듈에의한디바이스제어 ( 계속 ) * linux/gpio.h 함수를사용한제어 ( 계속 ) 참고 ) 인터럽트처리를위해 GPIO 핀의 IRQ 번호를반환하는함수 : 반환된 irq 번호는 request_irq() 함수를사용하여인터럽트핸들러함수를등록할때사용 int gpio_to_irq(unsigned int gpio);

57 RaspberryPi 커널컴파일및커널모듈 57 커널모듈에의한디바이스제어 ( 계속 ) [ 실습 4] gpio.h 함수를활용한 LED 제어 (./gpioled2/) : gpio.h 함수를이용한커널모듈로 LED 제어 : 응용프로그램은앞의 [ 실습3] 과동일한소스사용 $ nano gpioled.c //======================================= // gpioled.c // LED Device Driver // using /linux/gpio.h //======================================= #include <asm/uaccess.h> // copy_to_user(), copy_from_user() #include <linux/ioport.h> #include <linux/module.h> #include <linux/fs.h> // open(),close(), read(), write() #include <linux/cdev.h> #include <linux/io.h> // ioremap(), iounmap() #include <linux/gpio.h> // *)!!!!

58 RaspberryPi 커널컴파일및커널모듈 58 //#define MOD_MAJOR 0 // automatic allocation #define MOD_MAJOR 201 #define MOD_NAME "gpioled" #define GPIO_LED 18 // BCM_GPIO #18 int gpioled_open(struct inode *minode, struct file *mfile) { printk("kernel Module Open(): %s\n", MOD_NAME); return 0; int gpioled_release(struct inode *minode, struct file *mfile) { printk("kernel Module close(): %s\n", MOD_NAME); return 0; ssize_t gpioled_write(struct file *inode, const char *gdata, size_t length, loff_t *off_what) { unsigned char c; get_user(c, gdata); gpio_set_value(gpio_led, ((c == 0)? 0 : 1)); return length; static struct file_operations gpioled_fops = {.write = gpioled_write,

59 ;.open.release RaspberryPi 커널컴파일및커널모듈 59 = gpioled_open, = gpioled_release, int gpioled_init(void) { int result; result = register_chrdev(mod_major, MOD_NAME, &gpioled_fops); if(result < 0) { printk("can't get any major\n"); return result; printk("init Module: Major number %d\n", MOD_MAJOR); gpio_request(gpio_led, "LED"); gpio_direction_output(gpio_led, 0); return 0; void gpioled_exit(void) { unregister_chrdev(mod_major, MOD_NAME); printk("%s DRIVER CLEANUP\n", MOD_NAME); gpio_free(gpio_led);

60 module_init(gpioled_init); module_exit(gpioled_exit); RaspberryPi 커널컴파일및커널모듈 60 MODULE_LICENSE("GPL"); MODULE_AUTHOR("melee"); MODULE_DESCRIPTION("Raspberry Pi 3 GPIO LED Device Driver Module"); : 실행을위한응용프로그램은 [ 실습 3] 의것을사용

61 RaspberryPi 커널컴파일및커널모듈 61 커널모듈에의한디바이스제어 ( 계속 ) * Interrupt 처리 ( linux/interrupt.h 라이브러리 ) : 인터럽트핸들러함수원형 static irqreturn_t btn_interrupt(int irq, void *dev_id) {... : 인터럽트핸들러함수의등록및해제 : GPIO 핀에대한인터럽트번호는 gpio_to_irq() 함수호출로확보 int request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags, const char *name, void *dev); // 인터럽트핸들러함수를등록하는함수 void free_irq(unsigned int, void *); // 인터럽트핸들러함수의등록을해제하는함수

62 RaspberryPi 커널컴파일및커널모듈 62 커널모듈에의한디바이스제어 ( 계속 ) * 인터럽트처리시주요코드 static int btn_irq; // interrupt handler static irqreturn_t btn_interrupt(int irq, void *dev_id) {... // service return 0; int gpiobtn_init(void) { int result, irq;... gpio_request(gpio_btn, "SWITCH"); gpio_direction_input(gpio_btn); btn_irq = gpio_to_irq(gpio_btn); irq = request_irq(btn_irq, &btn_interrupt, IRQF_TRIGGER_FALLING, "SWITCH", NULL);... void gpiobtn_exit(void) {... free_irq(btn_irq, NULL);

63 RaspberryPi 커널컴파일및커널모듈 63 커널모듈에의한디바이스제어 ( 계속 ) [ 실습 5] 인터럽트에의한 BTN 제어 (./gpiobtnint/ ) : BTN 디바이스의제어를위해디바이스드라이버를구현 : BTN 디바이스로부터의입력에대해인터럽트방식으로처리 : interrupt.h와 gpio.h 함수사용 : major 202, gpiobtn $ nano gpiobtn.c //======================================= // gpiobtn.c // GPIO Input Device Driver // using Interrupt method & gpio.h //======================================= #include <linux/interrupt.h> // *)!! #include <linux/cdev.h> #include <linux/module.h> #include <linux/io.h>

64 #include <linux/gpio.h> // *)!! #include <asm/uaccess.h> #define MOD_MAJOR 202 #define MOD_NAME "gpiobtn" RaspberryPi 커널컴파일및커널모듈 64 #define GPIO_BTN 17 // BCM_GPIO #17 static int btn_irq; static char msg[40] = {0; // interrupt handler static irqreturn_t btn_interrupt(int irq, void *dev_id) { char temp[40] = "GPIO Switch was Pushed!"; strcpy(msg, temp); return 0; static ssize_t gpiobtn_read(struct file *filp, char *buf, size_t count, loff_t *l) { int result; result = copy_to_user(buf, &msg, sizeof(msg)); memset(msg, 0, 40);

65 RaspberryPi 커널컴파일및커널모듈 65 return result; static int gpiobtn_open(struct inode *inode, struct file *filp) { printk("kernel Module Open(): %s\n", MOD_NAME); return 0; static int gpiobtn_release(struct inode *inode, struct file *filp) { printk("kernel Module close(): %s\n", MOD_NAME); disable_irq(gpio_btn); return 0; static struct file_operations gpiobtn_fops = {.read = gpiobtn_read,.open = gpiobtn_open,.release = gpiobtn_release, ; int gpiobtn_init(void) { int result, irq; result = register_chrdev(mod_major, "GPIO INTERRUPT", &gpiobtn_fops); if(result < 0) {

66 RaspberryPi 커널컴파일및커널모듈 66 printk(kern_warning"can't get major %d\n", MOD_MAJOR); gpio_request(gpio_btn, "SWITCH"); gpio_direction_input(gpio_btn); btn_irq = gpio_to_irq(gpio_btn); irq = request_irq(btn_irq, &btn_interrupt, IRQF_TRIGGER_FALLING, "SWITCH", NULL); if(irq < 0) printk(kern_err "%s: Request for IRQ %d failed\n", FUNCTION, GPIO_BTN); printk("init module, GPIO major number : %d\n", MOD_MAJOR); return 0; void gpiobtn_exit(void){ unregister_chrdev(mod_major, "GPIO INTERRUPT"); free_irq(btn_irq, NULL); gpio_free(gpio_btn); printk("%s DRIVER CLEANUP\n", MOD_NAME); return;

67 RaspberryPi 커널컴파일및커널모듈 67 module_init(gpiobtn_init); module_exit(gpiobtn_exit); MODULE_LICENSE("GPL"); MODULE_AUTHOR("melee"); MODULE_DESCRIPTION("Raspberry Pi 3 GPIO Switch Device Driver Module"); $ nano gpiobtn_test.c //======================================= // gpiobtn_test.c // //======================================= #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <errno.h> int main(void) { int fd;

68 RaspberryPi 커널컴파일및커널모듈 68 char buf[40]; fd = open("/dev/gpiobtn", O_RDWR); if(fd < 0) { printf( "Device Open ERROR!\n"); exit(1); printf("please push the GPIO button!\n"); read(fd, buf, 40); printf("%s\n", buf); // read close(fd); return 0;

69 응용과제 [ 응용 1] 커널컴파일및테스트 RaspberryPi 커널컴파일및커널모듈 69 : 다음버전의커널소스를다운도드받아적용 # wget : 위커널소스는 버전임 ( 현재 ) +) LED/BTN 제어소스적용 (mmap() 이용 ) +) LED/BTN 제어소스적용 ( 디바이스드라이버이용 )

70 응용과제 ( 계속 ) RaspberryPi 커널컴파일및커널모듈 70 [ 응용 2] BTN 제어 (./gpiobtnpoll/ ) : BTN 디바이스의제어를위해디바이스드라이버를구현 : Polling 방식 : 하지말것!!

71 RaspberryPi 커널컴파일및커널모듈 71 아래는자율학습할것!!

72 커널모듈을커널에포함하기 * 커널이미지에모듈포함 RaspberryPi 커널컴파일및커널모듈 72 : 커널소스의일부로커널모듈소스를포함 // [ 실습3] gpioled 관련소스활용 : 커널모듈을포함한커널이미지로부팅 : bool 메뉴유형, tristate 메뉴유형 : Kconfig ( 커널환경설정파일 )

73 RaspberryPi 커널컴파일및커널모듈 73 커널모듈을커널에포함하기 ( 계속 ) * Kconfig 메뉴항목포맷 : config DEVMEM bool "/dev/mem virtual device support" default y help Say Y here if you want to support the /dev/mem device. The /dev/mem device is used to access areas of physical memory. When in doubt, say "Y". bool "/dev/mem virtual device support // y( 커널이미지에포함 ), n( 비포함 ) tristate "/dev/mem virtual device support // y( 커널이미지에포함 ), m(module 형태로 ), n( 비포함 ) string, hex, int : 해당유형별입력박스항목 default : 디폴트설정값, help : 메뉴사용도움말

74 RaspberryPi 커널컴파일및커널모듈 74 커널모듈을커널에포함하기 ( 계속 ) * 드라이버모듈소스를커널소스내로복사 # cd /usr/src/linux/ // 커널소스홈디렉터리 # cp???/gpioled.c./drivers/char/ //./drivers/char/ 커널의문자디바이스관련모듈소스위치 //./drivers/block/ 커널의블록디바이스관련모듈소스위치 * Kconfig 편집하여항목추가 : 커널환경설정에서드라이버모듈항목이나타나도록등록 (make menuconfig 명령사용할때 ) # nano./drivers/char/kconfig config GPIO_LED_TEST bool GPIO LED Module Test Program ( 혹은, tristate GPIO LED Module Test Program ) // 항목의심볼명은 CONFIG_GPIO_LED_TEST임, default/help항비명시

75 RaspberryPi 커널컴파일및커널모듈 75 커널모듈을커널에포함하기 ( 계속 ) * Makefile 수정 : 커널컴파일시드라이버모듈이컴파일될수있도록 : 현디렉터리의 Makefile에심볼명을활용하여다음과같은라인을추가 ( Kconfig에서등록한모듈항목에대한심볼명유의 ) : 목적코드파일명지정 # nano./drivers/char/makefile... obj-$(config_brcm_char_drivers) += broadcom/ obj-$(config_gpio_led_test) += gpioled.o // Kconfig 등록심볼명과일치

76 RaspberryPi 커널컴파일및커널모듈 76 커널모듈을커널에포함하기 ( 계속 ) * 커널환경설정 # KERNEL=kernel7 # make bcm2709_defconfig // 기본커널환경설정정보 # make menuconfig : Device Drivers-Character devices-gpio LED Module.. 이동 : bool 메뉴유형의경우, [ ] GPIO LED M...

77 RaspberryPi 커널컴파일및커널모듈 77 커널모듈을커널에포함하기 ( 계속 ) : tristate 메뉴유형의경우, < > GPIO LED M... // 메뉴유형에따라적절히선택하여설정하고저장 (.config 로저장 ) # cat.config grep CONFIG_GPIO_LED* // 커널모듈에대한심볼명이포함여부및설정상태확인 CONFIG_GPIO_LED_TEST=y // bool, y CONFIG_GPIO_LED_TEST=m // tristate, m(module)

78 RaspberryPi 커널컴파일및커널모듈 78 bool 메뉴유형 * bool 메뉴유형이며, y 설정의경우 : 커널모듈을커널이미지로파일로포함 (built-in) : 커널컴파일및타깃보드로전달 # cd /usr/src/linux // 커널소스의홈디렉터리로이동 # make j4 zimage // 커널컴파일 # cp./arch/arm/boot/zimage /nfs/ // NFS 서비스위해 $ sudo mount -t nfs :/nfs /share $ cd /boot/ // 필요시이전커널이미지퇴피권고 $ cp /share/zimage./kernel7.img $ sudo reboot // 새로운커널이미지로재부팅

79 bool 메뉴유형 ( 계속 ) : 커널모듈적재확인 RaspberryPi 커널컴파일및커널모듈 79 $ dmesg grep Init* [ ] Init Module: Major number 201 [ ] Init: Port Power? op_state=1 $ cat /proc/devices grep gpio* 201 gpioled // 주번호및모듈명 246 bcm2835-gpiomem : 디바이스파일생성및응용프로그램실생 $ sudo mknod /dev/gpioled c $ sudo chmod 777 /dev/gpioled $./gpioled_test on 혹은, $./gpioled_test off

80 tristate 메뉴유형 RaspberryPi 커널컴파일및커널모듈 80 * tristate 메뉴유형, m(modules) 설정의경우 : : 커널컴파일및모듈라이브러리설치 # cd /usr/src/linux # sudo make -j4 zimage modules dtbs scripts/kconfig/conf --silentoldconfig Kconfig... CC [M] drivers/char/gpioled.o... LD [M] drivers/char/gpioled.ko # sudo make modules_install // 커널모듈라이브러리설치 # cd /lib/modules/ v7/ # ls kernel/drivers/char/ broadcom gpioled.ko // 커널모듈

81 tristate 메뉴유형 ( 계속 ) : NFS 서비스로타깃보드로전달 # cp./arch/arm/boot/zimage /nfs # cp -rf /lib/modules/ v7/ /nfs RaspberryPi 커널컴파일및커널모듈 81 $ sudo mount t nfs :/nfs /share $ sudo cd /boot/ $ sudo cp /share/zimage./kernel7.img $ sudo cp rf /share/ v7/ /lib/modules/ : 부팅시커널모듈을적재토록하려면 ( 선택사항임 ) $ sudo nano /etc/modules gpioled // 모듈이름을추가 $ sudo reboot // 새로운커널이미지로재부팅 참고 ) /etc/modules 파일에미등록시 insmod, rmmod 명령으로동적링크함

82 tristate 메뉴유형 ( 계속 ) : 커널모듈적재확인 RaspberryPi 커널컴파일및커널모듈 82 $ lsmod grep gpio* // 확인가능 $ dmesg grep Init* [ ] Init Module: Major number 201 [ ] Init: Port Power? op_state=1 $ cat /proc/devices grep gpio* 201 gpioled // 주번호및모듈명 246 bcm2835-gpiomem : 디바이스파일생성및응용프로그램실생 $ sudo mknod /dev/gpioled c $ sudo chmod 777 /dev/gpioled $./gpioled_test on 혹은, $./gpioled_test off

untitled

untitled Step Motor Device Driver Embedded System Lab. II Step Motor Step Motor Step Motor source Embedded System Lab. II 2 open loop, : : Pulse, 1 Pulse,, -, 1 +5%, step Step Motor (2),, Embedded System Lab. II

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 KeyPad Device Control - Device driver Jo, Heeseung HBE-SM5-S4210 에는 16 개의 Tack Switch 를사용하여 4 행 4 열의 Keypad 가장착 4x4 Keypad 2 KeyPad 를제어하기위하여 FPGA 내부에 KeyPad controller 가구현 KeyPad controller 16bit 로구성된

More information

Microsoft PowerPoint - lab14.pptx

Microsoft PowerPoint - lab14.pptx Mobile & Embedded System Lab. Dept. of Computer Engineering Kyung Hee Univ. Keypad Device Control in Embedded Linux HBE-SM5-S4210 에는 16 개의 Tack Switch 를사용하여 4 행 4 열의 Keypad 가장착되어있다. 2 Keypad Device Driver

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 LED Device Control - mmap() Jo, Heeseung 디바이스제어 디바이스제어 HBE-SM5-S4210 에장착된 Peripheral 들은다양한인터페이스로연결되어있음 베이스보드에있는 LED 와 7-Segment 는 GPIO 로직접 CPU 에연결 M3 모듈인 FPGA 모듈은 FPGA 에의해서제어되며 CPU 와호스트버스로연결되어있어서프로그램에서는메모리인터페이스로인식

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 7-Segment Device Control - Device driver Jo, Heeseung HBE-SM5-S4210 의 M3 Module 에는 6 자리를가지는 7-Segment 모듈이아래그림처럼실장 6 Digit 7-Segment 2 6-Digit 7-Segment LED controller 16비트로구성된 2개의레지스터에의해제어 SEG_Sel_Reg(Segment

More information

ECE30076 Embedded System Programming - LED Device Driver

ECE30076 Embedded System Programming - LED Device Driver Module 12: LED 제어디바이스드라이버 ESP30076 임베디드시스템프로그래밍 (Embedded System Programming) 조윤석 전산전자공학부 주차별목표 하드웨어제어를위한디바이스드라이버작성방법알아보기 LED 제어용디바이스드라이버작성하기 ioremap 을이용한 LED 제어디바이스드라이버 mmap 을이용한 LED 제어디바이스드라이버 2 디바이스구분

More information

교육지원 IT시스템 선진화

교육지원 IT시스템 선진화 Module 16: ioctl 을활용한 LED 제어디바이스드라이버 ESP30076 임베디드시스템프로그래밍 (Embedded System Programming) 조윤석 전산전자공학부 주차별목표 ioctl() 을활용법배우기 커널타이머와 ioctl 을활용하여 LED 제어용디바이스드라이브작성하기 2 IOCTL 을이용한드라이버제어 ioctl() 함수활용 어떤경우에는읽는용도로만쓰고,

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 7-Segment Device Control - Device driver Jo, Heeseung HBE-SM5-S4210 의 M3 Module 에는 6 자리를가지는 7-Segment 모듈이아래그림처럼실장 6 Digit 7-Segment 2 6-Digit 7-Segment LED Controller 16비트로구성된 2개의레지스터에의해제어 SEG_Sel_Reg(Segment

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 7-SEGMENT DEVICE CONTROL - DEVICE DRIVER Jo, Heeseung 디바이스드라이버구현 : 7-SEGMENT HBE-SM5-S4210 의 M3 Module 에는 6 자리를가지는 7-Segment 모듈이아래그림처럼실장 6 Digit 7-Segment 2 디바이스드라이버구현 : 7-SEGMENT 6-Digit 7-Segment LED

More information

Chapter #01 Subject

Chapter #01  Subject Device Driver March 24, 2004 Kim, ki-hyeon 목차 1. 인터럽트처리복습 1. 인터럽트복습 입력검출방법 인터럽트방식, 폴링 (polling) 방식 인터럽트서비스등록함수 ( 커널에등록 ) int request_irq(unsigned int irq, void(*handler)(int,void*,struct pt_regs*), unsigned

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Linux Kernel and Device Driver Jo, Heeseung 커널과의관계 시스템이지원하는하드웨어를응용프로그램에서사용할수있도록커널에서제공하는라이브러리 응용프로그램이하드웨어를제어하려면커널에자원을요청 - 응용프로그램에서는 C 라이브러리같은함수를호출 - 라이브러리내부에서는커널에게시스템콜을호출 - 커널로제어가넘어가게되면 ( 커널모드 ) 를통해서하드웨어를제어

More information

KEY 디바이스 드라이버

KEY 디바이스 드라이버 KEY 디바이스드라이버 임베디드시스템소프트웨어 I (http://et.smu.ac.kr et.smu.ac.kr) 차례 GPIO 및 Control Registers KEY 하드웨어구성 KEY Driver 프로그램 key-driver.c 시험응용프로그램 key-app.c KEY 디바이스드라이버 11-2 GPIO(General-Purpose Purpose I/O)

More information

슬라이드 1

슬라이드 1 / 임베디드시스템개요 / 임베디드운영체제 / 디바이스드라이버 01 Linux System Architecture Application Area Application System Call Interface BSD Socket Virtual File System INET(AF_INET) Kernel Area Buffer Cache Network Subsystem

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Web server porting 2 Jo, Heeseung Web 을이용한 LED 제어 Web 을이용한 LED 제어프로그램 web 에서데이터를전송받아타겟보드의 LED 를조작하는프로그램을작성하기위해다음과같은소스파일을생성 2 Web 을이용한 LED 제어 LED 제어프로그램작성 8bitled.html 파일을작성 root@ubuntu:/working/web# vi

More information

슬라이드 1

슬라이드 1 / 유닉스시스템개요 / 파일 / 프로세스 01 File Descriptor file file descriptor file type unix 에서의파일은단지바이트들의나열임 operating system 은파일에어떤포맷도부과하지않음 파일의내용은바이트단위로주소를줄수있음 file descriptor 는 0 이나양수임 file 은 open 이나 creat 로 file

More information

임베디드시스템설계강의자료 6 system call 2/2 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과

임베디드시스템설계강의자료 6 system call 2/2 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과 임베디드시스템설계강의자료 6 system call 2/2 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과 System call table and linkage v Ref. http://www.ibm.com/developerworks/linux/library/l-system-calls/ - 2 - Young-Jin Kim SYSCALL_DEFINE 함수

More information

Adding a New Dev file

Adding a New Dev file Adding a New Dev file - 김성영, 이재혁, 김남현 - 발표자 : 김남현 목차 01 Progress 02 Device file 03 How create dev file 04 Example Progress 4 월 1 일 프로젝트방향설정 4 월 8 일 device file 추가방법조사 mem.c 파일분석 4 월 10 일 알고리즘제시필요한함수분석

More information

망고100 보드로 놀아보자 -13

망고100 보드로 놀아보자 -13 리눅스디바이스드라이버개요 http://cafe.naver.com/embeddedcrazyboys http://www.mangoboard.com 디바이스드라이버개요 디바이스 (Device ) 네트워크어댑터, LCD 디스플레이, PCMCIA, Audio, 터미널, 키보드, 하드디스 크, 플로피디스크, 프린터등과같은주변장치들을말함 디바이스의구동에필요한프로그램, 즉디바이스드라이버가필수적으로요구

More information

Microsoft PowerPoint - lab15.pptx

Microsoft PowerPoint - lab15.pptx Mobile & Embedded System Lab. Dept. of Computer Engineering Kyung Hee Univ. TextLCD Device Control in Embedded Linux M3 모듈에장착되어있는 Tedxt LCD 장치를제어하는 App을개발 TextLCD는영문자와숫자일본어, 특수문자를표현하는데사용되는디바이스 HBE-SM5-S4210의

More information

<4D F736F F F696E74202D FB8DEB8F0B8AE20B8C5C7CE205BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D FB8DEB8F0B8AE20B8C5C7CE205BC8A3C8AF20B8F0B5E55D> 학습목표 통신프로그램이무엇인지이해한다. 을이용한 IPC 기법을이해한다. 함수를사용해프로그램을작성할수있다. IT CookBook, 유닉스시스템프로그래밍 2/20 목차 의개념 함수 해제함수 의보호모드변경 파일의크기확장 매핑된메모리동기화 데이터교환하기 의개념 파일을프로세스의메모리에매핑 프로세스에전달할데이터를저장한파일을직접프로세스의가상주소공간으로매핑 read, write

More information

2009년 상반기 사업계획

2009년 상반기 사업계획 메모리매핑 IT CookBook, 유닉스시스템프로그래밍 학습목표 통신프로그램이무엇인지이해한다. 메모리매핑을이용한 IPC 기법을이해한다. 메모리매핑함수를사용해프로그램을작성할수있다. 2/20 목차 메모리매핑의개념 메모리매핑함수 메모리매핑해제함수 메모리매핑의보호모드변경 파일의크기확장 매핑된메모리동기화 데이터교환하기 3/20 메모리매핑의개념 메모리매핑 파일을프로세스의메모리에매핑

More information

Microsoft PowerPoint - IOControl [호환 모드]

Microsoft PowerPoint - IOControl [호환 모드] 목차 Input/Output Control I/O Control Mechanism mmap function munmap function RAM Area Access LED Control 4 digits 7 Segment Control Text LCD Control 1 2 I/O Control Mechanism (1) I/O Control Mechanism (2)

More information

Microsoft PowerPoint - 10-EmbedSW-11-모듈

Microsoft PowerPoint - 10-EmbedSW-11-모듈 11. 개요 proc 파일시스템 순천향대학교컴퓨터학부이상정 1 개요 순천향대학교컴퓨터학부이상정 2 개요 커널프래그래밍 커널의일부변경시커널전체를다시컴파일해야하는번거로움 해당모듈만컴파일하고필요할때만동적으로링크시켜커널의일부로사용할수있어효율적 자주사용하지않는커널기능은메모리에상주시키지않아도됨 확장성과재사용성을높일수있음. 순천향대학교컴퓨터학부이상정 3 모듈 (module)

More information

Microsoft Word doc

Microsoft Word doc 2. 디바이스드라이버 [ DIO ] 2.1. 개요 타겟보드의데이터버스를이용하여 LED 및스위치동작을제어하는방법을설명하겠다. 2.2. 회로도 2.3. 준비조건 ARM 용크로스컴파일러가설치되어있어야한다. 하드웨어적인점검을하여정상적인동작을한다고가정한다. NFS(Network File System) 를사용할경우에는 NFS가마운트되어있어야한다. 여기서는소스전문을포함하지않았다.

More information

교육지원 IT시스템 선진화

교육지원 IT시스템 선진화 Module 11: 가상디바이스드라이버작성 ESP30076 임베디드시스템프로그래밍 (Embedded System Programming) 조윤석 전산전자공학부 주차별목표 디바이스드라이버의실행과정이해하기 크로스컴파일러를이용하여가상의디바이스드라이버생성하기 Kbuild 에대해이해하기 2 file_operations 구조체 struct file_operations {

More information

RaspberryPi U-Boot & GPIO 제어 1 제 12 강 U-Boot + GPIO 제어 부트로더 U-Boot 부트로더 raw GPIO 제어 (LED, BTN) LED, BTN 제어

RaspberryPi U-Boot & GPIO 제어 1 제 12 강 U-Boot + GPIO 제어 부트로더 U-Boot 부트로더 raw GPIO 제어 (LED, BTN) LED, BTN 제어 RaspberryPi U-Boot & GPIO 제어 1 제 12 강 U-Boot + GPIO 제어 부트로더 U-Boot 부트로더 raw GPIO 제어 (LED, BTN) LED, BTN 제어 RaspberryPi U-Boot & GPIO 제어 2 부트로더 * boot loader : 시스템초기화후 OS로부팅 : 부트로더의기능 -시스템초기화 -시스템동작에필요한환경설정

More information

<4D F736F F F696E74202D205BBAB0C3B75D20B8AEB4AABDBA20B5F0B9D9C0CCBDBA20B5E5B6F3C0CCB9F620B8F0B5A82E >

<4D F736F F F696E74202D205BBAB0C3B75D20B8AEB4AABDBA20B5F0B9D9C0CCBDBA20B5E5B6F3C0CCB9F620B8F0B5A82E > 안드로이드환경에서의 리눅스디바이스드라이버 문자디바이스드라이버설명 Table of contents 디바이스드라이버구조 시스템구조 모듈의기본골격 드라이버 IO 제어 안드로이드환경에서의 한백전자교육사업부 리눅스디바이스드라이버 시스템구조 쉘 응용프로그램 표준라이브러리 시스템콜 가상파일시스템 (VFS) 버퍼캐시 네트워크시스템 문자디바이스드라이버 블럭디바이스드라이버 네트워크디바이스드라이버

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Text-LCD Device Control - Device driver Jo, Heeseung M3 모듈에장착되어있는 Tedxt LCD 장치를제어하는 App 을개발 TextLCD 는영문자와숫자일본어, 특수문자를표현하는데사용되는디바이스 HBE-SM5-S4210 의 TextLCD 는 16 문자 *2 라인을 Display 할수있으며, 이 TextLCD 를제어하기위하여

More information

지난시간에... 우리는 kernel compile을위하여 cross compile 환경을구축했음. UBUNTU 12.04에서 arm-2009q3를사용하여 간단한 c source를빌드함. 한번은 intel CPU를위한 gcc로, 한번은 ARM CPU를위한 gcc로. AR

지난시간에... 우리는 kernel compile을위하여 cross compile 환경을구축했음. UBUNTU 12.04에서 arm-2009q3를사용하여 간단한 c source를빌드함. 한번은 intel CPU를위한 gcc로, 한번은 ARM CPU를위한 gcc로. AR Configure Kernel Build Environment And kernel & root file system Build 2018-09-27 VLSI Design Lab 1 지난시간에... 우리는 kernel compile을위하여 cross compile 환경을구축했음. UBUNTU 12.04에서 arm-2009q3를사용하여 간단한 c source를빌드함.

More information

Chap 7

Chap 7 Chap 7 FPGA 디바이스 1. FPGA 디바이스 1.1. External FPGA Device Driver FPGA 모듈을제어하는디바이스드라이버를작성하는방법에대해서알아보도록한다. 이모듈은 Achro-i.MX6Q의 External Connector에연결된다. 본교재에는 FGPA 펌웨어소스코드가포함되어있지않지만 VHDL로작성할수있다. FGPA 관련소스는패키지에포함되어있는바이너리를이용하면된다.

More information

Microsoft Word doc

Microsoft Word doc 1. 디바이스드라이버 [ GPIO ] 1.1. GPIO 란 GPIO(General Purpose Input/Output) 란일반적인용도로사용가능한디지털입출력기능의 Port pins 이다. S3C2410의 GPIO는총 117개이며각각이 pin 들은 input/output으로프로그램되거나인터럽트 source로사용될수있다. S3C2410의대부분의 GPIO는단순히디지털입출력뿐만아니라부가적인기능을갖고있다.

More information

임베디드시스템설계강의자료 6 system call 1/2 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과

임베디드시스템설계강의자료 6 system call 1/2 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과 임베디드시스템설계강의자료 6 system call 1/2 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과 시스템호출개요 리눅스에서는사용자공간과커널공간을구분 사용자프로그램은사용자모드, 운영체제는커널모드에서수행 커널공간에대한접근은커널 ( 특권, priviledged) 모드에서가능 컴퓨팅자원 (CPU, memory, I/O 등 ) 을안전하게보호 커널수행을안전하게유지

More information

제1장 Unix란 무엇인가?

제1장  Unix란 무엇인가? 4 장파일 컴퓨터과학과박환수 1 2 4.1 시스템호출 컴퓨터시스템구조 유닉스커널 (kernel) 하드웨어를운영관리하여다음과같은서비스를제공 파일관리 (File management) 프로세스관리 (Process management) 메모리관리 (Memory management) 통신관리 (Communication management) 주변장치관리 (Device

More information

제1장 Unix란 무엇인가?

제1장  Unix란 무엇인가? 1 12 장파이프 2 12.1 파이프 파이프원리 $ who sort 파이프 3 물을보내는수도파이프와비슷 한프로세스는쓰기용파일디스크립터를이용하여파이프에데이터를보내고 ( 쓰고 ) 다른프로세스는읽기용파일디스크립터를이용하여그파이프에서데이터를받는다 ( 읽는다 ). 한방향 (one way) 통신 파이프생성 파이프는두개의파일디스크립터를갖는다. 하나는쓰기용이고다른하나는읽기용이다.

More information

/chroot/lib/ /chroot/etc/

/chroot/lib/ /chroot/etc/ 구축 환경 VirtualBox - Fedora 15 (kernel : 2.6.40.4-5.fc15.i686.PAE) 작동 원리 chroot유저 ssh 접속 -> 접속유저의 홈디렉토리 밑.ssh의 rc 파일 실행 -> daemonstart실행 -> daemon 작동 -> 접속 유저만의 Jail 디렉토리 생성 -> 접속 유저의.bashrc 의 chroot 명령어

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Web server porting 2 Jo, Heeseung Web 을이용한 LED 제어 Web 을이용한 LED 제어프로그램 web 에서데이터를전송받아타겟보드의 LED 를조작하는프로그램을작성하기위해다음과같은소스파일을생성 2 Web 을이용한 LED 제어 LED 제어프로그램작성 8bitled.html 파일을작성 root@ubuntu:/working/web# vi

More information

제12장 파일 입출력

제12장 파일 입출력 제 4 장파일입출력 리눅스시스템프로그래밍 청주대학교전자공학과 한철수 1 시스템호출 (system call) 파일 (file) 임의접근 (random access) 주요학습내용 2 4.1 절 커널의역할 (kernel) 커널 (kernel) 은운영체제의핵심부분으로서, 하드웨어를운영관리하는여러가지서비스를제공함 파일관리 (File management) 디스크 프로세스관리

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Network Programming Jo, Heeseung Network 실습 네트워크프로그래밍 멀리떨어져있는호스트들이서로데이터를주고받을수있도록프로그램을구현하는것 파일과는달리데이터를주고받을대상이멀리떨어져있기때문에소프트웨어차원에서호스트들간에연결을해주는장치가필요 이러한기능을해주는장치로소켓이라는인터페이스를많이사용 소켓프로그래밍이란용어와네트워크프로그래밍이랑용어가같은의미로사용

More information

고급 프로그래밍 설계

고급 프로그래밍 설계 UNIT 13 라즈베리파이블루투스 광운대학교로봇 SW 교육원 최상훈 Bluetooth Module 2 Bluetooth Slave UART Board UART 인터페이스용블루투스모듈 slave/device mode 라즈베리파이 GPIO 3 < 라즈베리파이 B+ 의 P1 헤더핀 GPIO 배치도 > wiringpi 라이브러리 4 라즈베리파이 GPIO 라이브러리

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 (Host) set up : Linux Backend RS-232, Ethernet, parallel(jtag) Host terminal Target terminal : monitor (Minicom) JTAG Cross compiler Boot loader Pentium Redhat 9.0 Serial port Serial cross cable Ethernet

More information

디바이스드라이버 (Device Driver) Driver is literally a subject which drive a object. 응용프로그램에서하드웨어장치를이용해서데이터를직접읽고쓰거나제어해야하는경우에디바이스드라이버를이용 하드웨어를제어하는프로그램과애플리케이션에서

디바이스드라이버 (Device Driver) Driver is literally a subject which drive a object. 응용프로그램에서하드웨어장치를이용해서데이터를직접읽고쓰거나제어해야하는경우에디바이스드라이버를이용 하드웨어를제어하는프로그램과애플리케이션에서 임베디드시스템설계강의자료 7 Device Driver (2014 년도 1 학기 ) 김영진 아주대학교전자공학과 디바이스드라이버 (Device Driver) Driver is literally a subject which drive a object. 응용프로그램에서하드웨어장치를이용해서데이터를직접읽고쓰거나제어해야하는경우에디바이스드라이버를이용 하드웨어를제어하는프로그램과애플리케이션에서디바이스를제어하기위한자료구조와함수의집합

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Sensor Device Jo, Heeseung Sensor 실습 HBE-SM5-S4210 에는근접 / 가속도 / 컴파스센서가장착 각센서들을사용하기위한디바이스드라이버와어플리케이션을작성 2 근접 (Proximity) 센서 HBE-SM5-S4210 Camera Module 근접센서디바이스 근접센서는사물이다른사물에접촉되기이전에가까이접근하였는지를검출할목적으로사용 일반적으로생활에서자동문이나엘리베이터,

More information

6주차.key

6주차.key 6, Process concept A program in execution Program code PCB (process control block) Program counter, registers, etc. Stack Heap Data section => global variable Process in memory Process state New Running

More information

로봇SW교육원 강의자료

로봇SW교육원 강의자료 UNIT 06 커널모듈 로봇 SW 교육원 3 기 학습목표 2 커널모듈의장점을설명핛수있다. 커널모듈을작성핛수있다. 커널모듈을리눅스시스템에로딩하고해제핛수있다. 커널모듈 3 커널모듈이란무엇인가? 모듈을이용해커널의기능을확장핛수있음 디바이스드라이버추가또는커널기능확장 커널모듈의장점은무엇인가? 커널이미지를재컴파일하지않고기능을추가핛수있음 커널모듈은어떻게작성핛수있는가? 커널소스트리필요

More information

ABC 11장

ABC 11장 12 장고급응용 0 수행중인프로그램 프로세스 모든프로세스는유일한프로세스식별번호 (PID) 를가짐 유닉스에서는 ps 명령을사용하여프로세스목록을볼수있음 12-1 프로세스 $ ps -aux USER PID %CPU %MEM SZ RSS TT STAT START TIME COMMAND blufox 17725 34.0 1.6 146 105 i2 R 15:13 0:00

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 BOOTLOADER Jo, Heeseung 부트로더컴파일 부트로더소스복사및압축해제 부트로더소스는웹페이지에서다운로드 /working 디렉터리로이동한후, wget으로다운로드 이후작업은모두 /working 디렉터리에서진행 root@ubuntu:# cp /media/sm5-linux-111031/source/platform/uboot-s4210.tar.bz2 /working

More information

Microsoft PowerPoint - ch09_파이프 [호환 모드]

Microsoft PowerPoint - ch09_파이프 [호환 모드] 학습목표 파이프를이용한 IPC 기법을이해한다. 이름없는파이프를이용해통신프로그램을작성할수있다. 이름있는파이프를이용해통신프로그램을작성할수있다. 파이프 IT CookBook, 유닉스시스템프로그래밍 2/20 목차 파이프의개념 이름없는파이프만들기 복잡한파이프생성 양방향파이프활용 이름있는파이프만들기 파이프의개념 파이프 두프로세스간에통신할수있도록해주는특수파일 그냥파이프라고하면일반적으로이름없는파이프를의미

More information

2009년 상반기 사업계획

2009년 상반기 사업계획 파이프 IT CookBook, 유닉스시스템프로그래밍 학습목표 파이프를이용한 IPC 기법을이해한다. 이름없는파이프를이용해통신프로그램을작성할수있다. 이름있는파이프를이용해통신프로그램을작성할수있다. 2/20 목차 파이프의개념 이름없는파이프만들기 복잡한파이프생성 양방향파이프활용 이름있는파이프만들기 3/20 파이프의개념 파이프 두프로세스간에통신할수있도록해주는특수파일 그냥파이프라고하면일반적으로이름없는파이프를의미

More information

Microsoft PowerPoint - 03-Development-Environment-2.ppt

Microsoft PowerPoint - 03-Development-Environment-2.ppt 개발환경 2 임베디드시스템소프트웨어 I 차례 부트로더의기능, 컴파일방법 커널의기능, 컴파일방법 파일시스템의기능, 생성방법 Host-KIT 네트워크연결방법 (Bootp, TFTP, NFS) 개발환경 2 2 부트로더의기능 하드웨어초기화 CPU clock, Memory Timing, Interrupt, UART, GPIO 등을초기화 커널로드 커널이미지를 flash

More information

(Microsoft PowerPoint - Device Driver [\310\243\310\257 \270\360\265\345])

(Microsoft PowerPoint - Device Driver [\310\243\310\257 \270\360\265\345]) Device Driver 커널프로그램 Kernel program 목차 Kernel program 유의사항 Kernel module 디바이스드라이버 Character/Block device driver Device driver 구조 Device driver 작성절차및 module 등록 LED 디바이스드라이버 Kernel Program (1) 커널프로그램과응용프로그램과비교

More information

chap7.key

chap7.key 1 7 C 2 7.1 C (System Calls) Unix UNIX man Section 2 C. C (Library Functions) C 1975 Dennis Ritchie ANSI C Standard Library 3 (system call). 4 C?... 5 C (text file), C. (binary file). 6 C 1. : fopen( )

More information

vi 사용법

vi 사용법 네트워크프로그래밍 6 장과제샘플코드 - 1:1 채팅 (udp 버전 ) 과제 서버에서먼저 bind 하고그포트를다른사람에게알려줄것 클라이언트에서알려준포트로접속 서로간에키보드입력을받아상대방에게메시지전송 2 Makefile 1 SRC_DIR =../../common 2 COM_OBJS = $(SRC_DIR)/addressUtility.o $(SRC_DIR)/dieWithMessage.o

More information

(Microsoft PowerPoint - Device Driver [\310\243\310\257 \270\360\265\345])

(Microsoft PowerPoint - Device Driver [\310\243\310\257 \270\360\265\345]) 목차 Device Driver 커널프로그램 Kernel program Kernel program 유의사항 Kernel module 디바이스드라이버 Character/Block device driver Device driver 구조 Device driver 작성절차및 module 등록 LED 디바이스드라이버 Kernel Program (1) 커널프로그램과응용프로그램과비교

More information

슬라이드 1

슬라이드 1 -Part3- 제 4 장동적메모리할당과가변인 자 학습목차 4.1 동적메모리할당 4.1 동적메모리할당 4.1 동적메모리할당 배울내용 1 프로세스의메모리공간 2 동적메모리할당의필요성 4.1 동적메모리할당 (1/6) 프로세스의메모리구조 코드영역 : 프로그램실행코드, 함수들이저장되는영역 스택영역 : 매개변수, 지역변수, 중괄호 ( 블록 ) 내부에정의된변수들이저장되는영역

More information

Microsoft PowerPoint - e9.pptx

Microsoft PowerPoint - e9.pptx Kernel Programming 이란? 커널모드에서수행하는프로그램을작성하는것 임베디드리눅스커널프로그래밍 커널프로그래밍종류 Linux kernel core 기능추가 Linux kernel 알고리즘개선 Linux kernel 모듈프로그래밍 커널컴파일필요없음 2 Kernel Program vs. Application Program (1) Kernel Program

More information

<4D F736F F F696E74202D20B8AEB4AABDBA20BFC0B7F920C3B3B8AEC7CFB1E22E BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D20B8AEB4AABDBA20BFC0B7F920C3B3B8AEC7CFB1E22E BC8A3C8AF20B8F0B5E55D> 리눅스 오류처리하기 2007. 11. 28 안효창 라이브러리함수의오류번호얻기 errno 변수기능오류번호를저장한다. 기본형 extern int errno; 헤더파일 라이브러리함수호출에실패했을때함수예 정수값을반환하는함수 -1 반환 open 함수 포인터를반환하는함수 NULL 반환 fopen 함수 2 유닉스 / 리눅스 라이브러리함수의오류번호얻기 19-1

More information

11장 포인터

11장 포인터 Dynamic Memory and Linked List 1 동적할당메모리의개념 프로그램이메모리를할당받는방법 정적 (static) 동적 (dynamic) 정적메모리할당 프로그램이시작되기전에미리정해진크기의메모리를할당받는것 메모리의크기는프로그램이시작하기전에결정 int i, j; int buffer[80]; char name[] = data structure"; 처음에결정된크기보다더큰입력이들어온다면처리하지못함

More information

Microsoft PowerPoint - chap13-입출력라이브러리.pptx

Microsoft PowerPoint - chap13-입출력라이브러리.pptx #include int main(void) int num; printf( Please enter an integer: "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num = %d\n", num); return 0; 1 학습목표 스트림의 기본 개념을 알아보고,

More information

61 62 63 64 234 235 p r i n t f ( % 5 d :, i+1); g e t s ( s t u d e n t _ n a m e [ i ] ) ; if (student_name[i][0] == \ 0 ) i = MAX; p r i n t f (\ n :\ n ); 6 1 for (i = 0; student_name[i][0]!= \ 0&&

More information

Embeddedsystem(8).PDF

Embeddedsystem(8).PDF insmod init_module() register_blkdev() blk_init_queue() blk_dev[] request() default queue blkdevs[] block_device_ops rmmod cleanup_module() unregister_blkdev() blk_cleanup_queue() static struct { const

More information

Mango220 Android How to compile and Transfer image to Target

Mango220 Android How to compile and Transfer image to Target Mango220 Android How to compile and Transfer image to Target http://www.mangoboard.com/ http://cafe.naver.com/embeddedcrazyboys Crazy Embedded Laboratory www.mangoboard.com cafe.naver.com/embeddedcrazyboys

More information

Microsoft PowerPoint - chap12 [호환 모드]

Microsoft PowerPoint - chap12 [호환 모드] 제 12 장고급입출력 Nov 2007 숙대창병모 1 Contents 1. Nonblocking I/O 2. Record Locking 3. Memory Mapped I/O Nov 2007 숙대창병모 2 12.1 Nonblocking I/O Nov 2007 숙대창병모 3 Nonblocking I/O Blocking I/O I/O 작업완료를기다리며영원히리턴안할수있다

More information

Microsoft Word - MPC850 SPI Driver.doc

Microsoft Word - MPC850 SPI Driver.doc MPC850 SPI Driver 네트워크보드에서구현한 SPI Device Driver 제작및이용방법입니다. 문서작성 : 이재훈 (kingseft.lee@samsung.com) 이용한 SPI EEPROM - X5043/X5045 512 x 8 bit SPI EEPROM (4Kbits = 512bytes) - 제조사 : XICOR (www.xicor.com) -

More information

리눅스 취약점대응방안권고 / KISA 취약점점검팀 영향받는플랫폼 OS, FAQ 추가 개요 미국보안회사 에의해 시스템의 라이브러리 의특정함수에서임의코드를실행할수있는취약점이공개 해당취약점은 CVE 지정, 도메인네임을

리눅스 취약점대응방안권고 / KISA 취약점점검팀 영향받는플랫폼 OS, FAQ 추가 개요 미국보안회사 에의해 시스템의 라이브러리 의특정함수에서임의코드를실행할수있는취약점이공개 해당취약점은 CVE 지정, 도메인네임을 리눅스 취약점대응방안권고 15. 01. 29 / KISA 취약점점검팀 15. 01. 30 영향받는플랫폼 OS, FAQ 추가 개요 미국보안회사 에의해 시스템의 라이브러리 의특정함수에서임의코드를실행할수있는취약점이공개 해당취약점은 CVE-2015-0235 지정, 도메인네임을 IP로변환하는기능이포함된서비스 ( 메일, 웹등 ) 들은해당취약점에영향을받을수있음 취약점상세분석

More information

BMP 파일 처리

BMP 파일 처리 BMP 파일처리 김성영교수 금오공과대학교 컴퓨터공학과 학습내용 영상반전프로그램제작 2 Inverting images out = 255 - in 3 /* 이프로그램은 8bit gray-scale 영상을입력으로사용하여반전한후동일포맷의영상으로저장한다. */ #include #include #define WIDTHBYTES(bytes)

More information

슬라이드 제목 없음

슬라이드 제목 없음 < > Target cross compiler Target code Target Software Development Kit (SDK) T-Appl T-Appl T-VM Cross downloader Cross debugger Case 1) Serial line Case 2) LAN line LAN line T-OS Target debugger Host System

More information

Raspbian 설치 라즈비안 OS (Raspbian OS) 라즈베리파이 3 Model B USB 마우스 USB 키보드 마이크로 SD 카드 마이크로 SD 카드리더기 HDM I 케이블모니터

Raspbian 설치 라즈비안 OS (Raspbian OS) 라즈베리파이 3 Model B USB 마우스 USB 키보드 마이크로 SD 카드 마이크로 SD 카드리더기 HDM I 케이블모니터 운영체제실습 Raspbian 설치 2017. 3 표월성 wspyo74@naver.com cherub.sungkyul.ac.kr 목차 Ⅰ. 설치 1. 라즈비안 (Raspbian 설치 ) 2. 설치후, 설정 설정사항 Raspbian 설치 라즈비안 OS (Raspbian OS) 라즈베리파이 3 Model B USB 마우스 USB 키보드 마이크로 SD 카드 마이크로

More information

10.

10. 10. 10.1 10.2 Library Routine: void perror (char* str) perror( ) str Error 0 10.3 10.3 int fd; /* */ fd = open (filename, ) /*, */ if (fd = = -1) { /* */ } fcnt1 (fd, ); /* */ read (fd, ); /* */ write

More information

좀비프로세스 2

좀비프로세스 2 Signal & Inter-Process Communication Department of Computer Engineering Kyung Hee University. Choong Seon Hong 1 좀비프로세스 2 좀비프로세스 (zombie process) 좀비프로세스란프로세스종료후메모리상에서사라지지않는프로세스 좀비프로세스의생성이유. 자식프로세스는부모프로세스에게실행결과에대한값을반환해야한다.

More information

°ø°³¼ÒÇÁÆ®-8È£

°ø°³¼ÒÇÁÆ®-8È£ 2007. 08 No.8 IT World 운영체제 미들웨어 데이터베이스 웹프로그래밍까지 표준화된공개SW 컴퓨팅환경이지원합니다. 글로벌표준의공개SW 환경은 핵심애플리케이션뿐만아니라다양한플랫폼에서도활용됩니다. 2 2007. 08No.8 Contents Special Editorial 04 Best Practice 08 12 16 20 24 26 Insight 32

More information

untitled

untitled Block Device Driver in Linux Embedded System Lab. II Embedded System Lab. II 2 Define objective of applications using device Study Hardware manual (Registers) (vector number) Understand interface to related

More information

Microsoft PowerPoint - 09-Pipe

Microsoft PowerPoint - 09-Pipe 9. 파이프 상명대학교소프트웨어학부 파이프 시그널은이상한사건이나오류를처리하는데는이용하지만, 한프로세스로부터다른프로세스로대량의정보를전송하는데는부적합하다. 파이프 한프로세스를다른관련된프로세스에연결시켜주는단방향의통신채널 2 pipe() Usage #include int pipe(int filedes[2]); 3 < ex_1.c > #include

More information

K&R2 Reference Manual 번역본

K&R2 Reference Manual 번역본 typewriter structunion struct union if-else if if else if if else if if if if else else ; auto register static extern typedef void char short int long float double signed unsigned const volatile { } struct

More information

< E20C6DFBFFEBEEE20C0DBBCBAC0BB20C0A7C7D12043BEF0BEEE20492E707074>

< E20C6DFBFFEBEEE20C0DBBCBAC0BB20C0A7C7D12043BEF0BEEE20492E707074> Chap #2 펌웨어작성을위한 C 언어 I http://www.smartdisplay.co.kr 강의계획 Chap1. 강의계획및디지털논리이론 Chap2. 펌웨어작성을위한 C 언어 I Chap3. 펌웨어작성을위한 C 언어 II Chap4. AT89S52 메모리구조 Chap5. SD-52 보드구성과코드메모리프로그래밍방법 Chap6. 어드레스디코딩 ( 매핑 ) 과어셈블리어코딩방법

More information

교육지원 IT시스템 선진화

교육지원 IT시스템 선진화 Module 10: 디바이스드라이버기초 ESP30076 임베디드시스템프로그래밍 (Embedded System Programming) 조윤석 전산전자공학부 주차별목표 디바이스드라이버란? 디바이스드라이버주요함수알아보기 디바이스드라이버기본골격구성하기 2 디바이스드라이버프로그래밍 리눅스커널의구조 커널프로그래밍 리눅스커널의핵심 (core) 기능추가 리눅스커널알고리즘개선

More information

Microsoft PowerPoint - chap10-함수의활용.pptx

Microsoft PowerPoint - chap10-함수의활용.pptx #include int main(void) { int num; printf( Please enter an integer: "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num = %d\n", num); return 0; } 1 학습목표 중 값에 의한 전달 방법과

More information

이번장에서학습할내용 동적메모리란? malloc() 와 calloc() 연결리스트 파일을이용하면보다많은데이터를유용하고지속적으로사용및관리할수있습니다. 2

이번장에서학습할내용 동적메모리란? malloc() 와 calloc() 연결리스트 파일을이용하면보다많은데이터를유용하고지속적으로사용및관리할수있습니다. 2 제 17 장동적메모리와연결리스트 유준범 (JUNBEOM YOO) Ver. 2.0 jbyoo@konkuk.ac.kr http://dslab.konkuk.ac.kr 본강의자료는생능출판사의 PPT 강의자료 를기반으로제작되었습니다. 이번장에서학습할내용 동적메모리란? malloc() 와 calloc() 연결리스트 파일을이용하면보다많은데이터를유용하고지속적으로사용및관리할수있습니다.

More information

2009년 상반기 사업계획

2009년 상반기 사업계획 소켓프로그래밍활용 IT CookBook, 유닉스시스템프로그래밍 학습목표 소켓인터페이스를활용한다양한프로그램을작성할수있다. 2/23 목차 TCP 기반프로그래밍 반복서버 동시동작서버 동시동작서버-exec함수사용하기 동시동작서버-명령행인자로소켓기술자전달하기 UDP 프로그래밍 3/23 TCP 기반프로그래밍 반복서버 데몬프로세스가직접모든클라이언트의요청을차례로처리 동시동작서버

More information

API 매뉴얼

API 매뉴얼 PCI-DIO12 API Programming (Rev 1.0) Windows, Windows2000, Windows NT and Windows XP are trademarks of Microsoft. We acknowledge that the trademarks or service names of all other organizations mentioned

More information

Microsoft PowerPoint APUE(Intro).ppt

Microsoft PowerPoint APUE(Intro).ppt 컴퓨터특강 () [Ch. 1 & Ch. 2] 2006 년봄학기 문양세강원대학교컴퓨터과학과 APUE 강의목적 UNIX 시스템프로그래밍 file, process, signal, network programming UNIX 시스템의체계적이해 시스템프로그래밍능력향상 Page 2 1 APUE 강의동기 UNIX 는인기있는운영체제 서버시스템 ( 웹서버, 데이터베이스서버

More information

휠세미나3 ver0.4

휠세미나3 ver0.4 andromeda@sparcs:/$ ls -al dev/sda* brw-rw---- 1 root disk 8, 0 2014-06-09 18:43 dev/sda brw-rw---- 1 root disk 8, 1 2014-06-09 18:43 dev/sda1 brw-rw---- 1 root disk 8, 2 2014-06-09 18:43 dev/sda2 andromeda@sparcs:/$

More information

임베디드시스템설계강의자료 4 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과

임베디드시스템설계강의자료 4 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과 임베디드시스템설계강의자료 4 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과 Outline n n n n n n 보드개요보드연결필수패키지, Tool-Chain 설치 Kernel, file system build Fastboot 및 Tera Term설치 Kernel, file system 이미지전송및설치 - 2 - Young-Jin Kim X-Hyper320TKU

More information

<4D F736F F F696E74202D20B8B6C0CCC5A9B7CEC7C1B7CEBCBCBCAD202839C1D6C2F7207E203135C1D6C2F >

<4D F736F F F696E74202D20B8B6C0CCC5A9B7CEC7C1B7CEBCBCBCAD202839C1D6C2F7207E203135C1D6C2F > 10주차 문자 LCD 의인터페이스회로및구동함수 Next-Generation Networks Lab. 5. 16x2 CLCD 모듈 (HY-1602H-803) 그림 11-18 19 핀설명표 11-11 번호 분류 핀이름 레벨 (V) 기능 1 V SS or GND 0 GND 전원 2 V Power DD or V CC +5 CLCD 구동전원 3 V 0 - CLCD 명암조절

More information

[ 컴퓨터시스템 ] 3 주차 1 차시. 디렉토리사이의이동 3 주차 1 차시디렉토리사이의이동 학습목표 1. pwd 명령을사용하여현재디렉토리를확인할수있다. 2. cd 명령을사용하여다른디렉토리로이동할수있다. 3. ls 명령을사용하여디렉토리내의파일목록을옵션에따라다양하게확인할수

[ 컴퓨터시스템 ] 3 주차 1 차시. 디렉토리사이의이동 3 주차 1 차시디렉토리사이의이동 학습목표 1. pwd 명령을사용하여현재디렉토리를확인할수있다. 2. cd 명령을사용하여다른디렉토리로이동할수있다. 3. ls 명령을사용하여디렉토리내의파일목록을옵션에따라다양하게확인할수 3 주차 1 차시디렉토리사이의이동 학습목표 1. pwd 명령을사용하여현재디렉토리를확인할수있다. 2. cd 명령을사용하여다른디렉토리로이동할수있다. 3. ls 명령을사용하여디렉토리내의파일목록을옵션에따라다양하게확인할수있다. 학습내용 1 : 현재디렉토리확인 1. 홈디렉토리 - 로그인을한후, 사용자가기본으로놓이게되는디렉토리위치를홈디렉토리 (home directory)

More information

DE1-SoC Board

DE1-SoC Board 실습 1 개발환경 DE1-SoC Board Design Tools - Installation Download & Install Quartus Prime Lite Edition http://www.altera.com/ Quartus Prime (includes Nios II EDS) Nios II Embedded Design Suite (EDS) is automatically

More information

C++-¿Ïº®Çؼ³10Àå

C++-¿Ïº®Çؼ³10Àå C C++. (preprocessor directives), C C++ C/C++... C++, C. C++ C. C C++. C,, C++, C++., C++.,.. #define #elif #else #error #if #itdef #ifndef #include #line #pragma #undef #.,.,. #include #include

More information

Microsoft PowerPoint - chap02-C프로그램시작하기.pptx

Microsoft PowerPoint - chap02-C프로그램시작하기.pptx #include int main(void) { int num; printf( Please enter an integer "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num = %d\n", num); return 0; } 1 학습목표 을 작성하면서 C 프로그램의

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Development Environment 2 Jo, Heeseung make make Definition make is utility to maintain groups of programs Object If some file is modified, make detects it and update files related with modified one It

More information

Microsoft PowerPoint - chap12-고급기능.pptx

Microsoft PowerPoint - chap12-고급기능.pptx #include int main(void) int num; printf( Please enter an integer: "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num = %d\n", num); return 0; 1 학습목표 가 제공하는 매크로 상수와 매크로

More information

Abstract View of System Components

Abstract View of System Components Operating System 4 주차 - System Call Implementation - Real-Time Computing and Communications Lab. Hanyang University jtlim@rtcc.hanyang.ac.kr yschoi@rtcc.hanyang.ac.kr shpark@rtcc.hanyang.ac.kr Contents

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 DEVELOPMENT ENVIRONMENT 2 MAKE Jo, Heeseung MAKE Definition make is utility to maintain groups of programs Object If some file is modified, make detects it and update files related with modified one 2

More information

Microsoft Word - KPMC-400,401 SW 사용 설명서

Microsoft Word - KPMC-400,401 SW 사용 설명서 LKP Ethernet Card SW 사용설명서 Version Information Tornado 2.0, 2.2 알 림 여기에실린내용은제품의성능향상과신뢰도의증대를위하여예고없이변경될수도있습니다. 여기에실린내용의일부라도엘케이일레븐의사전허락없이어떠한유형의매체에복사되거나저장될수없으며전기적, 기계적, 광학적, 화학적인어떤방법으로도전송될수없습니다. 엘케이일레븐경기도성남시중원구상대원동

More information

Microsoft PowerPoint - [2009] 02.pptx

Microsoft PowerPoint - [2009] 02.pptx 원시데이터유형과연산 원시데이터유형과연산 원시데이터유형과연산 숫자데이터유형 - 숫자데이터유형 원시데이터유형과연산 표준입출력함수 - printf 문 가장기본적인출력함수. (stdio.h) 문법 ) printf( Test printf. a = %d \n, a); printf( %d, %f, %c \n, a, b, c); #include #include

More information

한백전자교육사업부 AndroX Studio 로배우는임베디드프로그래밍 - 한백전자 - 본문서의저작권은 한백전자에있으며, 허락없이무단복제및전제를불허합니다.

한백전자교육사업부 AndroX Studio 로배우는임베디드프로그래밍 - 한백전자 - 본문서의저작권은 한백전자에있으며, 허락없이무단복제및전제를불허합니다. 한백전자교육사업부 AndroX Studio 로배우는임베디드프로그래밍 - 한백전자 - 실습용장비 ; SM7-S4412 프로세서와주변장치직접연결 GPIO, 인터럽트, SPI, I2C 인터페이스사용 FPGA 모듈을거치지않음! 마이컴개발을위한아두이노 (Arduino Mega 2560) 탑재 ADK 2011 지원 안드로이드장치와아두이노보드연동가능 2 타깃주요명칭 HBE-SM7-S4412

More information

Microsoft PowerPoint - Lecture_Note_7.ppt [Compatibility Mode]

Microsoft PowerPoint - Lecture_Note_7.ppt [Compatibility Mode] Unix Process Department of Computer Engineering Kyung Hee University. Choong Seon Hong 1 유닉스기반다중서버구현방법 클라이언트들이동시에접속할수있는서버 서비스를동시에처리할수있는서버프로세스생성을통한멀티태스킹 (Multitasking) 서버의구현 select 함수에의한멀티플렉싱 (Multiplexing)

More information

RaspberryPi 시리얼통신 1 제 08 강 시리얼통신제어 시리얼통신시리얼모니터링루프백시리얼통신 Win. PC와의시리얼통신가상머신과의시리얼통신아두이노보드와의시리얼통신 KUT51보드와의시리얼통신

RaspberryPi 시리얼통신 1 제 08 강 시리얼통신제어 시리얼통신시리얼모니터링루프백시리얼통신 Win. PC와의시리얼통신가상머신과의시리얼통신아두이노보드와의시리얼통신 KUT51보드와의시리얼통신 RaspberryPi 시리얼통신 1 제 08 강 시리얼통신제어 시리얼통신시리얼모니터링루프백시리얼통신 Win. PC와의시리얼통신가상머신과의시리얼통신아두이노보드와의시리얼통신 KUT51보드와의시리얼통신 시리얼통신 * Serial 활성화후재부팅 $ sudo raspi-config RaspberryPi 시리얼통신 2 $ sudo reboot : 시리얼통신을위한장치파일

More information

1217 WebTrafMon II

1217 WebTrafMon II (1/28) (2/28) (10 Mbps ) Video, Audio. (3/28) 10 ~ 15 ( : telnet, ftp ),, (4/28) UDP/TCP (5/28) centralized environment packet header information analysis network traffic data, capture presentation network

More information

The Pocket Guide to TCP/IP Sockets: C Version

The Pocket Guide to  TCP/IP Sockets: C Version 얇지만얇지않은 TCP/IP 소켓프로그래밍 C 2 판 4 장 UDP 소켓 제 4 장 UDP 소켓 4.1 UDP 클라이언트 4.2 UDP 서버 4.3 UDP 소켓을이용한데이터송싞및수싞 4.4 UDP 소켓의연결 UDP 소켓의특징 UDP 소켓의특성 싞뢰할수없는데이터젂송방식 목적지에정확하게젂송된다는보장이없음. 별도의처리필요 비연결지향적, 순서바뀌는것이가능 흐름제어 (flow

More information

본 강의에 들어가기 전

본 강의에 들어가기 전 C 기초특강 종합과제 과제내용 구조체를이용하여교과목이름과코드를파일로부터입력받아관리 구조체를이용하여학생들의이름, 학번과이수한교과목의코드와점수를파일로부터입력 학생개인별총점, 평균계산 교과목별이수학생수, 총점및평균을계산 결과를파일에저장하는프로그램을작성 2 Makefile OBJS = score_main.o score_input.o score_calc.o score_print.o

More information

Sena Technologies, Inc. HelloDevice Super 1.1.0

Sena Technologies, Inc. HelloDevice Super 1.1.0 HelloDevice Super 110 Copyright 1998-2005, All rights reserved HelloDevice 210 ()137-130 Tel: (02) 573-5422 Fax: (02) 573-7710 E-Mail: support@senacom Website: http://wwwsenacom Revision history Revision

More information