Académique Documents
Professionnel Documents
Culture Documents
Introduction
This section describes the TMS320VC5402 (hereafter referred to as the C5402) bootloader and gives an overview of the steps involved in performing a bootload operation through the Host Port Interface (HPI). It also briefly describes the C5402 DSP Starter Kit (DSK) functionality, which will be used as a demonstration platform.
TMS320C54x is a trademark of Texas Instruments. Other trademarks are the property of their respective owners.
1.2
SPRA382
If the INT 2 signal is used to activate the HPI boot mode, there are two methods to obtain an input pulse on the INT 2 pin: Tie the Host Interrupt ( HINT ) pin directly to the INT 2 pin Generate a valid interrupt signal on INT 2 within 30 clock cycles from when the C5402 fetches the reset vector
Note that the HINT pin generates a valid interrupt signal at the start of the bootload process. The host processor uses the HPI port to send program code to the C5402 during the HPI boot. When the host is finished, it writes the code entry point to location 0x007F. The bootloader will recognize this change, branch execution to the entry point, and terminate, leaving the transferred code in control.
1.3
SPRA382
This application report has an associated Zip archive that may be downloaded from the same web location as this document. The archive contains the files that are mentioned in the given examples.
2.1
2.2
2.3
SPRA382
Note: This application report includes example code that uses the C5402 DSK host-side library, evmdsk54dll.lib. The DSK library contains communication routines that allow a host PC access to the DSK through its parallel port connection. Complete library documentation is available in the Code Composer Studio help file and in the library include file, evmdsk54dll.h. Appendix A shows the listing for this example, hpi-boot.cpp. The executable for this code is available on the TI website along with this application report. This program shows one way to read the listing file, initialize the DSK, and transmit the program code to the DSK using the evmdsk54dll libraries.
2.4
All programs in this example are run out of subdirectory hpi-boot in the associated archive. Using the COFF Hex extraction utility, coff_both, parse blink.out to produce a text listing. On the DOS command line, type: coff_both out blink.out Coff_both will prompt for the COFF type. Enter 2 because both Code Composer Studio versions 1.20 and 2.0 produce type two COFF files. The generated file will contain the hex listing and be entitled blink.out.c. An excerpt from its contents is shown in Figure 1.
SPRA382
Section = .vers src_addr = 0x0 length = 0x39 (57) dest_addr = 0x0 space = 0 0x0046, 0x004D, 0x0031, 0x0039, 0x003A, 0x0032, 0x0000, 0x006E, 0x0069, 0x0063, 0x0040, 0x002A, 0x0067, 0x002D, 0x0000, checksum = 0x 0x0072, 0x0061, 0x0032, 0x003A, 0x0032, 0x0030, 0x0062, 0x006B, 0x006F, 0x0064, 0x0028, 0x002A, 0x006C, 0x0064, 0x0069, 0x0079, 0x0020, 0x0032, 0x0031, 0x0030, 0x006C, 0x005F, 0x0073, 0x0062, 0x0023, 0x002A, 0x0075, 0x0030, 0x0020, 0x0020, 0x0030, 0x0034, 0x0020, 0x0030, 0x0069, 0x0062, 0x002E, 0x0000, 0x0029, 0x0020, 0x0065, 0x0039,
57
Figure 1.
Next, use the host-side bootloader code, hpi-boot, to read the extracted hex file and write the information to the DSK. Source code for this program is presented in Appendix A. On the DOS command line, type: hpi-boot blink_bios.out.c Note that the bootloader code is set up with the entry point of the DSK Blink demo. Other programs may require you to change this code in order to use a different entry point. Entry point information is best obtained from the .map file produced during the Code Composer Studio linking stage. This completes the HPI boot process. Status information will also be displayed while the program is running. Verify that the boot was successful by observing the blinking LEDs on the DSK.
References
1. TMS320C54x DSP Reference Set, Volume 1: CPU and Peripherals (literature number SPRU131) 2. Extracting Equivalent Hex Values From a COFF File application report (literature number SPRA573) 3. TMS320C54x Assembly Language Tools Users Guide (literature number SPRU102) 4. TMS320VC5402 and TMS320UC5402 Bootloader application report (literature number SPRA618) 5. Code Composer Studio Users Guide (literature number SPRU328) 6. TMS320VC5402 Fixed-Point Digital Signal Processor data sheet (literature number SPRS079)
SPRA382
int DSK_init(); int DSK_close(); int main(int argc, char* argv[]) { FILE *fp; char line[80]; char tokA[20], tokB[20], tokD[20]; //strings used to tokenize input int length, destaddr; short data[20000]; //Buffer used to hold data sections. Increase for large code short prog_entry=0x0500; //a default entry point int i,flag,eof_flag;
if (argc == 1) { //error printf ("Correct Syntax: hpi-boot FILENAME\n"); printf ("where FILENAME is a parsed COFF file\n"); exit(1); } else { if ((fp = fopen(argv[1], "r")) == NULL) printf ("File could not be opened for reading\n"); }
if (DSK_init()) //Initialize the DSK--open the DSK, HPI port, and configure exit(-1);
SPRA382
eof_flag=0; //shows if end of sections reached //This section scans for a new data section in //The new section is read into memory and then //When there are no more sections to read, the //writen to stop the boot process while (!eof_flag){ while ((fscanf(fp, "%s", tokA) != EOF) 7)) != 0)); if (!flag) { the parsed file. written to the DSP entry point is
fgets(line, sizeof(line), fp); //read src addr line fgets(line, sizeof(line), fp); //read length line fscanf(fp, "%s %s %x %s", tokA, tokB, &length, tokD); fscanf(fp, "%s %s %x %s", tokA, tokB, &destaddr, tokD); //read dest addr
fgets(line, sizeof(line), fp); //read spc addr line fgets(line, sizeof(line), fp); //read blank line
for (i=0; i< length; i++){ //reads and records data values fscanf(fp, "%x,", &data[i]) } // write single program section to 'C5402 printf("\n** Writing data section for HPI boot\n"); printf("Section Length: %#x\n", length); printf("Destination Address: %#x\n\n", destaddr); if (!evmdsk54x_hpi_write(hm, (PULONG) data, (PULONG) &length, (ULONG)destaddr, PROG_MEMORY, 0)) { printf(" -- failed"); return (-1); } } else { eof_flag = 1; // write prog start address in data mem 0x007F printf("** Writing program entry point to complete HPI boot\n"); printf("Entry point: %#x written at location 0x007f\n", prog_entry); if (!evmdsk54x_hpi_write_single(hm, (PULONG) &prog_entry, (ULONG) 0x7F, DATA_MEMORY, 0)) { printf(" -- failed"); return (-1); } // HPI booting ** } } printf("\nClosing...\n\n"); if (DSK_close()) exit (-1); ** End of standard initialization for 5402 DSK HPI access and
SPRA382
} return 0;
int DSK_init() { // ** Standard initialization for 5402 DSK HPI access and HPI booting **
// open a communication port with the // DSK parallel port interface printf ("\n** Initializing DSK communication channel"); if ((hd = evmdsk54x_open(port, boardType, openType, 1)) == INVALID_HANDLE_VALUE) { printf ("!! Error:\n"); printf ("evmdsk54x_open failed"); return (-1); } // open a communication port with the HPI printf ("\n** Opening HPI"); if (!(hm = evmdsk54x_hpi_open(hd))) { printf ("!! Error:\n"); printf ("evmdsk54x_hpi_open failed"); return (-1); } // hold the DSP in reset printf("\n** Resetting DSP"); if (!evmdsk54x_reset_dsp(hd, (ULONG)0x00)) { printf ("!! Error:\n"); printf ("evmdsk54x_reset_dsp failed"); return (-1); } // take the DSP out of reset printf("\n** Taking DSP out of reset"); if (!evmdsk54x_unreset_dsp(hd, (ULONG) 0x00)) { printf ("!! Error:\n"); printf ("evmdsk54x_unreset_dsp failed"); return (-1); } // disable on board flash access to ensure HPI // memory access will not affect the on-board flash printf("\n** Disabling FLASH access"); if (!evmdsk54x_flash_access(hd, FALSE)) { printf ("!! Error:\n"); printf ("evmdsk54x_flash_access failed"); return (-1); } printf("\n** DSK Init Passed\n\n"); return 0; }
int DSK_close() {
SPRA382
// close HPI communication port printf ("** Closing HPI\n"); if (!evmdsk54x_hpi_close(hm)) { printf ("!! Error:\n"); printf ("evmdsk54x_hpi_close failed\n"); return(-1); } // close DSK communicaiton port printf ("** Closing DSK communication channel\n"); if (!evmdsk54x_close(hd)) { printf ("!! Error:\n"); printf ("evmdsk54x_close failed\n"); return(-1); } return(0); }
10
IMPORTANT NOTICE Texas Instruments Incorporated and its subsidiaries (TI) reserve the right to make corrections, modifications, enhancements, improvements, and other changes to its products and services at any time and to discontinue any product or service without notice. Customers should obtain the latest relevant information before placing orders and should verify that such information is current and complete. All products are sold subject to TIs terms and conditions of sale supplied at the time of order acknowledgment. TI warrants performance of its hardware products to the specifications applicable at the time of sale in accordance with TIs standard warranty. Testing and other quality control techniques are used to the extent TI deems necessary to support this warranty. Except where mandated by government requirements, testing of all parameters of each product is not necessarily performed. TI assumes no liability for applications assistance or customer product design. Customers are responsible for their products and applications using TI components. To minimize the risks associated with customer products and applications, customers should provide adequate design and operating safeguards. TI does not warrant or represent that any license, either express or implied, is granted under any TI patent right, copyright, mask work right, or other TI intellectual property right relating to any combination, machine, or process in which TI products or services are used. Information published by TI regarding thirdparty products or services does not constitute a license from TI to use such products or services or a warranty or endorsement thereof. Use of such information may require a license from a third party under the patents or other intellectual property of the third party, or a license from TI under the patents or other intellectual property of TI. Reproduction of information in TI data books or data sheets is permissible only if reproduction is without alteration and is accompanied by all associated warranties, conditions, limitations, and notices. Reproduction of this information with alteration is an unfair and deceptive business practice. TI is not responsible or liable for such altered documentation. Resale of TI products or services with statements different from or beyond the parameters stated by TI for that product or service voids all express and any implied warranties for the associated TI product or service and is an unfair and deceptive business practice. TI is not responsible or liable for any such statements.
Mailing Address: Texas Instruments Post Office Box 655303 Dallas, Texas 75265