4733|6

12

帖子

0

TA的资源

一粒金砂(中级)

楼主
 

板子上的两片flash,u-boot只识别了一片 [复制链接]

板子上的两片Nor Flash都是SST39VF3201,板子自带的u-boot是0.4版本,我按照板子自带的u-boot里面的内容修改了1.3.4版本的u-boot里面的几个文件:include/configsat91rm9200dk.h、board/at91rm9200dk/at91rm9200dk.c、board/at91rm9200dk/flash.c,下载后显示如下:

 


U-Boot 1.3.4 (Jun  2 2011 - 10:53:03)

DRAM:  32 MB
SST: SST39VF3201 (32Mbit)
SST: Unkown Flash: 0x90, 0x90
Unknown Flash!

 

用板子自带的u-boot下载后显示:

U-Boot 0.4.0 (Apr 27 2005 - 19:26:55)

U-Boot code: 21F00000 -> 21F143A8  BSS: -> 21F22478
DRAM Configuration:
Bank #0: 20000000 32 MB
SST: SST39VF3201 (32Mbit)
SST: SST39VF3201 (32Mbit)
Flash:  8 MB
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Hit any key to stop autoboot:  0

 

请问大侠我该怎么办怎么办啊?

最新回复

FLASH的驱动部分你是怎样写的  详情 回复 发表于 2011-6-8 12:49
点赞 关注

回复
举报

5970

帖子

8

TA的资源

版主

沙发
 
为什么 你要识别另外一块
 
个人签名生活就是油盐酱醋再加一点糖,快活就是一天到晚乐呵呵的忙
===================================
做一个简单的人,踏实而务实,不沉溺幻想,不庸人自扰
 

回复

12

帖子

0

TA的资源

一粒金砂(中级)

板凳
 

回复 沙发 chenzhufly 的帖子

u-boot没有识别到另一片flash,然后提示Unknown Flash!  之后u-boot就停止运行了。所以u-boot没办法跑起来,后面下载内核和文件系统也不好办
 
 
 

回复

5970

帖子

8

TA的资源

版主

4
 

哇,难道是用两片flash来存放内核和文件系统
太有才了,有创意!长见识!
 
个人签名生活就是油盐酱醋再加一点糖,快活就是一天到晚乐呵呵的忙
===================================
做一个简单的人,踏实而务实,不沉溺幻想,不庸人自扰
 
 

回复

12

帖子

0

TA的资源

一粒金砂(中级)

5
 

回复 4楼 chenzhufly 的帖子

版主别笑我啦,快想办法帮帮我吧,刚入门遇到问题自己解决还是有很大困难的
 
 
 

回复

2131

帖子

0

TA的资源

至上芯片

6
 

回复 5楼 tamujin 的帖子

FLASH的驱动部分你是怎样写的
 
个人签名处处留心皆学问!
 
 

回复

12

帖子

0

TA的资源

一粒金砂(中级)

7
 

回复 6楼 daicheng 的帖子

在u-boot-1.3.4里面的 board/atmel/at91rm9200dk/flash.c 我看着u-boot-0.4.0里面的 flash.c 来改的。
两片flash在 include/configs/at91rm9200dk.h 中起始地址定义:
#define PHYS_FLASH_1                    0x10000000
#define PHYS_FLASH_2                    0x80000000

flash.c 添加SST39VF3201的支持,文件内容如下,麻烦斑竹帮忙看看:

#include

ulong myflush(void);


/* Flash Organization Structure */
typedef struct OrgDef
{
        unsigned int sector_number;
        unsigned int sector_size;
} OrgDef;


/* Flash Organizations */
OrgDef OrgAT49BV16x4[] =
{
        {  8,  8*1024 },        /*   8 *  8 kBytes sectors */
        {  2, 32*1024 },        /*   2 * 32 kBytes sectors */
        { 30, 64*1024 },        /*  30 * 64 kBytes sectors */
};

OrgDef OrgAT49BV16x4A[] =
{
        {  8,  8*1024 },        /*   8 *  8 kBytes sectors */
        { 31, 64*1024 },        /*  31 * 64 kBytes sectors */
};

OrgDef OrgAT49BV6416[] =
{
        {   8,  8*1024 },        /*   8 *  8 kBytes sectors */
        { 127, 64*1024 },        /* 127 * 64 kBytes sectors */
};


OrgDef OrgSST39VF3201[] =
{
        { 1024, 4*1024 } /* 1024 * 4kBytes sectors */
};

#define FLASH_BANK_SIZE 0x400000        /* 4 MB */
//#define MAIN_SECT_SIZE  0x10000               /* 64 KB */

flash_info_t    flash_info[CFG_MAX_FLASH_BANKS];

/* SST39VF3201 Codes */
#define FLASH_CODE1                0xAA
#define FLASH_CODE2                0x55
#define ID_IN_CODE                0x90
#define ID_OUT_CODE                0xF0


#define CMD_READ_ARRAY                0x00F0
#define CMD_UNLOCK1                0x00AA
#define CMD_UNLOCK2                0x0055
#define CMD_ERASE_SETUP                0x0080
#define CMD_ERASE_CONFIRM        0x0030
#define CMD_PROGRAM                0x00A0
#define CMD_UNLOCK_BYPASS        0x0020
//#define CMD_SECTOR_UNLOCK        0x0070

#define MEM_FLASH_ADDR1         (*(volatile u16 *)(flash_base + (0x00005555<<1)))
#define MEM_FLASH_ADDR2         (*(volatile u16 *)(flash_base + (0x00002AAA<<1)))

#define IDENT_FLASH_ADDR1       (*(volatile u16 *)(flash_base + (0x00005555<<1)))
#define IDENT_FLASH_ADDR2       (*(volatile u16 *)(flash_base + (0x00002AAA<<1)))


#define BIT_ERASE_DONE                0x0080
#define BIT_RDY_MASK                0x0080
#define BIT_PROGRAM_ERROR        0x0020
#define BIT_TIMEOUT                0x80000000 /* our flag */

#define READY 1
#define ERR   2
#define TMO   4

/*-----------------------------------------------------------------------
*/
void flash_identification (ulong flash_base, flash_info_t * info)
{
        volatile u16 manuf_code, device_code, add_device_code;

        IDENT_FLASH_ADDR1 = FLASH_CODE1;
        IDENT_FLASH_ADDR2 = FLASH_CODE2;
        IDENT_FLASH_ADDR1 = ID_IN_CODE;

        manuf_code = *(volatile u16 *) flash_base;
        device_code = *(volatile u16 *) (flash_base + 2);
        //add_device_code = *(volatile u16 *) (CFG_FLASH_BASE + (3 << 1));

        IDENT_FLASH_ADDR1 = FLASH_CODE1;
        IDENT_FLASH_ADDR2 = FLASH_CODE2;
        IDENT_FLASH_ADDR1 = ID_OUT_CODE;

        /* Vendor type */
        info->flash_id = SST_MANUFACT & FLASH_VENDMASK;
        printf ("SST: ");

        if ((device_code & FLASH_TYPEMASK) == (SST_ID_xF3201 & FLASH_TYPEMASK)) {
                        info->flash_id |= SST_ID_xF3201 & FLASH_TYPEMASK;
                        printf ("SST39VF3201 (32Mbit)\n");
                } else {
                        printf ("Unkown Flash: 0x%x, 0x%x\n", manuf_code, device_code);                        }
}


ulong flash_init (void)
{
        int i, j, k;
        unsigned int flash_nb_blocks, sector;
        unsigned int start_address;
        ulong   flash_base;
        OrgDef *pOrgDef;

        ulong size = 0;       

        for (i = 0; i < CFG_MAX_FLASH_BANKS; i++) {

                if (i == 0)
                        flash_base = PHYS_FLASH_1;
                else if (i == 1)
                        flash_base = PHYS_FLASH_2;
                else
                        panic ("configured to many flash banks!\n");


                flash_identification (flash_base, &flash_info);

                flash_info.size = FLASH_BANK_SIZE;

                if ((flash_info.flash_id & FLASH_TYPEMASK) ==
                        (SST_ID_xF3201 & FLASH_TYPEMASK)) {
                        flash_info.sector_count = CFG_MAX_FLASH_SECT;
                        memset (flash_info.protect, 0, CFG_MAX_FLASH_SECT);

                        pOrgDef = OrgSST39VF3201;
                        flash_nb_blocks = sizeof (OrgSST39VF3201) / sizeof (OrgDef);
                } else
                        panic ("Unknown Flash!\n");

#if 0
                if ((flash_info.flash_id & FLASH_TYPEMASK) ==
                        (ATM_ID_BV1614 & FLASH_TYPEMASK)) {
                        flash_info.sector_count = CFG_MAX_FLASH_SECT;
                        memset (flash_info.protect, 0, CFG_MAX_FLASH_SECT);

                        pOrgDef = OrgAT49BV16x4;
                        flash_nb_blocks = sizeof (OrgAT49BV16x4) / sizeof (OrgDef);
                } else {                        /* AT49BV1614A Flash */
                        flash_info.sector_count = CFG_MAX_FLASH_SECT - 1;
                        memset (flash_info.protect, 0, CFG_MAX_FLASH_SECT - 1);

                        pOrgDef = OrgAT49BV16x4A;
                        flash_nb_blocks = sizeof (OrgAT49BV16x4A) / sizeof (OrgDef);
                }
#endif

        //      if (i == 0)
        //              flashbase = PHYS_FLASH_1;
        //      else
        //              panic ("configured to many flash banks!\n");


                sector = 0;
                start_address = flash_base;
                /*flash_info.size = 0;*/

                for (j = 0; j < flash_nb_blocks; j++) {
                        for (k = 0; k < pOrgDef[j].sector_number; k++) {
                                flash_info.start[sector++] = start_address;
                                start_address += pOrgDef[j].sector_size;
                                /*flash_info.size += pOrgDef[j].sector_size;*/
                        }
                }

                size += flash_info.size;

        }

        /* Protect binary boot image */
        flash_protect (FLAG_PROTECT_SET,
                       PHYS_FLASH_1,
                       PHYS_FLASH_1 + CFG_BOOT_SIZE - 1, &flash_info[0]);

        /* Protect environment variables */
        flash_protect (FLAG_PROTECT_SET,
                       CFG_ENV_ADDR,
                       CFG_ENV_ADDR + CFG_ENV_SIZE - 1, &flash_info[0]);

        /* Protect U-Boot gzipped image */
        flash_protect (FLAG_PROTECT_SET,
                       CFG_U_BOOT_BASE,
                       CFG_U_BOOT_BASE + CFG_U_BOOT_SIZE - 1, &flash_info[0]);

        return size;
}

/*-----------------------------------------------------------------------
*/
void flash_print_info (flash_info_t * info)
{
        int i;

        switch (info->flash_id & FLASH_VENDMASK) {
        case (ATM_MANUFACT & FLASH_VENDMASK):
                printf ("Atmel: ");
                break;
        case (SST_MANUFACT & FLASH_VENDMASK):
                printf ("SST: ");
                break;

        default:
                printf ("Unknown Vendor ");
                break;
        }

        switch (info->flash_id & FLASH_TYPEMASK) {
        case (ATM_ID_BV1614 & FLASH_TYPEMASK):
                printf ("AT49BV1614 (16Mbit)\n");
                break;
        case (ATM_ID_BV1614A & FLASH_TYPEMASK):
                printf ("AT49BV1614A (16Mbit)\n");
                break;
        case (ATM_ID_BV6416 & FLASH_TYPEMASK):
                printf ("AT49BV6416 (64Mbit)\n");
                break;
        case (SST_ID_xF3201 & FLASH_TYPEMASK):
                printf ("SST39VF3201 (32Mbit)\n");
                break;

        default:
                printf ("Unknown Chip Type\n");
                goto Done;
                break;
        }

        printf ("  Size: %ld MB in %d Sectors\n",
                info->size >> 20, info->sector_count);

        printf ("  Sector Start Addresses:");
        for (i = 0; i < info->sector_count; i++) {
                if ((i % 5) == 0) {
                        printf ("\n   ");
                }
                printf (" %08lX%s", info->start,
                        info->protect ? " (RO)" : "     ");
        }
        printf ("\n");

  Done:
        return 0;

}

/*-----------------------------------------------------------------------
*/

int flash_erase (flash_info_t * info, int s_first, int s_last)
{
        ulong result;
        int iflag, cflag, prot, sect;
        int rc = ERR_OK;
        int chip1;
        ulong flash_base;

        /* first look for protection bits */

        if (info->flash_id == FLASH_UNKNOWN)
                return ERR_UNKNOWN_FLASH_TYPE;

        if ((s_first < 0) || (s_first > s_last)) {
                return ERR_INVAL;
        }

        if ((info->flash_id & FLASH_VENDMASK) !=
                (SST_MANUFACT & FLASH_VENDMASK)) {
                return ERR_UNKNOWN_FLASH_VENDOR;
        }

        prot = 0;
        for (sect = s_first; sect <= s_last; ++sect) {
                if (info->protect[sect]) {
                        prot++;
                }
        }
        if (prot)
                return ERR_PROTECTED;

        /*
         * Disable interrupts which might cause a timeout
         * here. Remember that our exception vectors are
         * at address 0 in the flash, and we don't want a
         * (ticker) exception to happen while the flash
         * chip is in programming mode.
         */
        cflag = icache_status ();
        icache_disable ();
        iflag = disable_interrupts ();

        /* Start erase on unprotected sectors */
       
        for (sect = s_first; sect <= s_last && !ctrlc (); sect++) {
                printf ("Erasing sector %2d ... ", sect);

                /* arm simple, non interrupt dependent timer */
                reset_timer_masked ();
               
                if (info->protect[sect] == 0) {        /* not protected */
                        volatile u16 *addr = (volatile u16 *) (info->start[sect]);

                        MEM_FLASH_ADDR1 = CMD_UNLOCK1;
                        MEM_FLASH_ADDR2 = CMD_UNLOCK2;
                        MEM_FLASH_ADDR1 = CMD_ERASE_SETUP;

                        MEM_FLASH_ADDR1 = CMD_UNLOCK1;
                        MEM_FLASH_ADDR2 = CMD_UNLOCK2;
                        *addr = CMD_ERASE_CONFIRM;

                        /* wait until flash is ready */
                        chip1 = 0;

                        do {
                                result = *addr;

                                /* check timeout */
                                if (get_timer_masked () > CFG_FLASH_ERASE_TOUT) {
                                        MEM_FLASH_ADDR1 = CMD_READ_ARRAY;
                                        chip1 = TMO;
                                        break;
                                }

                                if (!chip1 && (result & 0xFFFF) & BIT_ERASE_DONE)
                                        chip1 = READY;

                        } while (!chip1);

                        MEM_FLASH_ADDR1 = CMD_READ_ARRAY;

                        if (chip1 == ERR) {
                                rc = ERR_PROG_ERROR;
                                goto outahere;
                        }
                        if (chip1 == TMO) {
                                rc = ERR_TIMOUT;
                                goto outahere;
                        }

                        printf ("ok.\n");
                } else {                        /* it was protected */
                        printf ("protected!\n");
                }

        }

        if (ctrlc ())
                printf ("User Interrupt!\n");

outahere:
        /* allow flash to settle - wait 10 ms */
        udelay_masked (10000);

        if (iflag)
                enable_interrupts ();

        if (cflag)
                icache_enable ();

        return rc;

}

/*-----------------------------------------------------------------------
* Copy memory to flash
*/

volatile static int write_word (flash_info_t * info, ulong dest, ulong data)
{
        volatile u16 *addr = (volatile u16 *) dest;
        ulong flash_base;
        ulong result;
        int rc = ERR_OK;
        int cflag, iflag;
        int chip1;

        /*
         * Check if Flash is (sufficiently) erased
         */
        result = *addr;
        if ((result & data) != data)
                return ERR_NOT_ERASED;

        /*
         * Disable interrupts which might cause a timeout
         * here. Remember that our exception vectors are
         * at address 0 in the flash, and we don't want a
         * (ticker) exception to happen while the flash
         * chip is in programming mode.
         */
        cflag = icache_status ();
        icache_disable ();
        iflag = disable_interrupts ();

        flash_base = info->start[0];       

        MEM_FLASH_ADDR1 = CMD_UNLOCK1;
        MEM_FLASH_ADDR2 = CMD_UNLOCK2;
        MEM_FLASH_ADDR1 = CMD_PROGRAM;
        *addr = data;

        /* arm simple, non interrupt dependent timer */
        reset_timer_masked ();

        /* wait until flash is ready */
        chip1 = 0;
        do {
                result = *addr;

                /* check timeout */
                if (get_timer_masked () > CFG_FLASH_ERASE_TOUT) {
                        chip1 = ERR | TMO;
                        break;
                }
                if (!chip1 && ((result & 0x80) == (data & 0x80)))
                        chip1 = READY;

        } while (!chip1);

        *addr = CMD_READ_ARRAY;

        if (chip1 == ERR || *addr != data)
                rc = ERR_PROG_ERROR;

        if (iflag)
                enable_interrupts ();

        if (cflag)
                icache_enable ();

        return rc;
}

/*-----------------------------------------------------------------------
* Copy memory to flash.
*/

int write_buff (flash_info_t * info, uchar * src, ulong addr, ulong cnt)
{
        ulong wp, data;
        int rc;

        if (addr & 1) {
                printf ("unaligned destination not supported\n");
                return ERR_ALIGN;
        };

        if ((int) src & 1) {
                printf ("unaligned source not supported\n");
                return ERR_ALIGN;
        };

        wp = addr;

        while (cnt >= 2) {
                data = *((volatile u16 *) src);
                if ((rc = write_word (info, wp, data)) != 0) {
                        return (rc);
                }
                src += 2;
                wp += 2;
                cnt -= 2;
        }

        if (cnt == 1) {
                data = (*((volatile u8 *) src)) | (*((volatile u8 *) (wp + 1)) <<
                                                                                   8);
                if ((rc = write_word (info, wp, data)) != 0) {
                        return (rc);
                }
                src += 1;
                wp += 1;
                cnt -= 1;
        };

        return ERR_OK;
}
 
 
 

回复
您需要登录后才可以回帖 登录 | 注册

随便看看
查找数据手册?

EEWorld Datasheet 技术支持

相关文章 更多>>
关闭
站长推荐上一条 1/10 下一条

 
EEWorld订阅号

 
EEWorld服务号

 
汽车开发圈

 
机器人开发圈

About Us 关于我们 客户服务 联系方式 器件索引 网站地图 最新更新 手机版

站点相关: 国产芯 安防电子 汽车电子 手机便携 工业控制 家用电子 医疗电子 测试测量 网络通信 物联网

北京市海淀区中关村大街18号B座15层1530室 电话:(010)82350740 邮编:100190

电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2025 EEWORLD.com.cn, Inc. All rights reserved
快速回复 返回顶部 返回列表