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文件,增加新添加开发板的��器码

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wyjxgp.html