參考來源
http://flykof.pixnet.net/blog/post/22779966
一、核心修改
1-1、下載核心
--------------------
http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.14.1.tar.bz2
將檔案放到 /home/flykof/tmp 中
解壓縮
$ tar xvjf linux-2.6.14.1.tar.bz2
$ cd linux-2.6.14.1
1-2、修改Makefile
--------------------
修改內核根目錄下的的Makefile,指明交叉編譯器
$ vi Makefile
找到ARCH和CROSS_COMPILE,修改
ARCH ?= arm
CROSS_COMPILE ?= arm-linux-
然後設定你的PATH環境變量,使其可以找到你的交叉編譯工具鏈
$ echo $PATH
如果沒有/usr/local/arm/3.4.1/bin搜索路徑,加入下面語句在~/.bashrc中的最下面
$ vi ~/.bashrc
export PATH=/usr/local/arm/3.4.1/bin:$PATH
1-3、設定flash分區
--------------------
1-3-1、指明分區訊息
由於 samsung K9F5608U0C-YCB0 只有32M的FLASH,所以在設定時要注意到這點來做調整。
kernel 要修改成跟 vivi 一致
1、建立 Nand Flash 分區表
修改添加內容如下:
設定kernel 的分區
--------------------
$ vi arch/arm/mach-s3c2410/devs.c
#include <linux/mtd/partitions.h>
#include <linux/mtd/nand.h>
#include <asm/arch/nand.h>
...
/* NAND Controller */
static struct mtd_partition partition_info[] ={
{
name = "vivi",
size = 0x20000,
offset = 0x0,
},{
name = "param",
size = 0x10000,
offset = 0x20000,
}, {
name = "kernel",
size = 0x1d0000,
offset =0x30000,
}, {
name = "root",
size = 0x01E00000,
offset = 0x00200000,
}
};
name:代表分區名字
size:代表flash分區大小(單位︰位元組)
offset:代表flash分區的起始位址(相對於0x0的偏移)
設定vivi 的分區
--------------------
vivi的設定在arch/s3c2410/smdk.c
static struct mtd_partition partition_info[] = {
{
name = "vivi",
size = 0x00020000,
offset = 0,
}, {
name = "param",
size = 0x00010000,
offset = 0x00020000,
}, {
name = "kernel",
size = 0x001d0000,
offset = 0x00030000,
}, {
name = "root",
size = 0x01E00000,
offset = 0x00200000,
}
};
或是啟動 Bootloader 進入 vivi 使用part指令去做修改再存檔即可。
2.加入Nand Flash 分區
struct s3c2410_nand_set nandset ={
nr_partitions: 4, /* the number of partitions */
partitions: partition_info, /* partition table */
};
nr_partitions: 指明partition_info中定義的分區數目
partitions: 分區訊息表
3.建立Nand Flash芯片支持
struct s3c2410_platform_nand superlpplatform={
tacls:0,
twrph0:30,
twrph1:0,
sets: &nandset,
nr_sets: 1,
};
tacls, twrph0, twrph1 的意思,請見S3C2410手冊的63,這3個值最後會被設定到NFCONF中,見S3C2410手冊66。
sets:支援的分區集
nr_set:分區集的個數
4.加入Nand Flash晶片支援到Nand Flash驅動
另外,還要修改此檔案中的s3c_device_nand架構體變量,添加對dev成員的賦值
(此部份要注意的是只有做修改並不是添加)
struct platform_device s3c_device_nand = {
.name = "s3c2410-nand", /* Device name */
.id = -1, /* Device ID */
.num_resources = ARRAY_SIZE(s3c_nand_resource),
.resource = s3c_nand_resource, /* Nand Flash Controller Registers */
/* Add the Nand Flash device */
.dev = {
.platform_data = &superlpplatform
}
};
name:設備名稱
id:有效設備編號,如果只有唯一的一個設備為1,有多個設備從0開始計數。
num_resource:有幾個暫存器區
resource:暫存器區數組首位址
dev:支援的 Nand Flash 設備
1-3-2、kernel啟動時依據我們對分區的設定進行初始配置
修改arch/arm/mach-s3c2410/mach-smdk2410.c檔案
$ vi arch/arm/mach-s3c2410/mach-smdk2410.c
修改smdk2410_devices[].指明初始化時包括我們在前面所設定的flash分區訊息
static struct platform_device *smdk2410_devices[] __initdata = {
&s3c_device_usb,
&s3c_device_lcd,
&s3c_device_wdt,
&s3c_device_i2c,
&s3c_device_iis,
/* 添加如下語句即可 */
&s3c_device_nand,
};
儲存,退出。
1-3-3、禁止Flash ECC校驗
這裡還有一個方面要注意的,就是ECC問題,就是需要把下面設定去掉。
Device Drivers --->
Memory Technology Devices (MTD) --->
NAND Flash Device Drivers --->
[*] S3C2410 NAND Hardware ECC
不然會出現如下的問題:
end_request: I/O error, dev mtdblock3, sector 2
EXT3-fs: unable to read superblock
end_request: I/O error, dev mtdblock3, sector 0
Buffer I/O error on device mtdblock3, logical block 0
end_request: I/O error, dev mtdblock3, sector 0
Buffer I/O error on device mtdblock3, logical block 0
end_request: I/O error, dev mtdblock3, sector 8
Buffer I/O error on device mtdblock3, logical block 1
end_request: I/O error, dev mtdblock3, sector 8
Buffer I/O error on device mtdblock3, logical block 1
end_request: I/O error, dev mtdblock3, sector 16
Buffer I/O error on device mtdblock3, logical block 2
end_request: I/O error, dev mtdblock3, sector 16
Buffer I/O error on device mtdblock3, logical block 2
end_request: I/O error, dev mtdblock3, sector 24
Buffer I/O error on device mtdblock3, logical block 3
end_request: I/O error, dev mtdblock3, sector 24
Buffer I/O error on device mtdblock3, logical block 3
end_request: I/O error, dev mtdblock3, sector 0
FAT: unable to read boot sector
VFS: Cannot open root device "mtdblock3" or unknown-block(31,3)
Please append a correct "root=" boot option
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,3)
$ vi drivers/mtd/nand/s3c2410.c
另外還要在 /linux-2.6.14.1/drivers/mtd/nand/s3c_2410.c 中
將 chip->eccmode = NAND_ECC_SOFT 改為chip->eccmode = NAND_ECC_NONE;
或是
找到s3c2410_nand_init_chip()函數,在該函數體最後加上一條語句:
chip->eccmode = NAND_ECC_NONE;
1-3-4、修改低級錯誤
$ vi include/linux/mtd/partitions.h
在partitions.h最前面加上#include <linux/list.h>
1-3-5、修改CMDLINE
這一部分其實並不需要作,但如果有出現啟動kernel時,是因為cmd line出問題才需要做修改
$ vi arch/arm/kernel/setup.c
將其中parse_tag_cmdline()函數中的strlcpy()函數註解掉
1-4、配置核心
1-4-1、支援啟動時掛載devfs
為了我們的內核支援devfs以及在啟動時並在/sbin/init營運之前能自動掛載/dev為devfs檔案系統,
修改fs/Kconfig檔案
$ vi fs/Kconfig
找到 menu "Pseudo filesystems"
添加如下語句︰
config DEVFS_FS
bool "/dev file system support (OBSOLETE)"
default y
config DEVFS_MOUNT
bool "Automatically mount at boot"
default y
depends on DEVFS_FS
1-4-2、配置核心產生.config檔
這一部分也可以等到進入menuconfig中再去load 即可
$ cp arch/arm/configs/smdk2410_defconfig .config
$ make mrproper #命令清除所有的舊的配置和舊的編譯目標檔等。
$ make menuconfig #在選單模式下對內核進行配置。
Load an Al terrnate Configuration File a
輸入 arch/arm/configs/smdk2410_defconfig
按下OK
Loadable module support a
[*] Enable loadable module support
[*] Automatic kernel module loading
System Type a
[*] S3C2410 DMA support
Boot options a
Default kernel command string:
noinitrd root=/dev/mtdblock3 init=/linuxrc console=ttySAC0,115200
#說明︰mtdblock3代表我的第4個flash分區,它是我的rootfs
# console=ttySAC0,115200使kernel啟動期間的訊息全部輸出到串口0上.
# 2.6內核對於串口的命名改為ttySAC0,但這不影響用戶空間的串口編程。
# 用戶空間的串口編程針對的仍是/dev/ttyS0等
Floating point emulation a
[*] NWFPE math emulation
This is necessary to run most binaries!!!
#接下來要做的是對內核MTD子系統的設定
Device Drivers a
Memory Technology Devices (MTD) a
[*] MTD partitioning support
#支援MTD分區,這樣我們在前面設定的分區才有意義
[*] Command line partition table parsing
#支援從命令行設定flash分區訊息,靈活
RAM/ROM/Flash chip drivers a
<*> Detect flash chips by Common Flash Interface (CFI) probe
<*> Detect non-CFI AMD/JEDEC-compatible flash chips
<*> Support for Intel/Sharp flash chips
<*> Support for AMD/Fujitsu flash chips
<*> Support for ROM chips in bus mapping
NAND Flash Device Drivers a
<*> NAND Device Support
<*> NAND Flash support for S3C2410/S3C2440 SoC
Character devices a
[*] Non-standard serial port support
[*] S3C2410 RTC Driver
Device Drivers a
Network device support a
Ethernet (10 or 100 Mbit) a
〔*〕 CS8900 support.
Graphics support a
S3C2410 LCD frambuffer support
#接下來做的是針對檔案系統的設定,本人實驗時目標板上要上的檔案系統是cramfs,故做如下配置
File systems a
<> Second extended fs support #去除對ext2的支援
Pseudo filesystems a
[*] /proc file system support
[*] Virtual memory file system support (former shm fs)
[*] /dev file system support (OBSOLETE)
[*] Automatically mount at boot (NEW)
#這裡會看到我們前先修改fs/Kconfig的成果,devfs已經被支援上了
Miscellaneous filesystemsa
<*> Compressed ROM file system support (cramfs)
#支援cramfs
Network File Systems a
<*> NFS file system support
儲存退出,產生.config檔案.
.config檔案能從提供的2.6.14.1的內核包中找到,檔案名為config.back。
1-5、編譯kernel
$ make zImage
留言列表