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.

MSP430FR6047: GCC 9.3.1 compiler error. Code Model differs

Part Number: MSP430FR6047


Tool/software:

Hi,

I have the following issue (Example):

[build] /opt/ti/msp430/gcc/bin/../lib/gcc/msp430-elf/9.3.1/../../../../msp430-elf/bin/ld: error: /opt/ti/msp430/gcc/msp430-elf/lib/libc.a(lib_a-fflush.o) uses the small code model whereas /opt/ti/msp430/gcc/bin/../lib/gcc/msp430-elf/9.3.1/../../../../msp430-elf/lib/large/crt0.o uses the large code model
[build] /opt/ti/msp430/gcc/bin/../lib/gcc/msp430-elf/9.3.1/../../../../msp430-elf/bin/ld: error: /opt/ti/msp430/gcc/msp430-elf/lib/libc.a(lib_a-fflush.o) uses the small data model whereas /opt/ti/msp430/gcc/bin/../lib/gcc/msp430-elf/9.3.1/../../../../msp430-elf/lib/large/crt0.o uses the large data model
the -mlarge flag I already set 
But I do not know how to say the compiler that he should use the large code model library.
  • Hi Tunguskar,

    Which library are you trying to compile?

    The -mlarge flag should set to do large bit addressing which would be the typical "large code model". We can open the whole memory space by setting the regions. 

    You can set the code and data regions to upper, lower, either, or none. Upper is the upper 64kB, lower is the lower 64kB, either will place data in any place it can fit and none will not add any sections if not predefined.

    If you set to the data region to either, this would be the most similar to the MSP430 compilers handling of a large data model.

    Regards,
    Luke

  • The problem is that both the large and small model libraries are being selected. I can't tell how you managed to do that as the -mlarge tells gcc to use the large libraries. The complete command line to gcc would help there.

    The usual way to get this error is to compile something with both "-c" and "-mlarge" and then later link without "-mlarge". This commonly happens when the makefile is changed. "make -B" is how I deal with that.

  • [build] [1/1] Linking CXX executable tests/pin_target_tests
    [build] FAILED: tests/pin_target_tests
    /opt/ti/msp430/gcc/bin/msp430-elf-g++ -O2 -g -DNDEBUG  -O2 -g -DNDEBUG -mhwmult=f5series -Og -g -gdwarf-3 -gstrict-dwarf -Wall -mcode-region=none -mlarge -Wl,--gc-sections -mmcu=MSP430FR6047 -T /opt/ti/msp430/gcc/include/msp430fr6047.ld tests/CMakeFiles/pin_target_tests.dir/test_target_pin.cpp.obj tests/CMakeFiles/pin_target_tests.dir/app/generic/ep_app.c.obj -o tests/pin_target_tests -L/opt/ti/msp430/gcc/msp430-elf/lib   -L/opt/ti/msp430/gcc/include tests/bsp/libtarget_bsp.a  _deps/msp430-driver-lib-build/src/MSP430FR5xx_6xx/libmsp430fr5xx_6xx_driverlib.a && cd /home/developer/repos/hal_drivers_msp430fr5xx_6xx_pin/build/msp430-gcc-ninja-rel-with-deb-info-local/tests && /opt/cmake/3.28.3/bin/cmake -E copy pin_target_tests pin_target_tests.elf && cd /home/developer/repos/hal_drivers_msp430fr5xx_6xx_pin/build/msp430-gcc-ninja-rel-with-deb-info-local/tests && /opt/ti/msp430/gcc/bin/msp430-elf-objcopy -I elf32-msp430 -O ihex pin_target_tests.elf pin_target_tests.hex && cd /home/developer/repos/hal_drivers_msp430fr5xx_6xx_pin/build/msp430-gcc-ninja-rel-with-deb-info-local/tests && /opt/ti/msp430/gcc/bin/msp430-elf-size /home/developer/repos/hal_drivers_msp430fr5xx_6xx_pin/build/msp430-gcc-ninja-rel-with-deb-info-local/tests/pin_target_tests
  • the error happens mainly on the libc.a. I include the library path like this: 

    find_path(

      TOOLCHAIN_STANDARD_LIBRARIES "libc.a"
      HINTS ${TOOLCHAIN_ROOT_DIR}
      PATH_SUFFIXES msp430-elf/lib
      NO_DEFAULT_PATH REQUIRED)
    it seems like the lib is found but not the large model is used.
  • GCC needs no help locating libc so I have no idea what you are doing here. In any case, the large model version of libc.a resides in another directory. I see eight different versions of libc.a and I have no idea what they are all for. GCC does so let it keep track of them.

    It does need help finding the device headers (msp430.h) and linker scripts.

**Attention** This is a public forum