Contents

Makefile Generator Tutorial

This example shows how to use the XMakefile functionality of IDE Link component to generate and build code from a simple Simulink® model.

You can use the XMakefile feature to:

  • Automate software builds without using an IDE

  • Customize the software build process

  • Add support for software build tool chains

Supported IDEs/tool chains:

  • Texas Instruments™ Code Composer Studio™ v3.3

  • Texas Instruments™ Code Composer Studio™ v4.x

  • Texas Instruments™ Code Composer Studio™ v5.x

Supported processors:

Introduction

This application example shows how to use the XMakefile functionality to generate and build code from a simple model using a makefile. You will configure your model to generate code for a Texas Instruments (TI) processor and to build with a Texas Instruments Code Composer Studio (CCS) tool chain.

Task 1 - Design and Simulate Algorithm

The following figure shows an algorithmic model that calculates the sum and difference of two random signal vectors containing 16 data points of int32 type.

1. Open the sumdiff_ccsdemosumdiff_ccsdemo model.

2. Click the "Run" button to run the simulation.

Task 2 - Configure Model for Code Generation

IDE Link component also provides some configuration parameters as part of simulation configuration parameters of the model. For more information, please refer to the product documentation.

In this step, you will modify one option for example purposes.

1. Open the Model Configuration Parameters dialog, set the "System target file" parameter under "Code Generation" to either "idelink_ert.tlc" or "idelink_grt.tlc" and click "Apply".

2. Next, select "Coder Target" under "Code Generation". Click "Target Hardware Resources" and set the parameters to match your target hardware. Click "OK".

For more information on configuring the model for your target hardware see this sectionthis section in the IDE Link documentation.

3. Click "Tool Chain Automation" tab.

4. If using CCS v3.3, select Makefile from the "Build format" drop-down list

5. If using CCS version 4.x or later, there is no need to select a build format. Makefile is the only "Build format" allowed.

6. Choose Build from the "Build action" drop-down list.

7. Click "OK" to apply your changes and close the dialog.

Task 3 - Configure XMakefile Functionality

IDE Link also provides configuration parameters that allow for the creation and selection of tool chain configurations. For more information, please refer to the XMakefile documentationXMakefile documentation.

Select a makefile configuration that matches "Target Hardware Resources" settings in the Model Configuration Parameters dialog. For example, if your configuration is for a C6000™ processor and no operating system, the makefile configuration you must choose is ticcs_c6000_ccsv3 if using CCS v3.3, ticcs_c6000_ccsv4 if using CCS v4 and ticcs_c6000_ccsv5 if using CCS v5.

If using CCS v3.3:

If ticcs_c6000_ccsv3 is an entry in the "Configuration" drop-down list:

1. Select ticcs_c6000_ccsv3.

2. Click "OK".

If ticcs_c6000_ccsv3 is not an entry in the "Configuration" drop-down list:

1. Uncheck "Display operational configurations only".

2. From the "Configuration" drop-down list, select ticcs_c6000_ccsv3.

3. Click "Apply".

4. One or more dialogs will come up asking you for the path of a specific CCS v3 tool. Provide the required paths to make ticcs_c6000_ccsv3 operational. The required tool paths for ticcs_c6000_ccsv3 are:

  • CCS v3 installation folder

  • C6000 Code Generation Tools installation folder

5. ticcs_c6000_ccsv3 is operational once a "Tool Directories" tab appears in the GUI. Inspect the paths displayed in this tab and make sure they are correct. If not, modify them using the "Browse" button.

6. Click "OK".

If using CCS version 4.x or later:

1. Uncheck "Display operational configurations only".

2. From the "Configuration" drop-down list, select a configuration that matches your CCS version. Example: Select ticcs_c6000_ccsv4 if you are using CCS v4.

3. Click "Apply".

4. One or more dialogs will come up asking you for the path of a specific CCS tool. Provide the required paths to make to make your configuration operational. For example, if you selected ticcs_c6000_ccsv4, the required tool paths for ticcs_c6000_ccsv4 are:

  • CCSv4 installation folder, e.g. C:\install_dir\ccsv4

  • C6000 Code Generation Tools installation folder, e.g. C:\install_dir\ccsv4\tools\compiler\c6000

  • C6000 Chip Support Library (CSL) installation folder

5. Your selected configuration is operational once a "Tool Directories" tab appears in the GUI. Inspect the paths displayed in this tab and make sure they are correct. If not, modify them using the "Browse" button.

6. Click "OK".

Task 4 - Build the Model

1. In your model, click the "Build Model" button to build the model.

2. Verify that a makefile was generated for the model.

Load and Run Program in CCS version 4.x or later

In CCS version 4.x or later, you can load and run the program file on a simulator or hardware through TI's Debug Server Scripting (DSS). For more information, refer to the Loading and Running Programs in CCS version 4.x or laterLoading and Running Programs in CCS version 4.x or later section in the IDE Link documentation.

The generated program is [BUILD_DIR]\sumdiff_ccsdemo_ticcs\CustomMW\sumdiff_ccsdemo.out, where [BUILD_DIR] is the location where you built your model.

Task 5 - Using the Generated Makefile

The software has generated the makefile and used it to build the model software. To re-build the model software, invoke the makefile from either the MATLAB or system command line. Use the make utility that corresponds to the "Template" selection on the "XMakefile User Configuration".

For example, if you set "Template" to gmake, invoke the gmake utility that ships with MATLAB. The gmake utility is located in the matlabroot\bin\$ARCH folder, where $ARCH is your system architecture (e.g., win32, glnx86).

The generated makefile in this case supports the "info" , "build" and "clean" targets and can be invoked with the command shown below from the model build directory. For example:

gmake -C sumdiff_ccsdemo_ticcs -f sumdiff_ccsdemo.mk info clean build

If matlabroot\bin\$ARCH is not on the system path, then use the full path for gmake. For example:

C:\MATLAB\bin\win32\gmake -C sumdiff_ccsdemo_ticcs -f sumdiff_ccsdemo.mk info clean build

Summary

This example showed how to configure a model for generating and building a model with a makefile.

See the Embedded Coder™ examples under the following categories:

  • Embedded Coder > Demos > Embedded IDEs > Texas Instruments Code Composer Studio

  • Embedded Coder > Demos > Embedded Targets > Texas Instruments C2000™

  • Embedded Coder > Demos > Embedded Targets > Texas Instruments C5000™

  • Embedded Coder > Demos > Embedded Targets > Texas Instruments C6000™

Refer to the XMakefile documentationXMakefile documentation to determine what features are supported with XMakefile.

Was this topic helpful?