- Booting from Flash is now from cached area (faster)
Committed on the Free edition of March Hare Software CVSNT Server. Upgrade to CVS Suite for more features and support: http://march-hare.com/cvsnt/ git-svn-id: http://moon:8086/svn/vhdl/trunk@545 cc03376c-175c-47c8-b038-4cd826a8556b
This commit is contained in:
@@ -261,7 +261,6 @@ void PrintCPUinfo(void)
|
||||
#define MAX_IMG_SIZE (1024*1024) // bytes
|
||||
#define SDRAM_BASE 0x40000000
|
||||
#define FLASH_USE_BLOCK 1
|
||||
#define FLASH_BASE 0x00000000
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -280,13 +279,14 @@ int main(int argc, char *argv[])
|
||||
volatile UINT8 *pMem;
|
||||
volatile UINT32 *pROM32;
|
||||
volatile UINT32 *pMem32;
|
||||
volatile UINT32 *pFlashIO = (UINT32*)sys_flash_io;
|
||||
volatile UINT32 *pFlashIO = (UINT32*)sys_flash_io; // Flash in uncached area
|
||||
volatile UINT32 *pFlashMem = (UINT32*)sys_flash_mem; // Flash in cached area
|
||||
volatile UINT32 *pUSB = (UINT32*)sys_usb_data;
|
||||
|
||||
volatile UINT8 *ram8 = (UINT8*)SDRAM_BASE;
|
||||
volatile UINT16 *ram16 = (UINT16*)SDRAM_BASE;
|
||||
volatile UINT32 *ram32 = (UINT32*)SDRAM_BASE;
|
||||
UINT32 flashio_offset;
|
||||
UINT32 flash_offset;
|
||||
|
||||
*pReg = 0;
|
||||
haddr = 0;
|
||||
@@ -299,10 +299,11 @@ int main(int argc, char *argv[])
|
||||
return 1;
|
||||
}
|
||||
|
||||
flashio_offset = flash_aligned_addr_by_blocknum(&flash, block_sel);
|
||||
// Get flash offset by value of DIP-switch
|
||||
flash_offset = flash_get_offset_by_blocknum(&flash, block_sel);
|
||||
|
||||
ram32 = (UINT32*)(SDRAM_BASE);
|
||||
pFlashIO = (UINT32*)(sys_flash_io + flashio_offset);
|
||||
pFlashIO = (UINT32*)(sys_flash_io + flash_offset);
|
||||
|
||||
if (!(*pBtn & 8))
|
||||
{
|
||||
@@ -311,18 +312,21 @@ int main(int argc, char *argv[])
|
||||
if ((pImg_hdr->magic != MAGIC_EL) && (pImg_hdr->magic != MAGIC_EB))
|
||||
{
|
||||
sputs("\n\n");
|
||||
sputs("Invalid image found at ");print_word(flashio_offset); sputs(". Abort.\n");
|
||||
sputs("Invalid image found at ");print_word(flash_offset); sputs(". Abort.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
sputs("Booting application from flash (");print_word(flashio_offset);sputs(")...");
|
||||
sputs("Booting application from flash (");print_word(flash_offset);sputs(")...");
|
||||
|
||||
ram32 = (UINT32*)pImg_hdr->target_base;
|
||||
pFlashIO = (UINT32*)(sys_flash_io + pImg_hdr->img_base);
|
||||
img_size = pImg_hdr->img_size;
|
||||
|
||||
// It's safe to use cached Flash,
|
||||
// because D-Cache was invalidated during execution of start code
|
||||
pFlashMem = (UINT32*)(sys_flash_mem + pImg_hdr->img_base);
|
||||
|
||||
for (i=0; i < img_size/4; i++)
|
||||
ram32[i] = pFlashIO[i];
|
||||
ram32[i] = pFlashMem[i];
|
||||
|
||||
sputs("done\n");
|
||||
|
||||
@@ -366,14 +370,14 @@ int main(int argc, char *argv[])
|
||||
img_hdr.magic = MAGIC_EB;
|
||||
img_hdr.target_base = srec.addr;
|
||||
img_hdr.img_size = haddr - srec.addr;
|
||||
img_hdr.img_base = flashio_offset + sizeof(flash_img_hdr_t);
|
||||
img_hdr.hdr_next = flash_aligned_addr_by_offset(&flash, img_hdr.img_base + img_hdr.img_size);
|
||||
img_hdr.img_base = flash_offset + sizeof(flash_img_hdr_t);
|
||||
img_hdr.hdr_next = flash_get_offset_blockaligned(&flash, img_hdr.img_base + img_hdr.img_size);
|
||||
sputs("Size of application : ");print_word(img_hdr.img_size); sputs("\n");
|
||||
sputs("Programming flash at : ");print_word(flashio_offset); sputs("\n");
|
||||
sputs("Programming flash at : ");print_word(flash_offset); sputs("\n");
|
||||
sputs("Next free flash offset : ");print_word(img_hdr.hdr_next); sputs("\n");
|
||||
|
||||
sputs("Flash erase...");
|
||||
result = flash_erase(&flash, flashio_offset, img_hdr.img_size + sizeof(flash_img_hdr_t));
|
||||
result = flash_erase(&flash, flash_offset, img_hdr.img_size + sizeof(flash_img_hdr_t));
|
||||
if (IS_ERROR(result))
|
||||
{
|
||||
sputs("failed (");print_word(result);sputs(")\n");
|
||||
@@ -382,7 +386,7 @@ int main(int argc, char *argv[])
|
||||
sputs("done\n");
|
||||
|
||||
sputs("Flash write...");
|
||||
result = flash_program(&flash, flashio_offset, (UINT8*)&img_hdr, sizeof(flash_img_hdr_t));
|
||||
result = flash_program(&flash, flash_offset, (UINT8*)&img_hdr, sizeof(flash_img_hdr_t));
|
||||
if (IS_ERROR(result))
|
||||
{
|
||||
sputs("failed (");print_word(result);sputs(")\n");
|
||||
@@ -404,9 +408,9 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
}
|
||||
sputs("passed\n");
|
||||
|
||||
// Jump to reset vector
|
||||
Jump_to((void*)0xBFC00000);
|
||||
// sputs("\nPush reset button to boot!\n");
|
||||
// *pReg = 1;
|
||||
|
||||
break;
|
||||
|
||||
|
||||
+1270
-1270
File diff suppressed because it is too large
Load Diff
+1270
-1270
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user