Flashing the C6747 EVM

From Texas Instruments Wiki
Jump to: navigation, search

Purpose

This page will describe:

  • Issues with executing current examples from flash.
  • Necessary Modifications to the PSP Examples.
  • How to properly flash/run the Examples from SPI.

Prerequisites

This article assumes that you have;

  • Microsoft .NET Framework Version 2.0 installed on your system. This can be downloaded from the Microsoft Website.

Executing PSP Examples from Flash

As previously stated in the "Getting Started Guide for C6747", there are PSP examples located in the PSP Installation directory (by default C:\Program Files\Texas Instruments\pspdrivers_01_20_00_07). You can find these examples in the \packages\ti\pspiom\examples\evm6747 directory.

If you try to execute the projects from flash without making any modifications, you will notice that the project all of a sudden does not work anymore. These projects are built assuming the GEL file is in place (considering both the examples and GEL are developed by Spectrum). User application code should always configure the required peripherals rather than relying on the GEL file to make them work.

For example, the audio project does not include code for configuring the I/O pin MUX and PSC. The GEL file takes care of all of this for you in CCS. Therefore, the configuration should be included in the application code if you are planning to run your application from the SPI Flash.

Modifying PSP Examples

The Getting Started Guide for C6747 includes a section on "Loading Example Software". These examples are executed while the board is connected to CCS. If the example is flashed to the board "as is" you will notice that the application is no longer valid when executed from flash.


Note: In this article the Audio example will be used for modification. Similar steps, can be followed to modify other examples for proper execution.

1. Open the audioSample.pjt in the C6747 CCS window. From the CCS menu bar select Project->Open and Navigate to the audio project. The default directory of this project is "C:\Program Files\Texas Instruments\pspdrivers_01_20_00_07\packages\ti\psp\iom\examples\evm6747\audio\build."

2. Once the project is open, take the time to review the source files and the gel file.

3. Open the audioSample_main.c file. The following sections will need to be added to this file to perform the proper system configurations when booting from flash.


#define SYS_BASE               0x01C14000
#define KICK0R                 *(unsigned int*)(SYS_BASE + 0x038)  
#define KICK1R                 *(unsigned int*)(SYS_BASE + 0x03c)  
#define PINMUX0	               *(unsigned int*)(SYS_BASE + 0x120)	//PINMUX0
#define PINMUX1		       *(unsigned int*)(SYS_BASE + 0x124)	//PINMUX1
#define PINMUX2		       *(unsigned int*)(SYS_BASE + 0x128)	//PINMUX2
#define PINMUX3		       *(unsigned int*)(SYS_BASE + 0x12C)	//PINMUX3
#define PINMUX4		       *(unsigned int*)(SYS_BASE + 0x130)	//PINMUX4
#define PINMUX5		       *(unsigned int*)(SYS_BASE + 0x134)	//PINMUX5
#define PINMUX6		       *(unsigned int*)(SYS_BASE + 0x138)	//PINMUX6
#define PINMUX7		       *(unsigned int*)(SYS_BASE + 0x13C)	//PINMUX7
#define PINMUX8		       *(unsigned int*)(SYS_BASE + 0x140)	//PINMUX8
#define PINMUX9		       *(unsigned int*)(SYS_BASE + 0x144)	//PINMUX9
#define PINMUX10	       *(unsigned int*)(SYS_BASE + 0x148)	//PINMUX10
#define PINMUX11	       *(unsigned int*)(SYS_BASE + 0x14C)	//PINMUX11
#define PINMUX12	       *(unsigned int*)(SYS_BASE + 0x150)	//PINMUX12
#define PINMUX13	       *(unsigned int*)(SYS_BASE + 0x154)	//PINMUX13
#define PINMUX14	       *(unsigned int*)(SYS_BASE + 0x158)	//PINMUX14
#define PINMUX15	       *(unsigned int*)(SYS_BASE + 0x15C)	//PINMUX15
#define PINMUX16	       *(unsigned int*)(SYS_BASE + 0x160)	//PINMUX16
#define PINMUX17	       *(unsigned int*)(SYS_BASE + 0x164)	//PINMUX17
#define PINMUX18	       *(unsigned int*)(SYS_BASE + 0x168)	//PINMUX18
#define PINMUX19	       *(unsigned int*)(SYS_BASE + 0x16C)	//PINMUX19
#define CFGCHIP2               *(unsigned int*)(SYS_BASE + 0x184) 

/*PSC Module Related Registers*/ 
             
#define PSC0_BASE  	 0x01C10000 
#define PSC1_BASE  	 0x01E27000

#define PSC0_MDCTL 	(PSC0_BASE+0xA00)
#define PSC0_MDSTAT 	(PSC0_BASE+0x800)
#define PSC0_PTCMD  	*(unsigned int*) (PSC0_BASE + 0x120)
#define PSC0_PTSTAT 	*(unsigned int*) (PSC0_BASE + 0x128)

#define PSC1_MDCTL 	(PSC1_BASE+0xA00)
#define PSC1_MDSTAT 	(PSC1_BASE+0x800)
#define PSC1_PTCMD  	*(unsigned int*) (PSC1_BASE + 0x120)
#define PSC1_PTSTAT 	*(unsigned int*) (PSC1_BASE + 0x128)


/*Enable Function for PSC0*/

void PSC0_lPSC_enable(unsigned int PD, unsigned int LPSC_num) {

 *(unsigned int*) (PSC0_MDCTL+4*LPSC_num) = (*(unsigned int*) (PSC0_MDCTL+4*LPSC_num) & 0xFFFFFFE0) | 0x0003;
 PSC0_PTCMD = 0x1<<PD;
 while( (PSC0_PTSTAT & (0x1<<PD) ) !=0) ; /*Wait for power state transition to finish*/
 while( (*(unsigned int*)(PSC0_MDSTAT+4 * LPSC_num) & 0x3F) !=0x3); 
}

/*Enable Function for PSC1*/

void PSC1_lPSC_enable(unsigned int PD, unsigned int LPSC_num) {

 *(unsigned int*) (PSC1_MDCTL+4*LPSC_num) = (*(unsigned int*) (PSC1_MDCTL+4*LPSC_num) & 0xFFFFFFE0) | 0x0003;
 PSC1_PTCMD = 0x1<<PD;
 while( (PSC1_PTSTAT & (0x1<<PD) ) !=0) ; /*Wait for power state transition to finish*/
 while( (*(unsigned int*)(PSC1_MDSTAT+4 * LPSC_num) & 0x3F) !=0x3);
}


void Setup_System_Config( )
{

    KICK0R = 0x83e70b13;  // Kick0 register + data (unlock)
    KICK1R = 0x95a4f1e0;  // Kick1 register + data (unlock)

    PINMUX0  = 0x11111188;  // EMIFB, Check EMU0/RTCK
    PINMUX1  = 0x11111111;  // EMIFB
    PINMUX2  = 0x11111111;  // EMIFB
    PINMUX3  = 0x11111111;  // EMIFB
    PINMUX4  = 0x11111111;  // EMIFB
    PINMUX5  = 0x11111111;  // EMIFB
    PINMUX6  = 0x11111111;  // EMIFB
    PINMUX7  = 0x11111111;  // EMIFB, SPI0
    PINMUX8  = 0x21122111;  // UART2, McASP1, I2C0, I2C1
    PINMUX9  = 0x11011112;  // RMII CLK, McASP0, USB_DRVVBUS, UART2
    PINMUX10 = 0x22222221;  // RMII/ McASP0
    PINMUX11 = 0x11112222;  // McASP1, UART1, McASP0, MDIO (last 2 digits 0x22 for MDIO  instead of GPIO)
    PINMUX12 = 0x11111111;  // McASP0 / McASP1
    PINMUX13 = 0x22111111;  // SD / McASP1
    PINMUX14 = 0x88222222;  // SD / EMIFA
    PINMUX15 = 0x21888888;  // SD / EMIFA
    PINMUX16 = 0x11111112;  // SD / EMIFA
    PINMUX17 = 0x00100111;  // EMIFA
    PINMUX18 = 0x11111111;  // EMIFA
    PINMUX19 = 0x00000001;  // EMIFA

    CFGCHIP2 |= 0x00001000; // Enable USB1 clock
}


 void Setup_Psc_All_On( )
{
   int i;

   // PSC0
   PSC0_lPSC_enable(0, 0);
   PSC0_lPSC_enable(0, 1);
   PSC0_lPSC_enable(0, 2);
   PSC0_lPSC_enable(0, 3);  // EMIFA
   PSC0_lPSC_enable(0, 4);
   PSC0_lPSC_enable(0, 5);
   PSC0_lPSC_enable(0, 6);
   PSC0_lPSC_enable(0, 8);
   PSC0_lPSC_enable(0, 9);
   PSC0_lPSC_enable(0, 10);
   PSC0_lPSC_enable(0, 11);
   PSC0_lPSC_enable(0, 12);
   PSC0_lPSC_enable(0, 13);

	// PSC1
   PSC1_lPSC_enable(0, 1);
   PSC1_lPSC_enable(0, 2);
   PSC1_lPSC_enable(0, 3);
	PSC1_lPSC_enable(0, 4);
   PSC1_lPSC_enable(0, 5);
   PSC1_lPSC_enable(0, 6);  // EMIFB
   PSC1_lPSC_enable(0, 7);
   PSC1_lPSC_enable(0, 8);
   PSC1_lPSC_enable(0, 9);
   PSC1_lPSC_enable(0, 10);
   PSC1_lPSC_enable(0, 11);
   PSC1_lPSC_enable(0, 12);
   PSC1_lPSC_enable(0, 13);
   PSC1_lPSC_enable(0, 16);
   PSC1_lPSC_enable(0, 17);
   PSC1_lPSC_enable(0, 20);
   PSC1_lPSC_enable(0, 21);
   PSC1_lPSC_enable(0, 24);
   PSC1_lPSC_enable(0, 25);
   PSC1_lPSC_enable(0, 26);
   PSC1_lPSC_enable(0, 31);
}



Void main(Void)
{
     PSP_DEBUG("\nTII PSP Audio Sample Main\n");

Setup_System_Config( );
Setup_Psc_All_On( );

...
}

REMARK: these configuration functions may not work well if you are using optimization, causing your program not to boot properly. As a work around, you can use optimization in your project, and you can put just the initialization functions in a separate source file and with optimization "none" just for that file. To do that, right click on the source file and select "File Specific Options..." and select optimization "none". This way all the other files can have the optimization you want, and you can still boot.


5. Once you have made modifications to the main.c file the project must be re-compiled. From the CCS menu bar select "Project->Build". If the build is successful, you can proceed to flash the project according to the Flashing the board section of this document.

Flashing the Board

The D800K001 Bootloader is used for the TMS320C6747. Various boot mechanisms supported by the D800K001 boot loader ROM image are described in the application report "Using the D800K001 Bootloader."

Generating Boot Script (AIS image)

1. Install AISgen, by downloading and executing the latest installer here. It is recommended to install this tool at its default location (C:\Program Files\Texas Instruments\AISgen for D800K001).


2. To Start AISgen, navigate to the folder created during the installation process. If you used the defualt location, C:\Program Files\Texas Instruments\AISgen for D800K001. Double-click on AISgen.exe. The Application below should appear.


Note: Some controls on the window are initially disabled. For example, when the Configure PLL checkbox is not selected, the controls the PLL Settings box will be disabled. Any display that can't be set directly.


3. The default Configuration can be set by selecting File -> Configure for the EVM. This applies default settings to the PLL and EMIF controls. You have to manually specify the DSP application and output AIS files.


4. Specify a DSP application file (*.out), in the appropriate box by either typing its name in the appropriate box or using the browse button to locate it. By default the location is C:\Program Files\Texas Instruments\pspdrivers_01_20_00_07\packages\ti\pspiom\examples\evm6747\audio\bin\Debug\audioSample.out. A valid DSP application can be created by building a project in Code Composer Studio.


5. To specify the AIS file, type C:\file.ais (For example C:\audioSample.ais) in the AIS file text box (left of error indicator) or use the browser button (right of the error indicator) to do so. You will notice that the error indicator vanishes as the text is entered in the AIS file specification box.

The resulting setup should look like the following:

Aisgen.JPG

6. Now, clicking on the Generate AIS button will successfully generate AIS (as C:\ais.bin). The size of this file depends on the DSP application.


7. The utility also has other options which can be specified according to your application. These options are described in the "Using the D800K001 Bootloader Document".

Boot Mode and Boot Peripheral Setup

  • EEPROM or Flash
  • I2C/SPI
  • UART

PLL Setup

SDRAM Setup

  • EMIFA SDRAM
  • EMIFB SDRAM


Note: AIS files do not perform all of the configuration steps that a GEL file handles during development. Notably, AIS will not setup the Pin Multiplexing Control Register (PINMUX) and the Power and Sleep Controller Register (PSC) for any peripheral devices your DSP application uses. Be sure to add the necessary configuration steps to your application code before generating the AIS file.

Flashing the AIS Image

The AIS image generated by the AISgen utility will be located in the location specified in the AIS file field. This image is now ready to be flashed to the board with the following steps.

If you have completed the Getting Started guide you will have executed the Windows C674x DSP Installer, C674x_dsp_setupwin32_1_00_00_07.exe.

1. Open CCS3.3 and connect to the C6747.

2. Open the spiflash_writer_dsp.pjt. From the CCS menu bar Select Project -> Open. Navigate to the project. The project will be in the following directory C:\C674x_dsp_1_00_00_07\dsp_spi_flash_writer\ccsv3.3 , if default installation paths were followed.


3. Build the flash utility project with either debug or release configuration. From the CCS menu bar select Project -> Build, or press F7. This will create the spiflash_writer_dsp.out file.


4. Load and Execute spiflash_writer_dsp. From the CCS menu bar Select File -> Load Program, Navigate to the spiflash_writer_dsp.out Once the program is loaded, Select Debug -> Run from the CCS menu bar.

5. You will be prompted to enter the input type of the binary file to be flashed. Type dspais in the box.


SF: Got idcode ef 30 16
SF: Detected W25X32 with page size 256, total 4194304 bytes
Flash page size: 256 bytes
Flash sector size: 4096 bytes
Starting SPIWriter.
Enter the image type (one of "dspais" "armubl" "uboot" "other")


6. You will then be prompted to input the path of the user bootloader binary file. Please supply the path of the file to be flashed. Note that the DSP user bootloader to be flashed needs to be in AIS format, therefore, this will be the ais file generated in the previous section (For example C:\audioSample.ais).

7. The flash utility will continue printing out some messages, indicating that it is flashing the bootloader into SPI-flash. Once it runs successfully, the following message will be printed out.

Reading verifying the file.. Files matched

8. Disconnect CCS from the DSP and switch off the board. Set the SW2 switch on the board according to the table below.

Pin # 7 2 1 0 3
Position 0 1 0 1 0


9. At power up, the board should boot from SPI flash.

Debugging Tips

Removing initializations from the GEL file

If your program works with CCS but not with the stand alone flash version, you could be missing some initialization made by the GEL file. In order to debug that with CCS, you can comment parts of the GEL file (and save it) before you connect to the board:


CommentGEL.JPG


If your CCS connects automatically when it opens, you can change that configuration at Option-> Customize..:


Notconnect.JPG


After that, close CCS, power cycle the board and open CCS again.

Removing optimization from initializations

Check if you are using optimization in your project. Right click on the project and choose Build Options...:


Buildoptions.JPG


Optproject.JPG


If you are, you might want to remove the optimization as it can interfere with the initialization functions. If you do not want to remove the optimization from all the files in your project, you can remove it just from the file that has the initializations:


Filespecificoptions.JPG


Optfile.JPG


The file that has different options from the rest of the files in the project will show in yellow:

Yellowfile.JPG