2.6.14 内核移植说明文档
5(g)内核操作Linux2.6内核驱动移植参考
内核操作Linux2.6内核驱动移植参考随着Linux2.6的发布,由于2.6内核做了教的改动,各个设备的驱动程序在不同程度上要进行改写。
为了方便各位Linux爱好者我把自己整理的这分文档share出来。
该文当列举了2.6内核同以前版本的绝大多数变化,可惜的是由于时间和精力有限没有详细列出各个函数的用法。
特别声明:该文档中的内容来自,该网也上也有各个函数的较为详细的说明可供各位参考。
1、使用新的入口必须包含<linux/init.h>module_init(your_init_func);module_exit(your_exit_func);老版本:int init_module(void);void cleanup_module(voi);2.4中两种都可以用,对如后面的入口函数不必要显示包含任何头文件。
2、GPLMODULE_LICENSE("Dual BSD/GPL");老版本:MODULE_LICENSE("GPL");3、模块参数必须显式包含<linux/moduleparam.h>module_param(name, type, perm);module_param_named(name, value, type, perm);参数定义module_param_string(name, string, len, perm);module_param_array(name, type, num, perm);老版本:MODULE_PARM(variable,type);MODULE_PARM_DESC(variable,type);4、模块别名MODULE_ALIAS("alias-name");这是新增的,在老版本中需在/etc/modules.conf配置,现在在代码中就可以实现。
5、模块计数int try_module_get(&module);module_put();老版本:MOD_INC_USE_COUNT 和MOD_DEC_USE_COUNT6、符号导出只有显示的导出符号才能被其他模块使用,默认不导出所有的符号,不必使用EXPORT_NO_SYMBOLS老板本:默认导出所有的符号,除非使用EXPORT_NO_SYMBOLS7、内核版本检查需要在多个文件中包含<linux/module.h>时,不必定义__NO_VERSION__老版本:在多个文件中包含<linux/module.h>时,除在主文件外的其他文件中必须定义__NO_VERSION__,防止版本重复定义。
内核(2.6.14) + 根文件系统 + Qt4 移植 for S3C2410
内核(2.6.14) + 根文件系统+ Qt4 移植for S3C2410/*********************************************************/LarryChan 阿牛哥(亮) QQ:85307887chenliang_43@ /mimimomoll2008.5.7. 桂林电子科技大学正平科技馆机器人中心衷心感谢所有对本文有所帮助的人。
本文仅供交流,无意侵权/*********************************************************/TARGETCPU: S3C2410XSDRAM: HY57V561620(32MB) × 2FLASH: K9F1208(64MB)NET: CS8900HOSTLinux Realse Version: Fecora Core 6CrossCompiler: gcc-4.1.1/arm-linux-gcc-3.4.1一、内核移植(2.6.14)1 修改linux2.6.14下面的makefile文件找到ARCH和CROSS_COMPILE,修改ARCH ?= armCROSS_COMPILE ?= /usr/local/arm/3.4.1/bin/arm-linux- (此处为你交叉编译的路径)2 设置flash分区在arch/arm/machs3c2410/devs.c文件中添加头文件#include <linux/mtd/partitions.h>#include <linux/mtd/nand.h>#include <asm/arch/nand.h>然后建立分区表/* 一个Nand Flash总共64MB, 按如下大小进行分区分区大小自己看着办*/static struct mtd_partition partition_info[] ={{ /* 1MB */name: "bootloader",size: 0x00100000,offset: 0x0,},{ /* 3MB */name: "kernel",size: 0x00300000,offset: 0x00100000,}, { /* 40MB */name: "root",size: 0x02800000,offset: 0x00400000,}, { /* 20MB */name: "user",size: 0x00f00000,offset: 0x02d00000,}};/*加入Nand Flash分区*/struct s3c2410_nand_set nandset ={nr_partitions: 4, /*指明partition_info中定义的分区数目*/partitions: partition_info, /* partition table分区信息表*/};/*建立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:分区集的个数/*加入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 Re gisters *//* Add the Nand Flash device */.dev = {.platform_data = &superlpplatform}};指定启动时初始化arch/arm/machs-3c2410/mach-smdk2410.c文件找到platform_device *smdk2410_devices[] __initdata函数,在该函数体最后加上一条语句:&s3c_device_nand,禁用禁止Flash ECC校验(有不同说法)修改drivers/mtd/nand/s3c2410.c找到chip->eccmode = NAND_ECC_SOFT;改为chip->eccmode = NAND_ECC_NONE;支持启动挂载devfs修改fs/Kconfig文件找到menu "Pseudo filesystems" 添加config DEVFS_FSbool "/dev file system support (OBSOLETE)"default yconfig DEVFS_MOUNTbool "Automatically mount at boot"default ydepends on DEVFS_FS3 Yaffs2文件系统支持下载yaffs2.tar.gz源码包,解压源码,并进入目录执行#./patch-ker.sh c /linux-2.6.14.1/注:假定内核源码在/linux-2.6.14.1/4 编译配置内核,首先先load一个默认的内核/linux-2.6.14/arch/arm/ configs/smdk2410_defconfig,在这个配置文件上改Loadable module support >[*] Enable loadable module support[*] Automatic kernel module loadingSystem Type >[*] S3C2410 DMA supportBoot options >Default kernel command string:noinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySAC0, 115200Floating point emulation >[*] NWFPE math emulationDevice Drivers >Memory Technology Devices (MTD) >[*] MTD partitioning support#支持MTD分区,这样我们在前面设置的分区才有意义[*] Command line partition table parsing#支持从命令行设置flash分区信息,灵活RAM/ROM/Flash chip drivers ><*> Detect flash chips by Common Flash Interface (C FI) probe<*> Detect nonCFI AMD/JEDECcompatible flash chips<*> Support for Intel/Sharp flash chips<*> Support for AMD/Fujitsu flash chips<*> Support for ROM chips in bus mappingNAND Flash Device Drivers ><*> NAND Device Support<*> NAND Flash support for S3C2410/S3C2440 SoCCharacter devices >[*] Nonstandard serial port support[*] S3C2410 RTC DriverFile systems ><> Second extended fs support #去除对ext2的支持Pseudo filesystems >[*] /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 filesystems ><*> Compressed ROM file system support (cramfs) #支持c ramfs<*> YAFFS2 file system support #支持y affs2Network File Systems ><*> NFS file system support二、CS8900网卡驱动的移植1 cs8900.c和cs8900.h放到/drivers/net/arm/2 在cs8900.c中的cs8900_probe()函数中,memset (&priv,0,sizeof (c s8900_t));函数之后添加如下两条语句:__raw_writel(0x2211d110,S3C2410_BWSCON);__raw_writel(0x1f7c,S3C2410_BANKCON3);添加头文件#include <asm/arch/regs-mem.h>3 修改drivers/net/arm/目录下的Kconfig文件,在最后添加如下内容:config ARM_CS8900tristate "CS8900 support"depends on NET_ETHERNET && ARM && ARCH_SMDK2410help4 修改drivers/net/arm/目录下的Makefile文件,在最后添加如下内容:obj-$(CONFIG_ARM_CS8900) += cs8900.o5 在/arch/arm/mach-s3c2410/mach-smdk2410.c文件中,找到smdk2410_ iodesc[]结构数组,添加如下如下内容:{vSMDK2410_ETH_IO, 0x19000000, SZ _1M, MT_DEVICE}添加头文件#inlcude <asm/arch/smdk2410.h>其实这个就是下面的那个头文件的链接/include/asm-arm/arch-s3c2410/s mdk2410.h6 在include/asm-arm/arch-s3c2410/目录下创建smdk2410.h文件,其内容为:#ifndef _INCLUDE_SMDK2410_H_#define _INCLUDE_SMDK2410_H_#include <linux/config.h>#define pSMDK2410_ETH_IO 0x19000000#define vSMDK2410_ETH_IO 0xE0000000#define SMDK2410_ETH_IRQ IRQ_EINT9#endif // _INCLUDE_SMDK2410_H_7 编译内核,选中所装驱动#make menuconfigDevice Drivers >Network device support --->Ethernet (10 or 100Mbit) --->[*]Ethernet (10 or 100Mbit)<*>CS8900 support三、LCD驱动移植1 在arch/arm/mach-s3c2410/mach-smdk2410.c中添加//lcd#include <asm/arch/regs-lcd.h>#include <asm/arch-s3c2410/fb.h>//-------------------------------------------lcdstatic struct s3c2410fb_mach_info s3c2410_lcd_info __initdata = { .fixed_syncs = 0,.regs = {//对于寄存器的设置是关键,可参考S3C2410X的手册//和LCD技术手册中对于LCD技术指标的描述来进行设置。
Linux内核移植指导书
Linux内核移植实验指导书实验目的:完成linux2.6.14内核向ARM平台的移植和剪裁实验内容分为以下几个步骤:1、准备实验环境,包括:安装VMware Tools,准备源码文件。
2、修改环境变量,对flash进行分区,将分区信息加入内核源码,指定启动时的设备初始化,3、下载Yaffs2,解压Yaffs2并将其加入Linux内核,修改Makefile,4、配置内核产生.config文件,然后编译:make zImage ,5、修改、创建根文件系统,所需设备:PC + VMWare + linux操作系统实验要求本次实验要求提交实训报告,可简要描述实验步骤,重点描述本人在实训过程中遇到的问题和解决的方法。
实验步骤由老师提供所需要的工具安装包、内核源码和实训指导书,各位同学根据文档逐步配置编译,实训内容包括:安装vmware tools、搭建交叉编译环境、修改内核源码、Makefile的改写、内核配置裁减、编译调试等。
1.安装vmware虚拟机,安装vmware tools2.修改内核源码,修改环境变量,将分区信息加入内核源码,指定启动时的设备初始化3.安装Yaffs2,解压Yaffs2并将其加入Linux内核,修改Makefile4.配置内核产生.config文件,然后编译系统内核所需设备:PC+linux操作系统1、准备工作需要以下工具和文件:●在PC机D盘建立目录“vmshare”,将上述文件拷贝到“vmshare”目录下,然后安装vmware虚拟机和vmware tools●启动linux后,配置虚拟机与winxp的文件共享,PC机上的共享目录是e盘下的vmshare目录,linux下的共享目录是/mnt/hgfs/vmshare2、展开源码在本步骤中,展开源码,并设置环境变量mkdir /home/armlinux //创建工作目录cp /mnt/hgfs/vmshare/* /home/armlinux //把所有源码拷贝到工作目录下cd / //回到根目录tar -jxvf /home/armlinux/arm-linux-gcc-3.4.1.tar.bz2 //展开交叉编译工具cd /home/armlinux //回到工作目录下tar -jxvf linux-2.6.14.tar.bz2 //展开内核源码建立环境变量、修改Makefile将交叉编译工具路径和内核源码路径加入环境变量。
Linux2.6内核移植
Linux2.6内核移植7.1移植概念在同一个硬件平台上可以嵌入不同的嵌入式操作系统,就好比PC可以安装Windows又可以安装 Linux一样。
同样,有些操作系统通过移植后可以运行在不同的硬件平台上。
如果一个系统可以在不同硬件平台上运行,那么这个系统就是可移植的。
使用某一个平台的代码运行在其他平台上的过程叫做移植。
本书使用的Linux操作系统就可以通过移植,使之运行在ARM、PowerPC等多种硬件平台上。
为什么要进行移植?在Linux系统内核代码中有arch目录,其中包含了不同平台的代码,arch目录中的代码就是为多平台设计并使用的。
我们知道,嵌入式系统是“硬件可裁剪”的,因些工程师们设计的硬件电路会有所不同,从而这些代码可能无法正确运行,我们必须要做的就是结合自己的硬件电路,对已有的内核代码进行修改移植。
7.2移植前的知识7.2.1 去除依赖关系命令说明通常要运行的第一个命令是:#cd /usr/src/linux;make mrproper该命令确保源代码目录下没有不正确的.o文件以及文件的互相依赖7.2.2 配置命令说明配置内核可以根据需要与爱好使用下面命令中的一个:#make config(基于文本的最为传统的配置界面,不推荐使用)#make menuconfig(基于文本选单的配置界面,字符终端下推荐使用) #make xconfig(基于图形窗口模式的配置界面,Xwindow下推荐使用) #make oldconfig(如果只想在原来内核配置的基础上修改一些小地方,会省去不少麻烦)这三个命令中,make xconfig的界面最为友好,如果你可以使用Xwindow,那么就推荐你使用这个命令。
与编译有关的命令有如下几个:#make dep#make clean#make zImage#make bzImage#make modules#make modules_install#depmod -a第一个命令make dep实际上读取配置过程生成的配置文件,来创建对应于配置的依赖关系树,从而决定哪些需要编译而那些不需要;第二命令make clean完成删除前面步骤留下的文件,以避免出现一些错误;第三个命令make zImage和第四个命令make bzImage实现完全编译内核,二者生成的内核都是使用gzip压缩的,只要使用一个就够了,它们的区别在于使用make bzImage可以生成大一点的内核。
linux 2.6内核+根文件系统的移植实验
linux 2.6内核的移植实验概述:对于嵌入式linux系统来说,有各种体系结构的处理器和硬件平台,用户根据自己的需要定制的硬件平台,只要是硬件平台有一点点变化,就需要做一些移植工作,linux内核移植是嵌入式linux系统中最常见的一项工作。
由于linux内核具备可移植性的特点,并且已经支持了很多种目标板,这样,用户很容易从中找到跟自己硬件平台类似的目标板,参考内核已经支持的目标板来进行移植工作。
linux-2.6内核已经支持S3C2410处理器的多种硬件板,我们可以参考SMDK2410参考板来移植开发板的内核。
实验步骤:(1)准备工作(2)修改顶层Makefile(3)添加分区(4)添加devfs(5)配置编译内核一、准备工作建立工作目录,下载源码,安装交叉工具链,步骤如下。
mkdir /root/build_kernelcd /root/build_kernelwget -c /pub/linux/kernel/v2.6/linux2.6.14.1.tar.bz2tar jxvf linux2.6.14.1.tar.bz2export PATH=/usr/local/arm/3.3.2/binPATH二、修改顶层Makefile修改内核目录树根下的的Makefile,指明体系结构是arm,交叉编译工具是arm-linux-。
vi Makefile找到ARCH和CROSS_COMPILE,修改ARCH ?= armCROSS_COMPILE ?= arm-linux-保存退出。
三、设置flash分区此处一共要修改3个文件,分别是:arch/arm/mach-s3c2410/devs.c ;指明分区信息arch/arm/mach-s3c2410/mach-smdk2410.c ;指定启动时初始化drivers/mtd/nand/s3c2410.c ;禁止Flash ECC校验3.1指明分区信息在arch/arm/mach-s3c2410/devs.c文件中:vi arch/arm/mach-s3c2410/devs.c在arch/arm/mach-s3c2410/devs.c文件添加的内容包括:(1)添加包含头文件。
第8章 基于ARM的Linux内核移植
(2)编译测试参考板的Linux内核 为了测试Linux对参考板的支持情况,最好配置编 译Linux内核,在目标参考板上运行测试一下。 对于交叉开发来说,首先应在顶层Makefile中设置 ARCH、CROSS_COMPILE和EXTRA_VERSION 变量,然后才能选择配置指定的体系结构平台。 ARM平台的例子如下 ARCH := arm CROSS_COMPILE := arm-linuxEXTRA_VERSION :=
8.1.2 开发板内核移植 对于内核移植工作来说,主要是添加开发板初始 化和驱动程序的代码。这部分代码大部分跟体系 结构相关,在arch目录下按照不同的体系结构管理 ,下面以ARM S3C2410平台为例,分析内核代码 移植过程。 Linux2.6内核已经支持S3C2410处理器的多种硬件 板,我们可以参考SMDK2410参考板,来移植开 发板的内核
真正系统平台号的定义位置在arch/arm/tools/mach-types 文件。 #machine_is_xx CONFIG_xx MACH_TYPE_xx number smd2410 ARCH_SMDK2410 SMDK2410 193 arch/arm/tools/mach-types中每一行定义一个系统平台号 。“machine_is_xxx”是用来判断当前的平台号名称 ;CONFIG_xxxx是在内核配置时生成的; MACH_TYPE_xxx是系统平台号的定义;number是系 统平台的值。
#include/asm/mach/arch.h
#define MACHINE_START(_type,_name) const struct machine_desc _mach_desc_##_type \ _attribute_((_section_(“.init”))) = { \ .nr = MACH_TYPE_##_type,\ .name = name, … #define MACHINE_END };
移植内核
1.移植内核的准备工作(1)使用的环境操作系统:Fedora 10交叉编译工具使用:arm-linux-gcc-4.3.2(2)获取内核获取内核的网址是:/pub/linux/kernel/有很多方式可以获取 Linux 内核源代码,如果你的Fedora10 平台可以上互联网,可以直接在命令行输入以下命令获取到最原汁原味的 Linux-2.6.32.2:#wget /pub/linux/kernel/v2.6/linux-2.6.32.2.t ar.gz当然你也可以先在 Windows 系统下使用迅雷等工具下载完,再复制到Fedora10中。
(3)交叉编译工具交叉编译工具使用友善之臂的arm-linux-gcc-4.3.2,他们提供的编译器是符合EAB I标准的编译器。
其中关于EABI的介绍可以参看下面:1。
什么是ABIABI,application binary interface (ABI),应用程序二进制接口。
既然是接口,那就是某两种东西之间的沟通桥梁,此处有这些种情况:A。
应用程序<-> 操作系统;B。
应用程序<-> (应用程序所用到的)库C 。
应用程序各个组件之间类似于API的作用是使得程序的代码间的兼容,ABI目的是使得程序的二进制(级别)的兼容。
2。
什么是OABI 和EABIOABI中的O,表示“Old”,“Lagacy”,旧的,过时的,OABI就是旧的/老的ABI。
EABI中的E,表示“Embedded”,是一种新的ABI。
EABI有时候也叫做GNU EABI。
OABI和EABI都是专门针对ARM的CPU来说的。
3。
EABI的好处/为何要用EABIA。
支持软件浮点和硬件实现浮点功能混用B。
系统调用的效率更高C。
后今后的工具更兼容D。
软件浮点的情况下,EABI的软件浮点的效率要比OABI高很多。
4。
OABI和EABI的区别两种ABI在如下方面有区别:A。
调用规则(包括参数如何传递及如何获得返回值)B。
linux2.6内核裁剪说明
Linux内核裁剪与移植内核,即操作系统。
它为底层的可编程部件提供服务,为上层应用程序提供执行环境。
内核裁剪就是对这些功能进行裁剪,选取满足特定平台和需求的功能。
不同的硬件平台对内核要求也不同,因此从一个平台到另一个平台需要对内核进行重新配置和编译。
操作系统从一个平台过渡到另一个平台称为移植。
Linux是一款平台适应性且容易裁剪的操作系统,因此Linux在嵌入式系统得到了广泛的应用。
本章将详细讲解内核裁剪与移植的各项技术。
4.1 Linux内核结构Linux内核采用模块化设计,并且各个模块源码以文件目录的形式存放,在对内核的裁剪和编译时非常方便。
下面介绍内核的主要部分及其文件目录。
4.1.1 内核的主要组成部分在第1章中已经介绍了Linux内核主要的5个部分:进程调度、内存管理、虚拟文件系统、网络接口、进程通信。
在系统移植的时候,它们是内核的基本元素,这5个部分之间的关系,如图4.1所示。
图4.1 Linux内核子系统及其之间的关系进程调度部分负责控制进程对CPU的访问。
内存管理允许多个进程安全地共享主内存区域。
内存管理从逻辑上分为硬件无关部分和硬件相关部分。
硬件无关部分提供了进程的映射和逻辑内存的对换;硬件相关部分为内存管理硬件提供了虚拟接口。
虚拟文件系统隐藏了不同类型硬件的具体细节,为所有的硬件设备提供了一个标准的接口,VFS提供了十多种不同类型的文件系统。
网络接口提供了对各种网络标准的存取和各种网络硬件的支持。
进程通信部分用于支持进程间各种不同的通信机制。
进程调度处于核心位置,内核的其他子系统都要依赖它,因为每个子系统都存在进程挂起或恢复过程。
* 进程调度与内存管理之间的关系:这两个子系统为互相依赖关系。
在多道程序环境下,程序要运行必须为之创建进程,而创建进程首先就是要将程序和数据装入内存。
另外,内存管理子系统也存在进程的挂起和恢复过程。
* 进程间通信与内存管理之间的关系:进程间通信子系统要依赖内存管理支持共享内存通信机制,通过对共同的内存区域进行操作来达到通信的目的。
Linux-2.6.24内核移植文档
Linux内核移植文档V3.0edaworld整理【Target DevBoard】Board: FS2410CPU: S3C2410XSDRAM: HY57V561620(64MB)FLASH: K9F1208(64MB)NET: CS8900【HOST PC】Linux Realse Version: Fedora Core 7 (FC7)CrossCompiler: arm-linux-gcc3.4.1 with softfloat第一部分:移植内核及NAND分区【移植步骤】1. 解压linux-2.6.24。
2. 编辑Makefile,修改目标cpu体系结构和交叉编译工具的路径。
[root @localhost linux-2.6.24]$ gedit Makefile第193行改为:ARCH ?= armCROSS_COMPILE ?= /usr/local/arm/3.4.1/bin/arm-linux-CROSS_COMPILE根据自己所使用的交叉编译器路径设置。
3. 复制编译配置文件到linux-2.6.24下面。
移植过程以smdk2410开发板为模板。
[root @localhostlinux-2.6.24]$cp arch/arm/configs/s3c2410_defconfig .config4. 修改NandFlash分区信息。
[root @localhostlinux-2.6.24]$gedit arch/arm/plat-s3c24xx/common-smdk.c 第108行smdk_default_nand_part[]修改如下:static struct mtd_partition smdk_default_nand_part[] = {[0] = {.name="BootLoader",.size=0x60000,.offset=0,},[1] = {.name="Kernel",.size=(0x200000-0x60000),.offset=0x60000,},[2] = {.name="RootFile",.size=62 * SZ_1M ,.offset=SZ_2M,// mask_flags: MTD_WRITEABLE,}};这里面修改成了三个分区,分别是bootloader,kernel和roogfilesystem分区。
第八章 Linux内核配置系统及Linux2.6内核移植实例
规则。
用户通过make %config配置后,产生顶层目录的.config文 件。顶层Makefile读入 .config中的配置选项而编译内核。 顶层 Makefile 有两个主要的任务: 产生vmlinux文件(驻留内存的内核映象) 产生内核模块(module) 为了实现这两个任务,顶层Makefile递归地进入到内核的各个 子目录中,分别调用位于这些子目录中的Makefile(取决于内核的 配置)进行编译。 如在顶层Makefile中的语句: include arch/$(ARCH)/Makefile,包含了特定 CPU 体系结构下 的 Makefile,这个 Makefile 中包含了CPU平台相关的信息。
CORE_FILES对应内核的核心文件,有 kernel/kernel.o, mm/mm.o,fs/fs.o,ipc/ipc.o,这些是组成内核最为重要的文 件。 同时,arch/arm/Makefile 对 CORE_FILES 进行了扩充:
# arch/arm/Makefile # If we have a machine-specific directory, then include it in the build. MACHDIR := arch/arm/mach-$(MACHINE) ifeq ($(MACHDIR),$(wildcard $(MACHDIR))) SUBDIRS += $(MACHDIR) CORE_FILES := $(MACHDIR)/$(MACHINE).o $(CORE_FILES) endif HEAD := arch/arm/kernel/head-$(PROCESSOR).o \ arch/arm/kernel/init_task.o SUBDIRS += arch/arm/kernel arch/arm/mm arch/arm/lib arch/arm/nwfpe CORE_FILES := arch/arm/kernel/kernel.o arch/arm/mm/mm.o $(CORE_FILES) LIBS := arch/arm/lib/lib.a $(LIBS)
linux内核2.6
越来越多的Linuxer开始对尚处在测试中的2.6内核产生了兴趣,确实它非常具有吸引力,众多的特性让人眼花潦乱。
我也从2.4全面转到了2.6内核之下,享受着新特性带来的新鲜体验。
不过不少兄弟在编译新内核时或多或少的遇到了一些问题,看来新娘的盖头也不是那么容易揭开的:)因此我打算写一些文章来介绍编译新内核时的一些应该注意的地方,以减少兄弟们在编译新内核时的麻烦。
由于我的水平十分有限,写这样的文章实在是勉为其难。
文中肯定有错误疏失之处,还请兄弟们多多包涵:)第一部分,准备:要使用新的内核首先当然要取得新内核的源码,内核的官方网站是 在上面可以得到最新的内核。
2.6的更新是相当快的,你可以在命令行下使用finger @命令来快速得到当前最新的内核列表。
在这篇文章中我将以2.6.0-test6为准。
下载了内核源码之后,我们要使用tar jxvf linux-2.6.0-test6.tar.bz2来提取源码,如果你下载的是以tgz结尾的压缩包就使用zxvf参数来解压。
我强烈建议你不要使用/usr/src/linux这个目录来存放源码,因为使用这个目录你需要手工在/usr/include目录下作一些符号链接,这实在不是一个好主意。
所以我建议你为源码单独建一个目录,这里我们的目录是/src/linux-2.6.0-test6。
要编译与正常运行新的内核你需要升级一些软件包,这些信息在源码目录下的Documentation/Changes 文件中,请根据你的实际情况选择升级。
这其中我强调一下你应该升级Module-Init-Tools,不要被你当前系统中depmod -V输出的版本号迷惑(在RH9中它的输出是2.4.22,感觉好象要比Changes中所要求的要高,实际上它们使用不同的版本规则)。
新的Module-Init-Tools在下面的网址中取得:/pub/linux/kernel/people/rusty/modules/我使用的是0.9.14。
Linux2.6内核配置详解
7.
[*] Automatic kernel module loading
复制代码
Enable loadable module support,很多人喜欢将全部功能、硬件支持一股脑的编 进内核,而不是使用模块的方式。这样做非常不好(个
人觉得)。其实我也做过嵌入式的开发,在针 对特定硬件的平台下尽可能将内核编小,将始终是支持 模块加载的。例如我们开发的防火墙就是做为内核的模 块被加载的。使用模块支持,你的系统能具有更好的可 扩充性。还有一个原因就是自己编写的功能模块、设备 驱动模块(假设编写的质量不高)以模块方式工作引起
2.
[*] Enable loadable module support
3.
[*] Module unloading
4.
[]
Forced module unloading
5.
[*] Module versioning support
(EXPERIMENTAL)
6.
[ ] Source checksum for all modules
Support for hot-pluggable devices:是否支持热插拔 的选项,肯定要选上。不然 USB、PCMCIA 等这些设备都
用不了。
Kernel Userspace Events:内核中分为系统区和用户区, 这里系统区和用户区进行通讯的一种方式,选上。
Kernel .config support:将.config 配置信息保存在 内核中,选上它及它的子项使得其它用户能从/proc 中 得到内核的配置。还记得另一篇贴子我是如何取得启动 光盘的内核配置信息,并在此基础上配置新的内核吗?
microcode support
linux移植过程手册
一、移植环境主机:VMWare-Ubuntu开发板:TOP6410, Kernel:2.6.36.2编译器:arm-linux-gcc-4.3.2.tgz二、源码获得内核源码到/下载;三、移植步骤:1.将Linux2.6.34.2内核源码放到工作目录文件夹下,并解压。
#tar xzvf linux2.6.36.2.tar.gz –c /#pwd/# cd linux2.6.36.22. 修改内核源码根目录下的Makefile文件(CROSS_COMPILE =的值因个人情况而定,其他可以照做,蓝色部分为修改部分。
)#geditMakefile......#SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \# -e s/arm.*/arm/ -e s/sa110/arm/ \# -e s/s390x/s390/ -e s/parisc64/parisc/ \# -e s/ppc.*/powerpc/ -e s/mips.*/mips/ )......#ARCH ?= $(SUBARCH)#CROSS_COMPILE ?=ARCH = armCROSS_COMPILE = /usr/local/arm/usr/local/arm/4.3.2/bin/arm-none-linux- gnueabi-3添加NandFlash分区信息.修改arch/arm/mach-s3c64xx/mach-smdk6410.c文件,添加Nand Flash的分区信息和Nand Flash的硬件信息。
(蓝色字体为添加部分)#pwd#gedit mach-smdk6410.c //add here 注意:此处的nandflash分区信息是内核设置,由于此处要用到uboot一致,所以分区信息也要按uboot的来添加头文件#include <plat/nand.h>#include <linux/mtd/partitions.h>#include <mtd/mtd-abi.h>#include <asm/mach/flash.h>structmtd_partition s3c_partition_info[] = {{.name = "Bootloader",.offset = 0,.size = (256*SZ_1K),.mask_flags =MTD_CAP_NANDFLASH,},{.name = "Kernel",.offset = (256*SZ_1K),.size = (4*SZ_1M) - (256*SZ_1K),.mask_flags = MTD_CAP_NANDFLASH,},#if defined (CONFIG_SPLIT_ROOT_FILESYSTEM){.name = "Rootfs",.offset = (4*SZ_1M),.size = (80*SZ_1M),//},#endif{.name = "File System",.offset = MTDPART_OFS_APPEND,.size = MTDPART_SIZ_FULL,}};staticstruct s3c2410_nand_set s3c_nandset[]={[0]= {.name ="s3c24xx-nand",.nr_chips = 1,.nr_partitions =ARRAY_SIZE(s3c_partition_info),.partitions =s3c_partition_info,}};staticstruct s3c2410_platform_nand s3c_platform={.tacls =25,.twrph0 =55,.sets = &s3c_nandset,.nr_sets =ARRAY_SIZE(s3c_nandset),};//add here…static structplatform_device *smdk6410_devices[] __initdata = { #ifdef CONFIG_SMDK6410_SD_CH0&s3c_device_hsmmc0,#endif#ifdef CONFIG_SMDK6410_SD_CH1&s3c_device_hsmmc1,#endif&s3c_device_i2c0,&s3c_device_i2c1,&s3c_device_fb,&s3c_device_ohci,&s3c_device_usb_hsotg,&s3c64xx_device_iisv4,//add here&s3c_device_nand,//add here…}static void __init smdk6410_map_io(void){u32tmp;//add heres3c_device_ = "s3c6410-nand";//add here……}static void __init smdk6410_machine_init(void){u32 cs1;s3c_i2c0_set_platdata(NULL);s3c_i2c1_set_platdata(NULL);s3c_fb_set_platdata(&smdk6410_lcd_pdata);//add heres3c_nand_set_platdata(&s3c_platform);////add here…}5.配置内核。
内核实验2、Linux2.6内核移植实验
一、 实验目的
移植 Linux2.6 内核到开发板,其它硬件资源驱动可以暂时不考虑 Samsung S3C2440A
Nand flash
Samsung K9D1208V0M 64M
RAM
64M
软件资源
cross toolchain 3.4.1
bootloader
<*>Support for AMD/Fujitsu flash chip <*>Support for ROM chip in bus mapping NAND Flash Device Drivers--->
................................ <*>NAND Device Support <*>NAND Flash support foe S3C2410/S3C2440 Soc Character devices---> ............................. [*]Non-standard serial port support [*]S3C2410 RTC Driver File systems---> <>Second extended fs support #去除 ext2 支持 Pseudo filesystems---> [*]Virtual memory file system support(former shm fs) [*]/dev file system support(OBSOLETE) [*]Automatically mount at boot(NEW) Miscellaneous filesystems---> ............................ <*>JFFS2 <*>cramfs ............................. Network File Systems----> <*>NFS file system support 保存退出
第1步Linux配置菜单及内核移植
第1步Linux配置菜单及内核移植Linux配置菜单及内核移植每次修改与增加内容者,需在⽂档修订记录中进⾏记录⼀、说明1.硬件平台SEP0718 eASIC开发板2.Linux BSP0718-android-kernel-2.6.29linux-v3.4(SEP4020)⼆、配置菜单进⼊BSP顶层⽬录后执⾏make menuconfig(调⽤arch/arm/Kconfig⽂件),即执⾏BSP的内核配置。
1.配置菜单选项介绍(SEP0718)主菜单"Linux Kernel Configuration"Kconfig中指定:mainmenu "Linux Kernel Configuration"General setupKconfig中source "init/Kconfig":menu "General setup"系统常规设置(略)重点配置选项●RCU Subsystem:Classic RCU●(17) Kernel log buffer size (16 => 64KB, 17 => 128KB)●(0) Default panic timeout●Choose SLAB allocator (SLUB (Unqueued Allocator)) Enable the block layerinit/Kconfig中source "block/Kconfig":"Enable the block layer"块设备层设置重要配置选项●Default I/O scheduler (No-op)System TypeKconfig中:menu "System Type"CPU类型及特性(略)重要配置选项(在内核移植部分介绍为何会出现这些选项)●ARM system type (SEP0718)●SEP0718 Implementations(EASIC0718)●Support ARM V6K processor extensions●Support Thumb user binariesKernel FeaturesKconfig中:menu "Kernel Features"重要配置选项●Memory split (3G/1G user/kernel split)●(4096) Low address space to protect from user allocation Boot optionsKconfig中:menu "Boot options"重要配置选项●(0x0) Compressed ROM boot loader base address●(0x0) Compressed ROM boot loader BSS address●(root=/dev/mtdblock1 rootfstype=yaffs mem=64mbconsole=ttyS1,115200 init=/init)Device DriversKconfig中:menu "Device Drivers"重要配置选项●Input device support(Horizontal/V ertical)●Character devices(Serial drivers)Kernel hackingKconfig中:source "arch/arm/Kconfig.debug":menu "Kernel hacking"重要配置选项●(1024) Warn for stack frames larger than (needs gcc 4.4)Load an Alternate Configuration FileSave an Alternate Configuration File内核配置后,⾃动⽣成.config⽂件,顶层Makefile间接包含.config⽂件并根据其定义的变量编译内核。
LINUX2.6.14在TE2410开发板上的移植
LINUX2.6.14在TE2410开发板上的移植作者:高福东 张银翠 王 鹏 乔 鹏 宋雪雁本实验是在TE2410开发板上实现的。
TE2410开发板是保定飞凌嵌入式技术有限公司自主研发的一款ARM9开发平台( ),基于三星公司的ARM 处理器S3C2410A 。
一. 准备必要的文件首先去官方网站下载最新的 linux 内核http ftp:/:///pub/linux/kernel/v2.6/linux-2.6.14.tar.bz2因为 linux2.6.14 内核需要更新版本的编译器,所以需要下载交叉编译器//projects/toolchain/arm-linux-gcc-3.4.1.tar.bz2二. 安装文件把 arm-linux-gcc 安装在 /usr/local/arm/3.4.1 目录下,安装方法和安装 gcc2.95.3 和 gcc3.3.2 是相同的!接下来需要解压 linux 内核,输入命令:[root · localhost hfrk]# tar jxvf linux-2.6.14.tar.bz2内核被解压到 linux-2.6.14 目录下。
三. 修改 makefile 文件内核的编译是根据 makefile 文件的指示进行的, Makefile 文件来组织内核的各模块之间的关系,记录了各个模块之间的相互联系和依赖关系。
我们首先修改 linux-2.6.14 的根目录下的 makfile 文件,须改的主要内容是目标代码的类型和为编译内核指定一个编译器。
注释掉以下内容:#ARCH ?= $(SUBARCH)#CROSS_COMPILE ?=增加如下内容:ARCH : = armCROSS_COMPILE =/usr/local/arm/3.4.1/bin/arm-linux-四. 修改相关的文件。
1、修改 arch\arm\mach-s3c2410\devs.c 文件增加头文件定义#include <linux/mtd/partitions.h>#include <asm/arch/nand.h>#include <linux/mtd/nand.h>/**************end add********/Te2410 开发板mtd分区表:name offset size flag------------------------------------------------vivi : 0x00000000 0x00020000 0 128k param : 0x00020000 0x00010000 0 64k kernel : 0x00030000 0x001c0000 0 1M+768k root : 0x00200000 0x00400000 0 4Musr : 0x00600000 0x03a00000 0 58M增加 nand flash 分区信息/***********add here***********/static struct mtd_partition partition_info[] ={{name: "vivi",size: 0x00020000,offset: 0,}, {name: "param",size: 0x00010000,offset: 0x00020000,}, {name: "kernel",size: 0x001c0000,offset: 0x00030000,}, {name: "root",size: 0x00400000,offset: 0x00200000,mask_flags: MTD_WRITEABLE,}, {name: "user",size: 0x03a00000,offset: 0x00600000,}};struct s3c2410_nand_set nandset ={nr_partitions: 5 ,partitions: partition_info ,};struct s3c2410_platform_nand superlpplatform={tacls:0,twrph0:30,twrph1:0,sets: &nandset,nr_sets: 1,};/**************end add********/struct platform_device s3c_device_nand = {.name= "s3c2410-nand",.id = -1,.num_resources = ARRAY_SIZE(s3c_nand_resource), .resource = s3c_nand_resource,/***********add here****************/.dev = {.platform_data = &superlpplatform}/**************end here************/};2. 修改 arch\arm\mach-s3c2410\mach-smdk2410.c 文件Startic struct platform_device *smdk2410_devices[] __initdata={ &s3c_device_usb,&s3c_device_lcd;&s3c_device_wdt,&s3c_device_i2c;&s3c_device_iis,&s3c_device_nand, /*add here*/};五解决ECC问题修改drivers/mtd/nand/s3c2410.c 文件:vi drivers/mtd/nand/s3c2410.c找到s3c2410_nand_init_chip()函数,在该函数体最后加上一条语句:chip->eccmode = NAND_ECC_NONE;保存,退出。
linux 2.6.14内核调度文件sched.h
///////include/sched.h#ifndef _LINUX_SCHED_H#define _LINUX_SCHED_H#include<asm/param.h>/* for HZ */#include<linux/config.h>#include<linux/capability.h>#include<linux/threads.h>#include<linux/kernel.h>#include<linux/types.h>#include<linux/timex.h>#include<linux/jiffies.h>#include<linux/rbtree.h>#include<linux/thread_info.h>#include<linux/cpumask.h>#include<linux/errno.h>#include<linux/nodemask.h>#include<asm/system.h>#include<asm/semaphore.h>#include<asm/page.h>#include<asm/ptrace.h>#include<asm/mmu.h>#include<asm/cputime.h>#include<linux/smp.h>#include<linux/sem.h>#include<linux/signal.h>#include<linux/securebits.h>#include<linux/fs_struct.h>#include<linux/compiler.h>#include<linux/completion.h>#include<linux/pid.h>#include<linux/percpu.h>#include<linux/topology.h>#include<linux/seccomp.h>#include<linux/auxvec.h>/* For AT_VECTOR_SIZE */struct exec_domain;/** cloning flags:*/#define CSIGNAL 0x000000ff /* signal mask to be sent at exit */#define CLONE_VM 0x00000100 /* set if VM shared between processes */#define CLONE_FS 0x00000200 /* set if fs info shared between processes */#define CLONE_FILES 0x00000400 /* set if open files shared between processes */#define CLONE_SIGHAND 0x00000800 /* set if signal handlers and blocked signals shared */#define CLONE_PTRACE 0x00002000 /* set if we want to let tracing continue on the child too */#define CLONE_VFORK 0x00004000 /* set if the parent wants the child to wake it up on mm_release */ #define CLONE_PARENT 0x00008000 /* set if we want to have the same parent as the cloner */#define CLONE_THREAD 0x00010000 /* Same thread group? */#define CLONE_NEWNS 0x00020000 /* New namespace group? */#define CLONE_SYSVSEM 0x00040000 /* share system V SEM_UNDO semantics */#define CLONE_SETTLS 0x00080000 /* create a new TLS for the child */#define CLONE_PARENT_SETTID 0x00100000 /* set the TID in the parent */#define CLONE_CHILD_CLEARTID 0x00200000 /* clear the TID in the child */#define CLONE_DETACHED 0x00400000 /* Unused, ignored */#define CLONE_UNTRACED 0x00800000 /* set if the tracing process can't force CLONE_PTRACE on this clone */ #define CLONE_CHILD_SETTID 0x01000000 /* set the TID in the child */#define CLONE_STOPPED 0x02000000 /* Start in stopped state *//** List of flags we want to share for kernel threads,* if only because they are not used by them anyway.*/#define CLONE_KERNEL (CLONE_FS | CLONE_FILES | CLONE_SIGHAND)/** These are the constant used to fake the fixed-point load-average* counting. Some notes:* - 11 bit fractions expand to 22 bits by the multiplies: this gives* a load-average precision of 10 bits integer + 11 bits fractional* - if you want to count load-averages more often, you need more* precision, or rounding will get you. With 2-second counting freq,* the EXP_n values would be 1981, 2034 and 2043 if still using only* 11 bit fractions.*/extern unsigned long avenrun[]; /* Load averages */#define FSHIFT 11 /* nr of bits of precision */#define FIXED_1 (1<<FSHIFT) /* 1.0 as fixed-point */#define LOAD_FREQ (5*HZ) /* 5 sec intervals */#define EXP_1 1884 /* 1/exp(5sec/1min) as fixed-point */#define EXP_5 2014 /* 1/exp(5sec/5min) */#define EXP_15 2037 /* 1/exp(5sec/15min) */#define CALC_LOAD(load,exp,n) \load *= exp; \load += n*(FIXED_1-exp); \load >>= FSHIFT;extern unsigned long total_forks;extern int nr_threads;extern int last_pid;DECLARE_PER_CPU(unsigned long, process_counts);extern int nr_processes(void);extern unsigned long nr_running(void);extern unsigned long nr_uninterruptible(void);extern unsigned long nr_iowait(void);#include<linux/time.h>#include<linux/param.h>#include<linux/resource.h>#include<linux/timer.h>#include<asm/processor.h>/** Task state bitmask. NOTE! These bits are also* encoded in fs/proc/array.c: get_task_state().** We have two separate sets of flags: task->state* is about runnability, while task->exit_state are* about the task exiting. Confusing, but this way* modifying one set can't modify the other one by* mistake.*/#define TASK_RUNNING 0#define TASK_INTERRUPTIBLE 1#define TASK_UNINTERRUPTIBLE 2#define TASK_STOPPED 4#define TASK_TRACED 8/* in tsk->exit_state */#define EXIT_ZOMBIE 16#define EXIT_DEAD 32/* in tsk->state again */#define TASK_NONINTERACTIVE 64#define __set_task_state(tsk, state_value) \do { (tsk)->state = (state_value); } while (0)#define set_task_state(tsk, state_value) \set_mb((tsk)->state, (state_value))/** set_current_state() includes a barrier so that the write of current->state* is correctly serialised wrt the caller's subsequent test of whether to* actually sleep:** set_current_state(TASK_UNINTERRUPTIBLE);* if (do_i_need_to_sleep())* schedule();** If the caller does not need such serialisation then use __set_current_state() */#define __set_current_state(state_value) \ do { current->state = (state_value); } while (0)#define set_current_state(state_value) \set_mb(current->state, (state_value))/* Task command name length */#define TASK_COMM_LEN 16/** Scheduling policies*/#define SCHED_NORMAL 0#define SCHED_FIFO 1#define SCHED_RR 2struct sched_param {int sched_priority;};#ifdef __KERNEL__#include<linux/spinlock.h>/** This serializes "schedule()" and also protects* the run-queue from deletions/modifications (but* _adding_ to the beginning of the run-queue has* a separate lock).*/extern rwlock_t tasklist_lock;extern spinlock_t mmlist_lock;typedef struct task_struct task_t;extern void sched_init(void);extern void sched_init_smp(void);extern void init_idle(task_t *idle, int cpu);extern cpumask_t nohz_cpu_mask;extern void show_state(void);extern void show_regs(struct pt_regs *);/** TASK is a pointer to the task whose backtrace we want to see (or NULL for current * task), SP is the stack pointer of the first frame that should be shown in the back* trace (or NULL if the entire call-chain of the task should be shown).*/extern void show_stack(struct task_struct *task, unsigned long *sp);void io_schedule(void);long io_schedule_timeout(long timeout);extern void cpu_init (void);extern void trap_init(void);extern void update_process_times(int user);extern void scheduler_tick(void);#ifdef CONFIG_DETECT_SOFTLOCKUPextern void softlockup_tick(struct pt_regs *regs);extern void spawn_softlockup_task(void);extern void touch_softlockup_watchdog(void);#elsestatic inline void softlockup_tick(struct pt_regs *regs){}static inline void spawn_softlockup_task(void){}static inline void touch_softlockup_watchdog(void){}#endif/* Attach to any functions which should be ignored in wchan output. */#define __sched __attribute__((__section__(".sched.text")))/* Is this address in the __sched functions? */extern int in_sched_functions(unsigned long addr);#define MAX_SCHEDULE_TIMEOUT LONG_MAXextern signed long FASTCALL(schedule_timeout(signed long timeout));extern signed long schedule_timeout_interruptible(signed long timeout);extern signed long schedule_timeout_uninterruptible(signed long timeout);asmlinkage void schedule(void);struct namespace;/* Maximum number of active map areas.. This is a random (large) number */#define DEFAULT_MAX_MAP_COUNT 65536extern int sysctl_max_map_count;#include<linux/aio.h>extern unsigned longarch_get_unmapped_area(struct file *, unsigned long, unsigned long,unsigned long, unsigned long);extern unsigned longarch_get_unmapped_area_topdown(struct file *filp, unsigned long addr,unsigned long len, unsigned long pgoff,unsigned long flags);extern void arch_unmap_area(struct mm_struct *, unsigned long);extern void arch_unmap_area_topdown(struct mm_struct *, unsigned long);#define set_mm_counter(mm, member, value) (mm)->_##member = (value)#define get_mm_counter(mm, member) ((mm)->_##member)#define add_mm_counter(mm, member, value) (mm)->_##member += (value)#define inc_mm_counter(mm, member) (mm)->_##member++#define dec_mm_counter(mm, member) (mm)->_##member--typedef unsigned long mm_counter_t;struct mm_struct {struct vm_area_struct * mmap; /* list of VMAs */struct rb_root mm_rb;struct vm_area_struct * mmap_cache; /* last find_vma result */unsigned long (*get_unmapped_area) (struct file *filp,unsigned long addr, unsigned long len,unsigned long pgoff, unsigned long flags);void (*unmap_area) (struct mm_struct *mm, unsigned long addr);unsigned long mmap_base; /* base of mmap area */unsigned long cached_hole_size; /* if non-zero, the largest hole below free_area_cache */unsigned long free_area_cache; /* first hole of size cached_hole_size or larger */pgd_t * pgd;atomic_t mm_users; /* How many users with user space? */atomic_t mm_count; /* How many references to "struct mm_struct" (users count as 1) */ int map_count; /* number of VMAs */struct rw_semaphore mmap_sem;spinlock_t page_table_lock; /* Protects page tables and some counters */struct list_head mmlist; /* List of maybe swapped mm's. These are globally strung* together off init_mm.mmlist, and are protected* by mmlist_lock*/unsigned long start_code, end_code, start_data, end_data;unsigned long start_brk, brk, start_stack;unsigned long arg_start, arg_end, env_start, env_end;unsigned long total_vm, locked_vm, shared_vm;unsigned long exec_vm, stack_vm, reserved_vm, def_flags, nr_ptes;/* Special counters protected by the page_table_lock */mm_counter_t _rss;mm_counter_t _anon_rss;unsigned long saved_auxv[AT_VECTOR_SIZE]; /* for /proc/PID/auxv */unsigned dumpable:2;cpumask_t cpu_vm_mask;/* Architecture-specific MM context */mm_context_t context;/* Token based thrashing protection. */unsigned long swap_token_time;char recent_pagein;/* coredumping support */int core_waiters;struct completion *core_startup_done, core_done;/* aio bits */rwlock_t ioctx_list_lock;struct kioctx *ioctx_list;struct kioctx default_kioctx;unsigned long hiwater_rss; /* High-water RSS usage */unsigned long hiwater_vm; /* High-water virtual memory usage */};struct sighand_struct {atomic_t count;struct k_sigaction action[_NSIG];spinlock_t siglock;};/** NOTE! "signal_struct" does not have it's own* locking, because a shared signal_struct always* implies a shared sighand_struct, so locking* sighand_struct is always a proper superset of* the locking of signal_struct.*/struct signal_struct {atomic_t count;atomic_t live;wait_queue_head_t wait_chldexit; /* for wait4() *//* current thread group signal load-balancing target: */task_t *curr_target;/* shared signal handling: */struct sigpending shared_pending;/* thread group exit support */int group_exit_code;/* overloaded:* - notify group_exit_task when ->count is equal to notify_count* - everyone except group_exit_task is stopped during signal delivery * of fatal signals, group_exit_task processes the signal.*/struct task_struct *group_exit_task;int notify_count;/* thread group stop support, overloads group_exit_code too */int group_stop_count;unsigned int flags; /* see SIGNAL_* flags below */ /* POSIX.1b Interval Timers */struct list_head posix_timers;/* ITIMER_REAL timer for the process */struct timer_list real_timer;unsigned long it_real_value, it_real_incr;/* ITIMER_PROF and ITIMER_VIRTUAL timers for the process */ cputime_t it_prof_expires, it_virt_expires;cputime_t it_prof_incr, it_virt_incr;/* job control IDs */pid_t pgrp;pid_t tty_old_pgrp;pid_t session;/* boolean value for session group leader */int leader;struct tty_struct *tty; /* NULL if no tty *//** Cumulative resource counters for dead threads in the group,* and for reaped dead child processes forked by this group.* Live threads maintain their own counters and add to these* in __exit_signal, except for the group leader.*/cputime_t utime, stime, cutime, cstime;unsigned long nvcsw, nivcsw, cnvcsw, cnivcsw;unsigned long min_flt, maj_flt, cmin_flt, cmaj_flt;/** Cumulative ns of scheduled CPU time for dead threads in the* group, not including a zombie group leader. (This only differs* from jiffies_to_ns(utime + stime) if sched_clock uses something* other than jiffies.)*/unsigned long long sched_time;/** We don't bother to synchronize most readers of this at all,* because there is no reader checking a limit that actually needs* to get both rlim_cur and rlim_max atomically, and either one* alone is a single word that can safely be read normally.* getrlimit/setrlimit use task_lock(current->group_leader) to* protect this instead of the siglock, because they really* have no need to disable irqs.*/struct rlimit rlim[RLIM_NLIMITS];struct list_head cpu_timers[3];/* keep the process-shared keyrings here so that they do the right* thing in threads created with CLONE_THREAD */#ifdef CONFIG_KEYSstruct key *session_keyring; /* keyring inherited over fork */struct key *process_keyring; /* keyring private to this process */#endif};/* Context switch must be unlocked if interrupts are to be enabled */#ifdef __ARCH_WANT_INTERRUPTS_ON_CTXSW# define __ARCH_WANT_UNLOCKED_CTXSW#endif/** Bits in flags field of signal_struct.*/#define SIGNAL_STOP_STOPPED 0x00000001 /* job control stop in effect */#define SIGNAL_STOP_DEQUEUED 0x00000002 /* stop signal dequeued */#define SIGNAL_STOP_CONTINUED 0x00000004 /* SIGCONT since WCONTINUED reap */ #define SIGNAL_GROUP_EXIT 0x00000008 /* group exit in progress *//** Priority of a process goes from 0..MAX_PRIO-1, valid RT* priority is 0..MAX_RT_PRIO-1, and SCHED_NORMAL tasks are* in the range MAX_RT_PRIO..MAX_PRIO-1. Priority values* are inverted: lower p->prio value means higher priority.** The MAX_USER_RT_PRIO value allows the actual maximum* RT priority to be separate from the value exported to* user-space. This allows kernel threads to set their* priority to a value higher than any user task. Note:* MAX_RT_PRIO must not be smaller than MAX_USER_RT_PRIO.*/#define MAX_USER_RT_PRIO 100#define MAX_RT_PRIO MAX_USER_RT_PRIO#define MAX_PRIO (MAX_RT_PRIO + 40)#define rt_task(p) (unlikely((p)->prio < MAX_RT_PRIO))/** Some day this will be a full-fledged user tracking system..*/struct user_struct {atomic_t __count; /* reference count */atomic_t processes; /* How many processes does this user have? */atomic_t files; /* How many open files does this user have? */atomic_t sigpending; /* How many pending signals does this user have? */#ifdef CONFIG_INOTIFYatomic_t inotify_watches; /* How many inotify watches does this user have? */atomic_t inotify_devs; /* How many inotify devs does this user have opened? */#endif/* protected by mq_lock */unsigned long mq_bytes; /* How many bytes can be allocated to mqueue? */unsigned long locked_shm; /* How many pages of mlocked shm ? */#ifdef CONFIG_KEYSstruct key *uid_keyring; /* UID specific keyring */struct key *session_keyring; /* UID's default session keyring */#endif/* Hash table maintenance information */struct list_head uidhash_list;uid_t uid;};extern struct user_struct *find_user(uid_t);extern struct user_struct root_user;#define INIT_USER (&root_user)typedef struct prio_array prio_array_t;struct backing_dev_info;struct reclaim_state;#ifdef CONFIG_SCHEDSTATSstruct sched_info {/* cumulative counters */unsigned long cpu_time, /* time spent on the cpu */run_delay, /* time spent waiting on a runqueue */pcnt; /* # of timeslices run on this cpu */ /* timestamps */unsigned long last_arrival, /* when we last ran on a cpu */last_queued; /* when we were last queued to run */};extern struct file_operations proc_schedstat_operations;#endifenum idle_type{SCHED_IDLE,NOT_IDLE,NEWLY_IDLE,MAX_IDLE_TYPES};/** sched-domains (multiprocessor balancing) declarations:*/#ifdef CONFIG_SMP#define SCHED_LOAD_SCALE 128UL /* increase resolution of load */#define SD_LOAD_BALANCE 1 /* Do load balancing on this domain. */ #define SD_BALANCE_NEWIDLE 2 /* Balance when about to become idle */#define SD_BALANCE_EXEC 4 /* Balance on exec */#define SD_BALANCE_FORK 8 /* Balance on fork, clone */#define SD_WAKE_IDLE 16 /* Wake to idle CPU on task wakeup */#define SD_WAKE_AFFINE 32 /* Wake task to waking CPU */#define SD_WAKE_BALANCE 64 /* Perform balancing at task wakeup */ #define SD_SHARE_CPUPOWER 128 /* Domain members share cpu power */struct sched_group {struct sched_group *next; /* Must be a circular list */cpumask_t cpumask;/** CPU power of this group, SCHED_LOAD_SCALE being max power for a* single CPU. This is read only (except for setup, hotplug CPU).*/unsigned long cpu_power;};struct sched_domain {/* These fields must be setup */struct sched_domain *parent; /* top domain must be null terminated */struct sched_group *groups; /* the balancing groups of the domain */cpumask_t span; /* span of all CPUs in this domain */unsigned long min_interval; /* Minimum balance interval ms */unsigned long max_interval; /* Maximum balance interval ms */unsigned int busy_factor; /* less balancing by factor if busy */unsigned int imbalance_pct; /* No balance until over watermark */unsigned long long cache_hot_time; /* Task considered cache hot (ns) */unsigned int cache_nice_tries; /* Leave cache hot tasks for # tries */unsigned int per_cpu_gain; /* CPU % gained by adding domain cpus */unsigned int busy_idx;unsigned int idle_idx;unsigned int newidle_idx;unsigned int wake_idx;unsigned int forkexec_idx;int flags; /* See SD_* *//* Runtime fields. */unsigned long last_balance; /* init to jiffies. units in jiffies */unsigned int balance_interval; /* initialise to 1. units in ms. */unsigned int nr_balance_failed; /* initialise to 0 */#ifdef CONFIG_SCHEDSTATS/* load_balance() stats */unsigned long lb_cnt[MAX_IDLE_TYPES];unsigned long lb_failed[MAX_IDLE_TYPES];unsigned long lb_balanced[MAX_IDLE_TYPES];unsigned long lb_imbalance[MAX_IDLE_TYPES];unsigned long lb_gained[MAX_IDLE_TYPES];unsigned long lb_hot_gained[MAX_IDLE_TYPES];unsigned long lb_nobusyg[MAX_IDLE_TYPES];unsigned long lb_nobusyq[MAX_IDLE_TYPES];/* Active load balancing */unsigned long alb_cnt;unsigned long alb_failed;unsigned long alb_pushed;/* SD_BALANCE_EXEC stats */unsigned long sbe_cnt;unsigned long sbe_balanced;unsigned long sbe_pushed;/* SD_BALANCE_FORK stats */unsigned long sbf_cnt;unsigned long sbf_balanced;unsigned long sbf_pushed;/* try_to_wake_up() stats */unsigned long ttwu_wake_remote;unsigned long ttwu_move_affine;unsigned long ttwu_move_balance;#endif};extern void partition_sched_domains(cpumask_t *partition1,cpumask_t *partition2);#endif/* CONFIG_SMP */struct io_context; /* See blkdev.h */void exit_io_context(void);struct cpuset;#define NGROUPS_SMALL 32#define NGROUPS_PER_BLOCK ((int)(PAGE_SIZE / sizeof(gid_t)))struct group_info {int ngroups;atomic_t usage;gid_t small_block[NGROUPS_SMALL];int nblocks;gid_t *blocks[0];};/** get_group_info() must be called with the owning task locked (via task_lock()) * when task != current. The reason being that the vast majority of callers are* looking at current->group_info, which can not be changed except by the* current task. Changing current->group_info requires the task lock, too.*/#define get_group_info(group_info) do { \atomic_inc(&(group_info)->usage); \} while (0)#define put_group_info(group_info) do { \if (atomic_dec_and_test(&(group_info)->usage)) \groups_free(group_info); \} while (0)extern struct group_info *groups_alloc(int gidsetsize);extern void groups_free(struct group_info *group_info);extern int set_current_groups(struct group_info *group_info);extern int groups_search(struct group_info *group_info, gid_t grp);/* access the groups "array" with this macro */#define GROUP_AT(gi, i) \((gi)->blocks[(i)/NGROUPS_PER_BLOCK][(i)%NGROUPS_PER_BLOCK]) #ifdef ARCH_HAS_PREFETCH_SWITCH_STACKextern void prefetch_stack(struct task_struct*);#elsestatic inline void prefetch_stack(struct task_struct *t) { }#endifstruct audit_context; /* See audit.c */struct mempolicy;struct task_struct {volatile long state; /* -1 unrunnable, 0 runnable, >0 stopped */struct thread_info *thread_info;atomic_t usage;unsigned long flags; /* per process flags, defined below */unsigned long ptrace;int lock_depth; /* BKL lock depth */#if defined(CONFIG_SMP) && defined(__ARCH_WANT_UNLOCKED_CTXSW) int oncpu;#endifint prio, static_prio;struct list_head run_list;prio_array_t *array;unsigned short ioprio;unsigned long sleep_avg;unsigned long long timestamp, last_ran;unsigned long long sched_time; /* sched_clock time spent running */int activated;unsigned long policy;cpumask_t cpus_allowed;unsigned int time_slice, first_time_slice;#ifdef CONFIG_SCHEDSTATSstruct sched_info sched_info;#endifstruct list_head tasks;/** ptrace_list/ptrace_children forms the list of my children* that were stolen by a ptracer.*/struct list_head ptrace_children;struct list_head ptrace_list;struct mm_struct *mm, *active_mm;/* task state */struct linux_binfmt *binfmt;long exit_state;int exit_code, exit_signal;int pdeath_signal; /* The signal sent when the parent dies *//* ??? */unsigned long personality;unsigned did_exec:1;pid_t pid;pid_t tgid;/** pointers to (original) parent process, youngest child, younger sibling,* older sibling, respectively. (p->father can be replaced with* p->parent->pid)*/struct task_struct *real_parent; /* real parent process (when being debugged) */struct task_struct *parent; /* parent process *//** children/sibling forms the list of my children plus the* tasks I'm ptracing.*/struct list_head children; /* list of my children */struct list_head sibling; /* linkage in my parent's children list */struct task_struct *group_leader; /* threadgroup leader *//* PID/PID hash table linkage. */struct pid pids[PIDTYPE_MAX];struct completion *vfork_done; /* for vfork() */int __user *set_child_tid; /* CLONE_CHILD_SETTID */int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */unsigned long rt_priority;cputime_t utime, stime;unsigned long nvcsw, nivcsw; /* context switch counts */struct timespec start_time;/* mm fault and swap info: this can arguably be seen as either mm-specific or thread-specific */ unsigned long min_flt, maj_flt;cputime_t it_prof_expires, it_virt_expires;unsigned long long it_sched_expires;struct list_head cpu_timers[3];/* process credentials */uid_t uid,euid,suid,fsuid;gid_t gid,egid,sgid,fsgid;struct group_info *group_info;kernel_cap_t cap_effective, cap_inheritable, cap_permitted;unsigned keep_capabilities:1;struct user_struct *user;#ifdef CONFIG_KEYSstruct key *thread_keyring; /* keyring private to this thread */unsigned char jit_keyring; /* default keyring to attach requested keys to */#endifint oomkilladj; /* OOM kill score adjustment (bit shift). */char comm[TASK_COMM_LEN]; /* executable name excluding path- access with [gs]et_task_comm (which lockit with task_lock())- initialized normally by flush_old_exec *//* file system info */int link_count, total_link_count;/* ipc stuff */struct sysv_sem sysvsem;/* CPU-specific state of this task */struct thread_struct thread;/* filesystem information */struct fs_struct *fs;/* open file information */struct files_struct *files;/* namespace */struct namespace *namespace;/* signal handlers */struct signal_struct *signal;struct sighand_struct *sighand;sigset_t blocked, real_blocked;struct sigpending pending;unsigned long sas_ss_sp;size_t sas_ss_size;int (*notifier)(void *priv);void *notifier_data;sigset_t *notifier_mask;void *security;struct audit_context *audit_context;seccomp_t seccomp;/* Thread group tracking */u32 parent_exec_id;u32 self_exec_id;/* Protection of (de-)allocation: mm, files, fs, tty, keyrings */spinlock_t alloc_lock;/* Protection of proc_dentry: nesting proc_lock, dcache_lock, write_lock_irq(&tasklist_lock); */ spinlock_t proc_lock;/* journalling filesystem info */void *journal_info;/* VM state */struct reclaim_state *reclaim_state;struct dentry *proc_dentry;struct backing_dev_info *backing_dev_info;struct io_context *io_context;unsigned long ptrace_message;siginfo_t *last_siginfo; /* For ptrace use. *//** current io wait handle: wait queue entry to use for io waits* If this thread is processing aio, this points at the waitqueue* inside the currently handled kiocb. It may be NULL (i.e. default* to a stack based synchronous wait) if its doing sync IO.*/wait_queue_t *io_wait;/* i/o counters(bytes read/written, #syscalls */u64 rchar, wchar, syscr, syscw;#if defined(CONFIG_BSD_PROCESS_ACCT)u64 acct_rss_mem1; /* accumulated rss usage */u64 acct_vm_mem1; /* accumulated virtual memory usage */clock_t acct_stimexpd; /* clock_t-converted stime since last update */#endif#ifdef CONFIG_NUMAstruct mempolicy *mempolicy;short il_next;#endif#ifdef CONFIG_CPUSETSstruct cpuset *cpuset;nodemask_t mems_allowed;int cpuset_mems_generation;#endifatomic_t fs_excl; /* holding fs exclusive resources */};static inline pid_t process_group(struct task_struct *tsk){return tsk->signal->pgrp;}/*** pid_alive - check that a task structure is not stale* @p: Task structure to be checked.** Test if a process is not yet dead (at most zombie state)* If pid_alive fails, then pointers within the task structure* can be stale and must not be dereferenced.*/static inline int pid_alive(struct task_struct *p){return p->pids[PIDTYPE_PID].nr != 0;}extern void free_task(struct task_struct *tsk);extern void __put_task_struct(struct task_struct *tsk);#define get_task_struct(tsk) do { atomic_inc(&(tsk)->usage); } while(0)#define put_task_struct(tsk) \do { if (atomic_dec_and_test(&(tsk)->usage)) __put_task_struct(tsk); } while(0)/** Per process flags*/#define PF_ALIGNWARN 0x00000001 /* Print alignment warning msgs *//* Not implemented yet, only for 486*/#define PF_STARTING 0x00000002 /* being created */#define PF_EXITING 0x00000004 /* getting shut down */#define PF_DEAD 0x00000008 /* Dead */#define PF_FORKNOEXEC 0x00000040 /* forked but didn't exec */#define PF_SUPERPRIV 0x00000100 /* used super-user privileges */#define PF_DUMPCORE 0x00000200 /* dumped core */#define PF_SIGNALED 0x00000400 /* killed by a signal */#define PF_MEMALLOC 0x00000800 /* Allocating memory */#define PF_FLUSHER 0x00001000 /* responsible for disk writeback */#define PF_USED_MATH 0x00002000 /* if unset the fpu must be initialized before use */ #define PF_FREEZE 0x00004000 /* this task is being frozen for suspend now */#define PF_NOFREEZE 0x00008000 /* this thread should not be frozen */#define PF_FROZEN 0x00010000 /* frozen for system suspend */#define PF_FSTRANS 0x00020000 /* inside a filesystem transaction */#define PF_KSWAPD 0x00040000 /* I am kswapd */#define PF_SWAPOFF 0x00080000 /* I am in swapoff */#define PF_LESS_THROTTLE 0x00100000 /* Throttle me less: I clean memory */#define PF_SYNCWRITE 0x00200000 /* I am doing a sync write */#define PF_BORROWED_MM 0x00400000 /* I am a kthread doing use_mm */#define PF_RANDOMIZE 0x00800000 /* randomize virtual address space */。
LINUX内核移植实验
4 LINUX内核移植实验4.1 资源1.linux-2.6.24.4.tar.bz2 (Linux内核源码的压缩包,下载地址)2.yaffs2.tar.gz (yaffs文件系统源码的压缩包)3.dm9000.h和dm9000.c (dm9000网卡驱动程序)4.2 解压源码包1.在XP中,把“04/下午/src”文件夹拷贝到“//192.168.1.12”的共享文件夹uptech内,并把uptech中的“src”更名为“04 linux”2.在Linux虚拟机中进入该文件夹“cd /home/uptech/04 linux”ls可见4个文件:“linux-2.6.24.4.tar.bz2”、“yaffs2.tar.gz”、“dm9000.h”、“dm9000.c”◆bz2压缩包用“tar jxvf”解压◆gz压缩包用“tar zxvf”解压3.解压Linux源码压缩包,即输入命令“tar jxvf linux-2.6.24.4.tar.bz2”4.解压YAFFS源码压缩包,即输入命令“tar zxvf yaffs2.tar.gz”4.3 修改Makefile文件,支持交叉编译1.cd /home/uptech/04 linux/linux-2.6.24.2,该目录下就是linux的内核源码2.修改Makefile文件,使之支持交叉编译,也就是在Linux上编译出ARM开发板上运行的内核程序。
ARCH ?= arm (目标平台是arm)CROSS_COMPILE ?= arm-linux-(交叉编译器的前缀是arm-linux-) 4.4 得到.config文件1.得到.config文件将“/home/uptech/04 linux/linux-2.6.24.2/arch/arm/configs/s3c2410_defconfig”文件拷贝成“/home/uptech/04 linux/linux-2.6.24.2/.config”cp arch/arm/configs/s3c2410_defconfig .config2.对内核进行裁剪(此时暂时不做裁剪,仅是看看)make menuconfig4.5 修改Nand Flash分区修改“/home/uptech/04 linux/linux-2.6.24.2/arch/arm/plat-s3c24xx/common-smdk.c”文件中的“struct mtd-partition smdk_default_nand_part[]”这个结构体:第一个分区从0x0000 0000 到0x0008 0000,大小为0.5M第二个分区从0x0008 0000 到0x0028 0000,大小为2M第三个分区从0x0028 0000 到0x0068 0000,大小为4M第四个分区从0x0068 0000 到0x0400 0000,大小为57.5M具体做法:(1) vi arch/arm/plat-s3c24xx/common-smdk.c(2)修改分区信息结构体static struct mtd_partition smdk_default_nand_part[] = {[0] = {.name = "Bootloader",.size = 0x80000,.offset = 0,},[1] = {.name = "Linux Kernel",.offset = 0x80000,.size = SZ_2M,},[2] = {.name = "Root File System",.offset = 0x280000,.size = SZ_4M,},[3] = {.name = "User Space",.offset = 0x680000,.size = 0x3980000,},};4.6 添加LCD支持修改“/home/uptech/04 linux/linux-2.6.24.2/arch/arm/mach-s3c2410/mach-smdk2410.c”。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
二、让内核支持 yaffs 文件系统
1. MTD 分区的支持
前面介绍了如何编译一个内核,现在要介绍的是如何让内核支持 yaffs 文件系统。在介绍添加文件系统的支持之前,首先了解一下ology device 内存技术设备 ) 是用于访问 memory 设备( ROM 、 flash )的 Linux 的子系统。 MTD 的主要目的是为了使新的 memory 设备的驱动更加简单,为此它在硬件和上层之间提供了一个抽象的接口。
.dev = {
.platform_data = &superlpplatform
}
/**************end here************/
};
2. 修改arch\arm\mach-s3c2410\mach-smdk2410.c文件
Startic struct platform_device *smdk2410_devices[] __initdata={
3.配置内核( Make menuconfig )
我一般会选择 load 一个配置文件然后在它的基础上修改。方法:选中 load an Alternate Configuration File ,然后键入配置文件的路径。
在我刚编译内核的时候选择的是 linux-2.6.14/arch/arm/configs/smdk2410_defconfig 这个配置文件。
一、编译内核
1. make distclean 或者 make mrproper
如果你是新下载的内核,那这一步就不用了。但如果你用的是别人移植好的内核,那最好在编译内核之前先清除一下中间文件,因为你们用来编译内核的交叉编译工具可能不同。
2.修改 Makefile
主要是以下两项:
/S3C2410/kaifa/05122311085973789_56.htm
可以看到其实要修改部分不多,主要是加上nandflash的支持和mtd分区表的填写,如下:
1.修改arch\arm\mach-s3c2410\devs.c文件
增加头文件定义
好了,其它的就不说了,有兴趣可以上网查一下相关的资料,下面说明让内核支持 mtd 分区的配置选项:
进入Device Drivers->Memory Technology Devices(MTD)目录,配置界面如下:
Memory Technology Device (MTD) support
};
struct s3c2410_platform_nand superlpplatform={
tacls:0,
twrph0:30,
twrph1:0,
sets: &nandset,
nr_sets: 1,
};
/**************end add********/
struct platform_device s3c_device_nand = {
NAND Flash Device Drivers ---> │ │
进入NAND Flash Device Drivers目录,配置界面如下:
[*] NAND Device Support │ │
RAM/ROM/Flash chip drivers ---> │ │
Mapping drivers for chip access ---> │ │
Self-contained MTD device drivers ---> │ │
mask_flags: MTD_WRITEABLE,
}, {
name: "user",
size: 0x03af8000,
offset: 0x00400000,
}
};
struct s3c2410_nand_set nandset ={
nr_partitions: 5 ,
partitions: partition_info ,
增加nand flash分区信息
/***********add here***********/
static struct mtd_partition partition_info[] ={
{
name: "loader",
size: 0x00020000,
offset: 0,
}, {
.name = "s3c2410-nand",
.id = -1,
.num_resources = ARRAY_SIZE(s3c_nand_resource),
.resource = s3c_nand_resource,
/***********add here****************/
[*] Caching block device access to MTD devices │ │
[ ] FTL (Flash Translation Layer) support │ │
4. make
然后一切 OK , 2.6 内核的编译就是这么简单。你可以在 linux-2.6.14/arch/arm/boot/ 目录下看到我们需要的 zImage 文件。这就是经过压缩的内核镜像文件,把它下载到目标板上的 flash 中即可运行。由于 2410 已经作为 2.6 内核的标准板来支持,所以上面编译的这个内核不用什么修改即可运行,在串口可以看到内核的启动信息。主要是启动参数的问题:在 2.6 内核中, 2410 的串口由原来的 ttyS0 变为 ttySAC0 (听说其它的板还是保持不变,具体没有研究)。有关内核启动参数的设置以后会逐步提到。
/***********add here***********/
#include <linux/mtd/partitions.h>
#include <asm/arch/nand.h>
#include <linux/mtd/nand.h>
/**************end add********/
--- User Modules And Translation Layers │ │
[*] Direct char device access to MTD devices │ │
1 ) ARCH = arm
2) CROSS_COMPILE = /usr/local/arm/3.4.1/bin/arm-linux-
注 :在我的宿主机上有不少的交叉编译工具,而我又不习惯每次都传递参数,所以我选择写进 Makefile ,如果你的交叉编译工具存放在不同的目录或者使用不同的交叉编译工具,那你改变一下 CROSS_COMPILE 的值就行了。
其它不用多设,甚至 Direct char device access to MTD devices 选项和Mapping drivers for chip access ---> 目录下的所有选项都可以去掉(经已试验过) 。因为那些是为 nor flash 服务的,一般文件系统都会放在 nand flash 上吧,不过也不排除例外。那你就干脆让它们留着好了,因为编译出来后实在多不了多少,我把它们去掉的原因只是为了试验 ^_^
&s3c_device_usb,
&s3c_device_lcd;
&s3c_device_wdt,
&s3c_device_i2c;
&s3c_device_iis,
[ ] Command line partition table parsing │ │
[ ] ARM Firmware Suite partition parsing │ │
2.文件系统的支持
Yaffs 文件系统是专业针对 nand flash 的文件系统,比 jffs2 文件系统拥有更高的处理速度,更节省内存,支持的 mtd 分区更大等众多优点,所以在此选用 yaffs 文件系统。
Yaffs 文件系统内核没有集成,可以对其主页下载:
/cgi-bin/viewcvs.cgi/yaffs2.tar.gz?view=tar
[*] MTD partitioning support │ │
[ ] RedBoot partition table parsing │ │
name: "param",
size: 0x00010000,
offset: 0x00020000,
}, {
name: "kernel",
size: 0x001c0000,
offset: 0x00030000,
}, {
name: "root",
size: 0x00200000,
offset: 0x00200000,
[ ] S3C2410 NAND Hardware ECC │ │
[ ] DiskOnChip 2000, Millennium and Millennium Plus (NAND reimplement│ │
[ ] Support for NAND Flash Simulator │ │
[ ] Verify NAND page writes │ │
[*] NAND Flash support for S3C2410/S3C2440 SoC │ │
[*] S3C2410 NAND driver debug │ │
建议下载 yaffs2 源码包,里面就支持了 yaffs 和 yaffs2 两种文件系统,把它添加进内核也很方便,有专门的脚本来处理。以下是我在文坛上发过的贴,里面介绍了把 yaffs 文件系统支持添加进内核的全过程: