linking interrupts

Help
2008-12-16
2013-03-06
  • Ken Sallings
    Ken Sallings
    2008-12-16

    I am having a linking problem.  The reset_vector is not being generated and my ISRs are not being referenced in the interrupt vector table.  The interrupt vector table isn't being created.

    Here is my Makefile:

    PROG        = test
    ARCH        = 167
    CPU        = msp430x$(ARCH)

    RM        = rm
    MKDIR        = mkdir

    # Names of object files generated corresponding to each .c and .s file

    OBJ_DIR        = ./obj
    DEP_DIR        = ./dep
    LIB_DIR        = ./lib

    OBJ_FILES   = ${C_FILES:.c=.o} ${A_FILES:.s=.o} ${CXX_FILES:.cc=.o}

    CROSS_COMPILE    = msp430-

    CC        = ${CROSS_COMPILE}gcc
    CXX        = ${CROSS_COMPILE}g++
    AS        = ${CROSS_COMPILE}as
    LD        = ${CROSS_COMPILE}ld
    OBJCOPY        = ${CROSS_COMPILE}objcopy
    ASFLAGS        =
    CFLAGS        = -c -02 -mmcu=${CPU} -g -Wall
    LFLAGS        = -L/usr/local/msp430/lib/gcc-lib/msp430/3.2.3/ -lc -lgcc -A $(ARCH) -m ${CPU}

    C_FILES        =    bulb_timer.c    \             dac.c        \             delay.c        \             dma.c        \             main.c        \             spi_setup.c

    OBJ_FILES    =     $(addprefix ${OBJ_DIR}/, ${C_FILES:.c=.o})    \             $(addprefix ${OBJ_DIR}/, ${A_FILES:.s=.o})    \             $(addprefix ${OBJ_DIR}/, ${CXX_FILES:.cc=.o})

    .PHONY: noarg all clean setup

    all:    setup ${OBJ_FILES}
        ${LD} ${OBJ_FILES} ${LFLAGS} -o ${PROG}.elf
        ${OBJCOPY} -O ihex ${PROG}.elf ${PROG}.hex

    ${OBJ_DIR}/%.o : %.c
        ${CC} ${CFLAGS} -o $@ $<

    setup:  ${OBJ_DIR} ${DEP_DIR} ${LIB_DIR}

    ${OBJ_DIR} :
        ${MKDIR} ${OBJ_DIR}

    ${DEP_DIR} :
        ${MKDIR} ${DEP_DIR}

    ${LIB_DIR} :
        ${MKDIR} ${LIB_DIR}

    noarg:
        @echo "Usage: make [all clean]"

    clean :
        ${RM} -f *.o
        ${RM} -rf ${OBJ_DIR} ${DEP_DIR} ${LIB_DIR}
        ${RM} ${PROG}.elf ${PROG}.hex

     
    • Try
      LFLAGS = -L/usr/local/msp430/lib/gcc-lib/msp430/3.2.3/ -lc -lgcc -A $(ARCH) -m ${CPU} ${CPU} .o
      or just let gcc call linker:

      LFLAGS = -Wl,-lc

      all: setup ${PROG}.elf ${PROG}.hex

      %.elf: ${OBJ_FILES}
      ${CC} ${OBJ_FILES} ${LFLAGS} -o $@ 

      %.hex : %.elf
      ${OBJCOPY} -O ihex $< $@

       
    • Sorry,
      LFLAGS = -L/usr/local/msp430/lib/gcc-lib/msp430/3.2.3/ -lc -lgcc -A $(ARCH) -m ${CPU} crt430x${CPU}.o

      An if you invoke linker by calling ${СС}, gcc locates libraries and startup file itself

       
    • Ken Sallings
      Ken Sallings
      2008-12-16

      If I let msp430-gcc do the linking, then it complains with this:

      /usr/local/msp430/lib/gcc-lib/msp430/3.2.3/msp2/libgcc.a(_copy_data.o)(.init4+0x2): In function `__do_copy_data':
      : undefined reference to `__data_size'
      /usr/local/msp430/lib/gcc-lib/msp430/3.2.3/msp2/libgcc.a(_copy_data.o)(.init4+0xc): In function `__do_copy_data':
      : undefined reference to `__data_load_start'
      /usr/local/msp430/lib/gcc-lib/msp430/3.2.3/msp2/libgcc.a(_clear_bss.o)(.init4+0x2): In function `__do_clear_bss':
      : undefined reference to `__bss_size'

       
    • Ken Sallings
      Ken Sallings
      2008-12-16

      The patch is failing in a lot of places.  I am getting binutils from here ftp://sources.redhat.com/pub/binutils/releases/binutils-2.18.tar.bz2

      I am patching from within the binutils-2.18 directory like this.

      patch -p1 <../binutils-2.18-430X.patch

      Here is the output.

      patching file bfd/archures.c
      Hunk #1 FAILED at 377.
      Hunk #2 FAILED at 389.
      2 out of 2 hunks FAILED -- saving rejects to file bfd/archures.c.rej
      patching file bfd/bfd-in2.h
      Hunk #1 FAILED at 2048.
      Hunk #2 FAILED at 2060.
      Hunk #3 succeeded at 4300 (offset -6 lines).
      2 out of 3 hunks FAILED -- saving rejects to file bfd/bfd-in2.h.rej
      patching file bfd/cpu-msp430.c
      Hunk #1 FAILED at 74.
      1 out of 1 hunk FAILED -- saving rejects to file bfd/cpu-msp430.c.rej
      patching file bfd/elf32-msp430.c
      Hunk #10 FAILED at 997.
      Hunk #11 succeeded at 1016 with fuzz 2 (offset -28 lines).
      Hunk #12 FAILED at 1090.
      Hunk #13 FAILED at 1136.
      3 out of 13 hunks FAILED -- saving rejects to file bfd/elf32-msp430.c.rej
      patching file bfd/libbfd.h
      patching file bfd/reloc.c
      patching file binutils/objdump.c
      patching file gas/config/tc-msp430.c
      Hunk #5 FAILED at 241.
      Hunk #6 FAILED at 350.
      Hunk #7 FAILED at 412.
      Hunk #8 FAILED at 433.
      Hunk #9 succeeded at 394 with fuzz 2 (offset -53 lines).
      Hunk #10 succeeded at 477 (offset -53 lines).
      Hunk #11 succeeded at 532 (offset -53 lines).
      Hunk #12 succeeded at 593 (offset -53 lines).
      Hunk #13 succeeded at 639 (offset -53 lines).
      Hunk #14 succeeded at 753 (offset -53 lines).
      Hunk #15 succeeded at 857 (offset -53 lines).
      Hunk #16 FAILED at 902.
      Hunk #17 FAILED at 918.
      Hunk #18 succeeded at 995 (offset -66 lines).
      Hunk #19 succeeded at 1025 (offset -66 lines).
      Hunk #20 succeeded at 1161 (offset -66 lines).
      Hunk #21 succeeded at 1173 (offset -66 lines).
      Hunk #22 succeeded at 1185 (offset -66 lines).
      Hunk #23 succeeded at 1211 (offset -66 lines).
      Hunk #24 succeeded at 1346 (offset -66 lines).
      Hunk #25 succeeded at 1422 (offset -66 lines).
      Hunk #26 succeeded at 1457 (offset -66 lines).
      Hunk #27 succeeded at 1603 (offset -66 lines).
      Hunk #28 succeeded at 1643 (offset -66 lines).
      Hunk #29 succeeded at 1679 (offset -66 lines).
      Hunk #30 succeeded at 1696 (offset -66 lines).
      Hunk #31 succeeded at 1735 (offset -66 lines).
      Hunk #32 succeeded at 1768 (offset -66 lines).
      Hunk #33 succeeded at 1785 (offset -66 lines).
      Hunk #34 succeeded at 1796 (offset -66 lines).
      Hunk #35 succeeded at 1821 (offset -66 lines).
      Hunk #36 succeeded at 1891 (offset -66 lines).
      Hunk #37 succeeded at 1909 (offset -66 lines).
      Hunk #38 succeeded at 1930 (offset -66 lines).
      Hunk #39 succeeded at 1951 (offset -66 lines).
      Hunk #40 succeeded at 1971 (offset -66 lines).
      Hunk #41 succeeded at 1990 (offset -66 lines).
      Hunk #42 succeeded at 2682 (offset -66 lines).
      Hunk #43 succeeded at 2690 (offset -66 lines).
      Hunk #44 succeeded at 2830 (offset -66 lines).
      Hunk #45 succeeded at 2874 (offset -66 lines).
      Hunk #46 succeeded at 2884 (offset -66 lines).
      Hunk #47 succeeded at 2901 (offset -66 lines).
      6 out of 47 hunks FAILED -- saving rejects to file gas/config/tc-msp430.c.rej
      patching file include/elf/msp430.h
      Hunk #1 FAILED at 36.
      Hunk #2 FAILED at 48.
      Hunk #3 succeeded at 56 (offset -7 lines).
      2 out of 3 hunks FAILED -- saving rejects to file include/elf/msp430.h.rej
      patching file include/opcode/msp430.h
      patching file ld/Makefile.am
      Hunk #1 FAILED at 316.
      Hunk #2 succeeded at 336 (offset -33 lines).
      Hunk #3 FAILED at 362.
      Hunk #4 FAILED at 1434.
      Hunk #5 FAILED at 1634.
      Hunk #6 succeeded at 1538 (offset -169 lines).
      Hunk #7 succeeded at 1574 (offset -169 lines).
      Hunk #8 FAILED at 1614.
      5 out of 8 hunks FAILED -- saving rejects to file ld/Makefile.am.rej
      patching file ld/Makefile.in
      Hunk #1 FAILED at 560.
      Hunk #2 succeeded at 583 (offset -33 lines).
      Hunk #3 FAILED at 609.
      Hunk #4 FAILED at 2260.
      Hunk #5 FAILED at 2460.
      Hunk #6 succeeded at 2364 (offset -169 lines).
      Hunk #7 succeeded at 2400 (offset -169 lines).
      Hunk #8 FAILED at 2440.
      5 out of 8 hunks FAILED -- saving rejects to file ld/Makefile.in.rej
      patching file ld/configure.tgt
      Hunk #1 FAILED at 407.
      1 out of 1 hunk FAILED -- saving rejects to file ld/configure.tgt.rej
      patching file ld/emulparams/msp430all.sh
      Hunk #1 FAILED at 19.
      Hunk #2 FAILED at 28.
      Hunk #3 FAILED at 37.
      Hunk #4 FAILED at 46.
      Hunk #5 FAILED at 64.
      Hunk #6 FAILED at 136.
      Hunk #7 FAILED at 145.
      Hunk #8 FAILED at 152.
      Hunk #9 FAILED at 161.
      Hunk #10 FAILED at 170.
      Hunk #11 FAILED at 179.
      Hunk #12 FAILED at 190.
      Hunk #13 FAILED at 199.
      Hunk #14 FAILED at 208.
      Hunk #15 FAILED at 235.
      Hunk #16 FAILED at 448.
      Hunk #17 FAILED at 458.
      Hunk #18 FAILED at 468.
      Hunk #19 FAILED at 478.
      Hunk #20 FAILED at 488.
      Hunk #21 FAILED at 498.
      Hunk #22 FAILED at 508.
      Hunk #23 FAILED at 518.
      Hunk #24 FAILED at 528.
      Hunk #25 FAILED at 537.
      Hunk #26 FAILED at 546.
      Hunk #27 FAILED at 555.
      Hunk #28 FAILED at 564.
      Hunk #29 FAILED at 573.
      Hunk #30 FAILED at 595.
      Hunk #31 FAILED at 645.
      Hunk #32 FAILED at 652.
      Hunk #33 FAILED at 661.
      Hunk #34 FAILED at 732.
      Hunk #35 FAILED at 739.
      Hunk #36 FAILED at 748.
      36 out of 36 hunks FAILED -- saving rejects to file ld/emulparams/msp430all.sh.rej
      patching file ld/scripttempl/elf32msp430.sc
      Hunk #1 succeeded at 17 with fuzz 1.
      Hunk #2 FAILED at 47.
      Hunk #3 succeeded at 223 (offset -31 lines).
      Hunk #4 succeeded at 262 (offset -31 lines).
      1 out of 4 hunks FAILED -- saving rejects to file ld/scripttempl/elf32msp430.sc.rej
      patching file opcodes/msp430-dis.c
      Hunk #8 FAILED at 665.
      Hunk #9 succeeded at 820 (offset -4 lines).
      1 out of 9 hunks FAILED -- saving rejects to file opcodes/msp430-dis.c.rej

       
    • Ken Sallings
      Ken Sallings
      2008-12-16

      Thank you.  Applying those patches fixed everything.