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.

MSP430-GCC-OPENSOURCE: Errors Building MSP430 GCC in SlickEdit

Part Number: MSP430-GCC-OPENSOURCE
Other Parts Discussed in Thread: MSP430FR2675, MSP430WARE

I'm getting an "undefined reference to `WDTCTL`" error when I try to build a simple hello world project for MSP430 GCC in SlickEdit, even though I have __MSP430FR2675__ defined.  My source, makefile, and build output follow.  Any ideas?


#include <stdio.h>
#include "msp430.h"

int main (void)
{
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;

for (int i = 0; ; ++i) {
printf("Hello world!\n");
}

return 0;
}


# SlickEdit generated file. Do not edit this file except in designated areas.

# Make command to use for dependencies
MAKE=make
RM=rm
MKDIR=mkdir

# -----Begin user-editable area-----

# -----End user-editable area-----

# If no configuration is specified, "Debug" will be used
ifndef CFG
CFG=Debug
endif

#
# Configuration: Debug
#
ifeq "$(CFG)" "Debug"
OUTDIR=Debug
OUTFILE=$(OUTDIR)/SlickEditHello
CFG_INC=-I../../ti/msp430-gcc/include \
-I/Applications/ti/msp/MSP430Ware_3_80_13_03/driverlib
CFG_LIB=
CFG_OBJ=
COMMON_OBJ=$(OUTDIR)/SlickEditHello.o
OBJ=$(COMMON_OBJ) $(CFG_OBJ)
ALL_OBJ=$(OUTDIR)/SlickEditHello.o

COMPILE=/Users/pcpro178/ti/msp430-gcc/bin/msp430-elf-gcc -c -v "-D__MSP430FR2675__" -g -o "$(OUTDIR)/$(*F).o" $(CFG_INC) $<
LINK=/Users/pcpro178/ti/msp430-gcc/bin/msp430-elf-ld -v -g -o "$(OUTFILE)" $(ALL_OBJ)
COMPILE_ADA=gnat -g -c -o "$(OUTDIR)/$(*F).o" "$<"
COMPILE_ADB=gnat -g -c -o "$(OUTDIR)/$(*F).o" "$<"
COMPILE_F=gfortran -c -g -o "$(OUTDIR)/$(*F).o" "$<"
COMPILE_F90=gfortran -c -g -o "$(OUTDIR)/$(*F).o" "$<"
COMPILE_D=gdc -c -g -o "$(OUTDIR)/$(*F).o" "$<"

# Pattern rules
$(OUTDIR)/%.o : %.d
$(COMPILE_D)

$(OUTDIR)/%.o : %.f90
$(COMPILE_F90)

$(OUTDIR)/%.o : %.f
$(COMPILE_F)

$(OUTDIR)/%.o : %.ada
$(COMPILE_ADA)

$(OUTDIR)/%.o : %.c
$(COMPILE)

$(OUTDIR)/%.o : %.adb
$(COMPILE_ADB)

# Build rules
all: $(OUTFILE)

$(OUTFILE): $(OUTDIR) $(OBJ)
$(LINK)

$(OUTDIR):
$(MKDIR) -p "$(OUTDIR)"

# Rebuild this project
rebuild: cleanall
@$(MAKE) -f "$(strip $(MAKEFILE_LIST))" $(MAKEFLAGS) all

# Clean this project
clean:
$(RM) -f $(OUTFILE)
$(RM) -f $(OBJ)

# Clean this project and all dependencies
cleanall: clean
endif

#
# Configuration: Release
#
ifeq "$(CFG)" "Release"
OUTDIR=Release
OUTFILE=$(OUTDIR)/SlickEditHello
CFG_INC=-I../../ti/msp430-gcc/include \
-I/Applications/ti/msp/MSP430Ware_3_80_13_03/driverlib
CFG_LIB=
CFG_OBJ=
COMMON_OBJ=$(OUTDIR)/SlickEditHello.o
OBJ=$(COMMON_OBJ) $(CFG_OBJ)
ALL_OBJ=$(OUTDIR)/SlickEditHello.o

COMPILE=/Users/pcpro178/ti/msp430-gcc/bin/msp430-elf-gcc -c -v -o "$(OUTDIR)/$(*F).o" $(CFG_INC) $<
LINK=/Users/pcpro178/ti/msp430-gcc/bin/msp430-elf-ld -v -o "$(OUTFILE)" $(ALL_OBJ)
COMPILE_ADA=gnat -O -c -o "$(OUTDIR)/$(*F).o" "$<"
COMPILE_ADB=gnat -O -c -o "$(OUTDIR)/$(*F).o" "$<"
COMPILE_F=gfortran -O -g -o "$(OUTDIR)/$(*F).o" "$<"
COMPILE_F90=gfortran -O -g -o "$(OUTDIR)/$(*F).o" "$<"
COMPILE_D=gdc -c -g -o "$(OUTDIR)/$(*F).o" "$<"

# Pattern rules
$(OUTDIR)/%.o : %.d
$(COMPILE_D)

$(OUTDIR)/%.o : %.f90
$(COMPILE_F90)

$(OUTDIR)/%.o : %.f
$(COMPILE_F)

$(OUTDIR)/%.o : %.ada
$(COMPILE_ADA)

$(OUTDIR)/%.o : %.c
$(COMPILE)

$(OUTDIR)/%.o : %.adb
$(COMPILE_ADB)

# Build rules
all: $(OUTFILE)

$(OUTFILE): $(OUTDIR) $(OBJ)
$(LINK)

$(OUTDIR):
$(MKDIR) -p "$(OUTDIR)"

# Rebuild this project
rebuild: cleanall
@$(MAKE) -f "$(strip $(MAKEFILE_LIST))" $(MAKEFLAGS) all

# Clean this project
clean:
$(RM) -f $(OUTFILE)
$(RM) -f $(OBJ)

# Clean this project and all dependencies
cleanall: clean
endif

#
# include dependencies:
#
$(OUTDIR)/SlickEditHello.o: SlickEditHello.c ../../ti/msp430-gcc/include/msp430.h


[SE pcpro178@MBP-C02FD3MPMD6T SlickEditHello]$ /Applications/SlickEditPro2021.app/Contents/MacOS/vsbuild rebuild -v -c Debug -hidevep /Users/pcpro178/Desktop/SlickEditHello/SlickEditHello.vpw /Users/pcpro178/Desktop/SlickEditHello/SlickEditHello.vpj -signal 50861
vsbuild: No dependencies for /Users/pcpro178/Desktop/SlickEditHello/SlickEditHello.vpj
vsbuild: ---------- 'rebuild' Project: 'SlickEditHello.vpj' - 'Debug' ----------
VSLICKERRORPATH=/Users/pcpro178/Desktop/SlickEditHello
vsbuild: make -f "/Users/pcpro178/Desktop/SlickEditHello/SlickEditHello.mak" rebuild CFG=Debug
rm -f Debug/SlickEditHello
rm -f Debug/SlickEditHello.o
/Users/pcpro178/ti/msp430-gcc/bin/msp430-elf-gcc -c -v "-D__MSP430FR2675__" -g -o "Debug/SlickEditHello.o" -I../../ti/msp430-gcc/include -I/Applications/ti/msp/MSP430Ware_3_80_13_03/driverlib SlickEditHello.c
Using built-in specs.
COLLECT_GCC=/Users/pcpro178/ti/msp430-gcc/bin/msp430-elf-gcc
Target: msp430-elf
Configured with: ../../gcc/configure --target=msp430-elf --enable-languages=c,c++ --disable-nls --enable-initfini-array --enable-target-optspace --enable-newlib-nano-formatted-io --with-pkgversion='Mitto Systems Limited - msp430-gcc 9.3.1.11'
Thread model: single
gcc version 9.3.1 (Mitto Systems Limited - msp430-gcc 9.3.1.11)
COLLECT_GCC_OPTIONS='-c' '-v' '-D' '__MSP430FR2675__' '-g' '-o' 'Debug/SlickEditHello.o' '-I' '../../ti/msp430-gcc/include' '-I' '/Applications/ti/msp/MSP430Ware_3_80_13_03/driverlib' '-mdevices-csv-loc=../../ti/msp430-gcc/include/devices.csv'
/Users/pcpro178/ti/msp430-gcc/bin/../libexec/gcc/msp430-elf/9.3.1/cc1 -quiet -v -I ../../ti/msp430-gcc/include -I /Applications/ti/msp/MSP430Ware_3_80_13_03/driverlib -iprefix /Users/pcpro178/ti/msp430-gcc/bin/../lib/gcc/msp430-elf/9.3.1/ -D __MSP430FR2675__ SlickEditHello.c -quiet -dumpbase SlickEditHello.c -mdevices-csv-loc=../../ti/msp430-gcc/include/devices.csv -auxbase-strip Debug/SlickEditHello.o -g -version -o /var/folders/qb/05p9w70x0r9cbk1llbvpctmh0000gq/T//ccOh3wNC.s
GNU C17 (Mitto Systems Limited - msp430-gcc 9.3.1.11) version 9.3.1 (msp430-elf)
compiled by GNU C version 4.2.1 Compatible Apple LLVM 11.0.3 (clang-1103.0.32.59), GMP version 6.1.0, MPFR version 3.1.4, MPC version 1.0.3, isl version isl-0.18-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/Users/pcpro178/ti/msp430-gcc/bin/../lib/gcc/msp430-elf/9.3.1/../../../../msp430-elf/sys-include"
ignoring duplicate directory "/Users/pcpro178/ti/msp430-gcc/bin/../lib/gcc/../../lib/gcc/msp430-elf/9.3.1/include"
ignoring duplicate directory "/Users/pcpro178/ti/msp430-gcc/bin/../lib/gcc/../../lib/gcc/msp430-elf/9.3.1/include-fixed"
ignoring nonexistent directory "/Users/pcpro178/ti/msp430-gcc/bin/../lib/gcc/../../lib/gcc/msp430-elf/9.3.1/../../../../msp430-elf/sys-include"
ignoring duplicate directory "/Users/pcpro178/ti/msp430-gcc/bin/../lib/gcc/../../lib/gcc/msp430-elf/9.3.1/../../../../msp430-elf/include"
#include "..." search starts here:
#include <...> search starts here:
../../ti/msp430-gcc/include
/Applications/ti/msp/MSP430Ware_3_80_13_03/driverlib
/Users/pcpro178/ti/msp430-gcc/bin/../lib/gcc/msp430-elf/9.3.1/include
/Users/pcpro178/ti/msp430-gcc/bin/../lib/gcc/msp430-elf/9.3.1/include-fixed
/Users/pcpro178/ti/msp430-gcc/bin/../lib/gcc/msp430-elf/9.3.1/../../../../msp430-elf/include
End of search list.
GNU C17 (Mitto Systems Limited - msp430-gcc 9.3.1.11) version 9.3.1 (msp430-elf)
compiled by GNU C version 4.2.1 Compatible Apple LLVM 11.0.3 (clang-1103.0.32.59), GMP version 6.1.0, MPFR version 3.1.4, MPC version 1.0.3, isl version isl-0.18-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 423dcf60864bff94c13c4735bcdcee2b
COLLECT_GCC_OPTIONS='-c' '-v' '-D' '__MSP430FR2675__' '-g' '-o' 'Debug/SlickEditHello.o' '-I' '../../ti/msp430-gcc/include' '-I' '/Applications/ti/msp/MSP430Ware_3_80_13_03/driverlib' '-mdevices-csv-loc=../../ti/msp430-gcc/include/devices.csv'
/Users/pcpro178/ti/msp430-gcc/bin/../lib/gcc/msp430-elf/9.3.1/../../../../msp430-elf/bin/as --traditional-format -mP -o Debug/SlickEditHello.o /var/folders/qb/05p9w70x0r9cbk1llbvpctmh0000gq/T//ccOh3wNC.s
COMPILER_PATH=/Users/pcpro178/ti/msp430-gcc/bin/../libexec/gcc/msp430-elf/9.3.1/:/Users/pcpro178/ti/msp430-gcc/bin/../libexec/gcc/:/Users/pcpro178/ti/msp430-gcc/bin/../lib/gcc/msp430-elf/9.3.1/../../../../msp430-elf/bin/
LIBRARY_PATH=/Users/pcpro178/ti/msp430-gcc/bin/../lib/gcc/msp430-elf/9.3.1/:/Users/pcpro178/ti/msp430-gcc/bin/../lib/gcc/:/Users/pcpro178/ti/msp430-gcc/bin/../lib/gcc/msp430-elf/9.3.1/../../../../msp430-elf/lib/
COLLECT_GCC_OPTIONS='-c' '-v' '-D' '__MSP430FR2675__' '-g' '-o' 'Debug/SlickEditHello.o' '-I' '../../ti/msp430-gcc/include' '-I' '/Applications/ti/msp/MSP430Ware_3_80_13_03/driverlib' '-mdevices-csv-loc=../../ti/msp430-gcc/include/devices.csv'
/Users/pcpro178/ti/msp430-gcc/bin/msp430-elf-ld -v -g -o "Debug/SlickEditHello" Debug/SlickEditHello.o
GNU ld (Mitto Systems Limited - msp430-gcc 9.3.1.11) 2.34
/Users/pcpro178/ti/msp430-gcc/bin/msp430-elf-ld: Debug/SlickEditHello.o: in function `main':
/Users/pcpro178/Desktop/SlickEditHello//SlickEditHello.c:5: undefined reference to `WDTCTL'
/Users/pcpro178/ti/msp430-gcc/bin/msp430-elf-ld: /Users/pcpro178/Desktop/SlickEditHello//SlickEditHello.c:5: undefined reference to `puts'
make[1]: *** [Debug/SlickEditHello] Error 1
make: *** [rebuild] Error 2
vsbuild: Program returned 2
[SE pcpro178@MBP-C02FD3MPMD6T SlickEditHello]$

  • I have no idea what SlickEdit is but defining a symbol is not the usual way of telling GCC which device you are using. Use -mmcu= instead. As in:

    make -k 
    /usr/ti/gcc/bin/msp430-elf-gcc -g -mmcu=msp430g2253 -I /usr/ti/gcc/include  -Wall  -Wl,--gc-sections timer.c
    

    Symbols for special function registers like WDTCTL are defined in the linker scripts. Since you didn't tell the compiler which device you are using, it is no surprise that this symbol wasn't resolved. See slau646 for more information on using GCC for the MSP430.

**Attention** This is a public forum