조회 수 10400 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부

HelloWorld 커널 모듈 예제와 yocto 레시피를 작성하고 모듈을 적재 및 제거하는 내용을 다룬다.

 

개발환경: 우분투 리눅스 18.04, yocto

타겟: wandboard (i.MX6)

 

NXP에서 제공하는 욕토 레이어 meta-freescale, meta-freescale-3rdparty, meta-freescale-distro 를 사용할 수 있다.

이글은 간단한 커널 모듈을 적재하는 방법을 설명할 것이며 이미지는 아주 작은 것을 사용한다. 다음의 명령으로 이미지를 빌드 할 수 있다.

bitbake core-image-minimal

 

meta-freescale-3rdparty 레이어에 레시피 추가

 

위에서 언급한 레이어에 간단한 커널 모듈을 위한 레시피를 추가하려한다. 먼저 적당한 이름의 디렉토리를 만든다.

<your source path>/meta-freescale-3rdparty/recipes-kernel$ mkdir hello-module

 

$ cd hello-module

 

레시피 작성

hello-module.bb

#
# Yocto recipe to build a kernel module out of the kernel tree
# hello-module.bb 
# www.makersweb.net
#

DESCRIPTION = "Hello kernel module out of the kernel tree"
SECTION = "examples"
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://COPYING;md5=12f884d2ae1ff87c09e5b7ccc2c4ca7e"
PR = "r0"

inherit module

SRC_URI =  "file://hello.c \
                        file://Makefile \
                        file://COPYING \
                        "

S = "${WORKDIR}"

 

$ mkdir files

$ cd files/

 

모듈 프로그램 작성

hello.c

#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>

static int __init hello_init(void)
{
    printk("Hello World!\n");
    return 0;
}

static void __exit hello_exit(void)
{
    printk("Good bye!\n");
}

module_init(hello_init); // when insmod
module_exit(hello_exit); // when rmmod

MODULE_LICENSE("GPL v2");

 

Makefile 작성

Makefile

obj-m += hello.o

SRC := $(shell pwd)

all:
        $(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules

modules_install:
        $(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules_install

clean:
        rm *.o

 

디렉토리 구조

hello-module

├── files

│   ├── COPYING

│   ├── hello.c

│   └── Makefile

└── hello-module.bb

 

해당 레시피를 빌드

$ bitbake hello-module

 

빌드된 모듈 위치 찾기

$ bitbake -e hello-module | grep ^WORKDIR=

 

모듈을 이미지에 포함시키기

<build dir>/conf/local.conf 파일에 다음 라인 추가

IMAGE_INSTALL_append = " hello-module"

 

이미지 다시 빌드

$ bitbake core-image-minimal

 

이미지를 sd메모리에 쓰고 부팅

hello-module은 /lib/modules/4.9.67-fslc+g953c6e30c970/extra 에서 찾을 수 있다.

 

모듈 적재 및 제거

image.png

 


  1. HelloWorld 커널 모듈과 yocto 레시피 추가 방법

    Date2019.12.09 Category드라이버 Bymakersweb Views10400
    Read More
  2. ESP32 블루투스 스피커(A2DP Sink)

    Date2019.10.29 Category통신 Bymakersweb Views6609
    Read More
  3. ESP-IDF 의 A2DP리뷰 (ESP32)

    Date2019.10.28 CategoryMCU Bymakersweb Views13129
    Read More
  4. 임베디드 리눅스 부팅 절차

    Date2019.10.21 Category운영체제 Bymakersweb Views10705
    Read More
  5. No Image

    mainline 커널 및 etnaviv 를 사용하는 Wandboard(Freescale i.MX6Q)에서 eglfs를 사용

    Date2019.10.17 Category운영체제 Bymakersweb Views5130
    Read More
  6. Yocto를 이용한 wandboard BSP 및 Qt5 SDK 빌드

    Date2019.09.29 Category개발환경 Bymakersweb Views5594
    Read More
  7. STM32 & LibOpenCM3, printf함수사용

    Date2019.08.08 Category펌웨어 Bymakersweb Views5369
    Read More
  8. STM32(Cortex-M3) LED Blink with PlatformIO

    Date2019.08.05 Category펌웨어 Bymakersweb Views5410
    Read More
  9. 블루투스(Bluetooth) 기초

    Date2019.08.02 Category통신 Bymakersweb Views8856
    Read More
  10. STM32(Cortex-M3) 개발환경구축 with PlatformIO

    Date2019.07.26 Category개발환경 Bymakersweb Views6845
    Read More
  11. STM32(Cortex-M3) 개발 - Firmware Flashing

    Date2019.07.23 CategoryMCU Bymakersweb Views6076
    Read More
  12. No Image

    libopencm3 활용, Cortex-M 펌웨어 개발

    Date2019.07.14 CategoryMCU Bymakersweb Views5300
    Read More
  13. No Image

    yocto의 몇가지 중요한 용어 및 개념

    Date2019.06.21 Category개발환경 Bymakersweb Views7425
    Read More
  14. 라즈베리파이3와 PC간 Serial 통신 테스트

    Date2019.05.20 Category개발환경 Bymakersweb Views9452
    Read More
  15. 욕토 프로젝트를 이용한 Qt SDK 빌드 for 라즈베리파이3

    Date2019.03.19 Category운영체제 Bymakersweb Views5740
    Read More
  16. yocto project, 라즈베리파이를 위한 Qt + 임베디드리눅스 빌드

    Date2019.02.01 Category운영체제 Bymakersweb Views14417
    Read More
  17. STM32(Cortex-M3) 개발환경구축 with Eclipse

    Date2018.11.08 Category개발환경 Bymakersweb Views6567
    Read More
  18. No Image

    ST, STM32 MCU용 ‘통합 개발 환경(IDE)’ 무료 제공

    Date2015.03.04 Category개발환경 Bymakersweb Views13006
    Read More
  19. USB OTG 기술의 개념

    Date2014.11.03 Category통신 Bypjk Views19754
    Read More
  20. USB 핀아웃

    Date2014.10.11 Category통신 Bypjk Views11713
    Read More
Board Pagination Prev 1 2 3 Next
/ 3