Jump to content

A few notes about TI's command line compilers

Recommended Posts

For those unaware, CCS calls command line programs for all phases of compilation and linking.  Back in the days of CCS V4 I attempted to use these directly without any luck.  Shortly thereafter I discovered mspgcc and largely ignored CCS.  However, I have long wanted to be able to use these CLI tools so I can verify that my code is indeed cross-platform while developing.


I recently had another go, this time with much more success.  Not only did I succeed in getting the tools working from the command line, but I was able to get them working via Wine under OS/X.  Now I will be able to do all of my CCS verification directly under OS/X without having to run a virtual machine.


All you need are the following three directories from your CCSv5 install.  You can just copy the files, there do not appear to be any registry hoops to jump through, and it seems as if the files cal live anywhere with the proper edits to your makefiles.


C:\ti\ccsv5\tools\compiler\msp430_4.1.5 - the compiler itself


C:\ti\ccsv5\ccs_base\msp430\include - chip-specific includes and linker scripts


C:\ti\ccsv5\utils\bin - gmake.exe if you want to use the makefiles created by CCS


I am still working on understanding what the CCS-generated makefiles do and rolling that into my own.  If anyone is interested I'll post a follow-up.


Theoretically this could also be used to run TI's compilers under a native eclipse install under OSX, but I have no intention of even attempting this.  Perhaps the only other useful application of this would be to use TI's compilers on extremely resource-limited machines.  The full compiler+includes is only about 200 megs and seems to require very little RAM at runtime.



Link to post
Share on other sites

As an alternative on Mac OS X, I'm using the Energia distribution which packs an Arduino-compatible framework and the msp430-gcc and arm-none-eabi-gcc tools-chains.


The embedXcode template for Xcode uses a makefile and calls the relevant tools of the tool-chains for compiling and linking.


Feel free to have a look at the makefiles to design your own one.

Link to post
Share on other sites

The TI compiler is fully supported in the current BSP430 release, as long as you also use embtextf.


The TI compiler (distinct from CCS) has some "interesting features", including the fact it doesn't know where its own include files are unless it's explicitly told where to look.  In my case that means adding these to the compiler arguments:

--include_path="/usr/local/ccs/ccsv5/ccs_base/msp430/include" \

It also really wants to generate .obj files instead of .o files, which complicates use in standard GNU make environments.  You can see how BSP430's build framework supports it by looking at Makefile.common and searching for WITH_CCS elsewhere in that file.


Further, if you tell it to use its --relaxed_ansi personality to get things like structure tag initializers and other modern C constructs, it'll claim to be GCC by defining __GNUC__, even if you don't also use --gcc.  Methods of detecting which toolchain is being used, and some toolchain-specific workarounds for common MSP430 concepts, can be found in bsp430/core.h.

Link to post
Share on other sites

I have have finally gotten around to putting together an updated makefile that will build for both gcc and ccs/cl430


The root Makefile is kept simple like this:

PROG		= blink
CHIP		= msp430g2553
COPTS		= -O2 -Wall -g

include default.mk

And all the complicated bits are in defaut.mk:


The options for CCS are essentially those generated with the "Debug" option.  I am not entirely sure these are optimal, but they seem to work.


The makefile essentially invokes itself under Wine to build using TI's ccs/cl430 copiler.


This still needs to be cleaned up, but it works.

###  Generic makefile for MSP430 (gcc + cl430)

# make sure a PROG is specified
ifndef PROG
$(error No PROG specified.)

# make sure a chip is specified
ifndef CHIP
$(error No CHIP specified.)

# make uppercase and lowercase versions of chip
# (these get passed in when called via WINE)
ifndef MCU_LC
MCU_LC		:= $(shell echo $(CHIP) | tr A-Z a-z)
ifndef MCU_UC
MCU_UC		:= $(shell echo $(CHIP) | tr a-z A-Z)

# output dir config
O_GCC		= gcc
O_CCS		= ccs

# gcc config
CC		= msp430-gcc
CXX		= msp430-g++
OBJDUMP		= msp430-objdump
SIZE		= msp430-size
CFLAGS		= $(COPTS) -mmcu=$(MCU_LC)

# mspdebug config
MSPDEBUG	= mspdebug
FET		= rf2500
GDB		= msp430-gdb
GDBTUI		= $(GDB)tui

# ccs via wine config
WINE		= wine
GMAKE		= /Users/peter/.wine/drive_c/ti/utils/bin/gmake.exe
CL430		= "C:/ti/compiler/bin/cl430"
CL430_OPTS	= -vmsp --abi=eabi -g --define=__$(MCU_UC)__ \
			--display_error_number --diag_wrap=off \
			--diag_warning=225 --diag_suppress=10374 \
CL430_COPTS	= --include_path="C:/ti/include" --include_path="C:/ti/compiler/include"
CL430_LOPTS	= -z --stack_size=80 --heap_size=80 \
			-i"C:/ti/include" -i"C:/ti/compiler/lib" -i"C:/ti/compiler/include" \
			--reread_libs --warn_sections --rom_model
CL430_LNK	= "C:/ti/include/lnk_$(MCU_LC).cmd"

# gcc target files

# ccs target files

# specify non-file targets
.PHONY: all gcc ccs lst clean install mspdebug debug gdb tui

# what to make by default
all: gcc ccs

# make using "gcc" - make elf and display size
gcc: $(GCC_ELF)
	$(SIZE) $(GCC_ELF) 

# make using "ccs"
# - make sure dir exists and call gnu-make with wine
# doze can't 'tr' so pass MCU vars in
	mkdir -p $(O_CCS)

# begin gcc-specific block

lst: $(GCC_LST)

	$(CC) $(CFLAGS) -o $(GCC_ELF) $(GCC_OBJS)

$(O_GCC)/%.o: %.c
	@mkdir -p $(@D)
	$(CC) $(CFLAGS) -c $< -o $@

	$(OBJDUMP) -DS $< >$@

	rm -fr $(O_GCC) $(O_CCS)

install: $(GCC_ELF)
	$(MSPDEBUG) $(FET) "prog $(GCC_ELF)"

mspdebug: $(GCC_ELF)

debug: $(GCC_ELF)
	$(MSPDEBUG) $(FET) gdb

gdb: $(GCC_ELF)
	$(GDB) $(GCC_ELF)

tui: $(GCC_ELF)

# begin CCS-specific block

	$(CL430) $(CL430_OPTS) $(CL430_LOPTS) -m$(O_CCS)/$(PROG).map -o $(CCS_OUT) \
		$(CCS_OBJS) -l"libc.a" $(CL430_LNK)

$(O_CCS)/%.obj: %.c
	$(CL430) $(CL430_OPTS) $(CL430_COPTS) --obj_directory $(O_CCS) $<

install-ccs: $(CCS_OUT)
	$(MSPDEBUG) $(FET) "prog $(CCS_OUT)"

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...