Please note as of Wednesday, August 15th, 2018 this wiki has been set to read only. If you are a TI Employee and require Edit ability please contact x0211426 from the company directory.

Using MSP430-GCC with CCSv6

From Texas Instruments Wiki
Jump to: navigation, search


Starting with Code Composer Studio v6 , MSP430 programmers have the option of using GCC Open Source Compiler to build their projects. The GCC compiler has no code size limit, and can be used standalone or with CCSv6.


The GCC compiler can be installed in one of two ways:

  1. When installing CCSv6, you have the option to select the MSP430 GCC compiler to be installed as an “add-on”. One of the steps during installation is shown in the screenshot below. If you enable MSP430 GCC, it will get installed when you run CCS for the first time.
    Installer main v6.png

  2. Alternately, if you do not select the above option during installation, you can always install it at a later time. Go to menu View->CCS App Center. Select MSP430 GCC Beta and click the “Install Software” button to start the installation.
    Installer appcenter.png

Once installed, the GCC compiler tools will be in this directory within the CCS installation: \ccsv6\tools\compiler\gcc_msp430_xxx (where xxx denotes the version number).


Creating a new CCS project using MSP430 GCC

Below are the steps to create a new CCS project that uses MSP430 GCC tools to build the executable.

  1. Start CCSv6 and create a new project by going to menu Project->New CCS Project…
  2. Fill in the Target and Project name fields
  3. For Compiler version, select GNU v4.8.0 (Red hat)
  4. Under Project templates and examples, select Empty Project or Empty Project (with main.c)
  5. Click Finish

New ccs proj.png

This will create a new project that will be visible in the Project Explorer view. Notice that the project contains a .ld file (appropriate for the target selected). This is the linker script that contains the memory layout and section allocation. This file is the equivalent of the TI linker command file (.cmd). You can now add the necessary source files to the project and build. Similar to TI tools, additional compiler and linker options can be set from Project Properties.

Changing an existing CCS project created for TI compiler to use MSP430 GCC

Below are the steps to change an existing CCS project that uses TI compiler to one that uses MSP430 GCC. These steps can be applied to a project that was either created from TI Resource Explorer (using one of the device peripheral examples) or one that was created from scratch.

  1. Right-click on the project in Project Explorer view and go to Properties
  2. Change Compiler version to GNU v4.8.0 (Red Hat)
    Change compiler.png

  3. Click OK

This will pop up the following dialog. Click OK.
Warning message.png

A new build configuration named Debug__GNU will be created. This build configuration will use the appropriate GCC linker script (.ld) instead of the TI linker command file (.cmd). The project will now use the MSP430-GCC compiler for the build.

Creating a new CDT project using MSP430 GCC

In some cases you may want to create a standard Eclipse C/C++ project (instead of a CCS project) that uses the MSP430 GCC toolchain. This would be necessary if you wanted to debug using GDB instead of the CCS debugger.

Note that the steps and screenshots below refer to CCS 6.0.1. Adjust that to match with the specific version of CCSv6 you are working with.

Below are the steps to create a new Eclipse C/C++ project that uses MSP430 GCC tools to build the executable.

  1. Start CCSv6 and create a new project by going to menu File->New->Project...
  2. Expand C/C++ and select C Project (or C++ Project). Click Next
    New cdt proj.png

  3. Fill in the Project name field. For Project Type, choose Empty Project and for Toolchains, select Cross GCC. Click Next
    New cdt proj1.png

  4. Click Next again
  5. In the Cross compiler prefix field, enter msp430-elf- and in the Cross compiler path field, enter the path to the GCC toolset within CCS. Click Finish
    Note: The Problems view may show an error: Progam “gcc” not found in PATH. This can be ignored for now and will disappear when the project is built
    New cdt proj2.png

  6. Add source file(s) to project by right-clicking on the project and going to New->Source file, or by simply copying or linking source file(s) to the project. As an example, the attached code is for blinking an LED on a MSP430F5438A device
  7. Right-click on the project, go to Properties->C/C++ Build->Settings->Cross GCC Compiler->Includes. Add the include paths to the \ccs_base\msp430\include_gcc folder and \tools\compiler\gcc_msp430_xxx\msp430-elf\include folder within your CCS installation. The example below shows it for CCS 6.0.1, adjust it for your version of CCS.
    Cdt proj setting1.png

  8. Go to Miscellaneous, and under Other flags, add -mmcu=msp430f5438a or similar, depending on your device
    Cdt proj setting2.png

  9. Add other compiler options as required for the project
  10. Go to Cross GCC Linker->Miscellaneous, and under Linker flags, add -T C:\CCStudio_v6.0.1.00039\ccsv6\ccs_base\msp430\include_gcc\msp430f5438a.ld. This is the path to the GCC linker command file specific for the MSP430F5438A.
    Cdt proj setting3.png

  11. Go to Cross GCC Linker->Libraries, and under Library search path (-L), add the path to \ccs_base\msp430\include_gcc within your CCS installation. This is required if using MSP430 Emulators package version or later
    Cdt proj setting4.png

  12. Add other linker options as required by the project
  13. The C/C++ Builder uses make by default, but there isn't a make executable in the mspgcc toolchain. Modify the build command to use gmake from CCS instead.
    Cdt proj builder.png

  14. Build the project. The build output in the console should look something like this:
    Cdt proj build1.png

After the project has been built successfully, it can be debugged using GDB. Please see this wiki article GDB with MSP430 and CCSv6 for more details on setting up GDB debugging with CCSv6.