Project Templates in CCS

From Texas Instruments Wiki
Jump to: navigation, search

Introduction

Project Templates are a new feature in CCS4.2 and are used to support the creation of ready-made projects. Templates essentially define the inputs and processes required to create a project for a particular device.

Project templates are enabled through an Eclipse plugin. The template, at a minimum, requires a plugin.xml and manifest.mf file, and can additionally include directories with source files. The plugin manifest file plugin.xml contains bare minimum amount of information to make it an Eclipse plugin and the rest of it is XML that describes the actual template.


Using Templates

Templates are selected as part of the CCS New Project Wizard as shown in the screenshot below. The templates presented to the user are based on matching criteria defined by the templates. When the user selects a template from the list, the plug-in processes the selected template and creates a CCS project with the defined set of source files and build options.

Project Template in New Project Wizard


Example Templates

Example MSP430 and Stellaris templates are attached in this page which give an idea of how such templates can be created. The page also includes details on how to add the template to CCS and test it out.


Example MSP430 Template

The attached zip file contains a simple example template for MSP430. This example only comprises a single source file, hence the source is included with the template and can be packaged and installed as part of the CCS installation.

To understand the template structure, unzip the attached file and open the plugin.xml file.

The XML code describing the template is shown below:

    <extension point="com.ti.common.project.core.projectTemplates">

		<templateSet>
			<applicability>
                <when>
                    <context 
			deviceFamily="MSP430"               
			toolChain="TI"   
			deviceId="MSP430F54*"
                    />
		</when>
			</applicability>
			<template
				name="%msp430x54x_adc12_01_title"
				id="com.ti.msp430.example.ADC12_01.MSP430F54x"
				description="%msp430x54x_adc12_01_description"

				compilerBuildOptions="-vmspx -g --opt_level=2"
				linkerBuildOptions="--heap_size=200"
				postBuildStep="${CG_TOOL_ROOT}/bin/hex${CG_TOOL_SUFFIX}.exe --ti_txt
 ${BuildArtifactFileName} -o ${BuildArtifactFileBaseName}.txt -order MS -romwidth 16">

				<file path="resources/F54x_C_examples/msp430x54x_adc12_01.c"/>
				<group id="com.ti.common.project.core.otherExampleTemplates"/>
				
			</template>

			<template
				name="%msp430x54x_dma_01_title"
				id="com.ti.msp430.example.DMA_01.MSP430F54x"
				description="%msp430x54x_dma_01_description">
				
				<file path="resources/F54x_C_examples/msp430x54x_dma_01.c"/>
				<group id="com.ti.common.project.core.otherExampleTemplates"/>
				
			</template>

		</templateSet>

		<templateSet>
            		<applicability>
                <when>
                    <context
                          deviceFamily="MSP430"
			  toolChain="TI"
		  	  deviceId="MSP430F552*"
                    />
	
               </when>
            		</applicability>
			<template
				name="%msp430x552x_adc_01_title"
				id="com.ti.msp430.example_1"
				description="%msp430x552x_adc_01_description">
				
				<file path="resources/F552x_IAR_CCE_C_Code_Examples/MSP430F552x_adc_01.c"/>
				<group id="com.ti.common.project.core.otherExampleTemplates"/>
			</template>

			<template
				name="%msp430x552x_flashwrite_01_title"
				id="com.ti.msp430.example_2"
				description="%msp430x552x_flashwrite_01_description">
				
				<file path="resources/F552x_IAR_CCE_C_Code_Examples/MSP430F552x_flashwrite_01.c"/>
				<group id="com.ti.common.project.core.otherExampleTemplates"/>
			</template>

		</templateSet>

  • The example contains 2 sets of templates(one for MSP430F54* devices and another for MSP430F552* devices) each with 2 project examples
  • deviceFamily and deviceId are used to restrict the template applicability to certain families/devices.
  • name and description of the template are described in the file plugin.properties
  • <file path="resources/F54x_C_examples/msp430x54x_adc12_01.c"/> defines the source files to be added to the project. "resources" is a folder at the same level as plugin.xml. If source files are in a different location, relative path to source file can be specified.
  • <group id="com.ti.common.project.core.otherExampleTemplates"/> defines the name of the template group under which the template appears. In this example it is called "Other Examples" (this is set by another TI plugin so if a different name is required for the Template group/sub-group, it would need to be added by the CCS team).
  • compilerBuildOptions and linkerBuildOptions specify compiler and linker options for the project. These will over-ride the default CCS project options that are otherwise populated for the selected device family.

Testing the MSP430 Template

  • For CCS to recognize the template, copy the directory com.ti.msp430_1.0.0.0 from attached file into the CCSv4 \eclipse\plugins folder.
  • Restart CCS and create a new project by going to File->New->CCS Project.
  • Select Project Type to be MSP430
  • Select Device Variant to be any of the F54xx devices or any of the F552x devices. This screenshot shows that MSP430F5438 is selected.

Project settings in New Project Wizard

  • The Project Templates view will now show the 2 example projects created for that device under "Other Examples".

MSP430 Project Templates

  • Choose one of the projects and hit Finish.
  • CCS will create a project based on the template.


Example Stellaris Template

The attached zip file contains a example template for Stellaris Cortex M3. Basically it creates a template out of a couple of Stellarisware examples. Due to the size and directory structure of Stellarisware, the resources, in this case, are not copied into the CCS installation path as in the MSP430 example. Instead the plugin is included in the Stellarisware folder itself and CCS is made aware of it.

The XML code describing the template is shown below:

	<extension point="com.ti.common.project.core.projectTemplates">
		<templateSet>
<applicability>
                <when>
                    <context 
						deviceFamily="ARM"               
						toolChain="TI"   
						deviceId="Cortex M.LM3S9B92"
                    />
		</when>
            </applicability>
			<template
				name="%aes_expanded_key_title"
				id="com.ti.stellarisware.example.AES.LM9B92"
				description="%aes_expanded_key_description"
				linkerCommandFile="../../../boards/ek-lm3s9b92/aes_expanded_key/aes_expanded_key_ccs.cmd"
				compilerBuildOptions="-g --diag_warning=225 -me --define=ccs --define=PART_LM3S9B92 --define=TARGET_IS_TEMPEST_RB1 --gen_func_subsections --ual 
--include_path=${SW_ROOT}/boards/ek-lm3s9b92/aes_expanded_key/ccs/.. --include_path=${SW_ROOT}/third_party/aes 
--include_path=${SW_ROOT}/third_party --include_path=${SW_ROOT} 
--include_path=${SW_ROOT}/boards/ek-lm3s9b92/aes_expanded_key/ccs/../.. 
--include_path=${SW_ROOT}/boards/ek-lm3s9b92/aes_expanded_key/ccs/../../../.."
				linkerBuildOptions="-z -m${ProjName}.map --warn_sections -i${CG_TOOL_ROOT}/lib 
-i${CG_TOOL_ROOT}/include --reread_libs --rom_model --library=${SW_ROOT}/driverlib/ccs/Debug/driverlib.lib"
				postBuildStep="${CCE_INSTALL_ROOT}/utils/tiobj2bin/tiobj2bin.bat 
${BuildArtifactFileName} ${BuildArtifactFileBaseName}.bin ${CG_TOOL_ROOT}/bin/ofd470.exe 
${CG_TOOL_ROOT}/bin/hex470.exe ${CCE_INSTALL_ROOT}/utils/tiobj2bin/mkhex4bin.exe">
				
				<file path="../../../boards/ek-lm3s9b92/aes_expanded_key/aes_iv.c"/>
				<file path="../../../boards/ek-lm3s9b92/aes_expanded_key/aes_expanded_key.c"/>
				<file path="../../../boards/ek-lm3s9b92/aes_expanded_key/startup_ccs.c"/>
				<file path="../../../utils/uartstdio.c" targetDirectory="utils"/>
				<file path="../../../boards/ek-lm3s9b92/drivers/rit128x96x4.c" 
targetDirectory="drivers"/>
				<file path="../../../third_party/aes/aes.c" targetDirectory="third_party/aes" />
				<file path="../../../boards/ek-lm3s9b92/aes_expanded_key/aes_expanded_key_ccs.cmd"/>
				<group id="com.ti.common.project.core.otherExampleTemplates"/>
				
			</template>
		</templateSet>


		<templateSet>
			 <applicability>
                <when>
                    <context 
						deviceFamily="ARM"               
						toolChain="TI"   
						deviceId="Cortex M.LM3S8962"


                    />
				</when>
            </applicability>

			<template
				name="%enet_lwip_title"
				id="com.ti.stellarisware.example.LWIP.LM8962"
				description="%enet_lwip_description"
				linkerCommandFile="../../../boards/ek-lm3s8962/enet_lwip/enet_lwip_ccs.cmd"
				compilerBuildOptions="--include_path=${SW_ROOT}/boards/ek-lm3s8962/enet_lwip 
--include_path=${SW_ROOT}/boards/ek-lm3s8962 --include_path=${SW_ROOT}/third_party 
--include_path=${SW_ROOT}/third_party/lwip-1.3.2/apps --include_path=${SW_ROOT}/third_party/lwip-1.3.2/apps/httpserver_raw 
--include_path=${SW_ROOT} --include_path=${SW_ROOT}/third_party/lwip-1.3.2/src/include 
--include_path=${SW_ROOT}/third_party/lwip-1.3.2/ports/stellaris/include 
--include_path=${SW_ROOT}/third_party/lwip-1.3.2/src/include/ipv4 --include_path=${SW_ROOT}/boards/ek-lm3s8962/drivers 
--include_path=${SW_ROOT}/third_party/fatfs/src"
				linkerBuildOptions="-z -m${ProjName}.map --warn_sections -i${CG_TOOL_ROOT}/lib 
-i${CG_TOOL_ROOT}/include --reread_libs --rom_model --library=${SW_ROOT}/driverlib/ccs/Debug/driverlib.lib"
				postBuildStep="${CCE_INSTALL_ROOT}/utils/tiobj2bin/tiobj2bin.bat ${BuildArtifactFileName} 
${BuildArtifactFileBaseName}.bin ${CG_TOOL_ROOT}/bin/ofd470.exe ${CG_TOOL_ROOT}/bin/hex470.exe 
${CCE_INSTALL_ROOT}/utils/tiobj2bin/mkhex4bin.exe">
				
				<file path="../../../boards/ek-lm3s8962/enet_lwip/enet_lwip.c"/>
				<file path="../../../boards/ek-lm3s8962/enet_lwip/lmi_fs.c"/>
				<file path="../../../boards/ek-lm3s8962/enet_lwip/startup_ccs.c"/>
				<file path="../../../utils/locator.c" targetDirectory="utils"/>
				<file path="../../../utils/lwiplib.c" targetDirectory="utils"/>
				<file path="../../../utils/uartstdio.c" targetDirectory="utils"/>
				<file path="../../../utils/ustdlib.c" targetDirectory="utils"/>
				<file path="../../../third_party/lwip-1.3.2/apps/httpserver_raw/httpd.c" 
targetDirectory="third_party/lwip-1.3.2/apps/httpserver_raw" />
				<file path="../../../third_party/fatfs/port/mmc-ek-lm3s8962.c" 
targetDirectory="third_party/fatfs/port" />
				<file path="../../../third_party/fatfs/src/ff.c" targetDirectory="third_party/fatfs/src"/>
				<file path="../../../boards/ek-lm3s8962/drivers/rit128x96x4.c" targetDirectory="drivers" />	
				<file path="../../../boards/ek-lm3s8962/enet_lwip/enet_lwip_ccs.cmd"/>

				<group id="com.ti.common.project.core.otherExampleTemplates"/>
				
			</template>

		</templateSet>
  • The example contains 2 templates(one for LM3S9B92 and another for LM3S8962)
  • <file path="../../../boards/ek-lm3s9b92/aes_expanded_key/aes_iv.c"/> defines the source files to be added to the project. In this case the path is relative to the location of the plugin.xml file
  • Other properties are same as described in the MSP430 example
  • NOTE: One limitation in this example is that the compilerBuildOptions and linkerBuildOptions use the SW_ROOT macro for defining paths to include files and this macro needs to first be defined in the user's environment. To do this, go to Window->Preferences->General->Workspace->Linked Resources, and add a new linked resource named SW_ROOT with the location pointing to the root folder of Stellarisware. In future versions of CCS, we hope to add a enhancement to define a macro as part of the template.

Testing the Stellaris Template

  • For CCS to recognize this template:
    • copy the directory eclipse from attached file into the root level of Stellarisware, and
    • add a fle named stellaris.link to the folder C:\<ccs42_installdir>\ccsv4\eclipse\links with the contents: path=C:/StellarisWare

(where C:/Stellarisware is the root folder where Stellarisware is installed)

  • Create the SW_ROOT macro. Go to CCS menu Window->Preferences->General->Workspace->Linked Resources, and add a new linked resource named SW_ROOT with the location pointing to the root folder of Stellarisware.
  • Restart CCS and create a new project by going to File->New->CCS Project.
  • Select Project Type to be ARM
  • Select Device Variant to be LM3S9B92 or LM3S8962 devices.
  • Depending on the Device Variant, the appropriate template will show up under "Other Examples".
  • Choose one of the projects and hit Finish.
  • CCS will create a project based on the template.
  • Note that in this example the source files have been copied to the project folder, however the header files and libraries are still being referenced from the Stellarisware location.

Creating a new Template

To create a new template, start with one of the attached examples and customize plugin.xml and plugin.properties for your needs. Follow the above procedure to have CCS recognize the template and test out your template.


References

There are several examples of setting up BIOS project templates included in CCS4.2.

For BIOS 5.41.xx examples, take a look at
C:\<ccs42_installdir>\bios_5_41_07_24\eclipse\plugins\com.ti.rtsc.DSPBIOS.product.ui_5.41.7.24\plugin.xml

For BIOS 6.30.xx examples, take a look at
C:\<ccs42_installdir>\bios_6_30_02_42\eclipse\plugins\com.ti.rtsc.SYSBIOS.product.ui_6.30.2.42\plugin.xml