CAFE

강의실 - 이창우님

리눅스 커널포팅 하기 (삼성ARM용)-linux-2.6.23.8

작성자이창우|작성시간07.11.21|조회수899 목록 댓글 3

리눅스 커널포팅 하기 (삼성ARM)

 

작성 이   

 

가장 최신버전의 커널을 받습니다 (www.kernel.org)

이 문서를 작성할 때의 최신버전은 2.6.23.8 입니다(2007년11월20)

 

일단 커널의 압축을 풀어야겠죠

tar –jxvf linux-2.6.23.8.tar.bz2

cd linux-2.6.23.8

제일먼저 Makefile 을 고칩니다

vi Makefile

EXTRAVERSION = .8 EXTRAVERSION = .8.hl2irw-sjb2440 로 고쳤습니다 일단은 흔적을 남겨야겠죠 나중 uname –a 하시면 보여지는 내용이니.

182라인쯤 보시면

ARCH                               ?= $(SUBARCH)

CROSS_COMPILE            ?=

이것을

ARCH                               ?= arm

CROSS_COMPILE            ?= arm-linux-

아키텍쳐는 arm 으로 컴파일러는 arm-linux-gcc 를 사용하라는 내용입니다 저의 경우는

gcc version 4.1.0 을 사용하였습니다(크로스컴파일러 문서참조)

 

다음은 vi arch/arm/tools/mach-types 을 열어 제일 마지막 라인에

mx_uc7420         MACH_MX_UC7420           MX_UC7420                      1361  <- 마지막라인

sjb2440               MACH_SJB2440                SJB2440                           1362

머신 번호를 1362로 추가합니다.

 

다음은 vi /arch/arm/kernel/head.S 스타트업 코드를 열어서

ENTRY(stext)

#ifdef CONFIG_MACH_SJB2440

        ldr     r1, =1362;

#endif

             msr       cpsr_c, #PSR_F_BIT | PSR_I_BIT | SVC_MODE @ ensure svc mode

제가 만들어 사용하는 부트로더 에는 이 기능이 없어 여기에 추가했는데 사용하는 부트로더에 이 기능이 있다면 없어도 됩니다.

참고로 bl      __lookup_machine_type 여기서 체크 합니다.

 

이번커널은 삼성CPU경우 종류별로 분리되어 있습니다

mach-s3c2400,

mach-s3c2410,

mach-s3c2412,

mach-s3c2440,

mach-s3c2442,

mach-s3c2443

모두에게 적용되는 공통부분은 다음의 디렉토리에 있습니다.

plat-s3c

plat-s3c24xx

 

다음은 커널설정 시 메뉴에 내가 추가한 것이 나와야 하겠죠 Kconfig를 수정합니다.

vi arch/arm/mach-s3c2440/Kconfig

중간쯤 다음을 추가

config MACH_SJB2440

        bool "SJB samsung s3c2440"

        select CPU_S3C2440

        help

          Say Y here if you are using the SJB244X

          mail to: papercrane100@daum.net

          <http://www.armstudy.org>.

 

Endmenu

이번엔 vi arch/arm/mach-s3c2440/Makefile 컴파일 할 것을 지정 합니다

(정리하면 Kconfig 항목추가, Makefile 에 할일 추가, 소스작성 순이겠죠)

obj-$(CONFIG_MACH_NEXCODER_2440) += mach-nexcoder.o

obj-$(CONFIG_MACH_SJB2440)     += mach-sjb2440.o   <- 추가

 

cd arch/arm/mach-s3c2440 적당한 파일을 하나 골라 카피, 수정하면 편합니다.

저는 mach-sjb2440.c 라고 만들기로 하였습니다.

다른 부분, 없는 부분 등을 추가하면 됩니다.

먼저 메모리영역부터 설정

static struct map_desc sjb2440_iodesc[] __initdata = {

        {

                .virtual        = (u32)S3C_ADDR(0x03100000),

                .pfn            = __phys_to_pfn(S3C2410_CS1),

                .length         = SZ_1M,

                .type           = MT_DEVICE,

        }, {

                .virtual        = (u32)S3C_ADDR(0x03200000),

                .pfn            = __phys_to_pfn(S3C2410_CS2),

                .length         = SZ_1M,

                .type           = MT_DEVICE,

        }, {

                .virtual        = (u32)S3C_ADDR(0x03300000),

                .pfn            = __phys_to_pfn(S3C2410_CS3),

                .length         = SZ_1M,

                .type           = MT_DEVICE,

        }, {

                .virtual        = (u32)S3C_ADDR(0x03400000),

                .pfn            = __phys_to_pfn(S3C2410_CS4),

                .length         = SZ_1M,

                .type           = MT_DEVICE,

        }, {

                .virtual        = (u32)S3C_ADDR(0x03500000),

                .pfn            = __phys_to_pfn(S3C2410_CS5),

                .length         = SZ_1M,

                .type           = MT_DEVICE,

        }

};

다음은 네트웍 추가

static struct resource smc91x_eth_resources[] = {

        [0] = {

                .name   = "smc91x-regs",

                .start  = (0x10000300),

                .end    = (0x100fffff),

                .flags  = IORESOURCE_MEM,

        },

        [1] = {

                .start  = IRQ_EINT0,

                .end    = IRQ_EINT0,

                .flags  = IORESOURCE_IRQ,

        },

        [2] = {

                .name   = "smc91x-attrib",

                .start  = (0x14000000),

                .end    = (0x140fffff),

                .flags  = IORESOURCE_MEM,

        },

};

 

static struct platform_device smc91x_eth_device = {

        .name           = "smc91x",

        .id             = -1,

        .num_resources  = ARRAY_SIZE(smc91x_eth_resources),

        .resource       = smc91x_eth_resources,

};

 

/* LED devices */

 

static struct s3c24xx_led_platdata sjb_pdata_led1 = {

        .gpio           = S3C2410_GPB7,

        .flags          = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE,

        .name           = "led1",

        .def_trigger    = "timer",

};

 

static struct s3c24xx_led_platdata sjb_pdata_led2 = {

        .gpio           = S3C2410_GPH0,

        .flags          = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE,

        .name           = "led2",

        .def_trigger    = "system",

};

 

static struct platform_device sjb2440_led1 = {

        .name           = "s3c24xx_led",

        .id             = 0,

        .dev            = {

                .platform_data = &sjb_pdata_led1,

        },

};

 

static struct platform_device sjb2440_led2 = {

        .name           = "s3c24xx_led",

        .id             = 1,

        .dev            = {

                .platform_data = &sjb_pdata_led2,

        },

};

이런 식으로 USB,MMC,TOUTCH,LCD 추가 합니다(가끔 다른 소스파일을 참조하면됩니다)

사용할 플랫폼 디바이스 드라이버를 등록 해야합니다.

static struct platform_device *sjb2440_devices[] __initdata = {

        &s3c_device_usb,

        &s3c_device_lcd,

        &s3c_device_bl,

        &s3c_device_wdt,

        &s3c_device_i2c,

        &s3c_device_iis,

        &s3c_device_sdi,

        &s3c_device_usbgadget,

        &s3c_device_ts,

        &s3c_device_nand,

        &smc91x_eth_device,

        &sjb2440_led1,

        &sjb2440_led2,

};

포트 초기화도 해주시면 좋겠죠

void sjb_port_init(void)

{

        /* Configure the LEDs (even if we have no LED support)*/

        s3c2410_gpio_cfgpin(S3C2410_GPB7, S3C2410_GPB7_OUTP);  //led1

        s3c2410_gpio_cfgpin(S3C2410_GPH0, S3C2410_GPH0_OUTP);  //led2

        s3c2410_gpio_cfgpin(S3C2410_GPG9, S3C2410_GPH0_INP);   //UDC DET

        s3c2410_gpio_cfgpin(S3C2410_GPG10, S3C2410_GPH0_INP);  //SMC DET

        s3c2410_gpio_cfgpin(S3C2410_GPH1, S3C2410_GPH1_OUTP);  //IOENAB

        s3c2410_gpio_cfgpin(S3C2410_GPG4, S3C2410_GPG4_OUTP);  //UDC ON

        s3c2410_gpio_cfgpin(S3C2410_GPH8, S3C2410_GPH8_OUTP);  //USB ON

        s3c2410_gpio_setpin(S3C2410_GPB7, 1);

        s3c2410_gpio_setpin(S3C2410_GPH0, 1);

        s3c2410_gpio_setpin(S3C2410_GPH1, 1);

        s3c2410_gpio_setpin(S3C2410_GPG4, 1);

        s3c2410_gpio_setpin(S3C2410_GPH8, 1);

}

마지막으로 SJB2440 이름으로 mach-types 에 등록한 이름을 사용 합니다

MACHINE_START(SJB2440, "sjb2440 Lee,Chang-Woo hl2irw@armstudy.org")

             .phys_io             = S3C2410_PA_UART,

             .io_pg_offst         = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,

             .boot_params     = S3C2410_SDRAM_PA + 0x100,

 

arch/arm/plat-s3c24xx/devs.c 에 없는 장치의 리소스를 추가 합니다

arch/arm/plat-s3c24xx/s3c244x.c 에서

static struct map_desc s3c244x_iodesc[] __initdata = {

             IODESC_ENT(CLKPWR),

             IODESC_ENT(TIMER),

             IODESC_ENT(WATCHDOG),

        // 추가 항목

        IODESC_ENT(LCD),

        IODESC_ENT(ADC),

        IODESC_ENT(USBHOST),

        IODESC_ENT(USBDEV),

        IODESC_ENT(DMA),

        IODESC_ENT(IIC),

        IODESC_ENT(IIS),

        IODESC_ENT(RTC),

        IODESC_ENT(SPI),

             IODESC_ENT(NAND),

        IODESC_ENT(SDI),

};

헤더화일을 수정 합니다

헤더화일의 디렉토리 역시 나뉘어져 있죠

include/asm/arch

include/asm/plat-s3c

include/asm/plat-s3c24xx

 

먼저 plat-s3c/map.h 에서 아직 정의되지 않은 장치의 가상주소를 추가,

arch/map.h 에 정의되지 않은 가상주소를 선언해 줍니다.

또한 lcd.h, mmc.h, ts.h 등등 플랫폼관련 헤더화일을 만들어 줍니다

헤더화일 중 주소가 없는 것도 있으니 수정해 줍니다

#define S3C2410_LCDREG(x)        (x)

#define S3C2410_LCDREG(x)        ((x) + S3C24XX_VA_LCD)  <- 이런식으로

 

이제부터는 드라이버를 수정합니다 이전버전 소스 중 일부분만 수정하면 대부분

사용 가능합니다

순서는 Kconfig 추가, Makefile 추가, 소스추가 및 수정 입니다

Touchscreen, mmc(sd), nand, network, usb host/device, fb, backlight, sound 등등

필요한 장치드라이버를 추가 하였습니다.

 

이제는 커널 설정할 차례입니다

이전 버전에 설정한 내용과 비교해 가면서 하나하나 추가해 갑니다 물론 Kconfig에 추가한 항목들이 제대로 나타나야 합니다

디폴트 커멘드라인 옵션은 저의경우

"mem=128M root=/dev/ram rw console=ttyS0,115200n81 initrd=0x30600000,12M"

 

이제는 컴파일을 해봐야 겠죠

make zImage 로 컴파일 합니다

중간에 컴파일 에라가 나면 그 부분을 수정 합니다(물론 될때까지 해야겠죠)

 

테스트 해봅니다

 

cp arch/arm/boot/zImage /tftpboot

 

 

 

 

부트로더 에서

[S3C2440-SMC:/]$

[S3C2440-SMC:/]$tftp zImage 0x31000000                <- 부트로더서 커널로드

 

 TFTP from Server :192.168.0.210 Client address is 192.168.0.202

 Filename      : zImage

 Load Address  : 0x31000000

 

[S3C2440-SMC:/]$ tftp -> Start

***********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************

 0x001deed4 (1961684) bytes received.

 tftp done.

 

[S3C2440-SMC:/]$tftp ramdisk4.gz 0x30600000            <- 램디스크 로드

 

 TFTP from Server :192.168.0.210 Client address is 192.168.0.202

 Filename      : ramdisk4.gz

 Load Address  : 0x30600000

 

[S3C2440-SMC:/]$ tftp -> Start

**********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************

 0x004a2657 (4859479) bytes received.

 tftp done.

 

[S3C2440-SMC:/]$run 0x31000000                           <- 실행

 Jump 0x31000000

Uncompressing Linux............................................................................................................................. done, booting the kernel.

Linux version 2.6.23.8.hl2irw-sjb2440 (hl2irw@linux.nexcon.com) (gcc version 4.1.0) #27 PREEMPT Wed Nov 21 11:25:16 KST 2007

CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177

Machine: sjb2440 Lee,Chang-Woo hl2irw@armstudy.org

Warning: bad configuration page, trying to continue

Memory policy: ECC disabled, Data cache writeback

CPU S3C2440A (id 0x32440001)

S3C244X: core 427.593 MHz, memory 106.898 MHz, peripheral 53.449 MHz

S3C24XX Clocks, (c) 2004 Simtec Electronics

CLOCK: Slow mode (2.116 MHz), fast, MPLL on, UPLL on

CPU0: D VIVT write-back cache

CPU0: I cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets

CPU0: D cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets

Built 1 zonelists in Zone order.  Total pages: 32512

Kernel command line: mem=128M root=/dev/ram rw console=ttyS0,115200n81 initrd=0x30600000,12M

irq: clearing subpending status 00000012

PID hash table entries: 512 (order: 9, 2048 bytes)

timer tcon=00599909, tcnt adfc, tcfg 0000021f,00001111, usec 00001cbd

Console: colour dummy device 80x30

console [ttyS0] enabled

Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)

Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)

Memory: 128MB = 128MB total

Memory: 113536KB available (3492K code, 442K data, 124K init)

Mount-cache hash table entries: 512

CPU: Testing write buffer coherency: ok

NET: Registered protocol family 16

S3C2440: Initialising architecture

S3C2440: IRQ Support

S3C2440: Clock Support, DVS off

S3C24XX DMA Driver, (c) 2003-2004,2006 Simtec Electronics

DMA channel 0 at c8800000, irq 33

DMA channel 1 at c8800040, irq 34

DMA channel 2 at c8800080, irq 35

DMA channel 3 at c88000c0, irq 36

SCSI subsystem initialized

usbcore: registered new interface driver usbfs

usbcore: registered new interface driver hub

usbcore: registered new device driver usb

NET: Registered protocol family 2

IP route cache hash table entries: 1024 (order: 0, 4096 bytes)

TCP established hash table entries: 4096 (order: 3, 32768 bytes)

TCP bind hash table entries: 4096 (order: 2, 16384 bytes)

TCP: Hash tables configured (established 4096 bind 4096)

TCP reno registered

checking if image is initramfs...it isn't (no cpio magic); looks like an initrd

Freeing initrd memory: 12288K

NetWinder Floating Point Emulator V0.97 (double precision)

NTFS driver 2.1.28 [Flags: R/W].

io scheduler noop registered

io scheduler anticipatory registered (default)

io scheduler deadline registered

io scheduler cfq registered

fb0: s3c2410fb frame buffer device

s3c2440-uart.0: s3c2410_serial0 at MMIO 0x50000000 (irq = 70) is a S3C2440

s3c2440-uart.1: s3c2410_serial1 at MMIO 0x50004000 (irq = 73) is a S3C2440

s3c2440-uart.2: s3c2410_serial2 at MMIO 0x50008000 (irq = 76) is a S3C2440

RAMDISK driver initialized: 16 RAM disks of 16384K size 1024 blocksize

loop: module loaded

nbd: registered device at major 43

smc91x.c: v1.1, sep 22 2004 by Nicolas Pitre <nico@cam.org>

eth0: SMC91C11xFD (rev 2) at c8802300 IRQ 16 [nowait]

eth0: Ethernet addr: 00:0c:22:38:4e:44

usbcore: registered new interface driver catc

drivers/net/usb/catc.c: v2.8 CATC EL1210A NetMate USB Ethernet driver

usbcore: registered new interface driver kaweth

pegasus: v0.6.14 (2006/09/27), Pegasus/Pegasus II USB Ethernet driver

usbcore: registered new interface driver pegasus

drivers/net/usb/rtl8150.c: rtl8150 based usb-ethernet driver v0.6.2 (2004/08/27)

usbcore: registered new interface driver rtl8150

usbcore: registered new interface driver asix

usbcore: registered new interface driver cdc_ether

usbcore: registered new interface driver net1080

usbcore: registered new interface driver cdc_subset

usbcore: registered new interface driver zaurus

usbcore: registered new interface driver zd1211rw

usbcore: registered new interface driver zd1201

usbcore: registered new interface driver rtl8187

Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2

ide: Assuming 50MHz system bus speed for PIO modes; override with idebus=xx

aoe: AoE v32 initialised.

usbmon: debugfs is not available

s3c2410-ohci s3c2410-ohci: S3C24XX OHCI

s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1

s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000

usb usb1: configuration #1 chosen from 1 choice

hub 1-0:1.0: USB hub found

hub 1-0:1.0: 2 ports detected

Initializing USB Mass Storage driver...

usbcore: registered new interface driver usb-storage

USB Mass Storage support registered.

s3c2410_udc: debugfs dir creation failed -19

s3c2440-usbgadget s3c2440-usbgadget: S3C2440: increasing FIFO to 128 bytes

gadgetfs: USB Gadget filesystem, version 24 Aug 2004

mice: PS/2 mouse device common for all mice

s3c2410 TouchScreen successfully loaded

input: s3c2410 TouchScreen as /class/input/input0

S3C24XX RTC, (c) 2004,2006 Simtec Electronics

i2c /dev entries driver

s3c2440-i2c s3c2440-i2c: slave address 0x10

s3c2440-i2c s3c2440-i2c: bus frequency set to 371 KHz

s3c2440-i2c s3c2440-i2c: i2c-0: S3C I2C adapter

S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics

s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled

mmci-s3c2410: probe: mapped sdi_base=c9400000 irq=37 irq_cd=64

mmci-s3c2410: initialisation done.

Registered led device: led1

Registered led device: led2

usbcore: registered new interface driver usbhid

drivers/hid/usbhid/hid-core.c: v2.6:USB HID core driver

Pclk :  53.449200 MHz hl2irw

mapped channel 0 to 0

mapped channel 1 to 1

TCP cubic registered

NET: Registered protocol family 1

ieee80211: 802.11 data/management/control stack, git-1.1.13

ieee80211: Copyright (C) 2004-2005 Intel Corporation <jketreno@linux.intel.com>

drivers/rtc/hctosys.c: unable to open rtc device (rtc0)

RAMDISK: Compressed image found at block 0

VFS: Mounted root (ext2 filesystem).

Freeing init memory: 124K

INIT: version 2.86 booting

Auto-creating modules directory.

Not calculating module dependencies.

Loading modules from /etc/modules:

Checking all file systems...

fsck 1.35 (28-Feb-2004)

Setting kernel variables ...

... done.

Mounting local filesystems...

Cleaning /var/run.

Cleaning: /etc/network/ifstate.

Setting up IP spoofing protection: rp_filter.

Cleaning.

 

Setting the System Clock using the Hardware Clock as reference...

hwclock: Could not access RTC: No such file or directory

System Clock set. Local time: Wed Dec 31 19:00:15 EST 1969

 

Initializing random number generator...done.

Recovering nvi editor sessions... done.

INIT: Entering runlevel: 3

Starting system log daemon: syslogd.

Starting kernel log daemon: klogd.

Starting portmap daemon: portmap.

Starting OpenBSD Secure Shell server: sshd.

Starting periodic command scheduler: cron.

 

SJB-S3C2440-hl2irw

 

SJB-S3C2440 login: root

Password:

Linux SJB-S3C2440 2.6.23.8.hl2irw-sjb2440 #27 PREEMPT Wed Nov 21 11:25:16 KST 2007 armv4tl unknown

  ***************************************************

  *  SJB-S3C2440 HL2IRW   (kernel2.6.xx – gcc4.1.x) *

  *   Lee Chang-woo HL2IRW (hl2irw@armstudy.org)    *

  ***************************************************

 

SJB-S3C2440:~# ifconfig eth0 192.168.0.222

eth0: link down

SJB-S3C2440:~# eth0: link up, 100Mbps, full-duplex, lpa 0x45E1

 

SJB-S3C2440:~# mount -n 192.168.0.210:/nfs /mnt/nfs/ -o nolock,tcp

 

SJB-S3C2414:~#splay /mnt/nfs/hl2irw/05.Romance\ \(Composed\ By\ Yuhki\ Kuramoto\ \).mp3

 

다음검색
현재 게시글 추가 기능 열기

댓글

댓글 리스트
  • 작성자Yacc | 작성시간 07.11.21 ^^ 감사합니다. ^^ 많은 분들께 전체 흐름 잡는데 많은 도움이 될 것이라 믿어 의심치 않습니다. ^^ 더불어.... s3c6400 칩 릴리즈 일정이 늦어지네요... -_- 대리점에서 구할려면 언제가 될지 가물가물 합니다. -_- OTL.... 요즘 지상파 DMB 되는 PMP가 메리테크에서 9.9만원에도 팔던데.. 혹시나 기구 구할데가 있을지 몰겠습니다. ^^
  • 작성자대가리 | 작성시간 07.11.21 멋니네요... 근데 부트로더를 사적으로 만든건가요?
  • 작성자블루윙스 | 작성시간 13.10.24 55개의 오픈 라이브 CASINO 테이블 24시간 동시운영!
    현재ㄱㅏ입시 3만원지급, 365일 연중무휴 24시간 친절 콜상담!
    매일 쏟아지는 대박이벤트 많이참여하세요.
    바로가기 ⓜ ⓔ ⓚ ⑦ ⑧ 점 ⒞ ⒪ ⒨
댓글 전체보기
맨위로

카페 검색

카페 검색어 입력폼