您的位置:首页 > 其它

u-boot-2010.03在LT2440上的移植详解 (二)

2010-12-11 13:18 387 查看
u-boot-2010.03在LT2440上的移植详解 (二)
郑重声明,这系列文章改写自博客园 黄刚先生的《嵌入式Linux之我行——u-boot-2009.08在2440上的移植详解》

转载时请注明出处
文章出处:http://www.lt-net.cn
编译系统Ubuntu10.04
交叉编译器arm-linux-gcc 4.3.3
硬件设备LT2440开发板
测试软件u-boot-2010.03
依赖库
uboot下载地址:http://ftp.denx.de/pub/u-boot/u-boot-2010.03.tar.bz2

本次移植在u-boot-2010.03原有功能的基础上增加如下特性:

1.支持2KB page Nand Flash读写
2.支持Nand/Nor Flash启动自动识别
3.支持D[size=+0]M9000AEP 10[size=+0]M/100[size=+0]M自适应网卡
4.支持yaffs文件系统烧写
5.支持USB下载功能
6.支持一键式菜单
7.支持启动Logo
8.支持ubifs(待续)

上接:u-boot-2010.03在LT2440上的移植详解 (一)

4)准备进入u-boot的第二阶段(在u-boot中添加对我们开发板上Nor Flash的支持)
通常,在嵌入式bootloader中,有两种方式来引导启动内核:从Nor Flash启动和从Nand Flash启动。u-boot中默认是从Nor Flash启动,再从上一节这个运行结果图中看,还发现几个问题:第一,我开发板的Nor Flash是2M的,而这里显示的是512kB;第二,出现Warning - bad CRC, using default environment的警告信息。不是u-boot默认是从Nor Flash启动的吗?为什么会有这些错误信息呢?这是因为我们还没有添加对我们自己的Nor Flash的支持,u-boot默认的是其他型号的Nor Flash,而我们的Nor Flash的型号是AM29LV160DB,支持CFI接口。
下面我们一一来解决这些问题,让u-boot完全对我们Nor Flash的支持。由于我们的NorFlash支持CFI 接口,可以直接使用u-boot 提供的CFI驱动程序,只需要配置一些宏定义即可。首先我们修改头文件代码如下:

#gedit include/configs/lt2440.h //修改Nor Flash参数部分的定义
/*-----------------------------------------------------------------------
* FLASH and environment organization
*/
#if 0
#define CONFIG_AMD_LV400 1 /* uncomment this if you have a LV400 flash */
#if 0
#define CONFIG_AMD_LV800 1 /* uncomment this if you have a LV800 flash */
#endif#define CONFIG_SYS_MAX_FLASH_BANKS 1 /* max number of memory banks */
#ifdef CONFIG_AMD_LV800
#define PHYS_FLASH_SIZE 0x00100000 /* 1MB */
#define CONFIG_SYS_MAX_FLASH_SECT (19) /* max number of sectors on one chip */
#define CONFIG_ENV_ADDR (CONFIG_SYS_FLASH_BASE + 0x0F0000) /* 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
#endif#define CONFIG_FLASH_CFI_DRIVER 1
#define CONFIG_SYS_FLASH_CFI 1
#define CONFIG_SYS_MAX_FLASH_BANKS 1 /* max number of memory banks */
#define CONFIG_SYS_MAX_FLASH_SECT (38)
#define CONFIG_SYS_MONITOR_BASE PHYS_FLASH_1#define CONFIG_ENV_ADDR (CONFIG_SYS_FLASH_BASE + 0x0F0000) /* addr of environment */
#gedit board/samsung/lt2440/Makefile //修改默认板子的 Nor Flash驱动程序
include $(TOPDIR)/config.mkLIB = $(obj)lib$(BOARD).aCOBJS := lt2440.o //去掉flash.o ,我们使用CFI的驱动程序,所以去掉这个
SOBJS := lowlevel_init.o
修改完后重新编译u-boot,下载到RAM中运行结果如下图,从运行结果图看,Nor Flash的大小可以正确检测到了,但是还会出现bad CRC的警告信息,其实这并不是什么问题,只是还没有将环境变量设置到Nor Flash中,我们执行一下u-boot的:saveenv命令就可以了。如下图:

Hit any key to stop autoboot: 0
##### LT2440 U-Boot -2010.03 #####
##### Welcome to Embeded World #####
##### designed by: LuTong #####
##### www.lt-net.cn #####

Download u-boot or STEPLDR.nb1 to Nand Flash
[e] Download e-boot to Nand Flash

Download u-boot to Nor Flash
[k] Download Linux Kernel uImage to Nand Flash
[y] Download YAFFS2 Image to Nand Flash
[g] Download to SDRAM and Run
[d] Download Linux Kernel to SDRAM and RUN
[f] Format the Nand Flash
[l] Low-level Format the entire Nand Flash
Set the boot parameters
Boot the system
[r] Reboot U-Boot
[q] Quit from menu
Enter your selection: q
LT2440 # u 1 33f00000
USB host is connected. Waiting a download.
Now, Downloading [ADDRESS:33f00000h,TOTAL:105606]
RECEIVED FILE SIZE: 105606 (103KB/S, 1S)
LT2440 # go 33f00000
## Starting application at 0x33F00000 ...▲
U-Boot 2010.03 (12鏈?07 2010 - 14:14:06)
DRAM: 64 MB
Flash: 2 MB
*** Warning - bad CRC, using default environment
In: serial
Out: serial
Err: serial
Net: CS8900-0
LT2440 # saveenv
Saving Environment to Flash...
Un-Protected 1 sectors
Erasing Flash...
. done
Erased 1 sectors
Writing to Flash... done
Protected 1 sectors
LT2440 #

重启之后 无*** Warning - bad CRC, using default environment

U-Boot 2010.03 (12鏈?07 2010 - 14:14:06)
DRAM: 64 MB
Flash: 2 MB
In: serial
Out: serial
Err: serial
Net: CS8900-0
LT2440 #

下接:u-boot-2010.03在LT2440上的移植详解 (三)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: