GCC - Create a project
CCSv4 may be used to create a project that uses GCC compilers for building executables for Windows and even cross-compile to ARM targets.
Using GCC and Cygwin
Below are the steps on how to create a project that uses GCC that is part of cygwin distribution.
- Download and install Cygwin from this page, and make sure either the entire Devel or the GCC packages are marked as Install in the setup screen:
- Open CCSv4 and create a new project: go to menu File --> New --> CCS Project
- Give a name the project and click Next
- On this next screen check the box Show All Project Types and select the Project Type: as Executable (Cygwin):
- Click Next if you want to add additional dependent projects, or Finish to finish creating the project.
- Add source files and build.
Note: It is assumed that GCC is already installed on the machine. If cygwin distribution is used, then cygwin installation automatically configures environment variables that are used by the project build system. In other cases further tweaks may be required in project properties to find gcc executables.
Using Codesourcery G++ Lite for ARM cross-compile
The process is very similar to the steps above if you wish to use the Codesourcery G++ Lite compilers.
- Download and install the desired version of Codesourcery G++ Lite from their page. The example below assumes you are using Codesourcery G++ Lite 2009q1-203 GNU/Linux commonly used with TI's SDKs and DVSDKs.
- Once installed, the tool typically adds its bin\ installation directory to the system PATH:
- Open CCSv4 and create a new project using the instructions above for GCC for Cygwin, only selecting Executable (Gnu) as the Project Type. This will spawn a warning that you can ignore.
- Click on Next, then Finish.
- In order to use the tools one additional step must be performed; the CodeSourcery cross-compiler tools always have a prefix that designates the target and the type of the output binary format, changing the compiler/assembler/linker names from simply gcc or as to something like arm-none-linux-gnueabi-gcc or arm-none-linux-gnueabi-as. This must be configured on the project by right-clicking on the newly created project and selecting Build Properties...
- Once there, add the tool prefix to the Command: box for each tool: GCC C++ Compiler, GCC C Compiler, GCC C++ Linker, GCC Assembler. For example, for the Codesourcery G++ Lite 2009q1-203 GNU/Linux, the prefix arm-none-linux-gnueabi- must be added to each box.
- There is a CodeSourcery plug-in available at Source Forge that adds a new target called Executable (ARM) and modifies the project Build options by adding a few fields specific to CodeSourcery tools. The version that can be used with CCSv4 is 0.1.3.
- Important! The ability to debug your code within CCSv4 is highly dependent on the type of the GCC version and platform chosen. For example, although CCS can debug code generated with Codesourcery for GNU/Linux ARM, it does not mean you can simply load the target using the CCS debugger - such compiler generates code intented to be loaded from a Linux command prompt. That is not the case for MSP430 GCC, though.
- Because the project type is for the generic GCC compiler, all the target-related options typically used for ARM cross-compile (-march=armv5t, -mtune=arm9tdmi and others) must be specified manually in the project build options for each tool:
- GCC C++ Compiler or GCC C Compiler --> Miscellaneous --> Other flags
- GCC Assembler --> General --> Assembler Flags
- Since the cross compiler is not named <gcc.exe>, CCSv4 will spawn a warning for the newly created project that reflects the absence of the GCC program in the PATH:
- Error launching external scanner info generator (gcc -E -P -v -dD C:/user/workspace/.metadata/.plugins/org.eclipse.cdt.make.core/specs.cpp)
- If desired, the directory C:\Program Files\CodeSourcery\Sourcery G++ Lite\arm-none-linux-gnueabi\bin can be added to the PATH environment variable. By doing this two benefits can be achieved:
- No need to change the prefix for the GCC tools on the project;
- The warning mentioned above will disappear;
- However, please note that this may cause conflicts with other GCC tools installed in your system, like DJGPP, Cygwin or mspgcc.
Using mspgcc for MSP430 cross compile
Similarly to the Codesourcery tools, the steps to configure mspgcc are almost identical, just requiring a change of each tool under Project --> Build Properties... to its corresponding mspgcc name. For example, g++ becomes msp430-g++ and gcc becomes msp430-gcc.
Similarly to the Codesourcery case, make sure the mspgcc tools are in the PATH environment variable (its installer usually does that).
All the notes above are also applicable to mspgcc.
Important! At least one target-dependent compiler option is absolutely required for mspgcc: the -mmcu=msp430xxxx. It must be added to:
- Project --> Build Options... --> GCC C++ Compiler or GCC C Compiler --> Miscellaneous --> Other flags
To date CCSv4 cannot debug code generated with mspgcc version 3.x. The new version 4.x is still under testing. Check back soon!