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@790 cc03376c-175c-47c8-b038-4cd826a8556b
95 lines
3.5 KiB
C
95 lines
3.5 KiB
C
/************************************************************************/
|
|
/* */
|
|
/* AMD CFI Enabled Flash Memory Drivers */
|
|
/* File name: CFIDRIVE.C */
|
|
/* Revision: 1.0 5/07/98 */
|
|
/* */
|
|
/* Copyright (c) 1998 ADVANCED MICRO DEVICES, INC. All Rights Reserved. */
|
|
/* This software is unpublished and contains the trade secrets and */
|
|
/* confidential proprietary information of AMD. Unless otherwise */
|
|
/* provided in the Software Agreement associated herewith, it is */
|
|
/* licensed in confidence "AS IS" and is not to be reproduced in whole */
|
|
/* or part by any means except for backup. Use, duplication, or */
|
|
/* disclosure by the Government is subject to the restrictions in */
|
|
/* paragraph (b) (3) (B) of the Rights in Technical Data and Computer */
|
|
/* Software clause in DFAR 52.227-7013 (a) (Oct 1988). */
|
|
/* Software owned by */
|
|
/* Advanced Micro Devices, Inc., */
|
|
/* One AMD Place, */
|
|
/* P.O. Box 3453 */
|
|
/* Sunnyvale, CA 94088-3453. */
|
|
/************************************************************************/
|
|
/* This software constitutes a basic shell of source code for */
|
|
/* programming all AMD Flash components. AMD */
|
|
/* will not be responsible for misuse or illegal use of this */
|
|
/* software for devices not supported herein. AMD is providing */
|
|
/* this source code "AS IS" and will not be responsible for */
|
|
/* issues arising from incorrect user implementation of the */
|
|
/* source code herein. It is the user's responsibility to */
|
|
/* properly design-in this source code. */
|
|
/* */
|
|
/************************************************************************/
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include "cfiflash.h"
|
|
#include "libsys.h"
|
|
|
|
#define TEST_SIZE (1024*1024)
|
|
#define FLASH_OFFSET 0x700000
|
|
int main(void)
|
|
{
|
|
int i;
|
|
flash_t flash;
|
|
UINT8 *pFlash = (UINT8*)0xA4000000;
|
|
UINT32 result;
|
|
UINT8 *pBuf;
|
|
|
|
setbuf(stdout, NULL);
|
|
result = flash_find(&flash, 0xA4000000);
|
|
|
|
if (result < 0)
|
|
{
|
|
printf("flash_find() error!\n");
|
|
return 1;
|
|
}
|
|
|
|
printf("Found Flash at %8.8X\n", (UINT32)flash.pBase);
|
|
|
|
pBuf = (UINT8*)malloc(TEST_SIZE);
|
|
|
|
for (i=0; i < TEST_SIZE; i++)
|
|
pBuf[i] = i;
|
|
|
|
printf("Flash erase from %8.8X to %8.8X...", FLASH_OFFSET, FLASH_OFFSET+TEST_SIZE);
|
|
result = flash_erase(&flash, FLASH_OFFSET, TEST_SIZE);
|
|
if (result < 0)
|
|
{
|
|
printf("error!\n");
|
|
return 1;
|
|
}
|
|
printf("OK\n");
|
|
|
|
printf("Flash program from %8.8X to %8.8X...", FLASH_OFFSET, FLASH_OFFSET+TEST_SIZE);
|
|
result = flash_program(&flash, FLASH_OFFSET, pBuf, TEST_SIZE);
|
|
if (result < 0)
|
|
{
|
|
printf("error!\n");
|
|
return 1;
|
|
}
|
|
printf("OK\n");
|
|
|
|
printf("Flash verify from %8.8X to %8.8X...", FLASH_OFFSET, FLASH_OFFSET+TEST_SIZE);
|
|
result = flash_verify(&flash, FLASH_OFFSET, pBuf, TEST_SIZE);
|
|
if (result < 0)
|
|
{
|
|
printf("error!\n");
|
|
return 1;
|
|
}
|
|
printf("OK\n");
|
|
|
|
// PrintBuffer8((UINT8*)pFlash, 16, TEST_SIZE);
|
|
|
|
return 0;
|
|
}
|