OK6410开发板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 <augulis.darius@gmail.com> */

        .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 <zkaifa@163.com>

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一下,重启板子。

  • 1
  • 2
  • 下一页

相关内容