U-boot-200908在FL2440上的移植(二)--uboot在norflash上运行
2012-11-26 18:57
357 查看
我的开发板上的norflash是Intel的JS28F320(4MB)(1device=32blocks,1block=128MB)
1.修改norflash的配置,在include/configs/fl2440.h中关于flash的配置部分都删掉,换成下面的配置:
2.下载到norflash需要进行底层的初始化,所以要删除之前在配置文件include/configs/fl2440.h中加入的两句:
3.修改board/samsung/fl2440/lowlevel_init.S文件中SDARM刷新参数为:
4.修改flash型号相关文件:
(1).用board/cmi/flash.c文件替换board/samsung/fl2440/flash.c文件,使uboot支持Intel的JS28F320型号nor;
(2).修改board/samsung/fl2440/flash.c中函数申明:
(3).删除board/samsung/fl2440/flash.c中write_buff和write_short两个函数,用下面两个函数代替:
编译然后下载到norflash中就行了
1.修改norflash的配置,在include/configs/fl2440.h中关于flash的配置部分都删掉,换成下面的配置:
/*----------------------------------------------------------------------- * Physical Memory Map */ #define CONFIG_NR_DRAM_BANKS 1 /* we have 1 bank of DRAM */ #define PHYS_SDRAM_1 0x30000000 /* SDRAM Bank #1 */ #define PHYS_SDRAM_1_SIZE 0x04000000 /* 64 MB */ #define PHYS_FLASH_1 0x00000000 /* Flash Bank #1 */ #define CONFIG_SYS_FLASH_BASE PHYS_FLASH_1 #define CONFIG_SYS_MONITOR_BASE TEXT_BASE #define FLASH_BASE0_PRELIM PHYS_FLASH_1 /*------------------------------------------------------------ * FLASH and environment organization */ #define CONFIG_SYS_FLASH_PROTECTION 1 #define CONFIG_SYS_MAX_FLASH_BANKS 1 /*max number of memory banks*/ #define CONFIG_SYS_FLASH_SIZE 0x00400000 /*4 MB*/ #define CONFIG_SYS_MAX_FLASH_SECT 32 /*max number of sectors on one chip*/ /*timeout values are in ticks*/ #define CONFIG_SYS_FLASH_ERASE_TOUT (2*CONFIG_SYS_HZ) /*Timeout for Flash Erase*/ #define CONFIG_SYS_FLASH_WRITE_TOUT (2*CONFIG_SYS_HZ) /*Timeout for Flash Write*/ #define CONFIG_ENV_IS_IN_FLASH 1 #define CONFIG_ENV_SIZE 0x20000 /*128KB*/ #define CONFIG_ENV_OFFSET 0x40000
2.下载到norflash需要进行底层的初始化,所以要删除之前在配置文件include/configs/fl2440.h中加入的两句:
//#define CONFIG_SKIP_LOWLEVEL_INIT 1 //#define CONFIG_SKIP_RELOCATE_UBOOT 1
3.修改board/samsung/fl2440/lowlevel_init.S文件中SDARM刷新参数为:
#define REFCNT 1258 /* period=7.8125us, HCLK=405/4 Mhz, (2048+1-7.8125*405/4) */
4.修改flash型号相关文件:
(1).用board/cmi/flash.c文件替换board/samsung/fl2440/flash.c文件,使uboot支持Intel的JS28F320型号nor;
(2).修改board/samsung/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);
(3).删除board/samsung/fl2440/flash.c中write_buff和write_short两个函数,用下面两个函数代替:
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); /* get lower word aligned address */ /* * handle unaligned start bytes */ 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; } /* * handle word aligned part */ 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; } /* * handle unaligned tail bytes */ 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; /* Check if Flash is (sufficiently) erased , fix by kavin*/ 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) { /* check for error */ printf("\nFlash write error %02x at address %08lx\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; }
编译然后下载到norflash中就行了
相关文章推荐
- U-boot-200908在FL2440上的移植(一)--uboot在RAM中运行
- FL2440开发版烧录,u-boot移植,和简单C程序运行
- FL2440之U-Boot移植记录(二) uboot的编译配置
- U-boot-200908在FL2440上的移植(四)--用nfs和tftp下载
- U-boot-200908在FL2440上的移植(三)--移植DM9000
- 天祥 TX2440 UBOOT移植(1. 从NORFLASH中运行)
- u-boot-2014.04移植FL2440(norflash启动)
- u-boot-2009.08在飞凌OK2440/FL2440上的移植(一)——让u-boot在内存中运行进来
- U-Boot移植FL2440--1--构建FL2440框架
- u-boot分析与移植——基于u-boot-2011.3和FL2440
- fl2440 移植u-boot-2010.09全纪录3----------DM9000网卡支持
- u-boot2009,norflash移植
- uboot移植(六)——uboot启动第二阶段(init_sequence)
- U-boot-2009.03移植之十四:支持norflash启动
- u-boot-2011.09在ST2410上的移植-在RAM中运行
- <2012 12 06> FL2440开发板的U-boot-2010.09版本移植(九)NAND Flash启动支持的一种新型方法,利用U-Boot自带nand_spl/nand_boot.c
- U-Boot在FL2440上移植(一)----修改系统时钟
- fl2440的U-boot-2010.09移植
- ARM+LINUX移植攻略(三)U-boot-2009.08移植TE2440II开发板--在SDRAM中运行
- 嵌入式linux开发uboot移植(五)——uboot命令体系