?? flash_test.c
字號:
/*
* Copyright 2005 by Spectrum Digital Incorporated.
* All rights reserved. Property of Spectrum Digital Incorporated.
*
* Not for distribution.
*/
/*
* NOR Flash Test
*
*/
#include "stdio.h"
#include "davincievm_flash.h"
#define UBOOT_BASE 0x2000000
#define UIMAGE_BASE 0x2050000
static Uint8 bootloader[0x6000000];
static Uint8 uImage[0x6000000];
static Uint32 ubootsize;
static Uint32 uImagesize;
/* ------------------------------------------------------------------------ *
* *
* norflash_test( ) *
* *
* ------------------------------------------------------------------------ */
Int16 norflash_test( )
{
Int16 retcode = 0;
Uint32 npages=64;
Uint32 nbytes;
FILE *ubootfile;
FILE *uImagefile;
char ubootname[15];
char uImagename[15];
/* Initialize Flash */
DAVINCIEVM_FLASH_init();
nbytes = npages * FLASH_PAGESIZE;
printf( " %d Pages\n", npages );
printf( " %d Mbytes\n", nbytes >> 20 );
printf("****************************************************************\n");
printf("****************************************************************\n");
printf(" ERASE Flash Operation \n");
printf(" SEED DaVinci EVM v1.0 2006.12.07 \n");
printf("****************************************************************\n");
printf("****************************************************************\n");
/* ---------------------------------------------------------------- *
* Erase *
* ---------------------------------------------------------------- */
printf( " Erasing Flash [%d-%d] pages\n", 0, npages );
/* Erase all bytes of Flash */
if ( ( retcode = DAVINCIEVM_FLASH_erase( UBOOT_BASE, nbytes ) ) != 0 )
{
printf( " Error: Erasing code %d\n", retcode );
return retcode | 0x8000;
}
printf("****************************************************************\n");
printf(" ERASE Flash Operation Successfully \n");
printf("****************************************************************\n");
printf("\n");
printf("****************************************************************\n");
printf("****************************************************************\n");
printf(" Write U-boot to Flash Operation \n");
printf(" SEED DaVinci EVM v1.0 2006.12.07 \n");
printf("****************************************************************\n");
printf("****************************************************************\n");
printf("\n");
/* ---------------------------------------------------------------- *
* Write *
* ---------------------------------------------------------------- */
printf("Enter uboot file name\n");
scanf("%s",ubootname);
ubootfile=fopen(ubootname,"rb");
if(ubootfile==NULL)
printf("Can not open uboot file!!!\n") ;
fseek(ubootfile,0,SEEK_END);
ubootsize=ftell(ubootfile);
printf("Uboot file size %d(0x%x)\n",ubootsize,ubootsize);
fseek(ubootfile,0,SEEK_SET);
printf("Reading U-boot data ..... waiting for a while\n");
fread(bootloader,ubootsize,1,ubootfile);
printf("Writing U-BOOT to Flash ....waiting for a while\n");
retcode |= DAVINCIEVM_FLASH_write( (Uint32)bootloader, UBOOT_BASE, ubootsize );
/* Check errors */
if ( retcode != 0 )
{
printf( " Error: Writing code %d\n", retcode );
return retcode | 0x8000;
}
fclose(ubootfile);
printf("****************************************************************\n");
printf("Congratulations on Writing U-boot into Flash successfully....\n");
printf("****************************************************************\n");
printf("\n");
retcode=0;
printf("****************************************************************\n");
printf("****************************************************************\n");
printf(" Write uImage to Flash Operation \n");
printf(" SEED DaVinci EVM v1.0 2006.12.07 \n");
printf("****************************************************************\n");
printf("****************************************************************\n");
printf("\n");
printf("Enter uImage file name\n");
scanf("%s",uImagename);
uImagefile=fopen(uImagename,"rb");
if(uImagefile==NULL)
printf("Can not open uImage file!!!\n");
fseek(uImagefile,0,SEEK_END);
uImagesize=ftell(uImagefile);
printf("uImage file size %d\n",uImagesize);
fseek(uImagefile,0,SEEK_SET);
printf("Reading uImage data ..... waiting for a while\n");
fread(uImage,uImagesize,1,uImagefile);
printf("Writing uImage to Flash ....waiting for a while\n");
retcode |= DAVINCIEVM_FLASH_write( (Uint32)uImage, UIMAGE_BASE, uImagesize );
/* Check errors */
if ( retcode != 0 )
{
printf( " Error: Writing code %d\n", retcode );
return retcode | 0x8000;
}
fclose(uImagefile);
printf("****************************************************************\n");
printf("Congratulations on Writing U-boot into Flash successfully....\n");
printf("****************************************************************\n");
printf("\n");
printf("****************************************************************\n");
printf("****************************************************************\n");
printf("Congratulations on Writing U-boot and uImage into Flash successfully....\n");
printf("****************************************************************\n");
printf("****************************************************************\n");
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -