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.

MSP430G2001: Cannot link with msp430-elf-ld; the MCU has no upper memory capability

Part Number: MSP430G2001

I managed to install msp430 gcc version 8.2.0 on Linux by compiling in accordance with §5.2 of SLAU646E, followed by a "chmod -R 0:0 install" and a "cp -a install/* /". I upgraded the support files to version 1.207 with the command as root: "install -m755 -d /usr/local/msp430-elf/sys-include" followed by "install -m644 include/* /usr/local/msp430-elf/sys-include".

When trying to make a simple project, everything compiles fine, and a view with the "msp430-elf-size" command shows no components in the ".data" segment.

When trying to use msp430-elf-ld to link everything together using my canned Makefile, I get the following output:

msp430-elf-gcc -mmcu=msp430g2001 -msmall -mrelax -L/usr/local/msp430-elf/sys-include \
 -Wl,-Map,g2_01blink.map -o g2_01blink.elf g2_01blink.o bcm+.o io.o wdt+.o
/usr/local/lib/gcc/msp430-elf/8.2.0/../../../../msp430-elf/bin/ld: error: g2_01blink.elf uses the upper region for data, but g2_01blink.o assumes data is in lower memory.
/usr/local/lib/gcc/msp430-elf/8.2.0/../../../../msp430-elf/bin/ld: failed to merge target specific data of file g2_01blink.o
/usr/local/lib/gcc/msp430-elf/8.2.0/../../../../msp430-elf/bin/ld: error: g2_01blink.elf uses the upper region for data, but bcm+.o assumes data is in lower memory.
/usr/local/lib/gcc/msp430-elf/8.2.0/../../../../msp430-elf/bin/ld: failed to merge target specific data of file bcm+.o
/usr/local/lib/gcc/msp430-elf/8.2.0/../../../../msp430-elf/bin/ld: error: g2_01blink.elf uses the upper region for data, but io.o assumes data is in lower memory.
/usr/local/lib/gcc/msp430-elf/8.2.0/../../../../msp430-elf/bin/ld: failed to merge target specific data of file io.o
/usr/local/lib/gcc/msp430-elf/8.2.0/../../../../msp430-elf/bin/ld: error: g2_01blink.elf uses the upper region for data, but wdt+.o assumes data is in lower memory.
/usr/local/lib/gcc/msp430-elf/8.2.0/../../../../msp430-elf/bin/ld: failed to merge target specific data of file wdt+.o
collect2: error: ld returned 1 exit status
make: *** [makeg2001.mk:19: g2_01blink.elf] Error 1

I have the resulting load map.

I may have to revert back to version 7 if I still have problems.

  • Hi,

    I don't suppose you've passed "-mdata-region=none" at the compilation/assembly stage? If so, then removing that should fix the issue.

    "-mdata-region=none" has a new meaning for 8.2.0 and tells the compiler that data could be in the upper or lower memory regions. Of course, this is only applicable to 430X devices in the large memory model. The next release has this patched so you'll get an error if -mcode/data-region are used without -mlarge.

    If -mdata-region=none isn't the problem, could you please post the msp430-elf-gcc invocation for the object files at the compilation/assembly stage.

    Below links fine for me:

    msp430-elf-gcc -mmcu=msp430g2001 -I/home/jozef/msp430/msp430-gcc-support-files/include -msmall -mrelax -c tester.c -o tester.o
    msp430-elf-gcc -mmcu=msp430g2001 -L/home/jozef/msp430/msp430-gcc-support-files/include -msmall -mrelax -o tester.elf tester.o
    

    Regards,

  • Apologies, I see that the linker think it's the output executable ELF file that is using the upper region for data, not the input object files. So it appears they have been assembled correctly.

    Could you please add "-v -Wl,-v" to this link stage invocation of msp430-elf-gcc and post the output.

    The error comes from the linker checking the object attributes set on the input object files. The output ELF file gets its object attributes from the first object file the linker sees, which should be crt0.o.

    So there could have been a problem building crt0.o, or GCC is picking the wrong one for your device, or something else.

    Thanks and regards, 

  • The output is:

    Using built-in specs.
    COLLECT_GCC=msp430-elf-gcc
    COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/msp430-elf/8.2.0/lto-wrapper
    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=gleepy
    Thread model: single
    gcc version 8.2.0 (gleepy) 
    COMPILER_PATH=/usr/local/libexec/gcc/msp430-elf/8.2.0/:/usr/local/libexec/gcc/msp430-elf/8.2.0/:/usr/local/libexec/gcc/msp430-elf/:/usr/local/lib/gcc/msp430-elf/8.2.0/:/usr/local/lib/gcc/msp430-elf/:/usr/local/lib/gcc/msp430-elf/8.2.0/../../../../msp430-elf/bin/
    LIBRARY_PATH=/usr/local/lib/gcc/msp430-elf/8.2.0/430/:/usr/local/lib/gcc/msp430-elf/8.2.0/../../../../msp430-elf/lib/430/:/usr/local/lib/gcc/msp430-elf/8.2.0/:/usr/local/lib/gcc/msp430-elf/8.2.0/../../../../msp430-elf/lib/
    COLLECT_GCC_OPTIONS='-mmcu=msp430g2001' '-msmall' '-mrelax' '-L/usr/local/msp430-elf/sys-include' '-v' '-o' 'g2_01blink.elf' '-mdevices-csv-loc=/usr/local/msp430-elf/sys-include/devices.csv' '-mcpu=msp430'
     /usr/local/libexec/gcc/msp430-elf/8.2.0/collect2 -plugin /usr/local/libexec/gcc/msp430-elf/8.2.0/liblto_plugin.so -plugin-opt=/usr/local/libexec/gcc/msp430-elf/8.2.0/lto-wrapper -plugin-opt=-fresolution=/tmp/ccrqRNZv.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmul_none -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lcrt -plugin-opt=-pass-through=-lnosys -plugin-opt=-pass-through=-lgcc --relax --gc-sections -o g2_01blink.elf /usr/local/lib/gcc/msp430-elf/8.2.0/../../../../msp430-elf/lib/430/crt0.o /usr/local/lib/gcc/msp430-elf/8.2.0/430/crtbegin_no_eh.o -L/usr/local/msp430-elf/sys-include -L/usr/local/lib/gcc/msp430-elf/8.2.0/430 -L/usr/local/lib/gcc/msp430-elf/8.2.0/../../../../msp430-elf/lib/430 -L/usr/local/lib/gcc/msp430-elf/8.2.0 -L/usr/local/lib/gcc/msp430-elf/8.2.0/../../../../msp430-elf/lib -v -Map g2_01blink.map g2_01blink.o bcm+.o io.o wdt+.o -lgcc --start-group -lmul_none -lc -lgcc -lcrt -lnosys --end-group --script=msp430g2001.ld -lgcc /usr/local/lib/gcc/msp430-elf/8.2.0/430/crtend_no_eh.o /usr/local/lib/gcc/msp430-elf/8.2.0/../../../../msp430-elf/lib/430/crtn.o -lgcc
    collect2 version 8.2.0
    /usr/local/lib/gcc/msp430-elf/8.2.0/../../../../msp430-elf/bin/ld -plugin /usr/local/libexec/gcc/msp430-elf/8.2.0/liblto_plugin.so -plugin-opt=/usr/local/libexec/gcc/msp430-elf/8.2.0/lto-wrapper -plugin-opt=-fresolution=/tmp/ccrqRNZv.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmul_none -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lcrt -plugin-opt=-pass-through=-lnosys -plugin-opt=-pass-through=-lgcc --relax --gc-sections -o g2_01blink.elf /usr/local/lib/gcc/msp430-elf/8.2.0/../../../../msp430-elf/lib/430/crt0.o /usr/local/lib/gcc/msp430-elf/8.2.0/430/crtbegin_no_eh.o -L/usr/local/msp430-elf/sys-include -L/usr/local/lib/gcc/msp430-elf/8.2.0/430 -L/usr/local/lib/gcc/msp430-elf/8.2.0/../../../../msp430-elf/lib/430 -L/usr/local/lib/gcc/msp430-elf/8.2.0 -L/usr/local/lib/gcc/msp430-elf/8.2.0/../../../../msp430-elf/lib -v -Map g2_01blink.map g2_01blink.o bcm+.o io.o wdt+.o -lgcc --start-group -lmul_none -lc -lgcc -lcrt -lnosys --end-group --script=msp430g2001.ld -lgcc /usr/local/lib/gcc/msp430-elf/8.2.0/430/crtend_no_eh.o /usr/local/lib/gcc/msp430-elf/8.2.0/../../../../msp430-elf/lib/430/crtn.o -lgcc
    GNU ld (gleepy) 2.26.20160125
    /usr/local/lib/gcc/msp430-elf/8.2.0/../../../../msp430-elf/bin/ld: error: g2_01blink.elf uses the upper region for data, but g2_01blink.o assumes data is in lower memory.
    /usr/local/lib/gcc/msp430-elf/8.2.0/../../../../msp430-elf/bin/ld: failed to merge target specific data of file g2_01blink.o
    /usr/local/lib/gcc/msp430-elf/8.2.0/../../../../msp430-elf/bin/ld: error: g2_01blink.elf uses the upper region for data, but bcm+.o assumes data is in lower memory.
    /usr/local/lib/gcc/msp430-elf/8.2.0/../../../../msp430-elf/bin/ld: failed to merge target specific data of file bcm+.o
    /usr/local/lib/gcc/msp430-elf/8.2.0/../../../../msp430-elf/bin/ld: error: g2_01blink.elf uses the upper region for data, but io.o assumes data is in lower memory.
    /usr/local/lib/gcc/msp430-elf/8.2.0/../../../../msp430-elf/bin/ld: failed to merge target specific data of file io.o
    /usr/local/lib/gcc/msp430-elf/8.2.0/../../../../msp430-elf/bin/ld: error: g2_01blink.elf uses the upper region for data, but wdt+.o assumes data is in lower memory.
    /usr/local/lib/gcc/msp430-elf/8.2.0/../../../../msp430-elf/bin/ld: failed to merge target specific data of file wdt+.o
    collect2: error: ld returned 1 exit status

  • Thanks. I rebuilt the toolchain myself using 8.2.0.52-source-full and took your exact ld invocation after after fixing up the toolchain paths to match my system I could not reproduce it.

    If I replace the path to crt0.o with the path to crt0.o from 7.3.2.154, then I get the same error as you.

    Something that could have happened is that when you built the toolchain, "msp430-elf-as" from 7.3.2.154 was on your path. So the GCC build used the old assembler to built crt0.o (and the other CRT objects), these don't have the new "data region" object attribute it looks for to verify the data region is the same between object files.

    I wouldn't expect this to be possible if you used the README-build.sh script unmodified however, since there is a line before building GCC which puts the just built assembler on the path BEFORE anything else.

    export PATH=$PWD/../../install/usr/local/bin:$PATH

    Can you post the output of "readelf -A /usr/local/lib/gcc/msp430-elf/8.2.0/../../../../msp430-elf/lib/430/crt0.o"

    crt0.o from 7.3.2 will look like this:

    Attribute Section: mspabi
    File Attributes
      Tag_ISA: MSP430
      Tag_Code_Model: Small
      Tag_Data_Model: Small
    

    crt0.o from 8.2.0 will look like this (the tag isn't displayed properly but note Tag number 10 and tag value 1. 1 is for lower region 2 is for upper region):

    Attribute Section: mspabi
    File Attributes
      Tag_ISA: MSP430
      Tag_Code_Model: Small
      Tag_Data_Model: Small
      <unknown tag 10>: 1 (0x1)
  • I ended up rebuilding the whole thing.

    Before rebuild, the readelf command issued this:

    Attribute Section: mspabi
    File Attributes
      Tag_ISA: MSP430
      Tag_Code_Model: Small
      Tag_Data_Model: Small
    

    After rebuild, it was this:

    Attribute Section: mspabi
    File Attributes
      Tag_ISA: MSP430
      Tag_Code_Model: Small
      Tag_Data_Model: Small
      <unknown tag 10>: 1 (0x1)
    

  • I forgot to say that I have a successful compile. "msp430-elf-size -A g2_01blink.elf" yields the following:

    g2_01blink.elf  :
    section              size    addr
    __reset_vector          2   65534
    .rodata                 0   65024
    .rodata2                4   65024
    .text                 132   65028
    .data                   0     512
    .bss                    0     512
    .noinit                 0     512
    .heap                   4     512
    .MSP430.attributes     25       0
    .comment               20       0
    .debug_aranges        264       0
    .debug_info          2677       0
    .debug_abbrev         718       0
    .debug_line          1114       0
    .debug_frame          160       0
    .debug_str            483       0
    .debug_ranges         136       0
    Total                5739
    

    I have a note in my building instructions to erase the old version from /usr/local/bin first before building a new one.

**Attention** This is a public forum