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.

Code Composer Essentials V 3 --> Modified or custom Startup-Code

Other Parts Discussed in Thread: MSP430FG4618

Hi,

I am new using Code Composer Essentials - so this question may be trivial for a CCE-experienced user...

I use CCE Version 3.2.1.1.5 and I would like to modify or replace the startup-code. With "startup-code" I suppose the code-sequence which is executed from the reset vector of the MSP430 and which is used to setup the system for executing C code (setup the call-stack, the heap, the preinitialized global variables, ...) before the "main" function is executed.

Other IDEs like e.g. "CrossStudio for MSP430" from Rowley uses a separate asm-file which contains this startup-code - so it can simply be modified or replaced. In CCE I wasn't able to find the implementation of the startup-code.

I have the following questions:

  1. Where can I find the implementation of the startup-code and is this implementation available as asm source or as a lib?
  2. Is it possible to setup the linker to use a custom implementation for a startup-code instead of the default one?


Thanks and best regards,
Markus 

  • Hi

    I found this in SLAU132B–March 2008.

    Also see the example at SLAU157F–May 2005–Revised April 2008 - C.5.2 Custom Boot Routine.

     

    Regards,

    AES

     

    6.9 System Initialization

     

    Before you can run a C/C++ program, the C/C++ run-time environment must be created. The C/C++ boot routine performs this task using a function called c_int00 (or _c_int00). The run-time-support source library contains the source to this routine in a module named boot.c (or boot.asm).

    To begin running the system, the _c_int00 function can be called by reset hardware. You must link the _c_int00 function with the other object modules. This occurs automatically when you use the ––rom_model or ––ram_model linker function option and include the run-time library as one of the linker

    input files

     

    6.9.1 System Pre-Initialization

    The _c_int00( ) initialization routine also provides a mechanism for an application to perform the MSP430 setup (set I/O registers, enable/disable timers, etc.) before the C/C++ environment is initialized.

    Before calling the routine that initializes C/C++ global data and calls any C++ constructors, the boot routine makes a call to the function _system_pre_init( ). A developer can implement a customized version of _system_pre_init( ) to perform any application-specific initialization before proceeding with C/C++ environment setup. In addition, the default C/C++ data initialization can be bypassed if _system_pre_init( ) returns a 0. By default, _system_pre_init( ) should return a non-zero value.

    In order to perform application-specific initializations, you can create a customized version of _system_pre_init( ) and add it to the application project. The customized version will replace the default definition included in the run-time library if it is linked in before the run-time library.

    The default stubbed version of _system_pre_init( ) is included with the run-time library. It is located in the file pre_init.c and is included in the run-time source library (rts.src). The archiver utility (ar430) can be used to extract pre_init.c from the source library.

  • Hi AES,

    thanks for your answer. I think I can go on with this information. In addition I think that I should get more familiar with the CCE before I try to integrate a new startup-code.

    Thanks again and best regards,
    Markus

     

    P.S.: The document "SLAU157F" stated by "AES" is available in a newer version "SLAU157G" here:  http://focus.ti.com/lit/ug/slau157g/slau157g.pdf

  • Markus,

    In addition there are a couple more things to note when you create your own initialization routine to add to your project.

    Suppose you add a file called pre_init.c to your project with your own custom start up routine _system_pre_init, during link time you will see a symbol redefined error for _system_pre_init, something like:

    error: symbol "_system_pre_init" redefined: first defined in "./pre_init.obj";
       redefined in "C:/Program Files/Texas Instruments/CC Essentials
       v3/tools/compiler/MSP430/lib/rts430.lib<pre_init.obj>"
    error: errors encountered during linking; "rts_printf_custom.out" not built

    This is because the command line parses the runtime library prior to the custom object file and hence finds duplicate definitions of _system_pre_init.

    To avoid this error, the order of files on the command line needs to be changed. This can be changed using the project settings as below:

    Project Properties->C/C++ Build->MSP430 Linker:
    Change the Command line pattern to be: ${command} ${inputs} ${flags} ${output_flag} ${output}

    Placing ${inputs} before ${flags} puts the object files before the runtime library on the link command line, thus resolving the reference to the definition in the object file. Now rebuilding the project should no longer generate the symbol redefined errors.

    An alternate way to do this without modifying the default CCE build settings would be to remove the specific object file from the runtime library, in this case pre_init.obj. The way to do this on command line is:
    ar430 -d rts430.lib pre_init.obj

    Please be sure to make a backup copy of the original rts430.lib before doing this.

    The new runtime library, without pre_init.obj can now be included to the project and built.

     

  • Hi Aarti,

    I'm getting the error about redefining _system_pre_init().

    I tried reorganizing the command line pattern as you told, but now I get an error on the file "lnk_msp430fg4618.cmd" on the line at MEMORY: "#78-D this declaration has no storage class or type specifier"  [line 53]

    What should I do without messing with rts430.lib?

**Attention** This is a public forum