NOTICE: The Processors Wiki will End-of-Life on January 15, 2021. It is recommended to download any files or other content you may need that are hosted on processors.wiki.ti.com. The site is now set to read only.
Using MSP430-GCC with CCSv6
Contents
Introduction[edit]
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.
Installation[edit]
The GCC compiler can be installed in one of two ways:
- 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.
- 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.
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).
Reference[edit]
http://www.ti.com/tool/msp430-gcc-opensource
Creating a new CCS project using MSP430 GCC[edit]
Below are the steps to create a new CCS project that uses MSP430 GCC tools to build the executable.
- Start CCSv6 and create a new project by going to menu Project->New CCS Project…
- Fill in the Target and Project name fields
- For Compiler version, select GNU v4.8.0 (Red hat)
- Under Project templates and examples, select Empty Project or Empty Project (with main.c)
- Click Finish
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[edit]
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.
- Right-click on the project in Project Explorer view and go to Properties
- Change Compiler version to GNU v4.8.0 (Red Hat)
- Click OK
This will pop up the following dialog. Click OK.
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[edit]
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.
- Start CCSv6 and create a new project by going to menu File->New->Project...
- Expand C/C++ and select C Project (or C++ Project). Click Next
- Fill in the Project name field. For Project Type, choose Empty Project and for Toolchains, select Cross GCC. Click Next
- Click Next again
- 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
- 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
- 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.
- Go to Miscellaneous, and under Other flags, add -mmcu=msp430f5438a or similar, depending on your device
- Add other compiler options as required for the project
- 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.
- 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 6.3.1.8 or later
- Add other linker options as required by the project
- 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.
- Build the project. The build output in the console should look something like this:
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.