U-Boot在FL2440上移植(二)----支持NOR Flash
2013-08-24 09:34
344 查看
<一>选择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
我的开发板上的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
相关文章推荐
- fl2440的U-boot-2010.09移植(四) 添加NOR Flash启动支持
- <2012 12 05> FL2440开发板的U-boot-2010.09版本移植(四)Nor Flash启动支持
- u-boot-2009.08在飞凌OK2440/FL2440上的移植(二)——让u-boot支持从nor flash 启动
- U-Boot移植FL2440--2--支持从Nor FLASH启动
- FL2440的U-boot-2009.08移植(三)支持Nor FLASH
- U-boot-2014.04移植到MINI2440(5) Nor FLASH 读写支持移植
- FL2440的U-boot-2009.08移植(四) 支持DM900网卡
- TQ2440的学习——UBOOT移植(NOR FLASH相关操作支持)
- u-boot-2011.06在mini2440上的移植之Nor flash支持
- TQ2440 u-boot-2012.04.01移植三支持NOR Flash
- 移植uboot到fl2440支持DM9000网卡
- <2012 12 06> FL2440开发板的U-boot-2010.09版本移植(九)NAND Flash启动支持的一种新型方法,利用U-Boot自带nand_spl/nand_boot.c
- <2012 12 06> FL2440开发板的U-boot-2010.09版本移植(十)支持烧写YAFFS2文件系统
- fl2440 移植u-boot-2010.09全纪录3----------DM9000网卡支持
- 移植u-boot学习笔记6-----修改代码支持nor flash
- <2012 12 05> FL2440开发板的U-boot-2010.09版本移植(五)支持DM9000网卡和板级相关LED等配置
- u-boot移植(十)---代码修改---支持nor flash
- U-boot-2009.08移植(三)支持Nor FLASH
- <2012 12 05> FL2440开发板的U-boot-2010.09版本移植(七)NAND Flash启动支持
- 2440超详细uboot移植笔记(十)------支持NOR FLASH