U-Boot在FL2440上移植(二)----支持NOR Flash
<一>选择NOR flash型号
我的开发板上的nor flash芯片是Intel的JS28F320(4MB)(1device=32blocks,1block=128MB
fl2440默认是nandflash启动,norflash启动只需将跳线帽J5拔掉就可以了
1. 把开发板的配置文件fl2440.h(/include/configs/fl2440.h)中关于flash的配置部分都删掉,换成下面的配置:
#define CONFIG_NR_DRAM_BANKS 1
#define PHYS_SDRAM_1 0x30000000
#define PHYS_SDRAM_1_SIZE 0x04000000
#define PHYS_FLASH_1 0x00000000
#define CFG_FLASH_BASE PHYS_FLASH_1
#define CFG_MONITOR_BASE TEXT_BASE
#define FLASH_BASE0_PRELIM PHYS_FLASH_1
#define CONFIG_SYS_FLASH_PROTECTION 1
#define CFG_MAX_FLASH_BANKS 1
#define CONFIG_SYS_FLASH_SIZE 0x00400000
#define CFG_MAX_FLASH_SECT 32
#define CFG_FLASH_ERASE_TOUT (2*CONFIG_SYS_HZ)
#define CONFIG_SYS_FLASH_WRITE_TOUT (2*CONFIG_SYS_HZ)
#define CFG_ENV_IS_IN_FLASH 1
#define CFG_ENV_SIZE 0x20000
#define CFG_ENV_OFFSET 0x40000
#define CONFIG_SYS_HZ 1000
#endif
如果出现 警告: “no newline at end of file" 只需在这段代码后加几个回车就可以了
2. 把开发板目录下flash.c文件替换成下面的/board/cmi/下面的flash.c文件,然后删除这个write_short函数的申明和定义、删除write_buff函数。替换成下面的两个函数
int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
{
ulong cp, wp;
ushort data;
int l;
int i, rc;
wp = (addr & ~1);
if ((l = addr - wp) != 0)
{
data = 0;
for (i=0, cp=wp; i<l; ++i, ++cp) {
data = (data >> 8) | (*(uchar *)cp << 8);
}
for (; i<2 && cnt>0; ++i) {
data = (data >> 8) | (*src++ << 8);
--cnt;
++cp;
}
for (; cnt==0 && i<2; ++i, ++cp) {
data = (data >> 8) | (*(uchar *)cp << 8);
}
if ((rc = write_word(info, wp, data)) != 0) {
return (rc);
}
wp += 2;
}
while (cnt >= 2) {
data = *((vu_short*)src);
if ((rc = write_word(info, wp, data)) != 0) {
return (rc);
}
src += 2;
wp += 2;
cnt -= 2;
}
if (cnt == 0) {
return ERR_OK;
}
data = 0;
for (i=0, cp=wp; i<2 && cnt>0; ++i, ++cp) {
data = (data >> 8) | (*src++ << 8);
--cnt;
}
for (; i<2; ++i, ++cp) {
data = (data >> 8) | (*(uchar *)cp << 8);
}
return write_word(info, wp, data);
}
static int write_word (flash_info_t *info, ulong dest, ushort data)
{
vu_short *addr = (vu_short *)dest, val;
int rc = ERR_OK;
int flag;
if ((*addr & data) != data)
return ERR_NOT_ERASED;
flag = disable_interrupts();
*addr = 0x50;
*addr = 0x40;
*addr = data;
reset_timer_masked();
while(((val = *addr) & 0x80) != 0x80)
{
if (get_timer_masked() > CONFIG_SYS_FLASH_WRITE_TOUT) {
rc = ERR_TIMOUT;
*addr = 0xB0;
goto outahere;
}
}
if(val & 0x1A) {
printf("\nFlash write error x at address lx\n",
(int)val, (unsigned long)dest);
if(val & (1<<3)) {
printf("Voltage range error.\n");
rc = ERR_PROG_ERROR;
goto outahere;
}
if(val & (1<<1)) {
printf("Device protect error.\n");
rc = ERR_PROTECTED;
goto outahere;
}
if(val & (1<<4)) {
printf("Programming error.\n");
rc = ERR_PROG_ERROR;
goto outahere;
}
rc = ERR_PROG_ERROR;
goto outahere;
}
outahere:
*addr = 0xFF;
if (flag)
enable_interrupts();
return rc;
}
3. 修改board/fl2440/flash.c中函数申明:
static ulong flash_get_size (vu_short *addr, flash_info_t *info);
//static int write_short (flash_info_t *info, ulong dest, ushort data);
static int write_word (flash_info_t *info, ulong dest, ushort data);
static void flash_get_offsets (ulong base, flash_info_t *info);
4. 修改flash.c文件中的一个宏定义:
把:
#define FLASH_BLOCK_SIZE 0x00010000
改为:
#define FLASH_BLOCK_SIZE 0x00020000
<二>执行make fl2440config 和 make all将生成的U-Boot.bin烧入norflash
NOR Flash常用命令 :查看NOR flash信息 flinfo
加/解写保护命令 protect
擦出命令 erase
读norflash mm/cp
写norflash cp
U-Boot在FL2440上移植(二)----支持NOR Flash的更多相关文章
- U-Boot在FL2440上移植(三)----支持NAND Flash
<一>支持NAND Flash 1. 首先在配置文件 include/config/fl2440.h 的宏 CONFIG_COMMANDS 中增加 CFG_CMD_NAND, #defin ...
- U-Boot在FL2440上移植(四)----支持网卡DM9000和烧写yaffs文件系统
<一>支持网卡芯片DM9000 在driver下,有网卡驱动DM9000x.c 和 DM9000x.h DM9000接在BANK4,位宽16 在include/configs/TX2440 ...
- U-Boot在FL2440上移植(一)----修改系统时钟
<一>U-boot源码结构 图片来自韦东山的<嵌入式linux应用开发完全手册> U-boot下载地址:ftp://ftp.denx.de/pub/u-boot/ 交叉编译工具 ...
- Spring Boot 揭秘与实战(二) 数据存储篇 - 声明式事务管理
文章目录 1. 声明式事务 2. Spring Boot默认集成事务 3. 实战演练4. 源代码 3.1. 实体对象 3.2. DAO 相关 3.3. Service 相关 3.4. 测试,测试 本文 ...
- Spring Boot开发之流水无情(二)
http://my.oschina.net/u/1027043/blog/406558 上篇散仙写了一个很简单的入门级的Spring Boot的例子,没啥技术含量,不过,其实学任何东西只要找到第一个突 ...
- 【转】Spring Boot干货系列:(二)配置文件解析
转自:Spring Boot干货系列:(二)配置文件解析 前言 上一篇介绍了Spring Boot的入门,知道了Spring Boot使用"习惯优于配置"(项目中存在大量的配置,此 ...
- Spring Boot干货系列:(二)配置文件解析
Spring Boot干货系列:(二)配置文件解析 2017-02-28 嘟嘟MD 嘟爷java超神学堂 前言 上一篇介绍了Spring Boot的入门,知道了Spring Boot使用“习惯优于 ...
- ESA2GJK1DH1K基础篇: 测试APP扫描Air202上面的二维码绑定通过MQTT控制设备(兼容SIM800)
前言 此程序兼容SIM800 如果想绑定SIM800,请把其IMEI号,生成二维码,用手机APP扫描. 实现功能概要 APP通过扫描二维码获取GPRS设备的IMEI号,然后设置订阅的主题:device ...
- zedboard上移植OPENCV库
zedboard上移植OPENCV库 之前做了很多移植OPENCV库的工作,但是需要包含的各种库,需要交叉编译,X264 ,JPGE ,FFMPGE等等 注意:在<嵌入式系统软硬件协同设计实战指 ...
随机推荐
- SpringMVC深入理解
核心类与接口 - DispatcherServlet 前置控制器- HandlerMapping 请求映射(到Controller)- HandlerAdapter 请求映射(到Controller类 ...
- android之ArrayAdapter的重写
昨天介绍了ArrayAdapter的使用,今天介绍一下更加实用的一点,对它进行重写,满足自己的个性化设计需要. ArrayAdapter(数组适配器)一般用于显示一行文本信息,所以比较容易. publ ...
- javascript中对变量类型的推断
本文正式地址:http://www.xiabingbao.com/javascript/2015/07/04/javascript-type 在JavaScript中,有5种基本数据类型和1种复杂数据 ...
- GDB调试之core文件(如何定位到Segment fault)
core dump又叫核心转储,当程序运行过程中发生异常,程序异常退出时,由操作系统把程序当前的内存状况存储在一个core文件中,叫core dump.(内部实现是:linux系统中内存越界会收到SI ...
- vim之执行shell命令
vim中执行shell命令,有以下几种形式 (1) :!command 不退出vim, 并执行shell命令command, 将命令输出显示在vim的命令区域,不会改变当前编辑的文件的内容 (2) ...
- Error (0xc0000225) installing Windows 8 R2 on VirtualBox
Windows Boot Manager Windows failed to start. A recent hardware or software change might be the caus ...
- 【转】Linq实现DataTable行列转换
出处:http://www.cnblogs.com/li-peng/ 转换前的table: 转换后的table: 代码里有详细的说明, 还有一些参数我都截图了下面有 using System;usin ...
- SSIS:捕获修改了的数据
获取修改了的数据一般有三种方式: 1.使用一个datetime列 缺点:是并不是每个表都会有个‘修改日期’字段来让你判断行是否修改过 使用实例可以参考我之前的文章:SSIS: 使用最大ID和最大日期来 ...
- Objective-c 集合对象
集合(NSSet)是一组单值对象的组合,集合对象的操作包括:搜索,添加,删除集合中的成员(可变集合的功能),比较两个集合,计算两个集合的交集,并集等. 下面来看下(NSSet)的方法: 1)集合的构建 ...
- vs2013出现ISO C++ conformant解决办法
出现:错误 1 error C4996: 'strnset': The POSIX name for this item is deprecated. Instead, use the I ...