kernel-2.6.32.6移植到s3c6410

终于将最新的kernel-2.6.32.6移植到了s3c6410上运行!

1.从www.kernel.org上下载kernel-2.6.32.6.tar.bz2

2.解压tar jxfv kernel-2.6.32.6.tar.bz2

3.cd linux-2.6.32.6/

4.vi Makefile,修改

#ARCH ?= $(SUBARCH)

#CROSS_COMPILE ?=

ARCH ?= arm

CROSS_COMPILE   ?= /usr/local/arm/4.3.1-eabi-armv6/usr/bin/arm-linux-

 

5.这样修改后就可以使用

make s3c6400_defconfig

来生成对s3c6410的支持。 因为arch/arm/configs下面只有s3c6400_defconfig和6410

最相近。

6.make menuconfig

System Type -> 

ARM system type (Samsung S3C64XX) --->

[*] SMDK6410

[*] Support ARM V6K processor extensions

[*] Support Thumb user binaries

Kernel Features ->

[*] Use the ARM EABI to compile the kernel 

[*] Allow old ABI binaries to run with this kernel (EXPERIMENTAL)

Boot options ->

console=ttySAC0,115200 root=/dev/mtdblock4 rdinit=/init8 init=/linuxrc

Floating point emulation ->

[*] NWFPE math emulation

[*] VFP-format floating point maths

Device Drivers ->

<*> Memory Technology Device (MTD) support  --->

[*]   MTD partitioning support

<*>   Direct char device access to MTD devices  (MTD_CHAR)

<*>   Caching block device access to MTD devices (MTD_BLOCK) yaffs2依赖

<*>   NAND Device Support  ---> 

<*>   NAND Flash support for Samsung S3C SoCs

[*]     Samsung S3C NAND Hardware ECC 

 

7.编译make

8.烧写进去,可以运行,启动不久就挂掉,都没识别出NAND,所以,将2.6.27里面对nand分区的

支持移过来。

arch/arm/mach-s3c6410/mach-smdk6410.c

添加:

 

#include <plat/nand.h>

#include <linux/mtd/mtd.h>

#include <linux/mtd/partitions.h>

 

#define CONFIG_SPLIT_ROOT_FOR_ANDROID 1

#define NAND_128MB

//#define NAND_256MB

//#define NAND_1GB

static struct mtd_partition smdk6410_nand_part[] = {

#if defined(CONFIG_SPLIT_ROOT_FOR_ANDROID)

{

.name = "misc",

.offset = (768*SZ_1K), /* for 

 

bootloader */

.size = (256*SZ_1K),

.mask_flags = MTD_CAP_NANDFLASH,

},

{

.name = "recovery",

.offset = MTDPART_OFS_APPEND,

.size = (5*SZ_1M),

//  .mask_flags = MTD_CAP_NANDFLASH,

},

{

.name = "kernel",

.offset = MTDPART_OFS_APPEND,

.size = (3*SZ_1M),

},

{

.name = "ramdisk",

.offset = MTDPART_OFS_APPEND,

.size = (1*SZ_1M),

},

#ifdef NAND_128MB     

{

.name = "system",

.offset = MTDPART_OFS_APPEND,

.size = (67*SZ_1M),

},

{

.name = "cache",

.offset = MTDPART_OFS_APPEND,

.size = (13*SZ_1M),

},   

#endif

#ifdef NAND_256MB   

{

.name = "system",

.offset = MTDPART_OFS_APPEND,

.size = (128*SZ_1M),

},

{

.name = "cache",

.offset = MTDPART_OFS_APPEND,

.size = (67*SZ_1M),

},   

#endif

#ifdef NAND_1GB

{

.name = "system",

.offset = MTDPART_OFS_APPEND,

.size = (512*SZ_1M),

},

{

.name = "cache",

.offset = MTDPART_OFS_APPEND,

.size = (67*SZ_1M),

},

#endif        

{

.name = "userdata",

.offset = MTDPART_OFS_APPEND,

.size = MTDPART_SIZ_FULL,

}

#else

{

.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 = (48*SZ_1M),

},

#endif

{

.name = "File System",

.offset = MTDPART_OFS_APPEND,

.size = MTDPART_SIZ_FULL,

}

#endif

 

};

 

struct s3c_nand_mtd_info smdk6410_nand_mtd_part_info = {

.chip_nr = 1,

.mtd_part_nr = ARRAY_SIZE(smdk6410_nand_part),

.partition = smdk6410_nand_part,

};

 

static struct platform_device *smdk6410_devices[] __initdata = {

。。。。。。

 

&smdk6410_smsc911x,

&s3c_device_nand,   //添加这行

};

 

static void __init smdk6410_map_io(void)

{

u32 tmp;

s3c_device_nand.name = "s3c6410-nand";    //jeff. 添加这行,覆盖默认的"s3c2410-nand"

。。。。

}

static void __init smdk6410_machine_init(void)

{

s3c_i2c0_set_platdata(NULL);

s3c_i2c1_set_platdata(NULL);

s3c_fb_set_platdata(&smdk6410_lcd_pdata);

 

s3c_device_nand.dev.platform_data = &smdk6410_nand_mtd_part_info; //jeff.添加

。。。

}

 

drivers/mtd/nand目录下

从2.6.27此目录下copy s3c-nand.c到2.6.32.6中。

vi Kconfig,MTD_NAND_S3C2410_HWECC替换为MTD_NAND_S3C_HWECC(为了使用2.6.27中的s3c-nand.c代替

 

s3c2410.c)

vi Makefile,

obj-$(CONFIG_MTD_NAND_S3C2410) += s3c_nand.o    #s3c2410.o  #jeff

 

这样,NAND部分完成,正常的话会打印出类似信息:

S3C NAND Driver, (c) 2008 Samsung Electronics

S3C NAND Driver is using hardware ECC.

NAND device: Manufacturer ID: 0xec, Chip ID: 0xd3 (Samsung NAND 1GiB 3,3V 8-bit)

Creating 7 MTD partitions on "NAND 1GiB 3,3V 8-bit":

0x0000000c0000-0x000000100000 : "misc"

0x000000100000-0x000000600000 : "recovery"

0x000000600000-0x000000900000 : "kernel"

0x000000900000-0x000000a00000 : "ramdisk"

0x000000a00000-0x000004d00000 : "system"

0x000004d00000-0x000005a00000 : "cache"

0x000005a00000-0x000040000000 : "userdata"

这说明分区已经OK。

 

9.移植yaffs文件系统

下载

http://www.aleph1.co.uk/cgi-bin/viewcvs.cgi/yaffs2.tar.gz?view=tar

也可以分别查看每个文件

http://www.aleph1.co.uk/cgi-bin/viewcvs.cgi/yaffs2/

 

参考:http://blog.chinaunix.net/u1/38994/showart_2029707.html

如下

--------------------------------------------------------------------

yaffs2官网-源码下载
yaffs2.tar.gz

luther@gliethttp:~$ tar zvxf cvs-root.tar.gz

luther@gliethttp:~/cvs/yaffs2$ vim README-linux-patch

可以看到向linux内核源码追加yaffs2的方法,我们将仿照该命令为linux-2.6.30.4内核源码安装yaffs2文件

 

系统.

./patch-ker.sh c /usr/src/linux

luther@gliethttp:~/cvs/yaffs2$ ./patch-ker.sh c /luther/linux-2.6.30.4/

luther@gliethttp:~/cvs/yaffs2$ vim /luther/linux-2.6.30.4/fs/Kconfig

luther@gliethttp:~/cvs/yaffs2$ vim /luther/linux-2.6.30.4/fs/Makefile

可以看到都已经自动添加了yaffs2支持和编译.

luther@gliethttp:~/cvs/yaffs2$ ls /luther/linux-2.6.30.4/fs/yaffs2/

devextras.h           yaffs_guts.h        yaffs_packedtags1.c

Kconfig               yaffsinterface.h    yaffs_packedtags1.h

Makefile              yaffs_mtdif1.c      yaffs_packedtags2.c

moduleconfig.h        yaffs_mtdif1.h      yaffs_packedtags2.h

yaffs_checkptrw.c     yaffs_mtdif2.c      yaffs_qsort.c

yaffs_checkptrw.h     yaffs_mtdif2.h      yaffs_qsort.h

yaffs_ecc.c           yaffs_mtdif.c       yaffs_tagscompat.c

yaffs_ecc.h           yaffs_mtdif.h       yaffs_tagscompat.h

yaffs_fs.c            yaffs_nand.c        yaffs_tagsvalidity.c

yaffs_getblockinfo.h  yaffs_nandemul2k.h  yaffs_tagsvalidity.h

yaffs_guts.c          yaffs_nand.h        yportenv.h

 

luther@gliethttp:/luther/linux-2.6.30.4$ make menuconfig

就可以看到

File systems  --->

[*] Miscellaneous filesystems  --->

< >   YAFFS2 file system support (NEW)

--------------------------------------------------------------------

要注意的是,新的yaffs已经添加了对新版内核文件系统的支持,之前我想把现在2.6.27

上的yaffs2直接移植过来,但碰到了.write_begin和.write_end的问题。新版已经添加了

对新内核读写函数变化的支持,yaffs_fs.c中:

 

#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 27))

#define YAFFS_USE_WRITE_BEGIN_END 1

#else

#define YAFFS_USE_WRITE_BEGIN_END 0

#endif

 

#if (YAFFS_USE_WRITE_BEGIN_END != 0)

static int yaffs_write_begin(struct file *filp, struct address_space *mapping,

loff_t pos, unsigned len, unsigned flags,

struct page **pagep, void **fsdata);

static int yaffs_write_end(struct file *filp, struct address_space *mapping,

loff_t pos, unsigned len, unsigned copied,

struct page *pg, void *fsdadata);

#else

static int yaffs_prepare_write(struct file *f, struct page *pg,

unsigned offset, unsigned to);

static int yaffs_commit_write(struct file *f, struct page *pg, unsigned offset,

unsigned to);

#endif

static struct address_space_operations yaffs_file_address_operations = {

.readpage = yaffs_readpage,

.writepage = yaffs_writepage,

#if (YAFFS_USE_WRITE_BEGIN_END > 0)

.write_begin = yaffs_write_begin,

.write_end = yaffs_write_end,

#else

.prepare_write = yaffs_prepare_write,

.commit_write = yaffs_commit_write,

#endif

};

 

按参考文档说的打上patch就可以在File systems -> [*] Miscellaneous filesystems  --->下面看得到

  ¦ ¦      <*>   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 YAFFS from doing ECC on tags by default                   ¦ ¦  

  ¦ ¦      [ ]       Disable lazy loading                                              ¦ ¦  

  ¦ ¦      [ ]     Turn off wide tnodes                                                ¦ ¦  

  ¦ ¦      [ ]     Force chunk erase check                                             ¦ ¦  

  ¦ ¦      [*]     Cache short names in RAM                                            ¦ ¦  

  ¦ ¦      [ ]     Empty lost and found on boot                 

 

因为s3c6410有硬件ECC,并且内核menuconfig时也选上了“Samsung S3C NAND Hardware ECC”,那么这里

 

的 [*]       Disable YAFFS from doing ECC on tags by default 选项要选上,不选上的话默认是会去

做yaffs自己的ECC动作,而内核中s3c-nand.c中的ECC和这个ECC不同,导致一挂载文件系统就读不出来,而

 

用之前正常的kernel-2.6.27再烧进去也还是不能挂载,kernel-2.6.27内核下再次烧写可用的yaffs_rootfs

 

又是可以正常进入busybox的,说明文件系统已经坏了,找了好久,比较了新的yaffs和2.6.27中使用的

 

yaffs的区别,就锁定在这个选项!

 

10.设置好后,编译,此时应该可以顺利进入shell.

 

 

注:当我移植完,再进入到www.kernel.org看时,最新版本已经到了kernel-2.6.32.7。 天啦!怎么跟得上这节奏~~

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值