📄 dsk6xldr.c
字号:
/*-------------------------------------------------------------------------*/
/* FILENAME: dsk6xldr.c -- DSK - HOST Code */
/* */
/* Rev 2.02 11 May 2001 T.J.Dillon */
/* */
/*-------------------------------------------------------------------------*/
/* HISTORY */
/* Rev 1.00 Created */
/* Rev 1.10 Added command line options */
/* Rev 1.20 Added error on file not found */
/* Rev 1.21 Added -pd option */
/* Rev 1.22 Corrected help error */
/* Rev 1.30 Added SDRAM Extension Register */
/* Rev 2.00 Changed SDRAM params and Update for C6711 DSK */
/* Rev 2.01 Added filename to help, added L2CFG and MAR to emif */
/* Rev 2.02 Update for CCS2.0 support */
/* */
/*-------------------------------------------------------------------------*/
#include <stdio.h>
#include <windows.h>
#include "dsk6x11hpi.h"
#include "dsk6xldr.h"
#define TRUE 1
#define FALSE 0
#define EREG 10
static FILE *pFile=NULL;
static FILE *pBoardFile=NULL;
char *DefaultBoard = ".\\..\\..\\..\\cc\\bin\\BrdDat\\dsk6x11.cfg";
void setup_emif(dskHANDLE dskBoard);
void hpi_ReadnWrite(dskHANDLE dskBoard);
BOOL FILEDefined=FALSE;
BOOL COFFLoad=TRUE;
BOOL EMIFSetup=FALSE;
BOOL HPIReadWrite=FALSE;
/*-------------------------------------------------------------------------*/
/* main() */
/*-------------------------------------------------------------------------*/
void main(int argc1, char *argv1[])
{
dskHANDLE hBd; /* Board device handle */
short iBd = 0; /* Board index */
BOOL bExcl = 1; /* Exclusive open = TRUE */
short iMp = 1; /* Map selector = MAP1 */
char coffNam[80]="\0";
/* COFF file name */
BOOL bVerbose = 0; /* COFF load verbose mode = FALSE */
BOOL bClr = 0; /* Clear bss mode = FALSE */
BOOL bDump = 0; /* Dump mode = FALSE */
ULONG nPort=0xa; /* Default port definition */
char *sBoardFile = DefaultBoard;
int i;
/*-----------------------------------------------------------------------*/
/* Parse Command Line */
/*-----------------------------------------------------------------------*/
for(i=1; argc1 > i; i++)
{
if( argv1[i][0] != '-' )
{
strncpy(coffNam,argv1[i],19);
FILEDefined=TRUE;
}
else
{
switch(tolower(argv1[i][1]))
{
case 'd':
HPIReadWrite=TRUE;
break;
case 'e':
EMIFSetup=TRUE;
break;
case 'h':
case '?':
printf( "Syntax: %s [-?] [-e] [-d] [filename]\n", TestName );
printf( "\n");
printf( " -?,h : Displays command line help info.\n");
printf( " -ffilename.ext : Specifies the board configuration file.\n");
printf( " -e : Modify EMIF prior to COFF load.\n");
printf( " -d : Debug mode. Read/Write via HPI\n");
printf( "filename : Name of out file to load.\n\n");
printf("\nTMS320C6211/6711 DSK %s, ",TestType);
printf("Version 2.02, May 2001");
printf("\nCopyright (c) 2001 ");
printf("by Texas Instruments Incorporated. ");
printf("\nAll rights reserved.\n\n");
COFFLoad=FALSE;
break;
case 'f':
sBoardFile = &argv1[i][2];
break;
default:
printf( "\nOPTION (-%c) IGNORED: \n Valid options are -d,-e,-?,-h and -pport!\n",argv1[i][1]);
break;
}
}
}
pBoardFile = fopen( sBoardFile, "r" );
if ( pBoardFile == NULL )
{
printf( "ERROR: Please specify a valid board configuration file via the -f option.\n" );
exit(1);
}
else
{
fclose(pBoardFile);
}
if(COFFLoad)
{
/*-------------------------------------------------------------------*/
/* Print Program header */
/*-------------------------------------------------------------------*/
printf("\nTMS320C6211/6711 DSK %s Program ", TestType);
printf(", Version 2.02, May 2001 ");
printf("\nCopyright (c) 2001 ");
printf("by Texas Instruments Incorporated. ");
printf("All rights reserved.\n\n");
/*-------------------------------------------------------------------*/
/* Request name of .out file */
/*-------------------------------------------------------------------*/
if(!FILEDefined)
{
printf("\nInput the name of a .out file to be loaded: ");
scanf("%s",coffNam);
}
/*-------------------------------------------------------------------*/
/* Append .out to filename (if missing) */
/*-------------------------------------------------------------------*/
if(strchr( coffNam, '.') == NULL)
strcat(coffNam, ".out");
/*-------------------------------------------------------------------*/
/* Test for filename */
/*-------------------------------------------------------------------*/
pFile=fopen( coffNam, "r");
if(pFile == NULL)
{
printf("\nERROR: File %s does not exist!\n\n",coffNam);
}
else
fclose(pFile);
/*-------------------------------------------------------------------*/
/* Open a driver connection to a dsk6x board. */
/*-------------------------------------------------------------------*/
if ( !dsk6x_open(sBoardFile,&hBd) )
{
printf("FAILED: dsk6x_open()!\n");
exit(1);
}
/*-------------------------------------------------------------------*/
/* Cause a DSP reset. */
/*-------------------------------------------------------------------*/
if ( !dsk6x_reset_dsp(hBd,0,1) )
{
printf("FAILED: dsk6x_reset_dsp()!\n");
exit(2);
}
/*-------------------------------------------------------------------*/
/* Establish a connection to the HPI of a target board. */
/*-------------------------------------------------------------------*/
if ( !dsk6x_hpi_open(hBd))
{
printf("FAILED: dsk6x_hpi_open()!\n");
exit(3);
}
/*-------------------------------------------------------------------*/
/* Modify EMIF configuration before COFF load. */
/*-------------------------------------------------------------------*/
if(EMIFSetup)
{
setup_emif(hBd);
}
/*-------------------------------------------------------------------*/
/* Read a COFF file and write the data to DSP memory. */
/*-------------------------------------------------------------------*/
if (dsk6x_coff_load(hBd,coffNam,bVerbose,bClr,bDump))
{
printf("FAILED: dsk6x_coff_load()!\n");
exit(4);
}
/*-------------------------------------------------------------------*/
/* Generate a DSPINT to start program */
/*-------------------------------------------------------------------*/
if (!dsk6x_hpi_generate_int(hBd))
{
printf("FAILED: dsk6x_hpi_generate_int()!\n");
exit(5);
}
/*-------------------------------------------------------------------*/
/* Use HPI to read and write values to DSP program */
/*-------------------------------------------------------------------*/
if(HPIReadWrite)
{
hpi_ReadnWrite(hBd);
}
/*-------------------------------------------------------------------*/
/* Close the new HPI session started with evm6x_hpi_open() */
/*-------------------------------------------------------------------*/
if (!dsk6x_hpi_close(hBd))
{
printf("FAILED: dsk6x_hpi_close()!\n");
exit(6);
}
/*-------------------------------------------------------------------*/
/* Close a previously opened driver connection to a board. */
/*-------------------------------------------------------------------*/
if (!dsk6x_close(hBd))
{
printf("FAILED: dsk6x_close()!\n");
exit(7);
}
}
/*-----------------------------------------------------------------------*/
/* Cleanup */
/*-----------------------------------------------------------------------*/
printf("PASSED: HOST Program Complete!\n");
exit(0);
} /* end of main() */
void setup_emif(dskHANDLE dskBoard)
{
char *emif_config_name[EREG]={"GCTL", /* Global Control Reg */
"CE1", /* CE1 Space Control Reg */
"CE0", /* CE0 Space Control Reg */
"CE2", /* CE2 Space Control Reg */
"CE3", /* CE3 Space Control Reg */
"SDRAMCTL", /* SDRAM Control Reg */
"SDRAMTIMING", /* SDRAM Timing Reg */
"SDRAMEXT", /* SDRAM Extension Reg */
"L2CFG", /* L2 Cache Config Reg */
"MAR"}; /* Memory Attribute Reg */
ULONG emif_config_addr[EREG]={0x01800000,/* Global Control Reg */
0x01800004, /* CE1 Space Control Reg */
0x01800008, /* CE0 Space Control Reg */
0x01800010, /* CE2 Space Control Reg */
0x01800014, /* CE3 Space Control Reg */
0x01800018, /* SDRAM Control Reg */
0x0180001C, /* SDRAM Timing Reg */
0x01800020, /* SDRAM Extension Reg */
0x01840000, /* L2 Cache Config Reg */
0x01848200}; /* Memory Attribute Reg */
/*************************************************************************
* Standard 6211/6711 DSK includes 2 MT48LC1M16A1-7 devices = 4MB SDRAM *
* For these devices use the following parameters: *
* EMIF_SDCTRL=0x07126000 *
* If MT48LC1M16A1-10 devices are installed use the following parameters: *
* EMIF_SDCTRL=0x07227000 *
* /|\ 16Mb parts = 4MB SDRAM /|\ *-------------------------------------*
*----------------------------------* \|/ 64Mb parts = 16MB SDRAM \|/ *
* If MT48LC4M16A2-10 devices are installed use the following parameters: *
* EMIF_SDCTRL=0x57227000 *
*************************************************************************/
ULONG emif_config_value[EREG]={0x00003040,/* Global Control Reg */
0xFFFFFF23, /* CE1 Space Control Reg */
0xFFFFFF30, /* CE0 Space Control Reg */
0xFFFFFF23, /* CE2 Space Control Reg */
0xFFFFFF23, /* CE3 Space Control Reg */
0x07126000, /* SDRAM Control Reg */
0x0000061A, /* SDRAM Timing Reg */
0x00054529, /* SDRAM Extension Reg */
0x00000000, /* L2 Cache Config Reg */
0x00000000}; /* Memory Attribute Reg */
int i;
ULONG writeLength=4;
char Change[4]="\0";
/* Loop through all EMIF registers */
for(i=0;i<EREG;i++)
{
printf("Default Configuration value for %s(0x%x)=0x%x \n",
emif_config_name[i], emif_config_addr[i], emif_config_value[i]);
printf(" Do you want to keep it? (Yes/No): ");
scanf("%s",Change);
/* Yes to keep default */
if(!strncmp("Yes",Change,1) || !strncmp("yes",Change,1))
{ // no change
}
else /* Enter new value */
{
printf("Input Configuration value for %s(0x%x): ",
emif_config_name[i], emif_config_addr[i]);
scanf("%x",&emif_config_value[i]);
}
/* Write configuration value to register */
dsk6x_hpi_write(dskBoard, &emif_config_value[i], &writeLength,
emif_config_addr[i]);
}
}
void hpi_ReadnWrite(dskHANDLE dskBoard)
{
ULONG writeLength=4,read_value,mem_addr;
char choice[20];
int dont_stop=1;
/* HPI read and write */
do
{
printf(" Do you want to (Read=r/Write=w/Quit=q)? : ");
scanf("%s",choice);
switch(*choice)
{
case 'r':
printf(" Input Memory Address? : ");
scanf("%x",&mem_addr);
dsk6x_hpi_read(dskBoard, &read_value, &writeLength,
mem_addr);
printf(" READ mem_addr(0x%x)=0x%x\n",mem_addr,read_value);
break;
case 'w':
printf(" Input Memory Address? : ");
scanf("%x",&mem_addr);
printf(" Input Value? : ");
scanf("%x",&read_value);
dsk6x_hpi_write(dskBoard, &read_value, &writeLength,
mem_addr);
printf(" WRITE mem_addr(0x%x)=0x%x\n",mem_addr,read_value);
break;
case 'q':
printf(" ... QUIT!\n");
dont_stop=0;
break;
default:
printf(" ERROR The only choices are r,w,q !\n");
break;
}
} while (dont_stop);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -