mini2440移植uboot 2011.03(下)
参考博文:
《u-boot-2011.03在mini2440/micro2440上的移植》
移植(五)添加nand支持:
host@debian:~/soft/mini2440/u-boot-2011.03$ touch drivers/mtd/nand/s3c2440_nand.c
host@debian:~/soft/mini2440/u-boot-2011.03$ vim drivers/mtd/nand/s3c2440_nand.c
添加下面内容:
#include <common.h> #if 0
#define DEBUGN printf
#else
#define DEBUGN(x, args ...) {}
#endif #include <nand.h>
#include <asm/arch/s3c24x0_cpu.h>
#include <asm/io.h> #define __REGb(x) (*(volatile unsigned char *)(x))
#define __REGi(x) (*(volatile unsigned int *)(x)) #define NF_BASE 0x4e000000 //Nand配置寄存器基地址
#define NFCONF __REGi(NF_BASE + 0x0) //偏移后还是得到配置寄存器基地址
#define NFCONT __REGi(NF_BASE + 0x4) //偏移后得到Nand控制寄存器基地址
#define NFCMD __REGb(NF_BASE + 0x8) //偏移后得到Nand指令寄存器基地址
#define NFADDR __REGb(NF_BASE + 0xc) //偏移后得到Nand地址寄存器基地址
#define NFDATA __REGb(NF_BASE + 0x10) //偏移后得到Nand数据寄存器基地址
#define NFMECCD0 __REGi(NF_BASE + 0x14) //偏移后得到Nand主数据区域ECC0寄存器基地址
#define NFMECCD1 __REGi(NF_BASE + 0x18) //偏移后得到Nand主数据区域ECC1寄存器基地址
#define NFSECCD __REGi(NF_BASE + 0x1C) //偏移后得到Nand空闲区域ECC寄存器基地址
#define NFSTAT __REGb(NF_BASE + 0x20) //偏移后得到Nand状态寄存器基地址
#define NFSTAT0 __REGi(NF_BASE + 0x24) //偏移后得到Nand ECC0状态寄存器基地址
#define NFSTAT1 __REGi(NF_BASE + 0x28) //偏移后得到Nand ECC1状态寄存器基地址
#define NFMECC0 __REGi(NF_BASE + 0x2C) //偏移后得到Nand主数据区域ECC0状态寄存器基地址
#define NFMECC1 __REGi(NF_BASE + 0x30) //偏移后得到Nand主数据区域ECC1状态寄存器基地址
#define NFSECC __REGi(NF_BASE + 0x34) //偏移后得到Nand空闲区域ECC状态寄存器基地址
#define NFSBLK __REGi(NF_BASE + 0x38) //偏移后得到Nand块开始地址
#define NFEBLK __REGi(NF_BASE + 0x3c) //偏移后得到Nand块结束地址 #define S3C2440_NFCONT_nCE (1<<1)
#define S3C2440_ADDR_NALE 0x0c
#define S3C2440_ADDR_NCLE 0x08 ulong IO_ADDR_W = NF_BASE; static void s3c2440_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
{
struct nand_chip *chip = mtd->priv; DEBUGN("hwcontrol(): 0x%02x 0x%02x/n", cmd, ctrl); if (ctrl & NAND_CTRL_CHANGE)
{
IO_ADDR_W = NF_BASE; if (!(ctrl & NAND_CLE)) //要写的是地址
IO_ADDR_W |= S3C2440_ADDR_NALE;
if (!(ctrl & NAND_ALE)) //要写的是命令
IO_ADDR_W |= S3C2440_ADDR_NCLE; if (ctrl & NAND_NCE)
NFCONT &= ~S3C2440_NFCONT_nCE; //使能nand flash
else
NFCONT |= S3C2440_NFCONT_nCE; //禁止nand flash
} if (cmd != NAND_CMD_NONE)
writeb(cmd,(void *)IO_ADDR_W);
} static int s3c2440_dev_ready(struct mtd_info *mtd)
{
DEBUGN("dev_ready/n");
return (NFSTAT & 0x01);
} int board_nand_init(struct nand_chip *nand)
{
u_int32_t cfg;
u_int8_t tacls, twrph0, twrph1;
struct s3c24x0_clock_power * const clk_power = s3c24x0_get_base_clock_power(); DEBUGN("board_nand_init()/n"); tacls = 1; twrph0 = 2; twrph1 = 1; cfg = (tacls<<12)|(twrph0<<8)|(twrph1<<4);
NFCONF = cfg; cfg = (1<<6)|(1<<4)|(0<<1)|(1<<0);
NFCONT = cfg; /* initialize nand_chip data structure */
nand->IO_ADDR_R = nand->IO_ADDR_W = (void *)0x4e000010; /* read_buf and write_buf are default */
/* read_byte and write_byte are default */ /* hwcontrol always must be implemented */
nand->cmd_ctrl = s3c2440_hwcontrol; nand->dev_ready = s3c2440_dev_ready; return 0;
}
host@debian:~/soft/mini2440/u-boot-2011.03$ vim drivers/mtd/nand/Makefile
添加一行:
COBJS-$(CONFIG_NAND_S3C2440) += s3c2440_nand.o
host@debian:~/soft/mini2440/u-boot-2011.03$ vim include/configs/mini2440.h
添加下面内容:
#define CONFIG_MTD_DEVICE
#define CONFIG_NAND_S3C2440
#define CONFIG_CMD_NAND
#if defined(CONFIG_CMD_NAND)
#define CONFIG_SYS_NAND_BASE 0x4E000000 //Nand配置寄存器基地址
#define CONFIG_SYS_MAX_NAND_DEVICE 1
#define CONFIG_MTD_NAND_VERIFY_WRITE 1
#endif
#define CONFIG_ENV_IS_IN_NAND 1
#define CONFIG_ENV_OFFSET 0x40000 //将环境变量保存到nand中的0x40000位置
#define CONFIG_ENV_SIZE 0x10000 /* Total Size of Environment Sector */
修改后,进行编译,却得到好几个编译错误:
env_nand.o: In function `env_get_char_spec':
/home/host/soft/mini2440/u-boot-2011.03/common/env_nand.c:: multiple definition of `env_get_char_spec'
env_flash.o:/home/host/soft/mini2440/u-boot-2011.03/common/env_flash.c:: first defined here
env_nand.o: In function `env_init':
/home/host/soft/mini2440/u-boot-2011.03/common/env_nand.c:: multiple definition of `env_init'
env_flash.o:/home/host/soft/mini2440/u-boot-2011.03/common/env_flash.c:: first defined here
env_nand.o: In function `env_relocate_spec':
/home/host/soft/mini2440/u-boot-2011.03/common/env_nand.c:: multiple definition of `env_relocate_spec'
env_flash.o:/home/host/soft/mini2440/u-boot-2011.03/common/env_flash.c:: first defined here
env_nand.o: In function `saveenv':
/home/host/soft/mini2440/u-boot-2011.03/common/env_nand.c:: multiple definition of `saveenv'
env_flash.o:/home/host/soft/mini2440/u-boot-2011.03/common/env_flash.c:: first defined here
env_nand.o:(.data+0x0): multiple definition of `env_name_spec'
env_flash.o:(.data+0x4): first defined here
env_nand.o: In function `env_get_char_spec':
/home/host/soft/mini2440/u-boot-2011.03/common/env_nand.c:: multiple definition of `env_ptr'
env_flash.o:(.data+0x0): first defined here
make[]: *** [libcommon.o] 错误
make[]: Leaving directory `/home/host/soft/mini2440/u-boot-2011.03/common'
这是因为include/configs/mini2440.h已经定义了CONFIG_ENV_IS_IN_FLASH,新加入的定义CONFIG_ENV_IS_IN_NAND与之冲突,可以将
CONFIG_ENV_IS_IN_FLASH宏定义屏蔽掉即可。
修改好后重新编译,按照《mini2440移植uboot 2011.03(上)》中的步骤将其加载到mini2440 内存,然后启动uboot,得到下面的输出信息:
U-Boot 2011.03--g18dedc3-dirty (Jun - ::) DRAM: MiB
Flash: KiB
NAND: NAND_ECC_NONE selected by board driver. This is not recommended !!
MiB
*** Warning - bad CRC, using default environment In: serial
Out: serial
Err: serial
Net: dm9000
MINI2440 # nand
nand - NAND sub-system Usage:
nand info - show available NAND devices
nand device [dev] - show or set current device
nand read - addr off|partition size
nand write - addr off|partition size
read/write 'size' bytes starting at offset 'off'
to/from memory address 'addr', skipping bad blocks.
nand erase[.spread] [clean] [off [size]] - erase 'size' bytes from offset 'off'
With '.spread', erase enough for given file size, otherwise,
'size' includes skipped bad blocks.
nand erase.part [clean] partition - erase entire mtd partition'
nand erase.chip [clean] - erase entire chip'
nand bad - show bad blocks
nand dump[.oob] off - dump page
nand scrub off size | scrub.part partition | scrub.chip
really clean NAND erasing bad blocks (UNSAFE)
nand markbad off [...] - mark bad block(s) at offset (UNSAFE)
nand biterr off - make a bit error at offset (UNSAFE)
移植(六):添加nfs,命令补全的支持.
host@debian:~/soft/mini2440/u-boot-2011.03$ vim include/configs/mini2440.h
添加下面内容:
#define CONFIG_CMDLINE_EDITING
#ifdef CONFIG_CMDLINE_EDITING
#undef CONFIG_AUTO_COMPLETE
#else
#define CONFIG_AUTO_COMPLETE
#endif
#define CONFIG_CMD_NFS
修改完后,重新进行编译并加载到mini2440内存中执行,得到下面的输出:
U-Boot 2011.03--g0e6506b-dirty (Jun - ::) DRAM: MiB
Flash: KiB
NAND: NAND_ECC_NONE selected by board driver. This is not recommended !!
MiB
*** Warning - bad CRC, using default environment In: serial
Out: serial
Err: serial
Net: dm9000
MINI2440 # nfs 30007fc0 /home/host/nfs/mini2440/uImage
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in bit mode
MAC: ::3e::0a:5b
operating at unknown: mode
Using dm9000 device
File transfer via NFS from server 192.168.211.2; our IP address is 192.168.211.25
Filename '/home/host/nfs/mini2440/uImage'.
Load address: 0x30007fc0
Loading: *
Abort
MINI2440 # nfs 30007fc0 /home/host/nfs/mini2440/uImage
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in bit mode
MAC: ::3e::0a:5b
operating at unknown: mode
Using dm9000 device
File transfer via NFS from server 192.168.211.2; our IP address is 192.168.211.25
Filename '/home/host/nfs/mini2440/uImage'.
Load address: 0x30007fc0
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#####################################################
done
Bytes transferred = (22963c hex)
第一次调用nfs有可能不成功(跟前面的ping命令执行情况类似)。
后续移植过程我没有再继续下去了,因为我对yaffs兴趣不大,我希望能让它支持ubifs并且自己重新移植一遍。
整个代码(包含git历史记录)下载地址:http://pan.baidu.com/s/1dDipCqt
mini2440移植uboot 2011.03(下)的更多相关文章
- mini2440移植uboot 2011.03(上)
参考博文: <u-boot-2011.03在mini2440/micro2440上的移植> 本来我想移植最新版的uboot,但是移植却不太成功,所以先模仿他人的例子重新执行一遍,对uboo ...
- mini2440移植uboot 2014.04(一)
最新版的uboot添加了很多新功能,我决定在最新版代码基础上重新移植一遍加深理解. 我修改的代码已经上传到github上,地址:https://github.com/qiaoyuguo/u-boot- ...
- mini2440移植uboot 2014.04(三)
我修改的代码已经上传到github上,地址:https://github.com/qiaoyuguo/u-boot-2014.04-mini2440.git 参考文档: s3c2440手册(下载地址) ...
- mini2440移植uboot 2014.04(四)
我修改的代码已经上传到github上,地址:https://github.com/qiaoyuguo/u-boot-2014.04-mini2440.git 参考文章: <mini2440移植u ...
- mini2440移植uboot 2014.04(六)
上一篇博文:<mini2440移植uboot 2014.04(五)> 代码已经上传到github上:https://github.com/qiaoyuguo/u-boot-2014.04- ...
- mini2440移植uboot 2014.04(五)
代码上传到github上:https://github.com/qiaoyuguo/u-boot-2014.04-mini2440 前几篇博文: <mini2440移植uboot 2014.04 ...
- mini2440移植uboot 2014.04(二)
我修改的代码已经上传到github上,地址:https://github.com/qiaoyuguo/u-boot-2014.04-mini2440.git 参考文章: <u-boot-2011 ...
- mini2440移植uboot 2014.04(七)
上一篇博文:<mini2440移植uboot 2014.04(六)> 代码已经上传到github上: https://github.com/qiaoyuguo/u-boot-2014.04 ...
- uboot各种目录下的文件作用
uboot下载地址:http://ftp.denx.de/pub/u-boot/ 1.目录分布 2.目录结构变化: u-boot-2010.03及以前版本├── api ...
随机推荐
- 关于 Android 平台开发相关的有哪些推荐书籍?
转自:http://www.zhihu.com/question/19579609 作者:Shan Huang 链接:http://www.zhihu.com/question/19579609/an ...
- 九度oj题目&吉大考研10年机试题全解
吉大考研机试2010年题目 题目一(jobdu1478:三角形的边). http://ac.jobdu.com/problem.php?pid=1478 给出三个正整数,计算最小的数加上次小的数 ...
- tomcat下配置https方式
[本地HTTPS]①.<Connector SSLEnabled="true" clientAuth="false" keystoreFile=" ...
- Linux下ntp时间同步
在root用户下执行 先安装同步时间软件,每台机器执行 yum install -y ntp 然后执行以下命令: crontab -e */10 * * * * /usr/sbin/ntpdate - ...
- 转: https 加密通信流程
https 加密通信流程当用户在浏览器中输入一个以https开头的网址时,便开启了浏览器与被访问站点之间的加密通信.下面我们以一个用户访问https://qbox.me为例,给读者展现一下SSL/TL ...
- Notepad2替换记事本--映像劫持
Image File Execution Options就是映像劫持技术,通过此种方式替换记事本,非常地绿色环保. Image File Execution Options是CreateProces ...
- VueJS实现双向数据绑定:v-model
HTML <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <titl ...
- C# MVC VS WebAPI
获取路径: MVC:Server.MapPath("/Templates/vshop/default.json") WebAPI:System.Web.Hosting.Hostin ...
- Linux Sed命令具体解释+怎样替换换行符"\n"(非常多面试问道)
Sed Sed是一个强大的文本处理工具 能够採用正则匹配.对文本进行插入删除改动等操作 Sed处理的时候,一次处理一行,每一次把当前处理的存放在暂时缓冲区.处理完后输出缓冲区内容到屏幕,然后把下一行读 ...
- java.lang.UnsupportedClassVersionError: Unsupported major.minor version 49.0的错误 [转]
一:要解决的问题 我们在尝鲜 JDK1.5 的时候,相信不少人遇到过 Unsupported major.minor version 49.0 错误,当时定会茫然不知所措.因为刚开始那会儿,网上与此相 ...