Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7569775
  • 博文数量: 961
  • 博客积分: 15795
  • 博客等级: 上将
  • 技术积分: 16612
  • 用 户 组: 普通用户
  • 注册时间: 2010-08-07 14:23
文章分类

全部博文(961)

文章存档

2016年(1)

2015年(61)

2014年(41)

2013年(51)

2012年(235)

2011年(391)

2010年(181)

分类: 嵌入式

2010-08-09 11:21:01

嵌入式学习入门 http://blog.chinaunix.net/u3/117680/showart.php?id=2300212  

 

准备进入u-boot的第二阶段(在u-boot中添加对我们开发板上Nor Flash的支持)。
通常,在嵌入式bootloader中,有两种方式来引导启动内核:从Nor Flash启动和从Nand Flash启动。u-boot中默认是从Nor Flash启动,再从上一节这个运行结果图中看,还发现几个问题:第一,我开发板的Nor Flash2M的,而这里显示的是512kB这是因为我们还没有添加对我们自己的Nor Flash的支持

配置文件/include/configs/my2440.h中默认型号为AM29LV400。因为本开发板Nor Flash2MB,和AM29LV800很相似,所以对Nor Flash配置修改如下:

 /*‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐

* FLASH and environment organization

*/

#if 0

#define CONFIG_AMD_LV400 1   /* uncomment this if you have a LV400 flash */

#endif

#define CONFIG_AMD_LV800 1 /* uncomment this if you have a LV800 flash */

#define CONFIG_SYS_MAX_FLASH_BANKS 1 /* max number of memory banks */

 #ifdef CONFIG_AMD_LV800

#define PHYS_FLASH_SIZE 0x00200000 /* 2MB */

#define CONFIG_SYS_MAX_FLASH_SECT (19) /* max number of sectors on one chip */ #define CONFIG_ENV_ADDR (CONFIG_SYS_FLASH_BASE + 0x1F0000) /* addr of environment */

 #endif

#ifdef CONFIG_AMD_LV400

#define PHYS_FLASH_SIZE 0x00080000 /* 512KB */ #define CONFIG_SYS_MAX_FLASH_SECT (11) /* max number of sectors on one chip */

#define CONFIG_ENV_ADDR (CONFIG_SYS_FLASH_BASE + 0x070000) /* addr of environment */ #endif /* timeout values are in ticks */

 #define CONFIG_SYS_FLASH_ERASE_TOUT (5*CONFIG_SYS_HZ) /* Timeout for Flash Erase */

 #define CONFIG_SYS_FLASH_WRITE_TOUT (5*CONFIG_SYS_HZ) /* Timeout for Flash Write */

#define CONFIG_ENV_IS_IN_FLASH 1

 #define CONFIG_ENV_SIZE 0x20000 /* Total Size of Environment Sector */

本例中Nor Flash的操作函数在board/samsung/my2440/flash.c中实现,它支持AM29LV400AM29LV800

 

u‐boot中的提示符SMDK2410 #可以在/include/configs/my2440.h中修改成自己喜欢的提示符,操作如下:

 /*

* Miscellaneous configurable options

*/

 #define CONFIG_SYS_LONGHELP /* undef to save memory */

 #define CONFIG_SYS_PROMPT "[my2440]# " /* Monitor Command Prompt */

 #define CONFIG_SYS_CBSIZE 256 /* Console I/O Buffer Size */

#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE+sizeof(CONFIG_SYS_PROMPT)+16) /* Print Buffer Size */

#define CONFIG_SYS_MAXARGS 16 /* max number of command args */

 #define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE /* Boot Argument Buffer Size */

 

 最后make一下,没有错误,加载到内存中运行正常。我的运行结果如下

从运行结果图看,Nor Flash的大小可以正确检测到了,命令行前面的名字也由原来的SMDK2410改成我自己定义的[MY2440]了,但是还会出现bad CRC的警告信息,其实这并不是什么问题,只是还没有将环境变量设置到Nor Flash中,我们执行一下u-boot的:saveenv命令就可以了。如下图:

再重新下载u-boot.bin文件到RAM中运行,可以观察到不会出现警告信息了,这时候u-boot已经对我们开发板上的Nor Flash完全支持了。如下:

阅读(3109) | 评论(0) | 转发(2) |
给主人留下些什么吧!~~