3. Creating a Simple Application with the tiarmclang Compiler Tools

This section of the Getting Started Guide provides an example of how to build a simple application using the tiarmclang command-line interface. In addition, it provides a walk-through of how to build a simple application in a Code Composer Studio project that uses the tiarmclang compiler.

3.1. Source Files

The subsections below will describe how to build a simple “Hello World!” program using either the tiarmclang command-line interface or the Code Composer Studio (CCS) development environment. For the purposes of these tutorial examples, it is assumed that you have a C source file containing the following C code:

1#include <stdio.h>
2
3int main() {
4  printf("Hello World\n");
5  return 0;
6}

It is also assumed that you have at your disposal a linker command file that provides a specification of the available memory and how to place compiler/linker generated output sections in that memory. For example, in the tutorials below, the following linker command file, named lnkme.cmd, could be used:

/****************************************************************************/
/* Example Linker Command File                                              */
/****************************************************************************/
-c                                         /* LINK USING C CONVENTIONS      */
-stack  0x8000                             /* SOFTWARE STACK SIZE           */
-heap   0x2000                             /* HEAP AREA SIZE                */
--args  0x1000

/* SPECIFY THE SYSTEM MEMORY MAP */

MEMORY
{
    P_MEM    : org = 0x00000020   len = 0x20000000  /* PROGRAM MEMORY (ROM) */
    D_MEM    : org = 0x20000020   len = 0x20000000  /* DATA MEMORY    (RAM) */
}

/* SPECIFY THE SECTIONS ALLOCATION INTO MEMORY */

SECTIONS
{
    .intvecs    : {} > 0x0             /* INTERRUPT VECTORS                 */
    .bss        : {} > D_MEM           /* GLOBAL & STATIC VARS              */
    .data       : {} > D_MEM
    .sysmem     : {} > D_MEM           /* DYNAMIC MEMORY ALLOCATION AREA    */
    .stack      : {} > D_MEM           /* SOFTWARE SYSTEM STACK             */

    .text       : {} > P_MEM           /* CODE                              */
    .cinit      : {} > P_MEM           /* INITIALIZATION TABLES             */
    .const      : {} > P_MEM           /* CONSTANT DATA                     */
    .rodata     : {} > P_MEM
    .ARM.exidx  : {} > P_MEM
    .init_array : {} > P_MEM           /* C++ CONSTRUCTOR TABLES            */
}