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.

Compiler/CODECOMPOSER: error in building init.S from starterware

Part Number: CODECOMPOSER


Tool/software: TI C/C++ Compiler

Hey everyone,

as the title indicates i am having trouble to build my project when i include the init.S file...I hope i post it in the right place but if not, please inform me.
The errors i get are:

  • multiple definition of `Entry'    (well that's a conflict with the startup_ARMCA8.S file that is automatically generated when a new project is created)
  • undefined reference to `_bss_end'
  • undefined reference to `_bss_start'
  • undefined reference to `_stack'

The init.s file i use is the one from starterware (version 2.00.01.01) for the compiler i use (GNU v4.8.4 Linaro).
Code composer studio's version is 6.1.0.00104

I provide the init.S for your convenience:

@****************************** Global Symbols*********************************
        .global Entry
        .global _stack                  
        .global _bss_start
        .global _bss_end
        .global start_boot
@************************ Internal Definitions ********************************
@
@ Define the stack sizes for different modes. The user/system mode will use
@ the rest of the total stack size
@
        .set  UND_STACK_SIZE, 0x8
        .set  ABT_STACK_SIZE, 0x8
        .set  FIQ_STACK_SIZE, 0x8
        .set  IRQ_STACK_SIZE, 0x800
        .set  SVC_STACK_SIZE, 0x8
@
@ to set the mode bits in CPSR for different modes
@        
        .set  MODE_USR, 0x10            
        .set  MODE_FIQ, 0x11
        .set  MODE_IRQ, 0x12
        .set  MODE_SVC, 0x13
        .set  MODE_ABT, 0x17
        .set  MODE_UND, 0x1B
        .set  MODE_SYS, 0x1F            

        .equ  I_F_BIT, 0xC0               
@**************************** Code Seection ***********************************
        .text
@
@ This code is assembled for ARM instructions
@
        .code 32
@******************************************************************************
@
@******************************************************************************
@
@ The reset handler in StarterWare is named as 'Entry'.
@ The reset handler sets up the stack pointers for all the modes. The FIQ and
@ IRQ shall be disabled during this. Then clear the BSS sections and finally
@ switch to the function calling the main() function.
@
Entry:
@
@ Set up the Stack for Undefined mode
@
         LDR   r0, =_stack                     @ Read the stack address
         MSR   cpsr_c, #MODE_UND|I_F_BIT       @ switch to undef  mode
         MOV   sp,r0                           @ write the stack pointer
         SUB   r0, r0, #UND_STACK_SIZE         @ give stack space
@
@ Set up the Stack for abort mode
@        
         MSR   cpsr_c, #MODE_ABT|I_F_BIT       @ Change to abort mode
         MOV   sp, r0                          @ write the stack pointer
         SUB   r0,r0, #ABT_STACK_SIZE          @ give stack space
@
@ Set up the Stack for FIQ mode
@       
         MSR   cpsr_c, #MODE_FIQ|I_F_BIT       @ change to FIQ mode
         MOV   sp,r0                           @ write the stack pointer
         SUB   r0,r0, #FIQ_STACK_SIZE          @ give stack space
@
@ Set up the Stack for IRQ mode
@       
         MSR   cpsr_c, #MODE_IRQ|I_F_BIT       @ change to IRQ mode
         MOV   sp,r0                           @ write the stack pointer
         SUB   r0,r0, #IRQ_STACK_SIZE          @ give stack space
@
@ Set up the Stack for SVC mode
@        
         MSR   cpsr_c, #MODE_SVC|I_F_BIT       @ change to SVC mode
         MOV   sp,r0                           @ write the stack pointer
         SUB   r0,r0, #SVC_STACK_SIZE          @ give stack space
@
@ Set up the Stack for USer/System mode
@      
         MSR   cpsr_c, #MODE_SYS|I_F_BIT       @ change to system mode
         MOV   sp,r0                           @ write the stack pointer

@ Invalidate and Enable Branch Prediction  
         MOV     r0, #0
         MCR     p15, #0, r0, c7, c5, #6
         ISB
         MRC     p15, #0, r0, c1, c0, #0
         ORR     r0, r0, #0x00000800
         MCR     p15, #0, r0, c1, c0, #0

@
@ Enable and initialise VFP and NEON
@
        ORR r1, r1, #(0xf << 20)              @ OR over CPACR read value so to enable CP's
        MCR p15, #0, r1, c1, c0, #2           @ Write to CPACR
         
        MOV r1, #0
        MCR p15, #0, r1, c7, c5, #4           @ flush prefetch buffer because of FMXR below
        MOV r0,#0x40000000                    @ and CP 10 & 11 were only just enabled
        FMXR FPEXC, r0 ; FPEXC = r0           @ Enable VFP itself
@
@ Clear the BSS section here
@
Clear_Bss_Section:

         LDR   r0, =_bss_start                 @ Start address of BSS
         LDR   r1, =(_bss_end - 0x04)          @ End address of BSS
         MOV   r2, #0  
Loop:
         STR   r2, [r0], #4                    @ Clear one word in BSS
         CMP   r0, r1
         BLE   Loop                            @ Clear till BSS end
        
@
@ Enter the start_boot function. The execution still happens in system mode.
@
@Enter_main:
         LDR   r10,=start_boot
         MOV   lr,pc                           @ Dummy return from start_boot
         BX    r10                             @ Branch to start_boot
         SUB   pc, pc, #0x08                   @ looping
@
@ End of the file
@
         .end

So does anyone have any idea how to overcome the errors? Also, could someone tell me when it is necessary to use init.S?
Thanks in advance

  • Hi,

    Out of the two errors that are shown by your project, one is already pointed by you: the redefinition of the Entry symbol can be solved by simply removing the startup_ARMCA8.S file.

    The other errors are probably related to the linker script file. The default linker script that is added to a new CCS project (AM335s.lds) is suitable for the startup_ARMCA8.S file, but your init.S file will probably require a corresponding linker script from the Starterware SW package.

    The init.S performs very low-level initialization of the C environment and the device - if you are familiar with the Linux environment, it is similar to the MLO.

    For additional details about the Starterware-provided init.S and the linker scripts, please ask the experts at the Sitara forum, as they are much more knowledgeable about this software package.

    Hope this helps,
    Rafael
  • Hey,

    thanks for your reply.

    Well i am going to post it in Sitara's forum too, but in case you have the answer...

    When am i supposed to use the init.S rather than startup_ARMCA8.S?
    And as far as the errors related to the linker script file, do you mean that i should choose a different linker script file depending on my application?
    If it is so, then how should i know what to choose?
    (well i have noticed that some of the examples of starterware use different linker files, for example AM335x.cmd and dmtimerCounter.cmd, so i guess the answer to my second question is yes..
    I am particularly interested though, to know if the aforementioned difference has to do with handling interrupts or not..)

    Thanks again

  • Hi,

    >>When am i supposed to use the init.S rather than startup_ARMCA8.S?
    The startup_ARMCA8.S is a generic init file that was designed to help people get started with baremetal GCC projects - it performs some initialization and has the necessary settings to work with the Semihosting capabilities of CCS.

    If I recall correctly, the init.S is a custom init file provided by Starterware to be used with their own projects. I don't recall if Starterware uses GCC or the TI ARM compiler.

    >>And as far as the errors related to the linker script file, do you mean that i should choose a different linker script file depending on my application?
    Yes, you answered your own question. The presence of interrupt service routines and other hardware-related constructs will require modifications to the linker script and (sometimes) to the init.S file. It is not uncommon to have other startup files involved in the process as well.

    >>for example AM335x.cmd and dmtimerCounter.cmd
    This actually answers my previous doubt: the extension .cmd indicates the Starterware projects use, in fact, the TI ARM compiler (the GCC traditionally uses .lds or .ld for the linker scripts).

    Hope this helps,
    Rafael
  • Thank you again for your response!!!

    Your help is really valuable to me..

    Well i guess then that i will have to find the proper linker script file and/or init...or learn how to make them..(any help here would be more than welcomed)

    As far as what files are provided by starterware examples they are definitely for TI ARM Compiler but they also provide for GCC under the respective folders..

    Anyway, thanks again!!!

  • Hi,

    If you are starting your development now, one detail you may be interested to learn is the existence of the Processor SDK based on a RTOS. This is a more modern package that has full support and most probably has several new features and improvements.

    Check it at:

    http://www.ti.com/tool/processor-sdk-am335x

    Regards,

    Rafael 

  • Hey again,

    i am sorry for writing here again but firstly i was indicated to ask here from sitara's sub-forum and secondly i noticed something that may be more suitable to be asked here..

    In the console of code composer studio, after building my project i get the following description of the error:

    i/ccsv6/tools/compiler/gcc-arm-none-eabi-4_8-2014q3/bin/../lib/gcc/arm-none-eabi/4.8.4/../../../../arm-none-eabi/lib/crt0.o: In function `_start':
    (.text+0x104): undefined reference to `__bss_start__' 
    and the respective for __bss_end__


    Now i guess that somehow, the file crt0.o is that creates my problem..Is that the case and what should i do?

    Also, i have come to realize that maybe i am not using the right compilation and linkers flags..So could you please help me with that?
    After setting my project for gcc compiler i only added the following options:

    • -mfpu : vfpv3
    • -mfloat-abi : softfp

    My target is beaglebone white.

    If you need more info please let me know, or if i should post it in an other subforum..

    Thanks in advance

  • Hi,

    As a general statement you should require a .specs file to select which runtime you are going to use: nosys for absolutely no support for semihosting and minimal footprint or rdimon for full support for semihosting (printf, etc.). This option is set at:

    Also, starting with a specific version of GCC (IIRC 4.8.x), when setting this option it is recommended to remove the linker references to libc, libgcc and libnosys/librdimon. If you are using libm or others, then pass them as options as shown below:

     

    The -mfpu and -mfloat-abi are optional but depend on how other supporting libraries were built - you can't link a library build with "softfp" and an object file with "hard", for example.  Therefore you could try with the maximum performance options - i.e., using -mfloat-abi=hard (uses the hardware floating point unit) and -mfpu=vfpv3 or -mfpu=neon and see if the project builds fine.

    Hope this helps, 

    Rafael

  • Hey again,

    well i guess picking some (necessary) compiler and linker flags made a difference, since i finally managed to build successfully the project.
    The problem though is that now when starting the debugging session, the executable loads and starts running immediately without me pressing the run button...Instead i only get the option to pause or stop it. This would not be really a problem if it actually worked as wanted...But the case is that the program seems like not running at all (the board, beaglebone, seems like there is no executable loaded)...Moreover i don't have the option to debug as none of the relative buttons-options are available...

    So three questions,

    1. do you have any idea what is going on? i mean why it seems like no executable is loaded and why can't i start it along with the debugging tools?
    2. can this be a problem relative to the flags i have chosen? maybe an other set would not create that problem?
    3. as you mentioned, with .specs file i can't use some libraries...so which runtime support library should be chosen?

    Thanks in advance and sorry for the trouble

  • CCS automatically "runs to main" when you load a program. You can change this by going to Properties -> Debug and de-selecting "On a program load or restart." For CCS 6.2, right-click your project and select "Properties." Click "Debug." In the window, click "Auto Run and Launch Options." Look under "Auto Run Options."
  • Thank you for your reply,

    but unfortunately it didn't work...Again when i started debugging, the window of progress of loading just popped up and immediately disappeared (with no sign of progress) and in the debug mode the run option is not available along with other debug tools, except for pause and stop..In the meantime there is no error in the console...

    Is that an issue of code composer (although it seems to work just fine with other programs) or the executable that is produced is to be blamed?

    Also if you have any answers for my other questions in my previous post i would be really grateful..

    Thanks again