2012年(1008)
分类:
2012-08-01 11:39:55
原文地址:TX2440 内核移植 准备移植 作者:luozhiyong131
嵌入式学习入门 http://blog.chinaunix.net/u3/117680/showart.php?id=2300212
, 文章——>嵌入式学习入门 全面的讲述学习嵌入式linux中的每个步骤
内核版本:
Linux-2.6.31
交叉编译器版本:
arm-linux-gcc 4.3.2
操作系统平台:
Linux -- Red Hat 9.0
开发板平台:
RAM——TX2440A
一> 准备移植
获得内核源码:
Linux-2.6.31.tar.bz2 可到官方网站获得最新版本的内核源码
解压源码,进入目录:
#tar xjvf linux-2.6.31.bz2
#cd linux-2.6.31
修改 Makefile: 183行:
ARCH ?= arm 指定系统硬件架构
CROSS_COMPILE ?= arm-linux- 指定交叉编译器
修改时钟:
修改arch/arm/mach-s3c2440/mach-smdk2440.c 163行
static void __init smdk2440_map_io(void)
{
s3c24xx_init_io(smdk2440_iodesc, ARRAY_SIZE(smdk2440_iodesc));
s3c24xx_init_clocks(12000000); 输入时钟为12MHz
s3c24xx_init_uarts(smdk2440_uartcfgs, ARRAY_SIZE(smdk2440_uartcfgs));
}
这个一定要设置对,否则会打印出乱码。
修改机器码(根据实际情况,这个要和bootloader的匹配):
修改:arch/arm/tools/mach-types 379行:
s3c2440 ……………………… XXX 后面那个数就是机器码
(参考 http://blog.chinaunix.net/u3/117680/showart_2294492.html)
配置:
#make menuconfig 进入图形化配置界面
在配置菜单中选择这一项:”Load an Alternate Configuration File”
输入2440的默认配置文件:arch/arm/configs/s3c2410_defconfig
说明:这个文件就是S3C24XX系列开发板的板级支持包(BSP)
然后选择OK,按回车
进入”System Type”选项单,里面的选项保持默认
在”S3C24XX Machine”选项中只配置这几项(其他的选项取消):
#make menuconfig
首先加载s3c24xx系列的通用配置,然后在此基础上修改
各配置选项如下。这里只列出了要修改的项,其他的默认
在编译时系统启动最后可能会出现这个错误:
Kernel panic - not syncing: Attempted to kill init!
然后出打印出一些很乱的东西。
因为用4.X.X版本的交叉编译器使用EABI,但内核默认是不支持EABI编译的,所以编译出的系统会报错,但用3.X.X版本的编译器就不会出现这个问题。
解决办法是,配置内核支持EABI编译
Kernel Features --->
[*] Use the ARM EABI to compile the kernel
[*] Allow old ABI binaries to run with this kernel (EXPERIMENTA)
配置完后,回到主菜单,选择这一项“Save an Alternate Configuration File”输入要保存的配置文件名称:.config (默认)
退出,编译内核: #make zImage
说明:以后移植过程中的配置、编译,都是按这个步骤进行,但是只需要保存一次配置文件,以后就不需要再保存配置文件了,配置完后可以直接退出。
编译完后,会在arch/arm/boot下生成zImage内核镜像文件
可以修改该目录下的Makefile: 在第57行下面添加:
@cp –f arch/arm/boot/zImage zImage
@echo ` Kernel: $@ is ready`
这样执行make zImage后,就把生成的zImage拷到内核根目录下
如果希望在在执行make distclean时,也同时把zImage删除,
可以修改内核源码目录下Makefile的第1247行,在后面加上:
-type f –print | xargs rm –f rm zImage
把zImage镜像烧进NandFlash跑一下,看是否正常打印出信息
可以参考linux下tftp使用方法
http://blog.chinaunix.net/u3/117680/showart.php?id=2295231
如果第一步能正常引导内核,那就开始进行第二步,添加NAND驱动
修改:arch/arm/plat-s3c24xx/common-smdk.c文件,在第110行:
这里我们要使nandflash支持256M容量。
/* NAND parititon from
static struct mtd_partition smdk_default_nand_part[] = {
[0] = {
.name = "Boot",
.size = SZ_
.offset = 0,
},
[1] = {
.name = "Kernel",
.offset = MTDPART_OFS_APPEND,
.size = SZ_
},
[2] = {
.name = "yaffs2",
.offset = MTDPART_OFS_APPEND,
.size = MTDPART_SIZ_FULL,
},
};
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c24xx-nand s3c2440-nand: Tacls=1, 10ns Twrph0=3 30ns, Twrph1=1 10ns
s3c24xx-nand s3c2440-nand: NAND hardware ECC
NAND device: Manufacturer ID: 0xec, Chip ID: 0xda (Samsung NAND 256MiB 3,3V 8-bit)
Scanning device for bad blocks
Creating 3 MTD partitions on "NAND 256MiB 3,3V 8-bit":
0x000000000000-0x000000100000 : "boot"
0x000000120000-0x000000520000 : "kernel"
0x000000520000-0x000010000000 : "yaffs2"
支持yaffs2文件系统
下载yaffs2源码
|
解压,进入yaffs2目录:
#tar xzvf yaffs2.tar.gz
#cd cvs/yaffs2/
给内核打上yaffs2文件系统的补丁,执行:
#./patch-ker.sh c /………/linux-
这时内核源码fs目录下多了一个yaffs2目录,同时Makefile文件和Kconfig文件也增加了yaffs2的配置和编译条件。
配置对yaffs2支持:
这部分配置的比较多,可根据自己的需要进行配置,把不用的文件系统都去掉,
下面配置:
3. 配置内核,使其对yaffs2文件系统的支持。配置完后重新编译内核,下载到开发板上
File systems --->
< > Second extended fs support
< > Ext3 journalling file system support
< > The Extended 4 (ext4) filesystem
< > Reiserfs support
< > JFS filesystem support
< > XFS filesystem support
< > OCFS2 file system support
< > Btrfs filesystem (EXPERIMENTAL) Unstable disk format
[*] Enable POSIX file locking API
[*] Dnotify support
[*] Inotify file change notification support
[*] Inotify support for userspace
[ ] Quota support
Caches --->
CD-ROM/DVD Filesystems --->
<*> ISO 9660 CDROM file system support
[ ] Microsoft Joliet CDROM extensions
[ ] Transparent decompression extension
< > UDF file system support
DOS/FAT/NT Filesystems --->
<*> MSDOS fs support
<*> VFAT (Windows-95) fs support
(437) Default codepage for FAT
(iso8859-1) Default iocharset for FAT
< > NTFS file system support
Pseudo filesystems --->
[*] Miscellaneous filesystems --->
--- Miscellaneous filesystems
< > ADFS file system support (EXPERIMENTAL)
< > Amiga FFS file system support (EXPERIMENTAL)
< > Apple Macintosh file system support (EXPERIMENTAL)
< > Apple Extended HFS file system support
< > BeOS file system (BeFS) support (read only) (EXPERIMENTAL)
< > BFS file system support (EXPERIMENTAL)
< > EFS file system support (read only) (EXPERIMENTAL)
<*> YAFFS2 file system support
-*- 512 byte / page devices
[ ] Use older-style on-NAND data format with pageStatus byte
[ ] Lets Yaffs do its own ECC
-*- 2048 byte (or larger) / page devices
[*] Autoselect yaffs2 format
[ ] Disable lazy loading
[ ] Turn off wide tnodes
[ ] Force chunk erase check
[*] Cache short names in RAM
<*> Journalling Flash File System v2 (JFFS2) support
(0) JFFS2 debugging verbosity (0 = quiet, 2 = noisy)
[*] JFFS2 write-buffering support
[ ] Verify JFFS2 write-buffer reads
[*] JFFS2 summary support (EXPERIMENTAL)
[ ] JFFS2 XATTR support (EXPERIMENTAL)
[ ] Advanced compression options for JFFS2
<*> Compressed ROM file system support (cramfs)
[ ] Additional option for memory-constrained systems
< > FreeVxFS file system support (VERITAS VxFS(TM) compatible)
< > Minix file system support
< > SonicBlue Optimized MPEG File System support
< > OS/2 HPFS file system support
< > QNX4 file system support (read only)
<*> ROM file system support
RomFS backing stores (Block device-backed ROM file system support) --
< > System V/Xenix/V7/Coherent file system support
< > UFS file system support (read only)
< > NILFS2 file system support (EXPERIMENTAL)
[*] Network File Systems --->
Partition Types --->
-*- Native language support --->
< > Distributed Lock Manager (DLM) --->
Native Language support --->
(iso8859-1) Default NLS Option
<*> Codepage 437(United States, Canada)
<*> Simplified Chinese charset(CP936, GB2312)
<*> NLS ISO8859-1 (Latin 1; Western European Language)
<*> NLS UTF-8
说明:现在内核已经支持NandFlash和yaffs2文件系统,将内核烧入NandFlash后,再烧入yaffs2文件系统,可以使用制作好的文件系统,也可以自己制作,详细的制作文件系统方法,请查看下篇
启动时(成功挂载文件系统)输出:
yaffs: dev is 32505858 name is "mtdblock2"
yaffs: passed flags ""
yaffs: Attempting MTD mount on 31.2, "mtdblock2"
yaffs: auto selecting yaffs2
yaffs_read_super: isCheckpointed 0
VFS: Mounted root (yaffs filesystem) on device 31:2.
Freeing init memory: 196K