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.

Linker error [E0300] when assembling asm project with two files.

Other Parts Discussed in Thread: MSP430FR5739

Hi

I am trying to build a simple assembly project for the MSP430FR5739. I have made an simple project where I have two files "testinclude.asm" and "main.asm" but get an [E0300] error when linking. The source is as follows:

testinclude.asm:

****************************************************************

     .text

     mov.w #1, &ADC10CTL0

****************************************************************

main.asm:

****************************************************************

;-------------------------------------------------------------------------------
; MSP430 Assembler Code Template for use with TI Code Composer Studio
;
;
;-------------------------------------------------------------------------------

    .cdecls C,LIST,"msp430.h" ; Include device header file
    .include "testinclude.asm"

;-------------------------------------------------------------------------------
    .text ; Assemble into program memory
    .retain ; Override ELF conditional linking
; and retain current section
     .retainrefs ; Additionally retain any sections
; that have references to current
; section
;-------------------------------------------------------------------------------
     RESET mov.w #__STACK_END,SP ; Initialize stackpointer
     StopWDT mov.w #WDTPW|WDTHOLD,&WDTCTL ; Stop watchdog timer

;-------------------------------------------------------------------------------
; Main loop here
;-------------------------------------------------------------------------------


;-------------------------------------------------------------------------------
; Stack Pointer definition
;-------------------------------------------------------------------------------
     .global __STACK_END
     .sect .stack

;-------------------------------------------------------------------------------
; Interrupt Vectors
;-------------------------------------------------------------------------------
     .sect ".reset" ; MSP430 RESET Vector
     .short RESET

****************************************************************

I get the following error when linking:


**** Build of configuration Debug for project TestAssembly ****

"C:\\ti\\ccsv5\\utils\\bin\\gmake" -k all
'Building file: ../main.asm'
'Invoking: MSP430 Compiler'
"C:/ti/ccsv5/tools/compiler/msp430_4.1.4/bin/cl430" -vmspx --abi=eabi -g --include_path="C:/ti/ccsv5/ccs_base/msp430/include" --include_path="C:/ti/ccsv5/tools/compiler/msp430_4.1.4/include" --advice:power=all --define=__MSP430FR5739__ --diag_warning=225 --display_error_number --diag_wrap=off --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU40 --printf_support=minimal --preproc_with_compile --preproc_dependency="main.pp" "../main.asm"
'Finished building: ../main.asm'
' '
'Building file: ../testinclude.asm'
'Invoking: MSP430 Compiler'
"C:/ti/ccsv5/tools/compiler/msp430_4.1.4/bin/cl430" -vmspx --abi=eabi -g --include_path="C:/ti/ccsv5/ccs_base/msp430/include" --include_path="C:/ti/ccsv5/tools/compiler/msp430_4.1.4/include" --advice:power=all --define=__MSP430FR5739__ --diag_warning=225 --display_error_number --diag_wrap=off --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU40 --printf_support=minimal --preproc_with_compile --preproc_dependency="testinclude.pp" "../testinclude.asm"
"../testinclude.asm", ERROR! at EOF: [E0300] The following symbols are undefined:
ADC10CTL0

Errors in Source - Assembler Aborted
1 Assembly Error, No Assembly Warnings

>> Compilation failure
gmake: *** [testinclude.obj] Error 1
gmake: Target `all' not remade because of errors.

**** Build Finished ****

Why am I getting an error when accessing the defined symbols in msp430fr5739.cmd from my included file and not from main? Remember that main accesses WDTCTL without an error?

Kind regards,

Mads Nielsen

  • The error is coming when assembling testinclude.asm. You would need to include the device header file in this source file as well so it knows that ADC10CTL0 is defined elsewhere. Just add this line to testinclude.asm and that should allow it build fine:
                .cdecls C,LIST,"msp430.h"

  • Well, that actually doesn't solve the problem, the symbols are still defined in msp430fr5739.cmd are still unresolved.

    What solves the problem is that i need to add the lnk_mps430fr5739.cmd as an include library (the -l option) in the project properties under "Build"->"MSP430 Linker"->"File Search Path". This makes sense, but what does the setting under "General" : "Linker command file" do, besides obviously nothing?

    A second question, bear in mind with me, I come from the 8 bit PIC world. I have excluded all files from build, except my main.asm file. But changes made to the other files aren't recognized per default and and i need to do a Clean before a Build is performed, otherwise my changes will not be assembled. Why aren't changes made to the files being recognized? To my knowledge all other files than the main.asm file should be excluded from build, or am I wrong about that?

    Kind regards,

    Mads Nielsen

  • Mads Nielsen said:
    What solves the problem is that i need to add the lnk_mps430fr5739.cmd as an include library (the -l option) in the project properties under "Build"->"MSP430 Linker"->"File Search Path". This makes sense, but what does the setting under "General" : "Linker command file" do, besides obviously nothing

    When you create a new CCS project (Project->New CCS project), and choose your device as MSP430FR5739, and leave the setting under "General" : "Linker command file" as the default "automatic", then the linker command file lnk_mps430fr5739.cmd should be automatically added to the project. If this is done, there is no need to add the .cmd file as include library under "Build"->"MSP430 Linker"->"File Search Path".

    Are you saying that the lnk_mps430fr5739.cmd did not get automatically added to your project? Are you sure the setting under "General" : "Linker command file" was "automatic" and not "none"?

    Mads Nielsen said:
    I have excluded all files from build, except my main.asm file. But changes made to the other files aren't recognized per default and and i need to do a Clean before a Build is performed, otherwise my changes will not be assembled. Why aren't changes made to the files being recognized? To my knowledge all other files than the main.asm file should be excluded from build, or am I wrong about that?

    I'm not sure I understand what you asking. If all the files except main.asm are excluded from build, they will not be rebuilt. When they are included back into the build, their changes should be picked up and built. Sorry if I am misunderstanding your question - could you please elaborate a bit more?

  • I tried to create a new workspace and project and by any reason I can't explain, it have solved the problem. The new project assembles and links perfectly. By the way, the option "automatic" under "General" : "Linker command file" doesn't exist in my version of code composer studio (Version: 5.3.0.00090). The lnk_msp430fr5739.cmd is chosen by default by code composer studio.

    Thank you for your time and understanding.

    A side note, when developing PIC asm firmware using netbeans all asm files except the main asm file has to be excluded from build, but they will be rebuild if the are included in the main file (or from files included in main) and if they are updated. That was the reasoning behind my last question.

    Regards,

    Mads Nielsen