在s3c2440上linux镜像在nand flash中吗,Linux2.6.39在S3C2440上的移植

本文档详细介绍了如何在VMware下的Ubuntu环境中,针对Micro2440开发板移植Linux内核2.6.39。内容包括下载和解压内核源码、指定交叉编译器、创建目标平台的移植、修改NANDFlash驱动和分区信息。通过修改内核配置文件和驱动代码,实现了与U-Boot中NANDFlash分区的一致性,并最终成功编译内核。
摘要由CSDN通过智能技术生成

1、主机环境:VMare下Ubuntu10.04 ,1G内存。

2、编译编译环境:arm-linux-gcc

3、开发板:Micro2440,2M nor flash,256M nand flash。

4、u-boot-version:u-boot-2010.06

5、linux -version:Linux-2.6.39

一、下载并解压内核源码

a)在命令行终端中可以通过下列方式下载,当然用其它下载工具下载

root@bootloader:/home/eilian/development/Android#cd ../Linux

root@bootloader:/home/eilian/development/Linux# wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.39.tar.gz

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.36.2.tar.gzlinux-2.6.39linux-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 可以在mini2440 上运行。首先,使得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)

修改完成后退出保存

/********************************************************************************************************************************/

d)创建目标平台

个性移植从SMDK2440到eilian240

root@bootloader:/home/eilian/development/Linux/linux-2.6.39#cd arch/arm/mach-s3c2440

root@bootloader:/home/eilian/development/Linux/linux-2.6.39/arch/arm/mach-s3c2440#cp mach-smd2440.c mach-eilian240.c

将mach-eilian240.c文件中的所有smdk2440改成eilian240

root@bootloader:/home/eilian/development/Linux/linux-2.6.39/arch/arm/mach-s3c2440#vi mach-eilian240.c

操作如下:在vi的命令模式下输入

6737f58e19fcca3f27ffd5415cff0649.gif

修改mach-s3c2440目录下的Makefile,打开Makefile定位到38行做如下修改

obj-$(CONFIG_MACH_ANUBIS)    += mach-anubis.o

obj-$(CONFIG_MACH_OSIRIS)    += mach-osiris.o

obj-$(CONFIG_MACH_RX3715)    += mach-rx3715.o

obj-$(CONFIG_ARCH_S3C2440)    += mach-smdk2440.o

obj-$(CONFIG_MACH_NEXCODER_2440) += mach-nexcoder.o

obj-$(CONFIG_MACH_AT2440EVB) += mach-at2440evb.o

obj-$(CONFIG_MACH_MINI2440) += mach-mini2440.o

obj-$(CONFIG_MACH_NEO1973_GTA02) += mach-gta02.o

obj-$(CONFIG_MACH_RX1950) += mach-rx1950.o

obj-$(CONFIG_MACH_MINI2440) += mach-eilian240.o#为何这样修改呢?后面慢慢解释

修改mach-s3c2440目录下的Kconfig 添加如下代码

config MACH_MINI2440

bool "MINI2440 development board"

select CPU_S3C2440

select EEPROM_AT24

select NEW_LEDS

select LEDS_CLASS

select LEDS_TRIGGER

select LEDS_TRIGGER_BACKLIGHT

select S3C_DEV_NAND

select S3C_DEV_USB_HOST

help

Say Y here to select support for the MINI2440. Is a 10cm x 10cm board

available via various sources. It can come with a 3.5" or 7" touch LCD.

config MACH_EILIAN240bool "eilian240 development board"select CPU_S3C2440select EEPROM_AT24select NEW_LEDSselect LEDS_CLASSselect LEDS_TRIGGERselect LEDS_TRIGGER_BACKLIGHTselect S3C_DEV_NANDselect S3C_DEV_USB_HOSThelpSay Y here to select support for the eilian240. Is a 10cm x 10cm boardavailable via various sources. It can come with a 3.5" or 7" touch LCD.

这样修改之后在选择配置缺省文件的时候直接选择mini2440_defconfig了

除此之外,还有一个地方需要改动,在eilian240_machine_init(void)函数中,把smdk_machine_init()函数调用注释掉,因为我们后面会编写自己的初始化函数,不需要调用smdk2440 原来的,同时修改时钟频率,修改如下:

static void __init eilian240_machine_init(void)

{

s3c24xx_fb_set_platdata(&eilian240_fb_info);

s3c_i2c0_set_platdata(NULL);

s3c_nand_set_platdata(&eilian240_nand_info);

platform_add_devices(eilian240_devices, ARRAY_SIZE(eilian240_devices));//    smdk_machine_init();}

修改时钟频率

static void __init eilian240_map_io(void)

{

s3c24xx_init_io(eilian240_iodesc, ARRAY_SIZE(eilian240_iodesc));s3c24xx_init_clocks(12000000);s3c24xx_init_uarts(eilian240_uartcfgs, ARRAY_SIZE(eilian240_uartcfgs));

}

e)关于机器码

首先,很关键的一点,内核在启动时,是通过bootloader 传入的机器码(MACH_TYPE)确定应启动哪种目标平台的。

打开/arch/arm/tools/mach-types 定位到最后一行添加机器码(深蓝色部分):

ctbu_gen2        MACH_CTBU_GEN2        CTBU_GEN2        3410

kmp_am17_01        MACH_KMP_AM17_01    KMP_AM17_01        3411

wtplug            MACH_WTPLUG        WTPLUG            3412

mx27su2            MACH_MX27SU2        MX27SU2            3413

nb31            MACH_NB31        NB31            3414

hjsdu            MACH_HJSDU        HJSDU            3415

td3_rev1        MACH_TD3_REV1        TD3_REV1        3416

eag_ci4000        MACH_EAG_CI4000        EAG_CI4000        3417

net5big_nand_v2        MACH_NET5BIG_NAND_V2    NET5BIG_NAND_V2        3418

cpx2            MACH_CPX2        CPX2            3419

net2big_nand_v2        MACH_NET2BIG_NAND_V2    NET2BIG_NAND_V2        3420

ecuv5            MACH_ECUV5        ECUV5            3421

hsgx6d            MACH_HSGX6D        HSGX6D            3422

dawad7            MACH_DAWAD7        DAWAD7            3423

sam9repeater        MACH_SAM9REPEATER    SAM9REPEATER        3424

eilian240        MACH_EILIAN240        EILIAN240        8000

在u-boot-2010.06/arch/arm/include/asm/mach-types.h 中定义相对应的机器码,这里注意这个机器码是我自己移植UBOOT的时候定义的

#define MACH_TYPE_CAYENNE              2874

#define MACH_TYPE_FUJI                 2875

#define MACH_TYPE_SYNOLOGY_6282        2876

#define MACH_TYPE_EM1SY                2877

#define MACH_TYPE_M502                 2878

#define MACH_TYPE_MATRIX518            2879

#define MACH_TYPE_TINY_GURNARD         2880

#define MACH_TYPE_SPEAR1310            2881#define MACH_TYPE_EILIAN240            8000

这需要两者相匹配,如果内核的机器码和bootloader 传入的不匹配,就会经常出现下面的错误:

Uncompressing Linux................................................................................................................................. done, booting

the kernel.             不动了

d0a490374022dcc6a0209537dfe413ae.gif

接着修改linux-2.6.39/arch/arm/mach-s3c2440/eilian240.c定位到文件末尾处MACHINE_START(S3C2440, "SMDK2440") , 将其修改为MACHINE_START(EILIAN240, "eilian240 development board")

notes:开发板运行后,在命令行终端输入:cat /proc/cpuinfo 可以看到我们添加的开发板信息,当然这个信息可以定制成我们需要的信息。

f)内核配置菜单中的MINI2440 选项和实际代码是如何关联的

在开始移植其他驱动之前,了解一些看起来比较“神秘”的常识,那就是运行make menuconfig 时,内核配置菜单中的MINI2440 选项是如何出现的。

加载缺省文件因为在x86平台下下执行此操作,系统默认的是x86平台,操作如下:

root@bootloader:/home/eilian/development/Linux/linux-2.6.39#cp arch/arm/configs/mini2440_defconfig .config

root@bootloader:/home/eilian/development/Linux/linux-2.6.39#make menuconfig

出现下图所示内核配置根菜单

4c77cd4b16ceafa277fdadc1c20872c7.gif

按上下箭头键移动到 System Type,按回车进入该子菜单,如图

877dea584ddead886e5336b9e9c0e740.gif

再找到S3C2440 Machines,按回车进入该子菜单,如图

5494e81a040c8db5512889ac68629e5d.gif

这样明白上面修改Linux-2.6.39/arch/arm/mach-s3c2440/目录下的Makefile和Kconfig为什么那样修改了吧。。

再打开 Linux-2.6.39/arch/arm/mach-s3c2440/Kconfig 看看

config MACH_EILIAN240

bool "eilian240 development board"

select CPU_S3C2440

select EEPROM_AT24

select NEW_LEDS

select LEDS_CLASS

select LEDS_TRIGGER

select LEDS_TRIGGER_BACKLIGHT

select S3C_DEV_NAND

select S3C_DEV_USB_HOST

help

Say Y here to select support for the eilian240. Is a 10cm x 10cm board

available via various sources. It can come with a 3.5" or 7" touch LCD.

现在明白了吧“eilian240 development board”正是在这个Kconfig 文件中定义说明的,当然你可以根据自己的喜好改为其他显示信息。这里的显示信息只是在内核配置菜单中出现的,记住“要让选择的配置实际起效,还需要根据此配置在Makefile 中添加相应的代码文件”再次打开Makefile看看:

# Machine support

obj-$(CONFIG_MACH_ANUBIS)    += mach-anubis.o

obj-$(CONFIG_MACH_OSIRIS)    += mach-osiris.o

obj-$(CONFIG_MACH_RX3715)    += mach-rx3715.o

obj-$(CONFIG_ARCH_S3C2440)    += mach-smdk2440.o

obj-$(CONFIG_MACH_NEXCODER_2440) += mach-nexcoder.o

obj-$(CONFIG_MACH_AT2440EVB) += mach-at2440evb.o

obj-$(CONFIG_MACH_MINI2440) += mach-mini2440.o

obj-$(CONFIG_MACH_NEO1973_GTA02) += mach-gta02.o

obj-$(CONFIG_MACH_RX1950) += mach-rx1950.o

obj-$(CONFIG_MACH_EILIAN240) += mach-eilian240.o

# extra machine support

这样,配置文件就跟实际的代码文件通过配置定义联系在一起了,这里的配置定义是“CONFIG_MACH_EILIAN240”,内核中还有很多类似的配置定义,并且有的配置定义还存在依赖关系,我们在此就不对它们详细说明了,随着对内核代码结构的不断熟悉,你就会逐渐学会分析和查找你所需要的各种配置和定义等。

g)移植Nand 驱动并更改分区信息(我总感觉NANDFLASH是linux设备驱动中比较复杂的了)

g.1:了解释内核已经支持的NANDFLASH类型

Linux2.6.39 已经自带了大部分Nand Flash 驱动,在linux-2.6.39/drivers/mtd/nand/nand_ids.c 文件中,定义了所支持的各种Nand Flash 类型

struct nand_flash_dev nand_flash_ids[] = {

#ifdef CONFIG_MTD_NAND_MUSEUM_IDS

{"NAND 1MiB 5V 8-bit",        0x6e, 256, 1, 0x1000, 0},

{"NAND 2MiB 5V 8-bit",        0x64, 256, 2, 0x1000, 0},

{"NAND 4MiB 5V 8-bit",        0x6b, 512, 4, 0x2000, 0},

{"NAND 1MiB 3,3V 8-bit",    0xe8, 256, 1, 0x1000, 0},

{"NAND 1MiB 3,3V 8-bit",    0xec, 256, 1, 0x1000, 0},

{"NAND 2MiB 3,3V 8-bit",    0xea, 256, 2, 0x1000, 0},

{"NAND 4MiB 3,3V 8-bit",    0xd5, 512, 4, 0x2000, 0},

{"NAND 4MiB 3,3V 8-bit",    0xe3, 512, 4, 0x2000, 0},

{"NAND 4MiB 3,3V 8-bit",    0xe5, 512, 4, 0x2000, 0},

{"NAND 8MiB 3,3V 8-bit",    0xd6, 512, 8, 0x2000, 0},

{"NAND 8MiB 1,8V 8-bit",    0x39, 512, 8, 0x2000, 0},

{"NAND 8MiB 3,3V 8-bit",    0xe6, 512, 8, 0x2000, 0},

{"NAND 8MiB 1,8V 16-bit",    0x49, 512, 8, 0x2000, NAND_BUSWIDTH_16},

{"NAND 8MiB 3,3V 16-bit",    0x59, 512, 8, 0x2000, NAND_BUSWIDTH_16},

#endif

{"NAND 16MiB 1,8V 8-bit",    0x33, 512, 16, 0x4000, 0},

{"NAND 16MiB 3,3V 8-bit",    0x73, 512, 16, 0x4000, 0},

{"NAND 16MiB 1,8V 16-bit",    0x43, 512, 16, 0x4000, NAND_BUSWIDTH_16},

{"NAND 16MiB 3,3V 16-bit",    0x53, 512, 16, 0x4000, NAND_BUSWIDTH_16},

{"NAND 32MiB 1,8V 8-bit",    0x35, 512, 32, 0x4000, 0},

{"NAND 32MiB 3,3V 8-bit",    0x75, 512, 32, 0x4000, 0},

{"NAND 32MiB 1,8V 16-bit",    0x45, 512, 32, 0x4000, NAND_BUSWIDTH_16},

{"NAND 32MiB 3,3V 16-bit",    0x55, 512, 32, 0x4000, NAND_BUSWIDTH_16},

{"NAND 64MiB 1,8V 8-bit",    0x36, 512, 64, 0x4000, 0},

{"NAND 64MiB 3,3V 8-bit",    0x76, 512, 64, 0x4000, 0},

{"NAND 64MiB 1,8V 16-bit",    0x46, 512, 64, 0x4000, NAND_BUSWIDTH_16},

{"NAND 64MiB 3,3V 16-bit",    0x56, 512, 64, 0x4000, NAND_BUSWIDTH_16},

{"NAND 128MiB 1,8V 8-bit",    0x78, 512, 128, 0x4000, 0},

{"NAND 128MiB 1,8V 8-bit",    0x39, 512, 128, 0x4000, 0},

{"NAND 128MiB 3,3V 8-bit",    0x79, 512, 128, 0x4000, 0},

{"NAND 128MiB 1,8V 16-bit",    0x72, 512, 128, 0x4000, NAND_BUSWIDTH_16},

{"NAND 128MiB 1,8V 16-bit",    0x49, 512, 128, 0x4000, NAND_BUSWIDTH_16},

{"NAND 128MiB 3,3V 16-bit",    0x74, 512, 128, 0x4000, NAND_BUSWIDTH_16},

{"NAND 128MiB 3,3V 16-bit",    0x59, 512, 128, 0x4000, NAND_BUSWIDTH_16},

{"NAND 256MiB 3,3V 8-bit",    0x71, 512, 256, 0x4000, 0},

/*

* These are the new chips with large page size. The pagesize and the

* erasesize is determined from the extended id bytes,对于我们的是大页的NANDFLASH

*/

#define LP_OPTIONS (NAND_SAMSUNG_LP_OPTIONS | NAND_NO_READRDY | NAND_NO_AUTOINCR)

#define LP_OPTIONS16 (LP_OPTIONS | NAND_BUSWIDTH_16)

/*512 Megabit */

{"NAND 64MiB 1,8V 8-bit",    0xA2, 0,  64, 0, LP_OPTIONS},

{"NAND 64MiB 1,8V 8-bit",    0xA0, 0,  64, 0, LP_OPTIONS},

{"NAND 64MiB 3,3V 8-bit",    0xF2, 0,  64, 0, LP_OPTIONS},

{"NAND 64MiB 3,3V 8-bit",    0xD0, 0,  64, 0, LP_OPTIONS},

{"NAND 64MiB 1,8V 16-bit",    0xB2, 0,  64, 0, LP_OPTIONS16},

{"NAND 64MiB 1,8V 16-bit",    0xB0, 0,  64, 0, LP_OPTIONS16},

{"NAND 64MiB 3,3V 16-bit",    0xC2, 0,  64, 0, LP_OPTIONS16},

{"NAND 64MiB 3,3V 16-bit",    0xC0, 0,  64, 0, LP_OPTIONS16},

/* 1 Gigabit */

{"NAND 128MiB 1,8V 8-bit",    0xA1, 0, 128, 0, LP_OPTIONS},

{"NAND 128MiB 3,3V 8-bit",    0xF1, 0, 128, 0, LP_OPTIONS},

{"NAND 128MiB 3,3V 8-bit",    0xD1, 0, 128, 0, LP_OPTIONS},

{"NAND 128MiB 1,8V 16-bit",    0xB1, 0, 128, 0, LP_OPTIONS16},

{"NAND 128MiB 3,3V 16-bit",    0xC1, 0, 128, 0, LP_OPTIONS16},

{"NAND 128MiB 1,8V 16-bit",     0xAD, 0, 128, 0, LP_OPTIONS16},

/* 2 Gigabit */

{"NAND 256MiB 1,8V 8-bit",    0xAA, 0, 256, 0, LP_OPTIONS},

{"NAND 256MiB 3,3V 8-bit",    0xDA, 0, 256, 0, LP_OPTIONS},

{"NAND 256MiB 1,8V 16-bit",    0xBA, 0, 256, 0, LP_OPTIONS16},

{"NAND 256MiB 3,3V 16-bit",    0xCA, 0, 256, 0, LP_OPTIONS16},

/* 4 Gigabit */

{"NAND 512MiB 1,8V 8-bit",    0xAC, 0, 512, 0, LP_OPTIONS},

{"NAND 512MiB 3,3V 8-bit",    0xDC, 0, 512, 0, LP_OPTIONS},

{"NAND 512MiB 1,8V 16-bit",    0xBC, 0, 512, 0, LP_OPTIONS16},

{"NAND 512MiB 3,3V 16-bit",    0xCC, 0, 512, 0, LP_OPTIONS16},

/* 8 Gigabit */

{"NAND 1GiB 1,8V 8-bit",    0xA3, 0, 1024, 0, LP_OPTIONS},

{"NAND 1GiB 3,3V 8-bit",    0xD3, 0, 1024, 0, LP_OPTIONS},

{"NAND 1GiB 1,8V 16-bit",    0xB3, 0, 1024, 0, LP_OPTIONS16},

{"NAND 1GiB 3,3V 16-bit",    0xC3, 0, 1024, 0, LP_OPTIONS16},

/* 16 Gigabit */

{"NAND 2GiB 1,8V 8-bit",    0xA5, 0, 2048, 0, LP_OPTIONS},

{"NAND 2GiB 3,3V 8-bit",    0xD5, 0, 2048, 0, LP_OPTIONS},

{"NAND 2GiB 1,8V 16-bit",    0xB5, 0, 2048, 0, LP_OPTIONS16},

{"NAND 2GiB 3,3V 16-bit",    0xC5, 0, 2048, 0, LP_OPTIONS16},

/* 32 Gigabit */

{"NAND 4GiB 1,8V 8-bit",    0xA7, 0, 4096, 0, LP_OPTIONS},

{"NAND 4GiB 3,3V 8-bit",    0xD7, 0, 4096, 0, LP_OPTIONS},

{"NAND 4GiB 1,8V 16-bit",    0xB7, 0, 4096, 0, LP_OPTIONS16},

{"NAND 4GiB 3,3V 16-bit",    0xC7, 0, 4096, 0, LP_OPTIONS16},

/* 64 Gigabit */

{"NAND 8GiB 1,8V 8-bit",    0xAE, 0, 8192, 0, LP_OPTIONS},

{"NAND 8GiB 3,3V 8-bit",    0xDE, 0, 8192, 0, LP_OPTIONS},

{"NAND 8GiB 1,8V 16-bit",    0xBE, 0, 8192, 0, LP_OPTIONS16},

{"NAND 8GiB 3,3V 16-bit",    0xCE, 0, 8192, 0, LP_OPTIONS16},

/* 128 Gigabit */

{"NAND 16GiB 1,8V 8-bit",    0x1A, 0, 16384, 0, LP_OPTIONS},

{"NAND 16GiB 3,3V 8-bit",    0x3A, 0, 16384, 0, LP_OPTIONS},

{"NAND 16GiB 1,8V 16-bit",    0x2A, 0, 16384, 0, LP_OPTIONS16},

{"NAND 16GiB 3,3V 16-bit",    0x4A, 0, 16384, 0, LP_OPTIONS16},

/* 256 Gigabit */

{"NAND 32GiB 1,8V 8-bit",    0x1C, 0, 32768, 0, LP_OPTIONS},

{"NAND 32GiB 3,3V 8-bit",    0x3C, 0, 32768, 0, LP_OPTIONS},

{"NAND 32GiB 1,8V 16-bit",    0x2C, 0, 32768, 0, LP_OPTIONS16},

{"NAND 32GiB 3,3V 16-bit",    0x4C, 0, 32768, 0, LP_OPTIONS16},

/* 512 Gigabit */

{"NAND 64GiB 1,8V 8-bit",    0x1E, 0, 65536, 0, LP_OPTIONS},

{"NAND 64GiB 3,3V 8-bit",    0x3E, 0, 65536, 0, LP_OPTIONS},

{"NAND 64GiB 1,8V 16-bit",    0x2E, 0, 65536, 0, LP_OPTIONS16},

{"NAND 64GiB 3,3V 16-bit",    0x4E, 0, 65536, 0, LP_OPTIONS16},

/*

* Renesas AND 1 Gigabit. Those chips do not support extended id and

* have a strange page/block layout !  The chosen minimum erasesize is

* 4 * 2 * 2048 = 16384 Byte, as those chips have an array of 4 page

* planes 1 block = 2 pages, but due to plane arrangement the blocks

* 0-3 consists of page 0 + 4,1 + 5, 2 + 6, 3 + 7 Anyway JFFS2 would

* increase the eraseblock size so we chose a combined one which can be

* erased in one go There are more speed improvements for reads and

* writes possible, but not implemented now

*/

{"AND 128MiB 3,3V 8-bit",    0x01, 2048, 128, 0x4000,

NAND_IS_AND | NAND_NO_AUTOINCR |NAND_NO_READRDY | NAND_4PAGE_ARRAY |

BBT_AUTO_REFRESH

},

{NULL,}

};

/*

*    Manufacturer ID list

*/

struct nand_manufacturers nand_manuf_ids[] = {

{NAND_MFR_TOSHIBA, "Toshiba"},

{NAND_MFR_SAMSUNG, "Samsung"},

{NAND_MFR_FUJITSU, "Fujitsu"},

{NAND_MFR_NATIONAL, "National"},

{NAND_MFR_RENESAS, "Renesas"},

{NAND_MFR_STMICRO, "ST Micro"},

{NAND_MFR_HYNIX, "Hynix"},

{NAND_MFR_MICRON, "Micron"},

{NAND_MFR_AMD, "AMD"},

{0x0, "Unknown"}

};

既然对于ARM920T的核,Linux内核已经对大部分的NANDFLASH完美支持了,那还需修改什么呢?分区系统虽然对NANDFLASH进行了默认的分区,但这可能不是我们想要的,我们的分区得和UBOOT中对NANDFLASH的分区保持一致

g.2修改Nand Flash 分区表:那我怎么知道如何分啊?参考系统默认的,那系统默认的分区又在那里定义了?

对于S3C24XX这个CPU ,对于NANDFLASH这样的平台设备打开arch/arm/plat-s3c24xx/comm-smdk.c

/* NAND parititon from 2.4.18-swl5 */

static struct mtd_partition smdk_default_nand_part[] = {

[0] = {

.name    = "Boot Agent",

.size    = SZ_16K,

.offset    = 0,

},

[1] = {

.name    = "S3C2410 flash partition 1",

.offset = 0,

.size    = SZ_2M,

},

[2] = {

.name    = "S3C2410 flash partition 2",

.offset = SZ_4M,

.size    = SZ_4M,

},

[3] = {

.name    = "S3C2410 flash partition 3",

.offset    = SZ_8M,

.size    = SZ_2M,

},

[4] = {

.name    = "S3C2410 flash partition 4",

.offset = SZ_1M * 10,

.size    = SZ_4M,

},

[5] = {

.name    = "S3C2410 flash partition 5",

.offset    = SZ_1M * 14,

.size    = SZ_1M * 10,

},

[6] = {

.name    = "S3C2410 flash partition 6",

.offset    = SZ_1M * 24,

.size    = SZ_1M * 24,

},

[7] = {

.name    = "S3C2410 flash partition 7",

.offset = SZ_1M * 48,

.size    = MTDPART_SIZ_FULL,

}

};

static struct s3c2410_nand_set smdk_nand_sets[] = {

[0] = {

.name        = "NAND",

.nr_chips    = 1,

.nr_partitions    = ARRAY_SIZE(smdk_default_nand_part),

.partitions    = smdk_default_nand_part,

},

};

/* choose a set of timings which should suit most 512Mbit

* chips and beyond.

*/

static struct s3c2410_platform_nand smdk_nand_info = {

.tacls        = 20,

.twrph0        = 60,

.twrph1        = 20,

.nr_sets    = ARRAY_SIZE(smdk_nand_sets),

.sets        = smdk_nand_sets,

};

好了不多想了直接参考这个依葫芦画瓢的修改回到自己的板层文件

root@bootloader:/home/eilian/development/Linux/linux-2.6.39/arch/arm/mach-s3c2440#

打开mach-eilian240.c根据自己移植的UBOOT在里面添加对NANDFLASH分区的代码,代码如下

/* NAND Flash on eilian240 board */static struct mtd_partition eilian240_nand_part[] __initdata = {[0] = {.name    = "bootloader",.size    = SZ_1M,                                         //UBOOT大小1M.offset    = 0,},[1] = {.name    = "params",                            //存放参数.size    = SZ_128K,.offset    = SZ_1M,},[2] = {.name    = "kernel",.size    = 0x00500000,.offset    = SZ_1M + SZ_128K,           //内核},[3] = {.name    = "root",.offset    = SZ_1M + SZ_128K + 0x00500000,//根文件系统.size    = 1024 * 1024 * 1024,},[4] = {.name    = "nand",.offset    = 0,.size    = SZ_256M,                 //整个NANDFLASH 可有可无},};static struct s3c2410_nand_set eilian240_nand_sets[] __initdata = {[0] = {.name        = "nand",.nr_chips    = 1,.nr_partitions    = ARRAY_SIZE(eilian240_nand_part),.partitions    = eilian240_nand_part,.flash_bbt     = 1, /* we use u-boot to create a BBT */},};static struct s3c2410_platform_nand eilian240_nand_info __initdata = {.tacls        = 20,.twrph0        = 60,.twrph1        = 20,.nr_sets    = ARRAY_SIZE(eilian240_nand_sets),.sets        = eilian240_nand_sets,.ignore_unset_ecc = 1,};

将nand flash 设备注册到系统中

static struct platform_device *eilian240_devices[] __initdata = {

&s3c_device_ohci,

&s3c_device_lcd,

&s3c_device_wdt,

&s3c_device_i2c0,

&s3c_device_iis,

&s3c_device_nand,

};

传入eilian240_nand_info结构体��始化参数到内核中去

static void __init eilian240_machine_init(void)

{

s3c24xx_fb_set_platdata(&eilian240_fb_info);

s3c_i2c0_set_platdata(NULL);

s3c_nand_set_platdata(&eilian240_nand_info);

platform_add_devices(eilian240_devices, ARRAY_SIZE(eilian240_devices));

//    smdk_machine_init();

}

加入必要的头文件

/*********nand*****/#include #include #include #include #include /*********nand*****/

保存退出

h)编译测试

root@bootloader:/home/eilian/development/Linux/linux-2.6.39# make uImage

等待很久!!!!!!!!

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:      Fri Dec  2 02:55:06 2011

Image Type:   ARM Linux Kernel Image (uncompressed)

Data Size:    2144304 Bytes = 2094.05 kB = 2.04 MB

Load Address: 30008000

Entry Point:  30008000

Image arch/arm/boot/uImage is ready

root@bootloader:/home/eilian/development/Linux/linux-2.6.39# cparch/arm/boot/uImage /tftpboot

下载uImage到板子上运行

打开超级终端(我这已经将uboot烧入到NANDFLASH)

U-Boot 2010.06 (Nov 29 2011 - 21:13:28)

DRAM:  64 MiB

Flash: 512 KiB

NAND:  dev_id = 218

NAND 256MiB 3,3V 8-bit256 MiB

In:    serial

Out:   serial

Err:   serial

Net:   dm9000

Device nand0 not found!

Hit any key to stop autoboot:  0

bootloader# tftp 32000000 uImage

dm9000 i/o: 0x20000300, id: 0x90000a46

DM9000: running in 16 bit mode

MAC: 08:00:3e:26:0a:5b

operating at unknown: 0 mode

Using dm9000 device

TFTP from server 211.67.217.136; our IP address is 211.67.217.138

Filename 'uImage'.

Load address: 0x32000000

Loading: T #################T ################################################

#################################################################

#############################################################T ##T ##

#############################################T #################T ###

##T ###################T ############################################

##############T ############T ################################T #######T

#############################

done

Bytes transferred = 2144368 (20b870 hex)

bootloader# bootm 32000000

## Booting kernel from Legacy Image at 32000000 ...

Image Name:   Linux-2.6.39

Created:      2011-12-01  18:55:06 UTC

Image Type:   ARM Linux Kernel Image (uncompressed)

Data Size:    2144304 Bytes = 2 MiB

Load Address: 30008000

Entry Point:  30008000

Verifying Checksum ... OK

Loading Kernel Image ... OK

OK

Starting kernel ...

Uncompressing Linux... done, booting the kernel.

Linux version 2.6.39 (root@bootloader) (gcc version 4.3.2 (Sourcery G++ Lite 2008q3-72) ) #1 Fri Dec 2 02:54:32 CST 2011

CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177

CPU: VIVT data cache, VIVT instruction cache

Machine: eilian240 development board

Memory policy: ECC disabled, Data cache writeback

CPU S3C2440A (id 0x32440001)

S3C24XX Clocks, Copyright 2004 Simtec Electronics

S3C244X: core 405.000 MHz, memory 101.250 MHz, peripheral 50.625 MHz

CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on

Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16256

Kernel command line: noinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySAC0 mem=64M

PID hash table entries: 256 (order: -2, 1024 bytes)

Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)

Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)

Memory: 64MB = 64MB total

Memory: 60464k/60464k available, 5072k reserved, 0K highmem

Virtual kernel memory layout:

vector  : 0xffff0000 - 0xffff1000   (   4 kB)

fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)

DMA     : 0xffc00000 - 0xffe00000   (   2 MB)

vmalloc : 0xc4800000 - 0xf6000000   ( 792 MB)

lowmem  : 0xc0000000 - 0xc4000000   (  64 MB)

modules : 0xbf000000 - 0xc0000000   (  16 MB)

.init : 0xc0008000 - 0xc0029000   ( 132 kB)

.text : 0xc0029000 - 0xc03f7f30   (3900 kB)

.data : 0xc03f8000 - 0xc041bc80   ( 144 kB)

SLUB: Genslabs=13, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1

NR_IRQS:85

irq: clearing subpending status 00000003

irq: clearing subpending status 00000002

Console: colour dummy device 80x30

console [ttySAC0] enabled

Calibrating delay loop... 201.52 BogoMIPS (lpj=503808)

pid_max: default: 32768 minimum: 301

Mount-cache hash table entries: 512

CPU: Testing write buffer coherency: ok

gpiochip_add: gpios 288..303 (GPIOK) failed to register

gpiochip_add: gpios 320..334 (GPIOL) failed to register

gpiochip_add: gpios 352..353 (GPIOM) failed to register

NET: Registered protocol family 16

S3C2440: Initialising architecture

S3C2440: IRQ Support

S3C244X: Clock Support, DVS off

bio: create slab at 0

usbcore: registered new interface driver usbfs

usbcore: registered new interface driver hub

usbcore: registered new device driver usb

s3c-i2c s3c2440-i2c: slave address 0x10

s3c-i2c s3c2440-i2c: bus frequency set to 98 KHz

s3c-i2c s3c2440-i2c: i2c-0: S3C I2C adapter

Advanced Linux Sound Architecture Driver Version 1.0.24.

NET: Registered protocol family 2

IP route cache hash table entries: 1024 (order: 0, 4096 bytes)

TCP established hash table entries: 2048 (order: 2, 16384 bytes)

TCP bind hash table entries: 2048 (order: 1, 8192 bytes)

TCP: Hash tables configured (established 2048 bind 2048)

TCP reno registered

UDP hash table entries: 256 (order: 0, 4096 bytes)

UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)

NET: Registered protocol family 1

RPC: Registered udp transport module.

RPC: Registered tcp transport module.

RPC: Registered tcp NFSv4.1 backchannel transport module.

JFFS2 version 2.2. (NAND) © 2001-2006 Red Hat, Inc.

ROMFS MTD (C) 2007 Red Hat, Inc.

msgmni has been set to 118

io scheduler noop registered

io scheduler deadline registered

io scheduler cfq registered (default)

Console: switching to colour frame buffer device 60x53

fb0: s3c2410fb frame buffer device

s3c2440-uart.0: ttySAC0 at MMIO 0x50000000 (irq = 70) is a S3C2440

s3c2440-uart.1: ttySAC1 at MMIO 0x50004000 (irq = 73) is a S3C2440

s3c2440-uart.2: ttySAC2 at MMIO 0x50008000 (irq = 76) is a S3C2440

brd: module loaded

S3C24XX NAND Driver, (c) 2004 Simtec Electronics

s3c24xx-nand s3c2440-nand: Tacls=3, 29ns Twrph0=7 69ns, Twrph1=3 29nss3c24xx-nand s3c2440-nand: NAND soft ECCNAND device: Manufacturer ID: 0xec, Chip ID: 0xda (Samsung NAND 256MiB 3,3V 8-bit)Creating 5 MTD partitions on "nand":0x000000000000-0x000000100000 : "bootloader"uncorrectable error :0x000000100000-0x000000120000 : "params"ftl_cs: FTL header not found.0x000000120000-0x000000620000 : "kernel"ftl_cs: FTL header not found.0x000000620000-0x000040620000 : "root"

mtd: partition "root" extends beyond the end of device "nand" -- size truncated to 0xf9e0000ftl_cs: FTL header not found.0x000000000000-0x000040000000 : "nand"mtd: partition "nand" extends beyond the end of device "nand" -- size truncated to 0x10000000uncorrectable error :

dm9000 Ethernet Driver, V1.31

ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver

s3c2410-ohci s3c2410-ohci: S3C24XX OHCI

s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1

s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000

hub 1-0:1.0: USB hub found

hub 1-0:1.0: 2 ports detected

usbcore: registered new interface driver libusual

mousedev: PS/2 mouse device common for all mice

S3C24XX RTC, (c) 2004,2006 Simtec Electronics

i2c /dev entries driver

S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics

s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled

cpuidle: using governor ladder

sdhci: Secure Digital Host Controller Interface driver

sdhci: Copyright(c) Pierre Ossman

usbcore: registered new interface driver usbhid

usbhid: USB HID core driver

ALSA device list:

No soundcards found.

TCP cubic registered

NET: Registered protocol family 17

Registering the dns_resolver key type

drivers/rtc/hctosys.c: unable to open rtc device (rtc0)

List of all partitions:

1f00            1024 mtdblock0  (driver?)1f01             128 mtdblock1  (driver?)1f02            5120 mtdblock2  (driver?)1f03          255872 mtdblock3  (driver?)1f04          262144 mtdblock4  (driver?)           //因为没有文件系统所以出错啊

No filesystem could mount root, tried:  ext3 cramfs vfat msdos romfs

Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,2)

[] (unwind_backtrace+0x0/0xec) from [] (panic+0x54/0x184)

[] (panic+0x54/0x184) from [] (mount_block_root+0x1d0/0x210)

[] (mount_block_root+0x1d0/0x210) from [] (mount_root+0xa0/0xc0)

[] (mount_root+0xa0/0xc0) from [] (prepare_namespace+0x164/0x1bc)

[] (prepare_namespace+0x164/0x1bc) from [] (kernel_init+0xfc/0x138)

[] (kernel_init+0xfc/0x138) from [] (kernel_thread_exit+0x0/0x8)

/*********************************************************************************************************************************

关注上面深蓝色字体哈。。是否发现点什么。。。0b1331709591d260c1c78e86d0c51c18.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值