我修改的代码已经上传到github上,地址:https://github.com/qiaoyuguo/u-boot-2014.04-mini2440.git

参考文档: s3c2440手册(下载地址) mini2440电路图(下载地址) K9F1G08数据手册(下载地址

参考文章:《mini2440移植uboot 2011.03(下)

前两篇博文: 《mini2440移植uboot 2014.04(一)

mini2440移植uboot 2014.04(二)

(五)添加nand flash支持

主要是基于参考mini2440 自带的uboot源代码进行修改。

用官方uboot启动时,得到的输出信息是128MiB的nand flash。查看芯片电路图可以知道是K9F系列芯片,而128MiB的芯片只能是K9F1G08(128Mx8bits)。

在上一节执行uboot时,关于nand flash的显示信息如下:

NAND:  board_nand_init()
end of nand_init
hwcontrol(): 0xff 0x83
hwcontrol(): 0xffffffff 0x81
dev_ready
hwcontrol(): 0x90 0x83
hwcontrol(): 0x00 0x85
hwcontrol(): 0xffffffff 0x81
dev_ready
hwcontrol(): 0x90 0x83
hwcontrol(): 0x00 0x85
hwcontrol(): 0xffffffff 0x81
dev_ready
hwcontrol(): 0xffffffff 0x80
MiB

明显没有检测到nand flash.
整个调用入口是nand_init->nand_init_chip->board_nand_init,而board_nand_init函数位于drivers/mtd/nand/s3c2410_nand.c中 。

首先需要考虑的就是几个变量的值:tacls、twrph0、twrph1。

参考文章《uboot中nand flash控制器参数TACLS、TWRPH0和TWRPH1的确定(基于K9F2G08U0B)》,这三个值是根据时序来计算出来的。

根据K9F1G08手册第17页和第10页以及s3c2440手册587页,可以知道tacls=tCLS>12ns,twrph0=tWP>12ns,twrph1=tCLH>5ns。

而nand flash是根据HCLK时钟来计算,根据1:4:8的分频,HCLK=100MHZ,每个时钟=10ns.

可以将这三个值分别设置成2、2、1即可,但是为了保持和官方版本一致,我仍将其值设置成4、2、0.

根据2440手册第226页,其NFCONT寄存器中每一位的含义与s3c2410中的大部分都不相同,需要进行相应的修改。

我只是将mini2440中的uboot和当前代码合并,修改代码如下:

#ifdef CONFIG_S3C2410
#define S3C2410_NFCONF_EN (1<<15)
#define S3C2410_NFCONF_512BYTE (1<<14)
#define S3C2410_NFCONF_4STEP (1<<13)
#define S3C2410_NFCONF_INITECC (1<<12)
#define S3C2410_NFCONF_nFCE (1<<11)
#define S3C2410_NFCONF_TACLS(x) ((x)<<8)
#define S3C2410_NFCONF_TWRPH0(x) ((x)<<4)
#define S3C2410_NFCONF_TWRPH1(x) ((x)<<0) #define S3C2410_ADDR_NALE 4
#define S3C2410_ADDR_NCLE 8
#endif #ifdef CONFIG_S3C2440
#define S3C2410_NFCONT_EN (1<<0)
#define S3C2410_NFCONT_INITECC (1<<4)
#define S3C2410_NFCONT_nFCE (1<<1)
#define S3C2410_NFCONT_MAINECCLOCK (1<<5)
#define S3C2410_NFCONF_TACLS(x) ((x)<<12)
#define S3C2410_NFCONF_TWRPH0(x) ((x)<<8)
#define S3C2410_NFCONF_TWRPH1(x) ((x)<<4) #define S3C2410_ADDR_NALE 0x08
#define S3C2410_ADDR_NCLE 0x0c
#endif #if defined(CONFIG_S3C2410)
                if (ctrl & NAND_NCE)
                        writel(readl(&nand->nfconf) & ~S3C2410_NFCONF_nFCE,
                               &nand->nfconf);
                else
                        writel(readl(&nand->nfconf) | S3C2410_NFCONF_nFCE,
                               &nand->nfconf);
        }
#endif
#if defined(CONFIG_S3C2440)
                if (ctrl & NAND_NCE)
                        writel(readl(&nand->nfconf) & ~S3C2410_NFCONT_nFCE,
                               &nand->nfconf);
                else
                        writel(readl(&nand->nfconf) | S3C2410_NFCONT_nFCE,
                               &nand->nfconf);
        }
#endif
#if defined(CONFIG_S3C2410)
        writel(readl(&nand->nfconf) | S3C2410_NFCONF_INITECC, &nand->nfconf);
#endif #if defined(CONFIG_S3C2440)
        writel(readl(&nand->nfconf) | S3C2410_NFCONT_INITECC, &nand->nfconf);
#endif #if defined(CONFIG_S3C2410)
        /* initialize hardware */
#if defined(CONFIG_S3C24XX_CUSTOM_NAND_TIMING)
        tacls  = CONFIG_S3C24XX_TACLS;
        twrph0 = CONFIG_S3C24XX_TWRPH0;
        twrph1 =  CONFIG_S3C24XX_TWRPH1;
#else
        tacls = 4;
        twrph0 = 8;
        twrph1 = 8;
#endif
#endif #if defined(CONFIG_S3C2440)
        tacls = 4;
        twrph0 = 2;
        twrph1 = 0;         cfg = 0;
        cfg |= S3C2410_NFCONF_TACLS(tacls - 1);
        cfg |= S3C2410_NFCONF_TWRPH0(twrph0 - 1);
        cfg |= S3C2410_NFCONF_TWRPH1(twrph1 - 1);
        writel(cfg, &nand_reg->nfconf);         cfg = (1<<4)|(1<<0);
    writel(cfg, &nand_reg->nfcont);
#else
        cfg = S3C2410_NFCONF_EN;
        cfg |= S3C2410_NFCONF_TACLS(tacls - 1);
        cfg |= S3C2410_NFCONF_TWRPH0(twrph0 - 1);
        cfg |= S3C2410_NFCONF_TWRPH1(twrph1 - 1);
        writel(cfg, &nand_reg->nfconf);
        writel(cfg, &nand_reg->nfcont);
#endif

重新编译加载到mini2440,得到输出信息如下:

NAND:  board_nand_init()
end of nand_init
hwcontrol(): 0xff 0x83
hwcontrol(): 0xffffffff 0x81
dev_ready
hwcontrol(): 0x90 0x83
hwcontrol(): 0x00 0x85
hwcontrol(): 0xffffffff 0x81
dev_ready
hwcontrol(): 0x90 0x83
hwcontrol(): 0x00 0x85
hwcontrol(): 0xffffffff 0x81
dev_ready
hwcontrol(): 0xffffffff 0x80
MiB

执行一些命令,得到的输出信息:

SMDK2410 # nand info

Device : nand0, sector size  KiB
Page size b
OOB size b
Erase size b
Initial value for argc=
Final value for argc=
Initial value for argc=
Final value for argc=
Initial value for argc=
Final value for argc=

貌似nand flash基本支持已经完成了,后面使用有问题了再修改代码。

执行了几个nand命令,重新加载uboot到mini2440,却出现下面的错误:

U-Boot 2014.04-g9541fe9-dirty (Jun   - ::)

U-Boot code: 33E80000 -> 33EF9ED0  BSS: -> 33F488D0
CPUID:
FCLK: MHz
HCLK: 101.250 MHz
PCLK: 50.625 MHz
monitor len: 000C88D0
ramsize:
TLB table from 33ff0000 to 33ff4000
Top of RAM usable for U-Boot at: 33ff0000
Reserving 802k for U-Boot at: 33f27000
Reserving 4160k for malloc() at: 33b17000
Reserving Bytes for Board Info at: 33b16fe0
Reserving Bytes for Global Data at: 33b16f40
New Stack Pointer is: 33b16f30
RAM Configuration:
Bank #: MiB
addr=33f27000,_start=33e80000
relocation Offset is: 000a7000
WARNING: Caches not enabled
monitor flash len: 000846C0
dram_bank_mmu_setup: bank:
Now running in RAM - U-Boot at: 33f27000
Flash: fwc addr cmd f0 00f0 16bit x bit
fwc addr 0000aaaa cmd aa 00aa 16bit x bit
fwc addr cmd 16bit x bit
fwc addr 0000aaaa cmd 16bit x bit
fwc addr cmd f0 00f0 16bit x bit
JEDEC PROBE: ID f0 ffff
fwc addr cmd ff 00ff 16bit x bit
fwc addr cmd 16bit x bit
fwc addr cmd ff 00ff 16bit x bit
JEDEC PROBE: ID ffff
*** failed ***
### ERROR ### Please RESET the board ###

居然又无法检测到nor flash了。我折腾了好一会儿,将nand flash全部擦除,然后将官方的uboot重新加载进来,

之后再加载自己的uboot,能正常进入到uboot命令行了。

mini2440移植uboot 2014.04(三)的更多相关文章

  1. mini2440移植uboot 2014.04(五)

    代码上传到github上:https://github.com/qiaoyuguo/u-boot-2014.04-mini2440 前几篇博文: <mini2440移植uboot 2014.04 ...

  2. mini2440移植uboot 2014.04(四)

    我修改的代码已经上传到github上,地址:https://github.com/qiaoyuguo/u-boot-2014.04-mini2440.git 参考文章: <mini2440移植u ...

  3. mini2440移植uboot 2014.04(六)

    上一篇博文:<mini2440移植uboot 2014.04(五)> 代码已经上传到github上:https://github.com/qiaoyuguo/u-boot-2014.04- ...

  4. mini2440移植uboot 2014.04(二)

    我修改的代码已经上传到github上,地址:https://github.com/qiaoyuguo/u-boot-2014.04-mini2440.git 参考文章: <u-boot-2011 ...

  5. mini2440移植uboot 2014.04(七)

    上一篇博文:<mini2440移植uboot 2014.04(六)> 代码已经上传到github上: https://github.com/qiaoyuguo/u-boot-2014.04 ...

  6. mini2440移植uboot 2014.04(一)

    最新版的uboot添加了很多新功能,我决定在最新版代码基础上重新移植一遍加深理解. 我修改的代码已经上传到github上,地址:https://github.com/qiaoyuguo/u-boot- ...

  7. mini2440移植uboot 2011.03(下)

    参考博文: <u-boot-2011.03在mini2440/micro2440上的移植> 移植(五)添加nand支持: host@debian:~/soft/mini2440/u-boo ...

  8. 移植u-boot.2012.04.01

    /*************************************************** *u-boot版本:u-boot2012.04.01 *gcc版本:arm-linux-gcc ...

  9. mini2440移植uboot 2011.03(上)

    参考博文: <u-boot-2011.03在mini2440/micro2440上的移植> 本来我想移植最新版的uboot,但是移植却不太成功,所以先模仿他人的例子重新执行一遍,对uboo ...

随机推荐

  1. PHP面试题及答案解析(7)—Linux系统命令

    1.请解释下列10个shell命令的用途.top.ps.mv.find.df.cat.chmod.chgrp.grep.wc top:该命令提供了实时对系统处理器状态的监控,它能够实时显示系统中各个进 ...

  2. [ACM] HDU 5078 Osu!

    Osu! Problem Description Osu! is a very popular music game. Basically, it is a game about clicking. ...

  3. IDEA下配置Spring Boot的热部署

    © 版权声明:本文为博主原创文章,转载请注明出处 devtools简介 spring-boot-devtools会监听classpath下的文件变动,并且会立即重启应用(发生在保存时机),因为其采用的 ...

  4. hdu 4601 Letter Tree

    不easy啊.. 一个小错误让我wa死了.找了一个晚上,怎么都找不到 最后是对拍代码找到的错误.发现当步数比較小的时候答案就是对的,比較大的时候就不正确了 想到一定是什么地方越界了.. . power ...

  5. 基于 ZooKeeper 搭建 Hadoop 高可用集群

    一.高可用简介 二.集群规划 三.前置条件 四.集群配置 五.启动集群 六.查看集群 七.集群的二次启动 一.高可用简介 Hadoop 高可用 (High Availability) 分为 HDFS ...

  6. 查看Android源码和源码布局

    一.查看源码 1.https://github.com/android 2.http://grepcode.com/project/repository.grepcode.com/java/ext/c ...

  7. An internal error occurred during: &quot;J2EE Component Mapping Update&quot;.

    1.错误描写叙述 An internal error occurred during: "J2EE Component Mapping Update". java.lang.Nul ...

  8. Android小应用之拨号器

    首先看一下Android Studio下怎么设置应用的ICON Activity的onCreate()方法 当界面刚被创建时会回调此方法,super.onCreate()执行父类的初始化操作,必须要加 ...

  9. Java 异常介绍

    Java标准库内建了一些通用的异常,这些类以 Throwable 为顶层父类.Throwable又派生出 Error 类和 Exception 类. 错误:Error类以及他的子类的实例,代表了JVM ...

  10. html5小趣味知识点系列(二)tabindex

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...