全部博文(30)
分类: LINUX
2011-12-29 09:38:08
Author: eilian
Blog: http://blog.csdn.net/eilianlau
Copyright:Original
Date: 2011、12、13
1、Hosting environment:VMare ubuntu10.04
2、Cross-compiling environment:arm-2009q3.tar.bz2
3、Development board:QT6410
4、nanflash:K9F2G08(256M)
5、linux -version:Linux-2.6.39
6、uboot-version:u-boot-2010.06一、下载并解压内核源码
a)在命令行终端中可以通过下列方式下载,当然用其它下载工具下载
root@bootloader:/home/eilian/development/Android#cd ../Linux
root@bootloader:/home/eilian/development/Linux# wget
b)解压源码
root@bootloader:/home/eilian/development/Linux#
root@bootloader:/home/eilian/development/Linux# tar zxvf linux-2.6.39.tar.gz
root@bootloader:/home/eilian/development/Linux# ls
linux-2.6.32.2 linux-2.6.39
linux-2.6.36.2 linux-2.6.39.tar.bz2
linux-2.6.36.2.tar.gz linux-2.6.39.tar.gz
root@bootloader:/home/eilian/development/Linux# cd linux-2.6.39
root@bootloader:/home/eilian/development/Linux/linux-2.6.39#
c)指定交叉编译器
移植目的让 Linux-2.6.39 可以在QT6410 上运行。首先,使得Linux-2.6.39的缺省目标平台成为ARM 的平台,修改主目录下的Makefile。
用vi打开Makefile,定位到196行,修改如下:
root@bootloader:/home/eilian/development/Linux/linux-2.6.39# vi Makefile
# Default value for CROSS_COMPILE is not to prefix executables
# Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile
export KBUILD_BUILDHOST := $(SUBARCH)
ARCH ?= arm
CROSS_COMPILE ?= arm-linux-
# Architecture as present in compile.h
UTS_MACHINE := $(ARCH)
SRCARCH := $(ARCH)
修改完成后退出保存
二、创建目标平台
从smdk6410到qt6410
root@bootloader:/home/eilian/development/Linux/linux-2.6.39#cd arch/arm/mach-s3c64xx
root@bootloader:/home/eilian/development/Linux/linux-2.6.39/arch/arm/mach-s3c64xx#cp mach-smdk6410.c mach-qt6410.c
将mach-mach-qt6410.c文件中的所有smdk6410改成qt6410
root@bootloader:/home/eilian/development/Linux/linux-2.6.39/arch/arm/mach-s3c64xx#vi mach-qt6410.c
修改mach-s3c64xx目录下的Makefile和Kconfig 修改如下:
Kconfig:添加如下红色代码
config MACH_SMDK6410
bool "SMDK6410"
select CPU_S3C6410
select SAMSUNG_DEV_ADC
select S3C_DEV_HSMMC
select S3C_DEV_HSMMC1
select S3C_DEV_I2C1
select SAMSUNG_DEV_IDE
select S3C_DEV_FB
select S3C_DEV_RTC
select SAMSUNG_DEV_TS
select S3C_DEV_USB_HOST
select S3C_DEV_USB_HSOTG
select S3C_DEV_WDT
select SAMSUNG_DEV_KEYPAD
select SAMSUNG_DEV_PWM
select HAVE_S3C2410_WATCHDOG if WATCHDOG
select S3C64XX_SETUP_SDHCI
select S3C64XX_SETUP_I2C1
select S3C64XX_SETUP_IDE
select S3C64XX_SETUP_FB_24BPP
select S3C64XX_SETUP_KEYPAD
help
Machine support for the Samsung SMDK6410
config MACH_QT6410
bool "QT6410"
select CPU_S3C6410
select SAMSUNG_DEV_ADC
select S3C_DEV_HSMMC
select S3C_DEV_HSMMC1
select S3C_DEV_I2C1
select SAMSUNG_DEV_IDE
select S3C_DEV_FB
select S3C_DEV_RTC
select SAMSUNG_DEV_TS
select S3C_DEV_USB_HOST
select S3C_DEV_USB_HSOTG
select S3C_DEV_WDT
select SAMSUNG_DEV_KEYPAD
select SAMSUNG_DEV_PWM
select HAVE_S3C2410_WATCHDOG if WATCHDOG
select S3C64XX_SETUP_SDHCI
select S3C64XX_SETUP_I2C1
select S3C64XX_SETUP_IDE
select S3C64XX_SETUP_FB_24BPP
select S3C64XX_SETUP_KEYPAD
help
Machine support for the Samsung QT6410
Makefile:添加如下红色代码
obj-$(CONFIG_MACH_ANW6410) += mach-anw6410.o
obj-$(CONFIG_MACH_SMDK6400) += mach-smdk6400.o
obj-$(CONFIG_MACH_SMDK6410) += mach-smdk6410.o
obj-$(CONFIG_MACH_QT6410) += mach-qt6410.o
obj-$(CONFIG_MACH_REAL6410) += mach-real6410.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
三、About machine Number
打开arch/arm/tools/mach-types文件定位到217行左右,修改如下
at91sam9g20ek MACH_AT91SAM9G20EK AT91SAM9G20EK 1624
qt6410 MACH_QT6410 QT6410 1626
u300 MACH_U300 U300 1627
这需要两者相匹配,如果内核的机器码和bootloader 传入的不匹配,就会经常出现下面的错误:
Uncompressing
Linux.................................................................................................................................
done, booting
the kernel. 不动了
接着修改linux-2.6.39/arch/arm/mach-s3c64xx/qt6410.c定位到文件末尾处
四、配置、编译测试
root@bootloader:/home/eilian/development/Linux/linux-2.6.39#cp arch/arm/configs/s3c6400_defconfig .config
root@bootloader:/home/eilian/development/Linux/linux-2.6.39#make menuconfig
出现下图所示内核配置根菜单
设置完后退出
root@bootloader:/home/eilian/development/Linux/linux-2.6.39#make uImage
等待若干久后出现
SYSMAP .tmp_System.map
OBJCOPY arch/arm/boot/Image
Kernel: arch/arm/boot/Image is ready
AS arch/arm/boot/compressed/head.o
GZIP arch/arm/boot/compressed/piggy.gzip
AS arch/arm/boot/compressed/piggy.gzip.o
CC arch/arm/boot/compressed/misc.o
CC arch/arm/boot/compressed/decompress.o
SHIPPED arch/arm/boot/compressed/lib1funcs.S
AS arch/arm/boot/compressed/lib1funcs.o
LD arch/arm/boot/compressed/vmlinux
OBJCOPY arch/arm/boot/zImage
Kernel: arch/arm/boot/zImage is ready
UIMAGE arch/arm/boot/uImage
Image Name: Linux-2.6.39
Created: Mon Dec 12 20:29:35 2011
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 1266444 Bytes = 1236.76 kB = 1.21 MB
Load Address: 50008000
Entry Point: 50008000
Image arch/arm/boot/uImage is ready
root@bootloader:/home/eilian/development/Linux/linux-2.6.39#cparch/arm/boot/uImage
/tftpboot/
给开发板上电(开发板已烧入uboot)打开超级终端