在AT91RM9200上跑U-Boot 1.3.2

 
ATMEL所提供光盘上的U-Boot版本为1.1.5。

到U-Boot的官方网站:
http://www.denx.de/wiki/UBoot
最近的版本为1.3.2。

进入FTP:
ftp://ftp.denx.de/pub/u-boot/
看清u-boot-1.3.2.tar.bz2的链接。

移步u-boot目录:
cd u-boot

把u-boot-1.3.2.tar.bz2拉回来:
wget ftp://ftp.denx.de/pub/u-boot/u-boot-1.3.2.tar.bz2

解包:
tar -xvjf u-boot-1.3.2.tar.bz2

这时进到生成的目录的board中,可见到自带了at91rm9200dk。

也就修改些个地方。

AT91RM9200DK的flash.c只支持AT49BV系列的FLASH芯片,因此有必要换用其它的flash.c,这是一种比较偷懒的做法,大家最好不要学,呵呵。当然,也可以考虑上CFI接口。

在众多开发板所在目录board中查找支持S29GL064(含有该字串)的所有FLASH操作文件flash.c:
代码
find . -name "flash.c" | xargs grep S29GL064


找到的文件罗列如下:
代码
./board/xsengine/flash.c:    case FLASH_S29GL064M:    printf ("S29GL064M (64Mbit, top boot sector size)/n");
./board/xsengine/flash.c:                debug ("Chip: S29GL064M-R3 -> unknown/n");
./board/xsengine/flash.c:                debug ("Chip: S29GL064M-R3/n");
./board/xsengine/flash.c:                info->flash_id += FLASH_S29GL064M;
./board/cmc_pu2/flash.c:    case FLASH_S29GL064M:
./board/cmc_pu2/flash.c:        printf ("S29GL064M-R6 (64Mbit, uniform sector size)/n");
./board/cmc_pu2/flash.c:                debug ("Chip: S29GL064M-R6/n");
./board/cmc_pu2/flash.c:                info->flash_id += FLASH_S29GL064M;

也就xsengine和cmc_pu2两个目录的flash.c文件直接支持。

把at91rm9200dk目录下的flash.c改一下名字,然后把cmc_pu2目录下的flash.c复制过来,然后重新编译:
代码
mv board/atmel/at91rm9200dk/flash.c board/atmel/at91rm9200dk/flash_AT49BV.c
cp board/cmc_pu2/flash.c board/atmel/at91rm9200dk/flash.c
make distclean
make at91rm9200dk_config
make all


通过运行loader.bin再下载前面所生成的u-boot.bin,u-boot跑起来了,就是FLASH容量为0:
代码
U-Boot 1.3.2 (May 21 2008 - 14:06:03)

DRAM:  32 MB
Chip: *** unknown ***
Flash:  0 kB
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial

这样的信息不够丰富,于是把u-boot-1.3.2/include/configs目录下的at91rm9200dk.h追加一行
#define DEBUG 1
好让它输出调试信息,结果如下:
代码
U-Boot 1.3.2 (May 21 2008 - 15:27:11)

U-Boot code: 21F00000 -> 21F181E4  BSS: -> 21F35E10
RAM Configuration:
Bank #0: 20000000 32 MB
Manufacturer ID: 0001
Manufacturer: AMD (Spansion)
Device ID: 227E
Mirror Bit flash: addr[14] = 00002210  addr[15] = 00002200
Chip: *** unknown ***
0 kB
flash_protect ON: from 0x10060000 to 0x1006FFFF
Flash:  0 kB
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
### main_loop entered: bootdelay=3

### main_loop: bootcmd="<UNDEFINED>"

可见,程序已经正确识别了生产厂商及器件(因为S29GL064的识别码Cycle 1/2/3依次为227Eh/2210h/2200h[Model Number为04的情况])。
查看flash.c代码中flash_get_size函数部分:
代码
        debug ("Mirror Bit flash: addr[14] = %08X  addr[15] = %08X/n",
            addr[14], addr[15]);

        switch(addr[14]) {
        case (AMD_ID_GL064M_2 & 0xFFFF):
            if (addr[15] != (AMD_ID_GL064M_3 & 0xffff)) {
                printf ("Chip: S29GLxxxM -> unknown/n");
                info->flash_id = FLASH_UNKNOWN;
                info->sector_count = 0;
                info->size = 0;
            } else {
                debug ("Chip: S29GL064M-R6/n");
                info->flash_id += FLASH_S29GL064M;
                info->sector_count = 128;
                info->size = 0x00800000;
                for (i = 0; i < info->sector_count; i++) {
                    info->start[i] = base;
                    base += 0x10000;
                }
            }
            break;    /* => 16 MB    */
        default:
            printf ("Chip: *** unknown ***/n");
            info->flash_id = FLASH_UNKNOWN;
            info->sector_count = 0;
            info->size = 0;
            break;
        }
        break;

问题就在这个switch中只有AMD_ID_GL064M_2一个case,从
u-boot-1.3.2/include/flash.h:#define AMD_ID_GL064M_2 0x22132213 /* 2nd ID word for S29GL064M-R6 */
定义可知它除了2213h之外什么都不认了,S29GL064A的2210h就成了“Chip: *** unknown ***”,因此需要添加一点识别代码:
1、在u-boot-1.3.2/include/flash.h中添加定义
#define AMD_ID_GL064A_2 0x22102210
#define AMD_ID_GL064A_3 0x22102200
#define FLASH_S29GL064A 0x00EF /* Spansion S29GL064A-R4 */
2、在flash.c中flash_get_size函数添加分支
代码
        case (AMD_ID_GL064A_2 & 0xFFFF):
            if (addr[15] != (AMD_ID_GL064A_3 & 0xffff)) {
                printf ("Chip: S29GLxxxA -> unknown/n");
                info->flash_id = FLASH_UNKNOWN;
                info->sector_count = 0;
                info->size = 0;
            } else {
                debug ("Chip: S29GL064A-R4/n");
                info->flash_id += FLASH_S29GL064A;
                info->sector_count = 128;
                info->size = 0x00800000;
                for (i = 0; i < info->sector_count; i++) {
                    info->start[i] = base;
                    base += 0x10000;
                }
            }
            break;    /* => 16 MB    */

flash_print_info函数也要添加分支
代码
    case FLASH_S29GL064A:
        printf ("S29GL064A-R4 (64Mbit, uniform sector size)/n");
        break;


重新编译,下载到目标板,成功信息如下:
代码
U-Boot 1.3.2 (May 21 2008 - 16:07:02)

U-Boot code: 21F00000 -> 21F182C0  BSS: -> 21F36010
RAM Configuration:
Bank #0: 20000000 32 MB
Manufacturer ID: 0001
Manufacturer: AMD (Spansion)
Device ID: 227E
Mirror Bit flash: addr[14] = 00002210  addr[15] = 00002200
Chip: S29GL064A-R4
flash_protect ON: from 0x10060000 to 0x1006FFFF
protect on 6
Flash:  8 MB
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
### main_loop entered: bootdelay=3

### main_loop: bootcmd="<UNDEFINED>"

http://blog.verycd.com/light/showentry=50102

你可能感兴趣的:(在AT91RM9200上跑U-Boot 1.3.2)