linux-2.6.38到tiny6410的移植手册(1):nand flash

发布者:HarmonyJoy最新更新时间:2024-10-15 来源: cnblogs关键字:linux-2  6  tiny6410  nand  flash 手机看文章 扫描二维码
随时随地手机看文章

环境 VirtualBox+ubuntu 10.04
编译器,友善自带arm-linux-gcc-4.5.1-v6-vfp-20101103.tgz
硬件,tiny6410,核心板号1107

1、下载linux-2.6.38的源码,ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.38.tar.bz2
2、解压 tar xvfj /mnt/ubuntu/linux-2.6.38.tar.bz2 -C .
3、vi Makefile       191行改为    ARCH            ?= arm
4、cp arch/arm/configs/s3c6400_defconfig .config
5、make menuconfig
5、General setup->(/usr/4.5.1/bin/arm-linux-) Cross-compiler tool prefix    我将编译器解压到了/usr/4.5.1目录
       System Type->[*] MINI6410   选上,其他的可以去掉,不确定的可以参考友善之臂的

这样编译出来的内核是可以被uboot引导的,然后是增加nand flash支持
vi arch/arm/mach-s3c64xx/mach-mini6410.c
第117行
struct mtd_partition mini6410_nand_part[] = {            
    {
        .name        = 'Bootloader',
        .offset        = 0,
        .size        = (4 * 128 *SZ_1K),
        .mask_flags    = MTD_CAP_NANDFLASH,
    },
    {
        .name        = 'Kernel',
        .offset        = (4 * 128 *SZ_1K),
        .size        = (5*SZ_1M) ,
        .mask_flags    = MTD_CAP_NANDFLASH,
    },
    {
        .name        = 'File System',
        .offset        = MTDPART_OFS_APPEND,
        .size        = MTDPART_SIZ_FULL,
    }
};       //update at 2011-8-26 经过测试发现,这里改完后根本不起作用,甚至将整个注释也无妨,估计分区已经固死在后面的s3c_nand_mlc.fo中

drivers/mtd/nand/s3c_nand.c和arch/arm/plat-samsung/include/plat/regs-nand.h两个文件可以从友善的源码中
拷贝过来,这是他们自己写的,当然drivers/mtd/nand/s3c_nand_mlc.fo也要拷贝过来,这是友善没有开源的一个驱动之一,
所以不用研究了,拷过来就是了。

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

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


修改drivers/mtd/nand/nand_base.c文件


修改方法如下,“-”就是要去掉的内容,“+”就是要增加的内容,@@后面的是行号,
嫌麻烦的的直接将drivers/mtd/nand/nand_base.c拷过来覆盖掉

嘿嘿,下面是我diff出来的东西。


@@ -342,7 +342,7 @@
  */
static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip)
{
-    int page, chipnr, res = 0;
+    int page, res = 0;
     struct nand_chip *chip = mtd->priv;
     u16 bad;

@@ -351,6 +351,8 @@

     page = (int)(ofs >> chip->page_shift) & chip->pagemask;

+#if 0
+    /* Moved to nand_block_checkbad() for chip specify support */
     if (getchip) {
         chipnr = (int)(ofs >> chip->chip_shift);

@@ -359,6 +361,7 @@
         /* Select the NAND device */
         chip->select_chip(mtd, chipnr);
     }
+#endif

     if (chip->options & NAND_BUSWIDTH_16) {
         chip->cmdfunc(mtd, NAND_CMD_READOOB, chip->badblockpos & 0xFE,
@@ -378,8 +381,10 @@
     else
         res = hweight8(bad) < chip->badblockbits;

+#if 0
     if (getchip)
         nand_release_device(mtd);
+#endif

     return res;
}
@@ -477,9 +482,26 @@
                    int allowbbt)
{
     struct nand_chip *chip = mtd->priv;
+    int chipnr, res = 0;
+
+    /* Chip specify block_bad() support */
+    if (!chip->bbt) {
+        if (getchip) {
+            chipnr = (int)(ofs >> chip->chip_shift);

-    if (!chip->bbt)
-        return chip->block_bad(mtd, ofs, getchip);
+            nand_get_device(chip, mtd, FL_READING);
+
+            /* Select the NAND device */
+            chip->select_chip(mtd, chipnr);
+        }
+
+        res = chip->block_bad(mtd, ofs, getchip);
+
+        if (getchip)
+            nand_release_device(mtd);
+
+        return res;
+    }

     /* Return info from the table */
     return nand_isbad_bbt(mtd, ofs, allowbbt);
@@ -3002,23 +3024,15 @@
                 id_data[0] == NAND_MFR_SAMSUNG &&
                 (chip->cellinfo & NAND_CI_CELLTYPE_MSK) &&
                 id_data[5] != 0x00) {
+            int __oobsz[] = { 0, 128, 218, 400 };
             /* Calc pagesize */
             mtd->writesize = 2048 << (extid & 0x03);
             extid >>= 2;
             /* Calc oobsize */
-            switch (extid & 0x03) {
-            case 1:
-                mtd->oobsize = 128;
-                break;
-            case 2:
-                mtd->oobsize = 218;
-                break;
-            case 3:
-                mtd->oobsize = 400;
-                break;
-            default:
+            if (extid & 0x10) {
                 mtd->oobsize = 436;
-                break;
+            } else {
+                mtd->oobsize = __oobsz[(extid & 0x03)];
             }
             extid >>= 2;
             /* Calc blocksize */
@@ -3099,16 +3113,21 @@

     /* Calculate the address shift from the page size */
     chip->page_shift = ffs(mtd->writesize) - 1;
+
     /* Convert chipsize to number of pages per chip -1. */
-    chip->pagemask = (chip->chipsize >> chip->page_shift) - 1;
+    if (!chip->pagemask) {
+        chip->pagemask = (chip->chipsize >> chip->page_shift) - 1;
+    }

     chip->bbt_erase_shift = chip->phys_erase_shift =
         ffs(mtd->erasesize) - 1;
-    if (chip->chipsize & 0xffffffff)
-        chip->chip_shift = ffs((unsigned)chip->chipsize) - 1;
-    else {
-        chip->chip_shift = ffs((unsigned)(chip->chipsize >> 32));
-        chip->chip_shift += 32 - 1;
+    if (!chip->chip_shift) {
+        if (chip->chipsize & 0xffffffff)
+            chip->chip_shift = ffs((unsigned)chip->chipsize) - 1;
+        else {
+            chip->chip_shift = ffs((unsigned)(chip->chipsize >> 32));
+            chip->chip_shift += 32 - 1;
+        }
     }

     /* Set the bad block position */
@@ -3126,8 +3145,11 @@
      */
     if ((chip->cellinfo & NAND_CI_CELLTYPE_MSK) &&
             (*maf_id == NAND_MFR_SAMSUNG ||
-             *maf_id == NAND_MFR_HYNIX))
-        chip->options |= NAND_BBT_SCANLASTPAGE;
+             *maf_id == NAND_MFR_HYNIX)) {
+        if (mtd->writesize < 4096) {
+            chip->options |= NAND_BBT_SCANLASTPAGE;
+        }
+    }
     else if ((!(chip->cellinfo & NAND_CI_CELLTYPE_MSK) &&
                 (*maf_id == NAND_MFR_SAMSUNG ||
                  *maf_id == NAND_MFR_HYNIX ||
    
              
然后修改drivers/mtd/nand/Kconfig和drivers/mtd/nand/Makefile文件
在drivers/mtd/nand/Kconfig  238行增加
config MTD_NAND_S3C
    tristate 'NAND Flash support for S3C SoC'
    depends on (ARCH_S3C64XX || ARCH_S5P64XX || ARCH_S5PC1XX) && MTD_NAND
    help
      This enables the NAND flash controller on the S3C.

      No board specfic support is done by this driver, each board
      must advertise a platform_device for the driver to attach.

config MTD_NAND_S3C_DEBUG
    bool 'S3C NAND driver debug'
    depends on MTD_NAND_S3C
    help
      Enable debugging of the S3C NAND driver

configMTD_NAND_S3C_HWECC
    bool 'S3C NAND Hardware ECC'
    depends on MTD_NAND_S3C
        help
      Enable the use of the S3C's internal ECC generator when
      using NAND. Early versions of the chip have had problems with
      incorrect ECC generation, and if using these, the default of
      software ECC is preferable.

      If you lay down a device with the hardware ECC, then you will
      currently not be able to switch to software, as there is no
      implementation for ECC method used by the S3C


drivers/mtd/nand/Makefile中20行增加
obj-$(CONFIG_MTD_NAND_S3C)            += s3c_nand.o

[1] [2]
关键字:linux-2  6  tiny6410  nand  flash 引用地址:linux-2.6.38到tiny6410的移植手册(1):nand flash

上一篇:移植yaffs2 文件系统
下一篇:linux-2.6.38到tiny6410的移植手册(连载4)__USB设备(U盘,摄像头,wifi)

推荐阅读最新更新时间:2026-03-25 09:02

linux-2.6.38tiny6410移植手册(连载1)__nand flash
2440的linux移植手册满天飞,到了6410怎么就没有了呢? 既然源码都给了,为什么不把移植步骤写出来,好让大家学习呢? 今日,小弟自搞奋勇,想自己移植一遍linux-2.6.38,参考友善给的源码,觉得既然源码都有了,想发掘移植步骤应该不难吧,嘿嘿 环境 VirtualBox+ubuntu 10.04 编译器,友善自带arm-linux-gcc-4.5.1-v6-vfp-20101103.tgz 硬件,tiny6410,核心板号1107 linux-2.6.38到tiny6410的移植手册(连载2)__网卡&NF http://www.arm9home.net/read.php?tid-14211.html linux
[单片机]
linux-2.6.38tiny6410移植手册(连载4)__USB设备(U盘,摄像头,wifi)
今天来讲讲一些USB设备(U盘,摄像头,wifi)的驱动吧,它的特点是内核已经带非常完善的驱动了, 我们需要的就是配置而已,和很少的修改而已。 一、首先是U盘得支持。 1、vi arch/arm/mach-s3c64xx/mach-mini6410.c 124行增加 /* Initializes OTG Phy. to output 48M clock */ void s3c_otg_phy_config(int enable) { u32 val; if (enable) { __raw_writel(0x0, S3C_PHYPWR); /* Power up */ val = _
[单片机]
linux-2.6.<font color='red'>38</font>到<font color='red'>tiny6410</font>的<font color='red'>移植</font><font color='red'>手册</font>(连载4)__USB设备(U盘,摄像头,wifi)
基于K9F2G08U0A的Nand Flash操作和电路原理
S3C2440内部集成了一个Nand flash控制器。S3C2440的Nand flash控制器包含了如下的特性: 一个引导启动单元 Nand Flash存储器接口,支持8位或16位的每页大小为256字,512字节,1K字和2K字节的Nand flash 软件模式:用户可以直接访问Nand Flash存储器,此特性可以用于Nand Flash存储器的读、擦除和编程。 S3C2440支持8/16位的Nand Flash存储器接口总线 硬件ECC生成,检测和指示(软件纠错)。 Steppingstone接口,支持大/小端模式的按字节/半字/字访问。 我用的开发板是天嵌的TQ2440,板子用到的Nand Flash是S
[单片机]
基于K9F2G08U0A的<font color='red'>Nand</font> <font color='red'>Flash</font>操作和电路原理
OK6410 tftp下载内核、文件系统以及nand flash地址相关整理、总结
飞凌官方提供了一键下载烧写linux的方式,相对来说比较方便,但是对于开发来说不够灵活,因此这篇文章把tftp相关的点介绍一下,整理下其中遇到的一些问题。 一键烧写本质上是启动位于SD卡中的Uboot,通过uboot读取sd卡中的文件到SRAM最后通过nand指令实现一键烧写,这一块可以参考飞凌提供 的uboot源码中includeconfigs 中的smdk6410.h 的529行,代码如下: 代码1: 1 #elif defined(FORLINX_BOOT_SD) 2 #define FORLINX_DEBUG 3 #define CONFIG_MMC 1 4 #define CONFIG_LCD 5 #def
[单片机]
S3C2440的内存情况在NAND FLASH或者NOR FLASH启动的情况下
1,从NANDFLASH启动时,在ARM上电时,ARM会自动把NANDFLASH前4K的内容拷贝到S3C2440内部SRAM中,同时把SRAM的地址映射到0X00000000。ARM上电后会从SRAM处开始运行。 2,从NOR FLASH启动时,因为NORFLASH接在bank0。地址映射是0X00000000。所以ARM上电后直接运行NORFLASH里的程序。此时S3C2440内部SRAM地址为0X40000000。 3,ARM上电启动都是从0X00000000开始运行。但是对于复位程序入口,ResetEntry的值在ARM上电运行时是0X00000000,在JTAG仿真时是0X30000000。这个值很关键,在拷贝程序
[单片机]
S3C2440的内存情况在<font color='red'>NAND</font> <font color='red'>FLASH</font>或者NOR <font color='red'>FLASH</font>启动的情况下
HI3531的nand flash测试
void NAND_Init() { *(unsigned int *)(0x20030000 + 0xd0) = 7; delay_x(0X5000); *(unsigned int *)(0x20030000 + 0xd0) = 6; delay_x(0X5000); *(unsigned int *)(0x200f0000 + 0x1fc) = 0;//muxctrl_reg127 NF_DQ0 管脚复用控制寄存器 *(unsigned int *)(0x200f0000 + 0x200) = 0; *(unsigned int *)(0x200f0000 + 0x204) = 0; *(unsigned int
[单片机]
S3c2440处理器中nor flash启动和nand flash启动问题
S3c2440是三星公司推出的一款基于ARM920T的处理器,采用ARM内核,不同于单片机,无片上rom与ram,必须搭配相应的外围电路进行使用,现在,让我们从零开始进行这一块MCU的学习,为了入门简单方便,前期我不会搭载任何操作系统,本手册写到哪算哪. 1.什么是nor flash启动和nand flash启动 在任何视屏教程里面,都会告诉你一个开关左右选择就能norflash启动或者nand flash启动,norflash启动能直接运行代码,nand flash启动不能直接运行代码,可是为什么呢? 要知道这一点,首先要明白nandflash和norflash的区别,首先,norflash是随机存储介质,也就是说,对n
[单片机]
S3c2440处理器中nor <font color='red'>flash</font>启动和<font color='red'>nand</font> <font color='red'>flash</font>启动问题
S3C2410之NAND Flash MTD配置
1 ./drivers/mtd/nand/s3c2410.c static void s3c2410_nand_init_chip(struct s3c2410_nand_info *info, struct s3c2410_nand_mtd *nmtd, struct s3c2410_nand_set *set) 将NAND_ECC_SOFT改为NAND_ECC_NONE 2 ./arch/arm/plat-s3c24xx/common-smdk.c static struct mtd_partition smdk_default_nand_
[单片机]
小广播
最新单片机文章
何立民专栏 单片机及嵌入式宝典

北京航空航天大学教授,20余年来致力于单片机与嵌入式系统推广工作。

厂商技术中心

 
EEWorld订阅号

 
EEWorld服务号

 
汽车开发圈

 
机器人开发圈

电子工程世界版权所有 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2026 EEWORLD.com.cn, Inc. All rights reserved