This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Correct files to use with makefile raw project

Hi all

I develop software for TM4C1994 device using Code ComposerStudio 6.0.1.

Everything is working, project is building etc. But now I need to move to standalone option - makefile build.

So I started to preparing Makefile file for that purpose. I will still use compiler shipped with CCS (armcl)

but all project must build direct from command line. Makefile I wrote is working but I am not sure if everything is OK with it.

And now I have few questions:

1) I use armcl compiler instead of gcc so I need to use files marked as *_ccs* instead of *_gcc*?

2) For normal console build usually two files are needed: startup file and linker script file. In case of

using armcl I should use startup_ccs.c and project_ccs.cmd (bow are from TivaWare C Series examples)?

3) I tried to convert output *.out file to *.bin file needed by LM Flash Programmer the same way as CCS doing it but it generates

around 500MB size bin file instead of 32k.

Bellow is Makefile I created, can someone take a look on it and tell me if I not miss anything? As I mentioned before it is compiling everything

but maybe I miss some important parts, libraries or settings? All flags are the same I use with window version of CCS.

# Project name
PROJ_NAME = SerialBuffer

# Project directories
SRC_DIR = src
OBJ_DIR = obj
INC_DIRS = inc
LIB_DIRS =

# Linker script
LINKER_SCRIPT = project_ccs.cmd

# Environment setup
RM_CMD = rm $(OBJ_DIR)/*

# Compile process parts
CC = armcl
CC_FLAGS =
CC_LNK_FLAGS =
CC_DEFS =
CC_LNK_NAMES =

# Flags for Tiva C TM4C1294 compiler
# For details refer to TI ARM C/C++ Compiler v5.1.6
# Procesor options
CC_FLAGS += --silicon_version=7M4
CC_FLAGS += --code_state=16
CC_FLAGS += --float_support=FPv4SPD16
CC_FLAGS += --abi=eabi
CC_FLAGS += --little_endian
# Debug options
CC_FLAGS += --symdebug:dwarf
# Optimalization options
CC_FLAGS += --opt_level=3
CC_FLAGS += --opt_for_speed=0
# Language options
CC_FLAGS += --gcc
# Diagnostic options (warnings)
CC_FLAGS += --diag_wrap=on
CC_FLAGS += --display_error_number
CC_FLAGS += --emit_warnings_as_errors
# Runtime options
CC_FLAGS += --align_structs=4
CC_FLAGS += --enum_type=packed
CC_FLAGS += --gen_func_subsections=on
CC_FLAGS += --plain_char=signed
CC_FLAGS += --small_enum
# Assembler options
CC_FLAGS += --ual
# Directory options
CC_FLAGS += --obj_directory=$(OBJ_DIR)

# Flags for Tiva C TM4C1295 linker
CC_LNK_FLAGS += --run_linker
CC_LNK_FLAGS += --heap_size=300
CC_LNK_FLAGS += --stack_size=1000
CC_LNK_FLAGS += --reread_libs

# Include directories
INC_DIRS += C:/ti/ccsv6/tools/compiler/arm_5.1.6/include
INC_DIRS += C:/ti/TivaWare_C_Series-2.1.0.12573
# Add prefix for flags set
INC_FLAGS = $(addprefix -I, $(INC_DIRS))

# Project defines
CC_DEFS += TARGET_IS_TM4C129_RA0
CC_DEFS += PART_TM4C1294NCPDT
CC_DEFS += UART_BUFFERED
# Add prefix for flags set
DEF_FLAGS = $(addprefix -D, $(CC_DEFS))

# Names for linker
CC_LNK_NAMES = rtsv7M4_T_le_eabi.lib driverlib.lib
# Add prefix for flags set
LNK_NAMES = $(addprefix -l, $(CC_LNK_NAMES))

# Add prefix for flags set
LIB_DIRS += C:\ti\TivaWare_C_Series-2.1.0.12573\driverlib\ccs\Debug
LIB_DIRS += C:\ti\ccsv6\tools\compiler\arm_5.1.6\lib
LIB_FLAGS = $(addprefix -i, $(LIB_DIRS))


# Generate list of needed object files
SRCS = $(wildcard $(SRC_DIR)/*.c)
$(info SRCS: $(SRCS))
OBJS = $(patsubst $(SRC_DIR)/%.c, $(OBJ_DIR)/%.obj, $(SRCS))
$(info OBJS: $(OBJS))


# Command for compile single target
COMPILE_CMD = $(CC) $(CC_FLAGS) $(INC_FLAGS) $(DEF_FLAGS)


# Rules for compile all source
# $@ - output file
# &< - input file
$(OBJ_DIR)/%.obj: $(SRC_DIR)/%.c
	$(COMPILE_CMD) -c $<


# Build main binary
all: $(OBJS)
	$(CC) $(CC_LNK_FLAGS) $(LIB_FLAGS) $(LNK_NAMES) $(LINKER_SCRIPT) -m $(PROJ_NAME).map -o $(PROJ_NAME).out $(OBJS)
	$(OBJ_TO_BIN_CMD) $(PROJ_NAME).out $(PROJ_NAME).bin
	tiobj2bin.bat "$(PROJ_NAME).out" "$(PROJ_NAME).bin" "armofd" "armhex" "mkhex4bin"


# Project cleaning
clean:
	$(RM_CMD)

  • Hello Pawel,

    Moving it to the Code Composer Forum.

    Regards
    Amit
  • Pawel Polawski said:
    1) I use armcl compiler instead of gcc so I need to use files marked as *_ccs* instead of *_gcc*?

    Yes.

    Pawel Polawski said:

    2) For normal console build usually two files are needed: startup file and linker script file. In case of using armcl I should use startup_ccs.c and project_ccs.cmd (bow are from TivaWare C Series examples)?

    Yes.

    Pawel Polawski said:

    3) I tried to convert output *.out file to *.bin file needed by LM Flash Programmer the same way as CCS doing it but it generates around 500MB size bin file instead of 32k.

     

    I haven't seen this happen with the examples, so it must be that you customized the linker command file. Please see this post for an explanation of why the .bin file size could be large.

    Pawel Polawski said:
    Bellow is Makefile I created, can someone take a look on it and tell me if I not miss anything?

    At a quick glance, it looks ok to me.

  • OK, i checked everything one more time and now it is working. I am attaching updated makefile I used to do that.

    # Project name
    PROJ_NAME = SerialBuffer
    
    # Project directories
    SRC_DIR = src
    OBJ_DIR = obj
    INC_DIRS = inc
    LIB_DIRS =
    
    # Linker script
    LINKER_SCRIPT = $(PROJ_NAME)_ccs.cmd
    
    # Environment setup
    RM_COMMAND = rm -rfv $(OBJ_DIR)
    CREATE_ODIR = mkdir -p $(OBJ_DIR)
    
    # Compile process parts
    CC = armcl
    CC_FLAGS =
    CC_LNK_FLAGS =
    CC_DEFS =
    CC_LNK_NAMES =
    
    # Flags for Tiva C TM4C1294 compiler
    # For details refer to TI ARM C/C++ Compiler v5.1.6
    # Procesor options
    CC_FLAGS += --silicon_version=7M4
    CC_FLAGS += --code_state=16
    CC_FLAGS += --float_support=FPv4SPD16
    CC_FLAGS += --abi=eabi
    CC_FLAGS += --little_endian
    # Debug options
    CC_FLAGS += --symdebug:dwarf
    # Optimalization options
    CC_FLAGS += --opt_level=0
    CC_FLAGS += --opt_for_speed=0
    # Language options
    CC_FLAGS += --gcc
    # Diagnostic options (warnings)
    CC_FLAGS += --diag_wrap=on
    CC_FLAGS += --display_error_number
    CC_FLAGS += --emit_warnings_as_errors
    # Runtime options
    CC_FLAGS += --align_structs=4
    CC_FLAGS += --enum_type=packed
    CC_FLAGS += --gen_func_subsections=on
    CC_FLAGS += --plain_char=signed
    CC_FLAGS += --small_enum
    # Assembler options
    CC_FLAGS += --ual
    CC_FLAGS += --preproc_with_compile
    # Directory options
    CC_FLAGS += --obj_directory=$(OBJ_DIR)
    
    # Flags for Tiva C TM4C1295 linker
    CC_LNK_FLAGS += --run_linker
    CC_LNK_FLAGS += --heap_size=300
    CC_LNK_FLAGS += --stack_size=1000
    CC_LNK_FLAGS += --reread_libs
    CC_LNK_FLAGS += --rom_model
    CC_LNK_FLAGS += --xml_link_info=$(PROJ_NAME)_linkInfo.xml
    
    # Project defines
    CC_DEFS += ccs="ccs"
    CC_DEFS += PART_TM4C1294NCPDT
    CC_DEFS += TARGET_IS_TM4C129_RA0
    CC_DEFS += UART_BUFFERED
    # Add prefix for flags set
    DEF_FLAGS = $(addprefix --define=, $(CC_DEFS))
    
    # Names for linker
    CC_LNK_NAMES = libc.a driverlib.lib
    # Add prefix for flags set
    LNK_NAMES = $(addprefix -l, $(CC_LNK_NAMES))
    
    # Include directories
    INC_DIRS += C:/ti/ccsv6/tools/compiler/arm_5.1.6/include
    INC_DIRS += C:/ti/TivaWare_C_Series-2.1.0.12573
    # Add prefix for flags set
    INC_FLAGS = $(addprefix --include_path=, $(INC_DIRS))
    
    # Add prefix for flags set
    LIB_DIRS += C:/ti/TivaWare_C_Series-2.1.0.12573/driverlib/ccs/Debug
    LIB_DIRS += C:/ti/ccsv6/tools/compiler/arm_5.1.6/lib
    LIB_FLAGS = $(addprefix -i, $(LIB_DIRS))
    
    
    # Generate list of needed object files
    SRCS = $(wildcard $(SRC_DIR)/*.c)
    #$(info SRCS: $(SRCS))
    OBJS = $(patsubst $(SRC_DIR)/%.c, $(OBJ_DIR)/%.obj, $(SRCS))
    #$(info OBJS: $(OBJS))
    
    
    # Command for compile single target
    COMPILE_CMD = $(CC) $(CC_FLAGS) $(INC_FLAGS) $(DEF_FLAGS)
    # Command for link final target
    LINK_CMD = $(CC) $(CC_FLAGS) $(DEF_FLAGS) $(CC_LNK_FLAGS) $(LIB_FLAGS) -m $(PROJ_NAME).map -o $(PROJ_NAME).out $(OBJS) $(LINKER_SCRIPT) $(LNK_NAMES)
    
    
    # Rules for compile all source
    # $@ - output file
    # &< - input file
    $(OBJ_DIR)/%.obj: $(SRC_DIR)/%.c
    	$(COMPILE_CMD) $<
    
    # Build main binary
    all: $(OBJS)
    	$(LINK_CMD)
    	tiobj2bin $(PROJ_NAME).out $(PROJ_NAME).bin armofd armhex mkhex4bin
    
    # Project cleaning
    clean:
    	$(RM_COMMAND)
    	$(CREATE_ODIR)
    

    CCS command file I use:

    /******************************************************************************
     *
     * CCS linker configuration file
     *
     * Copyright (c) 2013-2014 Texas Instruments Incorporated.  All rights reserved.
     * Software License Agreement
     * 
     * Texas Instruments (TI) is supplying this software for use solely and
     * exclusively on TI's microcontroller products. The software is owned by
     * TI and/or its suppliers, and is protected under applicable copyright
     * laws. You may not combine this software with "viral" open-source
     * software in order to form a larger program.
     * 
     * THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
     * NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
     * NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     * A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
     * CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
     * DAMAGES, FOR ANY REASON WHATSOEVER.
     * 
     * This is part of revision 2.1.0.12573 of the EK-TM4C1294XL Firmware Package.
     *
     *****************************************************************************/
    
    --retain=g_pfnVectors
    
    /* The following command line options are set as part of the CCS project.    */
    /* If you are building using the command line, or for some reason want to    */
    /* define them here, you can uncomment and modify these lines as needed.     */
    /* If you are using CCS for building, it is probably better to make any such */
    /* modifications in your CCS project and leave this file alone.              */
    /*                                                                           */
    /* --heap_size=0                                                             */
    /* --stack_size=256                                                          */
    /* --library=rtsv7M3_T_le_eabi.lib                                           */
    
    /* The starting address of the application.  Normally the interrupt vectors  */
    /* must be located at the beginning of the application.                      */
    #define APP_BASE 0x00000000
    #define RAM_BASE 0x20000000
    
    /* System memory map */
    
    MEMORY
    {
        /* Application stored in and executes from internal flash */
        FLASH (RX) : origin = APP_BASE, length = 0x00100000
        /* Application uses internal RAM for data */
        SRAM (RWX) : origin = 0x20000000, length = 0x00040000
    }
    
    /* Section allocation in memory */
    
    SECTIONS
    {
        .intvecs:   > APP_BASE
        .text   :   > FLASH
        .const  :   > FLASH
        .cinit  :   > FLASH
        .pinit  :   > FLASH
        .init_array : > FLASH
    
        .vtable :   > RAM_BASE
        .data   :   > SRAM
        .bss    :   > SRAM
        .sysmem :   > SRAM
        .stack  :   > SRAM
    }
    
    __STACK_TOP = __stack + 256;