This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

dm6437板卡BOOT失败

一块SEED的DEC6437板卡,使用合众达提供的boot例程boot工程时出现如下问题:

boo较小的out文件能够成功烧写,当我Boot较大(大约700kb)的.out文件时,程序也能够成功烧写进flash,但是再执行boot例程是就会出错,板卡直接断开连接,这种情况下反复跑boot很多次才能够重新把例程的小程序烧进去。当boot更大的程序时(大约850kb左右),boot的例程可以运行,但是程序并没有被成功烧写进flash,即断开仿真器板卡重新上电后程序并没有运行。

查询技术文档发现dm6437板卡的flash大小为4mb,为什么1m不到的out文件烧不进去呢?

这里提供一下seed公司提供的boot例程,大约100行代码,并没有发现有什么地方限制了烧写文件大小

/*
* Copyright 2008 by SEED International Ltd.
* All rights reserved. Property of SEED International Ltd.
*/

/*
* DM6437 Test Suite
*
*/

#include "stdio.h"
#include "evmdm6437_flash.h"
#include "FLASH_PRG.h"

int BootNum;
unsigned int boot_addr;
unsigned int Section_addr;
unsigned int Section_size;
unsigned int Section_flag;

PFILE_HEADER File_header;
POPTIONAL_FILE_HEADER Opt_File_header;
PSECTION_HEADER Sec_header;
Uint8 AddrBuf[4];
Uint8 Buffer[0x100000];
#pragma DATA_SECTION(Buffer,".buffer");
/* ------------------------------------------------------------------------ *
* *
* norflash_test( ) *
* *
* ------------------------------------------------------------------------ */
Int16 boot_test( )
{
int i;
FILE *fill;
unsigned int FillSize;

/* Initialize Flash */
EVMDM6437_FLASH_init();

for(i=0;i<0x100000;i++)
{
Buffer[i]=0;
}

// Fill out buffer with "friendly" data
fill = fopen("led.out","rb");
// File length
fseek(fill , 0 , SEEK_END);
FillSize = ftell(fill);
if(FillSize > 0x100000)
{
printf("The OUT file is too big!\n");
}

fill = fopen("led.out","rb"); // the file will be opened can be changed
fread(&Buffer[0], FillSize, sizeof(fill), fill);

/* ---------------------------------------------------------------- *
* Erase *
* ---------------------------------------------------------------- */
printf( " Erasing Flash by erasing entire chip\n");
Erase_Entire_Chip();

/* ---------------------------------------------------------------- *
* Write *
* ---------------------------------------------------------------- */
printf( " Writing Flash for boot\n" );
File_header = (FILE_HEADER *) &Buffer[0x0];
Opt_File_header = (OPTIONAL_FILE_HEADER *) &Buffer[0x16];

// Boot section
for(i = 0; i < File_header->fileSecNum; i++)
{
Sec_header = (SECTION_HEADER *) &Buffer[0x32+ i*0x30];
//'.bootld'
if( (Sec_header->secCharacterLo1 == 0x622E) && \
(Sec_header->secCharacterLo2 == 0x6F6F) && \
(Sec_header->secCharacterHi1 == 0x6C74) && \
(Sec_header->secCharacterHi2 == 0x0064))
{
BootNum = i;
// 在地址0x42000000处写BOOT
boot_addr = FLASH_BASE;
Section_addr = TO32(Sec_header->secRawLo, Sec_header->secRawHi);
Section_addr += (Uint32) Buffer;
Section_size = TO32(Sec_header->secSizeLo, Sec_header->secSizeHi);
EVMDM6437_FLASH_write(Section_addr, boot_addr, Section_size);
break;
}
}

// 在地址0x42000400处写ENTRY_POINT
AddrBuf[0] = Opt_File_header->EntryPointLo;
AddrBuf[1] = Opt_File_header->EntryPointLo>>8;
AddrBuf[2] = Opt_File_header->EntryPointHi;
AddrBuf[3] = Opt_File_header->EntryPointHi>>8;
boot_addr = FLASH_BASE + 0x400;
EVMDM6437_FLASH_write((Uint32)&AddrBuf[0], boot_addr, 4);
boot_addr += 4;

// Other section
for(i = 0; i < File_header->fileSecNum; i++)
{
Sec_header = (SECTION_HEADER *) &Buffer[0x32+ i*0x30];
Section_flag = TO32(Sec_header->secFlagLo, Sec_header->secFlagHi);
Section_size = TO32(Sec_header->secSizeLo, Sec_header->secSizeHi);
if((Section_flag & 0x60) && (i != BootNum)&& Section_size)
{
// 长度
AddrBuf[0] = Sec_header->secSizeLo;
AddrBuf[1] = Sec_header->secSizeLo>>8;
AddrBuf[2] = Sec_header->secSizeHi;
AddrBuf[3] = Sec_header->secSizeHi>>8;
EVMDM6437_FLASH_write((Uint32)&AddrBuf[0], boot_addr, 4);
boot_addr += 4;

// 在RAM中的地址
AddrBuf[0] = Sec_header->secPhyAddrLo;
AddrBuf[1] = Sec_header->secPhyAddrLo>>8;
AddrBuf[2] = Sec_header->secPhyAddrHi;
AddrBuf[3] = Sec_header->secPhyAddrHi>>8;
EVMDM6437_FLASH_write((Uint32)&AddrBuf[0], boot_addr, 4);
boot_addr += 4;

// 数据
Section_addr = TO32(Sec_header->secRawLo, Sec_header->secRawHi);
Section_addr += (Uint32) Buffer;
Section_size = TO32(Sec_header->secSizeLo, Sec_header->secSizeHi);
if(Section_size % 4)
{
Section_size += 4 - (Section_size % 4);
}
EVMDM6437_FLASH_write(Section_addr, boot_addr, Section_size);
boot_addr += Section_size;
}

else
{
}
}

//table end
for(i = 0; i < 4; i++)
AddrBuf[i] = TABLE_END>>(8*i);
EVMDM6437_FLASH_write((Uint32)&AddrBuf[0], boot_addr, 4);
boot_addr += 4;
EVMDM6437_FLASH_write((Uint32)&AddrBuf[0], boot_addr, 4);
boot_addr += 4;
EVMDM6437_FLASH_write((Uint32)&AddrBuf[0], boot_addr, 4);
/* ---------------------------------------------------------------- *
* Erase *
* ---------------------------------------------------------------- */
printf( " Boot writing finished\n" );

// Test Passed
return 0;
}

unsigned int TO32(unsigned short datalow, unsigned short datahigh)
{
unsigned int data;
data = datalow + (datahigh <<16);
return(data);
}

谢谢帮助!