您的位置:首页 > 其它

u-boot-2011.06在mini2440上的移植之Nor flash支持

2012-05-03 22:28 477 查看
转载请注明出处http://blog.csdn.net/cneozhang/article/details/6693764,如有任何疑问,欢迎交流学习。

源码可以到我的git仓库下载:

[plain]
view plaincopyprint?

git clone git://github.com/cneozhang/u-boot-2011.06-cneo.git

[plain]
view plaincopyprint?

<pre class="plain" name="code">neo@neo-machine:~/u-boot-2-11.06$ make distclean

<pre class="plain" name="code">neo@neo-machine:~/u-boot-2-11.06$ make distclean






二、关于SST39LV1601 flash的一些特性:
重要需要了解的是,这款Nor flash兼容JEDEC接口方式,对于U-BOOT来说,如果直接定义成CFI接口方式的话,操作命令过程中,flash不能unlock。
FEATURES:
size: 1M x 16bit
sector:2KWord / sector
block: 32Kword / sector

Product identification



Software command sequence



三、更改代码:
1、更改include/configs/mini2440.h中关于nor flash的配置:

[cpp]
view plaincopyprint?

/*-----------------------------------------------------------------------
* FLASH and environment organization
*/

#define CONFIG_SYS_FLASH_CFI
#define CONFIG_FLASH_CFI_DRIVER

#define CONFIG_FLASH_CFI_LEGACY
#define CONFIG_SYS_FLASH_LEGACY_1024Kx16
#define CONFIG_FLASH_SHOW_PROGRESS 45
#define CONFIG_FLASH_CFI_MTD

#define CONFIG_SYS_MAX_FLASH_BANKS 1
#define CONFIG_SYS_FLASH_BANKS_LIST { CONFIG_SYS_FLASH_BASE }
#define CONFIG_SYS_MAX_FLASH_SECT (512)

#define CONFIG_ENV_ADDR (CONFIG_SYS_FLASH_BASE + 0x1f0000) /* at the end block */
#define CONFIG_ENV_IS_IN_FLASH
#define CONFIG_ENV_SIZE 0x10000

[cpp]
view plaincopyprint?

*-----------------------------------------------------------------------
* FLASH Info: contains chip specific data, per FLASH bank
*/

typedef struct {
ulong   size;           /* total bank size in bytes     */
ushort  sector_count;       /* number of erase units        */
ulong   flash_id;       /* combined device & manufacturer code  */
ulong   start[CONFIG_SYS_MAX_FLASH_SECT];   /* virtual sector start address */
uchar   protect[CONFIG_SYS_MAX_FLASH_SECT]; /* sector protection status */
#ifdef CONFIG_SYS_FLASH_CFI
uchar   portwidth;      /* the width of the port        */
uchar   chipwidth;      /* the width of the chip        */
ushort  buffer_size;        /* # of bytes in write buffer       */
ulong   erase_blk_tout;     /* maximum block erase timeout      */
ulong   write_tout;     /* maximum write timeout        */
ulong   buffer_write_tout;  /* maximum buffer write timeout     */
ushort  vendor;         /* the primary vendor id        */
ushort  cmd_reset;      /* vendor specific reset command    */
ushort  interface;      /* used for x8/x16 adjustments      */
ushort  legacy_unlock;      /* support Intel legacy (un)locking */
ushort  manufacturer_id;    /* manufacturer id          */
ushort  device_id;      /* device id                */
ushort  device_id2;     /* extended device id           */
ushort  ext_addr;       /* extended query table address     */
ushort  cfi_version;        /* cfi version              */
ushort  cfi_offset;     /* offset for cfi query         */
ulong   addr_unlock1;       /* unlock address 1 for AMD flash roms  */
ulong   addr_unlock2;       /* unlock address 2 for AMD flash roms  */
const char *name;       /* human-readable name                  */
#endif
} flash_info_t;

*-----------------------------------------------------------------------
* FLASH Info: contains chip specific data, per FLASH bank
*/

typedef struct {
ulong	size;			/* total bank size in bytes		*/
ushort	sector_count;		/* number of erase units		*/
ulong	flash_id;		/* combined device & manufacturer code	*/
ulong	start[CONFIG_SYS_MAX_FLASH_SECT];   /* virtual sector start address */
uchar	protect[CONFIG_SYS_MAX_FLASH_SECT]; /* sector protection status	*/
#ifdef CONFIG_SYS_FLASH_CFI
uchar	portwidth;		/* the width of the port		*/
uchar	chipwidth;		/* the width of the chip		*/
ushort	buffer_size;		/* # of bytes in write buffer		*/
ulong	erase_blk_tout;		/* maximum block erase timeout		*/
ulong	write_tout;		/* maximum write timeout		*/
ulong	buffer_write_tout;	/* maximum buffer write timeout		*/
ushort	vendor;			/* the primary vendor id		*/
ushort	cmd_reset;		/* vendor specific reset command	*/
ushort	interface;		/* used for x8/x16 adjustments		*/
ushort	legacy_unlock;		/* support Intel legacy (un)locking	*/
ushort	manufacturer_id;	/* manufacturer id			*/
ushort	device_id;		/* device id				*/
ushort	device_id2;		/* extended device id			*/
ushort	ext_addr;		/* extended query table address		*/
ushort	cfi_version;		/* cfi version				*/
ushort	cfi_offset;		/* offset for cfi query			*/
ulong   addr_unlock1;		/* unlock address 1 for AMD flash roms  */
ulong   addr_unlock2;		/* unlock address 2 for AMD flash roms  */
const char *name;		/* human-readable name	                */
#endif
} flash_info_t;

调用关系:
flash_init() -->flash_detect_legacy(cfi_flash_bank_addr(i), i) 去探测目标板中是否存在nor flash芯片
static int flash_detect_legacy(phys_addr_t base, int banknum) -->flash_read_jedec_ids(info)获取JEDEC接口标准flash芯片的信息,并填充info->manufacturer_id和info->device_id
static int flash_detect_legacy(phys_addr_t base, int banknum) -->jedec_flash_match(info, info->start[0])去匹配获取到的id号是否与jedec_table中定义的成员匹配,如果匹配,继续填充flash_info的其他信息,并返回1表示detect成功。
2、我们观察jedec_teble[]定义时发现,里边并未定义SST39LV1601芯片,所以要将其增加进去。
3、将SST39LV1601增加进jedec_table[]成员:

[cpp]
view plaincopyprint?

#ifdef CONFIG_SYS_FLASH_LEGACY_1024Kx16
{
.mfr_id = (u16)SST_MANUFACT,
.dev_id = SST39VF1601,
.name = "SST 39LV1601",
.uaddr = {
[1] = MTD_UADDR_0x5555_0x2AAA /* x16 */
},
.DevSize = SIZE_2MiB,
.CmdSet = P_ID_AMD_STD,
.NumEraseRegions= 4,
.regions = {
ERASEINFO(0x10000,6), /* 6 blocks */
ERASEINFO(0x10000,10), /* 10 blocks */
ERASEINFO(0x10000,15), /* 15 blocks */
ERASEINFO(0x10000,1), /* 1 blocks */
}
},
#endif

[plain]
view plaincopyprint?

neo@neo-machine:~/u-boot-2-11.06$ make mini2440_config
neo@neo-machine:~/u-boot-2-11.06$ make

neo@neo-machine:~/u-boot-2-11.06$ make mini2440_config
neo@neo-machine:~/u-boot-2-11.06$ make

将u-boot.bin文件烧录进nor flash,启动,此时,串口打印信息已经可以正确识别到nor flash了:



试验:

[plain]
view plaincopyprint?

mini2440 # flinfo

mini2440 # flinfo



在执行flinfo命令时,可能会提示raise: Signal # 8 错误,请参考我转载的《u-boot-2011.06 raise: Signal # 8 错误修正》。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: