Kernel Porting

24
Kernel Porting Kernel Porting Lecture #7 Lecture #7

description

Kernel Porting. Lecture #7. 목 차. 임베디드리눅스 최신 경향 Kernel Porting Overview ARM Patch Xscale Patch PXA255-PRO3 Board Patch Kernel Configuration & Compiling Kernel fusing & Testing. 임베디드 리눅스 관련 최신 경향 #1 : 삼성전자. 임베디드 리눅스 관련 최신 경향 #2 : 구글 (Google). 임베디드 리눅스 관련 최신 경향 #3 : Paradigm Shift. - PowerPoint PPT Presentation

Transcript of Kernel Porting

Page 1: Kernel Porting

Kernel PortingKernel Porting

Lecture #7Lecture #7

Page 2: Kernel Porting

2

목 차

임베디드리눅스 최신 경향 Kernel Porting Overview ARM Patch Xscale Patch PXA255-PRO3 Board Patch Kernel Configuration & Compiling Kernel fusing & Testing

Page 3: Kernel Porting

임베디드 리눅스 관련 최신 경향 임베디드 리눅스 관련 최신 경향 #1 : #1 : 삼성전자삼성전자

Page 4: Kernel Porting

4

임베디드 리눅스 관련 최신 경향 임베디드 리눅스 관련 최신 경향 #2 : #2 : 구글구글 (Google)(Google)

Page 5: Kernel Porting

5

임베디드 리눅스 관련 최신 경향 임베디드 리눅스 관련 최신 경향 #3 : Paradigm Shift#3 : Paradigm Shift

Linux Win CEPortsPorts

NetworksNetworks

Tool-chainTool-chain

GUIGUI

Mobile NetworkGUIGUI NetworksNetworks

ex) 휴대폰 , 차세대 가전기기 ex) 홈 게이트웨이 , 로봇

Page 6: Kernel Porting

6

Kernel Porting Overview (1)

Kernel Porting 리눅스 커널을 특정 타겟 보드의 하드웨어 환경 및 특정

응용에 맞게 수정하는 과정 포팅 영역

H/W-dependent CPU porting Board porting

H/W-independent Linux kernel 의 주요 기능

선별 및 수정 특정 응용 실행에 효율적인

환경 구축

Hardware

Application

H/W-indep.

H/W-dep.

Linux Kernel

주로 H/W-dep. 영역에 대한 포팅을 kernel porting 이라

Page 7: Kernel Porting

7

Kernel Porting Overview (2)

Kernel Porting 절차

이론적인 포팅 절차

실무에서의 포팅 절차

Original Kernel ARM Core Patch Target Board Patch

Reference Kernel ARM Core Patch Target Board Patch

XScale Core Patch

Why?1) 시간

2) 기능 구현 여부 : ex) SDIO, BlueTooth, CF I/O mode

3) 성능 , 안정성

Page 8: Kernel Porting

8

ARM Core Patch (1`)

Linux kernel 준비 http://www.kernel.org/ 원하는 버전의 리눅스 커널을 상기의 사이트에서 다운로드받아

준비한다 예 : linux-2.6.21.tar.gz

linux-2.4.19.tar.gz

ARM Core Patch 준비 ARM core patch 는 ARM 사에서 제공하나 리눅스 커널 2.6 에

대해 더 이상 지원되지 않음 리눅스 커널 2.4(e.g, linux-2.4.19) 에 대해 설명

http://www.arm.uk.linux.org/ 상기의 사이트에서 원하는 커널의 ARM core patch 파일을

다운로드한다 (e.g, patch-2.4.19-rmk4.gz)

Page 9: Kernel Porting

9

ARM Core Patch (2`)

ARM Core Patch 적용# pwd

/home/pxa255-pro3/kernel

# ls

linux-2.4.19.tar.gz patch-2.4.19-rmk4.gz

# tar xvfz linux-2.4.19.tar.gz

# cd /home/pxa255-pro3/kernel/linux-2.4.19

# zcat ../patch-2.4.19-rmk4.gz | patch –p1

(or

# gunzip –d ../patch-2.4.19-rmk4.gz

# patch –p1 < patch-2.4.19-rmk4 )

Page 10: Kernel Porting

10

Xscale Patch (1`)

Xscale Patch 필요성 타켓 보드에서 사용하는 CPU: Xscale PXA255 processor 상기의 processor 는 SoC processor 로 ARM core 이외에

외부 장치와의 인터페이스 기능 , 몇가지 기본적인 I/O 기능을 포함

추가적인 기능들에 대해 kernel patch 가 필요

Xscale Patch 준비 특정 processor 에 대한 patch 는 몇몇 프리랜서들에 의해

제공 Xscale patch 는 nico 라는 프리랜서가 제공

ftp://ftp.arm.uk.linux.org/pub/linux/arm/people/nico/v.2.4 상기의 사이트에서 원하는 커널의 Xscale patch 파일을

다운로드한다 (e.g, diff-2.4.19-rmk4-pxa2.gz)

Page 11: Kernel Porting

11

Xscale Patch (2)

Xscale Patch 적용# pwd

/home/pxa255-pro3/kernel

# ls

diff-2.4.19-rmk4-pxa2.gz linux-2.4.19

linux-2.4.19.tar.gz patch-2.4.19-rmk4.gz

# cd /home/pxa255-pro3/kernel/linux-2.4.19

# zcat ../diff-2.4.19-rmk4-pxa2.gz | patch –p1

(or

# gunzip –d ../diff-2.4.19-rmk4-pxa2.gz

# patch –p1 < diff-2.4.19-rmk4-pxa2 )

Page 12: Kernel Porting

12

PXA255-PRO3 Board Patch (1)

Board Patch 개요 타켓 보드에서 지원하는 각종 I/O 장치 및 인터페이스에

대한 kernel patch 예 :

1) Board description

2) Ethernet I/F

3) LCD display

4) USB

5) PCMCIA, CF, SD I/F etc. 타겟 보드 제조업체에서 제공

Page 13: Kernel Porting

13

PXA255-PRO3 Board Patch (2)

Board Patch 준비 휴인스 사이트나 제공된 CD-ROM 으로 부터 board patch

파일을 복사하여 준비 예 : diff-2.4.19-rmk4-pro3.gz

Board Patch 적용# pwd

/home/pxa255-pro3/kernel

# cd /home/pxa255-pro3/kernel/linux-2.4.19

# zcat ../diff-2.4.19-rmk4-pro3.gz | patch –p1

(or

# gunzip –d ../diff-2.4.19-rmk4-pro3.gz

# patch –p1 < diff-2.4.19-rmk4-pro3 )

Page 14: Kernel Porting

14

Kenel Compiling (1)

Kernel image making Kenel Configuration Kernel Compiling Kernel Configuration

타 겟 보 드 에 탑 재 될 linux kernel 의 구 성 , 주 요 기 능 및 옵션들을 설정 특정 응용에 적합하게 linux kernel 환경을 구축

커널 기능에 대해 ‘지원함’ , ‘ 지원하지 않음’ , ‘module 로 지원함’으로 선택

실행 명령 : # make menuconfig Kernel Compiling

커널 설정에 따라 커널 소스를 컴파일하여 커널 이미지를 생성 실행 명령 : # make dep

# make zImage

Page 15: Kernel Porting

15

Kenel Compiling (2)

Kernel image making 절차# pwd

/home/pxa255-pro3/kernel

# cd /home/pxa255-pro3/kernel/linux-2.4.19

# make pro3_config // default configuration 적용// 타겟 보드에 따라 지원되지 않을 수

있음# make oldconfig

(or # make menuconfig // default config. 를 수정하고자 할 때 .)

# make clean // # make distclean

# make dep

# make zImage

Page 16: Kernel Porting

16

Kenel Fusing

Kernel Fusing 새롭게 생성된 커널 이미지를 u-boot bootloader 프로그램을

통해 타겟 보드의 플래시 메모리에 퓨징한다 퓨징 절차는 “ 강의 -5” 내용을 참조

Page 17: Kernel Porting

17

PXA255-PRO3 Board 실습 (1)

PXA255-PRO3 Board Patch 실습 현재 실습중인 커널 버전은 linux-2.4.21 이고 , 이에 대한

kernel patch & compiling 을 실습한다 .

Step 1: 커널 소스 준비 http://www.kernel.org/ 사 이 트 에 서 커 널 소 스 linux-

2.6.21.tar.gz 을 다운로드한다 커널 소스 압축을 해제한다 :

# tar xvfz linux-2.6.21.tar.gz

Step 2: PXA255-PRO3 board patch 준비 PXA255-PRO3 board patch 파일 diff-2.6.21-pxa255-pro3.gz

을 준비한다

Page 18: Kernel Porting

18

PXA255-PRO3 Board 실습 (2)

PXA255-PRO3 Board Patch 실습 (cont’n)

Step 3: Board patch 적용# cd ~/pxa255-pro3/kernel/linux-2.6.21

# ls ../diff-2.6.21-pxa255-pro3.gz

diff-2.6.21-pxa255-pro3.gz

# zcat ../ diff-2.6.21-pxa255-pro3.gz | patch –p1

Step 4: Kernel compiling# pwd

/home/pxa255-pro3/kernel/linux-2.6.21

# make pro3_defconfig

# make oldconfig

# make uImage

Page 19: Kernel Porting

19

PXA255-PRO3 Board 실습 (3)

PXA255-PRO3 Board Patch 실습 (cont’n)

Step 5: Kernel image 생성 결과 확인 현재 board patch 에서는 커널 컴파일 후에 커널 이미지를

/tftpboot/pxa255_pro3/uImage-2.6.21-pro3 로 복사한다 ls 명령어를 통해 생성된 커널 이미지를 확인한다

# ls –al /tftpboot/pxa255_pro3

Step 6: Kernel fusing 타겟 보드를 리셋하여 u-boot 의 command mode 로 들어간다 커널 퓨징과 관련하여 환경 변수를 확인 및 수정한다

PRO3> printenv 커널을 퓨징한다

PRO3> run linuxf

Page 20: Kernel Porting

부록 : Menuconfig flow

make pro3_defconfig

make menuconfig

.config 有 arch/arm/defconfig

script/Menuconfig

cd include ; ln -sf asm-arm asm

lxdialog compile

arch/arm/config.in

lxdialog

no

yes

Configuration

.tmpconfig , .tmpconfig.h

mv .tmpconfig.h include/linux/autoconf.h exitmv .tmpconfig .config

Page 21: Kernel Porting

부록 : Patch file 만들기

Patch file Patch file 은 두 파일이나 디렉토리간의 차이점을 출력해주는

프로그램인 diff 에 의해 만들어진 파일을 의미 . 프로그램의 기능향상이나 문제점을 파악하기 위함 . 보관의 용이 , Version up 관리 용이

Page 22: Kernel Porting

부록 : Patch file 만들기 (con’t)

diff 사용법

#include <stdio.h>

int main(void) { printf("hello world!!!\n"); return 0;

}

#include <stdio.h>

int main(void) { printf("hello world!!!\n"); printf("hello bedguy!!!\n"); return 0;

}

hello.c hello2.c

[root@bedguy /root]# diff -uNr hello.c hello2.c > hello.patch [root@bedguy /root]# cat hello.patch--- hello.c Thu Aug 30 14:08:05 2001+++ hello2.c Thu Aug 30 14:06:54 2001@@ -2,6 +2,7 @@ int main(void) { printf("hello world!!!\n"); + printf("hello bedguy!!!\n"); return 0; }

[root@bedguy /root]#

Org file New file Patch file

Page 23: Kernel Porting

23

부록 : Patch file 만들기 (con’t)

Patch 적용

-p option p1 - 첫번째 슬래쉬를 뺀 곳부터 Patch 적용 ( 보통 디렉토리

전체 ) p0 – 그 상위 디렉토리에서부터 적용 ( 파일 하나 비교 )

[root@bedguy /root]# cat hello.patch | patch -p0[root@bedguy /root]# cat hello.c#include <stdio.h>

int main(void) { printf("hello world!!!\n"); printf("hello bedguy!!!\n"); return 0; } [root@bedguy /root]#

Page 24: Kernel Porting

부록 : Link

http://www.arm.linux.org.uk/ The ARM Linux Project http://www.netwinder.org/ netwinder http://handhelds.org/ IPAQ 관련 http://www.cs.cmu.edu/~wearable/software/ The Wearable Group http://www.lart.tudelft.nl The LART Pages http://www.kelp.or.kr/ Korea Embedded Linux Project http://www.kesl.org/ Korea Embedded System og Linux http://www.huins.com/ Huins, Co. http://linux.flyduck.com/ Kernel site http://kernelkorea.org/ Linux kernel http://www.linuxro.com/ ecos porting http://pcmcia-cs.sourceforge.net/ Linux PCMCIA Information Page http://ftp.arm.linux.org.uk/ The ARM Linux Project FTP http://www.kr.ibm.com/developerworks/ 전문 강좌 http://www.freechal.com/embedded/ 임베디드 리눅스 개발자 그룹 http://www.fsf.org/ gnu homepage http://www.phystech.com/download/ server demon program