一、解压内核并修改Makefile
1)解压源码
#tar zxvf linux-2.6.39.tar.gz
2)指定交叉编译器
export KBUILD_BUILDHOST := $(SUBARCH)
ARCH ?= arm
CROSS_COMPILE ?= arm-linux-
# Architecture as present in compile.h
UTS_MACHINE := $(ARCH)
SRCARCH := $(ARCH)
二、创建目标平台
1) 从smdk6410到th6410
#cd arch/arm/mach-s3c64xx
#cp mach-smdk6410.c mach-th6410.c
#gedit mach-th6410.c
2) 修改 mach-th6410.c 文件
a)mach-th6410.c文件中的所有smdk6410改成th6410
b)在#include <linux/regulator/machine.h> 下,新增
//add
#include <linux/pwm_backlight.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
#include <plat/nand.h>
c) 添加分区、时序等在117行
(static void smdk6410_lcd_power_set(struct plat_lcd_data *pd,)前新增
/* Nand flash */
struct mtd_partition th6410_nand_part[] = {
{
.name = "Bootloader",
.offset = 0,
.size = (4 * 128 *SZ_1K),
.mask_flags = MTD_CAP_NANDFLASH,
},
{
.name = "Kernel",
.offset = (4 * 128 *SZ_1K),
.size = (5*SZ_1M) ,
.mask_flags = MTD_CAP_NANDFLASH,
},
{
.name = "File System",
.offset = MTDPART_OFS_APPEND,
.size = MTDPART_SIZ_FULL,
}
};
static struct s3c2410_nand_set th6410_nand_sets[] = {
[0] = {
.name = "nand",
.nr_chips = 1,
.nr_partitions = ARRAY_SIZE(th6410_nand_part),
.partitions = th6410_nand_part,
},
};
static struct s3c2410_platform_nand th6410_nand_info = {
.tacls = 25,
.twrph0 = 55,
.twrph1 = 40,
.nr_sets = ARRAY_SIZE(th6410_nand_sets),
.sets = th6410_nand_sets,
};
d)在370行
在static struct platform_device *th6410_devices[] __initdata中加入
#if 0
&s3c64xx_device_iisv4,
&samsung_device_keypad,
#endif
&s3c_device_nand,
e) 向内核注册信息
在798行
在static void __init th6410_machine_init(void)函数中,添加如下代码:
s3c_nand_set_platdata(& th6410_nand_info);
3) 修改mach-s3c64xx目录下的Kconfig修改如下:
在config MACH_SMDK6410下面,新增
config MACH_TH6410
bool "TH6410"
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 TH6410
4) 修改mach-s3c64xx目录下的makefile修改如下:
在obj-$(CONFIG_MACH_SMDK6410) += mach-smdk6410.o下面,新增
obj-$(CONFIG_MACH_TH6410) +=mach-th6410.o //add
三、设置机器码
打开arch/arm/tools/mach-types,修改如下
在 Mini6410 MACH_TH6410 Mini6410 2520 下面,新增
th6410 MACH_TH6410 TH6410 2520
上面的机器码必须和uboot中的设置匹配,如:
进入arch/arm/mach-s3c64xx/mach-th6410.c修改如下:
MACHINE_START(S3C6410, "SMDK6410") , 将其修改为
MACHINE_START(TH6410, "TH6410")
四、配置nand
1)从Mini6410配套内核中复制Nand相关驱动
将友善之臂提供的内核中的它们复制到刚才解压的内核的对应文件夹下
drivers/mtd/nand/s3c_nand.c
arch/arm/plat-samsung/include/plat/regs-nand.h
drivers/mtd/nand/s3c_nand_mlc.fo
drivers/mtd/nand/nand_base.c
drivers/mtd/nand/s3c_nand.c
2)然后修改drivers/mtd/nand/Kconfig
在218行新增
config MTD_NAND_S3C
tristate "NAND Flash support for S3C SoC"
depends on (ARCH_S3C64XX || ARCH_S5P64XX || ARCH_S5PC1XX)&& MTD_NAND
help
This enables the NAND flash controller on the S3C.
No board specfic support is done by this driver, eachboard
must advertise a platform_device for the driver toattach.
config MTD_NAND_S3C_DEBUG
bool "S3C NAND driver debug"
depends on MTD_NAND_S3C
help
Enable debugging of the S3C NAND driver
config MTD_NAND_S3C_HWECC
bool "S3C NAND Hardware ECC"
depends on MTD_NAND_S3C
help
Enable the use of the S3C's internal ECC generatorwhen
using NAND. Early versions of the chip have hadproblems with
incorrect ECC generation, and if using these, the defaultof
software ECC is preferable.
If you lay down a device with the hardware ECC, thenyou will
currently not be able to switch to software, as thereis no
implementation for ECC method used by the S3C
3)修改drivers/mtd/nand/Makefile文件
a) 在drivers/mtd/nand/Makefile中 20行增加
obj-$(CONFIG_MTD_NAND_S3C) += s3c_nand.o
另外,在末尾再增加
S3C_NAND_MLC_SRC = $(shell ls drivers/mtd/nand/s3c_nand_mlc.c 2>/dev/null)
ifeq ($(S3C_NAND_MLC_SRC),)
obj-$(CONFIG_MTD_NAND_S3C) += s3c_nand_mlc.fo
else
obj-$(CONFIG_MTD_NAND_S3C) += s3c_nand_mlc.o
endif
五、编译内核
1)Nand配置
# cp arch/arm/configs/s3c6400_defconfig .config
# make menuconfig
General setup --->
(-FriendlyARM) Local version - append to kernel release
[*] Automatically append version information to the version strin
[*] System V IPC
(17) Kernel log buffer size (16 => 64KB, 17 => 128KB)
-*- Control Group support --->
-*- Namespaces support --->
[*] Automatic process group scheduling
[*] Enable deprecated sysfs features to support old userspace too
[*] Enable deprecated sysfs features by default
(scripts/FriendlyARM.cpio) Initramfs source file(s)
(0)User ID to map to 0 (user root)
(0)Group ID to map to 0 (group root)
Built-in initramfs compression mode (None) --->
[*] Optimize for size
[*] Disable heap randomization
Choose SLAB allocator (SLUB (Unqueued Allocator)) --->
Kernel Features --->
[*] Use the ARM EABI to compile the kernel
[*] Allow old ABI binaries to run with this kernel (EXPERIMENTA
Device Drivers--->
<*> Memory Technology Device(MTD) support --->
[*] MTD partitioning support
[*] Command line partition table parsing
<*> Direct char device access to MTD devices
<*> Caching block device access to MTD devices
<*> NAND Device Support --->
< > NAND Flash support forSamsung S3C SoCs 去掉不要选
<*> NAND Flash support for S3C SoC
[*] S3C NAND Hardware ECC
System Type--->
-*- S3C64XX DMA
[ ] SMDK6400
[ ] A&W6410
[ ] MINI6410
[ ] REAL6410
[ ] SMDK6410
[*] TH6410
[ ] NCP
[ ] Airgoo HMT
[ ] SmartQ 5
[ ] SmartQ 7
六、增加yaffs2文件系統支持
首先下載git,然後用git下載,為內核打補丁
# yum install git-core
# git clone git://www.aleph1.co.uk/yaffs2
# cd yaffs2
# ./patch-ker.sh c m <kernel>
Filesystem--->
Miscellaneous filesystems--->
<*> yaffs2 file system support
<*> UBIFS file system support
# make zImage
七、載入內核失敗
未找到relese() 釋放函數
解决辦法:在arch/arm/plat-samsung/dev-nand.h 文件中
static struct resource s3c_nand_resource[] = {
[0] = {
.start = S3C_PA_NAND,
.end = S3C_PA_NAND + SZ_1M-1, // 给最後加上一個 “ - 1” 紅色部分
.flags = IORESOURCE_MEM,
}
}
參考網址:
http://wenku.baidu.com/view/4fcc123c376baf1ffc4fad00.htmlhttp://wenku.baidu.com/view/4fcc123c376baf1ffc4fad00.htmlhttp://blog.csdn.net/acanoe/article/details/7506594http://blog.csdn.net/muge0913/article/details/7242620http://www.aiothome.net/read.php?tid-14211.htmlhttp://blog.csdn.net/jinatom/article/details/7669219http://rritw.com/a/caozuoxitong/Linux/20120426/160506.html