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.

assembly branch to C function link error

Other Parts Discussed in Thread: DM3730

Hello,

I'm writing code for C64x+ DSP inside DM3730 using CCS v5.5. I have the following assembly code: 

.global _vectors
.global _vector0
.global _vector1
.global _vector2
.global _vector3
.global _vector4
.global _vector5
.global _vector6
.global _vector7
.global _vector8
.global _vector9
.global _vector10
.global _vector11
.global _vector12
.global _vector13
.global _vector14
.global _vector15

.ref code_start
.ref gpTimer5_isr_dsp

;------------------------------------------------------------------------------
; This is a macro that instantiates one entry in the interrupt service table.
;------------------------------------------------------------------------------
VEC_ENTRY .macro addr
STW B0,*B15--
STW A0,*B15--
STW B1,*B15--
STW B2,*B15--
STW B3,*B15--
STW B4,*B15--
MVKL addr,B0
MVKH addr,B0
B B0
LDW *++B15,B4
LDW *++B15,B3
LDW *++B15,B2
LDW *++B15,B1
LDW *++B15,B0
LDW *++B15,A0
LDW *++B15,B0
B IRP
NOP 5
.endm

;------------------------------------------------------------------------------
; This is a dummy interrupt service routine used to initialize the IST.
;------------------------------------------------------------------------------
_vec_dummy:
B B3
NOP 5

;------------------------------------------------------------------------------
; This is the actual interrupt service table (IST). It is properly aligned and
; is located in the subsection .text:vecs. This means if you don't explicitly
; specify this section in your linker command file, it will default and link
; into the .text section. Remember to set the ISTP register to point to this
; table.
;------------------------------------------------------------------------------
.sect ".text"
.align 1024

_vectors:
_vector0: VEC_ENTRY code_start ;RESET
_vector1: VEC_ENTRY _vec_dummy ;NMI
_vector2: VEC_ENTRY _vec_dummy ;RSVD
_vector3: VEC_ENTRY _vec_dummy
_vector4: VEC_ENTRY gpTimer5_isr_dsp ;INT4
_vector5: VEC_ENTRY _vec_dummy
_vector6: VEC_ENTRY _vec_dummy
_vector7: VEC_ENTRY _vec_dummy
_vector8: VEC_ENTRY _vec_dummy
_vector9: VEC_ENTRY _vec_dummy
_vector10: VEC_ENTRY _vec_dummy
_vector11: VEC_ENTRY _vec_dummy
_vector12: VEC_ENTRY _vec_dummy
_vector13: VEC_ENTRY _vec_dummy
_vector14: VEC_ENTRY _vec_dummy
_vector15: VEC_ENTRY _vec_dummy

gpTimer5_isr_dsp function is defined in other file. When i build the whole project, i got a link error #10234-D: unresolved symbols remain. Below is the output of the build. Why do i get a link error even though i already reference the function with ".ref" directive? am i missing something? any help is greatly appreciated. THANKS! 

'Building target: Mentis_DSP.out'
'Invoking: C6000 Linker'
"C:/ti/ccsv5/tools/compiler/c6000_7.4.4/bin/cl6x" -mv64+ --abi=coffabi -g --define=dm3730 --define=DSP_CORE --display_error_number --diag_warning=225 --diag_wrap=off -k -z --stack_size=0x800 -m"Mentis_DSP.map" --heap_size=0x800 -i"C:/ti/ccsv5/tools/compiler/c6000_7.4.4/lib" -i"C:/ti/ccsv5/tools/compiler/c6000_7.4.4/include" --reread_libs --define=DSP_CORE=1 --warn_sections --display_error_number --diag_suppress=10063 --diag_wrap=off --xml_link_info="Mentis_DSP_linkInfo.xml" --entry_point=code_start --rom_model -o "Mentis_DSP.out" "./CPU_Peripheral/serial.obj" "./CPU_Peripheral/ns16550.obj" "./CPU_Peripheral/mailbox.obj" "./CPU_Peripheral/gpTimer.obj" "./CPU_Peripheral/dma.obj" "./printf.obj" "./DSP_main.obj" "./DSP_interruptASM.obj" "./DSP_interrupt.obj" "./DSP_codeStart.obj" "../DM3730.cmd" -l"libc.a"
<Linking>

undefined first referenced
symbol in file
--------- ----------------
gpTimer5_isr_dsp ./DSP_interruptASM.obj

error #10234-D: unresolved symbols remain

error #10010: errors encountered during linking; "Mentis_DSP.out" not built

  • Aristo,

    The best advice I can give you is to not write C6000 assembly. Use the Run Time Support library that we give you for free. Use the SYS/BIOS OS that we give you for free. But any assembly work should only be after studying the assembly output of the compiler and the contents of example files that we offer, such as vectors.asm or such.

    Where did you get your starting point for your VEC_ENTRY macro? This is not how it should be written. We already have examples in the device and DSK/EVM support files.

    Try putting _ in front of each instance of your external label. It might get past the build, but the only way to accurately tell you everything that is wrong with this file is to tell you to look at our examples we have already written and use that instead.

    Regards,
    RandyP

  • Hi Randy,

    Thanks for the reply. I got my problem resolved by putting _ in front of each instance of your external label as you said.

    Regards,

    Aristo Wibawa

  • Aristo,

    It builds now, with the _ prefix. Does the code work as shown in this thread with that fix? Or are you debugging that now?

    My previous comments and questions still stand. You cannot mix ISR code and vector entry code, for example.

    Regards,
    RandyP

  • Hi Randy,

    Sorry, it takes a long time for me to reply this thread. Here's my final code for the interrupt vector table:

    .ref _c_int00
    .ref _dsp_interrupt_defaultIsr
    .ref _gpTimer5_isr_dsp
    .ref _mailbox_isr_dsp

    .sect "codestart"
    .global code_start


    code_start:
    b _c_int00 ;Reset
    nop 9
    nop 9
    nop 9
    nop 9
    nop 9
    nop 9
    nop 9

    ;------------------------------------------------------------------------------
    ; This is the actual interrupt service table (IST). It is properly aligned because
    ; of the NOP instruction. The interrupt service packet can only fit 8 32-byte
    ; instructions, therefore, this ISR actually branch to the actual ISR from the
    ; interrupt source.
    ;------------------------------------------------------------------------------

    _vector1:
    b _dsp_interrupt_defaultIsr ;NMI
    nop 9
    nop 9
    nop 9
    nop 9
    nop 9
    nop 9
    nop 9

    _vector2:
    b _dsp_interrupt_defaultIsr ;reserved (not used)
    nop 9
    nop 9
    nop 9
    nop 9
    nop 9
    nop 9
    nop 9

    _vector3:
    b _dsp_interrupt_defaultIsr ;reserved (not used)
    nop 9
    nop 9
    nop 9
    nop 9
    nop 9
    nop 9
    nop 9

    _vector4:
    b _mailbox_isr_dsp ;INT4
    nop 9
    nop 9
    nop 9
    nop 9
    nop 9
    nop 9
    nop 9

    _vector5:
    b _dsp_interrupt_defaultIsr
    nop 9
    nop 9
    nop 9
    nop 9
    nop 9
    nop 9
    nop 9

    _vector6: ....

    ...

    _vector15: ....

    regards,

    Aristo Wibawa

  • Aristo,

    Thanks for the reply back. Please let us know when you make the next change, since you seem to be gradually developing the code that we supply in the software packages. It will be a painful process, but you will be very well educated on the DSP code when you get finished, and your sequences of code will help others the way you have annotated it with the reasons for your changes.

    I recommend changing the first nop 9 after each b instruction to a nop 5. This might not be a real problem, but the DSP expects a 5 cycle delay after the b instruction.

    Regards,
    RandyP