歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> Linux內核 >> OK6410開發板Linux內核移植

OK6410開發板Linux內核移植

日期:2017/3/1 10:41:40   编辑:Linux內核

一、環境介紹:

1、環境配置

Ø 開發板:ok6410-A

Ø 宿主機:XP-sp3下用Vmware搭建的CentOS6.0系統

注:1)、外網網卡用的NAT方式連接,用來在window客戶端用putty連接虛擬機和更新工具連上網用;

2)、第二塊兒網卡用的橋接方式,用來連接開發板;

3)、串口用來在虛擬機裡使用minicom連接開發板。

Ø 交叉工具:arm-linux-4.4.1.tar.gz

2、環境搭建結果

Minicom連接開發板:

Putty連接好虛擬機:

結束後內核能正常啟動並掛載NFS系統:

二、移植過程

1、源代碼准備

接下來開始。。哈哈 ,此過程痛並快樂著。。。准備好了麼?gogogo。。。。

更新最新源代碼,並創建新實驗分支:

[root@localhost linux-2.6]# git fetch

remote: Counting objects: 270, done.

remote: Compressing objects: 100% (117/117), done.

remote: Total 120 (delta 87), reused 0 (delta 0)

Receiving objects: 100% (120/120), 26.10 KiB, done.

Resolving deltas: 100% (87/87), completed with 54 local objects.

From git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6

371de6e..89307ba master -> origin/master

[root@localhost linux-2.6]# git status

# On branch zkf

nothing to commit (working directory clean)

[root@localhost linux-2.6]# git checkout -b test

Switched to a new branch 'test'

[root@localhost linux-2.6]# ls

arch Documentation init lib README sound

block drivers ipc MAINTAINERS REPORTING-BUGS tools

COPYING firmware Kbuild Makefile samples usr

CREDITS fs Kconfig mm scripts virt

crypto include kernel net security

[root@localhost linux-2.6]#

新添加一個說明文件,說明一下修改源代碼遵循GPL版權

[root@localhost linux-2.6]# vi ok6410_readme.txt

[root@localhost linux-2.6]# git add ok6410_readme.txt

[root@localhost linux-2.6]# git commit –a

[test 97a3a32] add note

1 files changed, 3 insertions(+), 0 deletions(-)

create mode 100644 ok6410_readme.txt

[root@localhost linux-2.6]#

2、移植過程

(1)、修改頂層makefile文件

注釋掉默認的並新添加:

export KBUILD_BUILDHOST := $(SUBARCH)

#ARCH ?= $(SUBARCH)

ARCH ?= arm

#CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%)

CROSS_COMPILE ?= arm-linux

# Architecture as present in compile.h

(2)、新增並修改板級文件

(復制現有最相近的板子的)

[root@localhost mach-s3c64xx]# ls

clock.c Kconfig mach-smartq.c setup-i2c0.c

cpu.c mach-anw6410.c mach-smartq.h setup-i2c1.c

dev-audio.c mach-crag6410.c mach-smdk6400.c setup-ide.c

dev-spi.c mach-crag6410-module.c mach-smdk6410.c setup-keypad.c

dev-uart.c mach-hmt.c Makefile setup-sdhci.c

dma.c mach-mini6410.c Makefile.boot setup-sdhci-gpio.c

include mach-ncp.c pm.c sleep.S

irq.c mach-real6410.c s3c6400.c

irq-eint.c mach-smartq5.c s3c6410.c

irq-pm.c mach-smartq7.c setup-fb-24bpp.c

[root@localhost mach-s3c64xx]# pwd

/home/linux-2.6/arch/arm/mach-s3c64xx

其中的mach-mini6410.c 板子的配置與ok6410比較相似

[root@localhost mach-s3c64xx]# cp mach-mini6410.c mach-ok6410.c

修改mach-ok6410.c

/* linux/arch/arm/mach-s3c64xx/mach-ok6410.c

將文件中所有mini6410替換為ok6410

:%s/mini6410/ok6410/g

注意需要將大寫的MINI6410也要替換掉(其中大部分都是輸出信息,有一處與機器碼有關的要更改)

MACHINE_START(MINI6410, "MINI6410")

/* Maintainer: Darius Augulis <[email protected]> */

.atag_offset = 0x100,

.init_irq = s3c6410_init_irq,

.map_io = ok6410_map_io,

.init_machine = ok6410_machine_init,

.timer = &s3c24xx_timer,

此文件中包含NAND的分區信息可以根據自己的需求修改:

/*modify by zkf

//static struct mtd_partition ok6410_nand_part[] = {

// [0] = {

// .name = "uboot",

// .size = SZ_1M,

// .offset = 0,

// },

// [1] = {

// .name = "kernel",

// .size = SZ_2M,

// .offset = SZ_1M,

// },

// [2] = {

// .name = "rootfs",

// .size = MTDPART_SIZ_FULL,

// .offset = SZ_1M + SZ_2M,

// },

//};

*/

struct mtd_partition ok6410_nand_part[] = {

{

.name = "Bootloader",

.offset = 0,

.size = (1 * SZ_1M),

.mask_flags = MTD_CAP_NANDFLASH,

},

{

.name = "Kernel",

.offset = (1 * SZ_1M),

.size = (5*SZ_1M) ,

.mask_flags = MTD_CAP_NANDFLASH,

},

{

.name = "User",

.offset = (6 * SZ_1M),

.size = (120*SZ_1M) ,

},

{

.name = "File System",

.offset = MTDPART_OFS_APPEND,

.size = MTDPART_SIZ_FULL,

}

};

/*modify by zkf end*/

修改此目錄下的Makefile 文件,使之在編譯的時候編譯我們剛才新建的“mach-ok6410”文件:

# Machine support

obj-$(CONFIG_MACH_ANW6410) += mach-anw6410.o

obj-$(CONFIG_MACH_SMDK6400) += mach-smdk6400.o

obj-$(CONFIG_MACH_SMDK6410) += mach-smdk6410.o

obj-$(CONFIG_MACH_REAL6410) += mach-real6410.o

obj-$(CONFIG_MACH_OK6410) += mach-ok6410.o

obj-$(CONFIG_MACH_MINI6410) += mach-mini6410.o

obj-$(CONFIG_MACH_NCP) += mach-ncp.o

obj-$(CONFIG_MACH_HMT) += mach-hmt.o

obj-$(CONFIG_MACH_SMARTQ) += mach-smartq.o

obj-$(CONFIG_MACH_SMARTQ5) += mach-smartq5.o

obj-$(CONFIG_MACH_SMARTQ7) += mach-smartq7.o

obj-$(CONFIG_MACH_WLF_CRAGG_6410) += mach-crag6410.o mach-crag6410-module.o

修改此目錄下的Kconfig文件:(比照其他開發板增加)

config MACH_OK6410

bool "OK6410"

select CPU_S3C6410

select S3C_DEV_HSMMC

select S3C_DEV_HSMMC1

select S3C64XX_SETUP_SDHCI

select S3C_DEV_USB_HOST

select S3C_DEV_NAND

select S3C_DEV_FB

select S3C64XX_SETUP_FB_24BPP

select SAMSUNG_DEV_ADC

select SAMSUNG_DEV_TS

help

Machine support for the FriendlyARM MINI6410

(3)、機器碼修改

修改/home/linux-2.6/arch/arm/tools目錄下mach-types文件,增加新添加開發板的機器碼

# machine_is_xxx CONFIG_xxxx MACH_TYPE_xxx number

smdk4212 MACH_SMDK4212 SMDK4212 3638

smdk4412 MACH_SMDK4412 SMDK4412 3765

ok6410 MACH_OK6410 OK6410 1216

(4)、配置內核

接下來配置內核:(如果有現成的配置文件更好啦,哈哈)

[root@localhost linux-2.6]# make menuconfig

HOSTCC scripts/basic/fixdep

HOSTCC scripts/kconfig/conf.o

*** Unable to find the ncurses libraries or the

*** required header files.

*** 'make menuconfig' requires the ncurses libraries.

***

*** Install ncurses (ncurses-devel) and try again.

***

make[1]: *** [scripts/kconfig/dochecklxdialog] 錯誤 1

make: *** [menuconfig] 錯誤 2

提示錯誤沒有安裝ncurses

[root@localhost linux-2.6]# yum –y install ncurses ncurses-devel 安裝後進入配置界面:

有耐心可以每項都看看。。。。這裡附上一個配置好的文件(cp ok6410_config .config 即可)

此時文件的修改已經結束了, 。

(5)修改文件概覽

看一下修改的文件有哪些:

[root@localhost linux-2.6]# git status

# On branch test

# Changed but not updated:

# (use "git add <file>..." to update what will be committed)

# (use "git checkout -- <file>..." to discard changes in working directory)

#

# modified: Makefile

# modified: arch/arm/mach-s3c64xx/Makefile

# modified: arch/arm/tools/mach-types

#

# Untracked files:

# (use "git add <file>..." to include in what will be committed)

#

# arch/arm/mach-s3c64xx/mach-ok6410.c

# ok6410_config

no changes added to commit (use "git add" and/or "git commit -a")

[root@localhost linux-2.6]# git add arch/arm/mach-s3c64xx/mach-ok6410.c

[root@localhost linux-2.6]# git add ok6410_config

Commit一下做一下記錄:

commit c07db86a1c7f6658958678eccb418f08bf665c6b

Author: zkaifa@VM <[email protected]>

Date: Fri Dec 30 16:22:59 2011 +0800

config is done

lala...Prepare to "make"

commit a26c6397a3446766ed6744012b4e570e185a698e

(6)、編譯內核

make zImage

三、燒寫內核

由於linux下DNW不太好用所以暫時把串口切換到windows下,使用DNW工具下載調試(大家誰有好的辦法記得通知我哦, )

1、將編譯好的zImage拷貝到windows下

2、用DNW下載內核

選擇好內核下載到板子內存中

下載完成

3、擦除NAND內核分區

4、寫入NAND

Reset一下,重啟板子。

Copyright © Linux教程網 All Rights Reserved